OSDN Git Service

2004-07-06 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 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2228 effect on the generated code. This may cause your code to be
2229 substantially larger. It may also cause an increase in the amount
2230 of stack required, so it is probably a good idea to turn on stack
2231 checking (see description of stack checking in the GNAT users guide)
2232 when using this pragma.
2233
2234 @node Pragma Inline_Always
2235 @unnumberedsec Pragma Inline_Always
2236 @findex Inline_Always
2237 @noindent
2238 Syntax:
2239
2240 @smallexample @c ada
2241 pragma Inline_Always (NAME [, NAME]);
2242 @end smallexample
2243
2244 @noindent
2245 Similar to pragma @code{Inline} except that inlining is not subject to
2246 the use of option @code{-gnatn} and the inlining happens regardless of
2247 whether this option is used.
2248
2249 @node Pragma Inline_Generic
2250 @unnumberedsec Pragma Inline_Generic
2251 @findex Inline_Generic
2252 @noindent
2253 Syntax:
2254
2255 @smallexample @c ada
2256 pragma Inline_Generic (generic_package_NAME);
2257 @end smallexample
2258
2259 @noindent
2260 This is implemented for compatibility with DEC Ada 83 and is recognized,
2261 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2262 by default when using GNAT@.
2263
2264 @node Pragma Interface
2265 @unnumberedsec Pragma Interface
2266 @findex Interface
2267 @noindent
2268 Syntax:
2269
2270 @smallexample @c ada
2271 pragma Interface (
2272      [Convention    =>] convention_identifier,
2273      [Entity =>] local_name
2274   [, [External_Name =>] static_string_expression],
2275   [, [Link_Name     =>] static_string_expression]);
2276 @end smallexample
2277
2278 @noindent
2279 This pragma is identical in syntax and semantics to
2280 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2281 with Ada 83.  The definition is upwards compatible both with pragma
2282 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2283 with some extended implementations of this pragma in certain Ada 83
2284 implementations.
2285
2286 @node Pragma Interface_Name
2287 @unnumberedsec Pragma Interface_Name
2288 @findex Interface_Name
2289 @noindent
2290 Syntax:
2291
2292 @smallexample @c ada
2293 pragma Interface_Name (
2294      [Entity        =>] LOCAL_NAME
2295   [, [External_Name =>] static_string_EXPRESSION]
2296   [, [Link_Name     =>] static_string_EXPRESSION]);
2297 @end smallexample
2298
2299 @noindent
2300 This pragma provides an alternative way of specifying the interface name
2301 for an interfaced subprogram, and is provided for compatibility with Ada
2302 83 compilers that use the pragma for this purpose.  You must provide at
2303 least one of @var{External_Name} or @var{Link_Name}.
2304
2305 @node Pragma Interrupt_Handler
2306 @unnumberedsec Pragma Interrupt_Handler
2307 @findex Interrupt_Handler
2308 @noindent
2309 Syntax:
2310
2311 @smallexample @c ada
2312 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2313 @end smallexample
2314
2315 @noindent
2316 This program unit pragma is supported for parameterless protected procedures
2317 as described in Annex C of the Ada Reference Manual. On the AAMP target
2318 the pragma can also be specified for nonprotected parameterless procedures
2319 that are declared at the library level (which includes procedures
2320 declared at the top level of a library package). In the case of AAMP,
2321 when this pragma is applied to a nonprotected procedure, the instruction
2322 @code{IERET} is generated for returns from the procedure, enabling
2323 maskable interrupts, in place of the normal return instruction.
2324
2325 @node Pragma Interrupt_State
2326 @unnumberedsec Pragma Interrupt_State
2327 @findex Interrupt_State
2328 @noindent
2329 Syntax:
2330
2331 @smallexample @c ada
2332 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2333 @end smallexample
2334
2335 @noindent
2336 Normally certain interrupts are reserved to the implementation.  Any attempt
2337 to attach an interrupt causes Program_Error to be raised, as described in
2338 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2339 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2340 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2341 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2342 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2343 Ada exceptions, or used to implement run-time functions such as the
2344 @code{abort} statement and stack overflow checking.
2345
2346 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2347 such uses of interrupts.  It subsumes the functionality of pragma
2348 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2349 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2350 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2351 and may be used to mark interrupts required by the board support package
2352 as reserved.
2353
2354 Interrupts can be in one of three states:
2355 @itemize @bullet
2356 @item System
2357
2358 The interrupt is reserved (no Ada handler can be installed), and the
2359 Ada run-time may not install a handler. As a result you are guaranteed
2360 standard system default action if this interrupt is raised.
2361
2362 @item Runtime
2363
2364 The interrupt is reserved (no Ada handler can be installed). The run time
2365 is allowed to install a handler for internal control purposes, but is
2366 not required to do so.
2367
2368 @item User
2369
2370 The interrupt is unreserved.  The user may install a handler to provide
2371 some other action.
2372 @end itemize
2373
2374 @noindent
2375 These states are the allowed values of the @code{State} parameter of the
2376 pragma.  The @code{Name} parameter is a value of the type
2377 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2378 @code{Ada.Interrupts.Names}.
2379
2380 This is a configuration pragma, and the binder will check that there
2381 are no inconsistencies between different units in a partition in how a
2382 given interrupt is specified. It may appear anywhere a pragma is legal.
2383
2384 The effect is to move the interrupt to the specified state.
2385
2386 By declaring interrupts to be SYSTEM, you guarantee the standard system
2387 action, such as a core dump.
2388
2389 By declaring interrupts to be USER, you guarantee that you can install
2390 a handler.
2391
2392 Note that certain signals on many operating systems cannot be caught and
2393 handled by applications.  In such cases, the pragma is ignored.  See the
2394 operating system documentation, or the value of the array @code{Reserved}
2395 declared in the specification of package @code{System.OS_Interface}.
2396
2397 Overriding the default state of signals used by the Ada runtime may interfere
2398 with an application's runtime behavior in the cases of the synchronous signals,
2399 and in the case of the signal used to implement the @code{abort} statement.
2400
2401 @node Pragma Keep_Names
2402 @unnumberedsec Pragma Keep_Names
2403 @findex Keep_Names
2404 @noindent
2405 Syntax:
2406
2407 @smallexample @c ada
2408 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2409 @end smallexample
2410
2411 @noindent
2412 The @var{LOCAL_NAME} argument
2413 must refer to an enumeration first subtype
2414 in the current declarative part. The effect is to retain the enumeration
2415 literal names for use by @code{Image} and @code{Value} even if a global
2416 @code{Discard_Names} pragma applies. This is useful when you want to
2417 generally suppress enumeration literal names and for example you therefore
2418 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2419 want to retain the names for specific enumeration types.
2420
2421 @node Pragma License
2422 @unnumberedsec Pragma License
2423 @findex License
2424 @cindex License checking
2425 @noindent
2426 Syntax:
2427
2428 @smallexample @c ada
2429 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2430 @end smallexample
2431
2432 @noindent
2433 This pragma is provided to allow automated checking for appropriate license
2434 conditions with respect to the standard and modified GPL@.  A pragma
2435 @code{License}, which is a configuration pragma that typically appears at
2436 the start of a source file or in a separate @file{gnat.adc} file, specifies
2437 the licensing conditions of a unit as follows:
2438
2439 @itemize @bullet
2440 @item Unrestricted
2441 This is used for a unit that can be freely used with no license restrictions.
2442 Examples of such units are public domain units, and units from the Ada
2443 Reference Manual.
2444
2445 @item GPL
2446 This is used for a unit that is licensed under the unmodified GPL, and which
2447 therefore cannot be @code{with}'ed by a restricted unit.
2448
2449 @item Modified_GPL
2450 This is used for a unit licensed under the GNAT modified GPL that includes
2451 a special exception paragraph that specifically permits the inclusion of
2452 the unit in programs without requiring the entire program to be released
2453 under the GPL@.  This is the license used for the GNAT run-time which ensures
2454 that the run-time can be used freely in any program without GPL concerns.
2455
2456 @item Restricted
2457 This is used for a unit that is restricted in that it is not permitted to
2458 depend on units that are licensed under the GPL@.  Typical examples are
2459 proprietary code that is to be released under more restrictive license
2460 conditions.  Note that restricted units are permitted to @code{with} units
2461 which are licensed under the modified GPL (this is the whole point of the
2462 modified GPL).
2463
2464 @end itemize
2465
2466 @noindent
2467 Normally a unit with no @code{License} pragma is considered to have an
2468 unknown license, and no checking is done.  However, standard GNAT headers
2469 are recognized, and license information is derived from them as follows.
2470
2471 @itemize @bullet
2472
2473 A GNAT license header starts with a line containing 78 hyphens.  The following
2474 comment text is searched for the appearance of any of the following strings.
2475
2476 If the string ``GNU General Public License'' is found, then the unit is assumed
2477 to have GPL license, unless the string ``As a special exception'' follows, in
2478 which case the license is assumed to be modified GPL@.
2479
2480 If one of the strings
2481 ``This specification is adapted from the Ada Semantic Interface'' or
2482 ``This specification is derived from the Ada Reference Manual'' is found
2483 then the unit is assumed to be unrestricted.
2484 @end itemize
2485
2486 @noindent
2487 These default actions means that a program with a restricted license pragma
2488 will automatically get warnings if a GPL unit is inappropriately
2489 @code{with}'ed.  For example, the program:
2490
2491 @smallexample @c ada
2492 with Sem_Ch3;
2493 with GNAT.Sockets;
2494 procedure Secret_Stuff is
2495   @dots{}
2496 end Secret_Stuff
2497 @end smallexample
2498
2499 @noindent
2500 if compiled with pragma @code{License} (@code{Restricted}) in a
2501 @file{gnat.adc} file will generate the warning:
2502
2503 @smallexample
2504 1.  with Sem_Ch3;
2505         |
2506    >>> license of withed unit "Sem_Ch3" is incompatible
2507
2508 2.  with GNAT.Sockets;
2509 3.  procedure Secret_Stuff is
2510 @end smallexample
2511
2512 @noindent
2513 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2514 compiler and is licensed under the
2515 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2516 run time, and is therefore licensed under the modified GPL@.
2517
2518 @node Pragma Link_With
2519 @unnumberedsec Pragma Link_With
2520 @findex Link_With
2521 @noindent
2522 Syntax:
2523
2524 @smallexample @c ada
2525 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2526 @end smallexample
2527
2528 @noindent
2529 This pragma is provided for compatibility with certain Ada 83 compilers.
2530 It has exactly the same effect as pragma @code{Linker_Options} except
2531 that spaces occurring within one of the string expressions are treated
2532 as separators. For example, in the following case:
2533
2534 @smallexample @c ada
2535 pragma Link_With ("-labc -ldef");
2536 @end smallexample
2537
2538 @noindent
2539 results in passing the strings @code{-labc} and @code{-ldef} as two
2540 separate arguments to the linker. In addition pragma Link_With allows
2541 multiple arguments, with the same effect as successive pragmas.
2542
2543 @node Pragma Linker_Alias
2544 @unnumberedsec Pragma Linker_Alias
2545 @findex Linker_Alias
2546 @noindent
2547 Syntax:
2548
2549 @smallexample @c ada
2550 pragma Linker_Alias (
2551   [Entity =>] LOCAL_NAME
2552   [Alias  =>] static_string_EXPRESSION);
2553 @end smallexample
2554
2555 @noindent
2556 This pragma establishes a linker alias for the given named entity.  For
2557 further details on the exact effect, consult the GCC manual.
2558
2559 @node Pragma Linker_Section
2560 @unnumberedsec Pragma Linker_Section
2561 @findex Linker_Section
2562 @noindent
2563 Syntax:
2564
2565 @smallexample @c ada
2566 pragma Linker_Section (
2567   [Entity  =>] LOCAL_NAME
2568   [Section =>] static_string_EXPRESSION);
2569 @end smallexample
2570
2571 @noindent
2572 This pragma specifies the name of the linker section for the given entity.
2573 For further details on the exact effect, consult the GCC manual.
2574
2575 @node Pragma Long_Float
2576 @unnumberedsec Pragma Long_Float
2577 @cindex OpenVMS
2578 @findex Long_Float
2579 @noindent
2580 Syntax:
2581
2582 @smallexample @c ada
2583 pragma Long_Float (FLOAT_FORMAT);
2584
2585 FLOAT_FORMAT ::= D_Float | G_Float
2586 @end smallexample
2587
2588 @noindent
2589 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2590 It allows control over the internal representation chosen for the predefined
2591 type @code{Long_Float} and for floating point type representations with
2592 @code{digits} specified in the range 7 through 15.
2593 For further details on this pragma, see the
2594 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2595 this pragma, the standard runtime libraries must be recompiled.  See the
2596 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2597 of the GNAT User's Guide for details on the use of this command.
2598
2599 @node Pragma Machine_Attribute
2600 @unnumberedsec Pragma Machine_Attribute
2601 @findex Machine_Attribute
2602 @noindent
2603 Syntax:
2604
2605 @smallexample @c ada
2606 pragma Machine_Attribute (
2607   [Attribute_Name =>] string_EXPRESSION,
2608   [Entity         =>] LOCAL_NAME);
2609 @end smallexample
2610
2611 @noindent
2612 Machine dependent attributes can be specified for types and/or
2613 declarations.  Currently only subprogram entities are supported.  This
2614 pragma is semantically equivalent to
2615 @code{__attribute__((@var{string_expression}))} in GNU C,
2616 where @code{@var{string_expression}} is
2617 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2618 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2619 configuration header file @file{tm.h} for each machine.  See the GCC
2620 manual for further information.
2621
2622 @node Pragma Main_Storage
2623 @unnumberedsec Pragma Main_Storage
2624 @cindex OpenVMS
2625 @findex Main_Storage
2626 @noindent
2627 Syntax:
2628
2629 @smallexample @c ada
2630 pragma Main_Storage
2631   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2632
2633 MAIN_STORAGE_OPTION ::=
2634   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2635 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2636
2637 @end smallexample
2638
2639 @noindent
2640 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2641 no effect in GNAT, other than being syntax checked.  Note that the pragma
2642 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2643
2644 @node Pragma No_Return
2645 @unnumberedsec Pragma No_Return
2646 @findex No_Return
2647 @noindent
2648 Syntax:
2649
2650 @smallexample @c ada
2651 pragma No_Return (procedure_LOCAL_NAME);
2652 @end smallexample
2653
2654 @noindent
2655 @var{procedure_local_NAME} must refer to one or more procedure
2656 declarations in the current declarative part.  A procedure to which this
2657 pragma is applied may not contain any explicit @code{return} statements,
2658 and also may not contain any implicit return statements from falling off
2659 the end of a statement sequence.  One use of this pragma is to identify
2660 procedures whose only purpose is to raise an exception.
2661
2662 Another use of this pragma is to suppress incorrect warnings about
2663 missing returns in functions, where the last statement of a function
2664 statement sequence is a call to such a procedure.
2665
2666 @node Pragma Normalize_Scalars
2667 @unnumberedsec Pragma Normalize_Scalars
2668 @findex Normalize_Scalars
2669 @noindent
2670 Syntax:
2671
2672 @smallexample @c ada
2673 pragma Normalize_Scalars;
2674 @end smallexample
2675
2676 @noindent
2677 This is a language defined pragma which is fully implemented in GNAT@.  The
2678 effect is to cause all scalar objects that are not otherwise initialized
2679 to be initialized.  The initial values are implementation dependent and
2680 are as follows:
2681
2682 @table @code
2683 @item Standard.Character
2684 @noindent
2685 Objects whose root type is Standard.Character are initialized to
2686 Character'Last.  This will be out of range of the subtype only if
2687 the subtype range excludes this value.
2688
2689 @item Standard.Wide_Character
2690 @noindent
2691 Objects whose root type is Standard.Wide_Character are initialized to
2692 Wide_Character'Last.  This will be out of range of the subtype only if
2693 the subtype range excludes this value.
2694
2695 @item Integer types
2696 @noindent
2697 Objects of an integer type are initialized to base_type'First, where
2698 base_type is the base type of the object type.  This will be out of range
2699 of the subtype only if the subtype range excludes this value.  For example,
2700 if you declare the subtype:
2701
2702 @smallexample @c ada
2703 subtype Ityp is integer range 1 .. 10;
2704 @end smallexample
2705
2706 @noindent
2707 then objects of type x will be initialized to Integer'First, a negative
2708 number that is certainly outside the range of subtype @code{Ityp}.
2709
2710 @item Real types
2711 Objects of all real types (fixed and floating) are initialized to
2712 base_type'First, where base_Type is the base type of the object type.
2713 This will be out of range of the subtype only if the subtype range
2714 excludes this value.
2715
2716 @item Modular types
2717 Objects of a modular type are initialized to typ'Last.  This will be out
2718 of range of the subtype only if the subtype excludes this value.
2719
2720 @item Enumeration types
2721 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2722 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2723 enumeration subtype in all cases except where the subtype contains
2724 exactly 2**8, 2**16, or 2**32 elements.
2725
2726 @end table
2727
2728 @node Pragma Obsolescent
2729 @unnumberedsec Pragma Obsolescent
2730 @findex Obsolescent
2731 @noindent
2732 Syntax:
2733
2734 @smallexample @c ada
2735 pragma Obsolescent [(static_string_EXPRESSION)];
2736 @end smallexample
2737
2738 @noindent
2739 This pragma must occur immediately following a subprogram
2740 declaration. It indicates that the associated function or procedure
2741 is considered obsolescent and should not be used. Typically this is
2742 used when an API must be modified by eventually removing or modifying
2743 existing subprograms. The pragma can be used at an intermediate stage
2744 when the subprogram is still present, but will be removed later.
2745
2746 The effect of this pragma is to output a warning message that the
2747 subprogram is obsolescent if the appropriate warning option in the
2748 compiler is activated. If a parameter is present, then a second
2749 warning message is given containing this text.
2750
2751 @node Pragma Passive
2752 @unnumberedsec Pragma Passive
2753 @findex Passive
2754 @noindent
2755 Syntax:
2756
2757 @smallexample @c ada
2758 pragma Passive ([Semaphore | No]);
2759 @end smallexample
2760
2761 @noindent
2762 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2763 compatibility with DEC Ada 83 implementations, where it is used within a
2764 task definition to request that a task be made passive.  If the argument
2765 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2766 treats the pragma as an assertion that the containing task is passive
2767 and that optimization of context switch with this task is permitted and
2768 desired.  If the argument @code{No} is present, the task must not be
2769 optimized.  GNAT does not attempt to optimize any tasks in this manner
2770 (since protected objects are available in place of passive tasks).
2771
2772 @node Pragma Polling
2773 @unnumberedsec Pragma Polling
2774 @findex Polling
2775 @noindent
2776 Syntax:
2777
2778 @smallexample @c ada
2779 pragma Polling (ON | OFF);
2780 @end smallexample
2781
2782 @noindent
2783 This pragma controls the generation of polling code.  This is normally off.
2784 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2785 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2786 runtime library, and can be found in file @file{a-excpol.adb}.
2787
2788 Pragma @code{Polling} can appear as a configuration pragma (for example it
2789 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2790 can be used in the statement or declaration sequence to control polling
2791 more locally.
2792
2793 A call to the polling routine is generated at the start of every loop and
2794 at the start of every subprogram call.  This guarantees that the @code{Poll}
2795 routine is called frequently, and places an upper bound (determined by
2796 the complexity of the code) on the period between two @code{Poll} calls.
2797
2798 The primary purpose of the polling interface is to enable asynchronous
2799 aborts on targets that cannot otherwise support it (for example Windows
2800 NT), but it may be used for any other purpose requiring periodic polling.
2801 The standard version is null, and can be replaced by a user program.  This
2802 will require re-compilation of the @code{Ada.Exceptions} package that can
2803 be found in files @file{a-except.ads} and @file{a-except.adb}.
2804
2805 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2806 distribution) is used to enable the asynchronous abort capability on
2807 targets that do not normally support the capability.  The version of
2808 @code{Poll} in this file makes a call to the appropriate runtime routine
2809 to test for an abort condition.
2810
2811 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2812 the @cite{GNAT User's Guide} for details.
2813
2814 @node Pragma Profile (Ravenscar)
2815 @unnumberedsec Pragma Profile (Ravenscar)
2816 @findex Ravenscar
2817 @noindent
2818 Syntax:
2819
2820 @smallexample @c ada
2821 pragma Profile (Ravenscar);
2822 @end smallexample
2823
2824 @noindent
2825 A configuration pragma that establishes the following set of configuration
2826 pragmas:
2827
2828 @table @code
2829 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2830 [RM D.2.2] Tasks are dispatched following a preemptive
2831 priority-ordered scheduling policy.
2832
2833 @item Locking_Policy (Ceiling_Locking)
2834 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2835 the ceiling priority of the corresponding protected object.
2836 @c
2837 @c @item Detect_Blocking
2838 @c This pragma forces the detection of potentially blocking operations within a
2839 @c protected operation, and to raise Program_Error if that happens.
2840 @end table
2841 @noindent
2842
2843 plus the following set of restrictions:
2844
2845 @table @code
2846 @item Max_Entry_Queue_Length = 1
2847 Defines the maximum number of calls that are queued on a (protected) entry.
2848 Note that this restrictions is checked at run time. Violation of this
2849 restriction results in the raising of Program_Error exception at the point of
2850 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2851 always 1 and hence no task can be queued on a protected entry.
2852
2853 @item Max_Protected_Entries = 1
2854 [RM D.7] Specifies the maximum number of entries per protected type. The
2855 bounds of every entry family of a protected unit shall be static, or shall be
2856 defined by a discriminant of a subtype whose corresponding bound is static.
2857 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
2858
2859 @item Max_Task_Entries = 0
2860 [RM D.7] Specifies the maximum number of entries
2861 per task.  The bounds of every entry family
2862 of a task unit shall be static, or shall be
2863 defined by a discriminant of a subtype whose
2864 corresponding bound is static.  A value of zero
2865 indicates that no rendezvous are possible.  For
2866 the Profile (Ravenscar), the value of Max_Task_Entries is always
2867 0 (zero).
2868
2869 @item No_Abort_Statements
2870 [RM D.7] There are no abort_statements, and there are
2871 no calls to Task_Identification.Abort_Task.
2872
2873 @item No_Asynchronous_Control
2874 [RM D.7] There are no semantic dependences on the package
2875 Asynchronous_Task_Control.
2876
2877 @item No_Calendar
2878 There are no semantic dependencies on the package Ada.Calendar.
2879
2880 @item No_Dynamic_Attachment
2881 There is no call to any of the operations defined in package Ada.Interrupts
2882 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
2883 Detach_Handler, and Reference).
2884
2885 @item No_Dynamic_Priorities
2886 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2887
2888 @item No_Implicit_Heap_Allocations
2889 [RM D.7] No constructs are allowed to cause implicit heap allocation.
2890
2891 @item No_Local_Protected_Objects
2892 Protected objects and access types that designate
2893 such objects shall be declared only at library level.
2894
2895 @item No_Protected_Type_Allocators
2896 There are no allocators for protected types or
2897 types containing protected subcomponents.
2898
2899 @item No_Relative_Delay
2900 There are no delay_relative statements.
2901
2902 @item No_Requeue_Statements
2903 Requeue statements are not allowed.
2904
2905 @item No_Select_Statements
2906 There are no select_statements.
2907
2908 @item No_Task_Allocators
2909 [RM D.7] There are no allocators for task types
2910 or types containing task subcomponents.
2911
2912 @item No_Task_Attributes_Package
2913 There are no semantic dependencies on the Ada.Task_Attributes package.
2914
2915 @item No_Task_Hierarchy
2916 [RM D.7] All (non-environment) tasks depend
2917 directly on the environment task of the partition.
2918
2919 @item No_Task_Termination
2920 Tasks which terminate are erroneous.
2921
2922 @item Simple_Barriers
2923 Entry barrier condition expressions shall be either static
2924 boolean expressions or boolean objects which are declared in
2925 the protected type which contains the entry.
2926 @end table
2927
2928 @noindent
2929 This set of configuration pragmas and restrictions correspond to the
2930 definition of the ``Ravenscar Profile'' for limited tasking, devised and
2931 published by the @cite{International Real-Time Ada Workshop}, 1997,
2932 and whose most recent description is available at
2933 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
2934
2935 The original definition of the profile was revised at subsequent IRTAW
2936 meetings. It has been included in the ISO
2937 @cite{Guide for the Use of the Ada Programming Language in High
2938 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
2939 the next revision of the standard. The formal definition given by
2940 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
2941 AI-305) available at
2942 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
2943 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
2944 respectively.
2945
2946 The above set is a superset of the restrictions provided by pragma
2947 @code{Restricted_Run_Time}, it includes six additional restrictions
2948 (@code{Simple_Barriers}, @code{No_Select_Statements},
2949 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
2950 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
2951 that pragma @code{Profile (Ravenscar)}, like the pragma
2952 @code{Restricted_Run_Time}, automatically causes the use of a simplified,
2953 more efficient version of the tasking run-time system.
2954
2955 @node Pragma Propagate_Exceptions
2956 @unnumberedsec Pragma Propagate_Exceptions
2957 @findex Propagate_Exceptions
2958 @cindex Zero Cost Exceptions
2959 @noindent
2960 Syntax:
2961
2962 @smallexample @c ada
2963 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2964 @end smallexample
2965
2966 @noindent
2967 This pragma indicates that the given entity, which is the name of an
2968 imported foreign-language subprogram may receive an Ada exception,
2969 and that the exception should be propagated.  It is relevant only if
2970 zero cost exception handling is in use, and is thus never needed if
2971 the alternative @code{longjmp} / @code{setjmp} implementation of
2972 exceptions is used (although it is harmless to use it in such cases).
2973
2974 The implementation of fast exceptions always properly propagates
2975 exceptions through Ada code, as described in the Ada Reference Manual.
2976 However, this manual is silent about the propagation of exceptions
2977 through foreign code.  For example, consider the
2978 situation where @code{P1} calls
2979 @code{P2}, and @code{P2} calls @code{P3}, where
2980 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2981 @code{P3} raises an Ada exception.  The question is whether or not
2982 it will be propagated through @code{P2} and can be handled in
2983 @code{P1}.
2984
2985 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
2986 the answer is always yes.  For some targets on which zero cost exception
2987 handling is implemented, the answer is also always yes.  However, there
2988 are some targets, notably in the current version all x86 architecture
2989 targets, in which the answer is that such propagation does not
2990 happen automatically.  If such propagation is required on these
2991 targets, it is mandatory to use @code{Propagate_Exceptions} to
2992 name all foreign language routines through which Ada exceptions
2993 may be propagated.
2994
2995 @node Pragma Psect_Object
2996 @unnumberedsec Pragma Psect_Object
2997 @findex Psect_Object
2998 @noindent
2999 Syntax:
3000
3001 @smallexample @c ada
3002 pragma Psect_Object (
3003      [Internal =>] LOCAL_NAME,
3004   [, [External =>] EXTERNAL_SYMBOL]
3005   [, [Size     =>] EXTERNAL_SYMBOL]);
3006
3007 EXTERNAL_SYMBOL ::=
3008   IDENTIFIER
3009 | static_string_EXPRESSION
3010 @end smallexample
3011
3012 @noindent
3013 This pragma is identical in effect to pragma @code{Common_Object}.
3014
3015 @node Pragma Pure_Function
3016 @unnumberedsec Pragma Pure_Function
3017 @findex Pure_Function
3018 @noindent
3019 Syntax:
3020
3021 @smallexample @c ada
3022 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3023 @end smallexample
3024
3025 @noindent
3026 This pragma appears in the same declarative part as a function
3027 declaration (or a set of function declarations if more than one
3028 overloaded declaration exists, in which case the pragma applies
3029 to all entities).  It specifies that the function @code{Entity} is
3030 to be considered pure for the purposes of code generation.  This means
3031 that the compiler can assume that there are no side effects, and
3032 in particular that two calls with identical arguments produce the
3033 same result.  It also means that the function can be used in an
3034 address clause.
3035
3036 Note that, quite deliberately, there are no static checks to try
3037 to ensure that this promise is met, so @code{Pure_Function} can be used
3038 with functions that are conceptually pure, even if they do modify
3039 global variables.  For example, a square root function that is
3040 instrumented to count the number of times it is called is still
3041 conceptually pure, and can still be optimized, even though it
3042 modifies a global variable (the count).  Memo functions are another
3043 example (where a table of previous calls is kept and consulted to
3044 avoid re-computation).
3045
3046 @findex Pure
3047 Note: Most functions in a @code{Pure} package are automatically pure, and
3048 there is no need to use pragma @code{Pure_Function} for such functions.  One
3049 exception is any function that has at least one formal of type
3050 @code{System.Address} or a type derived from it.  Such functions are not
3051 considered pure by default, since the compiler assumes that the
3052 @code{Address} parameter may be functioning as a pointer and that the
3053 referenced data may change even if the address value does not.
3054 Similarly, imported functions are not considered to be pure by default,
3055 since there is no way of checking that they are in fact pure.  The use
3056 of pragma @code{Pure_Function} for such a function will override these default
3057 assumption, and cause the compiler to treat a designated subprogram as pure
3058 in these cases.
3059
3060 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3061 applies to the underlying renamed function.  This can be used to
3062 disambiguate cases of overloading where some but not all functions
3063 in a set of overloaded functions are to be designated as pure.
3064
3065 @node Pragma Restricted_Run_Time
3066 @unnumberedsec Pragma Restricted_Run_Time
3067 @findex Restricted_Run_Time
3068 @noindent
3069 Syntax:
3070
3071 @smallexample @c ada
3072 pragma Restricted_Run_Time;
3073 @end smallexample
3074
3075 @noindent
3076 A configuration pragma that establishes the following set of restrictions:
3077
3078 @itemize @bullet
3079 @item No_Abort_Statements
3080 @item No_Entry_Queue
3081 @item No_Task_Hierarchy
3082 @item No_Task_Allocators
3083 @item No_Dynamic_Priorities
3084 @item No_Terminate_Alternatives
3085 @item No_Dynamic_Attachment
3086 @item No_Protected_Type_Allocators
3087 @item No_Local_Protected_Objects
3088 @item No_Requeue_Statements
3089 @item No_Task_Attributes_Package
3090 @item Max_Asynchronous_Select_Nesting =  0
3091 @item Max_Task_Entries =  0
3092 @item Max_Protected_Entries = 1
3093 @item Max_Select_Alternatives = 0
3094 @end itemize
3095
3096 @noindent
3097 This set of restrictions causes the automatic selection of a simplified
3098 version of the run time that provides improved performance for the
3099 limited set of tasking functionality permitted by this set of restrictions.
3100
3101 @node Pragma Restriction_Warnings
3102 @unnumberedsec Pragma Restriction_Warnings
3103 @findex Restriction_Warnings
3104 @noindent
3105 Syntax:
3106
3107 @smallexample @c ada
3108 pragma Restriction_Warnings
3109   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3110 @end smallexample
3111
3112 @noindent
3113 This pragma allows a series of restriction identifiers to be
3114 specified (the list of allowed identifiers is the same as for
3115 pragma @code{Restrictions}). For each of these identifiers
3116 the compiler checks for violations of the restriction, but
3117 generates a warning message rather than an error message
3118 if the restriction is violated.
3119
3120 @node Pragma Source_File_Name
3121 @unnumberedsec Pragma Source_File_Name
3122 @findex Source_File_Name
3123 @noindent
3124 Syntax:
3125
3126 @smallexample @c ada
3127 pragma Source_File_Name (
3128   [Unit_Name   =>] unit_NAME,
3129   Spec_File_Name =>  STRING_LITERAL);
3130
3131 pragma Source_File_Name (
3132   [Unit_Name   =>] unit_NAME,
3133   Body_File_Name =>  STRING_LITERAL);
3134 @end smallexample
3135
3136 @noindent
3137 Use this to override the normal naming convention.  It is a configuration
3138 pragma, and so has the usual applicability of configuration pragmas
3139 (i.e.@: it applies to either an entire partition, or to all units in a
3140 compilation, or to a single unit, depending on how it is used.
3141 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3142 the second argument is required, and indicates whether this is the file
3143 name for the spec or for the body.
3144
3145 Another form of the @code{Source_File_Name} pragma allows
3146 the specification of patterns defining alternative file naming schemes
3147 to apply to all files.
3148
3149 @smallexample @c ada
3150 pragma Source_File_Name
3151   (Spec_File_Name => STRING_LITERAL
3152    [,Casing => CASING_SPEC]
3153    [,Dot_Replacement => STRING_LITERAL]);
3154
3155 pragma Source_File_Name
3156   (Body_File_Name => STRING_LITERAL
3157    [,Casing => CASING_SPEC]
3158    [,Dot_Replacement => STRING_LITERAL]);
3159
3160 pragma Source_File_Name
3161   (Subunit_File_Name => STRING_LITERAL
3162    [,Casing => CASING_SPEC]
3163    [,Dot_Replacement => STRING_LITERAL]);
3164
3165 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3166 @end smallexample
3167
3168 @noindent
3169 The first argument is a pattern that contains a single asterisk indicating
3170 the point at which the unit name is to be inserted in the pattern string
3171 to form the file name.  The second argument is optional.  If present it
3172 specifies the casing of the unit name in the resulting file name string.
3173 The default is lower case.  Finally the third argument allows for systematic
3174 replacement of any dots in the unit name by the specified string literal.
3175
3176 A pragma Source_File_Name cannot appear after a
3177 @ref{Pragma Source_File_Name_Project}.
3178
3179 For more details on the use of the @code{Source_File_Name} pragma,
3180 see the sections ``Using Other File Names'' and
3181 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3182
3183 @node Pragma Source_File_Name_Project
3184 @unnumberedsec Pragma Source_File_Name_Project
3185 @findex Source_File_Name_Project
3186 @noindent
3187
3188 This pragma has the same syntax and semantics as pragma Source_File_Name.
3189 It is only allowed as a stand alone configuration pragma.
3190 It cannot appear after a @ref{Pragma Source_File_Name}, and
3191 most importantly, once pragma Source_File_Name_Project appears,
3192 no further Source_File_Name pragmas are allowed.
3193
3194 The intention is that Source_File_Name_Project pragmas are always
3195 generated by the Project Manager in a manner consistent with the naming
3196 specified in a project file, and when naming is controlled in this manner,
3197 it is not permissible to attempt to modify this naming scheme using
3198 Source_File_Name pragmas (which would not be known to the project manager).
3199
3200 @node Pragma Source_Reference
3201 @unnumberedsec Pragma Source_Reference
3202 @findex Source_Reference
3203 @noindent
3204 Syntax:
3205
3206 @smallexample @c ada
3207 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3208 @end smallexample
3209
3210 @noindent
3211 This pragma must appear as the first line of a source file.
3212 @var{integer_literal} is the logical line number of the line following
3213 the pragma line (for use in error messages and debugging
3214 information).  @var{string_literal} is a static string constant that
3215 specifies the file name to be used in error messages and debugging
3216 information.  This is most notably used for the output of @code{gnatchop}
3217 with the @code{-r} switch, to make sure that the original unchopped
3218 source file is the one referred to.
3219
3220 The second argument must be a string literal, it cannot be a static
3221 string expression other than a string literal.  This is because its value
3222 is needed for error messages issued by all phases of the compiler.
3223
3224 @node Pragma Stream_Convert
3225 @unnumberedsec Pragma Stream_Convert
3226 @findex Stream_Convert
3227 @noindent
3228 Syntax:
3229
3230 @smallexample @c ada
3231 pragma Stream_Convert (
3232   [Entity =>] type_LOCAL_NAME,
3233   [Read   =>] function_NAME,
3234   [Write  =>] function_NAME);
3235 @end smallexample
3236
3237 @noindent
3238 This pragma provides an efficient way of providing stream functions for
3239 types defined in packages.  Not only is it simpler to use than declaring
3240 the necessary functions with attribute representation clauses, but more
3241 significantly, it allows the declaration to made in such a way that the
3242 stream packages are not loaded unless they are needed.  The use of
3243 the Stream_Convert pragma adds no overhead at all, unless the stream
3244 attributes are actually used on the designated type.
3245
3246 The first argument specifies the type for which stream functions are
3247 provided.  The second parameter provides a function used to read values
3248 of this type.  It must name a function whose argument type may be any
3249 subtype, and whose returned type must be the type given as the first
3250 argument to the pragma.
3251
3252 The meaning of the @var{Read}
3253 parameter is that if a stream attribute directly
3254 or indirectly specifies reading of the type given as the first parameter,
3255 then a value of the type given as the argument to the Read function is
3256 read from the stream, and then the Read function is used to convert this
3257 to the required target type.
3258
3259 Similarly the @var{Write} parameter specifies how to treat write attributes
3260 that directly or indirectly apply to the type given as the first parameter.
3261 It must have an input parameter of the type specified by the first parameter,
3262 and the return type must be the same as the input type of the Read function.
3263 The effect is to first call the Write function to convert to the given stream
3264 type, and then write the result type to the stream.
3265
3266 The Read and Write functions must not be overloaded subprograms.  If necessary
3267 renamings can be supplied to meet this requirement.
3268 The usage of this attribute is best illustrated by a simple example, taken
3269 from the GNAT implementation of package Ada.Strings.Unbounded:
3270
3271 @smallexample @c ada
3272 function To_Unbounded (S : String)
3273            return Unbounded_String
3274   renames To_Unbounded_String;
3275
3276 pragma Stream_Convert
3277   (Unbounded_String, To_Unbounded, To_String);
3278 @end smallexample
3279
3280 @noindent
3281 The specifications of the referenced functions, as given in the Ada 95
3282 Reference Manual are:
3283
3284 @smallexample @c ada
3285 function To_Unbounded_String (Source : String)
3286   return Unbounded_String;
3287
3288 function To_String (Source : Unbounded_String)
3289   return String;
3290 @end smallexample
3291
3292 @noindent
3293 The effect is that if the value of an unbounded string is written to a
3294 stream, then the representation of the item in the stream is in the same
3295 format used for @code{Standard.String}, and this same representation is
3296 expected when a value of this type is read from the stream.
3297
3298 @node Pragma Style_Checks
3299 @unnumberedsec Pragma Style_Checks
3300 @findex Style_Checks
3301 @noindent
3302 Syntax:
3303
3304 @smallexample @c ada
3305 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3306                      On | Off [, LOCAL_NAME]);
3307 @end smallexample
3308
3309 @noindent
3310 This pragma is used in conjunction with compiler switches to control the
3311 built in style checking provided by GNAT@.  The compiler switches, if set,
3312 provide an initial setting for the switches, and this pragma may be used
3313 to modify these settings, or the settings may be provided entirely by
3314 the use of the pragma.  This pragma can be used anywhere that a pragma
3315 is legal, including use as a configuration pragma (including use in
3316 the @file{gnat.adc} file).
3317
3318 The form with a string literal specifies which style options are to be
3319 activated.  These are additive, so they apply in addition to any previously
3320 set style check options.  The codes for the options are the same as those
3321 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3322 For example the following two methods can be used to enable
3323 layout checking:
3324
3325 @itemize @bullet
3326 @item
3327 @smallexample @c ada
3328 pragma Style_Checks ("l");
3329 @end smallexample
3330
3331 @item
3332 @smallexample
3333 gcc -c -gnatyl @dots{}
3334 @end smallexample
3335 @end itemize
3336
3337 @noindent
3338 The form ALL_CHECKS activates all standard checks (its use is equivalent
3339 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3340 Guide for details.
3341
3342 The forms with @code{Off} and @code{On}
3343 can be used to temporarily disable style checks
3344 as shown in the following example:
3345
3346 @smallexample @c ada
3347 @iftex
3348 @leftskip=0cm
3349 @end iftex
3350 pragma Style_Checks ("k"); -- requires keywords in lower case
3351 pragma Style_Checks (Off); -- turn off style checks
3352 NULL;                      -- this will not generate an error message
3353 pragma Style_Checks (On);  -- turn style checks back on
3354 NULL;                      -- this will generate an error message
3355 @end smallexample
3356
3357 @noindent
3358 Finally the two argument form is allowed only if the first argument is
3359 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3360 for the specified entity, as shown in the following example:
3361
3362 @smallexample @c ada
3363 @iftex
3364 @leftskip=0cm
3365 @end iftex
3366 pragma Style_Checks ("r"); -- require consistency of identifier casing
3367 Arg : Integer;
3368 Rf1 : Integer := ARG;      -- incorrect, wrong case
3369 pragma Style_Checks (Off, Arg);
3370 Rf2 : Integer := ARG;      -- OK, no error
3371 @end smallexample
3372
3373 @node Pragma Subtitle
3374 @unnumberedsec Pragma Subtitle
3375 @findex Subtitle
3376 @noindent
3377 Syntax:
3378
3379 @smallexample @c ada
3380 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3381 @end smallexample
3382
3383 @noindent
3384 This pragma is recognized for compatibility with other Ada compilers
3385 but is ignored by GNAT@.
3386
3387 @node Pragma Suppress_All
3388 @unnumberedsec Pragma Suppress_All
3389 @findex Suppress_All
3390 @noindent
3391 Syntax:
3392
3393 @smallexample @c ada
3394 pragma Suppress_All;
3395 @end smallexample
3396
3397 @noindent
3398 This pragma can only appear immediately following a compilation
3399 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3400 which it follows.  This pragma is implemented for compatibility with DEC
3401 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3402 configuration pragma is the preferred usage in GNAT@.
3403
3404 @node Pragma Suppress_Exception_Locations
3405 @unnumberedsec Pragma Suppress_Exception_Locations
3406 @findex Suppress_Exception_Locations
3407 @noindent
3408 Syntax:
3409
3410 @smallexample @c ada
3411 pragma Suppress_Exception_Locations;
3412 @end smallexample
3413
3414 @noindent
3415 In normal mode, a raise statement for an exception by default generates
3416 an exception message giving the file name and line number for the location
3417 of the raise. This is useful for debugging and logging purposes, but this
3418 entails extra space for the strings for the messages. The configuration
3419 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3420 generation of these strings, with the result that space is saved, but the
3421 exception message for such raises is null. This configuration pragma may
3422 appear in a global configuration pragma file, or in a specific unit as
3423 usual. It is not required that this pragma be used consistently within
3424 a partition, so it is fine to have some units within a partition compiled
3425 with this pragma and others compiled in normal mode without it.
3426
3427 @node Pragma Suppress_Initialization
3428 @unnumberedsec Pragma Suppress_Initialization
3429 @findex Suppress_Initialization
3430 @cindex Suppressing initialization
3431 @cindex Initialization, suppression of
3432 @noindent
3433 Syntax:
3434
3435 @smallexample @c ada
3436 pragma Suppress_Initialization ([Entity =>] type_Name);
3437 @end smallexample
3438
3439 @noindent
3440 This pragma suppresses any implicit or explicit initialization
3441 associated with the given type name for all variables of this type.
3442
3443 @node Pragma Task_Info
3444 @unnumberedsec Pragma Task_Info
3445 @findex Task_Info
3446 @noindent
3447 Syntax
3448
3449 @smallexample @c ada
3450 pragma Task_Info (EXPRESSION);
3451 @end smallexample
3452
3453 @noindent
3454 This pragma appears within a task definition (like pragma
3455 @code{Priority}) and applies to the task in which it appears.  The
3456 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3457 The @code{Task_Info} pragma provides system dependent control over
3458 aspects of tasking implementation, for example, the ability to map
3459 tasks to specific processors.  For details on the facilities available
3460 for the version of GNAT that you are using, see the documentation
3461 in the specification of package System.Task_Info in the runtime
3462 library.
3463
3464 @node Pragma Task_Name
3465 @unnumberedsec Pragma Task_Name
3466 @findex Task_Name
3467 @noindent
3468 Syntax
3469
3470 @smallexample @c ada
3471 pragma Task_Name (string_EXPRESSION);
3472 @end smallexample
3473
3474 @noindent
3475 This pragma appears within a task definition (like pragma
3476 @code{Priority}) and applies to the task in which it appears.  The
3477 argument must be of type String, and provides a name to be used for
3478 the task instance when the task is created.  Note that this expression
3479 is not required to be static, and in particular, it can contain
3480 references to task discriminants.  This facility can be used to
3481 provide different names for different tasks as they are created,
3482 as illustrated in the example below.
3483
3484 The task name is recorded internally in the run-time structures
3485 and is accessible to tools like the debugger.  In addition the
3486 routine @code{Ada.Task_Identification.Image} will return this
3487 string, with a unique task address appended.
3488
3489 @smallexample @c ada
3490 --  Example of the use of pragma Task_Name
3491
3492 with Ada.Task_Identification;
3493 use Ada.Task_Identification;
3494 with Text_IO; use Text_IO;
3495 procedure t3 is
3496
3497    type Astring is access String;
3498
3499    task type Task_Typ (Name : access String) is
3500       pragma Task_Name (Name.all);
3501    end Task_Typ;
3502
3503    task body Task_Typ is
3504       Nam : constant String := Image (Current_Task);
3505    begin
3506       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3507    end Task_Typ;
3508
3509    type Ptr_Task is access Task_Typ;
3510    Task_Var : Ptr_Task;
3511
3512 begin
3513    Task_Var :=
3514      new Task_Typ (new String'("This is task 1"));
3515    Task_Var :=
3516      new Task_Typ (new String'("This is task 2"));
3517 end;
3518 @end smallexample
3519
3520 @node Pragma Task_Storage
3521 @unnumberedsec Pragma Task_Storage
3522 @findex Task_Storage
3523 Syntax:
3524
3525 @smallexample @c ada
3526 pragma Task_Storage (
3527   [Task_Type =>] LOCAL_NAME,
3528   [Top_Guard =>] static_integer_EXPRESSION);
3529 @end smallexample
3530
3531 @noindent
3532 This pragma specifies the length of the guard area for tasks.  The guard
3533 area is an additional storage area allocated to a task.  A value of zero
3534 means that either no guard area is created or a minimal guard area is
3535 created, depending on the target.  This pragma can appear anywhere a
3536 @code{Storage_Size} attribute definition clause is allowed for a task
3537 type.
3538
3539 @node Pragma Thread_Body
3540 @unnumberedsec Pragma Thread_Body
3541 @findex Thread_Body
3542 Syntax:
3543
3544 @smallexample @c ada
3545 pragma Thread_Body (
3546   [Entity =>] LOCAL_NAME,
3547  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3548 @end smallexample
3549
3550 @noindent
3551 This pragma specifies that the subprogram whose name is given as the
3552 @code{Entity} argument is a thread body, which will be activated
3553 by being called via its Address from foreign code. The purpose is
3554 to allow execution and registration of the foreign thread within the
3555 Ada run-time system.
3556
3557 See the library unit @code{System.Threads} for details on the expansion of
3558 a thread body subprogram, including the calls made to subprograms
3559 within System.Threads to register the task.  This unit also lists the
3560 targets and runtime systems for which this pragma is supported.
3561
3562 A thread body subprogram may not be called directly from Ada code, and
3563 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3564 to such a subprogram. The only legitimate way of calling such a subprogram
3565 is to pass its Address to foreign code and then make the call from the
3566 foreign code.
3567
3568 A thread body subprogram may have any parameters, and it may be a function
3569 returning a result. The convention of the thread body subprogram may be
3570 set in the usual manner using @code{pragma Convention}.
3571
3572 The secondary stack size parameter, if given, is used to set the size
3573 of secondary stack for the thread. The secondary stack is allocated as
3574 a local variable of the expanded thread body subprogram, and thus is
3575 allocated out of the main thread stack size. If no secondary stack
3576 size parameter is present, the default size (from the declaration in
3577 @code{System.Secondary_Stack} is used.
3578
3579 @node Pragma Time_Slice
3580 @unnumberedsec Pragma Time_Slice
3581 @findex Time_Slice
3582 @noindent
3583 Syntax:
3584
3585 @smallexample @c ada
3586 pragma Time_Slice (static_duration_EXPRESSION);
3587 @end smallexample
3588
3589 @noindent
3590 For implementations of GNAT on operating systems where it is possible
3591 to supply a time slice value, this pragma may be used for this purpose.
3592 It is ignored if it is used in a system that does not allow this control,
3593 or if it appears in other than the main program unit.
3594 @cindex OpenVMS
3595 Note that the effect of this pragma is identical to the effect of the
3596 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3597
3598 @node Pragma Title
3599 @unnumberedsec Pragma Title
3600 @findex Title
3601 @noindent
3602 Syntax:
3603
3604 @smallexample @c ada
3605 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3606
3607 TITLING_OPTION ::=
3608   [Title    =>] STRING_LITERAL,
3609 | [Subtitle =>] STRING_LITERAL
3610 @end smallexample
3611
3612 @noindent
3613 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3614 pragma used in DEC Ada 83 implementations to provide a title and/or
3615 subtitle for the program listing.  The program listing generated by GNAT
3616 does not have titles or subtitles.
3617
3618 Unlike other pragmas, the full flexibility of named notation is allowed
3619 for this pragma, i.e.@: the parameters may be given in any order if named
3620 notation is used, and named and positional notation can be mixed
3621 following the normal rules for procedure calls in Ada.
3622
3623 @node Pragma Unchecked_Union
3624 @unnumberedsec Pragma Unchecked_Union
3625 @cindex Unions in C
3626 @findex Unchecked_Union
3627 @noindent
3628 Syntax:
3629
3630 @smallexample @c ada
3631 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3632 @end smallexample
3633
3634 @noindent
3635 This pragma is used to declare that the specified type should be represented
3636 in a manner
3637 equivalent to a C union type, and is intended only for use in
3638 interfacing with C code that uses union types.  In Ada terms, the named
3639 type must obey the following rules:
3640
3641 @itemize @bullet
3642 @item
3643 It is a non-tagged non-limited record type.
3644 @item
3645 It has a single discrete discriminant with a default value.
3646 @item
3647 The component list consists of a single variant part.
3648 @item
3649 Each variant has a component list with a single component.
3650 @item
3651 No nested variants are allowed.
3652 @item
3653 No component has an explicit default value.
3654 @item
3655 No component has a non-static constraint.
3656 @end itemize
3657
3658 @noindent
3659 In addition, given a type that meets the above requirements, the
3660 following restrictions apply to its use throughout the program:
3661
3662 @itemize @bullet
3663 @item
3664 The discriminant name can be mentioned only in an aggregate.
3665 @item
3666 No subtypes may be created of this type.
3667 @item
3668 The type may not be constrained by giving a discriminant value.
3669 @item
3670 The type cannot be passed as the actual for a generic formal with a
3671 discriminant.
3672 @end itemize
3673
3674 @noindent
3675 Equality and inequality operations on @code{unchecked_unions} are not
3676 available, since there is no discriminant to compare and the compiler
3677 does not even know how many bits to compare.  It is implementation
3678 dependent whether this is detected at compile time as an illegality or
3679 whether it is undetected and considered to be an erroneous construct.  In
3680 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3681 the composite case (where two composites are compared that contain an
3682 unchecked union component), so such comparisons are simply considered
3683 erroneous.
3684
3685 The layout of the resulting type corresponds exactly to a C union, where
3686 each branch of the union corresponds to a single variant in the Ada
3687 record.  The semantics of the Ada program is not changed in any way by
3688 the pragma, i.e.@: provided the above restrictions are followed, and no
3689 erroneous incorrect references to fields or erroneous comparisons occur,
3690 the semantics is exactly as described by the Ada reference manual.
3691 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3692 type and the default convention is C.
3693
3694 @node Pragma Unimplemented_Unit
3695 @unnumberedsec Pragma Unimplemented_Unit
3696 @findex Unimplemented_Unit
3697 @noindent
3698 Syntax:
3699
3700 @smallexample @c ada
3701 pragma Unimplemented_Unit;
3702 @end smallexample
3703
3704 @noindent
3705 If this pragma occurs in a unit that is processed by the compiler, GNAT
3706 aborts with the message @samp{@var{xxx} not implemented}, where
3707 @var{xxx} is the name of the current compilation unit.  This pragma is
3708 intended to allow the compiler to handle unimplemented library units in
3709 a clean manner.
3710
3711 The abort only happens if code is being generated.  Thus you can use
3712 specs of unimplemented packages in syntax or semantic checking mode.
3713
3714 @node Pragma Universal_Data
3715 @unnumberedsec Pragma Universal_Data
3716 @findex Universal_Data
3717 @noindent
3718 Syntax:
3719
3720 @smallexample @c ada
3721 pragma Universal_Data [(library_unit_Name)];
3722 @end smallexample
3723
3724 @noindent
3725 This pragma is supported only for the AAMP target and is ignored for
3726 other targets. The pragma specifies that all library-level objects
3727 (Counter 0 data) associated with the library unit are to be accessed
3728 and updated using universal addressing (24-bit addresses for AAMP5)
3729 rather than the default of 16-bit Data Environment (DENV) addressing.
3730 Use of this pragma will generally result in less efficient code for
3731 references to global data associated with the library unit, but
3732 allows such data to be located anywhere in memory. This pragma is
3733 a library unit pragma, but can also be used as a configuration pragma
3734 (including use in the @file{gnat.adc} file). The functionality
3735 of this pragma is also available by applying the -univ switch on the
3736 compilations of units where universal addressing of the data is desired.
3737
3738 @node Pragma Unreferenced
3739 @unnumberedsec Pragma Unreferenced
3740 @findex Unreferenced
3741 @cindex Warnings, unreferenced
3742 @noindent
3743 Syntax:
3744
3745 @smallexample @c ada
3746 pragma Unreferenced (local_Name @{, local_Name@});
3747 @end smallexample
3748
3749 @noindent
3750 This pragma signals that the entities whose names are listed are
3751 deliberately not referenced in the current source unit. This
3752 suppresses warnings about the
3753 entities being unreferenced, and in addition a warning will be
3754 generated if one of these entities is in fact referenced in the
3755 same unit as the pragma (or in the corresponding body, or one
3756 of its subunits).
3757
3758 This is particularly useful for clearly signaling that a particular
3759 parameter is not referenced in some particular subprogram implementation
3760 and that this is deliberate. It can also be useful in the case of
3761 objects declared only for their initialization or finalization side
3762 effects.
3763
3764 If @code{local_Name} identifies more than one matching homonym in the
3765 current scope, then the entity most recently declared is the one to which
3766 the pragma applies.
3767
3768 The left hand side of an assignment does not count as a reference for the
3769 purpose of this pragma. Thus it is fine to assign to an entity for which
3770 pragma Unreferenced is given.
3771
3772 @node Pragma Unreserve_All_Interrupts
3773 @unnumberedsec Pragma Unreserve_All_Interrupts
3774 @findex Unreserve_All_Interrupts
3775 @noindent
3776 Syntax:
3777
3778 @smallexample @c ada
3779 pragma Unreserve_All_Interrupts;
3780 @end smallexample
3781
3782 @noindent
3783 Normally certain interrupts are reserved to the implementation.  Any attempt
3784 to attach an interrupt causes Program_Error to be raised, as described in
3785 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3786 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3787 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3788 interrupt execution.
3789
3790 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3791 a program, then all such interrupts are unreserved.  This allows the
3792 program to handle these interrupts, but disables their standard
3793 functions.  For example, if this pragma is used, then pressing
3794 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3795 a program can then handle the @code{SIGINT} interrupt as it chooses.
3796
3797 For a full list of the interrupts handled in a specific implementation,
3798 see the source code for the specification of @code{Ada.Interrupts.Names} in
3799 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3800 list of interrupts recognized for a given target.  The documentation in
3801 this file also specifies what interrupts are affected by the use of
3802 the @code{Unreserve_All_Interrupts} pragma.
3803
3804 For a more general facility for controlling what interrupts can be
3805 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3806 of the @code{Unreserve_All_Interrupts} pragma.
3807
3808 @node Pragma Unsuppress
3809 @unnumberedsec Pragma Unsuppress
3810 @findex Unsuppress
3811 @noindent
3812 Syntax:
3813
3814 @smallexample @c ada
3815 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3816 @end smallexample
3817
3818 @noindent
3819 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3820 there is no corresponding pragma @code{Suppress} in effect, it has no
3821 effect.  The range of the effect is the same as for pragma
3822 @code{Suppress}.  The meaning of the arguments is identical to that used
3823 in pragma @code{Suppress}.
3824
3825 One important application is to ensure that checks are on in cases where
3826 code depends on the checks for its correct functioning, so that the code
3827 will compile correctly even if the compiler switches are set to suppress
3828 checks.
3829
3830 @node Pragma Use_VADS_Size
3831 @unnumberedsec Pragma Use_VADS_Size
3832 @cindex @code{Size}, VADS compatibility
3833 @findex Use_VADS_Size
3834 @noindent
3835 Syntax:
3836
3837 @smallexample @c ada
3838 pragma Use_VADS_Size;
3839 @end smallexample
3840
3841 @noindent
3842 This is a configuration pragma.  In a unit to which it applies, any use
3843 of the 'Size attribute is automatically interpreted as a use of the
3844 'VADS_Size attribute.  Note that this may result in incorrect semantic
3845 processing of valid Ada 95 programs.  This is intended to aid in the
3846 handling of legacy code which depends on the interpretation of Size
3847 as implemented in the VADS compiler.  See description of the VADS_Size
3848 attribute for further details.
3849
3850 @node Pragma Validity_Checks
3851 @unnumberedsec Pragma Validity_Checks
3852 @findex Validity_Checks
3853 @noindent
3854 Syntax:
3855
3856 @smallexample @c ada
3857 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3858 @end smallexample
3859
3860 @noindent
3861 This pragma is used in conjunction with compiler switches to control the
3862 built-in validity checking provided by GNAT@.  The compiler switches, if set
3863 provide an initial setting for the switches, and this pragma may be used
3864 to modify these settings, or the settings may be provided entirely by
3865 the use of the pragma.  This pragma can be used anywhere that a pragma
3866 is legal, including use as a configuration pragma (including use in
3867 the @file{gnat.adc} file).
3868
3869 The form with a string literal specifies which validity options are to be
3870 activated.  The validity checks are first set to include only the default
3871 reference manual settings, and then a string of letters in the string
3872 specifies the exact set of options required.  The form of this string
3873 is exactly as described for the @code{-gnatVx} compiler switch (see the
3874 GNAT users guide for details).  For example the following two methods
3875 can be used to enable validity checking for mode @code{in} and
3876 @code{in out} subprogram parameters:
3877
3878 @itemize @bullet
3879 @item
3880 @smallexample @c ada
3881 pragma Validity_Checks ("im");
3882 @end smallexample
3883
3884 @item
3885 @smallexample
3886 gcc -c -gnatVim @dots{}
3887 @end smallexample
3888 @end itemize
3889
3890 @noindent
3891 The form ALL_CHECKS activates all standard checks (its use is equivalent
3892 to the use of the @code{gnatva} switch.
3893
3894 The forms with @code{Off} and @code{On}
3895 can be used to temporarily disable validity checks
3896 as shown in the following example:
3897
3898 @smallexample @c ada
3899 @iftex
3900 @leftskip=0cm
3901 @end iftex
3902 pragma Validity_Checks ("c"); -- validity checks for copies
3903 pragma Validity_Checks (Off); -- turn off validity checks
3904 A := B;                       -- B will not be validity checked
3905 pragma Validity_Checks (On);  -- turn validity checks back on
3906 A := C;                       -- C will be validity checked
3907 @end smallexample
3908
3909 @node Pragma Volatile
3910 @unnumberedsec Pragma Volatile
3911 @findex Volatile
3912 @noindent
3913 Syntax:
3914
3915 @smallexample @c ada
3916 pragma Volatile (local_NAME);
3917 @end smallexample
3918
3919 @noindent
3920 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3921 implementation is fully conformant with this definition.  The reason it
3922 is mentioned in this section is that a pragma of the same name was supplied
3923 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3924 of pragma Volatile is upwards compatible with the implementation in
3925 Dec Ada 83.
3926
3927 @node Pragma Warnings
3928 @unnumberedsec Pragma Warnings
3929 @findex Warnings
3930 @noindent
3931 Syntax:
3932
3933 @smallexample @c ada
3934 pragma Warnings (On | Off [, LOCAL_NAME]);
3935 @end smallexample
3936
3937 @noindent
3938 Normally warnings are enabled, with the output being controlled by
3939 the command line switch.  Warnings (@code{Off}) turns off generation of
3940 warnings until a Warnings (@code{On}) is encountered or the end of the
3941 current unit.  If generation of warnings is turned off using this
3942 pragma, then no warning messages are output, regardless of the
3943 setting of the command line switches.
3944
3945 The form with a single argument is a configuration pragma.
3946
3947 If the @var{local_name} parameter is present, warnings are suppressed for
3948 the specified entity.  This suppression is effective from the point where
3949 it occurs till the end of the extended scope of the variable (similar to
3950 the scope of @code{Suppress}).
3951
3952 @node Pragma Weak_External
3953 @unnumberedsec Pragma Weak_External
3954 @findex Weak_External
3955 @noindent
3956 Syntax:
3957
3958 @smallexample @c ada
3959 pragma Weak_External ([Entity =>] LOCAL_NAME);
3960 @end smallexample
3961
3962 @noindent
3963 This pragma specifies that the given entity should be marked as a weak
3964 external (one that does not have to be resolved) for the linker.  For
3965 further details, consult the GCC manual.
3966
3967 @node Implementation Defined Attributes
3968 @chapter Implementation Defined Attributes
3969 Ada 95 defines (throughout the Ada 95 reference manual,
3970 summarized in annex K),
3971 a set of attributes that provide useful additional functionality in all
3972 areas of the language.  These language defined attributes are implemented
3973 in GNAT and work as described in the Ada 95 Reference Manual.
3974
3975 In addition, Ada 95 allows implementations to define additional
3976 attributes whose meaning is defined by the implementation.  GNAT provides
3977 a number of these implementation-dependent attributes which can be used
3978 to extend and enhance the functionality of the compiler.  This section of
3979 the GNAT reference manual describes these additional attributes.
3980
3981 Note that any program using these attributes may not be portable to
3982 other compilers (although GNAT implements this set of attributes on all
3983 platforms).  Therefore if portability to other compilers is an important
3984 consideration, you should minimize the use of these attributes.
3985
3986 @menu
3987 * Abort_Signal::
3988 * Address_Size::
3989 * Asm_Input::
3990 * Asm_Output::
3991 * AST_Entry::
3992 * Bit::
3993 * Bit_Position::
3994 * Code_Address::
3995 * Default_Bit_Order::
3996 * Elaborated::
3997 * Elab_Body::
3998 * Elab_Spec::
3999 * Emax::
4000 * Enum_Rep::
4001 * Epsilon::
4002 * Fixed_Value::
4003 * Has_Discriminants::
4004 * Img::
4005 * Integer_Value::
4006 * Large::
4007 * Machine_Size::
4008 * Mantissa::
4009 * Max_Interrupt_Priority::
4010 * Max_Priority::
4011 * Maximum_Alignment::
4012 * Mechanism_Code::
4013 * Null_Parameter::
4014 * Object_Size::
4015 * Passed_By_Reference::
4016 * Range_Length::
4017 * Safe_Emax::
4018 * Safe_Large::
4019 * Small::
4020 * Storage_Unit::
4021 * Target_Name::
4022 * Tick::
4023 * To_Address::
4024 * Type_Class::
4025 * UET_Address::
4026 * Unconstrained_Array::
4027 * Universal_Literal_String::
4028 * Unrestricted_Access::
4029 * VADS_Size::
4030 * Value_Size::
4031 * Wchar_T_Size::
4032 * Word_Size::
4033 @end menu
4034
4035 @node Abort_Signal
4036 @unnumberedsec Abort_Signal
4037 @findex Abort_Signal
4038 @noindent
4039 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4040 prefix) provides the entity for the special exception used to signal
4041 task abort or asynchronous transfer of control.  Normally this attribute
4042 should only be used in the tasking runtime (it is highly peculiar, and
4043 completely outside the normal semantics of Ada, for a user program to
4044 intercept the abort exception).
4045
4046 @node Address_Size
4047 @unnumberedsec Address_Size
4048 @cindex Size of @code{Address}
4049 @findex Address_Size
4050 @noindent
4051 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4052 prefix) is a static constant giving the number of bits in an
4053 @code{Address}. It is the same value as System.Address'Size,
4054 but has the advantage of being static, while a direct
4055 reference to System.Address'Size is non-static because Address
4056 is a private type.
4057
4058 @node Asm_Input
4059 @unnumberedsec Asm_Input
4060 @findex Asm_Input
4061 @noindent
4062 The @code{Asm_Input} attribute denotes a function that takes two
4063 parameters.  The first is a string, the second is an expression of the
4064 type designated by the prefix.  The first (string) argument is required
4065 to be a static expression, and is the constraint for the parameter,
4066 (e.g.@: what kind of register is required).  The second argument is the
4067 value to be used as the input argument.  The possible values for the
4068 constant are the same as those used in the RTL, and are dependent on
4069 the configuration file used to built the GCC back end.
4070 @ref{Machine Code Insertions}
4071
4072 @node Asm_Output
4073 @unnumberedsec Asm_Output
4074 @findex Asm_Output
4075 @noindent
4076 The @code{Asm_Output} attribute denotes a function that takes two
4077 parameters.  The first is a string, the second is the name of a variable
4078 of the type designated by the attribute prefix.  The first (string)
4079 argument is required to be a static expression and designates the
4080 constraint for the parameter (e.g.@: what kind of register is
4081 required).  The second argument is the variable to be updated with the
4082 result.  The possible values for constraint are the same as those used in
4083 the RTL, and are dependent on the configuration file used to build the
4084 GCC back end.  If there are no output operands, then this argument may
4085 either be omitted, or explicitly given as @code{No_Output_Operands}.
4086 @ref{Machine Code Insertions}
4087
4088 @node AST_Entry
4089 @unnumberedsec AST_Entry
4090 @cindex OpenVMS
4091 @findex AST_Entry
4092 @noindent
4093 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4094 the name of an entry, it yields a value of the predefined type AST_Handler
4095 (declared in the predefined package System, as extended by the use of
4096 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4097 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4098 Language Reference Manual}, section 9.12a.
4099
4100 @node Bit
4101 @unnumberedsec Bit
4102 @findex Bit
4103 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4104 offset within the storage unit (byte) that contains the first bit of
4105 storage allocated for the object.  The value of this attribute is of the
4106 type @code{Universal_Integer}, and is always a non-negative number not
4107 exceeding the value of @code{System.Storage_Unit}.
4108
4109 For an object that is a variable or a constant allocated in a register,
4110 the value is zero.  (The use of this attribute does not force the
4111 allocation of a variable to memory).
4112
4113 For an object that is a formal parameter, this attribute applies
4114 to either the matching actual parameter or to a copy of the
4115 matching actual parameter.
4116
4117 For an access object the value is zero.  Note that
4118 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4119 designated object.  Similarly for a record component
4120 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4121 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4122 are subject to index checks.
4123
4124 This attribute is designed to be compatible with the DEC Ada 83 definition
4125 and implementation of the @code{Bit} attribute.
4126
4127 @node Bit_Position
4128 @unnumberedsec Bit_Position
4129 @findex Bit_Position
4130 @noindent
4131 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4132 of the fields of the record type, yields the bit
4133 offset within the record contains the first bit of
4134 storage allocated for the object.  The value of this attribute is of the
4135 type @code{Universal_Integer}.  The value depends only on the field
4136 @var{C} and is independent of the alignment of
4137 the containing record @var{R}.
4138
4139 @node Code_Address
4140 @unnumberedsec Code_Address
4141 @findex Code_Address
4142 @cindex Subprogram address
4143 @cindex Address of subprogram code
4144 @noindent
4145 The @code{'Address}
4146 attribute may be applied to subprograms in Ada 95, but the
4147 intended effect from the Ada 95 reference manual seems to be to provide
4148 an address value which can be used to call the subprogram by means of
4149 an address clause as in the following example:
4150
4151 @smallexample @c ada
4152 procedure K is @dots{}
4153
4154 procedure L;
4155 for L'Address use K'Address;
4156 pragma Import (Ada, L);
4157 @end smallexample
4158
4159 @noindent
4160 A call to @code{L} is then expected to result in a call to @code{K}@.
4161 In Ada 83, where there were no access-to-subprogram values, this was
4162 a common work around for getting the effect of an indirect call.
4163 GNAT implements the above use of @code{Address} and the technique
4164 illustrated by the example code works correctly.
4165
4166 However, for some purposes, it is useful to have the address of the start
4167 of the generated code for the subprogram.  On some architectures, this is
4168 not necessarily the same as the @code{Address} value described above.
4169 For example, the @code{Address} value may reference a subprogram
4170 descriptor rather than the subprogram itself.
4171
4172 The @code{'Code_Address} attribute, which can only be applied to
4173 subprogram entities, always returns the address of the start of the
4174 generated code of the specified subprogram, which may or may not be
4175 the same value as is returned by the corresponding @code{'Address}
4176 attribute.
4177
4178 @node Default_Bit_Order
4179 @unnumberedsec Default_Bit_Order
4180 @cindex Big endian
4181 @cindex Little endian
4182 @findex Default_Bit_Order
4183 @noindent
4184 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4185 permissible prefix), provides the value @code{System.Default_Bit_Order}
4186 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4187 @code{Low_Order_First}).  This is used to construct the definition of
4188 @code{Default_Bit_Order} in package @code{System}.
4189
4190 @node Elaborated
4191 @unnumberedsec Elaborated
4192 @findex Elaborated
4193 @noindent
4194 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4195 value is a Boolean which indicates whether or not the given unit has been
4196 elaborated.  This attribute is primarily intended for internal use by the
4197 generated code for dynamic elaboration checking, but it can also be used
4198 in user programs.  The value will always be True once elaboration of all
4199 units has been completed.  An exception is for units which need no
4200 elaboration, the value is always False for such units.
4201
4202 @node Elab_Body
4203 @unnumberedsec Elab_Body
4204 @findex Elab_Body
4205 @noindent
4206 This attribute can only be applied to a program unit name.  It returns
4207 the entity for the corresponding elaboration procedure for elaborating
4208 the body of the referenced unit.  This is used in the main generated
4209 elaboration procedure by the binder and is not normally used in any
4210 other context.  However, there may be specialized situations in which it
4211 is useful to be able to call this elaboration procedure from Ada code,
4212 e.g.@: if it is necessary to do selective re-elaboration to fix some
4213 error.
4214
4215 @node Elab_Spec
4216 @unnumberedsec Elab_Spec
4217 @findex Elab_Spec
4218 @noindent
4219 This attribute can only be applied to a program unit name.  It returns
4220 the entity for the corresponding elaboration procedure for elaborating
4221 the specification of the referenced unit.  This is used in the main
4222 generated elaboration procedure by the binder and is not normally used
4223 in any other context.  However, there may be specialized situations in
4224 which it is useful to be able to call this elaboration procedure from
4225 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4226 some error.
4227
4228 @node Emax
4229 @unnumberedsec Emax
4230 @cindex Ada 83 attributes
4231 @findex Emax
4232 @noindent
4233 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4234 the Ada 83 reference manual for an exact description of the semantics of
4235 this attribute.
4236
4237 @node Enum_Rep
4238 @unnumberedsec Enum_Rep
4239 @cindex Representation of enums
4240 @findex Enum_Rep
4241 @noindent
4242 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4243 function with the following spec:
4244
4245 @smallexample @c ada
4246 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4247   return @i{Universal_Integer};
4248 @end smallexample
4249
4250 @noindent
4251 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4252 enumeration type or to a non-overloaded enumeration
4253 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4254 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4255 enumeration literal or object.
4256
4257 The function returns the representation value for the given enumeration
4258 value.  This will be equal to value of the @code{Pos} attribute in the
4259 absence of an enumeration representation clause.  This is a static
4260 attribute (i.e.@: the result is static if the argument is static).
4261
4262 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4263 in which case it simply returns the integer value.  The reason for this
4264 is to allow it to be used for @code{(<>)} discrete formal arguments in
4265 a generic unit that can be instantiated with either enumeration types
4266 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4267 type whose upper bound exceeds the upper bound of the largest signed
4268 integer type, and the argument is a variable, so that the universal
4269 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4270 may raise @code{Constraint_Error}.
4271
4272 @node Epsilon
4273 @unnumberedsec Epsilon
4274 @cindex Ada 83 attributes
4275 @findex Epsilon
4276 @noindent
4277 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4278 the Ada 83 reference manual for an exact description of the semantics of
4279 this attribute.
4280
4281 @node Fixed_Value
4282 @unnumberedsec Fixed_Value
4283 @findex Fixed_Value
4284 @noindent
4285 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4286 function with the following specification:
4287
4288 @smallexample @c ada
4289 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4290   return @var{S};
4291 @end smallexample
4292
4293 @noindent
4294 The value returned is the fixed-point value @var{V} such that
4295
4296 @smallexample @c ada
4297 @var{V} = Arg * @var{S}'Small
4298 @end smallexample
4299
4300 @noindent
4301 The effect is thus similar to first converting the argument to the
4302 integer type used to represent @var{S}, and then doing an unchecked
4303 conversion to the fixed-point type.  The difference is
4304 that there are full range checks, to ensure that the result is in range.
4305 This attribute is primarily intended for use in implementation of the
4306 input-output functions for fixed-point values.
4307
4308 @node Has_Discriminants
4309 @unnumberedsec Has_Discriminants
4310 @cindex Discriminants, testing for
4311 @findex Has_Discriminants
4312 @noindent
4313 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4314 is a Boolean value which is True if the type has discriminants, and False
4315 otherwise.  The intended use of this attribute is in conjunction with generic
4316 definitions.  If the attribute is applied to a generic private type, it
4317 indicates whether or not the corresponding actual type has discriminants.
4318
4319 @node Img
4320 @unnumberedsec Img
4321 @findex Img
4322 @noindent
4323 The @code{Img} attribute differs from @code{Image} in that it may be
4324 applied to objects as well as types, in which case it gives the
4325 @code{Image} for the subtype of the object.  This is convenient for
4326 debugging:
4327
4328 @smallexample @c ada
4329 Put_Line ("X = " & X'Img);
4330 @end smallexample
4331
4332 @noindent
4333 has the same meaning as the more verbose:
4334
4335 @smallexample @c ada
4336 Put_Line ("X = " & @var{T}'Image (X));
4337 @end smallexample
4338
4339 @noindent
4340 where @var{T} is the (sub)type of the object @code{X}.
4341
4342 @node Integer_Value
4343 @unnumberedsec Integer_Value
4344 @findex Integer_Value
4345 @noindent
4346 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4347 function with the following spec:
4348
4349 @smallexample @c ada
4350 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4351   return @var{S};
4352 @end smallexample
4353
4354 @noindent
4355 The value returned is the integer value @var{V}, such that
4356
4357 @smallexample @c ada
4358 Arg = @var{V} * @var{T}'Small
4359 @end smallexample
4360
4361 @noindent
4362 where @var{T} is the type of @code{Arg}.
4363 The effect is thus similar to first doing an unchecked conversion from
4364 the fixed-point type to its corresponding implementation type, and then
4365 converting the result to the target integer type.  The difference is
4366 that there are full range checks, to ensure that the result is in range.
4367 This attribute is primarily intended for use in implementation of the
4368 standard input-output functions for fixed-point values.
4369
4370 @node Large
4371 @unnumberedsec Large
4372 @cindex Ada 83 attributes
4373 @findex Large
4374 @noindent
4375 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4376 the Ada 83 reference manual for an exact description of the semantics of
4377 this attribute.
4378
4379 @node Machine_Size
4380 @unnumberedsec Machine_Size
4381 @findex Machine_Size
4382 @noindent
4383 This attribute is identical to the @code{Object_Size} attribute.  It is
4384 provided for compatibility with the DEC Ada 83 attribute of this name.
4385
4386 @node Mantissa
4387 @unnumberedsec Mantissa
4388 @cindex Ada 83 attributes
4389 @findex Mantissa
4390 @noindent
4391 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4392 the Ada 83 reference manual for an exact description of the semantics of
4393 this attribute.
4394
4395 @node Max_Interrupt_Priority
4396 @unnumberedsec Max_Interrupt_Priority
4397 @cindex Interrupt priority, maximum
4398 @findex Max_Interrupt_Priority
4399 @noindent
4400 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4401 permissible prefix), provides the same value as
4402 @code{System.Max_Interrupt_Priority}.
4403
4404 @node Max_Priority
4405 @unnumberedsec Max_Priority
4406 @cindex Priority, maximum
4407 @findex Max_Priority
4408 @noindent
4409 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4410 prefix) provides the same value as @code{System.Max_Priority}.
4411
4412 @node Maximum_Alignment
4413 @unnumberedsec Maximum_Alignment
4414 @cindex Alignment, maximum
4415 @findex Maximum_Alignment
4416 @noindent
4417 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4418 permissible prefix) provides the maximum useful alignment value for the
4419 target.  This is a static value that can be used to specify the alignment
4420 for an object, guaranteeing that it is properly aligned in all
4421 cases.
4422
4423 @node Mechanism_Code
4424 @unnumberedsec Mechanism_Code
4425 @cindex Return values, passing mechanism
4426 @cindex Parameters, passing mechanism
4427 @findex Mechanism_Code
4428 @noindent
4429 @code{@var{function}'Mechanism_Code} yields an integer code for the
4430 mechanism used for the result of function, and
4431 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4432 used for formal parameter number @var{n} (a static integer value with 1
4433 meaning the first parameter) of @var{subprogram}.  The code returned is:
4434
4435 @table @asis
4436 @item 1
4437 by copy (value)
4438 @item 2
4439 by reference
4440 @item 3
4441 by descriptor (default descriptor class)
4442 @item 4
4443 by descriptor (UBS: unaligned bit string)
4444 @item 5
4445 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4446 @item 6
4447 by descriptor (UBA: unaligned bit array)
4448 @item 7
4449 by descriptor (S: string, also scalar access type parameter)
4450 @item 8
4451 by descriptor (SB: string with arbitrary bounds)
4452 @item 9
4453 by descriptor (A: contiguous array)
4454 @item 10
4455 by descriptor (NCA: non-contiguous array)
4456 @end table
4457
4458 @noindent
4459 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4460 @cindex OpenVMS
4461
4462 @node Null_Parameter
4463 @unnumberedsec Null_Parameter
4464 @cindex Zero address, passing
4465 @findex Null_Parameter
4466 @noindent
4467 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4468 type or subtype @var{T} allocated at machine address zero.  The attribute
4469 is allowed only as the default expression of a formal parameter, or as
4470 an actual expression of a subprogram call.  In either case, the
4471 subprogram must be imported.
4472
4473 The identity of the object is represented by the address zero in the
4474 argument list, independent of the passing mechanism (explicit or
4475 default).
4476
4477 This capability is needed to specify that a zero address should be
4478 passed for a record or other composite object passed by reference.
4479 There is no way of indicating this without the @code{Null_Parameter}
4480 attribute.
4481
4482 @node Object_Size
4483 @unnumberedsec Object_Size
4484 @cindex Size, used for objects
4485 @findex Object_Size
4486 @noindent
4487 The size of an object is not necessarily the same as the size of the type
4488 of an object.  This is because by default object sizes are increased to be
4489 a multiple of the alignment of the object.  For example,
4490 @code{Natural'Size} is
4491 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4492 Similarly, a record containing an integer and a character:
4493
4494 @smallexample @c ada
4495 type Rec is record
4496    I : Integer;
4497    C : Character;
4498 end record;
4499 @end smallexample
4500
4501 @noindent
4502 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4503 alignment will be 4, because of the
4504 integer field, and so the default size of record objects for this type
4505 will be 64 (8 bytes).
4506
4507 The @code{@var{type}'Object_Size} attribute
4508 has been added to GNAT to allow the
4509 default object size of a type to be easily determined.  For example,
4510 @code{Natural'Object_Size} is 32, and
4511 @code{Rec'Object_Size} (for the record type in the above example) will be
4512 64.  Note also that, unlike the situation with the
4513 @code{Size} attribute as defined in the Ada RM, the
4514 @code{Object_Size} attribute can be specified individually
4515 for different subtypes.  For example:
4516
4517 @smallexample @c ada
4518 type R is new Integer;
4519 subtype R1 is R range 1 .. 10;
4520 subtype R2 is R range 1 .. 10;
4521 for R2'Object_Size use 8;
4522 @end smallexample
4523
4524 @noindent
4525 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4526 32 since the default object size for a subtype is the same as the object size
4527 for the parent subtype.  This means that objects of type @code{R}
4528 or @code{R1} will
4529 by default be 32 bits (four bytes).  But objects of type
4530 @code{R2} will be only
4531 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4532
4533 @node Passed_By_Reference
4534 @unnumberedsec Passed_By_Reference
4535 @cindex Parameters, when passed by reference
4536 @findex Passed_By_Reference
4537 @noindent
4538 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4539 a value of type @code{Boolean} value that is @code{True} if the type is
4540 normally passed by reference and @code{False} if the type is normally
4541 passed by copy in calls.  For scalar types, the result is always @code{False}
4542 and is static.  For non-scalar types, the result is non-static.
4543
4544 @node Range_Length
4545 @unnumberedsec Range_Length
4546 @findex Range_Length
4547 @noindent
4548 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4549 the number of values represented by the subtype (zero for a null
4550 range).  The result is static for static subtypes.  @code{Range_Length}
4551 applied to the index subtype of a one dimensional array always gives the
4552 same result as @code{Range} applied to the array itself.
4553
4554 @node Safe_Emax
4555 @unnumberedsec Safe_Emax
4556 @cindex Ada 83 attributes
4557 @findex Safe_Emax
4558 @noindent
4559 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4560 the Ada 83 reference manual for an exact description of the semantics of
4561 this attribute.
4562
4563 @node Safe_Large
4564 @unnumberedsec Safe_Large
4565 @cindex Ada 83 attributes
4566 @findex Safe_Large
4567 @noindent
4568 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4569 the Ada 83 reference manual for an exact description of the semantics of
4570 this attribute.
4571
4572 @node Small
4573 @unnumberedsec Small
4574 @cindex Ada 83 attributes
4575 @findex Small
4576 @noindent
4577 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4578 GNAT also allows this attribute to be applied to floating-point types
4579 for compatibility with Ada 83.  See
4580 the Ada 83 reference manual for an exact description of the semantics of
4581 this attribute when applied to floating-point types.
4582
4583 @node Storage_Unit
4584 @unnumberedsec Storage_Unit
4585 @findex Storage_Unit
4586 @noindent
4587 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4588 prefix) provides the same value as @code{System.Storage_Unit}.
4589
4590 @node Target_Name
4591 @unnumberedsec Target_Name
4592 @findex Target_Name
4593 @noindent
4594 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4595 prefix) provides a static string value that identifies the target
4596 for the current compilation. For GCC implementations, this is the
4597 standard gcc target name without the terminating slash (for
4598 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4599
4600 @node Tick
4601 @unnumberedsec Tick
4602 @findex Tick
4603 @noindent
4604 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4605 provides the same value as @code{System.Tick},
4606
4607 @node To_Address
4608 @unnumberedsec To_Address
4609 @findex To_Address
4610 @noindent
4611 The @code{System'To_Address}
4612 (@code{System} is the only permissible prefix)
4613 denotes a function identical to
4614 @code{System.Storage_Elements.To_Address} except that
4615 it is a static attribute.  This means that if its argument is
4616 a static expression, then the result of the attribute is a
4617 static expression.  The result is that such an expression can be
4618 used in contexts (e.g.@: preelaborable packages) which require a
4619 static expression and where the function call could not be used
4620 (since the function call is always non-static, even if its
4621 argument is static).
4622
4623 @node Type_Class
4624 @unnumberedsec Type_Class
4625 @findex Type_Class
4626 @noindent
4627 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4628 the value of the type class for the full type of @var{type}.  If
4629 @var{type} is a generic formal type, the value is the value for the
4630 corresponding actual subtype.  The value of this attribute is of type
4631 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4632
4633 @smallexample @c ada
4634   type Type_Class is
4635     (Type_Class_Enumeration,
4636      Type_Class_Integer,
4637      Type_Class_Fixed_Point,
4638      Type_Class_Floating_Point,
4639      Type_Class_Array,
4640      Type_Class_Record,
4641      Type_Class_Access,
4642      Type_Class_Task,
4643      Type_Class_Address);
4644 @end smallexample
4645
4646 @noindent
4647 Protected types yield the value @code{Type_Class_Task}, which thus
4648 applies to all concurrent types.  This attribute is designed to
4649 be compatible with the DEC Ada 83 attribute of the same name.
4650
4651 @node UET_Address
4652 @unnumberedsec UET_Address
4653 @findex UET_Address
4654 @noindent
4655 The @code{UET_Address} attribute can only be used for a prefix which
4656 denotes a library package.  It yields the address of the unit exception
4657 table when zero cost exception handling is used.  This attribute is
4658 intended only for use within the GNAT implementation.  See the unit
4659 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4660 for details on how this attribute is used in the implementation.
4661
4662 @node Unconstrained_Array
4663 @unnumberedsec Unconstrained_Array
4664 @findex Unconstrained_Array
4665 @noindent
4666 The @code{Unconstrained_Array} attribute can be used with a prefix that
4667 denotes any type or subtype. It is a static attribute that yields
4668 @code{True} if the prefix designates an unconstrained array,
4669 and @code{False} otherwise. In a generic instance, the result is
4670 still static, and yields the result of applying this test to the
4671 generic actual.
4672
4673 @node Universal_Literal_String
4674 @unnumberedsec Universal_Literal_String
4675 @cindex Named numbers, representation of
4676 @findex Universal_Literal_String
4677 @noindent
4678 The prefix of @code{Universal_Literal_String} must be a named
4679 number.  The static result is the string consisting of the characters of
4680 the number as defined in the original source.  This allows the user
4681 program to access the actual text of named numbers without intermediate
4682 conversions and without the need to enclose the strings in quotes (which
4683 would preclude their use as numbers).  This is used internally for the
4684 construction of values of the floating-point attributes from the file
4685 @file{ttypef.ads}, but may also be used by user programs.
4686
4687 @node Unrestricted_Access
4688 @unnumberedsec Unrestricted_Access
4689 @cindex @code{Access}, unrestricted
4690 @findex Unrestricted_Access
4691 @noindent
4692 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4693 except that all accessibility and aliased view checks are omitted.  This
4694 is a user-beware attribute.  It is similar to
4695 @code{Address}, for which it is a desirable replacement where the value
4696 desired is an access type.  In other words, its effect is identical to
4697 first applying the @code{Address} attribute and then doing an unchecked
4698 conversion to a desired access type.  In GNAT, but not necessarily in
4699 other implementations, the use of static chains for inner level
4700 subprograms means that @code{Unrestricted_Access} applied to a
4701 subprogram yields a value that can be called as long as the subprogram
4702 is in scope (normal Ada 95 accessibility rules restrict this usage).
4703
4704 It is possible to use @code{Unrestricted_Access} for any type, but care
4705 must be excercised if it is used to create pointers to unconstrained
4706 objects. In this case, the resulting pointer has the same scope as the
4707 context of the attribute, and may not be returned to some enclosing
4708 scope. For instance, a function cannot use @code{Unrestricted_Access}
4709 to create a unconstrained pointer and then return that value to the
4710 caller.
4711
4712 @node VADS_Size
4713 @unnumberedsec VADS_Size
4714 @cindex @code{Size}, VADS compatibility
4715 @findex VADS_Size
4716 @noindent
4717 The @code{'VADS_Size} attribute is intended to make it easier to port
4718 legacy code which relies on the semantics of @code{'Size} as implemented
4719 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4720 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4721 to a predefined or other primitive type with no Size clause yields the
4722 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4723 typical machines).  In addition @code{'VADS_Size} applied to an object
4724 gives the result that would be obtained by applying the attribute to
4725 the corresponding type.
4726
4727 @node Value_Size
4728 @unnumberedsec Value_Size
4729 @cindex @code{Size}, setting for not-first subtype
4730 @findex Value_Size
4731 @code{@var{type}'Value_Size} is the number of bits required to represent
4732 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4733 but, unlike @code{Size}, may be set for non-first subtypes.
4734
4735 @node Wchar_T_Size
4736 @unnumberedsec Wchar_T_Size
4737 @findex Wchar_T_Size
4738 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4739 prefix) provides the size in bits of the C @code{wchar_t} type
4740 primarily for constructing the definition of this type in
4741 package @code{Interfaces.C}.
4742
4743 @node Word_Size
4744 @unnumberedsec Word_Size
4745 @findex Word_Size
4746 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4747 prefix) provides the value @code{System.Word_Size}.
4748
4749 @c ------------------------
4750 @node Implementation Advice
4751 @chapter Implementation Advice
4752 @noindent
4753 The main text of the Ada 95 Reference Manual describes the required
4754 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4755 these requirements.
4756
4757 In addition, there are sections throughout the Ada 95
4758 reference manual headed
4759 by the phrase ``implementation advice''.  These sections are not normative,
4760 i.e.@: they do not specify requirements that all compilers must
4761 follow.  Rather they provide advice on generally desirable behavior.  You
4762 may wonder why they are not requirements.  The most typical answer is
4763 that they describe behavior that seems generally desirable, but cannot
4764 be provided on all systems, or which may be undesirable on some systems.
4765
4766 As far as practical, GNAT follows the implementation advice sections in
4767 the Ada 95 Reference Manual.  This chapter contains a table giving the
4768 reference manual section number, paragraph number and several keywords
4769 for each advice.  Each entry consists of the text of the advice followed
4770 by the GNAT interpretation of this advice.  Most often, this simply says
4771 ``followed'', which means that GNAT follows the advice.  However, in a
4772 number of cases, GNAT deliberately deviates from this advice, in which
4773 case the text describes what GNAT does and why.
4774
4775 @cindex Error detection
4776 @unnumberedsec 1.1.3(20): Error Detection
4777 @sp 1
4778 @cartouche
4779 If an implementation detects the use of an unsupported Specialized Needs
4780 Annex feature at run time, it should raise @code{Program_Error} if
4781 feasible.
4782 @end cartouche
4783 Not relevant.  All specialized needs annex features are either supported,
4784 or diagnosed at compile time.
4785
4786 @cindex Child Units
4787 @unnumberedsec 1.1.3(31): Child Units
4788 @sp 1
4789 @cartouche
4790 If an implementation wishes to provide implementation-defined
4791 extensions to the functionality of a language-defined library unit, it
4792 should normally do so by adding children to the library unit.
4793 @end cartouche
4794 Followed.
4795
4796 @cindex Bounded errors
4797 @unnumberedsec 1.1.5(12): Bounded Errors
4798 @sp 1
4799 @cartouche
4800 If an implementation detects a bounded error or erroneous
4801 execution, it should raise @code{Program_Error}.
4802 @end cartouche
4803 Followed in all cases in which the implementation detects a bounded
4804 error or erroneous execution.  Not all such situations are detected at
4805 runtime.
4806
4807 @cindex Pragmas
4808 @unnumberedsec 2.8(16): Pragmas
4809 @sp 1
4810 @cartouche
4811 Normally, implementation-defined pragmas should have no semantic effect
4812 for error-free programs; that is, if the implementation-defined pragmas
4813 are removed from a working program, the program should still be legal,
4814 and should still have the same semantics.
4815 @end cartouche
4816 The following implementation defined pragmas are exceptions to this
4817 rule:
4818
4819 @table @code
4820 @item Abort_Defer
4821 Affects semantics
4822 @item Ada_83
4823 Affects legality
4824 @item Assert
4825 Affects semantics
4826 @item CPP_Class
4827 Affects semantics
4828 @item CPP_Constructor
4829 Affects semantics
4830 @item CPP_Virtual
4831 Affects semantics
4832 @item CPP_Vtable
4833 Affects semantics
4834 @item Debug
4835 Affects semantics
4836 @item Interface_Name
4837 Affects semantics
4838 @item Machine_Attribute
4839 Affects semantics
4840 @item Unimplemented_Unit
4841 Affects legality
4842 @item Unchecked_Union
4843 Affects semantics
4844 @end table
4845
4846 @noindent
4847 In each of the above cases, it is essential to the purpose of the pragma
4848 that this advice not be followed.  For details see the separate section
4849 on implementation defined pragmas.
4850
4851 @unnumberedsec 2.8(17-19): Pragmas
4852 @sp 1
4853 @cartouche
4854 Normally, an implementation should not define pragmas that can
4855 make an illegal program legal, except as follows:
4856 @end cartouche
4857 @sp 1
4858 @cartouche
4859 A pragma used to complete a declaration, such as a pragma @code{Import};
4860 @end cartouche
4861 @sp 1
4862 @cartouche
4863 A pragma used to configure the environment by adding, removing, or
4864 replacing @code{library_items}.
4865 @end cartouche
4866 See response to paragraph 16 of this same section.
4867
4868 @cindex Character Sets
4869 @cindex Alternative Character Sets
4870 @unnumberedsec 3.5.2(5): Alternative Character Sets
4871 @sp 1
4872 @cartouche
4873 If an implementation supports a mode with alternative interpretations
4874 for @code{Character} and @code{Wide_Character}, the set of graphic
4875 characters of @code{Character} should nevertheless remain a proper
4876 subset of the set of graphic characters of @code{Wide_Character}.  Any
4877 character set ``localizations'' should be reflected in the results of
4878 the subprograms defined in the language-defined package
4879 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4880 an alternative interpretation of @code{Character}, the implementation should
4881 also support a corresponding change in what is a legal
4882 @code{identifier_letter}.
4883 @end cartouche
4884 Not all wide character modes follow this advice, in particular the JIS
4885 and IEC modes reflect standard usage in Japan, and in these encoding,
4886 the upper half of the Latin-1 set is not part of the wide-character
4887 subset, since the most significant bit is used for wide character
4888 encoding.  However, this only applies to the external forms.  Internally
4889 there is no such restriction.
4890
4891 @cindex Integer types
4892 @unnumberedsec 3.5.4(28): Integer Types
4893
4894 @sp 1
4895 @cartouche
4896 An implementation should support @code{Long_Integer} in addition to
4897 @code{Integer} if the target machine supports 32-bit (or longer)
4898 arithmetic.  No other named integer subtypes are recommended for package
4899 @code{Standard}.  Instead, appropriate named integer subtypes should be
4900 provided in the library package @code{Interfaces} (see B.2).
4901 @end cartouche
4902 @code{Long_Integer} is supported.  Other standard integer types are supported
4903 so this advice is not fully followed.  These types
4904 are supported for convenient interface to C, and so that all hardware
4905 types of the machine are easily available.
4906 @unnumberedsec 3.5.4(29): Integer Types
4907
4908 @sp 1
4909 @cartouche
4910 An implementation for a two's complement machine should support
4911 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4912 implementation should support a non-binary modules up to @code{Integer'Last}.
4913 @end cartouche
4914 Followed.
4915
4916 @cindex Enumeration values
4917 @unnumberedsec 3.5.5(8): Enumeration Values
4918 @sp 1
4919 @cartouche
4920 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4921 subtype, if the value of the operand does not correspond to the internal
4922 code for any enumeration literal of its type (perhaps due to an
4923 un-initialized variable), then the implementation should raise
4924 @code{Program_Error}.  This is particularly important for enumeration
4925 types with noncontiguous internal codes specified by an
4926 enumeration_representation_clause.
4927 @end cartouche
4928 Followed.
4929
4930 @cindex Float types
4931 @unnumberedsec 3.5.7(17): Float Types
4932 @sp 1
4933 @cartouche
4934 An implementation should support @code{Long_Float} in addition to
4935 @code{Float} if the target machine supports 11 or more digits of
4936 precision.  No other named floating point subtypes are recommended for
4937 package @code{Standard}.  Instead, appropriate named floating point subtypes
4938 should be provided in the library package @code{Interfaces} (see B.2).
4939 @end cartouche
4940 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4941 former provides improved compatibility with other implementations
4942 supporting this type.  The latter corresponds to the highest precision
4943 floating-point type supported by the hardware.  On most machines, this
4944 will be the same as @code{Long_Float}, but on some machines, it will
4945 correspond to the IEEE extended form.  The notable case is all ia32
4946 (x86) implementations, where @code{Long_Long_Float} corresponds to
4947 the 80-bit extended precision format supported in hardware on this
4948 processor.  Note that the 128-bit format on SPARC is not supported,
4949 since this is a software rather than a hardware format.
4950
4951 @cindex Multidimensional arrays
4952 @cindex Arrays, multidimensional
4953 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4954 @sp 1
4955 @cartouche
4956 An implementation should normally represent multidimensional arrays in
4957 row-major order, consistent with the notation used for multidimensional
4958 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
4959 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4960 column-major order should be used instead (see B.5, ``Interfacing with
4961 Fortran'').
4962 @end cartouche
4963 Followed.
4964
4965 @findex Duration'Small
4966 @unnumberedsec 9.6(30-31): Duration'Small
4967 @sp 1
4968 @cartouche
4969 Whenever possible in an implementation, the value of @code{Duration'Small}
4970 should be no greater than 100 microseconds.
4971 @end cartouche
4972 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
4973
4974 @sp 1
4975 @cartouche
4976 The time base for @code{delay_relative_statements} should be monotonic;
4977 it need not be the same time base as used for @code{Calendar.Clock}.
4978 @end cartouche
4979 Followed.
4980
4981 @unnumberedsec 10.2.1(12): Consistent Representation
4982 @sp 1
4983 @cartouche
4984 In an implementation, a type declared in a pre-elaborated package should
4985 have the same representation in every elaboration of a given version of
4986 the package, whether the elaborations occur in distinct executions of
4987 the same program, or in executions of distinct programs or partitions
4988 that include the given version.
4989 @end cartouche
4990 Followed, except in the case of tagged types.  Tagged types involve
4991 implicit pointers to a local copy of a dispatch table, and these pointers
4992 have representations which thus depend on a particular elaboration of the
4993 package.  It is not easy to see how it would be possible to follow this
4994 advice without severely impacting efficiency of execution.
4995
4996 @cindex Exception information
4997 @unnumberedsec 11.4.1(19): Exception Information
4998 @sp 1
4999 @cartouche
5000 @code{Exception_Message} by default and @code{Exception_Information}
5001 should produce information useful for
5002 debugging.  @code{Exception_Message} should be short, about one
5003 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5004 should not include the
5005 @code{Exception_Name}.  @code{Exception_Information} should include both
5006 the @code{Exception_Name} and the @code{Exception_Message}.
5007 @end cartouche
5008 Followed.  For each exception that doesn't have a specified
5009 @code{Exception_Message}, the compiler generates one containing the location
5010 of the raise statement.  This location has the form ``file:line'', where
5011 file is the short file name (without path information) and line is the line
5012 number in the file.  Note that in the case of the Zero Cost Exception
5013 mechanism, these messages become redundant with the Exception_Information that
5014 contains a full backtrace of the calling sequence, so they are disabled.
5015 To disable explicitly the generation of the source location message, use the
5016 Pragma @code{Discard_Names}.
5017
5018 @cindex Suppression of checks
5019 @cindex Checks, suppression of
5020 @unnumberedsec 11.5(28): Suppression of Checks
5021 @sp 1
5022 @cartouche
5023 The implementation should minimize the code executed for checks that
5024 have been suppressed.
5025 @end cartouche
5026 Followed.
5027
5028 @cindex Representation clauses
5029 @unnumberedsec 13.1 (21-24): Representation Clauses
5030 @sp 1
5031 @cartouche
5032 The recommended level of support for all representation items is
5033 qualified as follows:
5034 @end cartouche
5035 @sp 1
5036 @cartouche
5037 An implementation need not support representation items containing
5038 non-static expressions, except that an implementation should support a
5039 representation item for a given entity if each non-static expression in
5040 the representation item is a name that statically denotes a constant
5041 declared before the entity.
5042 @end cartouche
5043 Followed.  GNAT does not support non-static expressions in representation
5044 clauses unless they are constants declared before the entity.  For
5045 example:
5046
5047 @smallexample @c ada
5048 X : Some_Type;
5049 for X'Address use To_address (16#2000#);
5050 @end smallexample
5051
5052 @noindent
5053 will be rejected, since the To_Address expression is non-static.  Instead
5054 write:
5055
5056 @smallexample @c ada
5057 X_Address : constant Address : = To_Address (16#2000#);
5058 X         : Some_Type;
5059 for X'Address use X_Address;
5060 @end smallexample
5061
5062 @sp 1
5063 @cartouche
5064 An implementation need not support a specification for the @code{Size}
5065 for a given composite subtype, nor the size or storage place for an
5066 object (including a component) of a given composite subtype, unless the
5067 constraints on the subtype and its composite subcomponents (if any) are
5068 all static constraints.
5069 @end cartouche
5070 Followed.  Size Clauses are not permitted on non-static components, as
5071 described above.
5072
5073 @sp 1
5074 @cartouche
5075 An aliased component, or a component whose type is by-reference, should
5076 always be allocated at an addressable location.
5077 @end cartouche
5078 Followed.
5079
5080 @cindex Packed types
5081 @unnumberedsec 13.2(6-8): Packed Types
5082 @sp 1
5083 @cartouche
5084 If a type is packed, then the implementation should try to minimize
5085 storage allocated to objects of the type, possibly at the expense of
5086 speed of accessing components, subject to reasonable complexity in
5087 addressing calculations.
5088 @end cartouche
5089 @sp 1
5090 @cartouche
5091 The recommended level of support pragma @code{Pack} is:
5092
5093 For a packed record type, the components should be packed as tightly as
5094 possible subject to the Sizes of the component subtypes, and subject to
5095 any @code{record_representation_clause} that applies to the type; the
5096 implementation may, but need not, reorder components or cross aligned
5097 word boundaries to improve the packing.  A component whose @code{Size} is
5098 greater than the word size may be allocated an integral number of words.
5099 @end cartouche
5100 Followed.  Tight packing of arrays is supported for all component sizes
5101 up to 64-bits. If the array component size is 1 (that is to say, if
5102 the component is a boolean type or an enumeration type with two values)
5103 then values of the type are implicitly initialized to zero. This
5104 happens both for objects of the packed type, and for objects that have a
5105 subcomponent of the packed type.
5106
5107 @sp 1
5108 @cartouche
5109 An implementation should support Address clauses for imported
5110 subprograms.
5111 @end cartouche
5112 Followed.
5113 @cindex @code{Address} clauses
5114 @unnumberedsec 13.3(14-19): Address Clauses
5115
5116 @sp 1
5117 @cartouche
5118 For an array @var{X}, @code{@var{X}'Address} should point at the first
5119 component of the array, and not at the array bounds.
5120 @end cartouche
5121 Followed.
5122
5123 @sp 1
5124 @cartouche
5125 The recommended level of support for the @code{Address} attribute is:
5126
5127 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5128 object that is aliased or of a by-reference type, or is an entity whose
5129 @code{Address} has been specified.
5130 @end cartouche
5131 Followed.  A valid address will be produced even if none of those
5132 conditions have been met.  If necessary, the object is forced into
5133 memory to ensure the address is valid.
5134
5135 @sp 1
5136 @cartouche
5137 An implementation should support @code{Address} clauses for imported
5138 subprograms.
5139 @end cartouche
5140 Followed.
5141
5142 @sp 1
5143 @cartouche
5144 Objects (including subcomponents) that are aliased or of a by-reference
5145 type should be allocated on storage element boundaries.
5146 @end cartouche
5147 Followed.
5148
5149 @sp 1
5150 @cartouche
5151 If the @code{Address} of an object is specified, or it is imported or exported,
5152 then the implementation should not perform optimizations based on
5153 assumptions of no aliases.
5154 @end cartouche
5155 Followed.
5156
5157 @cindex @code{Alignment} clauses
5158 @unnumberedsec 13.3(29-35): Alignment Clauses
5159 @sp 1
5160 @cartouche
5161 The recommended level of support for the @code{Alignment} attribute for
5162 subtypes is:
5163
5164 An implementation should support specified Alignments that are factors
5165 and multiples of the number of storage elements per word, subject to the
5166 following:
5167 @end cartouche
5168 Followed.
5169
5170 @sp 1
5171 @cartouche
5172 An implementation need not support specified @code{Alignment}s for
5173 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5174 loaded and stored by available machine instructions.
5175 @end cartouche
5176 Followed.
5177
5178 @sp 1
5179 @cartouche
5180 An implementation need not support specified @code{Alignment}s that are
5181 greater than the maximum @code{Alignment} the implementation ever returns by
5182 default.
5183 @end cartouche
5184 Followed.
5185
5186 @sp 1
5187 @cartouche
5188 The recommended level of support for the @code{Alignment} attribute for
5189 objects is:
5190
5191 Same as above, for subtypes, but in addition:
5192 @end cartouche
5193 Followed.
5194
5195 @sp 1
5196 @cartouche
5197 For stand-alone library-level objects of statically constrained
5198 subtypes, the implementation should support all @code{Alignment}s
5199 supported by the target linker.  For example, page alignment is likely to
5200 be supported for such objects, but not for subtypes.
5201 @end cartouche
5202 Followed.
5203
5204 @cindex @code{Size} clauses
5205 @unnumberedsec 13.3(42-43): Size Clauses
5206 @sp 1
5207 @cartouche
5208 The recommended level of support for the @code{Size} attribute of
5209 objects is:
5210
5211 A @code{Size} clause should be supported for an object if the specified
5212 @code{Size} is at least as large as its subtype's @code{Size}, and
5213 corresponds to a size in storage elements that is a multiple of the
5214 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5215 @end cartouche
5216 Followed.
5217
5218 @unnumberedsec 13.3(50-56): Size Clauses
5219 @sp 1
5220 @cartouche
5221 If the @code{Size} of a subtype is specified, and allows for efficient
5222 independent addressability (see 9.10) on the target architecture, then
5223 the @code{Size} of the following objects of the subtype should equal the
5224 @code{Size} of the subtype:
5225
5226 Aliased objects (including components).
5227 @end cartouche
5228 Followed.
5229
5230 @sp 1
5231 @cartouche
5232 @code{Size} clause on a composite subtype should not affect the
5233 internal layout of components.
5234 @end cartouche
5235 Followed.
5236
5237 @sp 1
5238 @cartouche
5239 The recommended level of support for the @code{Size} attribute of subtypes is:
5240 @end cartouche
5241 @sp 1
5242 @cartouche
5243 The @code{Size} (if not specified) of a static discrete or fixed point
5244 subtype should be the number of bits needed to represent each value
5245 belonging to the subtype using an unbiased representation, leaving space
5246 for a sign bit only if the subtype contains negative values.  If such a
5247 subtype is a first subtype, then an implementation should support a
5248 specified @code{Size} for it that reflects this representation.
5249 @end cartouche
5250 Followed.
5251
5252 @sp 1
5253 @cartouche
5254 For a subtype implemented with levels of indirection, the @code{Size}
5255 should include the size of the pointers, but not the size of what they
5256 point at.
5257 @end cartouche
5258 Followed.
5259
5260 @cindex @code{Component_Size} clauses
5261 @unnumberedsec 13.3(71-73): Component Size Clauses
5262 @sp 1
5263 @cartouche
5264 The recommended level of support for the @code{Component_Size}
5265 attribute is:
5266 @end cartouche
5267 @sp 1
5268 @cartouche
5269 An implementation need not support specified @code{Component_Sizes} that are
5270 less than the @code{Size} of the component subtype.
5271 @end cartouche
5272 Followed.
5273
5274 @sp 1
5275 @cartouche
5276 An implementation should support specified @code{Component_Size}s that
5277 are factors and multiples of the word size.  For such
5278 @code{Component_Size}s, the array should contain no gaps between
5279 components.  For other @code{Component_Size}s (if supported), the array
5280 should contain no gaps between components when packing is also
5281 specified; the implementation should forbid this combination in cases
5282 where it cannot support a no-gaps representation.
5283 @end cartouche
5284 Followed.
5285
5286 @cindex Enumeration representation clauses
5287 @cindex Representation clauses, enumeration
5288 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5289 @sp 1
5290 @cartouche
5291 The recommended level of support for enumeration representation clauses
5292 is:
5293
5294 An implementation need not support enumeration representation clauses
5295 for boolean types, but should at minimum support the internal codes in
5296 the range @code{System.Min_Int.System.Max_Int}.
5297 @end cartouche
5298 Followed.
5299
5300 @cindex Record representation clauses
5301 @cindex Representation clauses, records
5302 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5303 @sp 1
5304 @cartouche
5305 The recommended level of support for
5306 @*@code{record_representation_clauses} is:
5307
5308 An implementation should support storage places that can be extracted
5309 with a load, mask, shift sequence of machine code, and set with a load,
5310 shift, mask, store sequence, given the available machine instructions
5311 and run-time model.
5312 @end cartouche
5313 Followed.
5314
5315 @sp 1
5316 @cartouche
5317 A storage place should be supported if its size is equal to the
5318 @code{Size} of the component subtype, and it starts and ends on a
5319 boundary that obeys the @code{Alignment} of the component subtype.
5320 @end cartouche
5321 Followed.
5322
5323 @sp 1
5324 @cartouche
5325 If the default bit ordering applies to the declaration of a given type,
5326 then for a component whose subtype's @code{Size} is less than the word
5327 size, any storage place that does not cross an aligned word boundary
5328 should be supported.
5329 @end cartouche
5330 Followed.
5331
5332 @sp 1
5333 @cartouche
5334 An implementation may reserve a storage place for the tag field of a
5335 tagged type, and disallow other components from overlapping that place.
5336 @end cartouche
5337 Followed.  The storage place for the tag field is the beginning of the tagged
5338 record, and its size is Address'Size.  GNAT will reject an explicit component
5339 clause for the tag field.
5340
5341 @sp 1
5342 @cartouche
5343 An implementation need not support a @code{component_clause} for a
5344 component of an extension part if the storage place is not after the
5345 storage places of all components of the parent type, whether or not
5346 those storage places had been specified.
5347 @end cartouche
5348 Followed.  The above advice on record representation clauses is followed,
5349 and all mentioned features are implemented.
5350
5351 @cindex Storage place attributes
5352 @unnumberedsec 13.5.2(5): Storage Place Attributes
5353 @sp 1
5354 @cartouche
5355 If a component is represented using some form of pointer (such as an
5356 offset) to the actual data of the component, and this data is contiguous
5357 with the rest of the object, then the storage place attributes should
5358 reflect the place of the actual data, not the pointer.  If a component is
5359 allocated discontinuously from the rest of the object, then a warning
5360 should be generated upon reference to one of its storage place
5361 attributes.
5362 @end cartouche
5363 Followed.  There are no such components in GNAT@.
5364
5365 @cindex Bit ordering
5366 @unnumberedsec 13.5.3(7-8): Bit Ordering
5367 @sp 1
5368 @cartouche
5369 The recommended level of support for the non-default bit ordering is:
5370 @end cartouche
5371 @sp 1
5372 @cartouche
5373 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5374 should support the non-default bit ordering in addition to the default
5375 bit ordering.
5376 @end cartouche
5377 Followed.  Word size does not equal storage size in this implementation.
5378 Thus non-default bit ordering is not supported.
5379
5380 @cindex @code{Address}, as private type
5381 @unnumberedsec 13.7(37): Address as Private
5382 @sp 1
5383 @cartouche
5384 @code{Address} should be of a private type.
5385 @end cartouche
5386 Followed.
5387
5388 @cindex Operations, on @code{Address}
5389 @cindex @code{Address}, operations of
5390 @unnumberedsec 13.7.1(16): Address Operations
5391 @sp 1
5392 @cartouche
5393 Operations in @code{System} and its children should reflect the target
5394 environment semantics as closely as is reasonable.  For example, on most
5395 machines, it makes sense for address arithmetic to ``wrap around''.
5396 Operations that do not make sense should raise @code{Program_Error}.
5397 @end cartouche
5398 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5399 operation raises @code{Program_Error}, since all operations make sense.
5400
5401 @cindex Unchecked conversion
5402 @unnumberedsec 13.9(14-17): Unchecked Conversion
5403 @sp 1
5404 @cartouche
5405 The @code{Size} of an array object should not include its bounds; hence,
5406 the bounds should not be part of the converted data.
5407 @end cartouche
5408 Followed.
5409
5410 @sp 1
5411 @cartouche
5412 The implementation should not generate unnecessary run-time checks to
5413 ensure that the representation of @var{S} is a representation of the
5414 target type.  It should take advantage of the permission to return by
5415 reference when possible.  Restrictions on unchecked conversions should be
5416 avoided unless required by the target environment.
5417 @end cartouche
5418 Followed.  There are no restrictions on unchecked conversion.  A warning is
5419 generated if the source and target types do not have the same size since
5420 the semantics in this case may be target dependent.
5421
5422 @sp 1
5423 @cartouche
5424 The recommended level of support for unchecked conversions is:
5425 @end cartouche
5426 @sp 1
5427 @cartouche
5428 Unchecked conversions should be supported and should be reversible in
5429 the cases where this clause defines the result.  To enable meaningful use
5430 of unchecked conversion, a contiguous representation should be used for
5431 elementary subtypes, for statically constrained array subtypes whose
5432 component subtype is one of the subtypes described in this paragraph,
5433 and for record subtypes without discriminants whose component subtypes
5434 are described in this paragraph.
5435 @end cartouche
5436 Followed.
5437
5438 @cindex Heap usage, implicit
5439 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5440 @sp 1
5441 @cartouche
5442 An implementation should document any cases in which it dynamically
5443 allocates heap storage for a purpose other than the evaluation of an
5444 allocator.
5445 @end cartouche
5446 Followed, the only other points at which heap storage is dynamically
5447 allocated are as follows:
5448
5449 @itemize @bullet
5450 @item
5451 At initial elaboration time, to allocate dynamically sized global
5452 objects.
5453
5454 @item
5455 To allocate space for a task when a task is created.
5456
5457 @item
5458 To extend the secondary stack dynamically when needed.  The secondary
5459 stack is used for returning variable length results.
5460 @end itemize
5461
5462 @sp 1
5463 @cartouche
5464 A default (implementation-provided) storage pool for an
5465 access-to-constant type should not have overhead to support deallocation of
5466 individual objects.
5467 @end cartouche
5468 Followed.
5469
5470 @sp 1
5471 @cartouche
5472 A storage pool for an anonymous access type should be created at the
5473 point of an allocator for the type, and be reclaimed when the designated
5474 object becomes inaccessible.
5475 @end cartouche
5476 Followed.
5477
5478 @cindex Unchecked deallocation
5479 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5480 @sp 1
5481 @cartouche
5482 For a standard storage pool, @code{Free} should actually reclaim the
5483 storage.
5484 @end cartouche
5485 Followed.
5486
5487 @cindex Stream oriented attributes
5488 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5489 @sp 1
5490 @cartouche
5491 If a stream element is the same size as a storage element, then the
5492 normal in-memory representation should be used by @code{Read} and
5493 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5494 should use the smallest number of stream elements needed to represent
5495 all values in the base range of the scalar type.
5496 @end cartouche
5497
5498 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5499 which specifies using the size of the first subtype.
5500 However, such an implementation is based on direct binary
5501 representations and is therefore target- and endianness-dependent.
5502 To address this issue, GNAT also supplies an alternate implementation
5503 of the stream attributes @code{Read} and @code{Write},
5504 which uses the target-independent XDR standard representation
5505 for scalar types.
5506 @cindex XDR representation
5507 @cindex @code{Read} attribute
5508 @cindex @code{Write} attribute
5509 @cindex Stream oriented attributes
5510 The XDR implementation is provided as an alternative body of the
5511 @code{System.Stream_Attributes} package, in the file
5512 @file{s-strxdr.adb} in the GNAT library.
5513 There is no @file{s-strxdr.ads} file.
5514 In order to install the XDR implementation, do the following:
5515 @enumerate
5516 @item Replace the default implementation of the
5517 @code{System.Stream_Attributes} package with the XDR implementation.
5518 For example on a Unix platform issue the commands:
5519 @smallexample
5520 $ mv s-stratt.adb s-strold.adb
5521 $ mv s-strxdr.adb s-stratt.adb
5522 @end smallexample
5523
5524 @item
5525 Rebuild the GNAT run-time library as documented in the
5526 @cite{GNAT User's Guide}
5527 @end enumerate
5528
5529 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5530 @sp 1
5531 @cartouche
5532 If an implementation provides additional named predefined integer types,
5533 then the names should end with @samp{Integer} as in
5534 @samp{Long_Integer}.  If an implementation provides additional named
5535 predefined floating point types, then the names should end with
5536 @samp{Float} as in @samp{Long_Float}.
5537 @end cartouche
5538 Followed.
5539
5540 @findex Ada.Characters.Handling
5541 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5542 @sp 1
5543 @cartouche
5544 If an implementation provides a localized definition of @code{Character}
5545 or @code{Wide_Character}, then the effects of the subprograms in
5546 @code{Characters.Handling} should reflect the localizations.  See also
5547 3.5.2.
5548 @end cartouche
5549 Followed.  GNAT provides no such localized definitions.
5550
5551 @cindex Bounded-length strings
5552 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5553 @sp 1
5554 @cartouche
5555 Bounded string objects should not be implemented by implicit pointers
5556 and dynamic allocation.
5557 @end cartouche
5558 Followed.  No implicit pointers or dynamic allocation are used.
5559
5560 @cindex Random number generation
5561 @unnumberedsec A.5.2(46-47): Random Number Generation
5562 @sp 1
5563 @cartouche
5564 Any storage associated with an object of type @code{Generator} should be
5565 reclaimed on exit from the scope of the object.
5566 @end cartouche
5567 Followed.
5568
5569 @sp 1
5570 @cartouche
5571 If the generator period is sufficiently long in relation to the number
5572 of distinct initiator values, then each possible value of
5573 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5574 random numbers that does not, in a practical sense, overlap the sequence
5575 initiated by any other value.  If this is not possible, then the mapping
5576 between initiator values and generator states should be a rapidly
5577 varying function of the initiator value.
5578 @end cartouche
5579 Followed.  The generator period is sufficiently long for the first
5580 condition here to hold true.
5581
5582 @findex Get_Immediate
5583 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5584 @sp 1
5585 @cartouche
5586 The @code{Get_Immediate} procedures should be implemented with
5587 unbuffered input.  For a device such as a keyboard, input should be
5588 @dfn{available} if a key has already been typed, whereas for a disk
5589 file, input should always be available except at end of file.  For a file
5590 associated with a keyboard-like device, any line-editing features of the
5591 underlying operating system should be disabled during the execution of
5592 @code{Get_Immediate}.
5593 @end cartouche
5594 Followed on all targets except VxWorks. For VxWorks, there is no way to
5595 provide this functionality that does not result in the input buffer being
5596 flushed before the @code{Get_Immediate} call. A special unit
5597 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5598 this functionality.
5599
5600 @findex Export
5601 @unnumberedsec B.1(39-41): Pragma @code{Export}
5602 @sp 1
5603 @cartouche
5604 If an implementation supports pragma @code{Export} to a given language,
5605 then it should also allow the main subprogram to be written in that
5606 language.  It should support some mechanism for invoking the elaboration
5607 of the Ada library units included in the system, and for invoking the
5608 finalization of the environment task.  On typical systems, the
5609 recommended mechanism is to provide two subprograms whose link names are
5610 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5611 elaboration code for library units.  @code{adafinal} should contain the
5612 finalization code.  These subprograms should have no effect the second
5613 and subsequent time they are called.
5614 @end cartouche
5615 Followed.
5616
5617 @sp 1
5618 @cartouche
5619 Automatic elaboration of pre-elaborated packages should be
5620 provided when pragma @code{Export} is supported.
5621 @end cartouche
5622 Followed when the main program is in Ada.  If the main program is in a
5623 foreign language, then
5624 @code{adainit} must be called to elaborate pre-elaborated
5625 packages.
5626
5627 @sp 1
5628 @cartouche
5629 For each supported convention @var{L} other than @code{Intrinsic}, an
5630 implementation should support @code{Import} and @code{Export} pragmas
5631 for objects of @var{L}-compatible types and for subprograms, and pragma
5632 @code{Convention} for @var{L}-eligible types and for subprograms,
5633 presuming the other language has corresponding features.  Pragma
5634 @code{Convention} need not be supported for scalar types.
5635 @end cartouche
5636 Followed.
5637
5638 @cindex Package @code{Interfaces}
5639 @findex Interfaces
5640 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5641 @sp 1
5642 @cartouche
5643 For each implementation-defined convention identifier, there should be a
5644 child package of package Interfaces with the corresponding name.  This
5645 package should contain any declarations that would be useful for
5646 interfacing to the language (implementation) represented by the
5647 convention.  Any declarations useful for interfacing to any language on
5648 the given hardware architecture should be provided directly in
5649 @code{Interfaces}.
5650 @end cartouche
5651 Followed.  An additional package not defined
5652 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5653 for interfacing to C++.
5654
5655 @sp 1
5656 @cartouche
5657 An implementation supporting an interface to C, COBOL, or Fortran should
5658 provide the corresponding package or packages described in the following
5659 clauses.
5660 @end cartouche
5661 Followed.  GNAT provides all the packages described in this section.
5662
5663 @cindex C, interfacing with
5664 @unnumberedsec B.3(63-71): Interfacing with C
5665 @sp 1
5666 @cartouche
5667 An implementation should support the following interface correspondences
5668 between Ada and C@.
5669 @end cartouche
5670 Followed.
5671
5672 @sp 1
5673 @cartouche
5674 An Ada procedure corresponds to a void-returning C function.
5675 @end cartouche
5676 Followed.
5677
5678 @sp 1
5679 @cartouche
5680 An Ada function corresponds to a non-void C function.
5681 @end cartouche
5682 Followed.
5683
5684 @sp 1
5685 @cartouche
5686 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5687 function.
5688 @end cartouche
5689 Followed.
5690
5691 @sp 1
5692 @cartouche
5693 An Ada @code{in} parameter of an access-to-object type with designated
5694 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5695 where @var{t} is the C type corresponding to the Ada type @var{T}.
5696 @end cartouche
5697 Followed.
5698
5699 @sp 1
5700 @cartouche
5701 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5702 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5703 argument to a C function, where @var{t} is the C type corresponding to
5704 the Ada type @var{T}.  In the case of an elementary @code{out} or
5705 @code{in out} parameter, a pointer to a temporary copy is used to
5706 preserve by-copy semantics.
5707 @end cartouche
5708 Followed.
5709
5710 @sp 1
5711 @cartouche
5712 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5713 @code{@var{t}*} argument to a C function, where @var{t} is the C
5714 structure corresponding to the Ada type @var{T}.
5715 @end cartouche
5716 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5717 pragma, or Convention, or by explicitly specifying the mechanism for a given
5718 call using an extended import or export pragma.
5719
5720 @sp 1
5721 @cartouche
5722 An Ada parameter of an array type with component type @var{T}, of any
5723 mode, is passed as a @code{@var{t}*} argument to a C function, where
5724 @var{t} is the C type corresponding to the Ada type @var{T}.
5725 @end cartouche
5726 Followed.
5727
5728 @sp 1
5729 @cartouche
5730 An Ada parameter of an access-to-subprogram type is passed as a pointer
5731 to a C function whose prototype corresponds to the designated
5732 subprogram's specification.
5733 @end cartouche
5734 Followed.
5735
5736 @cindex COBOL, interfacing with
5737 @unnumberedsec B.4(95-98): Interfacing with COBOL
5738 @sp 1
5739 @cartouche
5740 An Ada implementation should support the following interface
5741 correspondences between Ada and COBOL@.
5742 @end cartouche
5743 Followed.
5744
5745 @sp 1
5746 @cartouche
5747 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5748 the COBOL type corresponding to @var{T}.
5749 @end cartouche
5750 Followed.
5751
5752 @sp 1
5753 @cartouche
5754 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5755 the corresponding COBOL type.
5756 @end cartouche
5757 Followed.
5758
5759 @sp 1
5760 @cartouche
5761 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5762 COBOL type corresponding to the Ada parameter type; for scalars, a local
5763 copy is used if necessary to ensure by-copy semantics.
5764 @end cartouche
5765 Followed.
5766
5767 @cindex Fortran, interfacing with
5768 @unnumberedsec B.5(22-26): Interfacing with Fortran
5769 @sp 1
5770 @cartouche
5771 An Ada implementation should support the following interface
5772 correspondences between Ada and Fortran:
5773 @end cartouche
5774 Followed.
5775
5776 @sp 1
5777 @cartouche
5778 An Ada procedure corresponds to a Fortran subroutine.
5779 @end cartouche
5780 Followed.
5781
5782 @sp 1
5783 @cartouche
5784 An Ada function corresponds to a Fortran function.
5785 @end cartouche
5786 Followed.
5787
5788 @sp 1
5789 @cartouche
5790 An Ada parameter of an elementary, array, or record type @var{T} is
5791 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5792 the Fortran type corresponding to the Ada type @var{T}, and where the
5793 INTENT attribute of the corresponding dummy argument matches the Ada
5794 formal parameter mode; the Fortran implementation's parameter passing
5795 conventions are used.  For elementary types, a local copy is used if
5796 necessary to ensure by-copy semantics.
5797 @end cartouche
5798 Followed.
5799
5800 @sp 1
5801 @cartouche
5802 An Ada parameter of an access-to-subprogram type is passed as a
5803 reference to a Fortran procedure whose interface corresponds to the
5804 designated subprogram's specification.
5805 @end cartouche
5806 Followed.
5807
5808 @cindex Machine operations
5809 @unnumberedsec C.1(3-5): Access to Machine Operations
5810 @sp 1
5811 @cartouche
5812 The machine code or intrinsic support should allow access to all
5813 operations normally available to assembly language programmers for the
5814 target environment, including privileged instructions, if any.
5815 @end cartouche
5816 Followed.
5817
5818 @sp 1
5819 @cartouche
5820 The interfacing pragmas (see Annex B) should support interface to
5821 assembler; the default assembler should be associated with the
5822 convention identifier @code{Assembler}.
5823 @end cartouche
5824 Followed.
5825
5826 @sp 1
5827 @cartouche
5828 If an entity is exported to assembly language, then the implementation
5829 should allocate it at an addressable location, and should ensure that it
5830 is retained by the linking process, even if not otherwise referenced
5831 from the Ada code.  The implementation should assume that any call to a
5832 machine code or assembler subprogram is allowed to read or update every
5833 object that is specified as exported.
5834 @end cartouche
5835 Followed.
5836
5837 @unnumberedsec C.1(10-16): Access to Machine Operations
5838 @sp 1
5839 @cartouche
5840 The implementation should ensure that little or no overhead is
5841 associated with calling intrinsic and machine-code subprograms.
5842 @end cartouche
5843 Followed for both intrinsics and machine-code subprograms.
5844
5845 @sp 1
5846 @cartouche
5847 It is recommended that intrinsic subprograms be provided for convenient
5848 access to any machine operations that provide special capabilities or
5849 efficiency and that are not otherwise available through the language
5850 constructs.
5851 @end cartouche
5852 Followed.  A full set of machine operation intrinsic subprograms is provided.
5853
5854 @sp 1
5855 @cartouche
5856 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5857 swap, decrement and test, enqueue/dequeue.
5858 @end cartouche
5859 Followed on any target supporting such operations.
5860
5861 @sp 1
5862 @cartouche
5863 Standard numeric functions---e.g.@:, sin, log.
5864 @end cartouche
5865 Followed on any target supporting such operations.
5866
5867 @sp 1
5868 @cartouche
5869 String manipulation operations---e.g.@:, translate and test.
5870 @end cartouche
5871 Followed on any target supporting such operations.
5872
5873 @sp 1
5874 @cartouche
5875 Vector operations---e.g.@:, compare vector against thresholds.
5876 @end cartouche
5877 Followed on any target supporting such operations.
5878
5879 @sp 1
5880 @cartouche
5881 Direct operations on I/O ports.
5882 @end cartouche
5883 Followed on any target supporting such operations.
5884
5885 @cindex Interrupt support
5886 @unnumberedsec C.3(28): Interrupt Support
5887 @sp 1
5888 @cartouche
5889 If the @code{Ceiling_Locking} policy is not in effect, the
5890 implementation should provide means for the application to specify which
5891 interrupts are to be blocked during protected actions, if the underlying
5892 system allows for a finer-grain control of interrupt blocking.
5893 @end cartouche
5894 Followed.  The underlying system does not allow for finer-grain control
5895 of interrupt blocking.
5896
5897 @cindex Protected procedure handlers
5898 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5899 @sp 1
5900 @cartouche
5901 Whenever possible, the implementation should allow interrupt handlers to
5902 be called directly by the hardware.
5903 @end cartouche
5904 @c SGI info:
5905 @ignore
5906 This is never possible under IRIX, so this is followed by default.
5907 @end ignore
5908 Followed on any target where the underlying operating system permits
5909 such direct calls.
5910
5911 @sp 1
5912 @cartouche
5913 Whenever practical, violations of any
5914 implementation-defined restrictions should be detected before run time.
5915 @end cartouche
5916 Followed.  Compile time warnings are given when possible.
5917
5918 @cindex Package @code{Interrupts}
5919 @findex Interrupts
5920 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5921
5922 @sp 1
5923 @cartouche
5924 If implementation-defined forms of interrupt handler procedures are
5925 supported, such as protected procedures with parameters, then for each
5926 such form of a handler, a type analogous to @code{Parameterless_Handler}
5927 should be specified in a child package of @code{Interrupts}, with the
5928 same operations as in the predefined package Interrupts.
5929 @end cartouche
5930 Followed.
5931
5932 @cindex Pre-elaboration requirements
5933 @unnumberedsec C.4(14): Pre-elaboration Requirements
5934 @sp 1
5935 @cartouche
5936 It is recommended that pre-elaborated packages be implemented in such a
5937 way that there should be little or no code executed at run time for the
5938 elaboration of entities not already covered by the Implementation
5939 Requirements.
5940 @end cartouche
5941 Followed.  Executable code is generated in some cases, e.g.@: loops
5942 to initialize large arrays.
5943
5944 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5945
5946 @sp 1
5947 @cartouche
5948 If the pragma applies to an entity, then the implementation should
5949 reduce the amount of storage used for storing names associated with that
5950 entity.
5951 @end cartouche
5952 Followed.
5953
5954 @cindex Package @code{Task_Attributes}
5955 @findex Task_Attributes
5956 @unnumberedsec C.7.2(30): The Package Task_Attributes
5957 @sp 1
5958 @cartouche
5959 Some implementations are targeted to domains in which memory use at run
5960 time must be completely deterministic.  For such implementations, it is
5961 recommended that the storage for task attributes will be pre-allocated
5962 statically and not from the heap.  This can be accomplished by either
5963 placing restrictions on the number and the size of the task's
5964 attributes, or by using the pre-allocated storage for the first @var{N}
5965 attribute objects, and the heap for the others.  In the latter case,
5966 @var{N} should be documented.
5967 @end cartouche
5968 Not followed.  This implementation is not targeted to such a domain.
5969
5970 @cindex Locking Policies
5971 @unnumberedsec D.3(17): Locking Policies
5972
5973 @sp 1
5974 @cartouche
5975 The implementation should use names that end with @samp{_Locking} for
5976 locking policies defined by the implementation.
5977 @end cartouche
5978 Followed.  A single implementation-defined locking policy is defined,
5979 whose name (@code{Inheritance_Locking}) follows this suggestion.
5980
5981 @cindex Entry queuing policies
5982 @unnumberedsec D.4(16): Entry Queuing Policies
5983 @sp 1
5984 @cartouche
5985 Names that end with @samp{_Queuing} should be used
5986 for all implementation-defined queuing policies.
5987 @end cartouche
5988 Followed.  No such implementation-defined queuing policies exist.
5989
5990 @cindex Preemptive abort
5991 @unnumberedsec D.6(9-10): Preemptive Abort
5992 @sp 1
5993 @cartouche
5994 Even though the @code{abort_statement} is included in the list of
5995 potentially blocking operations (see 9.5.1), it is recommended that this
5996 statement be implemented in a way that never requires the task executing
5997 the @code{abort_statement} to block.
5998 @end cartouche
5999 Followed.
6000
6001 @sp 1
6002 @cartouche
6003 On a multi-processor, the delay associated with aborting a task on
6004 another processor should be bounded; the implementation should use
6005 periodic polling, if necessary, to achieve this.
6006 @end cartouche
6007 Followed.
6008
6009 @cindex Tasking restrictions
6010 @unnumberedsec D.7(21): Tasking Restrictions
6011 @sp 1
6012 @cartouche
6013 When feasible, the implementation should take advantage of the specified
6014 restrictions to produce a more efficient implementation.
6015 @end cartouche
6016 GNAT currently takes advantage of these restrictions by providing an optimized
6017 run time when the Ravenscar profile and the GNAT restricted run time set
6018 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6019 pragma @code{Restricted_Run_Time} for more details.
6020
6021 @cindex Time, monotonic
6022 @unnumberedsec D.8(47-49): Monotonic Time
6023 @sp 1
6024 @cartouche
6025 When appropriate, implementations should provide configuration
6026 mechanisms to change the value of @code{Tick}.
6027 @end cartouche
6028 Such configuration mechanisms are not appropriate to this implementation
6029 and are thus not supported.
6030
6031 @sp 1
6032 @cartouche
6033 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6034 be implemented as transformations of the same time base.
6035 @end cartouche
6036 Followed.
6037
6038 @sp 1
6039 @cartouche
6040 It is recommended that the @dfn{best} time base which exists in
6041 the underlying system be available to the application through
6042 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6043 @end cartouche
6044 Followed.
6045
6046 @cindex Partition communication subsystem
6047 @cindex PCS
6048 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6049 @sp 1
6050 @cartouche
6051 Whenever possible, the PCS on the called partition should allow for
6052 multiple tasks to call the RPC-receiver with different messages and
6053 should allow them to block until the corresponding subprogram body
6054 returns.
6055 @end cartouche
6056 Followed by GLADE, a separately supplied PCS that can be used with
6057 GNAT.
6058
6059 @sp 1
6060 @cartouche
6061 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6062 should raise @code{Storage_Error} if it runs out of space trying to
6063 write the @code{Item} into the stream.
6064 @end cartouche
6065 Followed by GLADE, a separately supplied PCS that can be used with
6066 GNAT@.
6067
6068 @cindex COBOL support
6069 @unnumberedsec F(7): COBOL Support
6070 @sp 1
6071 @cartouche
6072 If COBOL (respectively, C) is widely supported in the target
6073 environment, implementations supporting the Information Systems Annex
6074 should provide the child package @code{Interfaces.COBOL} (respectively,
6075 @code{Interfaces.C}) specified in Annex B and should support a
6076 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6077 pragmas (see Annex B), thus allowing Ada programs to interface with
6078 programs written in that language.
6079 @end cartouche
6080 Followed.
6081
6082 @cindex Decimal radix support
6083 @unnumberedsec F.1(2): Decimal Radix Support
6084 @sp 1
6085 @cartouche
6086 Packed decimal should be used as the internal representation for objects
6087 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6088 @end cartouche
6089 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6090 representations.
6091
6092 @cindex Numerics
6093 @unnumberedsec G: Numerics
6094 @sp 2
6095 @cartouche
6096 If Fortran (respectively, C) is widely supported in the target
6097 environment, implementations supporting the Numerics Annex
6098 should provide the child package @code{Interfaces.Fortran} (respectively,
6099 @code{Interfaces.C}) specified in Annex B and should support a
6100 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6101 pragmas (see Annex B), thus allowing Ada programs to interface with
6102 programs written in that language.
6103 @end cartouche
6104 Followed.
6105
6106 @cindex Complex types
6107 @unnumberedsec G.1.1(56-58): Complex Types
6108 @sp 2
6109 @cartouche
6110 Because the usual mathematical meaning of multiplication of a complex
6111 operand and a real operand is that of the scaling of both components of
6112 the former by the latter, an implementation should not perform this
6113 operation by first promoting the real operand to complex type and then
6114 performing a full complex multiplication.  In systems that, in the
6115 future, support an Ada binding to IEC 559:1989, the latter technique
6116 will not generate the required result when one of the components of the
6117 complex operand is infinite.  (Explicit multiplication of the infinite
6118 component by the zero component obtained during promotion yields a NaN
6119 that propagates into the final result.) Analogous advice applies in the
6120 case of multiplication of a complex operand and a pure-imaginary
6121 operand, and in the case of division of a complex operand by a real or
6122 pure-imaginary operand.
6123 @end cartouche
6124 Not followed.
6125
6126 @sp 1
6127 @cartouche
6128 Similarly, because the usual mathematical meaning of addition of a
6129 complex operand and a real operand is that the imaginary operand remains
6130 unchanged, an implementation should not perform this operation by first
6131 promoting the real operand to complex type and then performing a full
6132 complex addition.  In implementations in which the @code{Signed_Zeros}
6133 attribute of the component type is @code{True} (and which therefore
6134 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6135 predefined arithmetic operations), the latter technique will not
6136 generate the required result when the imaginary component of the complex
6137 operand is a negatively signed zero.  (Explicit addition of the negative
6138 zero to the zero obtained during promotion yields a positive zero.)
6139 Analogous advice applies in the case of addition of a complex operand
6140 and a pure-imaginary operand, and in the case of subtraction of a
6141 complex operand and a real or pure-imaginary operand.
6142 @end cartouche
6143 Not followed.
6144
6145 @sp 1
6146 @cartouche
6147 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6148 attempt to provide a rational treatment of the signs of zero results and
6149 result components.  As one example, the result of the @code{Argument}
6150 function should have the sign of the imaginary component of the
6151 parameter @code{X} when the point represented by that parameter lies on
6152 the positive real axis; as another, the sign of the imaginary component
6153 of the @code{Compose_From_Polar} function should be the same as
6154 (respectively, the opposite of) that of the @code{Argument} parameter when that
6155 parameter has a value of zero and the @code{Modulus} parameter has a
6156 nonnegative (respectively, negative) value.
6157 @end cartouche
6158 Followed.
6159
6160 @cindex Complex elementary functions
6161 @unnumberedsec G.1.2(49): Complex Elementary Functions
6162 @sp 1
6163 @cartouche
6164 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6165 @code{True} should attempt to provide a rational treatment of the signs
6166 of zero results and result components.  For example, many of the complex
6167 elementary functions have components that are odd functions of one of
6168 the parameter components; in these cases, the result component should
6169 have the sign of the parameter component at the origin.  Other complex
6170 elementary functions have zero components whose sign is opposite that of
6171 a parameter component at the origin, or is always positive or always
6172 negative.
6173 @end cartouche
6174 Followed.
6175
6176 @cindex Accuracy requirements
6177 @unnumberedsec G.2.4(19): Accuracy Requirements
6178 @sp 1
6179 @cartouche
6180 The versions of the forward trigonometric functions without a
6181 @code{Cycle} parameter should not be implemented by calling the
6182 corresponding version with a @code{Cycle} parameter of
6183 @code{2.0*Numerics.Pi}, since this will not provide the required
6184 accuracy in some portions of the domain.  For the same reason, the
6185 version of @code{Log} without a @code{Base} parameter should not be
6186 implemented by calling the corresponding version with a @code{Base}
6187 parameter of @code{Numerics.e}.
6188 @end cartouche
6189 Followed.
6190
6191 @cindex Complex arithmetic accuracy
6192 @cindex Accuracy, complex arithmetic
6193 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6194
6195 @sp 1
6196 @cartouche
6197 The version of the @code{Compose_From_Polar} function without a
6198 @code{Cycle} parameter should not be implemented by calling the
6199 corresponding version with a @code{Cycle} parameter of
6200 @code{2.0*Numerics.Pi}, since this will not provide the required
6201 accuracy in some portions of the domain.
6202 @end cartouche
6203 Followed.
6204
6205 @c -----------------------------------------
6206 @node Implementation Defined Characteristics
6207 @chapter Implementation Defined Characteristics
6208
6209 @noindent
6210 In addition to the implementation dependent pragmas and attributes, and
6211 the implementation advice, there are a number of other features of Ada
6212 95 that are potentially implementation dependent.  These are mentioned
6213 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6214
6215 A requirement for conforming Ada compilers is that they provide
6216 documentation describing how the implementation deals with each of these
6217 issues.  In this chapter, you will find each point in annex M listed
6218 followed by a description in italic font of how GNAT
6219 @c SGI info:
6220 @ignore
6221 in the ProDev Ada
6222 implementation on IRIX 5.3 operating system or greater
6223 @end ignore
6224 handles the implementation dependence.
6225
6226 You can use this chapter as a guide to minimizing implementation
6227 dependent features in your programs if portability to other compilers
6228 and other operating systems is an important consideration.  The numbers
6229 in each section below correspond to the paragraph number in the Ada 95
6230 Reference Manual.
6231
6232 @sp 1
6233 @cartouche
6234 @noindent
6235 @strong{2}.  Whether or not each recommendation given in Implementation
6236 Advice is followed.  See 1.1.2(37).
6237 @end cartouche
6238 @noindent
6239 @xref{Implementation Advice}.
6240
6241 @sp 1
6242 @cartouche
6243 @noindent
6244 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6245 @end cartouche
6246 @noindent
6247 The complexity of programs that can be processed is limited only by the
6248 total amount of available virtual memory, and disk space for the
6249 generated object files.
6250
6251 @sp 1
6252 @cartouche
6253 @noindent
6254 @strong{4}.  Variations from the standard that are impractical to avoid
6255 given the implementation's execution environment.  See 1.1.3(6).
6256 @end cartouche
6257 @noindent
6258 There are no variations from the standard.
6259
6260 @sp 1
6261 @cartouche
6262 @noindent
6263 @strong{5}.  Which @code{code_statement}s cause external
6264 interactions.  See 1.1.3(10).
6265 @end cartouche
6266 @noindent
6267 Any @code{code_statement} can potentially cause external interactions.
6268
6269 @sp 1
6270 @cartouche
6271 @noindent
6272 @strong{6}.  The coded representation for the text of an Ada
6273 program.  See 2.1(4).
6274 @end cartouche
6275 @noindent
6276 See separate section on source representation.
6277
6278 @sp 1
6279 @cartouche
6280 @noindent
6281 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6282 @end cartouche
6283 @noindent
6284 See separate section on source representation.
6285
6286 @sp 1
6287 @cartouche
6288 @noindent
6289 @strong{8}.  The representation for an end of line.  See 2.2(2).
6290 @end cartouche
6291 @noindent
6292 See separate section on source representation.
6293
6294 @sp 1
6295 @cartouche
6296 @noindent
6297 @strong{9}.  Maximum supported line length and lexical element
6298 length.  See 2.2(15).
6299 @end cartouche
6300 @noindent
6301 The maximum line length is 255 characters an the maximum length of a
6302 lexical element is also 255 characters.
6303
6304 @sp 1
6305 @cartouche
6306 @noindent
6307 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6308 @end cartouche
6309 @noindent
6310
6311 @xref{Implementation Defined Pragmas}.
6312
6313 @sp 1
6314 @cartouche
6315 @noindent
6316 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6317 @end cartouche
6318 @noindent
6319 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6320 parameter, checks that the optimization flag is set, and aborts if it is
6321 not.
6322
6323 @sp 1
6324 @cartouche
6325 @noindent
6326 @strong{12}.  The sequence of characters of the value returned by
6327 @code{@var{S}'Image} when some of the graphic characters of
6328 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6329 3.5(37).
6330 @end cartouche
6331 @noindent
6332 The sequence of characters is as defined by the wide character encoding
6333 method used for the source.  See section on source representation for
6334 further details.
6335
6336 @sp 1
6337 @cartouche
6338 @noindent
6339 @strong{13}.  The predefined integer types declared in
6340 @code{Standard}.  See 3.5.4(25).
6341 @end cartouche
6342 @noindent
6343 @table @code
6344 @item Short_Short_Integer
6345 8 bit signed
6346 @item Short_Integer
6347 (Short) 16 bit signed
6348 @item Integer
6349 32 bit signed
6350 @item Long_Integer
6351 64 bit signed (Alpha OpenVMS only)
6352 32 bit signed (all other targets)
6353 @item Long_Long_Integer
6354 64 bit signed
6355 @end table
6356
6357 @sp 1
6358 @cartouche
6359 @noindent
6360 @strong{14}.  Any nonstandard integer types and the operators defined
6361 for them.  See 3.5.4(26).
6362 @end cartouche
6363 @noindent
6364 There are no nonstandard integer types.
6365
6366 @sp 1
6367 @cartouche
6368 @noindent
6369 @strong{15}.  Any nonstandard real types and the operators defined for
6370 them.  See 3.5.6(8).
6371 @end cartouche
6372 @noindent
6373 There are no nonstandard real types.
6374
6375 @sp 1
6376 @cartouche
6377 @noindent
6378 @strong{16}.  What combinations of requested decimal precision and range
6379 are supported for floating point types.  See 3.5.7(7).
6380 @end cartouche
6381 @noindent
6382 The precision and range is as defined by the IEEE standard.
6383
6384 @sp 1
6385 @cartouche
6386 @noindent
6387 @strong{17}.  The predefined floating point types declared in
6388 @code{Standard}.  See 3.5.7(16).
6389 @end cartouche
6390 @noindent
6391 @table @code
6392 @item Short_Float
6393 32 bit IEEE short
6394 @item Float
6395 (Short) 32 bit IEEE short
6396 @item Long_Float
6397 64 bit IEEE long
6398 @item Long_Long_Float
6399 64 bit IEEE long (80 bit IEEE long on x86 processors)
6400 @end table
6401
6402 @sp 1
6403 @cartouche
6404 @noindent
6405 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6406 @end cartouche
6407 @noindent
6408 @code{Fine_Delta} is 2**(@minus{}63)
6409
6410 @sp 1
6411 @cartouche
6412 @noindent
6413 @strong{19}.  What combinations of small, range, and digits are
6414 supported for fixed point types.  See 3.5.9(10).
6415 @end cartouche
6416 @noindent
6417 Any combinations are permitted that do not result in a small less than
6418 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6419 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6420 is 64 bits (true of all architectures except ia32), then the output from
6421 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6422 is because floating-point conversions are used to convert fixed point.
6423
6424 @sp 1
6425 @cartouche
6426 @noindent
6427 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6428 within an unnamed @code{block_statement}.  See 3.9(10).
6429 @end cartouche
6430 @noindent
6431 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6432 decimal integer are allocated.
6433
6434 @sp 1
6435 @cartouche
6436 @noindent
6437 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6438 @end cartouche
6439 @noindent
6440 @xref{Implementation Defined Attributes}.
6441
6442 @sp 1
6443 @cartouche
6444 @noindent
6445 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6446 @end cartouche
6447 @noindent
6448 There are no implementation-defined time types.
6449
6450 @sp 1
6451 @cartouche
6452 @noindent
6453 @strong{23}.  The time base associated with relative delays.
6454 @end cartouche
6455 @noindent
6456 See 9.6(20).  The time base used is that provided by the C library
6457 function @code{gettimeofday}.
6458
6459 @sp 1
6460 @cartouche
6461 @noindent
6462 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6463 9.6(23).
6464 @end cartouche
6465 @noindent
6466 The time base used is that provided by the C library function
6467 @code{gettimeofday}.
6468
6469 @sp 1
6470 @cartouche
6471 @noindent
6472 @strong{25}.  The time zone used for package @code{Calendar}
6473 operations.  See 9.6(24).
6474 @end cartouche
6475 @noindent
6476 The time zone used by package @code{Calendar} is the current system time zone
6477 setting for local time, as accessed by the C library function
6478 @code{localtime}.
6479
6480 @sp 1
6481 @cartouche
6482 @noindent
6483 @strong{26}.  Any limit on @code{delay_until_statements} of
6484 @code{select_statements}.  See 9.6(29).
6485 @end cartouche
6486 @noindent
6487 There are no such limits.
6488
6489 @sp 1
6490 @cartouche
6491 @noindent
6492 @strong{27}.  Whether or not two non overlapping parts of a composite
6493 object are independently addressable, in the case where packing, record
6494 layout, or @code{Component_Size} is specified for the object.  See
6495 9.10(1).
6496 @end cartouche
6497 @noindent
6498 Separate components are independently addressable if they do not share
6499 overlapping storage units.
6500
6501 @sp 1
6502 @cartouche
6503 @noindent
6504 @strong{28}.  The representation for a compilation.  See 10.1(2).
6505 @end cartouche
6506 @noindent
6507 A compilation is represented by a sequence of files presented to the
6508 compiler in a single invocation of the @code{gcc} command.
6509
6510 @sp 1
6511 @cartouche
6512 @noindent
6513 @strong{29}.  Any restrictions on compilations that contain multiple
6514 compilation_units.  See 10.1(4).
6515 @end cartouche
6516 @noindent
6517 No single file can contain more than one compilation unit, but any
6518 sequence of files can be presented to the compiler as a single
6519 compilation.
6520
6521 @sp 1
6522 @cartouche
6523 @noindent
6524 @strong{30}.  The mechanisms for creating an environment and for adding
6525 and replacing compilation units.  See 10.1.4(3).
6526 @end cartouche
6527 @noindent
6528 See separate section on compilation model.
6529
6530 @sp 1
6531 @cartouche
6532 @noindent
6533 @strong{31}.  The manner of explicitly assigning library units to a
6534 partition.  See 10.2(2).
6535 @end cartouche
6536 @noindent
6537 If a unit contains an Ada main program, then the Ada units for the partition
6538 are determined by recursive application of the rules in the Ada Reference
6539 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6540 are needed by the main program, and then this definition of need is applied
6541 recursively to those units, and the partition contains the transitive
6542 closure determined by this relationship.  In short, all the necessary units
6543 are included, with no need to explicitly specify the list.  If additional
6544 units are required, e.g.@: by foreign language units, then all units must be
6545 mentioned in the context clause of one of the needed Ada units.
6546
6547 If the partition contains no main program, or if the main program is in
6548 a language other than Ada, then GNAT
6549 provides the binder options @code{-z} and @code{-n} respectively, and in
6550 this case a list of units can be explicitly supplied to the binder for
6551 inclusion in the partition (all units needed by these units will also
6552 be included automatically).  For full details on the use of these
6553 options, refer to the @cite{GNAT User's Guide} sections on Binding
6554 and Linking.
6555
6556 @sp 1
6557 @cartouche
6558 @noindent
6559 @strong{32}.  The implementation-defined means, if any, of specifying
6560 which compilation units are needed by a given compilation unit.  See
6561 10.2(2).
6562 @end cartouche
6563 @noindent
6564 The units needed by a given compilation unit are as defined in
6565 the Ada Reference Manual section 10.2(2-6).  There are no
6566 implementation-defined pragmas or other implementation-defined
6567 means for specifying needed units.
6568
6569 @sp 1
6570 @cartouche
6571 @noindent
6572 @strong{33}.  The manner of designating the main subprogram of a
6573 partition.  See 10.2(7).
6574 @end cartouche
6575 @noindent
6576 The main program is designated by providing the name of the
6577 corresponding @file{ALI} file as the input parameter to the binder.
6578
6579 @sp 1
6580 @cartouche
6581 @noindent
6582 @strong{34}.  The order of elaboration of @code{library_items}.  See
6583 10.2(18).
6584 @end cartouche
6585 @noindent
6586 The first constraint on ordering is that it meets the requirements of
6587 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6588 implementation dependent choices, which are resolved by first
6589 elaborating bodies as early as possible (i.e.@: in preference to specs
6590 where there is a choice), and second by evaluating the immediate with
6591 clauses of a unit to determine the probably best choice, and
6592 third by elaborating in alphabetical order of unit names
6593 where a choice still remains.
6594
6595 @sp 1
6596 @cartouche
6597 @noindent
6598 @strong{35}.  Parameter passing and function return for the main
6599 subprogram.  See 10.2(21).
6600 @end cartouche
6601 @noindent
6602 The main program has no parameters.  It may be a procedure, or a function
6603 returning an integer type.  In the latter case, the returned integer
6604 value is the return code of the program (overriding any value that
6605 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6606
6607 @sp 1
6608 @cartouche
6609 @noindent
6610 @strong{36}.  The mechanisms for building and running partitions.  See
6611 10.2(24).
6612 @end cartouche
6613 @noindent
6614 GNAT itself supports programs with only a single partition.  The GNATDIST
6615 tool provided with the GLADE package (which also includes an implementation
6616 of the PCS) provides a completely flexible method for building and running
6617 programs consisting of multiple partitions.  See the separate GLADE manual
6618 for details.
6619
6620 @sp 1
6621 @cartouche
6622 @noindent
6623 @strong{37}.  The details of program execution, including program
6624 termination.  See 10.2(25).
6625 @end cartouche
6626 @noindent
6627 See separate section on compilation model.
6628
6629 @sp 1
6630 @cartouche
6631 @noindent
6632 @strong{38}.  The semantics of any non-active partitions supported by the
6633 implementation.  See 10.2(28).
6634 @end cartouche
6635 @noindent
6636 Passive partitions are supported on targets where shared memory is
6637 provided by the operating system.  See the GLADE reference manual for
6638 further details.
6639
6640 @sp 1
6641 @cartouche
6642 @noindent
6643 @strong{39}.  The information returned by @code{Exception_Message}.  See
6644 11.4.1(10).
6645 @end cartouche
6646 @noindent
6647 Exception message returns the null string unless a specific message has
6648 been passed by the program.
6649
6650 @sp 1
6651 @cartouche
6652 @noindent
6653 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6654 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6655 @end cartouche
6656 @noindent
6657 Blocks have implementation defined names of the form @code{B@var{nnn}}
6658 where @var{nnn} is an integer.
6659
6660 @sp 1
6661 @cartouche
6662 @noindent
6663 @strong{41}.  The information returned by
6664 @code{Exception_Information}.  See 11.4.1(13).
6665 @end cartouche
6666 @noindent
6667 @code{Exception_Information} returns a string in the following format:
6668
6669 @smallexample
6670 @emph{Exception_Name:} nnnnn
6671 @emph{Message:} mmmmm
6672 @emph{PID:} ppp
6673 @emph{Call stack traceback locations:}
6674 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6675 @end smallexample
6676
6677 @noindent
6678 where
6679
6680 @itemize @bullet
6681 @item
6682 @code{nnnn} is the fully qualified name of the exception in all upper
6683 case letters. This line is always present.
6684
6685 @item
6686 @code{mmmm} is the message (this line present only if message is non-null)
6687
6688 @item
6689 @code{ppp} is the Process Id value as a decimal integer (this line is
6690 present only if the Process Id is non-zero). Currently we are
6691 not making use of this field.
6692
6693 @item
6694 The Call stack traceback locations line and the following values
6695 are present only if at least one traceback location was recorded.
6696 The values are given in C style format, with lower case letters
6697 for a-f, and only as many digits present as are necessary.
6698 @end itemize
6699
6700 @noindent
6701 The line terminator sequence at the end of each line, including
6702 the last line is a single @code{LF} character (@code{16#0A#}).
6703
6704 @sp 1
6705 @cartouche
6706 @noindent
6707 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6708 @end cartouche
6709 @noindent
6710 No implementation-defined check names are supported.
6711
6712 @sp 1
6713 @cartouche
6714 @noindent
6715 @strong{43}.  The interpretation of each aspect of representation.  See
6716 13.1(20).
6717 @end cartouche
6718 @noindent
6719 See separate section on data representations.
6720
6721 @sp 1
6722 @cartouche
6723 @noindent
6724 @strong{44}.  Any restrictions placed upon representation items.  See
6725 13.1(20).
6726 @end cartouche
6727 @noindent
6728 See separate section on data representations.
6729
6730 @sp 1
6731 @cartouche
6732 @noindent
6733 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6734 13.3(48).
6735 @end cartouche
6736 @noindent
6737 Size for an indefinite subtype is the maximum possible size, except that
6738 for the case of a subprogram parameter, the size of the parameter object
6739 is the actual size.
6740
6741 @sp 1
6742 @cartouche
6743 @noindent
6744 @strong{46}.  The default external representation for a type tag.  See
6745 13.3(75).
6746 @end cartouche
6747 @noindent
6748 The default external representation for a type tag is the fully expanded
6749 name of the type in upper case letters.
6750
6751 @sp 1
6752 @cartouche
6753 @noindent
6754 @strong{47}.  What determines whether a compilation unit is the same in
6755 two different partitions.  See 13.3(76).
6756 @end cartouche
6757 @noindent
6758 A compilation unit is the same in two different partitions if and only
6759 if it derives from the same source file.
6760
6761 @sp 1
6762 @cartouche
6763 @noindent
6764 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6765 @end cartouche
6766 @noindent
6767 The only implementation defined component is the tag for a tagged type,
6768 which contains a pointer to the dispatching table.
6769
6770 @sp 1
6771 @cartouche
6772 @noindent
6773 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6774 ordering.  See 13.5.3(5).
6775 @end cartouche
6776 @noindent
6777 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6778 implementation, so no non-default bit ordering is supported.  The default
6779 bit ordering corresponds to the natural endianness of the target architecture.
6780
6781 @sp 1
6782 @cartouche
6783 @noindent
6784 @strong{50}.  The contents of the visible part of package @code{System}
6785 and its language-defined children.  See 13.7(2).
6786 @end cartouche
6787 @noindent
6788 See the definition of these packages in files @file{system.ads} and
6789 @file{s-stoele.ads}.
6790
6791 @sp 1
6792 @cartouche
6793 @noindent
6794 @strong{51}.  The contents of the visible part of package
6795 @code{System.Machine_Code}, and the meaning of
6796 @code{code_statements}.  See 13.8(7).
6797 @end cartouche
6798 @noindent
6799 See the definition and documentation in file @file{s-maccod.ads}.
6800
6801 @sp 1
6802 @cartouche
6803 @noindent
6804 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6805 @end cartouche
6806 @noindent
6807 Unchecked conversion between types of the same size
6808 and results in an uninterpreted transmission of the bits from one type
6809 to the other.  If the types are of unequal sizes, then in the case of
6810 discrete types, a shorter source is first zero or sign extended as
6811 necessary, and a shorter target is simply truncated on the left.
6812 For all non-discrete types, the source is first copied if necessary
6813 to ensure that the alignment requirements of the target are met, then
6814 a pointer is constructed to the source value, and the result is obtained
6815 by dereferencing this pointer after converting it to be a pointer to the
6816 target type.
6817
6818 @sp 1
6819 @cartouche
6820 @noindent
6821 @strong{53}.  The manner of choosing a storage pool for an access type
6822 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6823 @end cartouche
6824 @noindent
6825 There are 3 different standard pools used by the compiler when
6826 @code{Storage_Pool} is not specified depending whether the type is local
6827 to a subprogram or defined at the library level and whether
6828 @code{Storage_Size}is specified or not.  See documentation in the runtime
6829 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6830 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6831 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6832 default pools used.
6833
6834 @sp 1
6835 @cartouche
6836 @noindent
6837 @strong{54}.  Whether or not the implementation provides user-accessible
6838 names for the standard pool type(s).  See 13.11(17).
6839 @end cartouche
6840 @noindent
6841
6842 See documentation in the sources of the run time mentioned in paragraph
6843 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6844 these units.
6845
6846 @sp 1
6847 @cartouche
6848 @noindent
6849 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6850 @end cartouche
6851 @noindent
6852 @code{Storage_Size} is measured in storage units, and refers to the
6853 total space available for an access type collection, or to the primary
6854 stack space for a task.
6855
6856 @sp 1
6857 @cartouche
6858 @noindent
6859 @strong{56}.  Implementation-defined aspects of storage pools.  See
6860 13.11(22).
6861 @end cartouche
6862 @noindent
6863 See documentation in the sources of the run time mentioned in paragraph
6864 @strong{53} for details on GNAT-defined aspects of storage pools.
6865
6866 @sp 1
6867 @cartouche
6868 @noindent
6869 @strong{57}.  The set of restrictions allowed in a pragma
6870 @code{Restrictions}.  See 13.12(7).
6871 @end cartouche
6872 @noindent
6873 All RM defined Restriction identifiers are implemented.  The following
6874 additional restriction identifiers are provided.  There are two separate
6875 lists of implementation dependent restriction identifiers.  The first
6876 set requires consistency throughout a partition (in other words, if the
6877 restriction identifier is used for any compilation unit in the partition,
6878 then all compilation units in the partition must obey the restriction.
6879
6880 @table @code
6881
6882 @item Simple_Barriers
6883 @findex Simple_Barriers
6884 This restriction ensures at compile time that barriers in entry declarations
6885 for protected types are restricted to either static boolean expressions or
6886 references to simple boolean variables defined in the private part of the
6887 protected type.  No other form of entry barriers is permitted.  This is one
6888 of the restrictions of the Ravenscar profile for limited tasking (see also
6889 pragma @code{Profile (Ravenscar)}).
6890
6891 @item Max_Entry_Queue_Length => Expr
6892 @findex Max_Entry_Queue_Length
6893 This restriction is a declaration that any protected entry compiled in
6894 the scope of the restriction has at most the specified number of
6895 tasks waiting on the entry
6896 at any one time, and so no queue is required.  This restriction is not
6897 checked at compile time.  A program execution is erroneous if an attempt
6898 is made to queue more than the specified number of tasks on such an entry.
6899
6900 @item No_Calendar
6901 @findex No_Calendar
6902 This restriction ensures at compile time that there is no implicit or
6903 explicit dependence on the package @code{Ada.Calendar}.
6904
6905 @item No_Direct_Boolean_Operators
6906 @findex No_Direct_Boolean_Operators
6907 This restriction ensures that no logical (and/or/xor) or comparison
6908 operators are used on operands of type Boolean (or any type derived
6909 from Boolean). This is intended for use in safety critical programs
6910 where the certification protocol requires the use of short-circuit
6911 (and then, or else) forms for all composite boolean operations.
6912
6913 @item No_Dynamic_Attachment
6914 @findex No_Dynamic_Attachment
6915 This restriction ensures that there is no call to any of the operations
6916 defined in package Ada.Interrupts.
6917
6918 @item No_Enumeration_Maps
6919 @findex No_Enumeration_Maps
6920 This restriction ensures at compile time that no operations requiring
6921 enumeration maps are used (that is Image and Value attributes applied
6922 to enumeration types).
6923
6924 @item No_Entry_Calls_In_Elaboration_Code
6925 @findex No_Entry_Calls_In_Elaboration_Code
6926 This restriction ensures at compile time that no task or protected entry
6927 calls are made during elaboration code.  As a result of the use of this
6928 restriction, the compiler can assume that no code past an accept statement
6929 in a task can be executed at elaboration time.
6930
6931 @item No_Exception_Handlers
6932 @findex No_Exception_Handlers
6933 This restriction ensures at compile time that there are no explicit
6934 exception handlers. It also indicates that no exception propagation will
6935 be provided. In this mode, exceptions may be raised but will result in
6936 an immediate call to the last chance handler, a routine that the user
6937 must define with the following profile:
6938
6939    procedure Last_Chance_Handler
6940      (Source_Location : System.Address; Line : Integer);
6941    pragma Export (C, Last_Chance_Handler,
6942                   "__gnat_last_chance_handler");
6943
6944    The parameter is a C null-terminated string representing a message to be
6945    associated with the exception (typically the source location of the raise
6946    statement generated by the compiler). The Line parameter when non-zero
6947    represents the line number in the source program where the raise occurs.
6948
6949 @item No_Exception_Streams
6950 @findex No_Exception_Streams
6951 This restriction ensures at compile time that no stream operations for
6952 types Exception_Id or Exception_Occurrence are used. This also makes it
6953 impossible to pass exceptions to or from a partition with this restriction
6954 in a distributed environment. If this exception is active, then the generated
6955 code is simplified by omitting the otherwise-required global registration
6956 of exceptions when they are declared.
6957
6958 @item No_Implicit_Conditionals
6959 @findex No_Implicit_Conditionals
6960 This restriction ensures that the generated code does not contain any
6961 implicit conditionals, either by modifying the generated code where possible,
6962 or by rejecting any construct that would otherwise generate an implicit
6963 conditional.
6964
6965 @item No_Implicit_Dynamic_Code
6966 @findex No_Implicit_Dynamic_Code
6967 This restriction prevents the compiler from building ``trampolines''.
6968 This is a structure that is built on the stack and contains dynamic
6969 code to be executed at run time. A trampoline is needed to indirectly
6970 address a nested subprogram (that is a subprogram that is not at the
6971 library level). The restriction prevents the use of any of the
6972 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
6973 being applied to a subprogram that is not at the library level.
6974
6975 @item No_Implicit_Loops
6976 @findex No_Implicit_Loops
6977 This restriction ensures that the generated code does not contain any
6978 implicit @code{for} loops, either by modifying
6979 the generated code where possible,
6980 or by rejecting any construct that would otherwise generate an implicit
6981 @code{for} loop.
6982
6983 @item No_Initialize_Scalars
6984 @findex No_Initialize_Scalars
6985 This restriction ensures that no unit in the partition is compiled with
6986 pragma Initialize_Scalars. This allows the generation of more efficient
6987 code, and in particular eliminates dummy null initialization routines that
6988 are otherwise generated for some record and array types.
6989
6990 @item No_Local_Protected_Objects
6991 @findex No_Local_Protected_Objects
6992 This restriction ensures at compile time that protected objects are
6993 only declared at the library level.
6994
6995 @item No_Protected_Type_Allocators
6996 @findex No_Protected_Type_Allocators
6997 This restriction ensures at compile time that there are no allocator
6998 expressions that attempt to allocate protected objects.
6999
7000 @item No_Secondary_Stack
7001 @findex No_Secondary_Stack
7002 This restriction ensures at compile time that the generated code does not
7003 contain any reference to the secondary stack.  The secondary stack is used
7004 to implement functions returning unconstrained objects (arrays or records)
7005 on some targets.
7006
7007 @item No_Select_Statements
7008 @findex No_Select_Statements
7009 This restriction ensures at compile time no select statements of any kind
7010 are permitted, that is the keyword @code{select} may not appear.
7011 This is one of the restrictions of the Ravenscar
7012 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7013
7014 @item No_Standard_Storage_Pools
7015 @findex No_Standard_Storage_Pools
7016 This restriction ensures at compile time that no access types
7017 use the standard default storage pool.  Any access type declared must
7018 have an explicit Storage_Pool attribute defined specifying a
7019 user-defined storage pool.
7020
7021 @item No_Streams
7022 @findex No_Streams
7023 This restriction ensures at compile time that there are no implicit or
7024 explicit dependencies on the package @code{Ada.Streams}.
7025
7026 @item No_Task_Attributes_Package
7027 @findex No_Task_Attributes_Package
7028 This restriction ensures at compile time that there are no implicit or
7029 explicit dependencies on the package @code{Ada.Task_Attributes}.
7030
7031 @item No_Task_Termination
7032 @findex No_Task_Termination
7033 This restriction ensures at compile time that no terminate alternatives
7034 appear in any task body.
7035
7036 @item No_Tasking
7037 @findex No_Tasking
7038 This restriction prevents the declaration of tasks or task types throughout
7039 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7040 except that violations are caught at compile time and cause an error message
7041 to be output either by the compiler or binder.
7042
7043 @item No_Wide_Characters
7044 @findex No_Wide_Characters
7045 This restriction ensures at compile time that no uses of the types
7046 @code{Wide_Character} or @code{Wide_String}
7047 appear, and that no wide character literals
7048 appear in the program (that is literals representing characters not in
7049 type @code{Character}.
7050
7051 @item Static_Priorities
7052 @findex Static_Priorities
7053 This restriction ensures at compile time that all priority expressions
7054 are static, and that there are no dependencies on the package
7055 @code{Ada.Dynamic_Priorities}.
7056
7057 @item Static_Storage_Size
7058 @findex Static_Storage_Size
7059 This restriction ensures at compile time that any expression appearing
7060 in a Storage_Size pragma or attribute definition clause is static.
7061
7062 @end table
7063
7064 @noindent
7065 The second set of implementation dependent restriction identifiers
7066 does not require partition-wide consistency.
7067 The restriction may be enforced for a single
7068 compilation unit without any effect on any of the
7069 other compilation units in the partition.
7070
7071 @table @code
7072
7073 @item No_Elaboration_Code
7074 @findex No_Elaboration_Code
7075 This restriction ensures at compile time that no elaboration code is
7076 generated.  Note that this is not the same condition as is enforced
7077 by pragma @code{Preelaborate}.  There are cases in which pragma
7078 @code{Preelaborate} still permits code to be generated (e.g.@: code
7079 to initialize a large array to all zeroes), and there are cases of units
7080 which do not meet the requirements for pragma @code{Preelaborate},
7081 but for which no elaboration code is generated.  Generally, it is
7082 the case that preelaborable units will meet the restrictions, with
7083 the exception of large aggregates initialized with an others_clause,
7084 and exception declarations (which generate calls to a run-time
7085 registry procedure).  Note that this restriction is enforced on
7086 a unit by unit basis, it need not be obeyed consistently
7087 throughout a partition.
7088
7089 @item No_Entry_Queue
7090 @findex No_Entry_Queue
7091 This restriction is a declaration that any protected entry compiled in
7092 the scope of the restriction has at most one task waiting on the entry
7093 at any one time, and so no queue is required.  This restriction is not
7094 checked at compile time.  A program execution is erroneous if an attempt
7095 is made to queue a second task on such an entry.
7096
7097 @item No_Implementation_Attributes
7098 @findex No_Implementation_Attributes
7099 This restriction checks at compile time that no GNAT-defined attributes
7100 are present.  With this restriction, the only attributes that can be used
7101 are those defined in the Ada 95 Reference Manual.
7102
7103 @item No_Implementation_Pragmas
7104 @findex No_Implementation_Pragmas
7105 This restriction checks at compile time that no GNAT-defined pragmas
7106 are present.  With this restriction, the only pragmas that can be used
7107 are those defined in the Ada 95 Reference Manual.
7108
7109 @item No_Implementation_Restrictions
7110 @findex No_Implementation_Restrictions
7111 This restriction checks at compile time that no GNAT-defined restriction
7112 identifiers (other than @code{No_Implementation_Restrictions} itself)
7113 are present.  With this restriction, the only other restriction identifiers
7114 that can be used are those defined in the Ada 95 Reference Manual.
7115
7116 @end table
7117
7118 @sp 1
7119 @cartouche
7120 @noindent
7121 @strong{58}.  The consequences of violating limitations on
7122 @code{Restrictions} pragmas.  See 13.12(9).
7123 @end cartouche
7124 @noindent
7125 Restrictions that can be checked at compile time result in illegalities
7126 if violated.  Currently there are no other consequences of violating
7127 restrictions.
7128
7129 @sp 1
7130 @cartouche
7131 @noindent
7132 @strong{59}.  The representation used by the @code{Read} and
7133 @code{Write} attributes of elementary types in terms of stream
7134 elements.  See 13.13.2(9).
7135 @end cartouche
7136 @noindent
7137 The representation is the in-memory representation of the base type of
7138 the type, using the number of bits corresponding to the
7139 @code{@var{type}'Size} value, and the natural ordering of the machine.
7140
7141 @sp 1
7142 @cartouche
7143 @noindent
7144 @strong{60}.  The names and characteristics of the numeric subtypes
7145 declared in the visible part of package @code{Standard}.  See A.1(3).
7146 @end cartouche
7147 @noindent
7148 See items describing the integer and floating-point types supported.
7149
7150 @sp 1
7151 @cartouche
7152 @noindent
7153 @strong{61}.  The accuracy actually achieved by the elementary
7154 functions.  See A.5.1(1).
7155 @end cartouche
7156 @noindent
7157 The elementary functions correspond to the functions available in the C
7158 library.  Only fast math mode is implemented.
7159
7160 @sp 1
7161 @cartouche
7162 @noindent
7163 @strong{62}.  The sign of a zero result from some of the operators or
7164 functions in @code{Numerics.Generic_Elementary_Functions}, when
7165 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7166 @end cartouche
7167 @noindent
7168 The sign of zeroes follows the requirements of the IEEE 754 standard on
7169 floating-point.
7170
7171 @sp 1
7172 @cartouche
7173 @noindent
7174 @strong{63}.  The value of
7175 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7176 @end cartouche
7177 @noindent
7178 Maximum image width is 649, see library file @file{a-numran.ads}.
7179
7180 @sp 1
7181 @cartouche
7182 @noindent
7183 @strong{64}.  The value of
7184 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7185 @end cartouche
7186 @noindent
7187 Maximum image width is 80, see library file @file{a-nudira.ads}.
7188
7189 @sp 1
7190 @cartouche
7191 @noindent
7192 @strong{65}.  The algorithms for random number generation.  See
7193 A.5.2(32).
7194 @end cartouche
7195 @noindent
7196 The algorithm is documented in the source files @file{a-numran.ads} and
7197 @file{a-numran.adb}.
7198
7199 @sp 1
7200 @cartouche
7201 @noindent
7202 @strong{66}.  The string representation of a random number generator's
7203 state.  See A.5.2(38).
7204 @end cartouche
7205 @noindent
7206 See the documentation contained in the file @file{a-numran.adb}.
7207
7208 @sp 1
7209 @cartouche
7210 @noindent
7211 @strong{67}.  The minimum time interval between calls to the
7212 time-dependent Reset procedure that are guaranteed to initiate different
7213 random number sequences.  See A.5.2(45).
7214 @end cartouche
7215 @noindent
7216 The minimum period between reset calls to guarantee distinct series of
7217 random numbers is one microsecond.
7218
7219 @sp 1
7220 @cartouche
7221 @noindent
7222 @strong{68}.  The values of the @code{Model_Mantissa},
7223 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7224 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7225 Annex is not supported.  See A.5.3(72).
7226 @end cartouche
7227 @noindent
7228 See the source file @file{ttypef.ads} for the values of all numeric
7229 attributes.
7230
7231 @sp 1
7232 @cartouche
7233 @noindent
7234 @strong{69}.  Any implementation-defined characteristics of the
7235 input-output packages.  See A.7(14).
7236 @end cartouche
7237 @noindent
7238 There are no special implementation defined characteristics for these
7239 packages.
7240
7241 @sp 1
7242 @cartouche
7243 @noindent
7244 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7245 A.9(10).
7246 @end cartouche
7247 @noindent
7248 All type representations are contiguous, and the @code{Buffer_Size} is
7249 the value of @code{@var{type}'Size} rounded up to the next storage unit
7250 boundary.
7251
7252 @sp 1
7253 @cartouche
7254 @noindent
7255 @strong{71}.  External files for standard input, standard output, and
7256 standard error See A.10(5).
7257 @end cartouche
7258 @noindent
7259 These files are mapped onto the files provided by the C streams
7260 libraries.  See source file @file{i-cstrea.ads} for further details.
7261
7262 @sp 1
7263 @cartouche
7264 @noindent
7265 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7266 A.10.9(36).
7267 @end cartouche
7268 @noindent
7269 If more digits are requested in the output than are represented by the
7270 precision of the value, zeroes are output in the corresponding least
7271 significant digit positions.
7272
7273 @sp 1
7274 @cartouche
7275 @noindent
7276 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7277 @code{Command_Name}.  See A.15(1).
7278 @end cartouche
7279 @noindent
7280 These are mapped onto the @code{argv} and @code{argc} parameters of the
7281 main program in the natural manner.
7282
7283 @sp 1
7284 @cartouche
7285 @noindent
7286 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7287 @end cartouche
7288 @noindent
7289 The following convention names are supported
7290
7291 @table @code
7292 @item  Ada
7293 Ada
7294 @item Assembler
7295 Assembly language
7296 @item Asm
7297 Synonym for Assembler
7298 @item Assembly
7299 Synonym for Assembler
7300 @item C
7301 C
7302 @item C_Pass_By_Copy
7303 Allowed only for record types, like C, but also notes that record
7304 is to be passed by copy rather than reference.
7305 @item COBOL
7306 COBOL
7307 @item CPP
7308 C++
7309 @item Default
7310 Treated the same as C
7311 @item External
7312 Treated the same as C
7313 @item Fortran
7314 Fortran
7315 @item Intrinsic
7316 For support of pragma @code{Import} with convention Intrinsic, see
7317 separate section on Intrinsic Subprograms.
7318 @item Stdcall
7319 Stdcall (used for Windows implementations only).  This convention correspond
7320 to the WINAPI (previously called Pascal convention) C/C++ convention under
7321 Windows.  A function with this convention cleans the stack before exit.
7322 @item DLL
7323 Synonym for Stdcall
7324 @item Win32
7325 Synonym for Stdcall
7326 @item Stubbed
7327 Stubbed is a special convention used to indicate that the body of the
7328 subprogram will be entirely ignored.  Any call to the subprogram
7329 is converted into a raise of the @code{Program_Error} exception.  If a
7330 pragma @code{Import} specifies convention @code{stubbed} then no body need
7331 be present at all.  This convention is useful during development for the
7332 inclusion of subprograms whose body has not yet been written.
7333
7334 @end table
7335 @noindent
7336 In addition, all otherwise unrecognized convention names are also
7337 treated as being synonymous with convention C@.  In all implementations
7338 except for VMS, use of such other names results in a warning.  In VMS
7339 implementations, these names are accepted silently.
7340
7341 @sp 1
7342 @cartouche
7343 @noindent
7344 @strong{75}.  The meaning of link names.  See B.1(36).
7345 @end cartouche
7346 @noindent
7347 Link names are the actual names used by the linker.
7348
7349 @sp 1
7350 @cartouche
7351 @noindent
7352 @strong{76}.  The manner of choosing link names when neither the link
7353 name nor the address of an imported or exported entity is specified.  See
7354 B.1(36).
7355 @end cartouche
7356 @noindent
7357 The default linker name is that which would be assigned by the relevant
7358 external language, interpreting the Ada name as being in all lower case
7359 letters.
7360
7361 @sp 1
7362 @cartouche
7363 @noindent
7364 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7365 @end cartouche
7366 @noindent
7367 The string passed to @code{Linker_Options} is presented uninterpreted as
7368 an argument to the link command, unless it contains Ascii.NUL characters.
7369 NUL characters if they appear act as argument separators, so for example
7370
7371 @smallexample @c ada
7372 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7373 @end smallexample
7374
7375 @noindent
7376 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7377 linker. The order of linker options is preserved for a given unit. The final
7378 list of options passed to the linker is in reverse order of the elaboration
7379 order. For example, linker options fo a body always appear before the options
7380 from the corresponding package spec.
7381
7382 @sp 1
7383 @cartouche
7384 @noindent
7385 @strong{78}.  The contents of the visible part of package
7386 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7387 @end cartouche
7388 @noindent
7389 See files with prefix @file{i-} in the distributed library.
7390
7391 @sp 1
7392 @cartouche
7393 @noindent
7394 @strong{79}.  Implementation-defined children of package
7395 @code{Interfaces}.  The contents of the visible part of package
7396 @code{Interfaces}.  See B.2(11).
7397 @end cartouche
7398 @noindent
7399 See files with prefix @file{i-} in the distributed library.
7400
7401 @sp 1
7402 @cartouche
7403 @noindent
7404 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7405 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7406 @code{COBOL_Character}; and the initialization of the variables
7407 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7408 @code{Interfaces.COBOL}.  See B.4(50).
7409 @end cartouche
7410 @noindent
7411 @table @code
7412 @item Floating
7413 Float
7414 @item Long_Floating
7415 (Floating) Long_Float
7416 @item Binary
7417 Integer
7418 @item Long_Binary
7419 Long_Long_Integer
7420 @item Decimal_Element
7421 Character
7422 @item COBOL_Character
7423 Character
7424 @end table
7425
7426 @noindent
7427 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7428
7429 @sp 1
7430 @cartouche
7431 @noindent
7432 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7433 @end cartouche
7434 @noindent
7435 See documentation in file @file{s-maccod.ads} in the distributed library.
7436
7437 @sp 1
7438 @cartouche
7439 @noindent
7440 @strong{82}.  Implementation-defined aspects of access to machine
7441 operations.  See C.1(9).
7442 @end cartouche
7443 @noindent
7444 See documentation in file @file{s-maccod.ads} in the distributed library.
7445
7446 @sp 1
7447 @cartouche
7448 @noindent
7449 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7450 @end cartouche
7451 @noindent
7452 Interrupts are mapped to signals or conditions as appropriate.  See
7453 definition of unit
7454 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7455 on the interrupts supported on a particular target.
7456
7457 @sp 1
7458 @cartouche
7459 @noindent
7460 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7461 C.4(13).
7462 @end cartouche
7463 @noindent
7464 GNAT does not permit a partition to be restarted without reloading,
7465 except under control of the debugger.
7466
7467 @sp 1
7468 @cartouche
7469 @noindent
7470 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7471 @end cartouche
7472 @noindent
7473 Pragma @code{Discard_Names} causes names of enumeration literals to
7474 be suppressed.  In the presence of this pragma, the Image attribute
7475 provides the image of the Pos of the literal, and Value accepts
7476 Pos values.
7477
7478 @sp 1
7479 @cartouche
7480 @noindent
7481 @strong{86}.  The result of the @code{Task_Identification.Image}
7482 attribute.  See C.7.1(7).
7483 @end cartouche
7484 @noindent
7485 The result of this attribute is an 8-digit hexadecimal string
7486 representing the virtual address of the task control block.
7487
7488 @sp 1
7489 @cartouche
7490 @noindent
7491 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7492 or interrupt handler.  See C.7.1(17).
7493 @end cartouche
7494 @noindent
7495 Protected entries or interrupt handlers can be executed by any
7496 convenient thread, so the value of @code{Current_Task} is undefined.
7497
7498 @sp 1
7499 @cartouche
7500 @noindent
7501 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7502 body or interrupt handler.  See C.7.1(19).
7503 @end cartouche
7504 @noindent
7505 The effect of calling @code{Current_Task} from an entry body or
7506 interrupt handler is to return the identification of the task currently
7507 executing the code.
7508
7509 @sp 1
7510 @cartouche
7511 @noindent
7512 @strong{89}.  Implementation-defined aspects of
7513 @code{Task_Attributes}.  See C.7.2(19).
7514 @end cartouche
7515 @noindent
7516 There are no implementation-defined aspects of @code{Task_Attributes}.
7517
7518 @sp 1
7519 @cartouche
7520 @noindent
7521 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7522 @end cartouche
7523 @noindent
7524 The metrics information for GNAT depends on the performance of the
7525 underlying operating system.  The sources of the run-time for tasking
7526 implementation, together with the output from @code{-gnatG} can be
7527 used to determine the exact sequence of operating systems calls made
7528 to implement various tasking constructs.  Together with appropriate
7529 information on the performance of the underlying operating system,
7530 on the exact target in use, this information can be used to determine
7531 the required metrics.
7532
7533 @sp 1
7534 @cartouche
7535 @noindent
7536 @strong{91}.  The declarations of @code{Any_Priority} and
7537 @code{Priority}.  See D.1(11).
7538 @end cartouche
7539 @noindent
7540 See declarations in file @file{system.ads}.
7541
7542 @sp 1
7543 @cartouche
7544 @noindent
7545 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7546 @end cartouche
7547 @noindent
7548 There are no implementation-defined execution resources.
7549
7550 @sp 1
7551 @cartouche
7552 @noindent
7553 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7554 access to a protected object keeps its processor busy.  See D.2.1(3).
7555 @end cartouche
7556 @noindent
7557 On a multi-processor, a task that is waiting for access to a protected
7558 object does not keep its processor busy.
7559
7560 @sp 1
7561 @cartouche
7562 @noindent
7563 @strong{94}.  The affect of implementation defined execution resources
7564 on task dispatching.  See D.2.1(9).
7565 @end cartouche
7566 @noindent
7567 @c SGI info
7568 @ignore
7569 Tasks map to IRIX threads, and the dispatching policy is as defined by
7570 the IRIX implementation of threads.
7571 @end ignore
7572 Tasks map to threads in the threads package used by GNAT@.  Where possible
7573 and appropriate, these threads correspond to native threads of the
7574 underlying operating system.
7575
7576 @sp 1
7577 @cartouche
7578 @noindent
7579 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7580 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7581 @end cartouche
7582 @noindent
7583 There are no implementation-defined policy-identifiers allowed in this
7584 pragma.
7585
7586 @sp 1
7587 @cartouche
7588 @noindent
7589 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7590 D.2.2(16).
7591 @end cartouche
7592 @noindent
7593 Execution of a task cannot be preempted by the implementation processing
7594 of delay expirations for lower priority tasks.
7595
7596 @sp 1
7597 @cartouche
7598 @noindent
7599 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7600 @end cartouche
7601 @noindent
7602 @c SGI info:
7603 @ignore
7604 Tasks map to IRIX threads, and the dispatching policy is as defied by
7605 the IRIX implementation of threads.
7606 @end ignore
7607 The policy is the same as that of the underlying threads implementation.
7608
7609 @sp 1
7610 @cartouche
7611 @noindent
7612 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7613 in a pragma @code{Locking_Policy}.  See D.3(4).
7614 @end cartouche
7615 @noindent
7616 The only implementation defined policy permitted in GNAT is
7617 @code{Inheritance_Locking}.  On targets that support this policy, locking
7618 is implemented by inheritance, i.e.@: the task owning the lock operates
7619 at a priority equal to the highest priority of any task currently
7620 requesting the lock.
7621
7622 @sp 1
7623 @cartouche
7624 @noindent
7625 @strong{99}.  Default ceiling priorities.  See D.3(10).
7626 @end cartouche
7627 @noindent
7628 The ceiling priority of protected objects of the type
7629 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7630 Reference Manual D.3(10),
7631
7632 @sp 1
7633 @cartouche
7634 @noindent
7635 @strong{100}.  The ceiling of any protected object used internally by
7636 the implementation.  See D.3(16).
7637 @end cartouche
7638 @noindent
7639 The ceiling priority of internal protected objects is
7640 @code{System.Priority'Last}.
7641
7642 @sp 1
7643 @cartouche
7644 @noindent
7645 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7646 @end cartouche
7647 @noindent
7648 There are no implementation-defined queueing policies.
7649
7650 @sp 1
7651 @cartouche
7652 @noindent
7653 @strong{102}.  On a multiprocessor, any conditions that cause the
7654 completion of an aborted construct to be delayed later than what is
7655 specified for a single processor.  See D.6(3).
7656 @end cartouche
7657 @noindent
7658 The semantics for abort on a multi-processor is the same as on a single
7659 processor, there are no further delays.
7660
7661 @sp 1
7662 @cartouche
7663 @noindent
7664 @strong{103}.  Any operations that implicitly require heap storage
7665 allocation.  See D.7(8).
7666 @end cartouche
7667 @noindent
7668 The only operation that implicitly requires heap storage allocation is
7669 task creation.
7670
7671 @sp 1
7672 @cartouche
7673 @noindent
7674 @strong{104}.  Implementation-defined aspects of pragma
7675 @code{Restrictions}.  See D.7(20).
7676 @end cartouche
7677 @noindent
7678 There are no such implementation-defined aspects.
7679
7680 @sp 1
7681 @cartouche
7682 @noindent
7683 @strong{105}.  Implementation-defined aspects of package
7684 @code{Real_Time}.  See D.8(17).
7685 @end cartouche
7686 @noindent
7687 There are no implementation defined aspects of package @code{Real_Time}.
7688
7689 @sp 1
7690 @cartouche
7691 @noindent
7692 @strong{106}.  Implementation-defined aspects of
7693 @code{delay_statements}.  See D.9(8).
7694 @end cartouche
7695 @noindent
7696 Any difference greater than one microsecond will cause the task to be
7697 delayed (see D.9(7)).
7698
7699 @sp 1
7700 @cartouche
7701 @noindent
7702 @strong{107}.  The upper bound on the duration of interrupt blocking
7703 caused by the implementation.  See D.12(5).
7704 @end cartouche
7705 @noindent
7706 The upper bound is determined by the underlying operating system.  In
7707 no cases is it more than 10 milliseconds.
7708
7709 @sp 1
7710 @cartouche
7711 @noindent
7712 @strong{108}.  The means for creating and executing distributed
7713 programs.  See E(5).
7714 @end cartouche
7715 @noindent
7716 The GLADE package provides a utility GNATDIST for creating and executing
7717 distributed programs.  See the GLADE reference manual for further details.
7718
7719 @sp 1
7720 @cartouche
7721 @noindent
7722 @strong{109}.  Any events that can result in a partition becoming
7723 inaccessible.  See E.1(7).
7724 @end cartouche
7725 @noindent
7726 See the GLADE reference manual for full details on such events.
7727
7728 @sp 1
7729 @cartouche
7730 @noindent
7731 @strong{110}.  The scheduling policies, treatment of priorities, and
7732 management of shared resources between partitions in certain cases.  See
7733 E.1(11).
7734 @end cartouche
7735 @noindent
7736 See the GLADE reference manual for full details on these aspects of
7737 multi-partition execution.
7738
7739 @sp 1
7740 @cartouche
7741 @noindent
7742 @strong{111}.  Events that cause the version of a compilation unit to
7743 change.  See E.3(5).
7744 @end cartouche
7745 @noindent
7746 Editing the source file of a compilation unit, or the source files of
7747 any units on which it is dependent in a significant way cause the version
7748 to change.  No other actions cause the version number to change.  All changes
7749 are significant except those which affect only layout, capitalization or
7750 comments.
7751
7752 @sp 1
7753 @cartouche
7754 @noindent
7755 @strong{112}.  Whether the execution of the remote subprogram is
7756 immediately aborted as a result of cancellation.  See E.4(13).
7757 @end cartouche
7758 @noindent
7759 See the GLADE reference manual for details on the effect of abort in
7760 a distributed application.
7761
7762 @sp 1
7763 @cartouche
7764 @noindent
7765 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7766 @end cartouche
7767 @noindent
7768 See the GLADE reference manual for a full description of all implementation
7769 defined aspects of the PCS@.
7770
7771 @sp 1
7772 @cartouche
7773 @noindent
7774 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7775 E.5(26).
7776 @end cartouche
7777 @noindent
7778 See the GLADE reference manual for a full description of all
7779 implementation defined interfaces.
7780
7781 @sp 1
7782 @cartouche
7783 @noindent
7784 @strong{115}.  The values of named numbers in the package
7785 @code{Decimal}.  See F.2(7).
7786 @end cartouche
7787 @noindent
7788 @table @code
7789 @item Max_Scale
7790 +18
7791 @item Min_Scale
7792 -18
7793 @item Min_Delta
7794 1.0E-18
7795 @item Max_Delta
7796 1.0E+18
7797 @item Max_Decimal_Digits
7798 18
7799 @end table
7800
7801 @sp 1
7802 @cartouche
7803 @noindent
7804 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7805 @code{Text_IO.Editing}.  See F.3.3(16).
7806 @end cartouche
7807 @noindent
7808 64
7809
7810 @sp 1
7811 @cartouche
7812 @noindent
7813 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7814 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7815 @end cartouche
7816 @noindent
7817 64
7818
7819 @sp 1
7820 @cartouche
7821 @noindent
7822 @strong{118}.  The accuracy actually achieved by the complex elementary
7823 functions and by other complex arithmetic operations.  See G.1(1).
7824 @end cartouche
7825 @noindent
7826 Standard library functions are used for the complex arithmetic
7827 operations.  Only fast math mode is currently supported.
7828
7829 @sp 1
7830 @cartouche
7831 @noindent
7832 @strong{119}.  The sign of a zero result (or a component thereof) from
7833 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7834 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7835 @end cartouche
7836 @noindent
7837 The signs of zero values are as recommended by the relevant
7838 implementation advice.
7839
7840 @sp 1
7841 @cartouche
7842 @noindent
7843 @strong{120}.  The sign of a zero result (or a component thereof) from
7844 any operator or function in
7845 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7846 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7847 @end cartouche
7848 @noindent
7849 The signs of zero values are as recommended by the relevant
7850 implementation advice.
7851
7852 @sp 1
7853 @cartouche
7854 @noindent
7855 @strong{121}.  Whether the strict mode or the relaxed mode is the
7856 default.  See G.2(2).
7857 @end cartouche
7858 @noindent
7859 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7860 provides a highly efficient implementation of strict mode.
7861
7862 @sp 1
7863 @cartouche
7864 @noindent
7865 @strong{122}.  The result interval in certain cases of fixed-to-float
7866 conversion.  See G.2.1(10).
7867 @end cartouche
7868 @noindent
7869 For cases where the result interval is implementation dependent, the
7870 accuracy is that provided by performing all operations in 64-bit IEEE
7871 floating-point format.
7872
7873 @sp 1
7874 @cartouche
7875 @noindent
7876 @strong{123}.  The result of a floating point arithmetic operation in
7877 overflow situations, when the @code{Machine_Overflows} attribute of the
7878 result type is @code{False}.  See G.2.1(13).
7879 @end cartouche
7880 @noindent
7881 Infinite and Nan values are produced as dictated by the IEEE
7882 floating-point standard.
7883
7884 @sp 1
7885 @cartouche
7886 @noindent
7887 @strong{124}.  The result interval for division (or exponentiation by a
7888 negative exponent), when the floating point hardware implements division
7889 as multiplication by a reciprocal.  See G.2.1(16).
7890 @end cartouche
7891 @noindent
7892 Not relevant, division is IEEE exact.
7893
7894 @sp 1
7895 @cartouche
7896 @noindent
7897 @strong{125}.  The definition of close result set, which determines the
7898 accuracy of certain fixed point multiplications and divisions.  See
7899 G.2.3(5).
7900 @end cartouche
7901 @noindent
7902 Operations in the close result set are performed using IEEE long format
7903 floating-point arithmetic.  The input operands are converted to
7904 floating-point, the operation is done in floating-point, and the result
7905 is converted to the target type.
7906
7907 @sp 1
7908 @cartouche
7909 @noindent
7910 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7911 point multiplication or division for which the result shall be in the
7912 perfect result set.  See G.2.3(22).
7913 @end cartouche
7914 @noindent
7915 The result is only defined to be in the perfect result set if the result
7916 can be computed by a single scaling operation involving a scale factor
7917 representable in 64-bits.
7918
7919 @sp 1
7920 @cartouche
7921 @noindent
7922 @strong{127}.  The result of a fixed point arithmetic operation in
7923 overflow situations, when the @code{Machine_Overflows} attribute of the
7924 result type is @code{False}.  See G.2.3(27).
7925 @end cartouche
7926 @noindent
7927 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7928 types.
7929
7930 @sp 1
7931 @cartouche
7932 @noindent
7933 @strong{128}.  The result of an elementary function reference in
7934 overflow situations, when the @code{Machine_Overflows} attribute of the
7935 result type is @code{False}.  See G.2.4(4).
7936 @end cartouche
7937 @noindent
7938 IEEE infinite and Nan values are produced as appropriate.
7939
7940 @sp 1
7941 @cartouche
7942 @noindent
7943 @strong{129}.  The value of the angle threshold, within which certain
7944 elementary functions, complex arithmetic operations, and complex
7945 elementary functions yield results conforming to a maximum relative
7946 error bound.  See G.2.4(10).
7947 @end cartouche
7948 @noindent
7949 Information on this subject is not yet available.
7950
7951 @sp 1
7952 @cartouche
7953 @noindent
7954 @strong{130}.  The accuracy of certain elementary functions for
7955 parameters beyond the angle threshold.  See G.2.4(10).
7956 @end cartouche
7957 @noindent
7958 Information on this subject is not yet available.
7959
7960 @sp 1
7961 @cartouche
7962 @noindent
7963 @strong{131}.  The result of a complex arithmetic operation or complex
7964 elementary function reference in overflow situations, when the
7965 @code{Machine_Overflows} attribute of the corresponding real type is
7966 @code{False}.  See G.2.6(5).
7967 @end cartouche
7968 @noindent
7969 IEEE infinite and Nan values are produced as appropriate.
7970
7971 @sp 1
7972 @cartouche
7973 @noindent
7974 @strong{132}.  The accuracy of certain complex arithmetic operations and
7975 certain complex elementary functions for parameters (or components
7976 thereof) beyond the angle threshold.  See G.2.6(8).
7977 @end cartouche
7978 @noindent
7979 Information on those subjects is not yet available.
7980
7981 @sp 1
7982 @cartouche
7983 @noindent
7984 @strong{133}.  Information regarding bounded errors and erroneous
7985 execution.  See H.2(1).
7986 @end cartouche
7987 @noindent
7988 Information on this subject is not yet available.
7989
7990 @sp 1
7991 @cartouche
7992 @noindent
7993 @strong{134}.  Implementation-defined aspects of pragma
7994 @code{Inspection_Point}.  See H.3.2(8).
7995 @end cartouche
7996 @noindent
7997 Pragma @code{Inspection_Point} ensures that the variable is live and can
7998 be examined by the debugger at the inspection point.
7999
8000 @sp 1
8001 @cartouche
8002 @noindent
8003 @strong{135}.  Implementation-defined aspects of pragma
8004 @code{Restrictions}.  See H.4(25).
8005 @end cartouche
8006 @noindent
8007 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8008 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8009 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8010
8011 @sp 1
8012 @cartouche
8013 @noindent
8014 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8015 H.4(27).
8016 @end cartouche
8017 @noindent
8018 There are no restrictions on pragma @code{Restrictions}.
8019
8020 @node Intrinsic Subprograms
8021 @chapter Intrinsic Subprograms
8022 @cindex Intrinsic Subprograms
8023
8024 @menu
8025 * Intrinsic Operators::
8026 * Enclosing_Entity::
8027 * Exception_Information::
8028 * Exception_Message::
8029 * Exception_Name::
8030 * File::
8031 * Line::
8032 * Rotate_Left::
8033 * Rotate_Right::
8034 * Shift_Left::
8035 * Shift_Right::
8036 * Shift_Right_Arithmetic::
8037 * Source_Location::
8038 @end menu
8039
8040 @noindent
8041 GNAT allows a user application program to write the declaration:
8042
8043 @smallexample @c ada
8044    pragma Import (Intrinsic, name);
8045 @end smallexample
8046
8047 @noindent
8048 providing that the name corresponds to one of the implemented intrinsic
8049 subprograms in GNAT, and that the parameter profile of the referenced
8050 subprogram meets the requirements.  This chapter describes the set of
8051 implemented intrinsic subprograms, and the requirements on parameter profiles.
8052 Note that no body is supplied; as with other uses of pragma Import, the
8053 body is supplied elsewhere (in this case by the compiler itself).  Note
8054 that any use of this feature is potentially non-portable, since the
8055 Ada standard does not require Ada compilers to implement this feature.
8056
8057 @node Intrinsic Operators
8058 @section Intrinsic Operators
8059 @cindex Intrinsic operator
8060
8061 @noindent
8062 All the predefined numeric operators in package Standard
8063 in @code{pragma Import (Intrinsic,..)}
8064 declarations.  In the binary operator case, the operands must have the same
8065 size.  The operand or operands must also be appropriate for
8066 the operator.  For example, for addition, the operands must
8067 both be floating-point or both be fixed-point, and the
8068 right operand for @code{"**"} must have a root type of
8069 @code{Standard.Integer'Base}.
8070 You can use an intrinsic operator declaration as in the following example:
8071
8072 @smallexample @c ada
8073    type Int1 is new Integer;
8074    type Int2 is new Integer;
8075
8076    function "+" (X1 : Int1; X2 : Int2) return Int1;
8077    function "+" (X1 : Int1; X2 : Int2) return Int2;
8078    pragma Import (Intrinsic, "+");
8079 @end smallexample
8080
8081 @noindent
8082 This declaration would permit ``mixed mode'' arithmetic on items
8083 of the differing types @code{Int1} and @code{Int2}.
8084 It is also possible to specify such operators for private types, if the
8085 full views are appropriate arithmetic types.
8086
8087 @node Enclosing_Entity
8088 @section Enclosing_Entity
8089 @cindex Enclosing_Entity
8090 @noindent
8091 This intrinsic subprogram is used in the implementation of the
8092 library routine @code{GNAT.Source_Info}.  The only useful use of the
8093 intrinsic import in this case is the one in this unit, so an
8094 application program should simply call the function
8095 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8096 the current subprogram, package, task, entry, or protected subprogram.
8097
8098 @node Exception_Information
8099 @section Exception_Information
8100 @cindex Exception_Information'
8101 @noindent
8102 This intrinsic subprogram is used in the implementation of the
8103 library routine @code{GNAT.Current_Exception}.  The only useful
8104 use of the intrinsic import in this case is the one in this unit,
8105 so an application program should simply call the function
8106 @code{GNAT.Current_Exception.Exception_Information} to obtain
8107 the exception information associated with the current exception.
8108
8109 @node Exception_Message
8110 @section Exception_Message
8111 @cindex Exception_Message
8112 @noindent
8113 This intrinsic subprogram is used in the implementation of the
8114 library routine @code{GNAT.Current_Exception}.  The only useful
8115 use of the intrinsic import in this case is the one in this unit,
8116 so an application program should simply call the function
8117 @code{GNAT.Current_Exception.Exception_Message} to obtain
8118 the message associated with the current exception.
8119
8120 @node Exception_Name
8121 @section Exception_Name
8122 @cindex Exception_Name
8123 @noindent
8124 This intrinsic subprogram is used in the implementation of the
8125 library routine @code{GNAT.Current_Exception}.  The only useful
8126 use of the intrinsic import in this case is the one in this unit,
8127 so an application program should simply call the function
8128 @code{GNAT.Current_Exception.Exception_Name} to obtain
8129 the name of the current exception.
8130
8131 @node File
8132 @section File
8133 @cindex File
8134 @noindent
8135 This intrinsic subprogram is used in the implementation of the
8136 library routine @code{GNAT.Source_Info}.  The only useful use of the
8137 intrinsic import in this case is the one in this unit, so an
8138 application program should simply call the function
8139 @code{GNAT.Source_Info.File} to obtain the name of the current
8140 file.
8141
8142 @node Line
8143 @section Line
8144 @cindex Line
8145 @noindent
8146 This intrinsic subprogram is used in the implementation of the
8147 library routine @code{GNAT.Source_Info}.  The only useful use of the
8148 intrinsic import in this case is the one in this unit, so an
8149 application program should simply call the function
8150 @code{GNAT.Source_Info.Line} to obtain the number of the current
8151 source line.
8152
8153 @node Rotate_Left
8154 @section Rotate_Left
8155 @cindex Rotate_Left
8156 @noindent
8157 In standard Ada 95, the @code{Rotate_Left} function is available only
8158 for the predefined modular types in package @code{Interfaces}.  However, in
8159 GNAT it is possible to define a Rotate_Left function for a user
8160 defined modular type or any signed integer type as in this example:
8161
8162 @smallexample @c ada
8163    function Shift_Left
8164      (Value  : My_Modular_Type;
8165       Amount : Natural)
8166       return   My_Modular_Type;
8167 @end smallexample
8168
8169 @noindent
8170 The requirements are that the profile be exactly as in the example
8171 above.  The only modifications allowed are in the formal parameter
8172 names, and in the type of @code{Value} and the return type, which
8173 must be the same, and must be either a signed integer type, or
8174 a modular integer type with a binary modulus, and the size must
8175 be 8.  16, 32 or 64 bits.
8176
8177 @node Rotate_Right
8178 @section Rotate_Right
8179 @cindex Rotate_Right
8180 @noindent
8181 A @code{Rotate_Right} function can be defined for any user defined
8182 binary modular integer type, or signed integer type, as described
8183 above for @code{Rotate_Left}.
8184
8185 @node Shift_Left
8186 @section Shift_Left
8187 @cindex Shift_Left
8188 @noindent
8189 A @code{Shift_Left} function can be defined for any user defined
8190 binary modular integer type, or signed integer type, as described
8191 above for @code{Rotate_Left}.
8192
8193 @node Shift_Right
8194 @section Shift_Right
8195 @cindex Shift_Right
8196 @noindent
8197 A @code{Shift_Right} function can be defined for any user defined
8198 binary modular integer type, or signed integer type, as described
8199 above for @code{Rotate_Left}.
8200
8201 @node Shift_Right_Arithmetic
8202 @section Shift_Right_Arithmetic
8203 @cindex Shift_Right_Arithmetic
8204 @noindent
8205 A @code{Shift_Right_Arithmetic} function can be defined for any user
8206 defined binary modular integer type, or signed integer type, as described
8207 above for @code{Rotate_Left}.
8208
8209 @node Source_Location
8210 @section Source_Location
8211 @cindex Source_Location
8212 @noindent
8213 This intrinsic subprogram is used in the implementation of the
8214 library routine @code{GNAT.Source_Info}.  The only useful use of the
8215 intrinsic import in this case is the one in this unit, so an
8216 application program should simply call the function
8217 @code{GNAT.Source_Info.Source_Location} to obtain the current
8218 source file location.
8219
8220 @node Representation Clauses and Pragmas
8221 @chapter Representation Clauses and Pragmas
8222 @cindex Representation Clauses
8223
8224 @menu
8225 * Alignment Clauses::
8226 * Size Clauses::
8227 * Storage_Size Clauses::
8228 * Size of Variant Record Objects::
8229 * Biased Representation ::
8230 * Value_Size and Object_Size Clauses::
8231 * Component_Size Clauses::
8232 * Bit_Order Clauses::
8233 * Effect of Bit_Order on Byte Ordering::
8234 * Pragma Pack for Arrays::
8235 * Pragma Pack for Records::
8236 * Record Representation Clauses::
8237 * Enumeration Clauses::
8238 * Address Clauses::
8239 * Effect of Convention on Representation::
8240 * Determining the Representations chosen by GNAT::
8241 @end menu
8242
8243 @noindent
8244 @cindex Representation Clause
8245 @cindex Representation Pragma
8246 @cindex Pragma, representation
8247 This section describes the representation clauses accepted by GNAT, and
8248 their effect on the representation of corresponding data objects.
8249
8250 GNAT fully implements Annex C (Systems Programming).  This means that all
8251 the implementation advice sections in chapter 13 are fully implemented.
8252 However, these sections only require a minimal level of support for
8253 representation clauses.  GNAT provides much more extensive capabilities,
8254 and this section describes the additional capabilities provided.
8255
8256 @node Alignment Clauses
8257 @section Alignment Clauses
8258 @cindex Alignment Clause
8259
8260 @noindent
8261 GNAT requires that all alignment clauses specify a power of 2, and all
8262 default alignments are always a power of 2.  The default alignment
8263 values are as follows:
8264
8265 @itemize @bullet
8266 @item @emph{Primitive Types}.
8267 For primitive types, the alignment is the minimum of the actual size of
8268 objects of the type divided by @code{Storage_Unit},
8269 and the maximum alignment supported by the target.
8270 (This maximum alignment is given by the GNAT-specific attribute
8271 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8272 @cindex @code{Maximum_Alignment} attribute
8273 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8274 default alignment will be 8 on any target that supports alignments
8275 this large, but on some targets, the maximum alignment may be smaller
8276 than 8, in which case objects of type @code{Long_Float} will be maximally
8277 aligned.
8278
8279 @item @emph{Arrays}.
8280 For arrays, the alignment is equal to the alignment of the component type
8281 for the normal case where no packing or component size is given.  If the
8282 array is packed, and the packing is effective (see separate section on
8283 packed arrays), then the alignment will be one for long packed arrays,
8284 or arrays whose length is not known at compile time.  For short packed
8285 arrays, which are handled internally as modular types, the alignment
8286 will be as described for primitive types, e.g.@: a packed array of length
8287 31 bits will have an object size of four bytes, and an alignment of 4.
8288
8289 @item @emph{Records}.
8290 For the normal non-packed case, the alignment of a record is equal to
8291 the maximum alignment of any of its components.  For tagged records, this
8292 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8293 used and all fields are packable (see separate section on pragma @code{Pack}),
8294 then the resulting alignment is 1.
8295
8296 A special case is when:
8297 @itemize @bullet
8298 @item
8299 the size of the record is given explicitly, or a
8300 full record representation clause is given, and
8301 @item
8302 the size of the record is 2, 4, or 8 bytes.
8303 @end itemize
8304 @noindent
8305 In this case, an alignment is chosen to match the
8306 size of the record. For example, if we have:
8307
8308 @smallexample @c ada
8309    type Small is record
8310       A, B : Character;
8311    end record;
8312    for Small'Size use 16;
8313 @end smallexample
8314
8315 @noindent
8316 then the default alignment of the record type @code{Small} is 2, not 1. This
8317 leads to more efficient code when the record is treated as a unit, and also
8318 allows the type to specified as @code{Atomic} on architectures requiring
8319 strict alignment.
8320
8321 @end itemize
8322
8323 @noindent
8324 An alignment clause may
8325 always specify a larger alignment than the default value, up to some
8326 maximum value dependent on the target (obtainable by using the
8327 attribute reference @code{Standard'Maximum_Alignment}).
8328 The only case where
8329 it is permissible to specify a smaller alignment than the default value
8330 is for a record with a record representation clause.
8331 In this case, packable fields for which a component clause is
8332 given still result in a default alignment corresponding to the original
8333 type, but this may be overridden, since these components in fact only
8334 require an alignment of one byte.  For example, given
8335
8336 @smallexample @c ada
8337   type V is record
8338      A : Integer;
8339   end record;
8340
8341   for V use record
8342      A at 0  range 0 .. 31;
8343   end record;
8344
8345   for V'alignment use 1;
8346 @end smallexample
8347
8348 @noindent
8349 @cindex Alignment, default
8350 The default alignment for the type @code{V} is 4, as a result of the
8351 Integer field in the record, but since this field is placed with a
8352 component clause, it is permissible, as shown, to override the default
8353 alignment of the record with a smaller value.
8354
8355 @node Size Clauses
8356 @section Size Clauses
8357 @cindex Size Clause
8358
8359 @noindent
8360 The default size for a type @code{T} is obtainable through the
8361 language-defined attribute @code{T'Size} and also through the
8362 equivalent GNAT-defined attribute @code{T'Value_Size}.
8363 For objects of type @code{T}, GNAT will generally increase the type size
8364 so that the object size (obtainable through the GNAT-defined attribute
8365 @code{T'Object_Size})
8366 is a multiple of @code{T'Alignment * Storage_Unit}.
8367 For example
8368
8369 @smallexample @c ada
8370    type Smallint is range 1 .. 6;
8371
8372    type Rec is record
8373       Y1 : integer;
8374       Y2 : boolean;
8375    end record;
8376 @end smallexample
8377
8378 @noindent
8379 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8380 as specified by the RM rules,
8381 but objects of this type will have a size of 8
8382 (@code{Smallint'Object_Size} = 8),
8383 since objects by default occupy an integral number
8384 of storage units.  On some targets, notably older
8385 versions of the Digital Alpha, the size of stand
8386 alone objects of this type may be 32, reflecting
8387 the inability of the hardware to do byte load/stores.
8388
8389 Similarly, the size of type @code{Rec} is 40 bits
8390 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8391 the alignment is 4, so objects of this type will have
8392 their size increased to 64 bits so that it is a multiple
8393 of the alignment (in bits).  This decision is
8394 in accordance with the specific Implementation Advice in RM 13.3(43):
8395
8396 @quotation
8397 A @code{Size} clause should be supported for an object if the specified
8398 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8399 to a size in storage elements that is a multiple of the object's
8400 @code{Alignment} (if the @code{Alignment} is nonzero).
8401 @end quotation
8402
8403 @noindent
8404 An explicit size clause may be used to override the default size by
8405 increasing it.  For example, if we have:
8406
8407 @smallexample @c ada
8408    type My_Boolean is new Boolean;
8409    for My_Boolean'Size use 32;
8410 @end smallexample
8411
8412 @noindent
8413 then values of this type will always be 32 bits long.  In the case of
8414 discrete types, the size can be increased up to 64 bits, with the effect
8415 that the entire specified field is used to hold the value, sign- or
8416 zero-extended as appropriate.  If more than 64 bits is specified, then
8417 padding space is allocated after the value, and a warning is issued that
8418 there are unused bits.
8419
8420 Similarly the size of records and arrays may be increased, and the effect
8421 is to add padding bits after the value.  This also causes a warning message
8422 to be generated.
8423
8424 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8425 Size in bits, this corresponds to an object of size 256 megabytes (minus
8426 one).  This limitation is true on all targets.  The reason for this
8427 limitation is that it improves the quality of the code in many cases
8428 if it is known that a Size value can be accommodated in an object of
8429 type Integer.
8430
8431 @node Storage_Size Clauses
8432 @section Storage_Size Clauses
8433 @cindex Storage_Size Clause
8434
8435 @noindent
8436 For tasks, the @code{Storage_Size} clause specifies the amount of space
8437 to be allocated for the task stack.  This cannot be extended, and if the
8438 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8439 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8440 or a @code{Storage_Size} pragma in the task definition to set the
8441 appropriate required size.  A useful technique is to include in every
8442 task definition a pragma of the form:
8443
8444 @smallexample @c ada
8445    pragma Storage_Size (Default_Stack_Size);
8446 @end smallexample
8447
8448 @noindent
8449 Then @code{Default_Stack_Size} can be defined in a global package, and
8450 modified as required.  Any tasks requiring stack sizes different from the
8451 default can have an appropriate alternative reference in the pragma.
8452
8453 For access types, the @code{Storage_Size} clause specifies the maximum
8454 space available for allocation of objects of the type.  If this space is
8455 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8456 In the case where the access type is declared local to a subprogram, the
8457 use of a @code{Storage_Size} clause triggers automatic use of a special
8458 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8459 space for the pool is automatically reclaimed on exit from the scope in
8460 which the type is declared.
8461
8462 A special case recognized by the compiler is the specification of a
8463 @code{Storage_Size} of zero for an access type.  This means that no
8464 items can be allocated from the pool, and this is recognized at compile
8465 time, and all the overhead normally associated with maintaining a fixed
8466 size storage pool is eliminated.  Consider the following example:
8467
8468 @smallexample @c ada
8469    procedure p is
8470       type R is array (Natural) of Character;
8471       type P is access all R;
8472       for P'Storage_Size use 0;
8473       --  Above access type intended only for interfacing purposes
8474
8475       y : P;
8476
8477       procedure g (m : P);
8478       pragma Import (C, g);
8479
8480       --  @dots{}
8481
8482    begin
8483       --  @dots{}
8484       y := new R;
8485    end;
8486 @end smallexample
8487
8488 @noindent
8489 As indicated in this example, these dummy storage pools are often useful in
8490 connection with interfacing where no object will ever be allocated.  If you
8491 compile the above example, you get the warning:
8492
8493 @smallexample
8494    p.adb:16:09: warning: allocation from empty storage pool
8495    p.adb:16:09: warning: Storage_Error will be raised at run time
8496 @end smallexample
8497
8498 @noindent
8499 Of course in practice, there will not be any explicit allocators in the
8500 case of such an access declaration.
8501
8502 @node Size of Variant Record Objects
8503 @section Size of Variant Record Objects
8504 @cindex Size, variant record objects
8505 @cindex Variant record objects, size
8506
8507 @noindent
8508 In the case of variant record objects, there is a question whether Size gives
8509 information about a particular variant, or the maximum size required
8510 for any variant.  Consider the following program
8511
8512 @smallexample @c ada
8513 with Text_IO; use Text_IO;
8514 procedure q is
8515    type R1 (A : Boolean := False) is record
8516      case A is
8517        when True  => X : Character;
8518        when False => null;
8519      end case;
8520    end record;
8521
8522    V1 : R1 (False);
8523    V2 : R1;
8524
8525 begin
8526    Put_Line (Integer'Image (V1'Size));
8527    Put_Line (Integer'Image (V2'Size));
8528 end q;
8529 @end smallexample
8530
8531 @noindent
8532 Here we are dealing with a variant record, where the True variant
8533 requires 16 bits, and the False variant requires 8 bits.
8534 In the above example, both V1 and V2 contain the False variant,
8535 which is only 8 bits long.  However, the result of running the
8536 program is:
8537
8538 @smallexample
8539 8
8540 16
8541 @end smallexample
8542
8543 @noindent
8544 The reason for the difference here is that the discriminant value of
8545 V1 is fixed, and will always be False.  It is not possible to assign
8546 a True variant value to V1, therefore 8 bits is sufficient.  On the
8547 other hand, in the case of V2, the initial discriminant value is
8548 False (from the default), but it is possible to assign a True
8549 variant value to V2, therefore 16 bits must be allocated for V2
8550 in the general case, even fewer bits may be needed at any particular
8551 point during the program execution.
8552
8553 As can be seen from the output of this program, the @code{'Size}
8554 attribute applied to such an object in GNAT gives the actual allocated
8555 size of the variable, which is the largest size of any of the variants.
8556 The Ada Reference Manual is not completely clear on what choice should
8557 be made here, but the GNAT behavior seems most consistent with the
8558 language in the RM@.
8559
8560 In some cases, it may be desirable to obtain the size of the current
8561 variant, rather than the size of the largest variant.  This can be
8562 achieved in GNAT by making use of the fact that in the case of a
8563 subprogram parameter, GNAT does indeed return the size of the current
8564 variant (because a subprogram has no way of knowing how much space
8565 is actually allocated for the actual).
8566
8567 Consider the following modified version of the above program:
8568
8569 @smallexample @c ada
8570 with Text_IO; use Text_IO;
8571 procedure q is
8572    type R1 (A : Boolean := False) is record
8573      case A is
8574        when True  => X : Character;
8575        when False => null;
8576      end case;
8577    end record;
8578
8579    V2 : R1;
8580
8581    function Size (V : R1) return Integer is
8582    begin
8583       return V'Size;
8584    end Size;
8585
8586 begin
8587    Put_Line (Integer'Image (V2'Size));
8588    Put_Line (Integer'IMage (Size (V2)));
8589    V2 := (True, 'x');
8590    Put_Line (Integer'Image (V2'Size));
8591    Put_Line (Integer'IMage (Size (V2)));
8592 end q;
8593 @end smallexample
8594
8595 @noindent
8596 The output from this program is
8597
8598 @smallexample
8599 16
8600 8
8601 16
8602 16
8603 @end smallexample
8604
8605 @noindent
8606 Here we see that while the @code{'Size} attribute always returns
8607 the maximum size, regardless of the current variant value, the
8608 @code{Size} function does indeed return the size of the current
8609 variant value.
8610
8611 @node Biased Representation
8612 @section Biased Representation
8613 @cindex Size for biased representation
8614 @cindex Biased representation
8615
8616 @noindent
8617 In the case of scalars with a range starting at other than zero, it is
8618 possible in some cases to specify a size smaller than the default minimum
8619 value, and in such cases, GNAT uses an unsigned biased representation,
8620 in which zero is used to represent the lower bound, and successive values
8621 represent successive values of the type.
8622
8623 For example, suppose we have the declaration:
8624
8625 @smallexample @c ada
8626    type Small is range -7 .. -4;
8627    for Small'Size use 2;
8628 @end smallexample
8629
8630 @noindent
8631 Although the default size of type @code{Small} is 4, the @code{Size}
8632 clause is accepted by GNAT and results in the following representation
8633 scheme:
8634
8635 @smallexample
8636   -7 is represented as 2#00#
8637   -6 is represented as 2#01#
8638   -5 is represented as 2#10#
8639   -4 is represented as 2#11#
8640 @end smallexample
8641
8642 @noindent
8643 Biased representation is only used if the specified @code{Size} clause
8644 cannot be accepted in any other manner.  These reduced sizes that force
8645 biased representation can be used for all discrete types except for
8646 enumeration types for which a representation clause is given.
8647
8648 @node Value_Size and Object_Size Clauses
8649 @section Value_Size and Object_Size Clauses
8650 @findex Value_Size
8651 @findex Object_Size
8652 @cindex Size, of objects
8653
8654 @noindent
8655 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8656 required to hold values of type @code{T}.  Although this interpretation was
8657 allowed in Ada 83, it was not required, and this requirement in practice
8658 can cause some significant difficulties.  For example, in most Ada 83
8659 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8660 @code{Natural'Size} is
8661 typically 31.  This means that code may change in behavior when moving
8662 from Ada 83 to Ada 95.  For example, consider:
8663
8664 @smallexample @c ada
8665    type Rec is record;
8666       A : Natural;
8667       B : Natural;
8668    end record;
8669
8670    for Rec use record
8671       at 0  range 0 .. Natural'Size - 1;
8672       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8673    end record;
8674 @end smallexample
8675
8676 @noindent
8677 In the above code, since the typical size of @code{Natural} objects
8678 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8679 unexpected inefficient packing in Ada 95, and in general there are
8680 cases where the fact that the object size can exceed the
8681 size of the type causes surprises.
8682
8683 To help get around this problem GNAT provides two implementation
8684 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8685 applied to a type, these attributes yield the size of the type
8686 (corresponding to the RM defined size attribute), and the size of
8687 objects of the type respectively.
8688
8689 The @code{Object_Size} is used for determining the default size of
8690 objects and components.  This size value can be referred to using the
8691 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8692 the basis of the determination of the size.  The backend is free to
8693 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8694 character might be stored in 32 bits on a machine with no efficient
8695 byte access instructions such as the Alpha.
8696
8697 The default rules for the value of @code{Object_Size} for
8698 discrete types are as follows:
8699
8700 @itemize @bullet
8701 @item
8702 The @code{Object_Size} for base subtypes reflect the natural hardware
8703 size in bits (run the compiler with @option{-gnatS} to find those values
8704 for numeric types). Enumeration types and fixed-point base subtypes have
8705 8, 16, 32 or 64 bits for this size, depending on the range of values
8706 to be stored.
8707
8708 @item
8709 The @code{Object_Size} of a subtype is the same as the
8710 @code{Object_Size} of
8711 the type from which it is obtained.
8712
8713 @item
8714 The @code{Object_Size} of a derived base type is copied from the parent
8715 base type, and the @code{Object_Size} of a derived first subtype is copied
8716 from the parent first subtype.
8717 @end itemize
8718
8719 @noindent
8720 The @code{Value_Size} attribute
8721 is the (minimum) number of bits required to store a value
8722 of the type.
8723 This value is used to determine how tightly to pack
8724 records or arrays with components of this type, and also affects
8725 the semantics of unchecked conversion (unchecked conversions where
8726 the @code{Value_Size} values differ generate a warning, and are potentially
8727 target dependent).
8728
8729 The default rules for the value of @code{Value_Size} are as follows:
8730
8731 @itemize @bullet
8732 @item
8733 The @code{Value_Size} for a base subtype is the minimum number of bits
8734 required to store all values of the type (including the sign bit
8735 only if negative values are possible).
8736
8737 @item
8738 If a subtype statically matches the first subtype of a given type, then it has
8739 by default the same @code{Value_Size} as the first subtype.  This is a
8740 consequence of RM 13.1(14) (``if two subtypes statically match,
8741 then their subtype-specific aspects are the same''.)
8742
8743 @item
8744 All other subtypes have a @code{Value_Size} corresponding to the minimum
8745 number of bits required to store all values of the subtype.  For
8746 dynamic bounds, it is assumed that the value can range down or up
8747 to the corresponding bound of the ancestor
8748 @end itemize
8749
8750 @noindent
8751 The RM defined attribute @code{Size} corresponds to the
8752 @code{Value_Size} attribute.
8753
8754 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8755 the @code{Value_Size} of
8756 the first-named subtype to the given value, and the
8757 @code{Object_Size} of this first-named subtype to the given value padded up
8758 to an appropriate boundary.  It is a consequence of the default rules
8759 above that this @code{Object_Size} will apply to all further subtypes.  On the
8760 other hand, @code{Value_Size} is affected only for the first subtype, any
8761 dynamic subtypes obtained from it directly, and any statically matching
8762 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8763
8764 @code{Value_Size} and
8765 @code{Object_Size} may be explicitly set for any subtype using
8766 an attribute definition clause.  Note that the use of these attributes
8767 can cause the RM 13.1(14) rule to be violated.  If two access types
8768 reference aliased objects whose subtypes have differing @code{Object_Size}
8769 values as a result of explicit attribute definition clauses, then it
8770 is erroneous to convert from one access subtype to the other.
8771
8772 At the implementation level, Esize stores the Object_Size and the
8773 RM_Size field stores the @code{Value_Size} (and hence the value of the
8774 @code{Size} attribute,
8775 which, as noted above, is equivalent to @code{Value_Size}).
8776
8777 To get a feel for the difference, consider the following examples (note
8778 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8779
8780 @smallexample
8781                                        Object_Size     Value_Size
8782
8783 type x1 is range 0 .. 5;                    8               3
8784
8785 type x2 is range 0 .. 5;
8786 for x2'size use 12;                        16              12
8787
8788 subtype x3 is x2 range 0 .. 3;             16               2
8789
8790 subtype x4 is x2'base range 0 .. 10;        8               4
8791
8792 subtype x5 is x2 range 0 .. dynamic;       16               3*
8793
8794 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8795
8796 @end smallexample
8797
8798 @noindent
8799 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8800 but it seems in the spirit of the RM rules to allocate the minimum number
8801 of bits (here 3, given the range for @code{x2})
8802 known to be large enough to hold the given range of values.
8803
8804 So far, so good, but GNAT has to obey the RM rules, so the question is
8805 under what conditions must the RM @code{Size} be used.
8806 The following is a list
8807 of the occasions on which the RM @code{Size} must be used:
8808
8809 @itemize @bullet
8810 @item
8811 Component size for packed arrays or records
8812
8813 @item
8814 Value of the attribute @code{Size} for a type
8815
8816 @item
8817 Warning about sizes not matching for unchecked conversion
8818 @end itemize
8819
8820 @noindent
8821 For record types, the @code{Object_Size} is always a multiple of the
8822 alignment of the type (this is true for all types). In some cases the
8823 @code{Value_Size} can be smaller. Consider:
8824
8825 @smallexample
8826    type R is record
8827      X : Integer;
8828      Y : Character;
8829    end record;
8830 @end smallexample
8831
8832 @noindent
8833 On a typical 32-bit architecture, the X component will be four bytes, and
8834 require four-byte alignment, and the Y component will be one byte. In this
8835 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8836 required to store a value of this type, and for example, it is permissible
8837 to have a component of type R in an outer record whose component size is
8838 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8839 since it must be rounded up so that this value is a multiple of the
8840 alignment (4 bytes = 32 bits).
8841
8842 @noindent
8843 For all other types, the @code{Object_Size}
8844 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8845 Only @code{Size} may be specified for such types.
8846
8847 @node Component_Size Clauses
8848 @section Component_Size Clauses
8849 @cindex Component_Size Clause
8850
8851 @noindent
8852 Normally, the value specified in a component clause must be consistent
8853 with the subtype of the array component with regard to size and alignment.
8854 In other words, the value specified must be at least equal to the size
8855 of this subtype, and must be a multiple of the alignment value.
8856
8857 In addition, component size clauses are allowed which cause the array
8858 to be packed, by specifying a smaller value.  The cases in which this
8859 is allowed are for component size values in the range 1 through 63.  The value
8860 specified must not be smaller than the Size of the subtype.  GNAT will
8861 accurately honor all packing requests in this range.  For example, if
8862 we have:
8863
8864 @smallexample @c ada
8865 type r is array (1 .. 8) of Natural;
8866 for r'Component_Size use 31;
8867 @end smallexample
8868
8869 @noindent
8870 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8871 Of course access to the components of such an array is considerably
8872 less efficient than if the natural component size of 32 is used.
8873
8874 @node Bit_Order Clauses
8875 @section Bit_Order Clauses
8876 @cindex Bit_Order Clause
8877 @cindex bit ordering
8878 @cindex ordering, of bits
8879
8880 @noindent
8881 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8882 attribute.  The specification may either correspond to the default bit
8883 order for the target, in which case the specification has no effect and
8884 places no additional restrictions, or it may be for the non-standard
8885 setting (that is the opposite of the default).
8886
8887 In the case where the non-standard value is specified, the effect is
8888 to renumber bits within each byte, but the ordering of bytes is not
8889 affected.  There are certain
8890 restrictions placed on component clauses as follows:
8891
8892 @itemize @bullet
8893
8894 @item Components fitting within a single storage unit.
8895 @noindent
8896 These are unrestricted, and the effect is merely to renumber bits.  For
8897 example if we are on a little-endian machine with @code{Low_Order_First}
8898 being the default, then the following two declarations have exactly
8899 the same effect:
8900
8901 @smallexample @c ada
8902    type R1 is record
8903       A : Boolean;
8904       B : Integer range 1 .. 120;
8905    end record;
8906
8907    for R1 use record
8908       A at 0 range 0 .. 0;
8909       B at 0 range 1 .. 7;
8910    end record;
8911
8912    type R2 is record
8913       A : Boolean;
8914       B : Integer range 1 .. 120;
8915    end record;
8916
8917    for R2'Bit_Order use High_Order_First;
8918
8919    for R2 use record
8920       A at 0 range 7 .. 7;
8921       B at 0 range 0 .. 6;
8922    end record;
8923 @end smallexample
8924
8925 @noindent
8926 The useful application here is to write the second declaration with the
8927 @code{Bit_Order} attribute definition clause, and know that it will be treated
8928 the same, regardless of whether the target is little-endian or big-endian.
8929
8930 @item Components occupying an integral number of bytes.
8931 @noindent
8932 These are components that exactly fit in two or more bytes.  Such component
8933 declarations are allowed, but have no effect, since it is important to realize
8934 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8935 In particular, the following attempt at getting an endian-independent integer
8936 does not work:
8937
8938 @smallexample @c ada
8939    type R2 is record
8940       A : Integer;
8941    end record;
8942
8943    for R2'Bit_Order use High_Order_First;
8944
8945    for R2 use record
8946       A at 0 range 0 .. 31;
8947    end record;
8948 @end smallexample
8949
8950 @noindent
8951 This declaration will result in a little-endian integer on a
8952 little-endian machine, and a big-endian integer on a big-endian machine.
8953 If byte flipping is required for interoperability between big- and
8954 little-endian machines, this must be explicitly programmed.  This capability
8955 is not provided by @code{Bit_Order}.
8956
8957 @item Components that are positioned across byte boundaries
8958 @noindent
8959 but do not occupy an integral number of bytes.  Given that bytes are not
8960 reordered, such fields would occupy a non-contiguous sequence of bits
8961 in memory, requiring non-trivial code to reassemble.  They are for this
8962 reason not permitted, and any component clause specifying such a layout
8963 will be flagged as illegal by GNAT@.
8964
8965 @end itemize
8966
8967 @noindent
8968 Since the misconception that Bit_Order automatically deals with all
8969 endian-related incompatibilities is a common one, the specification of
8970 a component field that is an integral number of bytes will always
8971 generate a warning.  This warning may be suppressed using
8972 @code{pragma Suppress} if desired.  The following section contains additional
8973 details regarding the issue of byte ordering.
8974
8975 @node Effect of Bit_Order on Byte Ordering
8976 @section Effect of Bit_Order on Byte Ordering
8977 @cindex byte ordering
8978 @cindex ordering, of bytes
8979
8980 @noindent
8981 In this section we will review the effect of the @code{Bit_Order} attribute
8982 definition clause on byte ordering.  Briefly, it has no effect at all, but
8983 a detailed example will be helpful.  Before giving this
8984 example, let us review the precise
8985 definition of the effect of defining @code{Bit_Order}.  The effect of a
8986 non-standard bit order is described in section 15.5.3 of the Ada
8987 Reference Manual:
8988
8989 @quotation
8990 2   A bit ordering is a method of interpreting the meaning of
8991 the storage place attributes.
8992 @end quotation
8993
8994 @noindent
8995 To understand the precise definition of storage place attributes in
8996 this context, we visit section 13.5.1 of the manual:
8997
8998 @quotation
8999 13   A record_representation_clause (without the mod_clause)
9000 specifies the layout.  The storage place attributes (see 13.5.2)
9001 are taken from the values of the position, first_bit, and last_bit
9002 expressions after normalizing those values so that first_bit is
9003 less than Storage_Unit.
9004 @end quotation
9005
9006 @noindent
9007 The critical point here is that storage places are taken from
9008 the values after normalization, not before.  So the @code{Bit_Order}
9009 interpretation applies to normalized values.  The interpretation
9010 is described in the later part of the 15.5.3 paragraph:
9011
9012 @quotation
9013 2   A bit ordering is a method of interpreting the meaning of
9014 the storage place attributes.  High_Order_First (known in the
9015 vernacular as ``big endian'') means that the first bit of a
9016 storage element (bit 0) is the most significant bit (interpreting
9017 the sequence of bits that represent a component as an unsigned
9018 integer value).  Low_Order_First (known in the vernacular as
9019 ``little endian'') means the opposite: the first bit is the
9020 least significant.
9021 @end quotation
9022
9023 @noindent
9024 Note that the numbering is with respect to the bits of a storage
9025 unit.  In other words, the specification affects only the numbering
9026 of bits within a single storage unit.
9027
9028 We can make the effect clearer by giving an example.
9029
9030 Suppose that we have an external device which presents two bytes, the first
9031 byte presented, which is the first (low addressed byte) of the two byte
9032 record is called Master, and the second byte is called Slave.
9033
9034 The left most (most significant bit is called Control for each byte, and
9035 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9036 (least significant) bit.
9037
9038 On a big-endian machine, we can write the following representation clause
9039
9040 @smallexample @c ada
9041    type Data is record
9042       Master_Control : Bit;
9043       Master_V1      : Bit;
9044       Master_V2      : Bit;
9045       Master_V3      : Bit;
9046       Master_V4      : Bit;
9047       Master_V5      : Bit;
9048       Master_V6      : Bit;
9049       Master_V7      : Bit;
9050       Slave_Control  : Bit;
9051       Slave_V1       : Bit;
9052       Slave_V2       : Bit;
9053       Slave_V3       : Bit;
9054       Slave_V4       : Bit;
9055       Slave_V5       : Bit;
9056       Slave_V6       : Bit;
9057       Slave_V7       : Bit;
9058    end record;
9059
9060    for Data use record
9061       Master_Control at 0 range 0 .. 0;
9062       Master_V1      at 0 range 1 .. 1;
9063       Master_V2      at 0 range 2 .. 2;
9064       Master_V3      at 0 range 3 .. 3;
9065       Master_V4      at 0 range 4 .. 4;
9066       Master_V5      at 0 range 5 .. 5;
9067       Master_V6      at 0 range 6 .. 6;
9068       Master_V7      at 0 range 7 .. 7;
9069       Slave_Control  at 1 range 0 .. 0;
9070       Slave_V1       at 1 range 1 .. 1;
9071       Slave_V2       at 1 range 2 .. 2;
9072       Slave_V3       at 1 range 3 .. 3;
9073       Slave_V4       at 1 range 4 .. 4;
9074       Slave_V5       at 1 range 5 .. 5;
9075       Slave_V6       at 1 range 6 .. 6;
9076       Slave_V7       at 1 range 7 .. 7;
9077    end record;
9078 @end smallexample
9079
9080 @noindent
9081 Now if we move this to a little endian machine, then the bit ordering within
9082 the byte is backwards, so we have to rewrite the record rep clause as:
9083
9084 @smallexample @c ada
9085    for Data use record
9086       Master_Control at 0 range 7 .. 7;
9087       Master_V1      at 0 range 6 .. 6;
9088       Master_V2      at 0 range 5 .. 5;
9089       Master_V3      at 0 range 4 .. 4;
9090       Master_V4      at 0 range 3 .. 3;
9091       Master_V5      at 0 range 2 .. 2;
9092       Master_V6      at 0 range 1 .. 1;
9093       Master_V7      at 0 range 0 .. 0;
9094       Slave_Control  at 1 range 7 .. 7;
9095       Slave_V1       at 1 range 6 .. 6;
9096       Slave_V2       at 1 range 5 .. 5;
9097       Slave_V3       at 1 range 4 .. 4;
9098       Slave_V4       at 1 range 3 .. 3;
9099       Slave_V5       at 1 range 2 .. 2;
9100       Slave_V6       at 1 range 1 .. 1;
9101       Slave_V7       at 1 range 0 .. 0;
9102    end record;
9103 @end smallexample
9104
9105 @noindent
9106 It is a nuisance to have to rewrite the clause, especially if
9107 the code has to be maintained on both machines.  However,
9108 this is a case that we can handle with the
9109 @code{Bit_Order} attribute if it is implemented.
9110 Note that the implementation is not required on byte addressed
9111 machines, but it is indeed implemented in GNAT.
9112 This means that we can simply use the
9113 first record clause, together with the declaration
9114
9115 @smallexample @c ada
9116    for Data'Bit_Order use High_Order_First;
9117 @end smallexample
9118
9119 @noindent
9120 and the effect is what is desired, namely the layout is exactly the same,
9121 independent of whether the code is compiled on a big-endian or little-endian
9122 machine.
9123
9124 The important point to understand is that byte ordering is not affected.
9125 A @code{Bit_Order} attribute definition never affects which byte a field
9126 ends up in, only where it ends up in that byte.
9127 To make this clear, let us rewrite the record rep clause of the previous
9128 example as:
9129
9130 @smallexample @c ada
9131    for Data'Bit_Order use High_Order_First;
9132    for Data use record
9133       Master_Control at 0 range  0 .. 0;
9134       Master_V1      at 0 range  1 .. 1;
9135       Master_V2      at 0 range  2 .. 2;
9136       Master_V3      at 0 range  3 .. 3;
9137       Master_V4      at 0 range  4 .. 4;
9138       Master_V5      at 0 range  5 .. 5;
9139       Master_V6      at 0 range  6 .. 6;
9140       Master_V7      at 0 range  7 .. 7;
9141       Slave_Control  at 0 range  8 .. 8;
9142       Slave_V1       at 0 range  9 .. 9;
9143       Slave_V2       at 0 range 10 .. 10;
9144       Slave_V3       at 0 range 11 .. 11;
9145       Slave_V4       at 0 range 12 .. 12;
9146       Slave_V5       at 0 range 13 .. 13;
9147       Slave_V6       at 0 range 14 .. 14;
9148       Slave_V7       at 0 range 15 .. 15;
9149    end record;
9150 @end smallexample
9151
9152 @noindent
9153 This is exactly equivalent to saying (a repeat of the first example):
9154
9155 @smallexample @c ada
9156    for Data'Bit_Order use High_Order_First;
9157    for Data use record
9158       Master_Control at 0 range 0 .. 0;
9159       Master_V1      at 0 range 1 .. 1;
9160       Master_V2      at 0 range 2 .. 2;
9161       Master_V3      at 0 range 3 .. 3;
9162       Master_V4      at 0 range 4 .. 4;
9163       Master_V5      at 0 range 5 .. 5;
9164       Master_V6      at 0 range 6 .. 6;
9165       Master_V7      at 0 range 7 .. 7;
9166       Slave_Control  at 1 range 0 .. 0;
9167       Slave_V1       at 1 range 1 .. 1;
9168       Slave_V2       at 1 range 2 .. 2;
9169       Slave_V3       at 1 range 3 .. 3;
9170       Slave_V4       at 1 range 4 .. 4;
9171       Slave_V5       at 1 range 5 .. 5;
9172       Slave_V6       at 1 range 6 .. 6;
9173       Slave_V7       at 1 range 7 .. 7;
9174    end record;
9175 @end smallexample
9176
9177 @noindent
9178 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9179 field.  The storage place attributes are obtained by normalizing the
9180 values given so that the @code{First_Bit} value is less than 8.  After
9181 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9182 we specified in the other case.
9183
9184 Now one might expect that the @code{Bit_Order} attribute might affect
9185 bit numbering within the entire record component (two bytes in this
9186 case, thus affecting which byte fields end up in), but that is not
9187 the way this feature is defined, it only affects numbering of bits,
9188 not which byte they end up in.
9189
9190 Consequently it never makes sense to specify a starting bit number
9191 greater than 7 (for a byte addressable field) if an attribute
9192 definition for @code{Bit_Order} has been given, and indeed it
9193 may be actively confusing to specify such a value, so the compiler
9194 generates a warning for such usage.
9195
9196 If you do need to control byte ordering then appropriate conditional
9197 values must be used.  If in our example, the slave byte came first on
9198 some machines we might write:
9199
9200 @smallexample @c ada
9201    Master_Byte_First constant Boolean := @dots{};
9202
9203    Master_Byte : constant Natural :=
9204                    1 - Boolean'Pos (Master_Byte_First);
9205    Slave_Byte  : constant Natural :=
9206                    Boolean'Pos (Master_Byte_First);
9207
9208    for Data'Bit_Order use High_Order_First;
9209    for Data use record
9210       Master_Control at Master_Byte range 0 .. 0;
9211       Master_V1      at Master_Byte range 1 .. 1;
9212       Master_V2      at Master_Byte range 2 .. 2;
9213       Master_V3      at Master_Byte range 3 .. 3;
9214       Master_V4      at Master_Byte range 4 .. 4;
9215       Master_V5      at Master_Byte range 5 .. 5;
9216       Master_V6      at Master_Byte range 6 .. 6;
9217       Master_V7      at Master_Byte range 7 .. 7;
9218       Slave_Control  at Slave_Byte  range 0 .. 0;
9219       Slave_V1       at Slave_Byte  range 1 .. 1;
9220       Slave_V2       at Slave_Byte  range 2 .. 2;
9221       Slave_V3       at Slave_Byte  range 3 .. 3;
9222       Slave_V4       at Slave_Byte  range 4 .. 4;
9223       Slave_V5       at Slave_Byte  range 5 .. 5;
9224       Slave_V6       at Slave_Byte  range 6 .. 6;
9225       Slave_V7       at Slave_Byte  range 7 .. 7;
9226    end record;
9227 @end smallexample
9228
9229 @noindent
9230 Now to switch between machines, all that is necessary is
9231 to set the boolean constant @code{Master_Byte_First} in
9232 an appropriate manner.
9233
9234 @node Pragma Pack for Arrays
9235 @section Pragma Pack for Arrays
9236 @cindex Pragma Pack (for arrays)
9237
9238 @noindent
9239 Pragma @code{Pack} applied to an array has no effect unless the component type
9240 is packable.  For a component type to be packable, it must be one of the
9241 following cases:
9242
9243 @itemize @bullet
9244 @item
9245 Any scalar type
9246 @item
9247 Any type whose size is specified with a size clause
9248 @item
9249 Any packed array type with a static size
9250 @end itemize
9251
9252 @noindent
9253 For all these cases, if the component subtype size is in the range
9254 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9255 component size were specified giving the component subtype size.
9256 For example if we have:
9257
9258 @smallexample @c ada
9259    type r is range 0 .. 17;
9260
9261    type ar is array (1 .. 8) of r;
9262    pragma Pack (ar);
9263 @end smallexample
9264
9265 @noindent
9266 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9267 and the size of the array @code{ar} will be exactly 40 bits.
9268
9269 Note that in some cases this rather fierce approach to packing can produce
9270 unexpected effects.  For example, in Ada 95, type Natural typically has a
9271 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9272 close packing, which saves a few bits, but results in far less efficient
9273 access.  Since many other Ada compilers will ignore such a packing request,
9274 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9275 might not be what is intended.  You can easily remove this warning by
9276 using an explicit @code{Component_Size} setting instead, which never generates
9277 a warning, since the intention of the programmer is clear in this case.
9278
9279 GNAT treats packed arrays in one of two ways.  If the size of the array is
9280 known at compile time and is less than 64 bits, then internally the array
9281 is represented as a single modular type, of exactly the appropriate number
9282 of bits.  If the length is greater than 63 bits, or is not known at compile
9283 time, then the packed array is represented as an array of bytes, and the
9284 length is always a multiple of 8 bits.
9285
9286 Note that to represent a packed array as a modular type, the alignment must
9287 be suitable for the modular type involved. For example, on typical machines
9288 a 32-bit packed array will be represented by a 32-bit modular integer with
9289 an alignment of four bytes. If you explicitly override the default alignment
9290 with an alignment clause that is too small, the modular representation
9291 cannot be used. For example, consider the following set of declarations:
9292
9293 @smallexample @c ada
9294    type R is range 1 .. 3;
9295    type S is array (1 .. 31) of R;
9296    for S'Component_Size use 2;
9297    for S'Size use 62;
9298    for S'Alignment use 1;
9299 @end smallexample
9300
9301 @noindent
9302 If the alignment clause were not present, then a 62-bit modular
9303 representation would be chosen (typically with an alignment of 4 or 8
9304 bytes depending on the target). But the default alignment is overridden
9305 with the explicit alignment clause. This means that the modular
9306 representation cannot be used, and instead the array of bytes
9307 representation must be used, meaning that the length must be a multiple
9308 of 8. Thus the above set of declarations will result in a diagnostic
9309 rejecting the size clause and noting that the minimum size allowed is 64.
9310
9311 @cindex Pragma Pack (for type Natural)
9312 @cindex Pragma Pack warning
9313
9314 One special case that is worth noting occurs when the base type of the
9315 component size is 8/16/32 and the subtype is one bit less. Notably this
9316 occurs with subtype @code{Natural}. Consider:
9317
9318 @smallexample @c ada
9319    type Arr is array (1 .. 32) of Natural;
9320    pragma Pack (Arr);
9321 @end smallexample
9322
9323 @noindent
9324 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9325 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9326 Ada 83 compilers did not attempt 31 bit packing.
9327
9328 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9329 does pack 31-bit subtype to 31 bits. This may result in a substantial
9330 unintended performance penalty when porting legacy Ada 83 code. To help
9331 prevent this, GNAT generates a warning in such cases. If you really want 31
9332 bit packing in a case like this, you can set the component size explicitly:
9333
9334 @smallexample @c ada
9335    type Arr is array (1 .. 32) of Natural;
9336    for Arr'Component_Size use 31;
9337 @end smallexample
9338
9339 @noindent
9340 Here 31-bit packing is achieved as required, and no warning is generated,
9341 since in this case the programmer intention is clear.
9342
9343 @node Pragma Pack for Records
9344 @section Pragma Pack for Records
9345 @cindex Pragma Pack (for records)
9346
9347 @noindent
9348 Pragma @code{Pack} applied to a record will pack the components to reduce
9349 wasted space from alignment gaps and by reducing the amount of space
9350 taken by components.  We distinguish between @emph{packable} components and
9351 @emph{non-packable} components.
9352 Components of the following types are considered packable:
9353 @itemize @bullet
9354 @item
9355 All primitive types are packable.
9356
9357 @item
9358 Small packed arrays, whose size does not exceed 64 bits, and where the
9359 size is statically known at compile time, are represented internally
9360 as modular integers, and so they are also packable.
9361
9362 @end itemize
9363
9364 @noindent
9365 All packable components occupy the exact number of bits corresponding to
9366 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9367 can start on an arbitrary bit boundary.
9368
9369 All other types are non-packable, they occupy an integral number of
9370 storage units, and
9371 are placed at a boundary corresponding to their alignment requirements.
9372
9373 For example, consider the record
9374
9375 @smallexample @c ada
9376    type Rb1 is array (1 .. 13) of Boolean;
9377    pragma Pack (rb1);
9378
9379    type Rb2 is array (1 .. 65) of Boolean;
9380    pragma Pack (rb2);
9381
9382    type x2 is record
9383       l1 : Boolean;
9384       l2 : Duration;
9385       l3 : Float;
9386       l4 : Boolean;
9387       l5 : Rb1;
9388       l6 : Rb2;
9389    end record;
9390    pragma Pack (x2);
9391 @end smallexample
9392
9393 @noindent
9394 The representation for the record x2 is as follows:
9395
9396 @smallexample @c ada
9397 for x2'Size use 224;
9398 for x2 use record
9399    l1 at  0 range  0 .. 0;
9400    l2 at  0 range  1 .. 64;
9401    l3 at 12 range  0 .. 31;
9402    l4 at 16 range  0 .. 0;
9403    l5 at 16 range  1 .. 13;
9404    l6 at 18 range  0 .. 71;
9405 end record;
9406 @end smallexample
9407
9408 @noindent
9409 Studying this example, we see that the packable fields @code{l1}
9410 and @code{l2} are
9411 of length equal to their sizes, and placed at specific bit boundaries (and
9412 not byte boundaries) to
9413 eliminate padding.  But @code{l3} is of a non-packable float type, so
9414 it is on the next appropriate alignment boundary.
9415
9416 The next two fields are fully packable, so @code{l4} and @code{l5} are
9417 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9418 array that is longer than 64 bits, so it is itself non-packable.  Thus
9419 the @code{l6} field is aligned to the next byte boundary, and takes an
9420 integral number of bytes, i.e.@: 72 bits.
9421
9422 @node Record Representation Clauses
9423 @section Record Representation Clauses
9424 @cindex Record Representation Clause
9425
9426 @noindent
9427 Record representation clauses may be given for all record types, including
9428 types obtained by record extension.  Component clauses are allowed for any
9429 static component.  The restrictions on component clauses depend on the type
9430 of the component.
9431
9432 @cindex Component Clause
9433 For all components of an elementary type, the only restriction on component
9434 clauses is that the size must be at least the 'Size value of the type
9435 (actually the Value_Size).  There are no restrictions due to alignment,
9436 and such components may freely cross storage boundaries.
9437
9438 Packed arrays with a size up to and including 64 bits are represented
9439 internally using a modular type with the appropriate number of bits, and
9440 thus the same lack of restriction applies.  For example, if you declare:
9441
9442 @smallexample @c ada
9443    type R is array (1 .. 49) of Boolean;
9444    pragma Pack (R);
9445    for R'Size use 49;
9446 @end smallexample
9447
9448 @noindent
9449 then a component clause for a component of type R may start on any
9450 specified bit boundary, and may specify a value of 49 bits or greater.
9451
9452 Packed bit arrays that are longer than 64 bits must always be placed
9453 on a storage unit (byte) boundary. Any component clause that does not
9454 meet this requirement will be rejected.
9455
9456 The rules for other types are different for GNAT 3 and GNAT 5 versions
9457 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9458 (other than packed arrays)
9459 may also be placed on arbitrary boundaries, so for example, the following
9460 is permitted:
9461
9462 @smallexample @c ada
9463    type R is array (1 .. 10) of Boolean;
9464    for R'Size use 80;
9465
9466    type Q is record
9467       G, H : Boolean;
9468       L, M : R;
9469    end record;
9470
9471    for Q use record
9472       G at 0 range  0 ..   0;
9473       H at 0 range  1 ..   1;
9474       L at 0 range  2 ..  81;
9475       R at 0 range 82 .. 161;
9476    end record;
9477 @end smallexample
9478
9479 @noindent
9480 In GNAT 3, there are more severe restrictions on larger components.
9481 For non-primitive types, including packed arrays with a size greater than
9482 64 bits, component clauses must respect the alignment requirement of the
9483 type, in particular, always starting on a byte boundary, and the length
9484 must be a multiple of the storage unit.
9485
9486 The following rules regarding tagged types are enforced in both GNAT 3 and
9487 GNAT 5:
9488
9489 The tag field of a tagged type always occupies an address sized field at
9490 the start of the record.  No component clause may attempt to overlay this
9491 tag.
9492
9493 In the case of a record extension T1, of a type T, no component clause applied
9494 to the type T1 can specify a storage location that would overlap the first
9495 T'Size bytes of the record.
9496
9497 @node Enumeration Clauses
9498 @section Enumeration Clauses
9499
9500 The only restriction on enumeration clauses is that the range of values
9501 must be representable.  For the signed case, if one or more of the
9502 representation values are negative, all values must be in the range:
9503
9504 @smallexample @c ada
9505    System.Min_Int .. System.Max_Int
9506 @end smallexample
9507
9508 @noindent
9509 For the unsigned case, where all values are non negative, the values must
9510 be in the range:
9511
9512 @smallexample @c ada
9513    0 .. System.Max_Binary_Modulus;
9514 @end smallexample
9515
9516 @noindent
9517 A @emph{confirming} representation clause is one in which the values range
9518 from 0 in sequence, i.e.@: a clause that confirms the default representation
9519 for an enumeration type.
9520 Such a confirming representation
9521 is permitted by these rules, and is specially recognized by the compiler so
9522 that no extra overhead results from the use of such a clause.
9523
9524 If an array has an index type which is an enumeration type to which an
9525 enumeration clause has been applied, then the array is stored in a compact
9526 manner.  Consider the declarations:
9527
9528 @smallexample @c ada
9529    type r is (A, B, C);
9530    for r use (A => 1, B => 5, C => 10);
9531    type t is array (r) of Character;
9532 @end smallexample
9533
9534 @noindent
9535 The array type t corresponds to a vector with exactly three elements and
9536 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9537 use of space, but means that accesses to elements of the array will incur
9538 the overhead of converting representation values to the corresponding
9539 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9540
9541 @node Address Clauses
9542 @section Address Clauses
9543 @cindex Address Clause
9544
9545 The reference manual allows a general restriction on representation clauses,
9546 as found in RM 13.1(22):
9547
9548 @quotation
9549 An implementation need not support representation
9550 items containing nonstatic expressions, except that
9551 an implementation should support a representation item
9552 for a given entity if each nonstatic expression in the
9553 representation item is a name that statically denotes
9554 a constant declared before the entity.
9555 @end quotation
9556
9557 @noindent
9558 In practice this is applicable only to address clauses, since this is the
9559 only case in which a non-static expression is permitted by the syntax.  As
9560 the AARM notes in sections 13.1 (22.a-22.h):
9561
9562 @display
9563   22.a   Reason: This is to avoid the following sort of thing:
9564
9565   22.b        X : Integer := F(@dots{});
9566               Y : Address := G(@dots{});
9567               for X'Address use Y;
9568
9569   22.c   In the above, we have to evaluate the
9570          initialization expression for X before we
9571          know where to put the result.  This seems
9572          like an unreasonable implementation burden.
9573
9574   22.d   The above code should instead be written
9575          like this:
9576
9577   22.e        Y : constant Address := G(@dots{});
9578               X : Integer := F(@dots{});
9579               for X'Address use Y;
9580
9581   22.f   This allows the expression ``Y'' to be safely
9582          evaluated before X is created.
9583
9584   22.g   The constant could be a formal parameter of mode in.
9585
9586   22.h   An implementation can support other nonstatic
9587          expressions if it wants to.  Expressions of type
9588          Address are hardly ever static, but their value
9589          might be known at compile time anyway in many
9590          cases.
9591 @end display
9592
9593 @noindent
9594 GNAT does indeed permit many additional cases of non-static expressions.  In
9595 particular, if the type involved is elementary there are no restrictions
9596 (since in this case, holding a temporary copy of the initialization value,
9597 if one is present, is inexpensive).  In addition, if there is no implicit or
9598 explicit initialization, then there are no restrictions.  GNAT will reject
9599 only the case where all three of these conditions hold:
9600
9601 @itemize @bullet
9602
9603 @item
9604 The type of the item is non-elementary (e.g.@: a record or array).
9605
9606 @item
9607 There is explicit or implicit initialization required for the object.
9608 Note that access values are always implicitly initialized, and also
9609 in GNAT, certain bit-packed arrays (those having a dynamic length or
9610 a length greater than 64) will also be implicitly initialized to zero.
9611
9612 @item
9613 The address value is non-static.  Here GNAT is more permissive than the
9614 RM, and allows the address value to be the address of a previously declared
9615 stand-alone variable, as long as it does not itself have an address clause.
9616
9617 @smallexample @c ada
9618            Anchor  : Some_Initialized_Type;
9619            Overlay : Some_Initialized_Type;
9620            for Overlay'Address use Anchor'Address;
9621 @end smallexample
9622
9623 @noindent
9624 However, the prefix of the address clause cannot be an array component, or
9625 a component of a discriminated record.
9626
9627 @end itemize
9628
9629 @noindent
9630 As noted above in section 22.h, address values are typically non-static.  In
9631 particular the To_Address function, even if applied to a literal value, is
9632 a non-static function call.  To avoid this minor annoyance, GNAT provides
9633 the implementation defined attribute 'To_Address.  The following two
9634 expressions have identical values:
9635
9636 @findex Attribute
9637 @findex To_Address
9638 @smallexample @c ada
9639    To_Address (16#1234_0000#)
9640    System'To_Address (16#1234_0000#);
9641 @end smallexample
9642
9643 @noindent
9644 except that the second form is considered to be a static expression, and
9645 thus when used as an address clause value is always permitted.
9646
9647 @noindent
9648 Additionally, GNAT treats as static an address clause that is an
9649 unchecked_conversion of a static integer value.  This simplifies the porting
9650 of legacy code, and provides a portable equivalent to the GNAT attribute
9651 @code{To_Address}.
9652
9653 Another issue with address clauses is the interaction with alignment
9654 requirements.  When an address clause is given for an object, the address
9655 value must be consistent with the alignment of the object (which is usually
9656 the same as the alignment of the type of the object).  If an address clause
9657 is given that specifies an inappropriately aligned address value, then the
9658 program execution is erroneous.
9659
9660 Since this source of erroneous behavior can have unfortunate effects, GNAT
9661 checks (at compile time if possible, generating a warning, or at execution
9662 time with a run-time check) that the alignment is appropriate.  If the
9663 run-time check fails, then @code{Program_Error} is raised.  This run-time
9664 check is suppressed if range checks are suppressed, or if
9665 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9666
9667 @findex Export
9668 An address clause cannot be given for an exported object.  More
9669 understandably the real restriction is that objects with an address
9670 clause cannot be exported.  This is because such variables are not
9671 defined by the Ada program, so there is no external object to export.
9672
9673 @findex Import
9674 It is permissible to give an address clause and a pragma Import for the
9675 same object.  In this case, the variable is not really defined by the
9676 Ada program, so there is no external symbol to be linked.  The link name
9677 and the external name are ignored in this case.  The reason that we allow this
9678 combination is that it provides a useful idiom to avoid unwanted
9679 initializations on objects with address clauses.
9680
9681 When an address clause is given for an object that has implicit or
9682 explicit initialization, then by default initialization takes place.  This
9683 means that the effect of the object declaration is to overwrite the
9684 memory at the specified address.  This is almost always not what the
9685 programmer wants, so GNAT will output a warning:
9686
9687 @smallexample
9688   with System;
9689   package G is
9690      type R is record
9691         M : Integer := 0;
9692      end record;
9693
9694      Ext : R;
9695      for Ext'Address use System'To_Address (16#1234_1234#);
9696          |
9697   >>> warning: implicit initialization of "Ext" may
9698       modify overlaid storage
9699   >>> warning: use pragma Import for "Ext" to suppress
9700       initialization (RM B(24))
9701
9702   end G;
9703 @end smallexample
9704
9705 @noindent
9706 As indicated by the warning message, the solution is to use a (dummy) pragma
9707 Import to suppress this initialization.  The pragma tell the compiler that the
9708 object is declared and initialized elsewhere.  The following package compiles
9709 without warnings (and the initialization is suppressed):
9710
9711 @smallexample @c ada
9712    with System;
9713    package G is
9714       type R is record
9715          M : Integer := 0;
9716       end record;
9717
9718       Ext : R;
9719       for Ext'Address use System'To_Address (16#1234_1234#);
9720       pragma Import (Ada, Ext);
9721    end G;
9722 @end smallexample
9723
9724 @noindent
9725 A final issue with address clauses involves their use for overlaying
9726 variables, as in the following example:
9727 @cindex Overlaying of objects
9728
9729 @smallexample @c ada
9730   A : Integer;
9731   B : Integer;
9732   for B'Address use A'Address;
9733 @end smallexample
9734
9735 @noindent
9736 or alternatively, using the form recommended by the RM:
9737
9738 @smallexample @c ada
9739   A    : Integer;
9740   Addr : constant Address := A'Address;
9741   B    : Integer;
9742   for B'Address use Addr;
9743 @end smallexample
9744
9745 @noindent
9746 In both of these cases, @code{A}
9747 and @code{B} become aliased to one another via the
9748 address clause. This use of address clauses to overlay
9749 variables, achieving an effect similar to unchecked
9750 conversion was erroneous in Ada 83, but in Ada 95
9751 the effect is implementation defined. Furthermore, the
9752 Ada 95 RM specifically recommends that in a situation
9753 like this, @code{B} should be subject to the following
9754 implementation advice (RM 13.3(19)):
9755
9756 @quotation
9757 19  If the Address of an object is specified, or it is imported
9758     or exported, then the implementation should not perform
9759     optimizations based on assumptions of no aliases.
9760 @end quotation
9761
9762 @noindent
9763 GNAT follows this recommendation, and goes further by also applying
9764 this recommendation to the overlaid variable (@code{A}
9765 in the above example) in this case. This means that the overlay
9766 works "as expected", in that a modification to one of the variables
9767 will affect the value of the other.
9768
9769 @node Effect of Convention on Representation
9770 @section Effect of Convention on Representation
9771 @cindex Convention, effect on representation
9772
9773 @noindent
9774 Normally the specification of a foreign language convention for a type or
9775 an object has no effect on the chosen representation.  In particular, the
9776 representation chosen for data in GNAT generally meets the standard system
9777 conventions, and for example records are laid out in a manner that is
9778 consistent with C@.  This means that specifying convention C (for example)
9779 has no effect.
9780
9781 There are three exceptions to this general rule:
9782
9783 @itemize @bullet
9784
9785 @item Convention Fortran and array subtypes
9786 If pragma Convention Fortran is specified for an array subtype, then in
9787 accordance with the implementation advice in section 3.6.2(11) of the
9788 Ada Reference Manual, the array will be stored in a Fortran-compatible
9789 column-major manner, instead of the normal default row-major order.
9790
9791 @item Convention C and enumeration types
9792 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9793 to accommodate all values of the type.  For example, for the enumeration
9794 type declared by:
9795
9796 @smallexample @c ada
9797    type Color is (Red, Green, Blue);
9798 @end smallexample
9799
9800 @noindent
9801 8 bits is sufficient to store all values of the type, so by default, objects
9802 of type @code{Color} will be represented using 8 bits.  However, normal C
9803 convention is to use 32 bits for all enum values in C, since enum values
9804 are essentially of type int.  If pragma @code{Convention C} is specified for an
9805 Ada enumeration type, then the size is modified as necessary (usually to
9806 32 bits) to be consistent with the C convention for enum values.
9807
9808 @item Convention C/Fortran and Boolean types
9809 In C, the usual convention for boolean values, that is values used for
9810 conditions, is that zero represents false, and nonzero values represent
9811 true.  In Ada, the normal convention is that two specific values, typically
9812 0/1, are used to represent false/true respectively.
9813
9814 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9815 value represents true).
9816
9817 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9818 C or Fortran convention for a derived Boolean, as in the following example:
9819
9820 @smallexample @c ada
9821    type C_Switch is new Boolean;
9822    pragma Convention (C, C_Switch);
9823 @end smallexample
9824
9825 @noindent
9826 then the GNAT generated code will treat any nonzero value as true.  For truth
9827 values generated by GNAT, the conventional value 1 will be used for True, but
9828 when one of these values is read, any nonzero value is treated as True.
9829
9830 @end itemize
9831
9832 @node Determining the Representations chosen by GNAT
9833 @section Determining the Representations chosen by GNAT
9834 @cindex Representation, determination of
9835 @cindex @code{-gnatR} switch
9836
9837 @noindent
9838 Although the descriptions in this section are intended to be complete, it is
9839 often easier to simply experiment to see what GNAT accepts and what the
9840 effect is on the layout of types and objects.
9841
9842 As required by the Ada RM, if a representation clause is not accepted, then
9843 it must be rejected as illegal by the compiler.  However, when a
9844 representation clause or pragma is accepted, there can still be questions
9845 of what the compiler actually does.  For example, if a partial record
9846 representation clause specifies the location of some components and not
9847 others, then where are the non-specified components placed? Or if pragma
9848 @code{Pack} is used on a record, then exactly where are the resulting
9849 fields placed? The section on pragma @code{Pack} in this chapter can be
9850 used to answer the second question, but it is often easier to just see
9851 what the compiler does.
9852
9853 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9854 with this option, then the compiler will output information on the actual
9855 representations chosen, in a format similar to source representation
9856 clauses.  For example, if we compile the package:
9857
9858 @smallexample @c ada
9859 package q is
9860    type r (x : boolean) is tagged record
9861       case x is
9862          when True => S : String (1 .. 100);
9863          when False => null;
9864       end case;
9865    end record;
9866
9867    type r2 is new r (false) with record
9868       y2 : integer;
9869    end record;
9870
9871    for r2 use record
9872       y2 at 16 range 0 .. 31;
9873    end record;
9874
9875    type x is record
9876       y : character;
9877    end record;
9878
9879    type x1 is array (1 .. 10) of x;
9880    for x1'component_size use 11;
9881
9882    type ia is access integer;
9883
9884    type Rb1 is array (1 .. 13) of Boolean;
9885    pragma Pack (rb1);
9886
9887    type Rb2 is array (1 .. 65) of Boolean;
9888    pragma Pack (rb2);
9889
9890    type x2 is record
9891       l1 : Boolean;
9892       l2 : Duration;
9893       l3 : Float;
9894       l4 : Boolean;
9895       l5 : Rb1;
9896       l6 : Rb2;
9897    end record;
9898    pragma Pack (x2);
9899 end q;
9900 @end smallexample
9901
9902 @noindent
9903 using the switch @code{-gnatR} we obtain the following output:
9904
9905 @smallexample
9906 Representation information for unit q
9907 -------------------------------------
9908
9909 for r'Size use ??;
9910 for r'Alignment use 4;
9911 for r use record
9912    x    at 4 range  0 .. 7;
9913    _tag at 0 range  0 .. 31;
9914    s    at 5 range  0 .. 799;
9915 end record;
9916
9917 for r2'Size use 160;
9918 for r2'Alignment use 4;
9919 for r2 use record
9920    x       at  4 range  0 .. 7;
9921    _tag    at  0 range  0 .. 31;
9922    _parent at  0 range  0 .. 63;
9923    y2      at 16 range  0 .. 31;
9924 end record;
9925
9926 for x'Size use 8;
9927 for x'Alignment use 1;
9928 for x use record
9929    y at 0 range  0 .. 7;
9930 end record;
9931
9932 for x1'Size use 112;
9933 for x1'Alignment use 1;
9934 for x1'Component_Size use 11;
9935
9936 for rb1'Size use 13;
9937 for rb1'Alignment use 2;
9938 for rb1'Component_Size use 1;
9939
9940 for rb2'Size use 72;
9941 for rb2'Alignment use 1;
9942 for rb2'Component_Size use 1;
9943
9944 for x2'Size use 224;
9945 for x2'Alignment use 4;
9946 for x2 use record
9947    l1 at  0 range  0 .. 0;
9948    l2 at  0 range  1 .. 64;
9949    l3 at 12 range  0 .. 31;
9950    l4 at 16 range  0 .. 0;
9951    l5 at 16 range  1 .. 13;
9952    l6 at 18 range  0 .. 71;
9953 end record;
9954 @end smallexample
9955
9956 @noindent
9957 The Size values are actually the Object_Size, i.e.@: the default size that
9958 will be allocated for objects of the type.
9959 The ?? size for type r indicates that we have a variant record, and the
9960 actual size of objects will depend on the discriminant value.
9961
9962 The Alignment values show the actual alignment chosen by the compiler
9963 for each record or array type.
9964
9965 The record representation clause for type r shows where all fields
9966 are placed, including the compiler generated tag field (whose location
9967 cannot be controlled by the programmer).
9968
9969 The record representation clause for the type extension r2 shows all the
9970 fields present, including the parent field, which is a copy of the fields
9971 of the parent type of r2, i.e.@: r1.
9972
9973 The component size and size clauses for types rb1 and rb2 show
9974 the exact effect of pragma @code{Pack} on these arrays, and the record
9975 representation clause for type x2 shows how pragma @code{Pack} affects
9976 this record type.
9977
9978 In some cases, it may be useful to cut and paste the representation clauses
9979 generated by the compiler into the original source to fix and guarantee
9980 the actual representation to be used.
9981
9982 @node Standard Library Routines
9983 @chapter Standard Library Routines
9984
9985 @noindent
9986 The Ada 95 Reference Manual contains in Annex A a full description of an
9987 extensive set of standard library routines that can be used in any Ada
9988 program, and which must be provided by all Ada compilers.  They are
9989 analogous to the standard C library used by C programs.
9990
9991 GNAT implements all of the facilities described in annex A, and for most
9992 purposes the description in the Ada 95
9993 reference manual, or appropriate Ada
9994 text book, will be sufficient for making use of these facilities.
9995
9996 In the case of the input-output facilities, @xref{The Implementation of
9997 Standard I/O}, gives details on exactly how GNAT interfaces to the
9998 file system.  For the remaining packages, the Ada 95 reference manual
9999 should be sufficient.  The following is a list of the packages included,
10000 together with a brief description of the functionality that is provided.
10001
10002 For completeness, references are included to other predefined library
10003 routines defined in other sections of the Ada 95 reference manual (these are
10004 cross-indexed from annex A).
10005
10006 @table @code
10007 @item Ada (A.2)
10008 This is a parent package for all the standard library packages.  It is
10009 usually included implicitly in your program, and itself contains no
10010 useful data or routines.
10011
10012 @item Ada.Calendar (9.6)
10013 @code{Calendar} provides time of day access, and routines for
10014 manipulating times and durations.
10015
10016 @item Ada.Characters (A.3.1)
10017 This is a dummy parent package that contains no useful entities
10018
10019 @item Ada.Characters.Handling (A.3.2)
10020 This package provides some basic character handling capabilities,
10021 including classification functions for classes of characters (e.g.@: test
10022 for letters, or digits).
10023
10024 @item Ada.Characters.Latin_1 (A.3.3)
10025 This package includes a complete set of definitions of the characters
10026 that appear in type CHARACTER@.  It is useful for writing programs that
10027 will run in international environments.  For example, if you want an
10028 upper case E with an acute accent in a string, it is often better to use
10029 the definition of @code{UC_E_Acute} in this package.  Then your program
10030 will print in an understandable manner even if your environment does not
10031 support these extended characters.
10032
10033 @item Ada.Command_Line (A.15)
10034 This package provides access to the command line parameters and the name
10035 of the current program (analogous to the use of @code{argc} and @code{argv}
10036 in C), and also allows the exit status for the program to be set in a
10037 system-independent manner.
10038
10039 @item Ada.Decimal (F.2)
10040 This package provides constants describing the range of decimal numbers
10041 implemented, and also a decimal divide routine (analogous to the COBOL
10042 verb DIVIDE .. GIVING .. REMAINDER ..)
10043
10044 @item Ada.Direct_IO (A.8.4)
10045 This package provides input-output using a model of a set of records of
10046 fixed-length, containing an arbitrary definite Ada type, indexed by an
10047 integer record number.
10048
10049 @item Ada.Dynamic_Priorities (D.5)
10050 This package allows the priorities of a task to be adjusted dynamically
10051 as the task is running.
10052
10053 @item Ada.Exceptions (11.4.1)
10054 This package provides additional information on exceptions, and also
10055 contains facilities for treating exceptions as data objects, and raising
10056 exceptions with associated messages.
10057
10058 @item Ada.Finalization (7.6)
10059 This package contains the declarations and subprograms to support the
10060 use of controlled types, providing for automatic initialization and
10061 finalization (analogous to the constructors and destructors of C++)
10062
10063 @item Ada.Interrupts (C.3.2)
10064 This package provides facilities for interfacing to interrupts, which
10065 includes the set of signals or conditions that can be raised and
10066 recognized as interrupts.
10067
10068 @item Ada.Interrupts.Names (C.3.2)
10069 This package provides the set of interrupt names (actually signal
10070 or condition names) that can be handled by GNAT@.
10071
10072 @item Ada.IO_Exceptions (A.13)
10073 This package defines the set of exceptions that can be raised by use of
10074 the standard IO packages.
10075
10076 @item Ada.Numerics
10077 This package contains some standard constants and exceptions used
10078 throughout the numerics packages.  Note that the constants pi and e are
10079 defined here, and it is better to use these definitions than rolling
10080 your own.
10081
10082 @item Ada.Numerics.Complex_Elementary_Functions
10083 Provides the implementation of standard elementary functions (such as
10084 log and trigonometric functions) operating on complex numbers using the
10085 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10086 created by the package @code{Numerics.Complex_Types}.
10087
10088 @item Ada.Numerics.Complex_Types
10089 This is a predefined instantiation of
10090 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10091 build the type @code{Complex} and @code{Imaginary}.
10092
10093 @item Ada.Numerics.Discrete_Random
10094 This package provides a random number generator suitable for generating
10095 random integer values from a specified range.
10096
10097 @item Ada.Numerics.Float_Random
10098 This package provides a random number generator suitable for generating
10099 uniformly distributed floating point values.
10100
10101 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10102 This is a generic version of the package that provides the
10103 implementation of standard elementary functions (such as log and
10104 trigonometric functions) for an arbitrary complex type.
10105
10106 The following predefined instantiations of this package are provided:
10107
10108 @table @code
10109 @item Short_Float
10110 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10111 @item Float
10112 @code{Ada.Numerics.Complex_Elementary_Functions}
10113 @item Long_Float
10114 @code{Ada.Numerics.
10115  Long_Complex_Elementary_Functions}
10116 @end table
10117
10118 @item Ada.Numerics.Generic_Complex_Types
10119 This is a generic package that allows the creation of complex types,
10120 with associated complex arithmetic operations.
10121
10122 The following predefined instantiations of this package exist
10123 @table @code
10124 @item Short_Float
10125 @code{Ada.Numerics.Short_Complex_Complex_Types}
10126 @item Float
10127 @code{Ada.Numerics.Complex_Complex_Types}
10128 @item Long_Float
10129 @code{Ada.Numerics.Long_Complex_Complex_Types}
10130 @end table
10131
10132 @item Ada.Numerics.Generic_Elementary_Functions
10133 This is a generic package that provides the implementation of standard
10134 elementary functions (such as log an trigonometric functions) for an
10135 arbitrary float type.
10136
10137 The following predefined instantiations of this package exist
10138
10139 @table @code
10140 @item Short_Float
10141 @code{Ada.Numerics.Short_Elementary_Functions}
10142 @item Float
10143 @code{Ada.Numerics.Elementary_Functions}
10144 @item Long_Float
10145 @code{Ada.Numerics.Long_Elementary_Functions}
10146 @end table
10147
10148 @item Ada.Real_Time (D.8)
10149 This package provides facilities similar to those of @code{Calendar}, but
10150 operating with a finer clock suitable for real time control. Note that
10151 annex D requires that there be no backward clock jumps, and GNAT generally
10152 guarantees this behavior, but of course if the external clock on which
10153 the GNAT runtime depends is deliberately reset by some external event,
10154 then such a backward jump may occur.
10155
10156 @item Ada.Sequential_IO (A.8.1)
10157 This package provides input-output facilities for sequential files,
10158 which can contain a sequence of values of a single type, which can be
10159 any Ada type, including indefinite (unconstrained) types.
10160
10161 @item Ada.Storage_IO (A.9)
10162 This package provides a facility for mapping arbitrary Ada types to and
10163 from a storage buffer.  It is primarily intended for the creation of new
10164 IO packages.
10165
10166 @item Ada.Streams (13.13.1)
10167 This is a generic package that provides the basic support for the
10168 concept of streams as used by the stream attributes (@code{Input},
10169 @code{Output}, @code{Read} and @code{Write}).
10170
10171 @item Ada.Streams.Stream_IO (A.12.1)
10172 This package is a specialization of the type @code{Streams} defined in
10173 package @code{Streams} together with a set of operations providing
10174 Stream_IO capability.  The Stream_IO model permits both random and
10175 sequential access to a file which can contain an arbitrary set of values
10176 of one or more Ada types.
10177
10178 @item Ada.Strings (A.4.1)
10179 This package provides some basic constants used by the string handling
10180 packages.
10181
10182 @item Ada.Strings.Bounded (A.4.4)
10183 This package provides facilities for handling variable length
10184 strings.  The bounded model requires a maximum length.  It is thus
10185 somewhat more limited than the unbounded model, but avoids the use of
10186 dynamic allocation or finalization.
10187
10188 @item Ada.Strings.Fixed (A.4.3)
10189 This package provides facilities for handling fixed length strings.
10190
10191 @item Ada.Strings.Maps (A.4.2)
10192 This package provides facilities for handling character mappings and
10193 arbitrarily defined subsets of characters.  For instance it is useful in
10194 defining specialized translation tables.
10195
10196 @item Ada.Strings.Maps.Constants (A.4.6)
10197 This package provides a standard set of predefined mappings and
10198 predefined character sets.  For example, the standard upper to lower case
10199 conversion table is found in this package.  Note that upper to lower case
10200 conversion is non-trivial if you want to take the entire set of
10201 characters, including extended characters like E with an acute accent,
10202 into account.  You should use the mappings in this package (rather than
10203 adding 32 yourself) to do case mappings.
10204
10205 @item Ada.Strings.Unbounded (A.4.5)
10206 This package provides facilities for handling variable length
10207 strings.  The unbounded model allows arbitrary length strings, but
10208 requires the use of dynamic allocation and finalization.
10209
10210 @item Ada.Strings.Wide_Bounded (A.4.7)
10211 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10212 @itemx Ada.Strings.Wide_Maps (A.4.7)
10213 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10214 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10215 These packages provide analogous capabilities to the corresponding
10216 packages without @samp{Wide_} in the name, but operate with the types
10217 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10218 and @code{Character}.
10219
10220 @item Ada.Synchronous_Task_Control (D.10)
10221 This package provides some standard facilities for controlling task
10222 communication in a synchronous manner.
10223
10224 @item Ada.Tags
10225 This package contains definitions for manipulation of the tags of tagged
10226 values.
10227
10228 @item Ada.Task_Attributes
10229 This package provides the capability of associating arbitrary
10230 task-specific data with separate tasks.
10231
10232 @item Ada.Text_IO
10233 This package provides basic text input-output capabilities for
10234 character, string and numeric data.  The subpackages of this
10235 package are listed next.
10236
10237 @item Ada.Text_IO.Decimal_IO
10238 Provides input-output facilities for decimal fixed-point types
10239
10240 @item Ada.Text_IO.Enumeration_IO
10241 Provides input-output facilities for enumeration types.
10242
10243 @item Ada.Text_IO.Fixed_IO
10244 Provides input-output facilities for ordinary fixed-point types.
10245
10246 @item Ada.Text_IO.Float_IO
10247 Provides input-output facilities for float types.  The following
10248 predefined instantiations of this generic package are available:
10249
10250 @table @code
10251 @item Short_Float
10252 @code{Short_Float_Text_IO}
10253 @item Float
10254 @code{Float_Text_IO}
10255 @item Long_Float
10256 @code{Long_Float_Text_IO}
10257 @end table
10258
10259 @item Ada.Text_IO.Integer_IO
10260 Provides input-output facilities for integer types.  The following
10261 predefined instantiations of this generic package are available:
10262
10263 @table @code
10264 @item Short_Short_Integer
10265 @code{Ada.Short_Short_Integer_Text_IO}
10266 @item Short_Integer
10267 @code{Ada.Short_Integer_Text_IO}
10268 @item Integer
10269 @code{Ada.Integer_Text_IO}
10270 @item Long_Integer
10271 @code{Ada.Long_Integer_Text_IO}
10272 @item Long_Long_Integer
10273 @code{Ada.Long_Long_Integer_Text_IO}
10274 @end table
10275
10276 @item Ada.Text_IO.Modular_IO
10277 Provides input-output facilities for modular (unsigned) types
10278
10279 @item Ada.Text_IO.Complex_IO (G.1.3)
10280 This package provides basic text input-output capabilities for complex
10281 data.
10282
10283 @item Ada.Text_IO.Editing (F.3.3)
10284 This package contains routines for edited output, analogous to the use
10285 of pictures in COBOL@.  The picture formats used by this package are a
10286 close copy of the facility in COBOL@.
10287
10288 @item Ada.Text_IO.Text_Streams (A.12.2)
10289 This package provides a facility that allows Text_IO files to be treated
10290 as streams, so that the stream attributes can be used for writing
10291 arbitrary data, including binary data, to Text_IO files.
10292
10293 @item Ada.Unchecked_Conversion (13.9)
10294 This generic package allows arbitrary conversion from one type to
10295 another of the same size, providing for breaking the type safety in
10296 special circumstances.
10297
10298 If the types have the same Size (more accurately the same Value_Size),
10299 then the effect is simply to transfer the bits from the source to the
10300 target type without any modification.  This usage is well defined, and
10301 for simple types whose representation is typically the same across
10302 all implementations, gives a portable method of performing such
10303 conversions.
10304
10305 If the types do not have the same size, then the result is implementation
10306 defined, and thus may be non-portable.  The following describes how GNAT
10307 handles such unchecked conversion cases.
10308
10309 If the types are of different sizes, and are both discrete types, then
10310 the effect is of a normal type conversion without any constraint checking.
10311 In particular if the result type has a larger size, the result will be
10312 zero or sign extended.  If the result type has a smaller size, the result
10313 will be truncated by ignoring high order bits.
10314
10315 If the types are of different sizes, and are not both discrete types,
10316 then the conversion works as though pointers were created to the source
10317 and target, and the pointer value is converted.  The effect is that bits
10318 are copied from successive low order storage units and bits of the source
10319 up to the length of the target type.
10320
10321 A warning is issued if the lengths differ, since the effect in this
10322 case is implementation dependent, and the above behavior may not match
10323 that of some other compiler.
10324
10325 A pointer to one type may be converted to a pointer to another type using
10326 unchecked conversion.  The only case in which the effect is undefined is
10327 when one or both pointers are pointers to unconstrained array types.  In
10328 this case, the bounds information may get incorrectly transferred, and in
10329 particular, GNAT uses double size pointers for such types, and it is
10330 meaningless to convert between such pointer types.  GNAT will issue a
10331 warning if the alignment of the target designated type is more strict
10332 than the alignment of the source designated type (since the result may
10333 be unaligned in this case).
10334
10335 A pointer other than a pointer to an unconstrained array type may be
10336 converted to and from System.Address.  Such usage is common in Ada 83
10337 programs, but note that Ada.Address_To_Access_Conversions is the
10338 preferred method of performing such conversions in Ada 95.  Neither
10339 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10340 used in conjunction with pointers to unconstrained objects, since
10341 the bounds information cannot be handled correctly in this case.
10342
10343 @item Ada.Unchecked_Deallocation (13.11.2)
10344 This generic package allows explicit freeing of storage previously
10345 allocated by use of an allocator.
10346
10347 @item Ada.Wide_Text_IO (A.11)
10348 This package is similar to @code{Ada.Text_IO}, except that the external
10349 file supports wide character representations, and the internal types are
10350 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10351 and @code{String}.  It contains generic subpackages listed next.
10352
10353 @item Ada.Wide_Text_IO.Decimal_IO
10354 Provides input-output facilities for decimal fixed-point types
10355
10356 @item Ada.Wide_Text_IO.Enumeration_IO
10357 Provides input-output facilities for enumeration types.
10358
10359 @item Ada.Wide_Text_IO.Fixed_IO
10360 Provides input-output facilities for ordinary fixed-point types.
10361
10362 @item Ada.Wide_Text_IO.Float_IO
10363 Provides input-output facilities for float types.  The following
10364 predefined instantiations of this generic package are available:
10365
10366 @table @code
10367 @item Short_Float
10368 @code{Short_Float_Wide_Text_IO}
10369 @item Float
10370 @code{Float_Wide_Text_IO}
10371 @item Long_Float
10372 @code{Long_Float_Wide_Text_IO}
10373 @end table
10374
10375 @item Ada.Wide_Text_IO.Integer_IO
10376 Provides input-output facilities for integer types.  The following
10377 predefined instantiations of this generic package are available:
10378
10379 @table @code
10380 @item Short_Short_Integer
10381 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10382 @item Short_Integer
10383 @code{Ada.Short_Integer_Wide_Text_IO}
10384 @item Integer
10385 @code{Ada.Integer_Wide_Text_IO}
10386 @item Long_Integer
10387 @code{Ada.Long_Integer_Wide_Text_IO}
10388 @item Long_Long_Integer
10389 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10390 @end table
10391
10392 @item Ada.Wide_Text_IO.Modular_IO
10393 Provides input-output facilities for modular (unsigned) types
10394
10395 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10396 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10397 external file supports wide character representations.
10398
10399 @item Ada.Wide_Text_IO.Editing (F.3.4)
10400 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10401 types are @code{Wide_Character} and @code{Wide_String} instead of
10402 @code{Character} and @code{String}.
10403
10404 @item Ada.Wide_Text_IO.Streams (A.12.3)
10405 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10406 types are @code{Wide_Character} and @code{Wide_String} instead of
10407 @code{Character} and @code{String}.
10408 @end table
10409
10410 @node The Implementation of Standard I/O
10411 @chapter The Implementation of Standard I/O
10412
10413 @noindent
10414 GNAT implements all the required input-output facilities described in
10415 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10416 required behavior of these packages from the Ada point of view, and if
10417 you are writing a portable Ada program that does not need to know the
10418 exact manner in which Ada maps to the outside world when it comes to
10419 reading or writing external files, then you do not need to read this
10420 chapter.  As long as your files are all regular files (not pipes or
10421 devices), and as long as you write and read the files only from Ada, the
10422 description in the Ada 95 reference manual is sufficient.
10423
10424 However, if you want to do input-output to pipes or other devices, such
10425 as the keyboard or screen, or if the files you are dealing with are
10426 either generated by some other language, or to be read by some other
10427 language, then you need to know more about the details of how the GNAT
10428 implementation of these input-output facilities behaves.
10429
10430 In this chapter we give a detailed description of exactly how GNAT
10431 interfaces to the file system.  As always, the sources of the system are
10432 available to you for answering questions at an even more detailed level,
10433 but for most purposes the information in this chapter will suffice.
10434
10435 Another reason that you may need to know more about how input-output is
10436 implemented arises when you have a program written in mixed languages
10437 where, for example, files are shared between the C and Ada sections of
10438 the same program.  GNAT provides some additional facilities, in the form
10439 of additional child library packages, that facilitate this sharing, and
10440 these additional facilities are also described in this chapter.
10441
10442 @menu
10443 * Standard I/O Packages::
10444 * FORM Strings::
10445 * Direct_IO::
10446 * Sequential_IO::
10447 * Text_IO::
10448 * Wide_Text_IO::
10449 * Stream_IO::
10450 * Shared Files::
10451 * Open Modes::
10452 * Operations on C Streams::
10453 * Interfacing to C Streams::
10454 @end menu
10455
10456 @node Standard I/O Packages
10457 @section Standard I/O Packages
10458
10459 @noindent
10460 The Standard I/O packages described in Annex A for
10461
10462 @itemize @bullet
10463 @item
10464 Ada.Text_IO
10465 @item
10466 Ada.Text_IO.Complex_IO
10467 @item
10468 Ada.Text_IO.Text_Streams,
10469 @item
10470 Ada.Wide_Text_IO
10471 @item
10472 Ada.Wide_Text_IO.Complex_IO,
10473 @item
10474 Ada.Wide_Text_IO.Text_Streams
10475 @item
10476 Ada.Stream_IO
10477 @item
10478 Ada.Sequential_IO
10479 @item
10480 Ada.Direct_IO
10481 @end itemize
10482
10483 @noindent
10484 are implemented using the C
10485 library streams facility; where
10486
10487 @itemize @bullet
10488 @item
10489 All files are opened using @code{fopen}.
10490 @item
10491 All input/output operations use @code{fread}/@code{fwrite}.
10492 @end itemize
10493
10494 @noindent
10495 There is no internal buffering of any kind at the Ada library level.  The
10496 only buffering is that provided at the system level in the
10497 implementation of the C library routines that support streams.  This
10498 facilitates shared use of these streams by mixed language programs.
10499
10500 @node FORM Strings
10501 @section FORM Strings
10502
10503 @noindent
10504 The format of a FORM string in GNAT is:
10505
10506 @smallexample
10507 "keyword=value,keyword=value,@dots{},keyword=value"
10508 @end smallexample
10509
10510 @noindent
10511 where letters may be in upper or lower case, and there are no spaces
10512 between values.  The order of the entries is not important.  Currently
10513 there are two keywords defined.
10514
10515 @smallexample
10516 SHARED=[YES|NO]
10517 WCEM=[n|h|u|s\e]
10518 @end smallexample
10519
10520 @noindent
10521 The use of these parameters is described later in this section.
10522
10523 @node Direct_IO
10524 @section Direct_IO
10525
10526 @noindent
10527 Direct_IO can only be instantiated for definite types.  This is a
10528 restriction of the Ada language, which means that the records are fixed
10529 length (the length being determined by @code{@var{type}'Size}, rounded
10530 up to the next storage unit boundary if necessary).
10531
10532 The records of a Direct_IO file are simply written to the file in index
10533 sequence, with the first record starting at offset zero, and subsequent
10534 records following.  There is no control information of any kind.  For
10535 example, if 32-bit integers are being written, each record takes
10536 4-bytes, so the record at index @var{K} starts at offset
10537 (@var{K}@minus{}1)*4.
10538
10539 There is no limit on the size of Direct_IO files, they are expanded as
10540 necessary to accommodate whatever records are written to the file.
10541
10542 @node Sequential_IO
10543 @section Sequential_IO
10544
10545 @noindent
10546 Sequential_IO may be instantiated with either a definite (constrained)
10547 or indefinite (unconstrained) type.
10548
10549 For the definite type case, the elements written to the file are simply
10550 the memory images of the data values with no control information of any
10551 kind.  The resulting file should be read using the same type, no validity
10552 checking is performed on input.
10553
10554 For the indefinite type case, the elements written consist of two
10555 parts.  First is the size of the data item, written as the memory image
10556 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10557 the data value.  The resulting file can only be read using the same
10558 (unconstrained) type.  Normal assignment checks are performed on these
10559 read operations, and if these checks fail, @code{Data_Error} is
10560 raised.  In particular, in the array case, the lengths must match, and in
10561 the variant record case, if the variable for a particular read operation
10562 is constrained, the discriminants must match.
10563
10564 Note that it is not possible to use Sequential_IO to write variable
10565 length array items, and then read the data back into different length
10566 arrays.  For example, the following will raise @code{Data_Error}:
10567
10568 @smallexample @c ada
10569  package IO is new Sequential_IO (String);
10570  F : IO.File_Type;
10571  S : String (1..4);
10572  @dots{}
10573  IO.Create (F)
10574  IO.Write (F, "hello!")
10575  IO.Reset (F, Mode=>In_File);
10576  IO.Read (F, S);
10577  Put_Line (S);
10578
10579 @end smallexample
10580
10581 @noindent
10582 On some Ada implementations, this will print @code{hell}, but the program is
10583 clearly incorrect, since there is only one element in the file, and that
10584 element is the string @code{hello!}.
10585
10586 In Ada 95, this kind of behavior can be legitimately achieved using
10587 Stream_IO, and this is the preferred mechanism.  In particular, the above
10588 program fragment rewritten to use Stream_IO will work correctly.
10589
10590 @node Text_IO
10591 @section Text_IO
10592
10593 @noindent
10594 Text_IO files consist of a stream of characters containing the following
10595 special control characters:
10596
10597 @smallexample
10598 LF (line feed, 16#0A#) Line Mark
10599 FF (form feed, 16#0C#) Page Mark
10600 @end smallexample
10601
10602 @noindent
10603 A canonical Text_IO file is defined as one in which the following
10604 conditions are met:
10605
10606 @itemize @bullet
10607 @item
10608 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10609 of the line.
10610
10611 @item
10612 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10613 end of a page and consequently can appear only immediately following a
10614 @code{LF} (line mark) character.
10615
10616 @item
10617 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10618 (line mark, page mark).  In the former case, the page mark is implicitly
10619 assumed to be present.
10620 @end itemize
10621
10622 @noindent
10623 A file written using Text_IO will be in canonical form provided that no
10624 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10625 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10626 the file unless an explicit @code{New_Page} operation was performed
10627 before closing the file.
10628
10629 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10630 pipe, can be read using any of the routines in Text_IO@.  The
10631 semantics in this case will be exactly as defined in the Ada 95 reference
10632 manual and all the routines in Text_IO are fully implemented.
10633
10634 A text file that does not meet the requirements for a canonical Text_IO
10635 file has one of the following:
10636
10637 @itemize @bullet
10638 @item
10639 The file contains @code{FF} characters not immediately following a
10640 @code{LF} character.
10641
10642 @item
10643 The file contains @code{LF} or @code{FF} characters written by
10644 @code{Put} or @code{Put_Line}, which are not logically considered to be
10645 line marks or page marks.
10646
10647 @item
10648 The file ends in a character other than @code{LF} or @code{FF},
10649 i.e.@: there is no explicit line mark or page mark at the end of the file.
10650 @end itemize
10651
10652 @noindent
10653 Text_IO can be used to read such non-standard text files but subprograms
10654 to do with line or page numbers do not have defined meanings.  In
10655 particular, a @code{FF} character that does not follow a @code{LF}
10656 character may or may not be treated as a page mark from the point of
10657 view of page and line numbering.  Every @code{LF} character is considered
10658 to end a line, and there is an implied @code{LF} character at the end of
10659 the file.
10660
10661 @menu
10662 * Text_IO Stream Pointer Positioning::
10663 * Text_IO Reading and Writing Non-Regular Files::
10664 * Get_Immediate::
10665 * Treating Text_IO Files as Streams::
10666 * Text_IO Extensions::
10667 * Text_IO Facilities for Unbounded Strings::
10668 @end menu
10669
10670 @node Text_IO Stream Pointer Positioning
10671 @subsection Stream Pointer Positioning
10672
10673 @noindent
10674 @code{Ada.Text_IO} has a definition of current position for a file that
10675 is being read.  No internal buffering occurs in Text_IO, and usually the
10676 physical position in the stream used to implement the file corresponds
10677 to this logical position defined by Text_IO@.  There are two exceptions:
10678
10679 @itemize @bullet
10680 @item
10681 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10682 is positioned past the @code{LF} (line mark) that precedes the page
10683 mark.  Text_IO maintains an internal flag so that subsequent read
10684 operations properly handle the logical position which is unchanged by
10685 the @code{End_Of_Page} call.
10686
10687 @item
10688 After a call to @code{End_Of_File} that returns @code{True}, if the
10689 Text_IO file was positioned before the line mark at the end of file
10690 before the call, then the logical position is unchanged, but the stream
10691 is physically positioned right at the end of file (past the line mark,
10692 and past a possible page mark following the line mark.  Again Text_IO
10693 maintains internal flags so that subsequent read operations properly
10694 handle the logical position.
10695 @end itemize
10696
10697 @noindent
10698 These discrepancies have no effect on the observable behavior of
10699 Text_IO, but if a single Ada stream is shared between a C program and
10700 Ada program, or shared (using @samp{shared=yes} in the form string)
10701 between two Ada files, then the difference may be observable in some
10702 situations.
10703
10704 @node Text_IO Reading and Writing Non-Regular Files
10705 @subsection Reading and Writing Non-Regular Files
10706
10707 @noindent
10708 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10709 can be used for reading and writing.  Writing is not affected and the
10710 sequence of characters output is identical to the normal file case, but
10711 for reading, the behavior of Text_IO is modified to avoid undesirable
10712 look-ahead as follows:
10713
10714 An input file that is not a regular file is considered to have no page
10715 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10716 page mark) appearing in the file are considered to be data
10717 characters.  In particular:
10718
10719 @itemize @bullet
10720 @item
10721 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10722 following a line mark.  If a page mark appears, it will be treated as a
10723 data character.
10724
10725 @item
10726 This avoids the need to wait for an extra character to be typed or
10727 entered from the pipe to complete one of these operations.
10728
10729 @item
10730 @code{End_Of_Page} always returns @code{False}
10731
10732 @item
10733 @code{End_Of_File} will return @code{False} if there is a page mark at
10734 the end of the file.
10735 @end itemize
10736
10737 @noindent
10738 Output to non-regular files is the same as for regular files.  Page marks
10739 may be written to non-regular files using @code{New_Page}, but as noted
10740 above they will not be treated as page marks on input if the output is
10741 piped to another Ada program.
10742
10743 Another important discrepancy when reading non-regular files is that the end
10744 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10745 pressing the @key{EOT} key,
10746 then end of file
10747 is signaled once (i.e.@: the test @code{End_Of_File}
10748 will yield @code{True}, or a read will
10749 raise @code{End_Error}), but then reading can resume
10750 to read data past that end of
10751 file indication, until another end of file indication is entered.
10752
10753 @node Get_Immediate
10754 @subsection Get_Immediate
10755 @cindex Get_Immediate
10756
10757 @noindent
10758 Get_Immediate returns the next character (including control characters)
10759 from the input file.  In particular, Get_Immediate will return LF or FF
10760 characters used as line marks or page marks.  Such operations leave the
10761 file positioned past the control character, and it is thus not treated
10762 as having its normal function.  This means that page, line and column
10763 counts after this kind of Get_Immediate call are set as though the mark
10764 did not occur.  In the case where a Get_Immediate leaves the file
10765 positioned between the line mark and page mark (which is not normally
10766 possible), it is undefined whether the FF character will be treated as a
10767 page mark.
10768
10769 @node Treating Text_IO Files as Streams
10770 @subsection Treating Text_IO Files as Streams
10771 @cindex Stream files
10772
10773 @noindent
10774 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10775 as a stream.  Data written to a Text_IO file in this stream mode is
10776 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10777 16#0C# (@code{FF}), the resulting file may have non-standard
10778 format.  Similarly if read operations are used to read from a Text_IO
10779 file treated as a stream, then @code{LF} and @code{FF} characters may be
10780 skipped and the effect is similar to that described above for
10781 @code{Get_Immediate}.
10782
10783 @node Text_IO Extensions
10784 @subsection Text_IO Extensions
10785 @cindex Text_IO extensions
10786
10787 @noindent
10788 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10789 to the standard @code{Text_IO} package:
10790
10791 @itemize @bullet
10792 @item function File_Exists (Name : String) return Boolean;
10793 Determines if a file of the given name exists.
10794
10795 @item function Get_Line return String;
10796 Reads a string from the standard input file.  The value returned is exactly
10797 the length of the line that was read.
10798
10799 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10800 Similar, except that the parameter File specifies the file from which
10801 the string is to be read.
10802
10803 @end itemize
10804
10805 @node Text_IO Facilities for Unbounded Strings
10806 @subsection Text_IO Facilities for Unbounded Strings
10807 @cindex Text_IO for unbounded strings
10808 @cindex Unbounded_String, Text_IO operations
10809
10810 @noindent
10811 The package @code{Ada.Strings.Unbounded.Text_IO}
10812 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10813 subprograms useful for Text_IO operations on unbounded strings:
10814
10815 @itemize @bullet
10816
10817 @item function Get_Line (File : File_Type) return Unbounded_String;
10818 Reads a line from the specified file
10819 and returns the result as an unbounded string.
10820
10821 @item procedure Put (File : File_Type; U : Unbounded_String);
10822 Writes the value of the given unbounded string to the specified file
10823 Similar to the effect of
10824 @code{Put (To_String (U))} except that an extra copy is avoided.
10825
10826 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10827 Writes the value of the given unbounded string to the specified file,
10828 followed by a @code{New_Line}.
10829 Similar to the effect of @code{Put_Line (To_String (U))} except
10830 that an extra copy is avoided.
10831 @end itemize
10832
10833 @noindent
10834 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10835 and is optional.  If the parameter is omitted, then the standard input or
10836 output file is referenced as appropriate.
10837
10838 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10839 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10840 @code{Wide_Text_IO} functionality for unbounded wide strings.
10841
10842 @node Wide_Text_IO
10843 @section Wide_Text_IO
10844
10845 @noindent
10846 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10847 both input and output files may contain special sequences that represent
10848 wide character values.  The encoding scheme for a given file may be
10849 specified using a FORM parameter:
10850
10851 @smallexample
10852 WCEM=@var{x}
10853 @end smallexample
10854
10855 @noindent
10856 as part of the FORM string (WCEM = wide character encoding method),
10857 where @var{x} is one of the following characters
10858
10859 @table @samp
10860 @item h
10861 Hex ESC encoding
10862 @item u
10863 Upper half encoding
10864 @item s
10865 Shift-JIS encoding
10866 @item e
10867 EUC Encoding
10868 @item 8
10869 UTF-8 encoding
10870 @item b
10871 Brackets encoding
10872 @end table
10873
10874 @noindent
10875 The encoding methods match those that
10876 can be used in a source
10877 program, but there is no requirement that the encoding method used for
10878 the source program be the same as the encoding method used for files,
10879 and different files may use different encoding methods.
10880
10881 The default encoding method for the standard files, and for opened files
10882 for which no WCEM parameter is given in the FORM string matches the
10883 wide character encoding specified for the main program (the default
10884 being brackets encoding if no coding method was specified with -gnatW).
10885
10886 @table @asis
10887 @item Hex Coding
10888 In this encoding, a wide character is represented by a five character
10889 sequence:
10890
10891 @smallexample
10892 ESC a b c d
10893 @end smallexample
10894
10895 @noindent
10896 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10897 characters (using upper case letters) of the wide character code.  For
10898 example, ESC A345 is used to represent the wide character with code
10899 16#A345#.  This scheme is compatible with use of the full
10900 @code{Wide_Character} set.
10901
10902 @item Upper Half Coding
10903 The wide character with encoding 16#abcd#, where the upper bit is on
10904 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10905 16#cd#.  The second byte may never be a format control character, but is
10906 not required to be in the upper half.  This method can be also used for
10907 shift-JIS or EUC where the internal coding matches the external coding.
10908
10909 @item Shift JIS Coding
10910 A wide character is represented by a two character sequence 16#ab# and
10911 16#cd#, with the restrictions described for upper half encoding as
10912 described above.  The internal character code is the corresponding JIS
10913 character according to the standard algorithm for Shift-JIS
10914 conversion.  Only characters defined in the JIS code set table can be
10915 used with this encoding method.
10916
10917 @item EUC Coding
10918 A wide character is represented by a two character sequence 16#ab# and
10919 16#cd#, with both characters being in the upper half.  The internal
10920 character code is the corresponding JIS character according to the EUC
10921 encoding algorithm.  Only characters defined in the JIS code set table
10922 can be used with this encoding method.
10923
10924 @item UTF-8 Coding
10925 A wide character is represented using
10926 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10927 10646-1/Am.2.  Depending on the character value, the representation
10928 is a one, two, or three byte sequence:
10929
10930 @smallexample
10931 16#0000#-16#007f#: 2#0xxxxxxx#
10932 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10933 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10934 @end smallexample
10935
10936 @noindent
10937 where the xxx bits correspond to the left-padded bits of the
10938 16-bit character value.  Note that all lower half ASCII characters
10939 are represented as ASCII bytes and all upper half characters and
10940 other wide characters are represented as sequences of upper-half
10941 (The full UTF-8 scheme allows for encoding 31-bit characters as
10942 6-byte sequences, but in this implementation, all UTF-8 sequences
10943 of four or more bytes length will raise a Constraint_Error, as
10944 will all invalid UTF-8 sequences.)
10945
10946 @item Brackets Coding
10947 In this encoding, a wide character is represented by the following eight
10948 character sequence:
10949
10950 @smallexample
10951 [ " a b c d " ]
10952 @end smallexample
10953
10954 @noindent
10955 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
10956 characters (using uppercase letters) of the wide character code.  For
10957 example, @code{["A345"]} is used to represent the wide character with code
10958 @code{16#A345#}.
10959 This scheme is compatible with use of the full Wide_Character set.
10960 On input, brackets coding can also be used for upper half characters,
10961 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
10962 is only used for wide characters with a code greater than @code{16#FF#}.
10963
10964 @end table
10965
10966 @noindent
10967 For the coding schemes other than Hex and Brackets encoding,
10968 not all wide character
10969 values can be represented.  An attempt to output a character that cannot
10970 be represented using the encoding scheme for the file causes
10971 Constraint_Error to be raised.  An invalid wide character sequence on
10972 input also causes Constraint_Error to be raised.
10973
10974 @menu
10975 * Wide_Text_IO Stream Pointer Positioning::
10976 * Wide_Text_IO Reading and Writing Non-Regular Files::
10977 @end menu
10978
10979 @node Wide_Text_IO Stream Pointer Positioning
10980 @subsection Stream Pointer Positioning
10981
10982 @noindent
10983 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
10984 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
10985 case:
10986
10987 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
10988 normal lower ASCII set (i.e.@: a character in the range:
10989
10990 @smallexample @c ada
10991 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
10992 @end smallexample
10993
10994 @noindent
10995 then although the logical position of the file pointer is unchanged by
10996 the @code{Look_Ahead} call, the stream is physically positioned past the
10997 wide character sequence.  Again this is to avoid the need for buffering
10998 or backup, and all @code{Wide_Text_IO} routines check the internal
10999 indication that this situation has occurred so that this is not visible
11000 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11001 can be observed if the wide text file shares a stream with another file.
11002
11003 @node Wide_Text_IO Reading and Writing Non-Regular Files
11004 @subsection Reading and Writing Non-Regular Files
11005
11006 @noindent
11007 As in the case of Text_IO, when a non-regular file is read, it is
11008 assumed that the file contains no page marks (any form characters are
11009 treated as data characters), and @code{End_Of_Page} always returns
11010 @code{False}.  Similarly, the end of file indication is not sticky, so
11011 it is possible to read beyond an end of file.
11012
11013 @node Stream_IO
11014 @section Stream_IO
11015
11016 @noindent
11017 A stream file is a sequence of bytes, where individual elements are
11018 written to the file as described in the Ada 95 reference manual.  The type
11019 @code{Stream_Element} is simply a byte.  There are two ways to read or
11020 write a stream file.
11021
11022 @itemize @bullet
11023 @item
11024 The operations @code{Read} and @code{Write} directly read or write a
11025 sequence of stream elements with no control information.
11026
11027 @item
11028 The stream attributes applied to a stream file transfer data in the
11029 manner described for stream attributes.
11030 @end itemize
11031
11032 @node Shared Files
11033 @section Shared Files
11034
11035 @noindent
11036 Section A.14 of the Ada 95 Reference Manual allows implementations to
11037 provide a wide variety of behavior if an attempt is made to access the
11038 same external file with two or more internal files.
11039
11040 To provide a full range of functionality, while at the same time
11041 minimizing the problems of portability caused by this implementation
11042 dependence, GNAT handles file sharing as follows:
11043
11044 @itemize @bullet
11045 @item
11046 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11047 to open two or more files with the same full name is considered an error
11048 and is not supported.  The exception @code{Use_Error} will be
11049 raised.  Note that a file that is not explicitly closed by the program
11050 remains open until the program terminates.
11051
11052 @item
11053 If the form parameter @samp{shared=no} appears in the form string, the
11054 file can be opened or created with its own separate stream identifier,
11055 regardless of whether other files sharing the same external file are
11056 opened.  The exact effect depends on how the C stream routines handle
11057 multiple accesses to the same external files using separate streams.
11058
11059 @item
11060 If the form parameter @samp{shared=yes} appears in the form string for
11061 each of two or more files opened using the same full name, the same
11062 stream is shared between these files, and the semantics are as described
11063 in Ada 95 Reference Manual, Section A.14.
11064 @end itemize
11065
11066 @noindent
11067 When a program that opens multiple files with the same name is ported
11068 from another Ada compiler to GNAT, the effect will be that
11069 @code{Use_Error} is raised.
11070
11071 The documentation of the original compiler and the documentation of the
11072 program should then be examined to determine if file sharing was
11073 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11074 and @code{Create} calls as required.
11075
11076 When a program is ported from GNAT to some other Ada compiler, no
11077 special attention is required unless the @samp{shared=@var{xxx}} form
11078 parameter is used in the program.  In this case, you must examine the
11079 documentation of the new compiler to see if it supports the required
11080 file sharing semantics, and form strings modified appropriately.  Of
11081 course it may be the case that the program cannot be ported if the
11082 target compiler does not support the required functionality.  The best
11083 approach in writing portable code is to avoid file sharing (and hence
11084 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11085 completely.
11086
11087 One common use of file sharing in Ada 83 is the use of instantiations of
11088 Sequential_IO on the same file with different types, to achieve
11089 heterogeneous input-output.  Although this approach will work in GNAT if
11090 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11091 for this purpose (using the stream attributes)
11092
11093 @node Open Modes
11094 @section Open Modes
11095
11096 @noindent
11097 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11098 using the mode shown in the following table:
11099
11100 @sp 2
11101 @center @code{Open} and @code{Create} Call Modes
11102 @smallexample
11103                                @b{OPEN }           @b{CREATE}
11104 Append_File                    "r+"             "w+"
11105 In_File                        "r"              "w+"
11106 Out_File (Direct_IO)           "r+"             "w"
11107 Out_File (all other cases)     "w"              "w"
11108 Inout_File                     "r+"             "w+"
11109 @end smallexample
11110
11111 @noindent
11112 If text file translation is required, then either @samp{b} or @samp{t}
11113 is added to the mode, depending on the setting of Text.  Text file
11114 translation refers to the mapping of CR/LF sequences in an external file
11115 to LF characters internally.  This mapping only occurs in DOS and
11116 DOS-like systems, and is not relevant to other systems.
11117
11118 A special case occurs with Stream_IO@.  As shown in the above table, the
11119 file is initially opened in @samp{r} or @samp{w} mode for the
11120 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11121 subsequently requires switching from reading to writing or vice-versa,
11122 then the file is reopened in @samp{r+} mode to permit the required operation.
11123
11124 @node Operations on C Streams
11125 @section Operations on C Streams
11126 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11127 access to the C library functions for operations on C streams:
11128
11129 @smallexample @c adanocomment
11130 package Interfaces.C_Streams is
11131   -- Note: the reason we do not use the types that are in
11132   -- Interfaces.C is that we want to avoid dragging in the
11133   -- code in this unit if possible.
11134   subtype chars is System.Address;
11135   -- Pointer to null-terminated array of characters
11136   subtype FILEs is System.Address;
11137   -- Corresponds to the C type FILE*
11138   subtype voids is System.Address;
11139   -- Corresponds to the C type void*
11140   subtype int is Integer;
11141   subtype long is Long_Integer;
11142   -- Note: the above types are subtypes deliberately, and it
11143   -- is part of this spec that the above correspondences are
11144   -- guaranteed.  This means that it is legitimate to, for
11145   -- example, use Integer instead of int.  We provide these
11146   -- synonyms for clarity, but in some cases it may be
11147   -- convenient to use the underlying types (for example to
11148   -- avoid an unnecessary dependency of a spec on the spec
11149   -- of this unit).
11150   type size_t is mod 2 ** Standard'Address_Size;
11151   NULL_Stream : constant FILEs;
11152   -- Value returned (NULL in C) to indicate an
11153   -- fdopen/fopen/tmpfile error
11154   ----------------------------------
11155   -- Constants Defined in stdio.h --
11156   ----------------------------------
11157   EOF : constant int;
11158   -- Used by a number of routines to indicate error or
11159   -- end of file
11160   IOFBF : constant int;
11161   IOLBF : constant int;
11162   IONBF : constant int;
11163   -- Used to indicate buffering mode for setvbuf call
11164   SEEK_CUR : constant int;
11165   SEEK_END : constant int;
11166   SEEK_SET : constant int;
11167   -- Used to indicate origin for fseek call
11168   function stdin return FILEs;
11169   function stdout return FILEs;
11170   function stderr return FILEs;
11171   -- Streams associated with standard files
11172   --------------------------
11173   -- Standard C functions --
11174   --------------------------
11175   -- The functions selected below are ones that are
11176   -- available in DOS, OS/2, UNIX and Xenix (but not
11177   -- necessarily in ANSI C).  These are very thin interfaces
11178   -- which copy exactly the C headers.  For more
11179   -- documentation on these functions, see the Microsoft C
11180   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11181   -- ISBN 1-55615-225-6), which includes useful information
11182   -- on system compatibility.
11183   procedure clearerr (stream : FILEs);
11184   function fclose (stream : FILEs) return int;
11185   function fdopen (handle : int; mode : chars) return FILEs;
11186   function feof (stream : FILEs) return int;
11187   function ferror (stream : FILEs) return int;
11188   function fflush (stream : FILEs) return int;
11189   function fgetc (stream : FILEs) return int;
11190   function fgets (strng : chars; n : int; stream : FILEs)
11191       return chars;
11192   function fileno (stream : FILEs) return int;
11193   function fopen (filename : chars; Mode : chars)
11194       return FILEs;
11195   -- Note: to maintain target independence, use
11196   -- text_translation_required, a boolean variable defined in
11197   -- a-sysdep.c to deal with the target dependent text
11198   -- translation requirement.  If this variable is set,
11199   -- then  b/t should be appended to the standard mode
11200   -- argument to set the text translation mode off or on
11201   -- as required.
11202   function fputc (C : int; stream : FILEs) return int;
11203   function fputs (Strng : chars; Stream : FILEs) return int;
11204   function fread
11205      (buffer : voids;
11206       size : size_t;
11207       count : size_t;
11208       stream : FILEs)
11209       return size_t;
11210   function freopen
11211      (filename : chars;
11212       mode : chars;
11213       stream : FILEs)
11214       return FILEs;
11215   function fseek
11216      (stream : FILEs;
11217       offset : long;
11218       origin : int)
11219       return int;
11220   function ftell (stream : FILEs) return long;
11221   function fwrite
11222      (buffer : voids;
11223       size : size_t;
11224       count : size_t;
11225       stream : FILEs)
11226       return size_t;
11227   function isatty (handle : int) return int;
11228   procedure mktemp (template : chars);
11229   -- The return value (which is just a pointer to template)
11230   -- is discarded
11231   procedure rewind (stream : FILEs);
11232   function rmtmp return int;
11233   function setvbuf
11234      (stream : FILEs;
11235       buffer : chars;
11236       mode : int;
11237       size : size_t)
11238       return int;
11239
11240   function tmpfile return FILEs;
11241   function ungetc (c : int; stream : FILEs) return int;
11242   function unlink (filename : chars) return int;
11243   ---------------------
11244   -- Extra functions --
11245   ---------------------
11246   -- These functions supply slightly thicker bindings than
11247   -- those above.  They are derived from functions in the
11248   -- C Run-Time Library, but may do a bit more work than
11249   -- just directly calling one of the Library functions.
11250   function is_regular_file (handle : int) return int;
11251   -- Tests if given handle is for a regular file (result 1)
11252   -- or for a non-regular file (pipe or device, result 0).
11253   ---------------------------------
11254   -- Control of Text/Binary Mode --
11255   ---------------------------------
11256   -- If text_translation_required is true, then the following
11257   -- functions may be used to dynamically switch a file from
11258   -- binary to text mode or vice versa.  These functions have
11259   -- no effect if text_translation_required is false (i.e.  in
11260   -- normal UNIX mode).  Use fileno to get a stream handle.
11261   procedure set_binary_mode (handle : int);
11262   procedure set_text_mode (handle : int);
11263   ----------------------------
11264   -- Full Path Name support --
11265   ----------------------------
11266   procedure full_name (nam : chars; buffer : chars);
11267   -- Given a NUL terminated string representing a file
11268   -- name, returns in buffer a NUL terminated string
11269   -- representing the full path name for the file name.
11270   -- On systems where it is relevant the   drive is also
11271   -- part of the full path name.  It is the responsibility
11272   -- of the caller to pass an actual parameter for buffer
11273   -- that is big enough for any full path name.  Use
11274   -- max_path_len given below as the size of buffer.
11275   max_path_len : integer;
11276   -- Maximum length of an allowable full path name on the
11277   -- system, including a terminating NUL character.
11278 end Interfaces.C_Streams;
11279 @end smallexample
11280
11281 @node Interfacing to C Streams
11282 @section Interfacing to C Streams
11283
11284 @noindent
11285 The packages in this section permit interfacing Ada files to C Stream
11286 operations.
11287
11288 @smallexample @c ada
11289  with Interfaces.C_Streams;
11290  package Ada.Sequential_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.Sequential_IO.C_Streams;
11299
11300   with Interfaces.C_Streams;
11301   package Ada.Direct_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.Direct_IO.C_Streams;
11310
11311   with Interfaces.C_Streams;
11312   package Ada.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.Text_IO.C_Streams;
11321
11322   with Interfaces.C_Streams;
11323   package Ada.Wide_Text_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.Wide_Text_IO.C_Streams;
11332
11333  with Interfaces.C_Streams;
11334  package Ada.Stream_IO.C_Streams is
11335     function C_Stream (F : File_Type)
11336        return Interfaces.C_Streams.FILEs;
11337     procedure Open
11338       (File : in out File_Type;
11339        Mode : in File_Mode;
11340        C_Stream : in Interfaces.C_Streams.FILEs;
11341        Form : in String := "");
11342  end Ada.Stream_IO.C_Streams;
11343 @end smallexample
11344
11345 @noindent
11346 In each of these five packages, the @code{C_Stream} function obtains the
11347 @code{FILE} pointer from a currently opened Ada file.  It is then
11348 possible to use the @code{Interfaces.C_Streams} package to operate on
11349 this stream, or the stream can be passed to a C program which can
11350 operate on it directly.  Of course the program is responsible for
11351 ensuring that only appropriate sequences of operations are executed.
11352
11353 One particular use of relevance to an Ada program is that the
11354 @code{setvbuf} function can be used to control the buffering of the
11355 stream used by an Ada file.  In the absence of such a call the standard
11356 default buffering is used.
11357
11358 The @code{Open} procedures in these packages open a file giving an
11359 existing C Stream instead of a file name.  Typically this stream is
11360 imported from a C program, allowing an Ada file to operate on an
11361 existing C file.
11362
11363 @node The GNAT Library
11364 @chapter The GNAT Library
11365
11366 @noindent
11367 The GNAT library contains a number of general and special purpose packages.
11368 It represents functionality that the GNAT developers have found useful, and
11369 which is made available to GNAT users.  The packages described here are fully
11370 supported, and upwards compatibility will be maintained in future releases,
11371 so you can use these facilities with the confidence that the same functionality
11372 will be available in future releases.
11373
11374 The chapter here simply gives a brief summary of the facilities available.
11375 The full documentation is found in the spec file for the package.  The full
11376 sources of these library packages, including both spec and body, are provided
11377 with all GNAT releases.  For example, to find out the full specifications of
11378 the SPITBOL pattern matching capability, including a full tutorial and
11379 extensive examples, look in the @file{g-spipat.ads} file in the library.
11380
11381 For each entry here, the package name (as it would appear in a @code{with}
11382 clause) is given, followed by the name of the corresponding spec file in
11383 parentheses.  The packages are children in four hierarchies, @code{Ada},
11384 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11385 GNAT-specific hierarchy.
11386
11387 Note that an application program should only use packages in one of these
11388 four hierarchies if the package is defined in the Ada Reference Manual,
11389 or is listed in this section of the GNAT Programmers Reference Manual.
11390 All other units should be considered internal implementation units and
11391 should not be directly @code{with}'ed by application code.  The use of
11392 a @code{with} statement that references one of these internal implementation
11393 units makes an application potentially dependent on changes in versions
11394 of GNAT, and will generate a warning message.
11395
11396 @menu
11397 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11398 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11399 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11400 * Ada.Command_Line.Remove (a-colire.ads)::
11401 * Ada.Command_Line.Environment (a-colien.ads)::
11402 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11403 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11404 * Ada.Exceptions.Traceback (a-exctra.ads)::
11405 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11406 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11407 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11408 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11409 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11410 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11411 * GNAT.Array_Split (g-arrspl.ads)::
11412 * GNAT.AWK (g-awk.ads)::
11413 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11414 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11415 * GNAT.Bubble_Sort (g-bubsor.ads)::
11416 * GNAT.Bubble_Sort_A (g-busora.ads)::
11417 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11418 * GNAT.Calendar (g-calend.ads)::
11419 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11420 * GNAT.CRC32 (g-crc32.ads)::
11421 * GNAT.Case_Util (g-casuti.ads)::
11422 * GNAT.CGI (g-cgi.ads)::
11423 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11424 * GNAT.CGI.Debug (g-cgideb.ads)::
11425 * GNAT.Command_Line (g-comlin.ads)::
11426 * GNAT.Compiler_Version (g-comver.ads)::
11427 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11428 * GNAT.Current_Exception (g-curexc.ads)::
11429 * GNAT.Debug_Pools (g-debpoo.ads)::
11430 * GNAT.Debug_Utilities (g-debuti.ads)::
11431 * GNAT.Directory_Operations (g-dirope.ads)::
11432 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11433 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11434 * GNAT.Exception_Actions (g-excact.ads)::
11435 * GNAT.Exception_Traces (g-exctra.ads)::
11436 * GNAT.Exceptions (g-except.ads)::
11437 * GNAT.Expect (g-expect.ads)::
11438 * GNAT.Float_Control (g-flocon.ads)::
11439 * GNAT.Heap_Sort (g-heasor.ads)::
11440 * GNAT.Heap_Sort_A (g-hesora.ads)::
11441 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11442 * GNAT.HTable (g-htable.ads)::
11443 * GNAT.IO (g-io.ads)::
11444 * GNAT.IO_Aux (g-io_aux.ads)::
11445 * GNAT.Lock_Files (g-locfil.ads)::
11446 * GNAT.MD5 (g-md5.ads)::
11447 * GNAT.Memory_Dump (g-memdum.ads)::
11448 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11449 * GNAT.OS_Lib (g-os_lib.ads)::
11450 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11451 * GNAT.Regexp (g-regexp.ads)::
11452 * GNAT.Registry (g-regist.ads)::
11453 * GNAT.Regpat (g-regpat.ads)::
11454 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11455 * GNAT.Semaphores (g-semaph.ads)::
11456 * GNAT.Signals (g-signal.ads)::
11457 * GNAT.Sockets (g-socket.ads)::
11458 * GNAT.Source_Info (g-souinf.ads)::
11459 * GNAT.Spell_Checker (g-speche.ads)::
11460 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11461 * GNAT.Spitbol (g-spitbo.ads)::
11462 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11463 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11464 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11465 * GNAT.Strings (g-string.ads)::
11466 * GNAT.String_Split (g-strspl.ads)::
11467 * GNAT.Table (g-table.ads)::
11468 * GNAT.Task_Lock (g-tasloc.ads)::
11469 * GNAT.Threads (g-thread.ads)::
11470 * GNAT.Traceback (g-traceb.ads)::
11471 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11472 * GNAT.Wide_String_Split (g-wistsp.ads)::
11473 * Interfaces.C.Extensions (i-cexten.ads)::
11474 * Interfaces.C.Streams (i-cstrea.ads)::
11475 * Interfaces.CPP (i-cpp.ads)::
11476 * Interfaces.Os2lib (i-os2lib.ads)::
11477 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11478 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11479 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11480 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11481 * Interfaces.VxWorks (i-vxwork.ads)::
11482 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11483 * System.Address_Image (s-addima.ads)::
11484 * System.Assertions (s-assert.ads)::
11485 * System.Memory (s-memory.ads)::
11486 * System.Partition_Interface (s-parint.ads)::
11487 * System.Restrictions (s-restri.ads)::
11488 * System.Rident (s-rident.ads)::
11489 * System.Task_Info (s-tasinf.ads)::
11490 * System.Wch_Cnv (s-wchcnv.ads)::
11491 * System.Wch_Con (s-wchcon.ads)::
11492 @end menu
11493
11494 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11495 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11496 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11497 @cindex Latin_9 constants for Character
11498
11499 @noindent
11500 This child of @code{Ada.Characters}
11501 provides a set of definitions corresponding to those in the
11502 RM-defined package @code{Ada.Characters.Latin_1} but with the
11503 few modifications required for @code{Latin-9}
11504 The provision of such a package
11505 is specifically authorized by the Ada Reference Manual
11506 (RM A.3(27)).
11507
11508 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11509 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11510 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11511 @cindex Latin_1 constants for Wide_Character
11512
11513 @noindent
11514 This child of @code{Ada.Characters}
11515 provides a set of definitions corresponding to those in the
11516 RM-defined package @code{Ada.Characters.Latin_1} but with the
11517 types of the constants being @code{Wide_Character}
11518 instead of @code{Character}.  The provision of such a package
11519 is specifically authorized by the Ada Reference Manual
11520 (RM A.3(27)).
11521
11522 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11523 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11524 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11525 @cindex Latin_9 constants for Wide_Character
11526
11527 @noindent
11528 This child of @code{Ada.Characters}
11529 provides a set of definitions corresponding to those in the
11530 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11531 types of the constants being @code{Wide_Character}
11532 instead of @code{Character}.  The provision of such a package
11533 is specifically authorized by the Ada Reference Manual
11534 (RM A.3(27)).
11535
11536 @node Ada.Command_Line.Remove (a-colire.ads)
11537 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11538 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11539 @cindex Removing command line arguments
11540 @cindex Command line, argument removal
11541
11542 @noindent
11543 This child of @code{Ada.Command_Line}
11544 provides a mechanism for logically removing
11545 arguments from the argument list.  Once removed, an argument is not visible
11546 to further calls on the subprograms in @code{Ada.Command_Line} will not
11547 see the removed argument.
11548
11549 @node Ada.Command_Line.Environment (a-colien.ads)
11550 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11551 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11552 @cindex Environment entries
11553
11554 @noindent
11555 This child of @code{Ada.Command_Line}
11556 provides a mechanism for obtaining environment values on systems
11557 where this concept makes sense.
11558
11559 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11560 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11561 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11562 @cindex C Streams, Interfacing with Direct_IO
11563
11564 @noindent
11565 This package provides subprograms that allow interfacing between
11566 C streams and @code{Direct_IO}.  The stream identifier can be
11567 extracted from a file opened on the Ada side, and an Ada file
11568 can be constructed from a stream opened on the C side.
11569
11570 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11571 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11572 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11573 @cindex Null_Occurrence, testing for
11574
11575 @noindent
11576 This child subprogram provides a way of testing for the null
11577 exception occurrence (@code{Null_Occurrence}) without raising
11578 an exception.
11579
11580 @node Ada.Exceptions.Traceback (a-exctra.ads)
11581 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11582 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11583 @cindex Traceback for Exception Occurrence
11584
11585 @noindent
11586 This child package provides the subprogram (@code{Tracebacks}) to
11587 give a traceback array of addresses based on an exception
11588 occurrence.
11589
11590 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11591 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11592 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11593 @cindex C Streams, Interfacing with Sequential_IO
11594
11595 @noindent
11596 This package provides subprograms that allow interfacing between
11597 C streams and @code{Sequential_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.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11602 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11603 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11604 @cindex C Streams, Interfacing with Stream_IO
11605
11606 @noindent
11607 This package provides subprograms that allow interfacing between
11608 C streams and @code{Stream_IO}.  The stream identifier can be
11609 extracted from a file opened on the Ada side, and an Ada file
11610 can be constructed from a stream opened on the C side.
11611
11612 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11613 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11614 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11615 @cindex @code{Unbounded_String}, IO support
11616 @cindex @code{Text_IO}, extensions for unbounded strings
11617
11618 @noindent
11619 This package provides subprograms for Text_IO for unbounded
11620 strings, avoiding the necessity for an intermediate operation
11621 with ordinary strings.
11622
11623 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11624 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11625 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11626 @cindex @code{Unbounded_Wide_String}, IO support
11627 @cindex @code{Text_IO}, extensions for unbounded wide strings
11628
11629 @noindent
11630 This package provides subprograms for Text_IO for unbounded
11631 wide strings, avoiding the necessity for an intermediate operation
11632 with ordinary wide strings.
11633
11634 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11635 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11636 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11637 @cindex C Streams, Interfacing with @code{Text_IO}
11638
11639 @noindent
11640 This package provides subprograms that allow interfacing between
11641 C streams and @code{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 Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11646 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11647 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11648 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11649
11650 @noindent
11651 This package provides subprograms that allow interfacing between
11652 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11653 extracted from a file opened on the Ada side, and an Ada file
11654 can be constructed from a stream opened on the C side.
11655
11656 @node GNAT.Array_Split (g-arrspl.ads)
11657 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11658 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11659 @cindex Array splitter
11660
11661 @noindent
11662 Useful array-manipulation routines: given a set of separators, split
11663 an array wherever the separators appear, and provide direct access
11664 to the resulting slices.
11665
11666 @node GNAT.AWK (g-awk.ads)
11667 @section @code{GNAT.AWK} (@file{g-awk.ads})
11668 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11669 @cindex Parsing
11670 @cindex AWK
11671
11672 @noindent
11673 Provides AWK-like parsing functions, with an easy interface for parsing one
11674 or more files containing formatted data.  The file is viewed as a database
11675 where each record is a line and a field is a data element in this line.
11676
11677 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11678 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11679 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11680 @cindex Parsing
11681 @cindex Bounded Buffers
11682
11683 @noindent
11684 Provides a concurrent generic bounded buffer abstraction.  Instances are
11685 useful directly or as parts of the implementations of other abstractions,
11686 such as mailboxes.
11687
11688 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11689 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11690 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11691 @cindex Parsing
11692 @cindex Mailboxes
11693
11694 @noindent
11695 Provides a thread-safe asynchronous intertask mailbox communication facility.
11696
11697 @node GNAT.Bubble_Sort (g-bubsor.ads)
11698 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11699 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.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.  Exchange and comparison procedures are provided by passing
11706 access-to-procedure values.
11707
11708 @node GNAT.Bubble_Sort_A (g-busora.ads)
11709 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11710 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11711 @cindex Sorting
11712 @cindex Bubble sort
11713
11714 @noindent
11715 Provides a general implementation of bubble sort usable for sorting arbitrary
11716 data items.  Move and comparison procedures are provided by passing
11717 access-to-procedure values. This is an older version, retained for
11718 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11719
11720 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11721 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11722 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11723 @cindex Sorting
11724 @cindex Bubble sort
11725
11726 @noindent
11727 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11728 are provided as generic parameters, this improves efficiency, especially
11729 if the procedures can be inlined, at the expense of duplicating code for
11730 multiple instantiations.
11731
11732 @node GNAT.Calendar (g-calend.ads)
11733 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11734 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11735 @cindex @code{Calendar}
11736
11737 @noindent
11738 Extends the facilities provided by @code{Ada.Calendar} to include handling
11739 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11740 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11741 C @code{timeval} format.
11742
11743 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11744 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11745 @cindex @code{Calendar}
11746 @cindex Time
11747 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11748
11749 @node GNAT.CRC32 (g-crc32.ads)
11750 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11751 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11752 @cindex CRC32
11753 @cindex Cyclic Redundancy Check
11754
11755 @noindent
11756 This package implements the CRC-32 algorithm.  For a full description
11757 of this algorithm see
11758 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11759 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11760 Aug.@: 1988.  Sarwate, D.V@.
11761
11762 @noindent
11763 Provides an extended capability for formatted output of time values with
11764 full user control over the format.  Modeled on the GNU Date specification.
11765
11766 @node GNAT.Case_Util (g-casuti.ads)
11767 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11768 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11769 @cindex Casing utilities
11770 @cindex Character handling (@code{GNAT.Case_Util})
11771
11772 @noindent
11773 A set of simple routines for handling upper and lower casing of strings
11774 without the overhead of the full casing tables
11775 in @code{Ada.Characters.Handling}.
11776
11777 @node GNAT.CGI (g-cgi.ads)
11778 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11779 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11780 @cindex CGI (Common Gateway Interface)
11781
11782 @noindent
11783 This is a package for interfacing a GNAT program with a Web server via the
11784 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11785 parameters, which are a set of key/value pairs sent by the Web server.  It
11786 builds a table whose index is the key and provides some services to deal
11787 with this table.
11788
11789 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11790 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11791 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11792 @cindex CGI (Common Gateway Interface) cookie support
11793 @cindex Cookie support in CGI
11794
11795 @noindent
11796 This is a package to interface a GNAT program with a Web server via the
11797 Common Gateway Interface (CGI).  It exports services to deal with Web
11798 cookies (piece of information kept in the Web client software).
11799
11800 @node GNAT.CGI.Debug (g-cgideb.ads)
11801 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11802 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11803 @cindex CGI (Common Gateway Interface) debugging
11804
11805 @noindent
11806 This is a package to help debugging CGI (Common Gateway Interface)
11807 programs written in Ada.
11808
11809 @node GNAT.Command_Line (g-comlin.ads)
11810 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11811 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11812 @cindex Command line
11813
11814 @noindent
11815 Provides a high level interface to @code{Ada.Command_Line} facilities,
11816 including the ability to scan for named switches with optional parameters
11817 and expand file names using wild card notations.
11818
11819 @node GNAT.Compiler_Version (g-comver.ads)
11820 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11821 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11822 @cindex Compiler Version
11823 @cindex Version, of compiler
11824
11825 @noindent
11826 Provides a routine for obtaining the version of the compiler used to
11827 compile the program. More accurately this is the version of the binder
11828 used to bind the program (this will normally be the same as the version
11829 of the compiler if a consistent tool set is used to compile all units
11830 of a partition).
11831
11832 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11833 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11834 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11835 @cindex Interrupt
11836
11837 @noindent
11838 Provides a simple interface to handle Ctrl-C keyboard events.
11839
11840 @node GNAT.Current_Exception (g-curexc.ads)
11841 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11842 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11843 @cindex Current exception
11844 @cindex Exception retrieval
11845
11846 @noindent
11847 Provides access to information on the current exception that has been raised
11848 without the need for using the Ada-95 exception choice parameter specification
11849 syntax.  This is particularly useful in simulating typical facilities for
11850 obtaining information about exceptions provided by Ada 83 compilers.
11851
11852 @node GNAT.Debug_Pools (g-debpoo.ads)
11853 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11854 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11855 @cindex Debugging
11856 @cindex Debug pools
11857 @cindex Memory corruption debugging
11858
11859 @noindent
11860 Provide a debugging storage pools that helps tracking memory corruption
11861 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11862 the @cite{GNAT User's Guide}.
11863
11864 @node GNAT.Debug_Utilities (g-debuti.ads)
11865 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11866 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11867 @cindex Debugging
11868
11869 @noindent
11870 Provides a few useful utilities for debugging purposes, including conversion
11871 to and from string images of address values. Supports both C and Ada formats
11872 for hexadecimal literals.
11873
11874 @node GNAT.Directory_Operations (g-dirope.ads)
11875 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11876 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11877 @cindex Directory operations
11878
11879 @noindent
11880 Provides a set of routines for manipulating directories, including changing
11881 the current directory, making new directories, and scanning the files in a
11882 directory.
11883
11884 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11885 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11886 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11887 @cindex Hash tables
11888
11889 @noindent
11890 A generic implementation of hash tables that can be used to hash arbitrary
11891 data.  Provided in two forms, a simple form with built in hash functions,
11892 and a more complex form in which the hash function is supplied.
11893
11894 @noindent
11895 This package provides a facility similar to that of @code{GNAT.HTable},
11896 except that this package declares a type that can be used to define
11897 dynamic instances of the hash table, while an instantiation of
11898 @code{GNAT.HTable} creates a single instance of the hash table.
11899
11900 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11901 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11902 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11903 @cindex Table implementation
11904 @cindex Arrays, extendable
11905
11906 @noindent
11907 A generic package providing a single dimension array abstraction where the
11908 length of the array can be dynamically modified.
11909
11910 @noindent
11911 This package provides a facility similar to that of @code{GNAT.Table},
11912 except that this package declares a type that can be used to define
11913 dynamic instances of the table, while an instantiation of
11914 @code{GNAT.Table} creates a single instance of the table type.
11915
11916 @node GNAT.Exception_Actions (g-excact.ads)
11917 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11918 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11919 @cindex Exception actions
11920
11921 @noindent
11922 Provides callbacks when an exception is raised. Callbacks can be registered
11923 for specific exceptions, or when any exception is raised. This
11924 can be used for instance to force a core dump to ease debugging.
11925
11926 @node GNAT.Exception_Traces (g-exctra.ads)
11927 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11928 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11929 @cindex Exception traces
11930 @cindex Debugging
11931
11932 @noindent
11933 Provides an interface allowing to control automatic output upon exception
11934 occurrences.
11935
11936 @node GNAT.Exceptions (g-except.ads)
11937 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11938 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11939 @cindex Exceptions, Pure
11940 @cindex Pure packages, exceptions
11941
11942 @noindent
11943 Normally it is not possible to raise an exception with
11944 a message from a subprogram in a pure package, since the
11945 necessary types and subprograms are in @code{Ada.Exceptions}
11946 which is not a pure unit. @code{GNAT.Exceptions} provides a
11947 facility for getting around this limitation for a few
11948 predefined exceptions, and for example allow raising
11949 @code{Constraint_Error} with a message from a pure subprogram.
11950
11951 @node GNAT.Expect (g-expect.ads)
11952 @section @code{GNAT.Expect} (@file{g-expect.ads})
11953 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
11954
11955 @noindent
11956 Provides a set of subprograms similar to what is available
11957 with the standard Tcl Expect tool.
11958 It allows you to easily spawn and communicate with an external process.
11959 You can send commands or inputs to the process, and compare the output
11960 with some expected regular expression. Currently @code{GNAT.Expect}
11961 is implemented on all native GNAT ports except for OpenVMS@.
11962 It is not implemented for cross ports, and in particular is not
11963 implemented for VxWorks or LynxOS@.
11964
11965 @node GNAT.Float_Control (g-flocon.ads)
11966 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
11967 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
11968 @cindex Floating-Point Processor
11969
11970 @noindent
11971 Provides an interface for resetting the floating-point processor into the
11972 mode required for correct semantic operation in Ada.  Some third party
11973 library calls may cause this mode to be modified, and the Reset procedure
11974 in this package can be used to reestablish the required mode.
11975
11976 @node GNAT.Heap_Sort (g-heasor.ads)
11977 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11978 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11979 @cindex Sorting
11980
11981 @noindent
11982 Provides a general implementation of heap sort usable for sorting arbitrary
11983 data items. Exchange 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
11987 @node GNAT.Heap_Sort_A (g-hesora.ads)
11988 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11989 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11990 @cindex Sorting
11991
11992 @noindent
11993 Provides a general implementation of heap sort usable for sorting arbitrary
11994 data items. Move and comparison procedures are provided by passing
11995 access-to-procedure values.  The algorithm used is a modified heap sort
11996 that performs approximately N*log(N) comparisons in the worst case.
11997 This differs from @code{GNAT.Heap_Sort} in having a less convenient
11998 interface, but may be slightly more efficient.
11999
12000 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12001 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12002 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12003 @cindex Sorting
12004
12005 @noindent
12006 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12007 are provided as generic parameters, this improves efficiency, especially
12008 if the procedures can be inlined, at the expense of duplicating code for
12009 multiple instantiations.
12010
12011 @node GNAT.HTable (g-htable.ads)
12012 @section @code{GNAT.HTable} (@file{g-htable.ads})
12013 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12014 @cindex Hash tables
12015
12016 @noindent
12017 A generic implementation of hash tables that can be used to hash arbitrary
12018 data.  Provides two approaches, one a simple static approach, and the other
12019 allowing arbitrary dynamic hash tables.
12020
12021 @node GNAT.IO (g-io.ads)
12022 @section @code{GNAT.IO} (@file{g-io.ads})
12023 @cindex @code{GNAT.IO} (@file{g-io.ads})
12024 @cindex Simple I/O
12025 @cindex Input/Output facilities
12026
12027 @noindent
12028 A simple preelaborable input-output package that provides a subset of
12029 simple Text_IO functions for reading characters and strings from
12030 Standard_Input, and writing characters, strings and integers to either
12031 Standard_Output or Standard_Error.
12032
12033 @node GNAT.IO_Aux (g-io_aux.ads)
12034 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12035 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12036 @cindex Text_IO
12037 @cindex Input/Output facilities
12038
12039 Provides some auxiliary functions for use with Text_IO, including a test
12040 for whether a file exists, and functions for reading a line of text.
12041
12042 @node GNAT.Lock_Files (g-locfil.ads)
12043 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12044 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12045 @cindex File locking
12046 @cindex Locking using files
12047
12048 @noindent
12049 Provides a general interface for using files as locks.  Can be used for
12050 providing program level synchronization.
12051
12052 @node GNAT.MD5 (g-md5.ads)
12053 @section @code{GNAT.MD5} (@file{g-md5.ads})
12054 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12055 @cindex Message Digest MD5
12056
12057 @noindent
12058 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12059
12060 @node GNAT.Memory_Dump (g-memdum.ads)
12061 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12062 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12063 @cindex Dump Memory
12064
12065 @noindent
12066 Provides a convenient routine for dumping raw memory to either the
12067 standard output or standard error files. Uses GNAT.IO for actual
12068 output.
12069
12070 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12071 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12072 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12073 @cindex Exception, obtaining most recent
12074
12075 @noindent
12076 Provides access to the most recently raised exception.  Can be used for
12077 various logging purposes, including duplicating functionality of some
12078 Ada 83 implementation dependent extensions.
12079
12080 @node GNAT.OS_Lib (g-os_lib.ads)
12081 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12082 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12083 @cindex Operating System interface
12084 @cindex Spawn capability
12085
12086 @noindent
12087 Provides a range of target independent operating system interface functions,
12088 including time/date management, file operations, subprocess management,
12089 including a portable spawn procedure, and access to environment variables
12090 and error return codes.
12091
12092 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12093 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12094 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12095 @cindex Hash functions
12096
12097 @noindent
12098 Provides a generator of static minimal perfect hash functions. No
12099 collisions occur and each item can be retrieved from the table in one
12100 probe (perfect property). The hash table size corresponds to the exact
12101 size of the key set and no larger (minimal property). The key set has to
12102 be know in advance (static property). The hash functions are also order
12103 preservering. If w2 is inserted after w1 in the generator, their
12104 hashcode are in the same order. These hashing functions are very
12105 convenient for use with realtime applications.
12106
12107 @node GNAT.Regexp (g-regexp.ads)
12108 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12109 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12110 @cindex Regular expressions
12111 @cindex Pattern matching
12112
12113 @noindent
12114 A simple implementation of regular expressions, using a subset of regular
12115 expression syntax copied from familiar Unix style utilities.  This is the
12116 simples of the three pattern matching packages provided, and is particularly
12117 suitable for ``file globbing'' applications.
12118
12119 @node GNAT.Registry (g-regist.ads)
12120 @section @code{GNAT.Registry} (@file{g-regist.ads})
12121 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12122 @cindex Windows Registry
12123
12124 @noindent
12125 This is a high level binding to the Windows registry.  It is possible to
12126 do simple things like reading a key value, creating a new key.  For full
12127 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12128 package provided with the Win32Ada binding
12129
12130 @node GNAT.Regpat (g-regpat.ads)
12131 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12132 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12133 @cindex Regular expressions
12134 @cindex Pattern matching
12135
12136 @noindent
12137 A complete implementation of Unix-style regular expression matching, copied
12138 from the original V7 style regular expression library written in C by
12139 Henry Spencer (and binary compatible with this C library).
12140
12141 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12142 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12143 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12144 @cindex Secondary Stack Info
12145
12146 @noindent
12147 Provide the capability to query the high water mark of the current task's
12148 secondary stack.
12149
12150 @node GNAT.Semaphores (g-semaph.ads)
12151 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12152 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12153 @cindex Semaphores
12154
12155 @noindent
12156 Provides classic counting and binary semaphores using protected types.
12157
12158 @node GNAT.Signals (g-signal.ads)
12159 @section @code{GNAT.Signals} (@file{g-signal.ads})
12160 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12161 @cindex Signals
12162
12163 @noindent
12164 Provides the ability to manipulate the blocked status of signals on supported
12165 targets.
12166
12167 @node GNAT.Sockets (g-socket.ads)
12168 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12169 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12170 @cindex Sockets
12171
12172 @noindent
12173 A high level and portable interface to develop sockets based applications.
12174 This package is based on the sockets thin binding found in
12175 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12176 on all native GNAT ports except for OpenVMS@.  It is not implemented
12177 for the LynxOS@ cross port.
12178
12179 @node GNAT.Source_Info (g-souinf.ads)
12180 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12181 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12182 @cindex Source Information
12183
12184 @noindent
12185 Provides subprograms that give access to source code information known at
12186 compile time, such as the current file name and line number.
12187
12188 @node GNAT.Spell_Checker (g-speche.ads)
12189 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12190 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12191 @cindex Spell checking
12192
12193 @noindent
12194 Provides a function for determining whether one string is a plausible
12195 near misspelling of another string.
12196
12197 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12198 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12199 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12200 @cindex SPITBOL pattern matching
12201 @cindex Pattern matching
12202
12203 @noindent
12204 A complete implementation of SNOBOL4 style pattern matching.  This is the
12205 most elaborate of the pattern matching packages provided.  It fully duplicates
12206 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12207 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12208
12209 @node GNAT.Spitbol (g-spitbo.ads)
12210 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12211 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12212 @cindex SPITBOL interface
12213
12214 @noindent
12215 The top level package of the collection of SPITBOL-style functionality, this
12216 package provides basic SNOBOL4 string manipulation functions, such as
12217 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12218 useful for constructing arbitrary mappings from strings in the style of
12219 the SNOBOL4 TABLE function.
12220
12221 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12222 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12223 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12224 @cindex Sets of strings
12225 @cindex SPITBOL Tables
12226
12227 @noindent
12228 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12229 for type @code{Standard.Boolean}, giving an implementation of sets of
12230 string values.
12231
12232 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12233 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12234 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12235 @cindex Integer maps
12236 @cindex Maps
12237 @cindex SPITBOL Tables
12238
12239 @noindent
12240 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12241 for type @code{Standard.Integer}, giving an implementation of maps
12242 from string to integer values.
12243
12244 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12245 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12246 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12247 @cindex String maps
12248 @cindex Maps
12249 @cindex SPITBOL Tables
12250
12251 @noindent
12252 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12253 a variable length string type, giving an implementation of general
12254 maps from strings to strings.
12255
12256 @node GNAT.Strings (g-string.ads)
12257 @section @code{GNAT.Strings} (@file{g-string.ads})
12258 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12259
12260 @noindent
12261 Common String access types and related subprograms. Basically it
12262 defines a string access and an array of string access types.
12263
12264 @node GNAT.String_Split (g-strspl.ads)
12265 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12266 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12267 @cindex String splitter
12268
12269 @noindent
12270 Useful string-manipulation routines: given a set of separators, split
12271 a string wherever the separators appear, and provide direct access
12272 to the resulting slices. This package is instantiated from
12273 @code{GNAT.Array_Split}.
12274
12275 @node GNAT.Table (g-table.ads)
12276 @section @code{GNAT.Table} (@file{g-table.ads})
12277 @cindex @code{GNAT.Table} (@file{g-table.ads})
12278 @cindex Table implementation
12279 @cindex Arrays, extendable
12280
12281 @noindent
12282 A generic package providing a single dimension array abstraction where the
12283 length of the array can be dynamically modified.
12284
12285 @noindent
12286 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12287 except that this package declares a single instance of the table type,
12288 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12289 used to define dynamic instances of the table.
12290
12291 @node GNAT.Task_Lock (g-tasloc.ads)
12292 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12293 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12294 @cindex Task synchronization
12295 @cindex Task locking
12296 @cindex Locking
12297
12298 @noindent
12299 A very simple facility for locking and unlocking sections of code using a
12300 single global task lock.  Appropriate for use in situations where contention
12301 between tasks is very rarely expected.
12302
12303 @node GNAT.Threads (g-thread.ads)
12304 @section @code{GNAT.Threads} (@file{g-thread.ads})
12305 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12306 @cindex Foreign threads
12307 @cindex Threads, foreign
12308
12309 @noindent
12310 Provides facilities for creating and destroying threads with explicit calls.
12311 These threads are known to the GNAT run-time system.  These subprograms are
12312 exported C-convention procedures intended to be called from foreign code.
12313 By using these primitives rather than directly calling operating systems
12314 routines, compatibility with the Ada tasking runt-time is provided.
12315
12316 @node GNAT.Traceback (g-traceb.ads)
12317 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12318 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12319 @cindex Trace back facilities
12320
12321 @noindent
12322 Provides a facility for obtaining non-symbolic traceback information, useful
12323 in various debugging situations.
12324
12325 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12326 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12327 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12328 @cindex Trace back facilities
12329
12330 @noindent
12331 Provides symbolic traceback information that includes the subprogram
12332 name and line number information.
12333
12334 @node GNAT.Wide_String_Split (g-wistsp.ads)
12335 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12336 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12337 @cindex Wide_String splitter
12338
12339 @noindent
12340 Useful wide_string-manipulation routines: given a set of separators, split
12341 a wide_string wherever the separators appear, and provide direct access
12342 to the resulting slices. This package is instantiated from
12343 @code{GNAT.Array_Split}.
12344
12345 @node Interfaces.C.Extensions (i-cexten.ads)
12346 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12347 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12348
12349 @noindent
12350 This package contains additional C-related definitions, intended
12351 for use with either manually or automatically generated bindings
12352 to C libraries.
12353
12354 @node Interfaces.C.Streams (i-cstrea.ads)
12355 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12356 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12357 @cindex  C streams, interfacing
12358
12359 @noindent
12360 This package is a binding for the most commonly used operations
12361 on C streams.
12362
12363 @node Interfaces.CPP (i-cpp.ads)
12364 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12365 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12366 @cindex  C++ interfacing
12367 @cindex  Interfacing, to C++
12368
12369 @noindent
12370 This package provides facilities for use in interfacing to C++.  It
12371 is primarily intended to be used in connection with automated tools
12372 for the generation of C++ interfaces.
12373
12374 @node Interfaces.Os2lib (i-os2lib.ads)
12375 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12376 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12377 @cindex Interfacing, to OS/2
12378 @cindex OS/2 interfacing
12379
12380 @noindent
12381 This package provides interface definitions to the OS/2 library.
12382 It is a thin binding which is a direct translation of the
12383 various @file{<bse@.h>} files.
12384
12385 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12386 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12387 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12388 @cindex OS/2 Error codes
12389 @cindex Interfacing, to OS/2
12390 @cindex OS/2 interfacing
12391
12392 @noindent
12393 This package provides definitions of the OS/2 error codes.
12394
12395 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12396 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12397 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12398 @cindex Interfacing, to OS/2
12399 @cindex Synchronization, OS/2
12400 @cindex OS/2 synchronization primitives
12401
12402 @noindent
12403 This is a child package that provides definitions for interfacing
12404 to the @code{OS/2} synchronization primitives.
12405
12406 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12407 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12408 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12409 @cindex Interfacing, to OS/2
12410 @cindex Thread control, OS/2
12411 @cindex OS/2 thread interfacing
12412
12413 @noindent
12414 This is a child package that provides definitions for interfacing
12415 to the @code{OS/2} thread primitives.
12416
12417 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12418 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12419 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12420 @cindex  IBM Packed Format
12421 @cindex  Packed Decimal
12422
12423 @noindent
12424 This package provides a set of routines for conversions to and
12425 from a packed decimal format compatible with that used on IBM
12426 mainframes.
12427
12428 @node Interfaces.VxWorks (i-vxwork.ads)
12429 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12430 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12431 @cindex Interfacing to VxWorks
12432 @cindex VxWorks, interfacing
12433
12434 @noindent
12435 This package provides a limited binding to the VxWorks API.
12436 In particular, it interfaces with the
12437 VxWorks hardware interrupt facilities.
12438
12439 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12440 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12441 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12442 @cindex Interfacing to VxWorks' I/O
12443 @cindex VxWorks, I/O interfacing
12444 @cindex VxWorks, Get_Immediate
12445 @cindex Get_Immediate, VxWorks
12446
12447 @noindent
12448 This package provides a binding to the ioctl (IO/Control)
12449 function of VxWorks, defining a set of option values and
12450 function codes. A particular use of this package is
12451 to enable the use of Get_Immediate under VxWorks.
12452
12453 @node System.Address_Image (s-addima.ads)
12454 @section @code{System.Address_Image} (@file{s-addima.ads})
12455 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12456 @cindex Address image
12457 @cindex Image, of an address
12458
12459 @noindent
12460 This function provides a useful debugging
12461 function that gives an (implementation dependent)
12462 string which identifies an address.
12463
12464 @node System.Assertions (s-assert.ads)
12465 @section @code{System.Assertions} (@file{s-assert.ads})
12466 @cindex @code{System.Assertions} (@file{s-assert.ads})
12467 @cindex Assertions
12468 @cindex Assert_Failure, exception
12469
12470 @noindent
12471 This package provides the declaration of the exception raised
12472 by an run-time assertion failure, as well as the routine that
12473 is used internally to raise this assertion.
12474
12475 @node System.Memory (s-memory.ads)
12476 @section @code{System.Memory} (@file{s-memory.ads})
12477 @cindex @code{System.Memory} (@file{s-memory.ads})
12478 @cindex Memory allocation
12479
12480 @noindent
12481 This package provides the interface to the low level routines used
12482 by the generated code for allocation and freeing storage for the
12483 default storage pool (analogous to the C routines malloc and free.
12484 It also provides a reallocation interface analogous to the C routine
12485 realloc. The body of this unit may be modified to provide alternative
12486 allocation mechanisms for the default pool, and in addition, direct
12487 calls to this unit may be made for low level allocation uses (for
12488 example see the body of @code{GNAT.Tables}).
12489
12490 @node System.Partition_Interface (s-parint.ads)
12491 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12492 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12493 @cindex Partition intefacing functions
12494
12495 @noindent
12496 This package provides facilities for partition interfacing.  It
12497 is used primarily in a distribution context when using Annex E
12498 with @code{GLADE}.
12499
12500 @node System.Restrictions (s-restri.ads)
12501 @section @code{System.Restrictions} (@file{s-restri.ads})
12502 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12503 @cindex Run-time restrictions access
12504
12505 @noindent
12506 This package provides facilities for accessing at run-time
12507 the status of restrictions specified at compile time for
12508 the partition. Information is available both with regard
12509 to actual restrictions specified, and with regard to
12510 compiler determined information on which restrictions
12511 are violated by one or more packages in the partition.
12512
12513 @node System.Rident (s-rident.ads)
12514 @section @code{System.Rident} (@file{s-rident.ads})
12515 @cindex @code{System.Rident} (@file{s-rident.ads})
12516 @cindex Restrictions definitions
12517
12518 @noindent
12519 This package provides definitions of the restrictions
12520 identifiers supported by GNAT, and also the format of
12521 the restrictions provided in package System.Restrictions.
12522 It is not normally necessary to @code{with} this generic package
12523 since the necessary instantiation is included in
12524 package System.Restrictions.
12525
12526 @node System.Task_Info (s-tasinf.ads)
12527 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12528 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12529 @cindex Task_Info pragma
12530
12531 @noindent
12532 This package provides target dependent functionality that is used
12533 to support the @code{Task_Info} pragma
12534
12535 @node System.Wch_Cnv (s-wchcnv.ads)
12536 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12537 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12538 @cindex Wide Character, Representation
12539 @cindex Wide String, Conversion
12540 @cindex Representation of wide characters
12541
12542 @noindent
12543 This package provides routines for converting between
12544 wide characters and a representation as a value of type
12545 @code{Standard.String}, using a specified wide character
12546 encoding method.  It uses definitions in
12547 package @code{System.Wch_Con}.
12548
12549 @node System.Wch_Con (s-wchcon.ads)
12550 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12551 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12552
12553 @noindent
12554 This package provides definitions and descriptions of
12555 the various methods used for encoding wide characters
12556 in ordinary strings.  These definitions are used by
12557 the package @code{System.Wch_Cnv}.
12558
12559 @node Interfacing to Other Languages
12560 @chapter Interfacing to Other Languages
12561 @noindent
12562 The facilities in annex B of the Ada 95 Reference Manual are fully
12563 implemented in GNAT, and in addition, a full interface to C++ is
12564 provided.
12565
12566 @menu
12567 * Interfacing to C::
12568 * Interfacing to C++::
12569 * Interfacing to COBOL::
12570 * Interfacing to Fortran::
12571 * Interfacing to non-GNAT Ada code::
12572 @end menu
12573
12574 @node Interfacing to C
12575 @section Interfacing to C
12576
12577 @noindent
12578 Interfacing to C with GNAT can use one of two approaches:
12579
12580 @itemize @bullet
12581 @item
12582 The types in the package @code{Interfaces.C} may be used.
12583 @item
12584 Standard Ada types may be used directly.  This may be less portable to
12585 other compilers, but will work on all GNAT compilers, which guarantee
12586 correspondence between the C and Ada types.
12587 @end itemize
12588
12589 @noindent
12590 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12591 effect, since this is the default.  The following table shows the
12592 correspondence between Ada scalar types and the corresponding C types.
12593
12594 @table @code
12595 @item Integer
12596 @code{int}
12597 @item Short_Integer
12598 @code{short}
12599 @item Short_Short_Integer
12600 @code{signed char}
12601 @item Long_Integer
12602 @code{long}
12603 @item Long_Long_Integer
12604 @code{long long}
12605 @item Short_Float
12606 @code{float}
12607 @item Float
12608 @code{float}
12609 @item Long_Float
12610 @code{double}
12611 @item Long_Long_Float
12612 This is the longest floating-point type supported by the hardware.
12613 @end table
12614
12615 @noindent
12616 Additionally, there are the following general correspondences between Ada
12617 and C types:
12618 @itemize @bullet
12619 @item
12620 Ada enumeration types map to C enumeration types directly if pragma
12621 @code{Convention C} is specified, which causes them to have int
12622 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12623 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12624 @code{int}, respectively) depending on the number of values passed.
12625 This is the only case in which pragma @code{Convention C} affects the
12626 representation of an Ada type.
12627
12628 @item
12629 Ada access types map to C pointers, except for the case of pointers to
12630 unconstrained types in Ada, which have no direct C equivalent.
12631
12632 @item
12633 Ada arrays map directly to C arrays.
12634
12635 @item
12636 Ada records map directly to C structures.
12637
12638 @item
12639 Packed Ada records map to C structures where all members are bit fields
12640 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12641 @end itemize
12642
12643 @node Interfacing to C++
12644 @section Interfacing to C++
12645
12646 @noindent
12647 The interface to C++ makes use of the following pragmas, which are
12648 primarily intended to be constructed automatically using a binding generator
12649 tool, although it is possible to construct them by hand.  No suitable binding
12650 generator tool is supplied with GNAT though.
12651
12652 Using these pragmas it is possible to achieve complete
12653 inter-operability between Ada tagged types and C class definitions.
12654 See @ref{Implementation Defined Pragmas}, for more details.
12655
12656 @table @code
12657 @item pragma CPP_Class ([Entity =>] @var{local_name})
12658 The argument denotes an entity in the current declarative region that is
12659 declared as a tagged or untagged record type.  It indicates that the type
12660 corresponds to an externally declared C++ class type, and is to be laid
12661 out the same way that C++ would lay out the type.
12662
12663 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12664 This pragma identifies an imported function (imported in the usual way
12665 with pragma @code{Import}) as corresponding to a C++ constructor.
12666
12667 @item pragma CPP_Vtable @dots{}
12668 One @code{CPP_Vtable} pragma can be present for each component of type
12669 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12670 applies.
12671 @end table
12672
12673 @node Interfacing to COBOL
12674 @section Interfacing to COBOL
12675
12676 @noindent
12677 Interfacing to COBOL is achieved as described in section B.4 of
12678 the Ada 95 reference manual.
12679
12680 @node Interfacing to Fortran
12681 @section Interfacing to Fortran
12682
12683 @noindent
12684 Interfacing to Fortran is achieved as described in section B.5 of the
12685 reference manual.  The pragma @code{Convention Fortran}, applied to a
12686 multi-dimensional array causes the array to be stored in column-major
12687 order as required for convenient interface to Fortran.
12688
12689 @node Interfacing to non-GNAT Ada code
12690 @section Interfacing to non-GNAT Ada code
12691
12692 It is possible to specify the convention @code{Ada} in a pragma
12693 @code{Import} or pragma @code{Export}.  However this refers to
12694 the calling conventions used by GNAT, which may or may not be
12695 similar enough to those used by some other Ada 83 or Ada 95
12696 compiler to allow interoperation.
12697
12698 If arguments types are kept simple, and if the foreign compiler generally
12699 follows system calling conventions, then it may be possible to integrate
12700 files compiled by other Ada compilers, provided that the elaboration
12701 issues are adequately addressed (for example by eliminating the
12702 need for any load time elaboration).
12703
12704 In particular, GNAT running on VMS is designed to
12705 be highly compatible with the DEC Ada 83 compiler, so this is one
12706 case in which it is possible to import foreign units of this type,
12707 provided that the data items passed are restricted to simple scalar
12708 values or simple record types without variants, or simple array
12709 types with fixed bounds.
12710
12711 @node Specialized Needs Annexes
12712 @chapter Specialized Needs Annexes
12713
12714 @noindent
12715 Ada 95 defines a number of specialized needs annexes, which are not
12716 required in all implementations.  However, as described in this chapter,
12717 GNAT implements all of these special needs annexes:
12718
12719 @table @asis
12720 @item Systems Programming (Annex C)
12721 The Systems Programming Annex is fully implemented.
12722
12723 @item Real-Time Systems (Annex D)
12724 The Real-Time Systems Annex is fully implemented.
12725
12726 @item Distributed Systems (Annex E)
12727 Stub generation is fully implemented in the GNAT compiler.  In addition,
12728 a complete compatible PCS is available as part of the GLADE system,
12729 a separate product.  When the two
12730 products are used in conjunction, this annex is fully implemented.
12731
12732 @item Information Systems (Annex F)
12733 The Information Systems annex is fully implemented.
12734
12735 @item Numerics (Annex G)
12736 The Numerics Annex is fully implemented.
12737
12738 @item Safety and Security (Annex H)
12739 The Safety and Security annex is fully implemented.
12740 @end table
12741
12742 @node Implementation of Specific Ada Features
12743 @chapter Implementation of Specific Ada Features
12744
12745 @noindent
12746 This chapter describes the GNAT implementation of several Ada language
12747 facilities.
12748
12749 @menu
12750 * Machine Code Insertions::
12751 * GNAT Implementation of Tasking::
12752 * GNAT Implementation of Shared Passive Packages::
12753 * Code Generation for Array Aggregates::
12754 @end menu
12755
12756 @node Machine Code Insertions
12757 @section Machine Code Insertions
12758
12759 @noindent
12760 Package @code{Machine_Code} provides machine code support as described
12761 in the Ada 95 Reference Manual in two separate forms:
12762 @itemize @bullet
12763 @item
12764 Machine code statements, consisting of qualified expressions that
12765 fit the requirements of RM section 13.8.
12766 @item
12767 An intrinsic callable procedure, providing an alternative mechanism of
12768 including machine instructions in a subprogram.
12769 @end itemize
12770
12771 @noindent
12772 The two features are similar, and both are closely related to the mechanism
12773 provided by the asm instruction in the GNU C compiler.  Full understanding
12774 and use of the facilities in this package requires understanding the asm
12775 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12776 by Richard Stallman. The relevant section is titled ``Extensions to the C
12777 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12778
12779 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12780 semantic restrictions and effects as described below.  Both are provided so
12781 that the procedure call can be used as a statement, and the function call
12782 can be used to form a code_statement.
12783
12784 The first example given in the GCC documentation is the C @code{asm}
12785 instruction:
12786 @smallexample
12787    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12788 @end smallexample
12789
12790 @noindent
12791 The equivalent can be written for GNAT as:
12792
12793 @smallexample @c ada
12794 Asm ("fsinx %1 %0",
12795      My_Float'Asm_Output ("=f", result),
12796      My_Float'Asm_Input  ("f",  angle));
12797 @end smallexample
12798
12799 @noindent
12800 The first argument to @code{Asm} is the assembler template, and is
12801 identical to what is used in GNU C@.  This string must be a static
12802 expression.  The second argument is the output operand list.  It is
12803 either a single @code{Asm_Output} attribute reference, or a list of such
12804 references enclosed in parentheses (technically an array aggregate of
12805 such references).
12806
12807 The @code{Asm_Output} attribute denotes a function that takes two
12808 parameters.  The first is a string, the second is the name of a variable
12809 of the type designated by the attribute prefix.  The first (string)
12810 argument is required to be a static expression and designates the
12811 constraint for the parameter (e.g.@: what kind of register is
12812 required).  The second argument is the variable to be updated with the
12813 result.  The possible values for constraint are the same as those used in
12814 the RTL, and are dependent on the configuration file used to build the
12815 GCC back end.  If there are no output operands, then this argument may
12816 either be omitted, or explicitly given as @code{No_Output_Operands}.
12817
12818 The second argument of @code{@var{my_float}'Asm_Output} functions as
12819 though it were an @code{out} parameter, which is a little curious, but
12820 all names have the form of expressions, so there is no syntactic
12821 irregularity, even though normally functions would not be permitted
12822 @code{out} parameters.  The third argument is the list of input
12823 operands.  It is either a single @code{Asm_Input} attribute reference, or
12824 a list of such references enclosed in parentheses (technically an array
12825 aggregate of such references).
12826
12827 The @code{Asm_Input} attribute denotes a function that takes two
12828 parameters.  The first is a string, the second is an expression of the
12829 type designated by the prefix.  The first (string) argument is required
12830 to be a static expression, and is the constraint for the parameter,
12831 (e.g.@: what kind of register is required).  The second argument is the
12832 value to be used as the input argument.  The possible values for the
12833 constant are the same as those used in the RTL, and are dependent on
12834 the configuration file used to built the GCC back end.
12835
12836 If there are no input operands, this argument may either be omitted, or
12837 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12838 present in the above example, is a list of register names, called the
12839 @dfn{clobber} argument.  This argument, if given, must be a static string
12840 expression, and is a space or comma separated list of names of registers
12841 that must be considered destroyed as a result of the @code{Asm} call.  If
12842 this argument is the null string (the default value), then the code
12843 generator assumes that no additional registers are destroyed.
12844
12845 The fifth argument, not present in the above example, called the
12846 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12847 the literal value @code{True} to indicate to the code generator that all
12848 optimizations with respect to the instruction specified should be
12849 suppressed, and that in particular, for an instruction that has outputs,
12850 the instruction will still be generated, even if none of the outputs are
12851 used.  See the full description in the GCC manual for further details.
12852
12853 The @code{Asm} subprograms may be used in two ways.  First the procedure
12854 forms can be used anywhere a procedure call would be valid, and
12855 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12856 be used to intersperse machine instructions with other Ada statements.
12857 Second, the function forms, which return a dummy value of the limited
12858 private type @code{Asm_Insn}, can be used in code statements, and indeed
12859 this is the only context where such calls are allowed.  Code statements
12860 appear as aggregates of the form:
12861
12862 @smallexample @c ada
12863 Asm_Insn'(Asm (@dots{}));
12864 Asm_Insn'(Asm_Volatile (@dots{}));
12865 @end smallexample
12866
12867 @noindent
12868 In accordance with RM rules, such code statements are allowed only
12869 within subprograms whose entire body consists of such statements.  It is
12870 not permissible to intermix such statements with other Ada statements.
12871
12872 Typically the form using intrinsic procedure calls is more convenient
12873 and more flexible.  The code statement form is provided to meet the RM
12874 suggestion that such a facility should be made available.  The following
12875 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12876 is used, the arguments may be given in arbitrary order, following the
12877 normal rules for use of positional and named arguments)
12878
12879 @smallexample
12880 ASM_CALL ::= Asm (
12881                  [Template =>] static_string_EXPRESSION
12882                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12883                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12884                [,[Clobber  =>] static_string_EXPRESSION ]
12885                [,[Volatile =>] static_boolean_EXPRESSION] )
12886
12887 OUTPUT_OPERAND_LIST ::=
12888   [PREFIX.]No_Output_Operands
12889 | OUTPUT_OPERAND_ATTRIBUTE
12890 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12891
12892 OUTPUT_OPERAND_ATTRIBUTE ::=
12893   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12894
12895 INPUT_OPERAND_LIST ::=
12896   [PREFIX.]No_Input_Operands
12897 | INPUT_OPERAND_ATTRIBUTE
12898 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12899
12900 INPUT_OPERAND_ATTRIBUTE ::=
12901   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12902 @end smallexample
12903
12904 @noindent
12905 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12906 are declared in the package @code{Machine_Code} and must be referenced
12907 according to normal visibility rules. In particular if there is no
12908 @code{use} clause for this package, then appropriate package name
12909 qualification is required.
12910
12911 @node GNAT Implementation of Tasking
12912 @section GNAT Implementation of Tasking
12913
12914 @noindent
12915 This chapter outlines the basic GNAT approach to tasking (in particular,
12916 a multi-layered library for portability) and discusses issues related
12917 to compliance with the Real-Time Systems Annex.
12918
12919 @menu
12920 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12921 * Ensuring Compliance with the Real-Time Annex::
12922 @end menu
12923
12924 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12925 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12926
12927 @noindent
12928 GNAT's run-time support comprises two layers:
12929
12930 @itemize @bullet
12931 @item GNARL (GNAT Run-time Layer)
12932 @item GNULL (GNAT Low-level Library)
12933 @end itemize
12934
12935 @noindent
12936 In GNAT, Ada's tasking services rely on a platform and OS independent
12937 layer known as GNARL@.  This code is responsible for implementing the
12938 correct semantics of Ada's task creation, rendezvous, protected
12939 operations etc.
12940
12941 GNARL decomposes Ada's tasking semantics into simpler lower level
12942 operations such as create a thread, set the priority of a thread,
12943 yield, create a lock, lock/unlock, etc.  The spec for these low-level
12944 operations constitutes GNULLI, the GNULL Interface.  This interface is
12945 directly inspired from the POSIX real-time API@.
12946
12947 If the underlying executive or OS implements the POSIX standard
12948 faithfully, the GNULL Interface maps as is to the services offered by
12949 the underlying kernel.  Otherwise, some target dependent glue code maps
12950 the services offered by the underlying kernel to the semantics expected
12951 by GNARL@.
12952
12953 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
12954 key point is that each Ada task is mapped on a thread in the underlying
12955 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
12956
12957 In addition Ada task priorities map onto the underlying thread priorities.
12958 Mapping Ada tasks onto the underlying kernel threads has several advantages:
12959
12960 @itemize @bullet
12961 @item
12962 The underlying scheduler is used to schedule the Ada tasks.  This
12963 makes Ada tasks as efficient as kernel threads from a scheduling
12964 standpoint.
12965
12966 @item
12967 Interaction with code written in C containing threads is eased
12968 since at the lowest level Ada tasks and C threads map onto the same
12969 underlying kernel concept.
12970
12971 @item
12972 When an Ada task is blocked during I/O the remaining Ada tasks are
12973 able to proceed.
12974
12975 @item
12976 On multiprocessor systems Ada tasks can execute in parallel.
12977 @end itemize
12978
12979 @noindent
12980 Some threads libraries offer a mechanism to fork a new process, with the
12981 child process duplicating the threads from the parent.
12982 GNAT does not
12983 support this functionality when the parent contains more than one task.
12984 @cindex Forking a new process
12985
12986 @node Ensuring Compliance with the Real-Time Annex
12987 @subsection Ensuring Compliance with the Real-Time Annex
12988 @cindex Real-Time Systems Annex compliance
12989
12990 @noindent
12991 Although mapping Ada tasks onto
12992 the underlying threads has significant advantages, it does create some
12993 complications when it comes to respecting the scheduling semantics
12994 specified in the real-time annex (Annex D).
12995
12996 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
12997 scheduling policy states:
12998
12999 @quotation
13000 @emph{When the active priority of a ready task that is not running
13001 changes, or the setting of its base priority takes effect, the
13002 task is removed from the ready queue for its old active priority
13003 and is added at the tail of the ready queue for its new active
13004 priority, except in the case where the active priority is lowered
13005 due to the loss of inherited priority, in which case the task is
13006 added at the head of the ready queue for its new active priority.}
13007 @end quotation
13008
13009 @noindent
13010 While most kernels do put tasks at the end of the priority queue when
13011 a task changes its priority, (which respects the main
13012 FIFO_Within_Priorities requirement), almost none keep a thread at the
13013 beginning of its priority queue when its priority drops from the loss
13014 of inherited priority.
13015
13016 As a result most vendors have provided incomplete Annex D implementations.
13017
13018 The GNAT run-time, has a nice cooperative solution to this problem
13019 which ensures that accurate FIFO_Within_Priorities semantics are
13020 respected.
13021
13022 The principle is as follows.  When an Ada task T is about to start
13023 running, it checks whether some other Ada task R with the same
13024 priority as T has been suspended due to the loss of priority
13025 inheritance.  If this is the case, T yields and is placed at the end of
13026 its priority queue.  When R arrives at the front of the queue it
13027 executes.
13028
13029 Note that this simple scheme preserves the relative order of the tasks
13030 that were ready to execute in the priority queue where R has been
13031 placed at the end.
13032
13033 @node GNAT Implementation of Shared Passive Packages
13034 @section GNAT Implementation of Shared Passive Packages
13035 @cindex Shared passive packages
13036
13037 @noindent
13038 GNAT fully implements the pragma @code{Shared_Passive} for
13039 @cindex pragma @code{Shared_Passive}
13040 the purpose of designating shared passive packages.
13041 This allows the use of passive partitions in the
13042 context described in the Ada Reference Manual; i.e. for communication
13043 between separate partitions of a distributed application using the
13044 features in Annex E.
13045 @cindex Annex E
13046 @cindex Distribution Systems Annex
13047
13048 However, the implementation approach used by GNAT provides for more
13049 extensive usage as follows:
13050
13051 @table @emph
13052 @item Communication between separate programs
13053
13054 This allows separate programs to access the data in passive
13055 partitions, using protected objects for synchronization where
13056 needed. The only requirement is that the two programs have a
13057 common shared file system. It is even possible for programs
13058 running on different machines with different architectures
13059 (e.g. different endianness) to communicate via the data in
13060 a passive partition.
13061
13062 @item Persistence between program runs
13063
13064 The data in a passive package can persist from one run of a
13065 program to another, so that a later program sees the final
13066 values stored by a previous run of the same program.
13067
13068 @end table
13069
13070 @noindent
13071 The implementation approach used is to store the data in files. A
13072 separate stream file is created for each object in the package, and
13073 an access to an object causes the corresponding file to be read or
13074 written.
13075
13076 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13077 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13078 set to the directory to be used for these files.
13079 The files in this directory
13080 have names that correspond to their fully qualified names. For
13081 example, if we have the package
13082
13083 @smallexample @c ada
13084 package X is
13085   pragma Shared_Passive (X);
13086   Y : Integer;
13087   Z : Float;
13088 end X;
13089 @end smallexample
13090
13091 @noindent
13092 and the environment variable is set to @code{/stemp/}, then the files created
13093 will have the names:
13094
13095 @smallexample
13096 /stemp/x.y
13097 /stemp/x.z
13098 @end smallexample
13099
13100 @noindent
13101 These files are created when a value is initially written to the object, and
13102 the files are retained until manually deleted. This provides the persistence
13103 semantics. If no file exists, it means that no partition has assigned a value
13104 to the variable; in this case the initial value declared in the package
13105 will be used. This model ensures that there are no issues in synchronizing
13106 the elaboration process, since elaboration of passive packages elaborates the
13107 initial values, but does not create the files.
13108
13109 The files are written using normal @code{Stream_IO} access.
13110 If you want to be able
13111 to communicate between programs or partitions running on different
13112 architectures, then you should use the XDR versions of the stream attribute
13113 routines, since these are architecture independent.
13114
13115 If active synchronization is required for access to the variables in the
13116 shared passive package, then as described in the Ada Reference Manual, the
13117 package may contain protected objects used for this purpose. In this case
13118 a lock file (whose name is @file{___lock} (three underscores)
13119 is created in the shared memory directory.
13120 @cindex @file{___lock} file (for shared passive packages)
13121 This is used to provide the required locking
13122 semantics for proper protected object synchronization.
13123
13124 As of January 2003, GNAT supports shared passive packages on all platforms
13125 except for OpenVMS.
13126
13127 @node Code Generation for Array Aggregates
13128 @section Code Generation for Array Aggregates
13129
13130 @menu
13131 * Static constant aggregates with static bounds::
13132 * Constant aggregates with an unconstrained nominal types::
13133 * Aggregates with static bounds::
13134 * Aggregates with non-static bounds::
13135 * Aggregates in assignment statements::
13136 @end menu
13137
13138 @noindent
13139 Aggregate have a rich syntax and allow the user to specify the values of
13140 complex data structures by means of a single construct.  As a result, the
13141 code generated for aggregates can be quite complex and involve loops, case
13142 statements and multiple assignments.  In the simplest cases, however, the
13143 compiler will recognize aggregates whose components and constraints are
13144 fully static, and in those cases the compiler will generate little or no
13145 executable code.  The following is an outline of the code that GNAT generates
13146 for various aggregate constructs.  For further details, the user will find it
13147 useful to examine the output produced by the -gnatG flag to see the expanded
13148 source that is input to the code generator.  The user will also want to examine
13149 the assembly code generated at various levels of optimization.
13150
13151 The code generated for aggregates depends on the context, the component values,
13152 and the type.  In the context of an object declaration the code generated is
13153 generally simpler than in the case of an assignment.  As a general rule, static
13154 component values and static subtypes also lead to simpler code.
13155
13156 @node Static constant aggregates with static bounds
13157 @subsection Static constant aggregates with static bounds
13158
13159 @noindent
13160 For the declarations:
13161 @smallexample @c ada
13162     type One_Dim is array (1..10) of integer;
13163     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13164 @end smallexample
13165
13166 @noindent
13167 GNAT generates no executable code: the constant ar0 is placed in static memory.
13168 The same is true for constant aggregates with named associations:
13169
13170 @smallexample @c ada
13171     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13172     Cr3 : constant One_Dim := (others => 7777);
13173 @end smallexample
13174
13175 @noindent
13176 The same is true for multidimensional constant arrays such as:
13177
13178 @smallexample @c ada
13179     type two_dim is array (1..3, 1..3) of integer;
13180     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13181 @end smallexample
13182
13183 @noindent
13184 The same is true for arrays of one-dimensional arrays: the following are
13185 static:
13186
13187 @smallexample @c ada
13188 type ar1b  is array (1..3) of boolean;
13189 type ar_ar is array (1..3) of ar1b;
13190 None  : constant ar1b := (others => false);     --  fully static
13191 None2 : constant ar_ar := (1..3 => None);       --  fully static
13192 @end smallexample
13193
13194 @noindent
13195 However, for multidimensional aggregates with named associations, GNAT will
13196 generate assignments and loops, even if all associations are static.  The
13197 following two declarations generate a loop for the first dimension, and
13198 individual component assignments for the second dimension:
13199
13200 @smallexample @c ada
13201 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13202 Zero2: constant two_dim := (others => (others => 0));
13203 @end smallexample
13204
13205 @node Constant aggregates with an unconstrained nominal types
13206 @subsection Constant aggregates with an unconstrained nominal types
13207
13208 @noindent
13209 In such cases the aggregate itself establishes the subtype, so that
13210 associations with @code{others} cannot be used.  GNAT determines the
13211 bounds for the actual subtype of the aggregate, and allocates the
13212 aggregate statically as well.  No code is generated for the following:
13213
13214 @smallexample @c ada
13215     type One_Unc is array (natural range <>) of integer;
13216     Cr_Unc : constant One_Unc := (12,24,36);
13217 @end smallexample
13218
13219 @node Aggregates with static bounds
13220 @subsection Aggregates with static bounds
13221
13222 @noindent
13223 In all previous examples the aggregate was the initial (and immutable) value
13224 of a constant.  If the aggregate initializes a variable, then code is generated
13225 for it as a combination of individual assignments and loops over the target
13226 object.  The declarations
13227
13228 @smallexample @c ada
13229        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13230        Cr_Var2 : One_Dim := (others > -1);
13231 @end smallexample
13232
13233 @noindent
13234 generate the equivalent of
13235
13236 @smallexample @c ada
13237        Cr_Var1 (1) := 2;
13238        Cr_Var1 (2) := 3;
13239        Cr_Var1 (3) := 5;
13240        Cr_Var1 (4) := 11;
13241
13242        for I in Cr_Var2'range loop
13243           Cr_Var2 (I) := =-1;
13244        end loop;
13245 @end smallexample
13246
13247 @node Aggregates with non-static bounds
13248 @subsection Aggregates with non-static bounds
13249
13250 @noindent
13251 If the bounds of the aggregate are not statically compatible with the bounds
13252 of the nominal subtype  of the target, then constraint checks have to be
13253 generated on the bounds.  For a multidimensional array, constraint checks may
13254 have to be applied to sub-arrays individually, if they do not have statically
13255 compatible subtypes.
13256
13257 @node Aggregates in assignment statements
13258 @subsection Aggregates in assignment statements
13259
13260 @noindent
13261 In general, aggregate assignment requires the construction of a temporary,
13262 and a copy from the temporary to the target of the assignment.  This is because
13263 it is not always possible to convert the assignment into a series of individual
13264 component assignments.  For example, consider the simple case:
13265
13266 @smallexample @c ada
13267         A := (A(2), A(1));
13268 @end smallexample
13269
13270 @noindent
13271 This cannot be converted into:
13272
13273 @smallexample @c ada
13274         A(1) := A(2);
13275         A(2) := A(1);
13276 @end smallexample
13277
13278 @noindent
13279 So the aggregate has to be built first in a separate location, and then
13280 copied into the target.  GNAT recognizes simple cases where this intermediate
13281 step is not required, and the assignments can be performed in place, directly
13282 into the target.  The following sufficient criteria are applied:
13283
13284 @itemize @bullet
13285 @item
13286 The bounds of the aggregate are static, and the associations are static.
13287 @item
13288 The components of the aggregate are static constants, names of
13289 simple variables that are not renamings, or expressions not involving
13290 indexed components whose operands obey these rules.
13291 @end itemize
13292
13293 @noindent
13294 If any of these conditions are violated, the aggregate will be built in
13295 a temporary (created either by the front-end or the code generator) and then
13296 that temporary will be copied onto the target.
13297
13298 @node Project File Reference
13299 @chapter Project File Reference
13300
13301 @noindent
13302 This chapter describes the syntax and semantics of project files.
13303 Project files specify the options to be used when building a system.
13304 Project files can specify global settings for all tools,
13305 as well as tool-specific settings.
13306 See the chapter on project files in the GNAT Users guide for examples of use.
13307
13308 @menu
13309 * Reserved Words::
13310 * Lexical Elements::
13311 * Declarations::
13312 * Empty declarations::
13313 * Typed string declarations::
13314 * Variables::
13315 * Expressions::
13316 * Attributes::
13317 * Project Attributes::
13318 * Attribute References::
13319 * External Values::
13320 * Case Construction::
13321 * Packages::
13322 * Package Renamings::
13323 * Projects::
13324 * Project Extensions::
13325 * Project File Elaboration::
13326 @end menu
13327
13328 @node Reserved Words
13329 @section Reserved Words
13330
13331 @noindent
13332 All Ada95 reserved words are reserved in project files, and cannot be used
13333 as variable names or project names. In addition, the following are
13334 also reserved in project files:
13335
13336 @itemize
13337 @item @code{extends}
13338
13339 @item @code{external}
13340
13341 @item @code{project}
13342
13343 @end itemize
13344
13345 @node Lexical Elements
13346 @section Lexical Elements
13347
13348 @noindent
13349 Rules for identifiers are the same as in Ada95. Identifiers
13350 are case-insensitive.  Strings are case sensitive, except where noted.
13351 Comments have the same form as in Ada95.
13352
13353 @noindent
13354 Syntax:
13355
13356 @smallexample
13357 simple_name ::=
13358   identifier
13359
13360 name ::=
13361   simple_name @{. simple_name@}
13362 @end smallexample
13363
13364 @node Declarations
13365 @section Declarations
13366
13367 @noindent
13368 Declarations introduce new entities that denote types, variables, attributes,
13369 and packages. Some declarations can only appear immediately within a project
13370 declaration. Others can appear within a project or within a package.
13371
13372 Syntax:
13373 @smallexample
13374 declarative_item ::=
13375   simple_declarative_item |
13376   typed_string_declaration |
13377   package_declaration
13378
13379 simple_declarative_item ::=
13380   variable_declaration |
13381   typed_variable_declaration |
13382   attribute_declaration |
13383   case_construction |
13384   empty_declaration
13385 @end smallexample
13386
13387 @node Empty declarations
13388 @section Empty declarations
13389
13390 @smallexample
13391 empty_declaration ::=
13392   @b{null} ;
13393 @end smallexample
13394
13395 An empty declaration is allowed anywhere a declaration is allowed.
13396 It has no effect.
13397
13398 @node Typed string declarations
13399 @section Typed string declarations
13400
13401 @noindent
13402 Typed strings are sequences of string literals. Typed strings are the only
13403 named types in project files. They are used in case constructions, where they
13404 provide support for conditional attribute definitions.
13405
13406 Syntax:
13407 @smallexample
13408 typed_string_declaration ::=
13409   @b{type} <typed_string_>_simple_name @b{is}
13410    ( string_literal @{, string_literal@} );
13411 @end smallexample
13412
13413 @noindent
13414 A typed string declaration can only appear immediately within a project
13415 declaration.
13416
13417 All the string literals in a typed string declaration must be distinct.
13418
13419 @node Variables
13420 @section Variables
13421
13422 @noindent
13423 Variables denote values, and appear as constituents of expressions.
13424
13425 @smallexample
13426 typed_variable_declaration ::=
13427   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13428
13429 variable_declaration ::=
13430   <variable_>simple_name := expression;
13431 @end smallexample
13432
13433 @noindent
13434 The elaboration of a variable declaration introduces the variable and
13435 assigns to it the value of the expression. The name of the variable is
13436 available after the assignment symbol.
13437
13438 @noindent
13439 A typed_variable can only be declare once.
13440
13441 @noindent
13442 a non typed variable can be declared multiple times.
13443
13444 @noindent
13445 Before the completion of its first declaration, the value of variable
13446 is the null string.
13447
13448 @node Expressions
13449 @section Expressions
13450
13451 @noindent
13452 An expression is a formula that defines a computation or retrieval of a value.
13453 In a project file the value of an expression is either a string or a list
13454 of strings. A string value in an expression is either a literal, the current
13455 value of a variable, an external value, an attribute reference, or a
13456 concatenation operation.
13457
13458 Syntax:
13459
13460 @smallexample
13461 expression ::=
13462   term @{& term@}
13463
13464 term ::=
13465   string_literal |
13466   string_list |
13467   <variable_>name |
13468   external_value |
13469   attribute_reference
13470
13471 string_literal ::=
13472   (same as Ada)
13473
13474 string_list ::=
13475   ( <string_>expression @{ , <string_>expression @} )
13476 @end smallexample
13477
13478 @subsection Concatenation
13479 @noindent
13480 The following concatenation functions are defined:
13481
13482 @smallexample @c ada
13483   function "&" (X : String;      Y : String)      return String;
13484   function "&" (X : String_List; Y : String)      return String_List;
13485   function "&" (X : String_List; Y : String_List) return String_List;
13486 @end smallexample
13487
13488 @node Attributes
13489 @section Attributes
13490
13491 @noindent
13492 An attribute declaration defines a property of a project or package. This
13493 property can later be queried by means of an attribute reference.
13494 Attribute values are strings or string lists.
13495
13496 Some attributes are associative arrays. These attributes are mappings whose
13497 domain is a set of strings. These attributes are declared one association
13498 at a time, by specifying a point in the domain and the corresponding image
13499 of the attribute. They may also be declared as a full associative array,
13500 getting the same associations as the corresponding attribute in an imported
13501 or extended project.
13502
13503 Attributes that are not associative arrays are called simple attributes.
13504
13505 Syntax:
13506 @smallexample
13507 attribute_declaration ::=
13508   full_associative_array_declaration |
13509   @b{for} attribute_designator @b{use} expression ;
13510
13511 full_associative_array_declaration ::=
13512   @b{for} <associative_array_attribute_>simple_name @b{use}
13513   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13514
13515 attribute_designator ::=
13516   <simple_attribute_>simple_name |
13517   <associative_array_attribute_>simple_name ( string_literal )
13518 @end smallexample
13519
13520 @noindent
13521 Some attributes are project-specific, and can only appear immediately within
13522 a project declaration. Others are package-specific, and can only appear within
13523 the proper package.
13524
13525 The expression in an attribute definition must be a string or a string_list.
13526 The string literal appearing in the attribute_designator of an associative
13527 array attribute is case-insensitive.
13528
13529 @node Project Attributes
13530 @section Project Attributes
13531
13532 @noindent
13533 The following attributes apply to a project. All of them are simple
13534 attributes.
13535
13536 @table @code
13537 @item   Object_Dir
13538 Expression must be a path name. The attribute defines the
13539 directory in which the object files created by the build are to be placed. If
13540 not specified, object files are placed in the project directory.
13541
13542 @item   Exec_Dir
13543 Expression must be a path name. The attribute defines the
13544 directory in which the executables created by the build are to be placed.
13545 If not specified, executables are placed in the object directory.
13546
13547 @item  Source_Dirs
13548 Expression must be a list of path names. The attribute
13549 defines the directories in which the source files for the project are to be
13550 found. If not specified, source files are found in the project directory.
13551
13552 @item  Source_Files
13553 Expression must be a list of file names. The attribute
13554 defines the individual files, in the project directory, which are to be used
13555 as sources for the project. File names are path_names that contain no directory
13556 information. If the project has no sources the attribute must be declared
13557 explicitly with an empty list.
13558
13559 @item  Source_List_File
13560 Expression must a single path name. The attribute
13561 defines a text file that contains a list of source file names to be used
13562 as sources for the project
13563
13564 @item  Library_Dir
13565 Expression must be a path name. The attribute defines the
13566 directory in which a  library is to be built.  The directory must exist, must
13567 be distinct from the project's object directory, and must be writable.
13568
13569 @item  Library_Name
13570 Expression must be a string that is a legal file name,
13571 without extension. The attribute defines a string that is used to generate
13572 the name of the library to be built by the project.
13573
13574 @item  Library_Kind
13575 Argument must be a string value that must be one of the
13576 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13577 string is case-insensitive. If this attribute is not specified, the library is
13578 a static library. Otherwise, the library may be dynamic or relocatable. This
13579 distinction is operating-system dependent.
13580
13581 @item  Library_Version
13582 Expression must be a string value whose interpretation
13583 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13584 libraries as the internal name of the library (the @code{"soname"}). If the
13585 library file name (built from the @code{Library_Name}) is different from the
13586 @code{Library_Version}, then the library file will be a symbolic link to the
13587 actual file whose name will be @code{Library_Version}.
13588
13589 @item Library_Interface
13590 Expression must be a string list. Each element of the string list
13591 must designate a unit of the project.
13592 If this attribute is present in a Library Project File, then the project
13593 file is a Stand-alone Library_Project_File.
13594
13595 @item Library_Auto_Init
13596 Expression must be a single string "true" or "false", case-insensitive.
13597 If this attribute is present in a Stand-alone Library Project File,
13598 it indicates if initialization is automatic when the dynamic library
13599 is loaded.
13600
13601 @item Library_Options
13602 Expression must be a string list. Indicates additional switches that
13603 are to be used when building a shared library.
13604
13605 @item Library_GCC
13606 Expression must be a single string. Designates an alternative to "gcc"
13607 for building shared libraries.
13608
13609 @item  Library_Src_Dir
13610 Expression must be a path name. The attribute defines the
13611 directory in which the sources of the interfaces of a Stand-alone Library will
13612 be copied.  The directory must exist, must be distinct from the project's
13613 object directory and source directories, and must be writable.
13614
13615 @item  Main
13616 Expression must be a list of strings that are legal file names.
13617 These file names designate existing compilation units in the source directory
13618 that are legal main subprograms.
13619
13620 When a project file is elaborated, as part of the execution of a gnatmake
13621 command, one or several executables are built and placed in the Exec_Dir.
13622 If the gnatmake command does not include explicit file names, the executables
13623 that are built correspond to the files specified by this attribute.
13624
13625 @item Main_Language
13626 This is a simple attribute. Its value is a string that specifies the
13627 language of the main program.
13628
13629 @item  Languages
13630 Expression must be a string list. Each string designates
13631 a programming language that is known to GNAT. The strings are case-insensitive.
13632
13633 @item  Locally_Removed_Files
13634 This attribute is legal only in a project file that extends another.
13635 Expression must be a list of strings that are legal file names.
13636 Each file name must designate a source that would normally be inherited
13637 by the current project file. It cannot designate an immediate source that is
13638 not inherited. Each of the source files in the list are not considered to
13639 be sources of the project file: they are not inherited.
13640 @end table
13641
13642 @node Attribute References
13643 @section Attribute References
13644
13645 @noindent
13646 Attribute references are used to retrieve the value of previously defined
13647 attribute for a package or project.
13648 Syntax:
13649 @smallexample
13650 attribute_reference ::=
13651   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13652
13653 attribute_prefix ::=
13654   @b{project} |
13655   <project_simple_name | package_identifier |
13656   <project_>simple_name . package_identifier
13657 @end smallexample
13658
13659 @noindent
13660 If an attribute has not been specified for a given package or project, its
13661 value is the null string or the empty list.
13662
13663 @node External Values
13664 @section External Values
13665
13666 @noindent
13667 An external value is an expression whose value is obtained from the command
13668 that invoked the processing of the current project file (typically a
13669 gnatmake command).
13670
13671 Syntax:
13672 @smallexample
13673 external_value ::=
13674   @b{external} ( string_literal [, string_literal] )
13675 @end smallexample
13676
13677 @noindent
13678 The first string_literal is the string to be used on the command line or
13679 in the environment to specify the external value. The second string_literal,
13680 if present, is the default to use if there is no specification for this
13681 external value either on the command line or in the environment.
13682
13683 @node Case Construction
13684 @section Case Construction
13685
13686 @noindent
13687 A case construction supports attribute declarations that depend on the value of
13688 a previously declared variable.
13689
13690 Syntax:
13691 @smallexample
13692 case_construction ::=
13693   @b{case} <typed_variable_>name @b{is}
13694     @{case_item@}
13695   @b{end case} ;
13696
13697 case_item ::=
13698   @b{when} discrete_choice_list =>
13699     @{case_construction | attribute_declaration | empty_declaration@}
13700
13701 discrete_choice_list ::=
13702   string_literal @{| string_literal@} |
13703     @b{others}
13704 @end smallexample
13705
13706 @noindent
13707 All choices in a choice list must be distinct. The choice lists of two
13708 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13709 alternatives do not need to include all values of the type. An @code{others}
13710 choice must appear last in the list of alternatives.
13711
13712 @node Packages
13713 @section Packages
13714
13715 @noindent
13716 A package provides a grouping of variable declarations and attribute
13717 declarations to be used when invoking various GNAT tools. The name of
13718 the package indicates the tool(s) to which it applies.
13719 Syntax:
13720
13721 @smallexample
13722 package_declaration ::=
13723   package_specification | package_renaming
13724
13725 package_specification ::=
13726   @b{package} package_identifier @b{is}
13727     @{simple_declarative_item@}
13728   @b{end} package_identifier ;
13729
13730 package_identifier ::=
13731   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13732   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13733   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13734 @end smallexample
13735
13736 @subsection Package Naming
13737
13738 @noindent
13739 The attributes of a @code{Naming} package specifies the naming conventions
13740 that apply to the source files in a project. When invoking other GNAT tools,
13741 they will use the sources in the source directories that satisfy these
13742 naming conventions.
13743
13744 The following attributes apply to a @code{Naming} package:
13745
13746 @table @code
13747 @item Casing
13748 This is a simple attribute whose value is a string. Legal values of this
13749 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13750 These strings are themselves case insensitive.
13751
13752 @noindent
13753 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13754
13755 @item Dot_Replacement
13756 This is a simple attribute whose string value satisfies the following
13757 requirements:
13758
13759 @itemize @bullet
13760 @item It must not be empty
13761 @item It cannot start or end with an alphanumeric character
13762 @item It cannot be a single underscore
13763 @item It cannot start with an underscore followed by an alphanumeric
13764 @item It cannot contain a dot @code{'.'} if longer than one character
13765 @end itemize
13766
13767 @noindent
13768 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13769
13770 @item Spec_Suffix
13771 This is an associative array attribute, defined on language names,
13772 whose image is a string that must satisfy the following
13773 conditions:
13774
13775 @itemize @bullet
13776 @item It must not be empty
13777 @item It cannot start with an alphanumeric character
13778 @item It cannot start with an underscore followed by an alphanumeric character
13779 @end itemize
13780
13781 @noindent
13782 For Ada, the attribute denotes the suffix used in file names that contain
13783 library unit declarations, that is to say units that are package and
13784 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13785 specified, then the default is @code{".ads"}.
13786
13787 For C and C++, the attribute denotes the suffix used in file names that
13788 contain prototypes.
13789
13790 @item Body_Suffix
13791 This is an associative array attribute defined on language names,
13792 whose image is a string that must satisfy the following
13793 conditions:
13794
13795 @itemize @bullet
13796 @item It must not be empty
13797 @item It cannot start with an alphanumeric character
13798 @item It cannot start with an underscore followed by an alphanumeric character
13799 @item It cannot be a suffix of @code{Spec_Suffix}
13800 @end itemize
13801
13802 @noindent
13803 For Ada, the attribute denotes the suffix used in file names that contain
13804 library bodies, that is to say units that are package and subprogram bodies.
13805 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13806 @code{".adb"}.
13807
13808 For C and C++, the attribute denotes the suffix used in file names that contain
13809 source code.
13810
13811 @item Separate_Suffix
13812 This is a simple attribute whose value satisfies the same conditions as
13813 @code{Body_Suffix}.
13814
13815 This attribute is specific to Ada. It denotes the suffix used in file names
13816 that contain separate bodies. If it is not specified, then it defaults to same
13817 value as @code{Body_Suffix ("Ada")}.
13818
13819 @item Spec
13820 This is an associative array attribute, specific to Ada, defined over
13821 compilation unit names. The image is a string that is the name of the file
13822 that contains that library unit. The file name is case sensitive if the
13823 conventions of the host operating system require it.
13824
13825 @item Body
13826 This is an associative array attribute, specific to Ada, defined over
13827 compilation unit names. The image is a string that is the name of the file
13828 that contains the library unit body for the named unit. The file name is case
13829 sensitive if the conventions of the host operating system require it.
13830
13831 @item Specification_Exceptions
13832 This is an associative array attribute defined on language names,
13833 whose value is a list of strings.
13834
13835 This attribute is not significant for Ada.
13836
13837 For C and C++, each string in the list denotes the name of a file that
13838 contains prototypes, but whose suffix is not necessarily the
13839 @code{Spec_Suffix} for the language.
13840
13841 @item Implementation_Exceptions
13842 This is an associative array attribute defined on language names,
13843 whose value is a list of strings.
13844
13845 This attribute is not significant for Ada.
13846
13847 For C and C++, each string in the list denotes the name of a file that
13848 contains source code, but whose suffix is not necessarily the
13849 @code{Body_Suffix} for the language.
13850 @end table
13851
13852 The following attributes of package @code{Naming} are obsolescent. They are
13853 kept as synonyms of other attributes for compatibility with previous versions
13854 of the Project Manager.
13855
13856 @table @code
13857 @item Specification_Suffix
13858 This is a synonym of @code{Spec_Suffix}.
13859
13860 @item Implementation_Suffix
13861 This is a synonym of @code{Body_Suffix}.
13862
13863 @item Specification
13864 This is a synonym of @code{Spec}.
13865
13866 @item Implementation
13867 This is a synonym of @code{Body}.
13868 @end table
13869
13870 @subsection package Compiler
13871
13872 @noindent
13873 The attributes of the @code{Compiler} package specify the compilation options
13874 to be used by the underlying compiler.
13875
13876 @table @code
13877 @item  Default_Switches
13878 This is an associative array attribute. Its
13879 domain is a set of language names. Its range is a string list that
13880 specifies the compilation options to be used when compiling a component
13881 written in that language, for which no file-specific switches have been
13882 specified..
13883
13884 @item  Switches
13885 This is an associative array attribute. Its domain is
13886 a set of file names. Its range is a string list that specifies the
13887 compilation options to be used when compiling the named file. If a file
13888 is not specified in the Switches attribute, it is compiled with the
13889 settings specified by Default_Switches.
13890
13891 @item  Local_Configuration_Pragmas.
13892 This is a simple attribute, whose
13893 value is a path name that designates a file containing configuration pragmas
13894 to be used for all invocations of the compiler for immediate sources of the
13895 project.
13896
13897 @item Executable
13898 This is an associative array attribute. Its domain is
13899 a set of main source file names. Its range is a simple string that specifies
13900 the executable file name to be used when linking the specified main source.
13901 If a main source is not specified in the Executable attribute, the executable
13902 file name is deducted from the main source file name.
13903 @end table
13904
13905 @subsection package Builder
13906
13907 @noindent
13908 The attributes of package @code{Builder} specify the compilation, binding, and
13909 linking options to be used when building an executable for a project. The
13910 following attributes apply to package @code{Builder}:
13911
13912 @table @code
13913 @item Default_Switches
13914 As above.
13915
13916 @item Switches
13917 As above.
13918
13919 @item Global_Configuration_Pragmas
13920 This is a simple attribute, whose
13921 value is a path name that designates a file that contains configuration pragmas
13922 to be used in every build of an executable. If both local and global
13923 configuration pragmas are specified, a compilation makes use of both sets.
13924
13925 @item Executable
13926 This is an associative array attribute, defined over
13927 compilation unit names. The image is a string that is the name of the
13928 executable file corresponding to the main source file index.
13929 This attribute has no effect if its value is the empty string.
13930
13931 @item Executable_Suffix
13932 This is a simple attribute whose value is a suffix to be added to
13933 the executables that don't have an attribute Executable specified.
13934 @end table
13935
13936 @subsection package Gnatls
13937
13938 @noindent
13939 The attributes of package @code{Gnatls} specify the tool options to be used
13940 when invoking the library browser @command{gnatls}.
13941 The following attributes apply to package @code{Gnatls}:
13942
13943 @table @code
13944 @item Switches
13945 As above.
13946 @end table
13947
13948 @subsection package Binder
13949
13950 @noindent
13951 The attributes of package @code{Binder} specify the options to be used
13952 when invoking the binder in the construction of an executable.
13953 The following attributes apply to package @code{Binder}:
13954
13955 @table @code
13956 @item     Default_Switches
13957 As above.
13958 @item     Switches
13959 As above.
13960 @end table
13961
13962 @subsection package Linker
13963
13964 @noindent
13965 The attributes of package @code{Linker} specify the options to be used when
13966 invoking the linker in the construction of an executable.
13967 The following attributes apply to package @code{Linker}:
13968
13969 @table @code
13970 @item     Default_Switches
13971 As above
13972 @item     Switches
13973 As above.
13974 @end table
13975
13976 @subsection package Cross_Reference
13977
13978 @noindent
13979 The attributes of package @code{Cross_Reference} specify the tool options
13980 to be used
13981 when invoking the library tool @command{gnatxref}.
13982 The following attributes apply to package @code{Cross_Reference}:
13983
13984 @table @code
13985 @item     Default_Switches
13986 As above.
13987 @item     Switches
13988 As above.
13989 @end table
13990
13991 @subsection package   Finder
13992
13993 @noindent
13994 The attributes of package @code{Finder} specify the tool options to be used
13995 when invoking the search tool @command{gnatfind}.
13996 The following attributes apply to package @code{Finder}:
13997
13998 @table @code
13999 @item     Default_Switches
14000 As above.
14001 @item     Switches
14002 As above.
14003 @end table
14004
14005 @subsection package Pretty_Printer
14006
14007 @noindent
14008 The attributes of package @code{Pretty_Printer}
14009 specify the tool options to be used
14010 when invoking the formatting tool @command{gnatpp}.
14011 The following attributes apply to package @code{Pretty_Printer}:
14012
14013 @table @code
14014 @item     Default_switches
14015 As above.
14016 @item     Switches
14017 As above.
14018 @end table
14019
14020 @subsection  package IDE
14021
14022 @noindent
14023 The attributes of package @code{IDE} specify the options to be used when using
14024 an Integrated Development Environment such as @command{GPS}.
14025
14026 @table @code
14027 @item Remote_Host
14028 This is a simple attribute. Its value is a string that designates the remote
14029 host in a cross-compilation environment, to be used for remote compilation and
14030 debugging. This field should not be specified when running on the local
14031 machine.
14032
14033 @item Program_Host
14034 This is a simple attribute. Its value is a string that specifies the
14035 name of IP address of the embedded target in a cross-compilation environment,
14036 on which the program should execute.
14037
14038 @item Communication_Protocol
14039 This is a simple string attribute. Its value is the name of the protocol
14040 to use to communicate with the target in a cross-compilation environment,
14041 e.g. @code{"wtx"} or @code{"vxworks"}.
14042
14043 @item Compiler_Command
14044 This is an associative array attribute, whose domain is a language name. Its
14045 value is  string that denotes the command to be used to invoke the compiler.
14046 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14047 gnatmake, in particular in the handling of switches.
14048
14049 @item Debugger_Command
14050 This is simple attribute, Its value is a string that specifies the name of
14051 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14052
14053 @item Default_Switches
14054 This is an associative array attribute. Its indexes are the name of the
14055 external tools that the GNAT Programming System (GPS) is supporting. Its
14056 value is a list of switches to use when invoking that tool.
14057
14058 @item  Gnatlist
14059 This is a simple attribute.  Its value is a string that specifies the name
14060 of the @command{gnatls} utility to be used to retrieve information about the
14061 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14062
14063 @item VCS_Kind
14064 This is a simple atribute. Is value is a string used to specify the
14065 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14066 ClearCase or Perforce.
14067
14068 @item VCS_File_Check
14069 This is a simple attribute. Its value is a string that specifies the
14070 command used by the VCS to check the validity of a file, either
14071 when the user explicitly asks for a check, or as a sanity check before
14072 doing the check-in.
14073
14074 @item VCS_Log_Check
14075 This is a simple attribute. Its value is a string that specifies
14076 the command used by the VCS to check the validity of a log file.
14077
14078 @end table
14079
14080 @node Package Renamings
14081 @section Package Renamings
14082
14083 @noindent
14084 A package can be defined by a renaming declaration. The new package renames
14085 a package declared in a different project file, and has the same attributes
14086 as the package it renames.
14087 Syntax:
14088 @smallexample
14089 package_renaming ::==
14090   @b{package} package_identifier @b{renames}
14091        <project_>simple_name.package_identifier ;
14092 @end smallexample
14093
14094 @noindent
14095 The package_identifier of the renamed package must be the same as the
14096 package_identifier. The project whose name is the prefix of the renamed
14097 package must contain a package declaration with this name. This project
14098 must appear in the context_clause of the enclosing project declaration,
14099 or be the parent project of the enclosing child project.
14100
14101 @node Projects
14102 @section Projects
14103
14104 @noindent
14105 A project file specifies a set of rules for constructing a software system.
14106 A project file can be self-contained, or depend on other project files.
14107 Dependencies are expressed through a context clause that names other projects.
14108
14109 Syntax:
14110
14111 @smallexample
14112 project ::=
14113   context_clause project_declaration
14114
14115 project_declaration ::=
14116   simple_project_declaration | project_extension
14117
14118 simple_project_declaration ::=
14119   @b{project} <project_>simple_name @b{is}
14120     @{declarative_item@}
14121   @b{end} <project_>simple_name;
14122
14123 context_clause ::=
14124   @{with_clause@}
14125
14126 with_clause ::=
14127   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14128
14129 path_name ::=
14130    string_literal
14131 @end smallexample
14132
14133 @noindent
14134 A path name denotes a project file. A path name can be absolute or relative.
14135 An absolute path name includes a sequence of directories, in the syntax of
14136 the host operating system, that identifies uniquely the project file in the
14137 file system. A relative path name identifies the project file, relative
14138 to the directory that contains the current project, or relative to a
14139 directory listed in the environment variable ADA_PROJECT_PATH.
14140 Path names are case sensitive if file names in the host operating system
14141 are case sensitive.
14142
14143 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14144 directory names separated by colons (semicolons on Windows).
14145
14146 A given project name can appear only once in a context_clause.
14147
14148 It is illegal for a project imported by a context clause to refer, directly
14149 or indirectly, to the project in which this context clause appears (the
14150 dependency graph cannot contain cycles), except when one of the with_clause
14151 in the cycle is a @code{limited with}.
14152
14153 @node Project Extensions
14154 @section Project Extensions
14155
14156 @noindent
14157 A project extension introduces a new project, which inherits the declarations
14158 of another project.
14159 Syntax:
14160 @smallexample
14161
14162 project_extension ::=
14163   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14164     @{declarative_item@}
14165   @b{end} <project_>simple_name;
14166 @end smallexample
14167
14168 @noindent
14169 The project extension declares a child project. The child project inherits
14170 all the declarations and all the files of the parent project, These inherited
14171 declaration can be overridden in the child project, by means of suitable
14172 declarations.
14173
14174 @node Project File Elaboration
14175 @section Project File Elaboration
14176
14177 @noindent
14178 A project file is processed as part of the invocation of a gnat tool that
14179 uses the project option. Elaboration of the process file consists in the
14180 sequential elaboration of all its declarations. The computed values of
14181 attributes and variables in the project are then used to establish the
14182 environment in which the gnat tool will execute.
14183
14184 @include fdl.texi
14185 @c GNU Free Documentation License
14186
14187 @node Index,,GNU Free Documentation License, Top
14188 @unnumbered Index
14189
14190 @printindex cp
14191
14192 @contents
14193
14194 @bye