OSDN Git Service

2004-04-29 Ed Schonberg <schonberg@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 Propagate_Exceptions::
155 * Pragma Psect_Object::
156 * Pragma Pure_Function::
157 * Pragma Ravenscar::
158 * Pragma Restricted_Run_Time::
159 * Pragma Restriction_Warnings::
160 * Pragma Source_File_Name::
161 * Pragma Source_File_Name_Project::
162 * Pragma Source_Reference::
163 * Pragma Stream_Convert::
164 * Pragma Style_Checks::
165 * Pragma Subtitle::
166 * Pragma Suppress_All::
167 * Pragma Suppress_Exception_Locations::
168 * Pragma Suppress_Initialization::
169 * Pragma Task_Info::
170 * Pragma Task_Name::
171 * Pragma Task_Storage::
172 * Pragma Thread_Body::
173 * Pragma Time_Slice::
174 * Pragma Title::
175 * Pragma Unchecked_Union::
176 * Pragma Unimplemented_Unit::
177 * Pragma Universal_Data::
178 * Pragma Unreferenced::
179 * Pragma Unreserve_All_Interrupts::
180 * Pragma Unsuppress::
181 * Pragma Use_VADS_Size::
182 * Pragma Validity_Checks::
183 * Pragma Volatile::
184 * Pragma Warnings::
185 * Pragma Weak_External::
186
187 Implementation Defined Attributes
188
189 * Abort_Signal::
190 * Address_Size::
191 * Asm_Input::
192 * Asm_Output::
193 * AST_Entry::
194 * Bit::
195 * Bit_Position::
196 * Code_Address::
197 * Default_Bit_Order::
198 * Elaborated::
199 * Elab_Body::
200 * Elab_Spec::
201 * Emax::
202 * Enum_Rep::
203 * Epsilon::
204 * Fixed_Value::
205 * Has_Discriminants::
206 * Img::
207 * Integer_Value::
208 * Large::
209 * Machine_Size::
210 * Mantissa::
211 * Max_Interrupt_Priority::
212 * Max_Priority::
213 * Maximum_Alignment::
214 * Mechanism_Code::
215 * Null_Parameter::
216 * Object_Size::
217 * Passed_By_Reference::
218 * Range_Length::
219 * Safe_Emax::
220 * Safe_Large::
221 * Small::
222 * Storage_Unit::
223 * Target_Name::
224 * Tick::
225 * To_Address::
226 * Type_Class::
227 * UET_Address::
228 * Unconstrained_Array::
229 * Universal_Literal_String::
230 * Unrestricted_Access::
231 * VADS_Size::
232 * Value_Size::
233 * Wchar_T_Size::
234 * Word_Size::
235
236 The Implementation of Standard I/O
237
238 * Standard I/O Packages::
239 * FORM Strings::
240 * Direct_IO::
241 * Sequential_IO::
242 * Text_IO::
243 * Wide_Text_IO::
244 * Stream_IO::
245 * Shared Files::
246 * Open Modes::
247 * Operations on C Streams::
248 * Interfacing to C Streams::
249
250 The GNAT Library
251
252 * Ada.Characters.Latin_9 (a-chlat9.ads)::
253 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
254 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
255 * Ada.Command_Line.Remove (a-colire.ads)::
256 * Ada.Command_Line.Environment (a-colien.ads)::
257 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
258 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
259 * Ada.Exceptions.Traceback (a-exctra.ads)::
260 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
261 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
262 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
263 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
264 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
265 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
266 * GNAT.Array_Split (g-arrspl.ads)::
267 * GNAT.AWK (g-awk.ads)::
268 * GNAT.Bounded_Buffers (g-boubuf.ads)::
269 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
270 * GNAT.Bubble_Sort (g-bubsor.ads)::
271 * GNAT.Bubble_Sort_A (g-busora.ads)::
272 * GNAT.Bubble_Sort_G (g-busorg.ads)::
273 * GNAT.Calendar (g-calend.ads)::
274 * GNAT.Calendar.Time_IO (g-catiio.ads)::
275 * GNAT.Case_Util (g-casuti.ads)::
276 * GNAT.CGI (g-cgi.ads)::
277 * GNAT.CGI.Cookie (g-cgicoo.ads)::
278 * GNAT.CGI.Debug (g-cgideb.ads)::
279 * GNAT.Command_Line (g-comlin.ads)::
280 * GNAT.Compiler_Version (g-comver.ads)::
281 * GNAT.Ctrl_C (g-ctrl_c.ads)::
282 * GNAT.CRC32 (g-crc32.ads)::
283 * GNAT.Current_Exception (g-curexc.ads)::
284 * GNAT.Debug_Pools (g-debpoo.ads)::
285 * GNAT.Debug_Utilities (g-debuti.ads)::
286 * GNAT.Directory_Operations (g-dirope.ads)::
287 * GNAT.Dynamic_HTables (g-dynhta.ads)::
288 * GNAT.Dynamic_Tables (g-dyntab.ads)::
289 * GNAT.Exception_Actions (g-excact.ads)::
290 * GNAT.Exception_Traces (g-exctra.ads)::
291 * GNAT.Exceptions (g-except.ads)::
292 * GNAT.Expect (g-expect.ads)::
293 * GNAT.Float_Control (g-flocon.ads)::
294 * GNAT.Heap_Sort (g-heasor.ads)::
295 * GNAT.Heap_Sort_A (g-hesora.ads)::
296 * GNAT.Heap_Sort_G (g-hesorg.ads)::
297 * GNAT.HTable (g-htable.ads)::
298 * GNAT.IO (g-io.ads)::
299 * GNAT.IO_Aux (g-io_aux.ads)::
300 * GNAT.Lock_Files (g-locfil.ads)::
301 * GNAT.MD5 (g-md5.ads)::
302 * GNAT.Memory_Dump (g-memdum.ads)::
303 * GNAT.Most_Recent_Exception (g-moreex.ads)::
304 * GNAT.OS_Lib (g-os_lib.ads)::
305 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
306 * GNAT.Regexp (g-regexp.ads)::
307 * GNAT.Registry (g-regist.ads)::
308 * GNAT.Regpat (g-regpat.ads)::
309 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
310 * GNAT.Semaphores (g-semaph.ads)::
311 * GNAT.Signals (g-signal.ads)::
312 * GNAT.Sockets (g-socket.ads)::
313 * GNAT.Source_Info (g-souinf.ads)::
314 * GNAT.Spell_Checker (g-speche.ads)::
315 * GNAT.Spitbol.Patterns (g-spipat.ads)::
316 * GNAT.Spitbol (g-spitbo.ads)::
317 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
318 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
319 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
320 * GNAT.Strings (g-string.ads)::
321 * GNAT.String_Split (g-strspl.ads)::
322 * GNAT.Table (g-table.ads)::
323 * GNAT.Task_Lock (g-tasloc.ads)::
324 * GNAT.Threads (g-thread.ads)::
325 * GNAT.Traceback (g-traceb.ads)::
326 * GNAT.Traceback.Symbolic (g-trasym.ads)::
327 * GNAT.Wide_String_Split (g-wistsp.ads)::
328 * Interfaces.C.Extensions (i-cexten.ads)::
329 * Interfaces.C.Streams (i-cstrea.ads)::
330 * Interfaces.CPP (i-cpp.ads)::
331 * Interfaces.Os2lib (i-os2lib.ads)::
332 * Interfaces.Os2lib.Errors (i-os2err.ads)::
333 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
334 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
335 * Interfaces.Packed_Decimal (i-pacdec.ads)::
336 * Interfaces.VxWorks (i-vxwork.ads)::
337 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
338 * System.Address_Image (s-addima.ads)::
339 * System.Assertions (s-assert.ads)::
340 * System.Memory (s-memory.ads)::
341 * System.Partition_Interface (s-parint.ads)::
342 * System.Restrictions (s-restri.ads)::
343 * System.Rident (s-rident.ads)::
344 * System.Task_Info (s-tasinf.ads)::
345 * System.Wch_Cnv (s-wchcnv.ads)::
346 * System.Wch_Con (s-wchcon.ads)::
347
348 Text_IO
349
350 * Text_IO Stream Pointer Positioning::
351 * Text_IO Reading and Writing Non-Regular Files::
352 * Get_Immediate::
353 * Treating Text_IO Files as Streams::
354 * Text_IO Extensions::
355 * Text_IO Facilities for Unbounded Strings::
356
357 Wide_Text_IO
358
359 * Wide_Text_IO Stream Pointer Positioning::
360 * Wide_Text_IO Reading and Writing Non-Regular Files::
361
362 Interfacing to Other Languages
363
364 * Interfacing to C::
365 * Interfacing to C++::
366 * Interfacing to COBOL::
367 * Interfacing to Fortran::
368 * Interfacing to non-GNAT Ada code::
369
370 Specialized Needs Annexes
371
372 Implementation of Specific Ada Features
373 * Machine Code Insertions::
374 * GNAT Implementation of Tasking::
375 * GNAT Implementation of Shared Passive Packages::
376 * Code Generation for Array Aggregates::
377
378 Project File Reference
379
380 GNU Free Documentation License
381
382 Index
383 @end menu
384
385 @end ifnottex
386
387 @node About This Guide
388 @unnumbered About This Guide
389
390 @noindent
391 This manual contains useful information in writing programs using the
392 GNAT compiler.  It includes information on implementation dependent
393 characteristics of GNAT, including all the information required by Annex
394 M of the standard.
395
396 Ada 95 is designed to be highly portable.
397 In general, a program will have the same effect even when compiled by
398 different compilers on different platforms.
399 However, since Ada 95 is designed to be used in a
400 wide variety of applications, it also contains a number of system
401 dependent features to be used in interfacing to the external world.
402 @cindex Implementation-dependent features
403 @cindex Portability
404
405 Note: Any program that makes use of implementation-dependent features
406 may be non-portable.  You should follow good programming practice and
407 isolate and clearly document any sections of your program that make use
408 of these features in a non-portable manner.
409
410 @menu
411 * What This Reference Manual Contains::
412 * Conventions::
413 * Related Information::
414 @end menu
415
416 @node What This Reference Manual Contains
417 @unnumberedsec What This Reference Manual Contains
418
419 @noindent
420 This reference manual contains the following chapters:
421
422 @itemize @bullet
423 @item
424 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
425 pragmas, which can be used to extend and enhance the functionality of the
426 compiler.
427
428 @item
429 @ref{Implementation Defined Attributes}, lists GNAT
430 implementation-dependent attributes which can be used to extend and
431 enhance the functionality of the compiler.
432
433 @item
434 @ref{Implementation Advice}, provides information on generally
435 desirable behavior which are not requirements that all compilers must
436 follow since it cannot be provided on all systems, or which may be
437 undesirable on some systems.
438
439 @item
440 @ref{Implementation Defined Characteristics}, provides a guide to
441 minimizing implementation dependent features.
442
443 @item
444 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
445 implemented by GNAT, and how they can be imported into user
446 application programs.
447
448 @item
449 @ref{Representation Clauses and Pragmas}, describes in detail the
450 way that GNAT represents data, and in particular the exact set
451 of representation clauses and pragmas that is accepted.
452
453 @item
454 @ref{Standard Library Routines}, provides a listing of packages and a
455 brief description of the functionality that is provided by Ada's
456 extensive set of standard library routines as implemented by GNAT@.
457
458 @item
459 @ref{The Implementation of Standard I/O}, details how the GNAT
460 implementation of the input-output facilities.
461
462 @item
463 @ref{The GNAT Library}, is a catalog of packages that complement
464 the Ada predefined library.
465
466 @item
467 @ref{Interfacing to Other Languages}, describes how programs
468 written in Ada using GNAT can be interfaced to other programming
469 languages.
470
471 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
472 of the specialized needs annexes.
473
474 @item
475 @ref{Implementation of Specific Ada Features}, discusses issues related
476 to GNAT's implementation of machine code insertions, tasking, and several
477 other features.
478
479 @item
480 @ref{Project File Reference}, presents the syntax and semantics
481 of project files.
482
483 @end itemize
484
485 @cindex Ada 95 ISO/ANSI Standard
486 @noindent
487 This reference manual assumes that you are familiar with Ada 95
488 language, as described in the International Standard
489 ANSI/ISO/IEC-8652:1995, Jan 1995.
490
491 @node Conventions
492 @unnumberedsec Conventions
493 @cindex Conventions, typographical
494 @cindex Typographical conventions
495
496 @noindent
497 Following are examples of the typographical and graphic conventions used
498 in this guide:
499
500 @itemize @bullet
501 @item
502 @code{Functions}, @code{utility program names}, @code{standard names},
503 and @code{classes}.
504
505 @item
506 @code{Option flags}
507
508 @item
509 @file{File Names}, @samp{button names}, and @samp{field names}.
510
511 @item
512 @code{Variables}.
513
514 @item
515 @emph{Emphasis}.
516
517 @item
518 [optional information or parameters]
519
520 @item
521 Examples are described by text
522 @smallexample
523 and then shown this way.
524 @end smallexample
525 @end itemize
526
527 @noindent
528 Commands that are entered by the user are preceded in this manual by the
529 characters @samp{$ } (dollar sign followed by space).  If your system uses this
530 sequence as a prompt, then the commands will appear exactly as you see them
531 in the manual.  If your system uses some other prompt, then the command will
532 appear with the @samp{$} replaced by whatever prompt character you are using.
533
534 @node Related Information
535 @unnumberedsec Related Information
536 @noindent
537 See the following documents for further information on GNAT:
538
539 @itemize @bullet
540 @item
541 @cite{GNAT User's Guide}, which provides information on how to use
542 the GNAT compiler system.
543
544 @item
545 @cite{Ada 95 Reference Manual}, which contains all reference
546 material for the Ada 95 programming language.
547
548 @item
549 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
550 of the standard reference manual cited above.  The annotations describe
551 detailed aspects of the design decision, and in particular contain useful
552 sections on Ada 83 compatibility.
553
554 @item
555 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
556 which contains specific information on compatibility between GNAT and
557 DEC Ada 83 systems.
558
559 @item
560 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
561 describes in detail the pragmas and attributes provided by the DEC Ada 83
562 compiler system.
563
564 @end itemize
565
566 @node Implementation Defined Pragmas
567 @chapter Implementation Defined Pragmas
568
569 @noindent
570 Ada 95 defines a set of pragmas that can be used to supply additional
571 information to the compiler.  These language defined pragmas are
572 implemented in GNAT and work as described in the Ada 95 Reference
573 Manual.
574
575 In addition, Ada 95 allows implementations to define additional pragmas
576 whose meaning is defined by the implementation.  GNAT provides a number
577 of these implementation-dependent pragmas which can be used to extend
578 and enhance the functionality of the compiler.  This section of the GNAT
579 Reference Manual describes these additional pragmas.
580
581 Note that any program using these pragmas may not be portable to other
582 compilers (although GNAT implements this set of pragmas on all
583 platforms).  Therefore if portability to other compilers is an important
584 consideration, the use of these pragmas should be minimized.
585
586 @menu
587 * Pragma Abort_Defer::
588 * Pragma Ada_83::
589 * Pragma Ada_95::
590 * Pragma Annotate::
591 * Pragma Assert::
592 * Pragma Ast_Entry::
593 * Pragma C_Pass_By_Copy::
594 * Pragma Comment::
595 * Pragma Common_Object::
596 * Pragma Compile_Time_Warning::
597 * Pragma Complex_Representation::
598 * Pragma Component_Alignment::
599 * Pragma Convention_Identifier::
600 * Pragma CPP_Class::
601 * Pragma CPP_Constructor::
602 * Pragma CPP_Virtual::
603 * Pragma CPP_Vtable::
604 * Pragma Debug::
605 * Pragma Elaboration_Checks::
606 * Pragma Eliminate::
607 * Pragma Export_Exception::
608 * Pragma Export_Function::
609 * Pragma Export_Object::
610 * Pragma Export_Procedure::
611 * Pragma Export_Value::
612 * Pragma Export_Valued_Procedure::
613 * Pragma Extend_System::
614 * Pragma External::
615 * Pragma External_Name_Casing::
616 * Pragma Finalize_Storage_Only::
617 * Pragma Float_Representation::
618 * Pragma Ident::
619 * Pragma Import_Exception::
620 * Pragma Import_Function::
621 * Pragma Import_Object::
622 * Pragma Import_Procedure::
623 * Pragma Import_Valued_Procedure::
624 * Pragma Initialize_Scalars::
625 * Pragma Inline_Always::
626 * Pragma Inline_Generic::
627 * Pragma Interface::
628 * Pragma Interface_Name::
629 * Pragma Interrupt_Handler::
630 * Pragma Interrupt_State::
631 * Pragma Keep_Names::
632 * Pragma License::
633 * Pragma Link_With::
634 * Pragma Linker_Alias::
635 * Pragma Linker_Section::
636 * Pragma Long_Float::
637 * Pragma Machine_Attribute::
638 * Pragma Main_Storage::
639 * Pragma No_Return::
640 * Pragma Normalize_Scalars::
641 * Pragma Obsolescent::
642 * Pragma Passive::
643 * Pragma Polling::
644 * Pragma Propagate_Exceptions::
645 * Pragma Psect_Object::
646 * Pragma Pure_Function::
647 * Pragma Ravenscar::
648 * Pragma Restricted_Run_Time::
649 * Pragma Restriction_Warnings::
650 * Pragma Source_File_Name::
651 * Pragma Source_File_Name_Project::
652 * Pragma Source_Reference::
653 * Pragma Stream_Convert::
654 * Pragma Style_Checks::
655 * Pragma Subtitle::
656 * Pragma Suppress_All::
657 * Pragma Suppress_Exception_Locations::
658 * Pragma Suppress_Initialization::
659 * Pragma Task_Info::
660 * Pragma Task_Name::
661 * Pragma Task_Storage::
662 * Pragma Thread_Body::
663 * Pragma Time_Slice::
664 * Pragma Title::
665 * Pragma Unchecked_Union::
666 * Pragma Unimplemented_Unit::
667 * Pragma Universal_Data::
668 * Pragma Unreferenced::
669 * Pragma Unreserve_All_Interrupts::
670 * Pragma Unsuppress::
671 * Pragma Use_VADS_Size::
672 * Pragma Validity_Checks::
673 * Pragma Volatile::
674 * Pragma Warnings::
675 * Pragma Weak_External::
676 @end menu
677
678 @node Pragma Abort_Defer
679 @unnumberedsec Pragma Abort_Defer
680 @findex Abort_Defer
681 @cindex Deferring aborts
682 @noindent
683 Syntax:
684 @smallexample
685 pragma Abort_Defer;
686 @end smallexample
687
688 @noindent
689 This pragma must appear at the start of the statement sequence of a
690 handled sequence of statements (right after the @code{begin}).  It has
691 the effect of deferring aborts for the sequence of statements (but not
692 for the declarations or handlers, if any, associated with this statement
693 sequence).
694
695 @node Pragma Ada_83
696 @unnumberedsec Pragma Ada_83
697 @findex Ada_83
698 @noindent
699 Syntax:
700 @smallexample @c ada
701 pragma Ada_83;
702 @end smallexample
703
704 @noindent
705 A configuration pragma that establishes Ada 83 mode for the unit to
706 which it applies, regardless of the mode set by the command line
707 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
708 the syntax and semantics of Ada 83, as defined in the original Ada
709 83 Reference Manual as possible.  In particular, the new Ada 95
710 keywords are not recognized, optional package bodies are allowed,
711 and generics may name types with unknown discriminants without using
712 the @code{(<>)} notation.  In addition, some but not all of the additional
713 restrictions of Ada 83 are enforced.
714
715 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
716 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
717 Secondly, it aids in keeping code backwards compatible with Ada 83.
718 However, there is no guarantee that code that is processed correctly
719 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
720 83 compiler, since GNAT does not enforce all the additional checks
721 required by Ada 83.
722
723 @node Pragma Ada_95
724 @unnumberedsec Pragma Ada_95
725 @findex Ada_95
726 @noindent
727 Syntax:
728 @smallexample @c ada
729 pragma Ada_95;
730 @end smallexample
731
732 @noindent
733 A configuration pragma that establishes Ada 95 mode for the unit to which
734 it applies, regardless of the mode set by the command line switches.
735 This mode is set automatically for the @code{Ada} and @code{System}
736 packages and their children, so you need not specify it in these
737 contexts.  This pragma is useful when writing a reusable component that
738 itself uses Ada 95 features, but which is intended to be usable from
739 either Ada 83 or Ada 95 programs.
740
741 @node Pragma Annotate
742 @unnumberedsec Pragma Annotate
743 @findex Annotate
744 @noindent
745 Syntax:
746 @smallexample @c ada
747 pragma Annotate (IDENTIFIER @{, ARG@});
748
749 ARG ::= NAME | EXPRESSION
750 @end smallexample
751
752 @noindent
753 This pragma is used to annotate programs.  @var{identifier} identifies
754 the type of annotation.  GNAT verifies this is an identifier, but does
755 not otherwise analyze it.  The @var{arg} argument
756 can be either a string literal or an
757 expression.  String literals are assumed to be of type
758 @code{Standard.String}.  Names of entities are simply analyzed as entity
759 names.  All other expressions are analyzed as expressions, and must be
760 unambiguous.
761
762 The analyzed pragma is retained in the tree, but not otherwise processed
763 by any part of the GNAT compiler.  This pragma is intended for use by
764 external tools, including ASIS@.
765
766 @node Pragma Assert
767 @unnumberedsec Pragma Assert
768 @findex Assert
769 @noindent
770 Syntax:
771 @smallexample @c ada
772 pragma Assert (
773   boolean_EXPRESSION
774   [, static_string_EXPRESSION]);
775 @end smallexample
776
777 @noindent
778 The effect of this pragma depends on whether the corresponding command
779 line switch is set to activate assertions.  The pragma expands into code
780 equivalent to the following:
781
782 @smallexample @c ada
783 if assertions-enabled then
784    if not boolean_EXPRESSION then
785       System.Assertions.Raise_Assert_Failure
786         (string_EXPRESSION);
787    end if;
788 end if;
789 @end smallexample
790
791 @noindent
792 The string argument, if given, is the message that will be associated
793 with the exception occurrence if the exception is raised.  If no second
794 argument is given, the default message is @samp{@var{file}:@var{nnn}},
795 where @var{file} is the name of the source file containing the assert,
796 and @var{nnn} is the line number of the assert.  A pragma is not a
797 statement, so if a statement sequence contains nothing but a pragma
798 assert, then a null statement is required in addition, as in:
799
800 @smallexample @c ada
801 @dots{}
802 if J > 3 then
803    pragma Assert (K > 3, "Bad value for K");
804    null;
805 end if;
806 @end smallexample
807
808 @noindent
809 Note that, as with the @code{if} statement to which it is equivalent, the
810 type of the expression is either @code{Standard.Boolean}, or any type derived
811 from this standard type.
812
813 If assertions are disabled (switch @code{-gnata} not used), then there
814 is no effect (and in particular, any side effects from the expression
815 are suppressed).  More precisely it is not quite true that the pragma
816 has no effect, since the expression is analyzed, and may cause types
817 to be frozen if they are mentioned here for the first time.
818
819 If assertions are enabled, then the given expression is tested, and if
820 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
821 which results in the raising of @code{Assert_Failure} with the given message.
822
823 If the boolean expression has side effects, these side effects will turn
824 on and off with the setting of the assertions mode, resulting in
825 assertions that have an effect on the program.  You should generally
826 avoid side effects in the expression arguments of this pragma.  However,
827 the expressions are analyzed for semantic correctness whether or not
828 assertions are enabled, so turning assertions on and off cannot affect
829 the legality of a program.
830
831 @node Pragma Ast_Entry
832 @unnumberedsec Pragma Ast_Entry
833 @cindex OpenVMS
834 @findex Ast_Entry
835 @noindent
836 Syntax:
837 @smallexample @c ada
838 pragma AST_Entry (entry_IDENTIFIER);
839 @end smallexample
840
841 @noindent
842 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
843 argument is the simple name of a single entry; at most one @code{AST_Entry}
844 pragma is allowed for any given entry.  This pragma must be used in
845 conjunction with the @code{AST_Entry} attribute, and is only allowed after
846 the entry declaration and in the same task type specification or single task
847 as the entry to which it applies.  This pragma specifies that the given entry
848 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
849 resulting from an OpenVMS system service call.  The pragma does not affect
850 normal use of the entry.  For further details on this pragma, see the
851 DEC Ada Language Reference Manual, section 9.12a.
852
853 @node Pragma C_Pass_By_Copy
854 @unnumberedsec Pragma C_Pass_By_Copy
855 @cindex Passing by copy
856 @findex C_Pass_By_Copy
857 @noindent
858 Syntax:
859 @smallexample @c ada
860 pragma C_Pass_By_Copy
861   ([Max_Size =>] static_integer_EXPRESSION);
862 @end smallexample
863
864 @noindent
865 Normally the default mechanism for passing C convention records to C
866 convention subprograms is to pass them by reference, as suggested by RM
867 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
868 this default, by requiring that record formal parameters be passed by
869 copy if all of the following conditions are met:
870
871 @itemize @bullet
872 @item
873 The size of the record type does not exceed@*@var{static_integer_expression}.
874 @item
875 The record type has @code{Convention C}.
876 @item
877 The formal parameter has this record type, and the subprogram has a
878 foreign (non-Ada) convention.
879 @end itemize
880
881 @noindent
882 If these conditions are met the argument is passed by copy, i.e.@: in a
883 manner consistent with what C expects if the corresponding formal in the
884 C prototype is a struct (rather than a pointer to a struct).
885
886 You can also pass records by copy by specifying the convention
887 @code{C_Pass_By_Copy} for the record type, or by using the extended
888 @code{Import} and @code{Export} pragmas, which allow specification of
889 passing mechanisms on a parameter by parameter basis.
890
891 @node Pragma Comment
892 @unnumberedsec Pragma Comment
893 @findex Comment
894 @noindent
895 Syntax:
896
897 @smallexample @c ada
898 pragma Comment (static_string_EXPRESSION);
899 @end smallexample
900
901 @noindent
902 This is almost identical in effect to pragma @code{Ident}.  It allows the
903 placement of a comment into the object file and hence into the
904 executable file if the operating system permits such usage.  The
905 difference is that @code{Comment}, unlike @code{Ident}, has
906 no limitations on placement of the pragma (it can be placed
907 anywhere in the main source unit), and if more than one pragma
908 is used, all comments are retained.
909
910 @node Pragma Common_Object
911 @unnumberedsec Pragma Common_Object
912 @findex Common_Object
913 @noindent
914 Syntax:
915
916 @smallexample @c ada
917 pragma Common_Object (
918      [Internal =>] LOCAL_NAME,
919   [, [External =>] EXTERNAL_SYMBOL]
920   [, [Size     =>] EXTERNAL_SYMBOL] );
921
922 EXTERNAL_SYMBOL ::=
923   IDENTIFIER
924 | static_string_EXPRESSION
925 @end smallexample
926
927 @noindent
928 This pragma enables the shared use of variables stored in overlaid
929 linker areas corresponding to the use of @code{COMMON}
930 in Fortran.  The single
931 object @var{local_name} is assigned to the area designated by
932 the @var{External} argument.
933 You may define a record to correspond to a series
934 of fields.  The @var{size} argument
935 is syntax checked in GNAT, but otherwise ignored.
936
937 @code{Common_Object} is not supported on all platforms.  If no
938 support is available, then the code generator will issue a message
939 indicating that the necessary attribute for implementation of this
940 pragma is not available.
941
942 @node Pragma Compile_Time_Warning
943 @unnumberedsec Pragma Compile_Time_Warning
944 @findex Compile_Time_Warning
945 @noindent
946 Syntax:
947
948 @smallexample @c ada
949 pragma Compile_Time_Warning
950          (boolean_EXPRESSION, static_string_EXPRESSION);
951 @end smallexample
952
953 @noindent
954 This pragma can be used to generate additional compile time warnings. It
955 is particularly useful in generics, where warnings can be issued for
956 specific problematic instantiations. The first parameter is a boolean
957 expression. The pragma is effective only if the value of this expression
958 is known at compile time, and has the value True. The set of expressions
959 whose values are known at compile time includes all static boolean
960 expressions, and also other values which the compiler can determine
961 at compile time (e.g. the size of a record type set by an explicit
962 size representation clause, or the value of a variable which was
963 initialized to a constant and is known not to have been modified).
964 If these conditions are met, a warning message is generated using
965 the value given as the second argument. This string value may contain
966 embedded ASCII.LF characters to break the message into multiple lines.
967
968 @node Pragma Complex_Representation
969 @unnumberedsec Pragma Complex_Representation
970 @findex Complex_Representation
971 @noindent
972 Syntax:
973
974 @smallexample @c ada
975 pragma Complex_Representation
976         ([Entity =>] LOCAL_NAME);
977 @end smallexample
978
979 @noindent
980 The @var{Entity} argument must be the name of a record type which has
981 two fields of the same floating-point type.  The effect of this pragma is
982 to force gcc to use the special internal complex representation form for
983 this record, which may be more efficient.  Note that this may result in
984 the code for this type not conforming to standard ABI (application
985 binary interface) requirements for the handling of record types.  For
986 example, in some environments, there is a requirement for passing
987 records by pointer, and the use of this pragma may result in passing
988 this type in floating-point registers.
989
990 @node Pragma Component_Alignment
991 @unnumberedsec Pragma Component_Alignment
992 @cindex Alignments of components
993 @findex Component_Alignment
994 @noindent
995 Syntax:
996
997 @smallexample @c ada
998 pragma Component_Alignment (
999      [Form =>] ALIGNMENT_CHOICE
1000   [, [Name =>] type_LOCAL_NAME]);
1001
1002 ALIGNMENT_CHOICE ::=
1003   Component_Size
1004 | Component_Size_4
1005 | Storage_Unit
1006 | Default
1007 @end smallexample
1008
1009 @noindent
1010 Specifies the alignment of components in array or record types.
1011 The meaning of the @var{Form} argument is as follows:
1012
1013 @table @code
1014 @findex Component_Size
1015 @item Component_Size
1016 Aligns scalar components and subcomponents of the array or record type
1017 on boundaries appropriate to their inherent size (naturally
1018 aligned).  For example, 1-byte components are aligned on byte boundaries,
1019 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1020 integer components are aligned on 4-byte boundaries and so on.  These
1021 alignment rules correspond to the normal rules for C compilers on all
1022 machines except the VAX@.
1023
1024 @findex Component_Size_4
1025 @item Component_Size_4
1026 Naturally aligns components with a size of four or fewer
1027 bytes.  Components that are larger than 4 bytes are placed on the next
1028 4-byte boundary.
1029
1030 @findex Storage_Unit
1031 @item Storage_Unit
1032 Specifies that array or record components are byte aligned, i.e.@:
1033 aligned on boundaries determined by the value of the constant
1034 @code{System.Storage_Unit}.
1035
1036 @cindex OpenVMS
1037 @item Default
1038 Specifies that array or record components are aligned on default
1039 boundaries, appropriate to the underlying hardware or operating system or
1040 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1041 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1042 the @code{Default} choice is the same as @code{Component_Size} (natural
1043 alignment).
1044 @end table
1045
1046 @noindent
1047 If the @code{Name} parameter is present, @var{type_local_name} must
1048 refer to a local record or array type, and the specified alignment
1049 choice applies to the specified type.  The use of
1050 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1051 @code{Component_Alignment} pragma to be ignored.  The use of
1052 @code{Component_Alignment} together with a record representation clause
1053 is only effective for fields not specified by the representation clause.
1054
1055 If the @code{Name} parameter is absent, the pragma can be used as either
1056 a configuration pragma, in which case it applies to one or more units in
1057 accordance with the normal rules for configuration pragmas, or it can be
1058 used within a declarative part, in which case it applies to types that
1059 are declared within this declarative part, or within any nested scope
1060 within this declarative part.  In either case it specifies the alignment
1061 to be applied to any record or array type which has otherwise standard
1062 representation.
1063
1064 If the alignment for a record or array type is not specified (using
1065 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1066 clause), the GNAT uses the default alignment as described previously.
1067
1068 @node Pragma Convention_Identifier
1069 @unnumberedsec Pragma Convention_Identifier
1070 @findex Convention_Identifier
1071 @cindex Conventions, synonyms
1072 @noindent
1073 Syntax:
1074
1075 @smallexample @c ada
1076 pragma Convention_Identifier (
1077          [Name =>]       IDENTIFIER,
1078          [Convention =>] convention_IDENTIFIER);
1079 @end smallexample
1080
1081 @noindent
1082 This pragma provides a mechanism for supplying synonyms for existing
1083 convention identifiers. The @code{Name} identifier can subsequently
1084 be used as a synonym for the given convention in other pragmas (including
1085 for example pragma @code{Import} or another @code{Convention_Identifier}
1086 pragma). As an example of the use of this, suppose you had legacy code
1087 which used Fortran77 as the identifier for Fortran. Then the pragma:
1088
1089 @smallexample @c ada
1090 pragma Convention_Identifier (Fortran77, Fortran);
1091 @end smallexample
1092
1093 @noindent
1094 would allow the use of the convention identifier @code{Fortran77} in
1095 subsequent code, avoiding the need to modify the sources. As another
1096 example, you could use this to parametrize convention requirements
1097 according to systems. Suppose you needed to use @code{Stdcall} on
1098 windows systems, and @code{C} on some other system, then you could
1099 define a convention identifier @code{Library} and use a single
1100 @code{Convention_Identifier} pragma to specify which convention
1101 would be used system-wide.
1102
1103 @node Pragma CPP_Class
1104 @unnumberedsec Pragma CPP_Class
1105 @findex CPP_Class
1106 @cindex Interfacing with C++
1107 @noindent
1108 Syntax:
1109
1110 @smallexample @c ada
1111 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1112 @end smallexample
1113
1114 @noindent
1115 The argument denotes an entity in the current declarative region
1116 that is declared as a tagged or untagged record type.  It indicates that
1117 the type corresponds to an externally declared C++ class type, and is to
1118 be laid out the same way that C++ would lay out the type.
1119
1120 If (and only if) the type is tagged, at least one component in the
1121 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1122 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1123 for dispatching.
1124
1125 Types for which @code{CPP_Class} is specified do not have assignment or
1126 equality operators defined (such operations can be imported or declared
1127 as subprograms as required).  Initialization is allowed only by
1128 constructor functions (see pragma @code{CPP_Constructor}).
1129
1130 Pragma @code{CPP_Class} is intended primarily for automatic generation
1131 using an automatic binding generator tool.
1132 See @ref{Interfacing to C++} for related information.
1133
1134 @node Pragma CPP_Constructor
1135 @unnumberedsec Pragma CPP_Constructor
1136 @cindex Interfacing with C++
1137 @findex CPP_Constructor
1138 @noindent
1139 Syntax:
1140
1141 @smallexample @c ada
1142 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1143 @end smallexample
1144
1145 @noindent
1146 This pragma identifies an imported function (imported in the usual way
1147 with pragma @code{Import}) as corresponding to a C++
1148 constructor.  The argument is a name that must have been
1149 previously mentioned in a pragma @code{Import}
1150 with @code{Convention} = @code{CPP}, and must be of one of the following
1151 forms:
1152
1153 @itemize @bullet
1154 @item
1155 @code{function @var{Fname} return @var{T}'Class}
1156
1157 @item
1158 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1159 @end itemize
1160
1161 @noindent
1162 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1163
1164 The first form is the default constructor, used when an object of type
1165 @var{T} is created on the Ada side with no explicit constructor.  Other
1166 constructors (including the copy constructor, which is simply a special
1167 case of the second form in which the one and only argument is of type
1168 @var{T}), can only appear in two contexts:
1169
1170 @itemize @bullet
1171 @item
1172 On the right side of an initialization of an object of type @var{T}.
1173 @item
1174 In an extension aggregate for an object of a type derived from @var{T}.
1175 @end itemize
1176
1177 @noindent
1178 Although the constructor is described as a function that returns a value
1179 on the Ada side, it is typically a procedure with an extra implicit
1180 argument (the object being initialized) at the implementation
1181 level.  GNAT issues the appropriate call, whatever it is, to get the
1182 object properly initialized.
1183
1184 In the case of derived objects, you may use one of two possible forms
1185 for declaring and creating an object:
1186
1187 @itemize @bullet
1188 @item @code{New_Object : Derived_T}
1189 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1190 @end itemize
1191
1192 @noindent
1193 In the first case the default constructor is called and extension fields
1194 if any are initialized according to the default initialization
1195 expressions in the Ada declaration.  In the second case, the given
1196 constructor is called and the extension aggregate indicates the explicit
1197 values of the extension fields.
1198
1199 If no constructors are imported, it is impossible to create any objects
1200 on the Ada side.  If no default constructor is imported, only the
1201 initialization forms using an explicit call to a constructor are
1202 permitted.
1203
1204 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1205 using an automatic binding generator tool.
1206 See @ref{Interfacing to C++} for more related information.
1207
1208 @node Pragma CPP_Virtual
1209 @unnumberedsec Pragma CPP_Virtual
1210 @cindex Interfacing to C++
1211 @findex CPP_Virtual
1212 @noindent
1213 Syntax:
1214
1215 @smallexample @c ada
1216 pragma CPP_Virtual
1217      [Entity     =>] ENTITY,
1218   [, [Vtable_Ptr =>] vtable_ENTITY,]
1219   [, [Position   =>] static_integer_EXPRESSION]);
1220 @end smallexample
1221
1222 @noindent
1223 This pragma serves the same function as pragma @code{Import} in that
1224 case of a virtual function imported from C++.  The @var{Entity} argument
1225 must be a
1226 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1227 applies.  The @var{Vtable_Ptr} argument specifies
1228 the Vtable_Ptr component which contains the
1229 entry for this virtual function.  The @var{Position} argument
1230 is the sequential number
1231 counting virtual functions for this Vtable starting at 1.
1232
1233 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1234 there is one Vtable_Ptr present (single inheritance case) and all
1235 virtual functions are imported.  In that case the compiler can deduce both
1236 these values.
1237
1238 No @code{External_Name} or @code{Link_Name} arguments are required for a
1239 virtual function, since it is always accessed indirectly via the
1240 appropriate Vtable entry.
1241
1242 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1243 using an automatic binding generator tool.
1244 See @ref{Interfacing to C++} for related information.
1245
1246 @node Pragma CPP_Vtable
1247 @unnumberedsec Pragma CPP_Vtable
1248 @cindex Interfacing with C++
1249 @findex CPP_Vtable
1250 @noindent
1251 Syntax:
1252
1253 @smallexample @c ada
1254 pragma CPP_Vtable (
1255   [Entity      =>] ENTITY,
1256   [Vtable_Ptr  =>] vtable_ENTITY,
1257   [Entry_Count =>] static_integer_EXPRESSION);
1258 @end smallexample
1259
1260 @noindent
1261 Given a record to which the pragma @code{CPP_Class} applies,
1262 this pragma can be specified for each component of type
1263 @code{CPP.Interfaces.Vtable_Ptr}.
1264 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1265 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1266 the number of virtual functions on the C++ side.  Not all of these
1267 functions need to be imported on the Ada side.
1268
1269 You may omit the @code{CPP_Vtable} pragma if there is only one
1270 @code{Vtable_Ptr} component in the record and all virtual functions are
1271 imported on the Ada side (the default value for the entry count in this
1272 case is simply the total number of virtual functions).
1273
1274 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1275 using an automatic binding generator tool.
1276 See @ref{Interfacing to C++} for related information.
1277
1278 @node Pragma Debug
1279 @unnumberedsec Pragma Debug
1280 @findex Debug
1281 @noindent
1282 Syntax:
1283
1284 @smallexample @c ada
1285 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1286
1287 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1288   PROCEDURE_NAME
1289 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1290 @end smallexample
1291
1292 @noindent
1293 The argument has the syntactic form of an expression, meeting the
1294 syntactic requirements for pragmas.
1295
1296 If assertions are not enabled on the command line, this pragma has no
1297 effect.  If asserts are enabled, the semantics of the pragma is exactly
1298 equivalent to the procedure call statement corresponding to the argument
1299 with a terminating semicolon.  Pragmas are permitted in sequences of
1300 declarations, so you can use pragma @code{Debug} to intersperse calls to
1301 debug procedures in the middle of declarations.
1302
1303 @node Pragma Elaboration_Checks
1304 @unnumberedsec Pragma Elaboration_Checks
1305 @cindex Elaboration control
1306 @findex Elaboration_Checks
1307 @noindent
1308 Syntax:
1309
1310 @smallexample @c ada
1311 pragma Elaboration_Checks (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_LITERAL
1360
1361 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1362 SOURCE_TRACE    ::= STRING_LITERAL
1363 @end smallexample
1364
1365 @noindent
1366 This pragma indicates that the given entity is not used outside the
1367 compilation unit it is defined in. The entity must be an explicitly declared
1368 subprogram; this includes  generic subprogram instances and
1369 subprograms declared in generic package instances.
1370
1371 If the entity to be eliminated is a library level subprogram, then
1372 the first form of pragma @code{Eliminate} is used with only a single argument.
1373 In this form, the @code{Unit_Name} argument specifies the name of the
1374 library  level unit to be eliminated.
1375
1376 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1377 are required. If item is an entity of a library package, then the first
1378 argument specifies the unit name, and the second argument specifies
1379 the particular entity.  If the second argument is in string form, it must
1380 correspond to the internal manner in which GNAT stores entity names (see
1381 compilation unit Namet in the compiler sources for details).
1382
1383 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1384 to distinguish between overloaded subprograms. If a pragma does not contain
1385 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1386 subprograms denoted by the first two parameters.
1387
1388 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1389 to be eliminated in a manner similar to that used for the extended
1390 @code{Import} and @code{Export} pragmas, except that the subtype names are
1391 always given as string literals. At the moment, this form of distinguishing
1392 overloaded subprograms is implemented only partially, so we do not recommend
1393 using it for practical subprogram elimination.
1394
1395 Note, that in case of a parameterless procedure its profile is represented
1396 as @code{Parameter_Types => ("")}
1397
1398 Alternatively, the @code{Source_Location} parameter is used to specify
1399 which overloaded alternative is to be eliminated by pointing to the
1400 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1401 source text. The string literal submitted as SOURCE_TRACE should have
1402 the following format:
1403
1404 @smallexample @c ada
1405 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1406
1407 LBRACKET ::= [
1408 RBRACKET ::= ]
1409
1410 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1411 FILE_NAME       ::= STRING_LITERAL
1412 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1413 @end smallexample
1414
1415 SOURCE_TRACE should be the short name of the source file (with no directory
1416 information), and LINE_NUMBER is supposed to point to the line where the
1417 defining name of the subprogram is located.
1418
1419 For the subprograms that are not a part of generic instantiations, only one
1420 SOURCE_LOCATION is used. If a subprogram is declared in a package
1421 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1422 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1423 second one denotes the declaration of the corresponding subprogram in the
1424 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1425 in case of nested instantiations.
1426
1427 The effect of the pragma is to allow the compiler to eliminate
1428 the code or data associated with the named entity.  Any reference to
1429 an eliminated entity outside the compilation unit it is defined in,
1430 causes a compile time or link time error.
1431
1432 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1433 in a system independent manner, with unused entities eliminated, without
1434 the requirement of modifying the source text.  Normally the required set
1435 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1436 tool. Elimination of unused entities local to a compilation unit is
1437 automatic, without requiring the use of pragma @code{Eliminate}.
1438
1439 Note that the reason this pragma takes string literals where names might
1440 be expected is that a pragma @code{Eliminate} can appear in a context where the
1441 relevant names are not visible.
1442
1443 Note that any change in the source files that includes removing, splitting of
1444 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1445 parameter illegal.
1446
1447 @node Pragma Export_Exception
1448 @unnumberedsec Pragma Export_Exception
1449 @cindex OpenVMS
1450 @findex Export_Exception
1451 @noindent
1452 Syntax:
1453
1454 @smallexample @c ada
1455 pragma Export_Exception (
1456      [Internal =>] LOCAL_NAME,
1457   [, [External =>] EXTERNAL_SYMBOL,]
1458   [, [Form     =>] Ada | VMS]
1459   [, [Code     =>] static_integer_EXPRESSION]);
1460
1461 EXTERNAL_SYMBOL ::=
1462   IDENTIFIER
1463 | static_string_EXPRESSION
1464 @end smallexample
1465
1466 @noindent
1467 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1468 causes the specified exception to be propagated outside of the Ada program,
1469 so that it can be handled by programs written in other OpenVMS languages.
1470 This pragma establishes an external name for an Ada exception and makes the
1471 name available to the OpenVMS Linker as a global symbol.  For further details
1472 on this pragma, see the
1473 DEC Ada Language Reference Manual, section 13.9a3.2.
1474
1475 @node Pragma Export_Function
1476 @unnumberedsec Pragma Export_Function
1477 @cindex Argument passing mechanisms
1478 @findex Export_Function
1479
1480 @noindent
1481 Syntax:
1482
1483 @smallexample @c ada
1484 pragma Export_Function (
1485      [Internal         =>] LOCAL_NAME,
1486   [, [External         =>] EXTERNAL_SYMBOL]
1487   [, [Parameter_Types  =>] PARAMETER_TYPES]
1488   [, [Result_Type      =>] result_SUBTYPE_MARK]
1489   [, [Mechanism        =>] MECHANISM]
1490   [, [Result_Mechanism =>] MECHANISM_NAME]);
1491
1492 EXTERNAL_SYMBOL ::=
1493   IDENTIFIER
1494 | static_string_EXPRESSION
1495 | ""
1496
1497 PARAMETER_TYPES ::=
1498   null
1499 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1500
1501 TYPE_DESIGNATOR ::=
1502   subtype_NAME
1503 | subtype_Name ' Access
1504
1505 MECHANISM ::=
1506   MECHANISM_NAME
1507 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1508
1509 MECHANISM_ASSOCIATION ::=
1510   [formal_parameter_NAME =>] MECHANISM_NAME
1511
1512 MECHANISM_NAME ::=
1513   Value
1514 | Reference
1515 @end smallexample
1516
1517 @noindent
1518 Use this pragma to make a function externally callable and optionally
1519 provide information on mechanisms to be used for passing parameter and
1520 result values.  We recommend, for the purposes of improving portability,
1521 this pragma always be used in conjunction with a separate pragma
1522 @code{Export}, which must precede the pragma @code{Export_Function}.
1523 GNAT does not require a separate pragma @code{Export}, but if none is
1524 present, @code{Convention Ada} is assumed, which is usually
1525 not what is wanted, so it is usually appropriate to use this
1526 pragma in conjunction with a @code{Export} or @code{Convention}
1527 pragma that specifies the desired foreign convention.
1528 Pragma @code{Export_Function}
1529 (and @code{Export}, if present) must appear in the same declarative
1530 region as the function to which they apply.
1531
1532 @var{internal_name} must uniquely designate the function to which the
1533 pragma applies.  If more than one function name exists of this name in
1534 the declarative part you must use the @code{Parameter_Types} and
1535 @code{Result_Type} parameters is mandatory to achieve the required
1536 unique designation.  @var{subtype_ mark}s in these parameters must
1537 exactly match the subtypes in the corresponding function specification,
1538 using positional notation to match parameters with subtype marks.
1539 The form with an @code{'Access} attribute can be used to match an
1540 anonymous access parameter.
1541
1542 @cindex OpenVMS
1543 @cindex Passing by descriptor
1544 Note that passing by descriptor is not supported, even on the OpenVMS
1545 ports of GNAT@.
1546
1547 @cindex Suppressing external name
1548 Special treatment is given if the EXTERNAL is an explicit null
1549 string or a static string expressions that evaluates to the null
1550 string. In this case, no external name is generated. This form
1551 still allows the specification of parameter mechanisms.
1552
1553 @node Pragma Export_Object
1554 @unnumberedsec Pragma Export_Object
1555 @findex Export_Object
1556 @noindent
1557 Syntax:
1558
1559 @smallexample @c ada
1560 pragma Export_Object
1561       [Internal =>] LOCAL_NAME,
1562    [, [External =>] EXTERNAL_SYMBOL]
1563    [, [Size     =>] EXTERNAL_SYMBOL]
1564
1565 EXTERNAL_SYMBOL ::=
1566   IDENTIFIER
1567 | static_string_EXPRESSION
1568 @end smallexample
1569
1570 @noindent
1571 This pragma designates an object as exported, and apart from the
1572 extended rules for external symbols, is identical in effect to the use of
1573 the normal @code{Export} pragma applied to an object.  You may use a
1574 separate Export pragma (and you probably should from the point of view
1575 of portability), but it is not required.  @var{Size} is syntax checked,
1576 but otherwise ignored by GNAT@.
1577
1578 @node Pragma Export_Procedure
1579 @unnumberedsec Pragma Export_Procedure
1580 @findex Export_Procedure
1581 @noindent
1582 Syntax:
1583
1584 @smallexample @c ada
1585 pragma Export_Procedure (
1586      [Internal        =>] LOCAL_NAME
1587   [, [External        =>] EXTERNAL_SYMBOL]
1588   [, [Parameter_Types =>] PARAMETER_TYPES]
1589   [, [Mechanism       =>] MECHANISM]);
1590
1591 EXTERNAL_SYMBOL ::=
1592   IDENTIFIER
1593 | static_string_EXPRESSION
1594 | ""
1595
1596 PARAMETER_TYPES ::=
1597   null
1598 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1599
1600 TYPE_DESIGNATOR ::=
1601   subtype_NAME
1602 | subtype_Name ' Access
1603
1604 MECHANISM ::=
1605   MECHANISM_NAME
1606 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1607
1608 MECHANISM_ASSOCIATION ::=
1609   [formal_parameter_NAME =>] MECHANISM_NAME
1610
1611 MECHANISM_NAME ::=
1612   Value
1613 | Reference
1614 @end smallexample
1615
1616 @noindent
1617 This pragma is identical to @code{Export_Function} except that it
1618 applies to a procedure rather than a function and the parameters
1619 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1620 GNAT does not require a separate pragma @code{Export}, but if none is
1621 present, @code{Convention Ada} is assumed, which is usually
1622 not what is wanted, so it is usually appropriate to use this
1623 pragma in conjunction with a @code{Export} or @code{Convention}
1624 pragma that specifies the desired foreign convention.
1625
1626 @cindex OpenVMS
1627 @cindex Passing by descriptor
1628 Note that passing by descriptor is not supported, even on the OpenVMS
1629 ports of GNAT@.
1630
1631 @cindex Suppressing external name
1632 Special treatment is given if the EXTERNAL is an explicit null
1633 string or a static string expressions that evaluates to the null
1634 string. In this case, no external name is generated. This form
1635 still allows the specification of parameter mechanisms.
1636
1637 @node Pragma Export_Value
1638 @unnumberedsec Pragma Export_Value
1639 @findex Export_Value
1640 @noindent
1641 Syntax:
1642
1643 @smallexample @c ada
1644 pragma Export_Value (
1645   [Value     =>] static_integer_EXPRESSION,
1646   [Link_Name =>] static_string_EXPRESSION);
1647 @end smallexample
1648
1649 @noindent
1650 This pragma serves to export a static integer value for external use.
1651 The first argument specifies the value to be exported. The Link_Name
1652 argument specifies the symbolic name to be associated with the integer
1653 value. This pragma is useful for defining a named static value in Ada
1654 that can be referenced in assembly language units to be linked with
1655 the application. This pragma is currently supported only for the
1656 AAMP target and is ignored for other targets.
1657
1658 @node Pragma Export_Valued_Procedure
1659 @unnumberedsec Pragma Export_Valued_Procedure
1660 @findex Export_Valued_Procedure
1661 @noindent
1662 Syntax:
1663
1664 @smallexample @c ada
1665 pragma Export_Valued_Procedure (
1666      [Internal        =>] LOCAL_NAME
1667   [, [External        =>] EXTERNAL_SYMBOL]
1668   [, [Parameter_Types =>] PARAMETER_TYPES]
1669   [, [Mechanism       =>] MECHANISM]);
1670
1671 EXTERNAL_SYMBOL ::=
1672   IDENTIFIER
1673 | static_string_EXPRESSION
1674 | ""
1675
1676 PARAMETER_TYPES ::=
1677   null
1678 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1679
1680 TYPE_DESIGNATOR ::=
1681   subtype_NAME
1682 | subtype_Name ' Access
1683
1684 MECHANISM ::=
1685   MECHANISM_NAME
1686 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1687
1688 MECHANISM_ASSOCIATION ::=
1689   [formal_parameter_NAME =>] MECHANISM_NAME
1690
1691 MECHANISM_NAME ::=
1692   Value
1693 | Reference
1694 @end smallexample
1695
1696 @noindent
1697 This pragma is identical to @code{Export_Procedure} except that the
1698 first parameter of @var{local_name}, which must be present, must be of
1699 mode @code{OUT}, and externally the subprogram is treated as a function
1700 with this parameter as the result of the function.  GNAT provides for
1701 this capability to allow the use of @code{OUT} and @code{IN OUT}
1702 parameters in interfacing to external functions (which are not permitted
1703 in Ada functions).
1704 GNAT does not require a separate pragma @code{Export}, but if none is
1705 present, @code{Convention Ada} is assumed, which is almost certainly
1706 not what is wanted since the whole point of this pragma is to interface
1707 with foreign language functions, so it is usually appropriate to use this
1708 pragma in conjunction with a @code{Export} or @code{Convention}
1709 pragma that specifies the desired foreign convention.
1710
1711 @cindex OpenVMS
1712 @cindex Passing by descriptor
1713 Note that passing by descriptor is not supported, even on the OpenVMS
1714 ports of GNAT@.
1715
1716 @cindex Suppressing external name
1717 Special treatment is given if the EXTERNAL is an explicit null
1718 string or a static string expressions that evaluates to the null
1719 string. In this case, no external name is generated. This form
1720 still allows the specification of parameter mechanisms.
1721
1722 @node Pragma Extend_System
1723 @unnumberedsec Pragma Extend_System
1724 @cindex @code{system}, extending
1725 @cindex Dec Ada 83
1726 @findex Extend_System
1727 @noindent
1728 Syntax:
1729
1730 @smallexample @c ada
1731 pragma Extend_System ([Name =>] IDENTIFIER);
1732 @end smallexample
1733
1734 @noindent
1735 This pragma is used to provide backwards compatibility with other
1736 implementations that extend the facilities of package @code{System}.  In
1737 GNAT, @code{System} contains only the definitions that are present in
1738 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1739 implementation, provide many extensions to package @code{System}.
1740
1741 For each such implementation accommodated by this pragma, GNAT provides a
1742 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1743 implementation, which provides the required additional definitions.  You
1744 can use this package in two ways.  You can @code{with} it in the normal
1745 way and access entities either by selection or using a @code{use}
1746 clause.  In this case no special processing is required.
1747
1748 However, if existing code contains references such as
1749 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1750 definitions provided in package @code{System}, you may use this pragma
1751 to extend visibility in @code{System} in a non-standard way that
1752 provides greater compatibility with the existing code.  Pragma
1753 @code{Extend_System} is a configuration pragma whose single argument is
1754 the name of the package containing the extended definition
1755 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1756 control of this pragma will be processed using special visibility
1757 processing that looks in package @code{System.Aux_@var{xxx}} where
1758 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1759 package @code{System}, but not found in package @code{System}.
1760
1761 You can use this pragma either to access a predefined @code{System}
1762 extension supplied with the compiler, for example @code{Aux_DEC} or
1763 you can construct your own extension unit following the above
1764 definition.  Note that such a package is a child of @code{System}
1765 and thus is considered part of the implementation.  To compile
1766 it you will have to use the appropriate switch for compiling
1767 system units.  See the GNAT User's Guide for details.
1768
1769 @node Pragma External
1770 @unnumberedsec Pragma External
1771 @findex External
1772 @noindent
1773 Syntax:
1774
1775 @smallexample @c ada
1776 pragma External (
1777   [   Convention    =>] convention_IDENTIFIER,
1778   [   Entity        =>] local_NAME
1779   [, [External_Name =>] static_string_EXPRESSION ]
1780   [, [Link_Name     =>] static_string_EXPRESSION ]);
1781 @end smallexample
1782
1783 @noindent
1784 This pragma is identical in syntax and semantics to pragma
1785 @code{Export} as defined in the Ada Reference Manual.  It is
1786 provided for compatibility with some Ada 83 compilers that
1787 used this pragma for exactly the same purposes as pragma
1788 @code{Export} before the latter was standardized.
1789
1790 @node Pragma External_Name_Casing
1791 @unnumberedsec Pragma External_Name_Casing
1792 @cindex Dec Ada 83 casing compatibility
1793 @cindex External Names, casing
1794 @cindex Casing of External names
1795 @findex External_Name_Casing
1796 @noindent
1797 Syntax:
1798
1799 @smallexample @c ada
1800 pragma External_Name_Casing (
1801   Uppercase | Lowercase
1802   [, Uppercase | Lowercase | As_Is]);
1803 @end smallexample
1804
1805 @noindent
1806 This pragma provides control over the casing of external names associated
1807 with Import and Export pragmas.  There are two cases to consider:
1808
1809 @table @asis
1810 @item Implicit external names
1811 Implicit external names are derived from identifiers.  The most common case
1812 arises when a standard Ada 95 Import or Export pragma is used with only two
1813 arguments, as in:
1814
1815 @smallexample @c ada
1816    pragma Import (C, C_Routine);
1817 @end smallexample
1818
1819 @noindent
1820 Since Ada is a case insensitive language, the spelling of the identifier in
1821 the Ada source program does not provide any information on the desired
1822 casing of the external name, and so a convention is needed.  In GNAT the
1823 default treatment is that such names are converted to all lower case
1824 letters.  This corresponds to the normal C style in many environments.
1825 The first argument of pragma @code{External_Name_Casing} can be used to
1826 control this treatment.  If @code{Uppercase} is specified, then the name
1827 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1828 then the normal default of all lower case letters will be used.
1829
1830 This same implicit treatment is also used in the case of extended DEC Ada 83
1831 compatible Import and Export pragmas where an external name is explicitly
1832 specified using an identifier rather than a string.
1833
1834 @item Explicit external names
1835 Explicit external names are given as string literals.  The most common case
1836 arises when a standard Ada 95 Import or Export pragma is used with three
1837 arguments, as in:
1838
1839 @smallexample @c ada
1840 pragma Import (C, C_Routine, "C_routine");
1841 @end smallexample
1842
1843 @noindent
1844 In this case, the string literal normally provides the exact casing required
1845 for the external name.  The second argument of pragma
1846 @code{External_Name_Casing} may be used to modify this behavior.
1847 If @code{Uppercase} is specified, then the name
1848 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1849 then the name will be forced to all lowercase letters.  A specification of
1850 @code{As_Is} provides the normal default behavior in which the casing is
1851 taken from the string provided.
1852 @end table
1853
1854 @noindent
1855 This pragma may appear anywhere that a pragma is valid.  In particular, it
1856 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1857 case it applies to all subsequent compilations, or it can be used as a program
1858 unit pragma, in which case it only applies to the current unit, or it can
1859 be used more locally to control individual Import/Export pragmas.
1860
1861 It is primarily intended for use with OpenVMS systems, where many
1862 compilers convert all symbols to upper case by default.  For interfacing to
1863 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1864 the pragma:
1865
1866 @smallexample @c ada
1867 pragma External_Name_Casing (Uppercase, Uppercase);
1868 @end smallexample
1869
1870 @noindent
1871 to enforce the upper casing of all external symbols.
1872
1873 @node Pragma Finalize_Storage_Only
1874 @unnumberedsec Pragma Finalize_Storage_Only
1875 @findex Finalize_Storage_Only
1876 @noindent
1877 Syntax:
1878
1879 @smallexample @c ada
1880 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1881 @end smallexample
1882
1883 @noindent
1884 This pragma allows the compiler not to emit a Finalize call for objects
1885 defined at the library level.  This is mostly useful for types where
1886 finalization is only used to deal with storage reclamation since in most
1887 environments it is not necessary to reclaim memory just before terminating
1888 execution, hence the name.
1889
1890 @node Pragma Float_Representation
1891 @unnumberedsec Pragma Float_Representation
1892 @cindex OpenVMS
1893 @findex Float_Representation
1894 @noindent
1895 Syntax:
1896
1897 @smallexample @c ada
1898 pragma Float_Representation (FLOAT_REP);
1899
1900 FLOAT_REP ::= VAX_Float | IEEE_Float
1901 @end smallexample
1902
1903 @noindent
1904 This pragma
1905 allows control over the internal representation chosen for the predefined
1906 floating point types declared in the packages @code{Standard} and
1907 @code{System}. On all systems other than OpenVMS, the argument must
1908 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1909 argument may be @code{VAX_Float} to specify the use of the VAX float
1910 format for the floating-point types in Standard. This requires that
1911 the standard runtime libraries be recompiled. See the
1912 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1913 of the GNAT Users Guide for details on the use of this command.
1914
1915 @node Pragma Ident
1916 @unnumberedsec Pragma Ident
1917 @findex Ident
1918 @noindent
1919 Syntax:
1920
1921 @smallexample @c ada
1922 pragma Ident (static_string_EXPRESSION);
1923 @end smallexample
1924
1925 @noindent
1926 This pragma provides a string identification in the generated object file,
1927 if the system supports the concept of this kind of identification string.
1928 This pragma is allowed only in the outermost declarative part or
1929 declarative items of a compilation unit. If more than one @code{Ident}
1930 pragma is given, only the last one processed is effective.
1931 @cindex OpenVMS
1932 On OpenVMS systems, the effect of the pragma is identical to the effect of
1933 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1934 maximum allowed length is 31 characters, so if it is important to
1935 maintain compatibility with this compiler, you should obey this length
1936 limit.
1937
1938 @node Pragma Import_Exception
1939 @unnumberedsec Pragma Import_Exception
1940 @cindex OpenVMS
1941 @findex Import_Exception
1942 @noindent
1943 Syntax:
1944
1945 @smallexample @c ada
1946 pragma Import_Exception (
1947      [Internal =>] LOCAL_NAME,
1948   [, [External =>] EXTERNAL_SYMBOL,]
1949   [, [Form     =>] Ada | VMS]
1950   [, [Code     =>] static_integer_EXPRESSION]);
1951
1952 EXTERNAL_SYMBOL ::=
1953   IDENTIFIER
1954 | static_string_EXPRESSION
1955 @end smallexample
1956
1957 @noindent
1958 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1959 It allows OpenVMS conditions (for example, from OpenVMS system services or
1960 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1961 The pragma specifies that the exception associated with an exception
1962 declaration in an Ada program be defined externally (in non-Ada code).
1963 For further details on this pragma, see the
1964 DEC Ada Language Reference Manual, section 13.9a.3.1.
1965
1966 @node Pragma Import_Function
1967 @unnumberedsec Pragma Import_Function
1968 @findex Import_Function
1969 @noindent
1970 Syntax:
1971
1972 @smallexample @c ada
1973 pragma Import_Function (
1974      [Internal                 =>] LOCAL_NAME,
1975   [, [External                 =>] EXTERNAL_SYMBOL]
1976   [, [Parameter_Types          =>] PARAMETER_TYPES]
1977   [, [Result_Type              =>] SUBTYPE_MARK]
1978   [, [Mechanism                =>] MECHANISM]
1979   [, [Result_Mechanism         =>] MECHANISM_NAME]
1980   [, [First_Optional_Parameter =>] IDENTIFIER]);
1981
1982 EXTERNAL_SYMBOL ::=
1983   IDENTIFIER
1984 | static_string_EXPRESSION
1985
1986 PARAMETER_TYPES ::=
1987   null
1988 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1989
1990 TYPE_DESIGNATOR ::=
1991   subtype_NAME
1992 | subtype_Name ' Access
1993
1994 MECHANISM ::=
1995   MECHANISM_NAME
1996 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1997
1998 MECHANISM_ASSOCIATION ::=
1999   [formal_parameter_NAME =>] MECHANISM_NAME
2000
2001 MECHANISM_NAME ::=
2002   Value
2003 | Reference
2004 | Descriptor [([Class =>] CLASS_NAME)]
2005
2006 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2007 @end smallexample
2008
2009 @noindent
2010 This pragma is used in conjunction with a pragma @code{Import} to
2011 specify additional information for an imported function.  The pragma
2012 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2013 @code{Import_Function} pragma and both must appear in the same
2014 declarative part as the function specification.
2015
2016 The @var{Internal} argument must uniquely designate
2017 the function to which the
2018 pragma applies.  If more than one function name exists of this name in
2019 the declarative part you must use the @code{Parameter_Types} and
2020 @var{Result_Type} parameters to achieve the required unique
2021 designation.  Subtype marks in these parameters must exactly match the
2022 subtypes in the corresponding function specification, using positional
2023 notation to match parameters with subtype marks.
2024 The form with an @code{'Access} attribute can be used to match an
2025 anonymous access parameter.
2026
2027 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2028 parameters to specify passing mechanisms for the
2029 parameters and result.  If you specify a single mechanism name, it
2030 applies to all parameters.  Otherwise you may specify a mechanism on a
2031 parameter by parameter basis using either positional or named
2032 notation.  If the mechanism is not specified, the default mechanism
2033 is used.
2034
2035 @cindex OpenVMS
2036 @cindex Passing by descriptor
2037 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2038
2039 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2040 It specifies that the designated parameter and all following parameters
2041 are optional, meaning that they are not passed at the generated code
2042 level (this is distinct from the notion of optional parameters in Ada
2043 where the parameters are passed anyway with the designated optional
2044 parameters).  All optional parameters must be of mode @code{IN} and have
2045 default parameter values that are either known at compile time
2046 expressions, or uses of the @code{'Null_Parameter} attribute.
2047
2048 @node Pragma Import_Object
2049 @unnumberedsec Pragma Import_Object
2050 @findex Import_Object
2051 @noindent
2052 Syntax:
2053
2054 @smallexample @c ada
2055 pragma Import_Object
2056      [Internal =>] LOCAL_NAME,
2057   [, [External =>] EXTERNAL_SYMBOL],
2058   [, [Size     =>] EXTERNAL_SYMBOL]);
2059
2060 EXTERNAL_SYMBOL ::=
2061   IDENTIFIER
2062 | static_string_EXPRESSION
2063 @end smallexample
2064
2065 @noindent
2066 This pragma designates an object as imported, and apart from the
2067 extended rules for external symbols, is identical in effect to the use of
2068 the normal @code{Import} pragma applied to an object.  Unlike the
2069 subprogram case, you need not use a separate @code{Import} pragma,
2070 although you may do so (and probably should do so from a portability
2071 point of view).  @var{size} is syntax checked, but otherwise ignored by
2072 GNAT@.
2073
2074 @node Pragma Import_Procedure
2075 @unnumberedsec Pragma Import_Procedure
2076 @findex Import_Procedure
2077 @noindent
2078 Syntax:
2079
2080 @smallexample @c ada
2081 pragma Import_Procedure (
2082      [Internal                 =>] LOCAL_NAME,
2083   [, [External                 =>] EXTERNAL_SYMBOL]
2084   [, [Parameter_Types          =>] PARAMETER_TYPES]
2085   [, [Mechanism                =>] MECHANISM]
2086   [, [First_Optional_Parameter =>] IDENTIFIER]);
2087
2088 EXTERNAL_SYMBOL ::=
2089   IDENTIFIER
2090 | static_string_EXPRESSION
2091
2092 PARAMETER_TYPES ::=
2093   null
2094 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2095
2096 TYPE_DESIGNATOR ::=
2097   subtype_NAME
2098 | subtype_Name ' Access
2099
2100 MECHANISM ::=
2101   MECHANISM_NAME
2102 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2103
2104 MECHANISM_ASSOCIATION ::=
2105   [formal_parameter_NAME =>] MECHANISM_NAME
2106
2107 MECHANISM_NAME ::=
2108   Value
2109 | Reference
2110 | Descriptor [([Class =>] CLASS_NAME)]
2111
2112 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2113 @end smallexample
2114
2115 @noindent
2116 This pragma is identical to @code{Import_Function} except that it
2117 applies to a procedure rather than a function and the parameters
2118 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2119
2120 @node Pragma Import_Valued_Procedure
2121 @unnumberedsec Pragma Import_Valued_Procedure
2122 @findex Import_Valued_Procedure
2123 @noindent
2124 Syntax:
2125
2126 @smallexample @c ada
2127 pragma Import_Valued_Procedure (
2128      [Internal                 =>] LOCAL_NAME,
2129   [, [External                 =>] EXTERNAL_SYMBOL]
2130   [, [Parameter_Types          =>] PARAMETER_TYPES]
2131   [, [Mechanism                =>] MECHANISM]
2132   [, [First_Optional_Parameter =>] IDENTIFIER]);
2133
2134 EXTERNAL_SYMBOL ::=
2135   IDENTIFIER
2136 | static_string_EXPRESSION
2137
2138 PARAMETER_TYPES ::=
2139   null
2140 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2141
2142 TYPE_DESIGNATOR ::=
2143   subtype_NAME
2144 | subtype_Name ' Access
2145
2146 MECHANISM ::=
2147   MECHANISM_NAME
2148 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2149
2150 MECHANISM_ASSOCIATION ::=
2151   [formal_parameter_NAME =>] MECHANISM_NAME
2152
2153 MECHANISM_NAME ::=
2154   Value
2155 | Reference
2156 | Descriptor [([Class =>] CLASS_NAME)]
2157
2158 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2159 @end smallexample
2160
2161 @noindent
2162 This pragma is identical to @code{Import_Procedure} except that the
2163 first parameter of @var{local_name}, which must be present, must be of
2164 mode @code{OUT}, and externally the subprogram is treated as a function
2165 with this parameter as the result of the function.  The purpose of this
2166 capability is to allow the use of @code{OUT} and @code{IN OUT}
2167 parameters in interfacing to external functions (which are not permitted
2168 in Ada functions).  You may optionally use the @code{Mechanism}
2169 parameters to specify passing mechanisms for the parameters.
2170 If you specify a single mechanism name, it applies to all parameters.
2171 Otherwise you may specify a mechanism on a parameter by parameter
2172 basis using either positional or named notation.  If the mechanism is not
2173 specified, the default mechanism is used.
2174
2175 Note that it is important to use this pragma in conjunction with a separate
2176 pragma Import that specifies the desired convention, since otherwise the
2177 default convention is Ada, which is almost certainly not what is required.
2178
2179 @node Pragma Initialize_Scalars
2180 @unnumberedsec Pragma Initialize_Scalars
2181 @findex Initialize_Scalars
2182 @cindex debugging with Initialize_Scalars
2183 @noindent
2184 Syntax:
2185
2186 @smallexample @c ada
2187 pragma Initialize_Scalars;
2188 @end smallexample
2189
2190 @noindent
2191 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2192 two important differences.  First, there is no requirement for the pragma
2193 to be used uniformly in all units of a partition, in particular, it is fine
2194 to use this just for some or all of the application units of a partition,
2195 without needing to recompile the run-time library.
2196
2197 In the case where some units are compiled with the pragma, and some without,
2198 then a declaration of a variable where the type is defined in package
2199 Standard or is locally declared will always be subject to initialization,
2200 as will any declaration of a scalar variable.  For composite variables,
2201 whether the variable is initialized may also depend on whether the package
2202 in which the type of the variable is declared is compiled with the pragma.
2203
2204 The other important difference is that there is control over the value used
2205 for initializing scalar objects.  At bind time, you can select whether to
2206 initialize with invalid values (like Normalize_Scalars), or with high or
2207 low values, or with a specified bit pattern.  See the users guide for binder
2208 options for specifying these cases.
2209
2210 This means that you can compile a program, and then without having to
2211 recompile the program, you can run it with different values being used
2212 for initializing otherwise uninitialized values, to test if your program
2213 behavior depends on the choice.  Of course the behavior should not change,
2214 and if it does, then most likely you have an erroneous reference to an
2215 uninitialized value.
2216
2217 Note that pragma @code{Initialize_Scalars} is particularly useful in
2218 conjunction with the enhanced validity checking that is now provided
2219 in GNAT, which checks for invalid values under more conditions.
2220 Using this feature (see description of the @code{-gnatV} flag in the
2221 users guide) in conjunction with pragma @code{Initialize_Scalars}
2222 provides a powerful new tool to assist in the detection of problems
2223 caused by uninitialized variables.
2224
2225 @node Pragma Inline_Always
2226 @unnumberedsec Pragma Inline_Always
2227 @findex Inline_Always
2228 @noindent
2229 Syntax:
2230
2231 @smallexample @c ada
2232 pragma Inline_Always (NAME [, NAME]);
2233 @end smallexample
2234
2235 @noindent
2236 Similar to pragma @code{Inline} except that inlining is not subject to
2237 the use of option @code{-gnatn} and the inlining happens regardless of
2238 whether this option is used.
2239
2240 @node Pragma Inline_Generic
2241 @unnumberedsec Pragma Inline_Generic
2242 @findex Inline_Generic
2243 @noindent
2244 Syntax:
2245
2246 @smallexample @c ada
2247 pragma Inline_Generic (generic_package_NAME);
2248 @end smallexample
2249
2250 @noindent
2251 This is implemented for compatibility with DEC Ada 83 and is recognized,
2252 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2253 by default when using GNAT@.
2254
2255 @node Pragma Interface
2256 @unnumberedsec Pragma Interface
2257 @findex Interface
2258 @noindent
2259 Syntax:
2260
2261 @smallexample @c ada
2262 pragma Interface (
2263      [Convention    =>] convention_identifier,
2264      [Entity =>] local_name
2265   [, [External_Name =>] static_string_expression],
2266   [, [Link_Name     =>] static_string_expression]);
2267 @end smallexample
2268
2269 @noindent
2270 This pragma is identical in syntax and semantics to
2271 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2272 with Ada 83.  The definition is upwards compatible both with pragma
2273 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2274 with some extended implementations of this pragma in certain Ada 83
2275 implementations.
2276
2277 @node Pragma Interface_Name
2278 @unnumberedsec Pragma Interface_Name
2279 @findex Interface_Name
2280 @noindent
2281 Syntax:
2282
2283 @smallexample @c ada
2284 pragma Interface_Name (
2285      [Entity        =>] LOCAL_NAME
2286   [, [External_Name =>] static_string_EXPRESSION]
2287   [, [Link_Name     =>] static_string_EXPRESSION]);
2288 @end smallexample
2289
2290 @noindent
2291 This pragma provides an alternative way of specifying the interface name
2292 for an interfaced subprogram, and is provided for compatibility with Ada
2293 83 compilers that use the pragma for this purpose.  You must provide at
2294 least one of @var{External_Name} or @var{Link_Name}.
2295
2296 @node Pragma Interrupt_Handler
2297 @unnumberedsec Pragma Interrupt_Handler
2298 @findex Interrupt_Handler
2299 @noindent
2300 Syntax:
2301
2302 @smallexample @c ada
2303 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2304 @end smallexample
2305
2306 @noindent
2307 This program unit pragma is supported for parameterless protected procedures
2308 as described in Annex C of the Ada Reference Manual. On the AAMP target
2309 the pragma can also be specified for nonprotected parameterless procedures
2310 that are declared at the library level (which includes procedures
2311 declared at the top level of a library package). In the case of AAMP,
2312 when this pragma is applied to a nonprotected procedure, the instruction
2313 @code{IERET} is generated for returns from the procedure, enabling
2314 maskable interrupts, in place of the normal return instruction.
2315
2316 @node Pragma Interrupt_State
2317 @unnumberedsec Pragma Interrupt_State
2318 @findex Interrupt_State
2319 @noindent
2320 Syntax:
2321
2322 @smallexample @c ada
2323 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2324 @end smallexample
2325
2326 @noindent
2327 Normally certain interrupts are reserved to the implementation.  Any attempt
2328 to attach an interrupt causes Program_Error to be raised, as described in
2329 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2330 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2331 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2332 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2333 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2334 Ada exceptions, or used to implement run-time functions such as the
2335 @code{abort} statement and stack overflow checking.
2336
2337 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2338 such uses of interrupts.  It subsumes the functionality of pragma
2339 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2340 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2341 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2342 and may be used to mark interrupts required by the board support package
2343 as reserved.
2344
2345 Interrupts can be in one of three states:
2346 @itemize @bullet
2347 @item System
2348
2349 The interrupt is reserved (no Ada handler can be installed), and the
2350 Ada run-time may not install a handler. As a result you are guaranteed
2351 standard system default action if this interrupt is raised.
2352
2353 @item Runtime
2354
2355 The interrupt is reserved (no Ada handler can be installed). The run time
2356 is allowed to install a handler for internal control purposes, but is
2357 not required to do so.
2358
2359 @item User
2360
2361 The interrupt is unreserved.  The user may install a handler to provide
2362 some other action.
2363 @end itemize
2364
2365 @noindent
2366 These states are the allowed values of the @code{State} parameter of the
2367 pragma.  The @code{Name} parameter is a value of the type
2368 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2369 @code{Ada.Interrupts.Names}.
2370
2371 This is a configuration pragma, and the binder will check that there
2372 are no inconsistencies between different units in a partition in how a
2373 given interrupt is specified. It may appear anywhere a pragma is legal.
2374
2375 The effect is to move the interrupt to the specified state.
2376
2377 By declaring interrupts to be SYSTEM, you guarantee the standard system
2378 action, such as a core dump.
2379
2380 By declaring interrupts to be USER, you guarantee that you can install
2381 a handler.
2382
2383 Note that certain signals on many operating systems cannot be caught and
2384 handled by applications.  In such cases, the pragma is ignored.  See the
2385 operating system documentation, or the value of the array @code{Reserved}
2386 declared in the specification of package @code{System.OS_Interface}.
2387
2388 Overriding the default state of signals used by the Ada runtime may interfere
2389 with an application's runtime behavior in the cases of the synchronous signals,
2390 and in the case of the signal used to implement the @code{abort} statement.
2391
2392 @node Pragma Keep_Names
2393 @unnumberedsec Pragma Keep_Names
2394 @findex Keep_Names
2395 @noindent
2396 Syntax:
2397
2398 @smallexample @c ada
2399 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2400 @end smallexample
2401
2402 @noindent
2403 The @var{LOCAL_NAME} argument
2404 must refer to an enumeration first subtype
2405 in the current declarative part. The effect is to retain the enumeration
2406 literal names for use by @code{Image} and @code{Value} even if a global
2407 @code{Discard_Names} pragma applies. This is useful when you want to
2408 generally suppress enumeration literal names and for example you therefore
2409 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2410 want to retain the names for specific enumeration types.
2411
2412 @node Pragma License
2413 @unnumberedsec Pragma License
2414 @findex License
2415 @cindex License checking
2416 @noindent
2417 Syntax:
2418
2419 @smallexample @c ada
2420 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2421 @end smallexample
2422
2423 @noindent
2424 This pragma is provided to allow automated checking for appropriate license
2425 conditions with respect to the standard and modified GPL@.  A pragma
2426 @code{License}, which is a configuration pragma that typically appears at
2427 the start of a source file or in a separate @file{gnat.adc} file, specifies
2428 the licensing conditions of a unit as follows:
2429
2430 @itemize @bullet
2431 @item Unrestricted
2432 This is used for a unit that can be freely used with no license restrictions.
2433 Examples of such units are public domain units, and units from the Ada
2434 Reference Manual.
2435
2436 @item GPL
2437 This is used for a unit that is licensed under the unmodified GPL, and which
2438 therefore cannot be @code{with}'ed by a restricted unit.
2439
2440 @item Modified_GPL
2441 This is used for a unit licensed under the GNAT modified GPL that includes
2442 a special exception paragraph that specifically permits the inclusion of
2443 the unit in programs without requiring the entire program to be released
2444 under the GPL@.  This is the license used for the GNAT run-time which ensures
2445 that the run-time can be used freely in any program without GPL concerns.
2446
2447 @item Restricted
2448 This is used for a unit that is restricted in that it is not permitted to
2449 depend on units that are licensed under the GPL@.  Typical examples are
2450 proprietary code that is to be released under more restrictive license
2451 conditions.  Note that restricted units are permitted to @code{with} units
2452 which are licensed under the modified GPL (this is the whole point of the
2453 modified GPL).
2454
2455 @end itemize
2456
2457 @noindent
2458 Normally a unit with no @code{License} pragma is considered to have an
2459 unknown license, and no checking is done.  However, standard GNAT headers
2460 are recognized, and license information is derived from them as follows.
2461
2462 @itemize @bullet
2463
2464 A GNAT license header starts with a line containing 78 hyphens.  The following
2465 comment text is searched for the appearance of any of the following strings.
2466
2467 If the string ``GNU General Public License'' is found, then the unit is assumed
2468 to have GPL license, unless the string ``As a special exception'' follows, in
2469 which case the license is assumed to be modified GPL@.
2470
2471 If one of the strings
2472 ``This specification is adapted from the Ada Semantic Interface'' or
2473 ``This specification is derived from the Ada Reference Manual'' is found
2474 then the unit is assumed to be unrestricted.
2475 @end itemize
2476
2477 @noindent
2478 These default actions means that a program with a restricted license pragma
2479 will automatically get warnings if a GPL unit is inappropriately
2480 @code{with}'ed.  For example, the program:
2481
2482 @smallexample @c ada
2483 with Sem_Ch3;
2484 with GNAT.Sockets;
2485 procedure Secret_Stuff is
2486   @dots{}
2487 end Secret_Stuff
2488 @end smallexample
2489
2490 @noindent
2491 if compiled with pragma @code{License} (@code{Restricted}) in a
2492 @file{gnat.adc} file will generate the warning:
2493
2494 @smallexample
2495 1.  with Sem_Ch3;
2496         |
2497    >>> license of withed unit "Sem_Ch3" is incompatible
2498
2499 2.  with GNAT.Sockets;
2500 3.  procedure Secret_Stuff is
2501 @end smallexample
2502
2503 @noindent
2504 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2505 compiler and is licensed under the
2506 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2507 run time, and is therefore licensed under the modified GPL@.
2508
2509 @node Pragma Link_With
2510 @unnumberedsec Pragma Link_With
2511 @findex Link_With
2512 @noindent
2513 Syntax:
2514
2515 @smallexample @c ada
2516 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2517 @end smallexample
2518
2519 @noindent
2520 This pragma is provided for compatibility with certain Ada 83 compilers.
2521 It has exactly the same effect as pragma @code{Linker_Options} except
2522 that spaces occurring within one of the string expressions are treated
2523 as separators. For example, in the following case:
2524
2525 @smallexample @c ada
2526 pragma Link_With ("-labc -ldef");
2527 @end smallexample
2528
2529 @noindent
2530 results in passing the strings @code{-labc} and @code{-ldef} as two
2531 separate arguments to the linker. In addition pragma Link_With allows
2532 multiple arguments, with the same effect as successive pragmas.
2533
2534 @node Pragma Linker_Alias
2535 @unnumberedsec Pragma Linker_Alias
2536 @findex Linker_Alias
2537 @noindent
2538 Syntax:
2539
2540 @smallexample @c ada
2541 pragma Linker_Alias (
2542   [Entity =>] LOCAL_NAME
2543   [Alias  =>] static_string_EXPRESSION);
2544 @end smallexample
2545
2546 @noindent
2547 This pragma establishes a linker alias for the given named entity.  For
2548 further details on the exact effect, consult the GCC manual.
2549
2550 @node Pragma Linker_Section
2551 @unnumberedsec Pragma Linker_Section
2552 @findex Linker_Section
2553 @noindent
2554 Syntax:
2555
2556 @smallexample @c ada
2557 pragma Linker_Section (
2558   [Entity  =>] LOCAL_NAME
2559   [Section =>] static_string_EXPRESSION);
2560 @end smallexample
2561
2562 @noindent
2563 This pragma specifies the name of the linker section for the given entity.
2564 For further details on the exact effect, consult the GCC manual.
2565
2566 @node Pragma Long_Float
2567 @unnumberedsec Pragma Long_Float
2568 @cindex OpenVMS
2569 @findex Long_Float
2570 @noindent
2571 Syntax:
2572
2573 @smallexample @c ada
2574 pragma Long_Float (FLOAT_FORMAT);
2575
2576 FLOAT_FORMAT ::= D_Float | G_Float
2577 @end smallexample
2578
2579 @noindent
2580 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2581 It allows control over the internal representation chosen for the predefined
2582 type @code{Long_Float} and for floating point type representations with
2583 @code{digits} specified in the range 7 through 15.
2584 For further details on this pragma, see the
2585 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2586 this pragma, the standard runtime libraries must be recompiled.  See the
2587 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2588 of the GNAT User's Guide for details on the use of this command.
2589
2590 @node Pragma Machine_Attribute
2591 @unnumberedsec Pragma Machine_Attribute
2592 @findex Machine_Attribute
2593 @noindent
2594 Syntax:
2595
2596 @smallexample @c ada
2597 pragma Machine_Attribute (
2598   [Attribute_Name =>] string_EXPRESSION,
2599   [Entity         =>] LOCAL_NAME);
2600 @end smallexample
2601
2602 @noindent
2603 Machine dependent attributes can be specified for types and/or
2604 declarations.  Currently only subprogram entities are supported.  This
2605 pragma is semantically equivalent to
2606 @code{__attribute__((@var{string_expression}))} in GNU C,
2607 where @code{@var{string_expression}} is
2608 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2609 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2610 configuration header file @file{tm.h} for each machine.  See the GCC
2611 manual for further information.
2612
2613 @node Pragma Main_Storage
2614 @unnumberedsec Pragma Main_Storage
2615 @cindex OpenVMS
2616 @findex Main_Storage
2617 @noindent
2618 Syntax:
2619
2620 @smallexample @c ada
2621 pragma Main_Storage
2622   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2623
2624 MAIN_STORAGE_OPTION ::=
2625   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2626 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2627
2628 @end smallexample
2629
2630 @noindent
2631 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2632 no effect in GNAT, other than being syntax checked.  Note that the pragma
2633 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2634
2635 @node Pragma No_Return
2636 @unnumberedsec Pragma No_Return
2637 @findex No_Return
2638 @noindent
2639 Syntax:
2640
2641 @smallexample @c ada
2642 pragma No_Return (procedure_LOCAL_NAME);
2643 @end smallexample
2644
2645 @noindent
2646 @var{procedure_local_NAME} must refer to one or more procedure
2647 declarations in the current declarative part.  A procedure to which this
2648 pragma is applied may not contain any explicit @code{return} statements,
2649 and also may not contain any implicit return statements from falling off
2650 the end of a statement sequence.  One use of this pragma is to identify
2651 procedures whose only purpose is to raise an exception.
2652
2653 Another use of this pragma is to suppress incorrect warnings about
2654 missing returns in functions, where the last statement of a function
2655 statement sequence is a call to such a procedure.
2656
2657 @node Pragma Normalize_Scalars
2658 @unnumberedsec Pragma Normalize_Scalars
2659 @findex Normalize_Scalars
2660 @noindent
2661 Syntax:
2662
2663 @smallexample @c ada
2664 pragma Normalize_Scalars;
2665 @end smallexample
2666
2667 @noindent
2668 This is a language defined pragma which is fully implemented in GNAT@.  The
2669 effect is to cause all scalar objects that are not otherwise initialized
2670 to be initialized.  The initial values are implementation dependent and
2671 are as follows:
2672
2673 @table @code
2674 @item Standard.Character
2675 @noindent
2676 Objects whose root type is Standard.Character are initialized to
2677 Character'Last.  This will be out of range of the subtype only if
2678 the subtype range excludes this value.
2679
2680 @item Standard.Wide_Character
2681 @noindent
2682 Objects whose root type is Standard.Wide_Character are initialized to
2683 Wide_Character'Last.  This will be out of range of the subtype only if
2684 the subtype range excludes this value.
2685
2686 @item Integer types
2687 @noindent
2688 Objects of an integer type are initialized to base_type'First, where
2689 base_type is the base type of the object type.  This will be out of range
2690 of the subtype only if the subtype range excludes this value.  For example,
2691 if you declare the subtype:
2692
2693 @smallexample @c ada
2694 subtype Ityp is integer range 1 .. 10;
2695 @end smallexample
2696
2697 @noindent
2698 then objects of type x will be initialized to Integer'First, a negative
2699 number that is certainly outside the range of subtype @code{Ityp}.
2700
2701 @item Real types
2702 Objects of all real types (fixed and floating) are initialized to
2703 base_type'First, where base_Type is the base type of the object type.
2704 This will be out of range of the subtype only if the subtype range
2705 excludes this value.
2706
2707 @item Modular types
2708 Objects of a modular type are initialized to typ'Last.  This will be out
2709 of range of the subtype only if the subtype excludes this value.
2710
2711 @item Enumeration types
2712 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2713 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2714 enumeration subtype in all cases except where the subtype contains
2715 exactly 2**8, 2**16, or 2**32 elements.
2716
2717 @end table
2718
2719 @node Pragma Obsolescent
2720 @unnumberedsec Pragma Obsolescent
2721 @findex Obsolescent
2722 @noindent
2723 Syntax:
2724
2725 @smallexample @c ada
2726 pragma Obsolescent [(static_string_EXPRESSION)];
2727 @end smallexample
2728
2729 @noindent
2730 This pragma must occur immediately following a subprogram
2731 declaration. It indicates that the associated function or procedure
2732 is considered obsolescent and should not be used. Typically this is
2733 used when an API must be modified by eventually removing or modifying
2734 existing subprograms. The pragma can be used at an intermediate stage
2735 when the subprogram is still present, but will be removed later.
2736
2737 The effect of this pragma is to output a warning message that the
2738 subprogram is obsolescent if the appropriate warning option in the
2739 compiler is activated. If a parameter is present, then a second
2740 warning message is given containing this text.
2741
2742 @node Pragma Passive
2743 @unnumberedsec Pragma Passive
2744 @findex Passive
2745 @noindent
2746 Syntax:
2747
2748 @smallexample @c ada
2749 pragma Passive ([Semaphore | No]);
2750 @end smallexample
2751
2752 @noindent
2753 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2754 compatibility with DEC Ada 83 implementations, where it is used within a
2755 task definition to request that a task be made passive.  If the argument
2756 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2757 treats the pragma as an assertion that the containing task is passive
2758 and that optimization of context switch with this task is permitted and
2759 desired.  If the argument @code{No} is present, the task must not be
2760 optimized.  GNAT does not attempt to optimize any tasks in this manner
2761 (since protected objects are available in place of passive tasks).
2762
2763 @node Pragma Polling
2764 @unnumberedsec Pragma Polling
2765 @findex Polling
2766 @noindent
2767 Syntax:
2768
2769 @smallexample @c ada
2770 pragma Polling (ON | OFF);
2771 @end smallexample
2772
2773 @noindent
2774 This pragma controls the generation of polling code.  This is normally off.
2775 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2776 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2777 runtime library, and can be found in file @file{a-excpol.adb}.
2778
2779 Pragma @code{Polling} can appear as a configuration pragma (for example it
2780 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2781 can be used in the statement or declaration sequence to control polling
2782 more locally.
2783
2784 A call to the polling routine is generated at the start of every loop and
2785 at the start of every subprogram call.  This guarantees that the @code{Poll}
2786 routine is called frequently, and places an upper bound (determined by
2787 the complexity of the code) on the period between two @code{Poll} calls.
2788
2789 The primary purpose of the polling interface is to enable asynchronous
2790 aborts on targets that cannot otherwise support it (for example Windows
2791 NT), but it may be used for any other purpose requiring periodic polling.
2792 The standard version is null, and can be replaced by a user program.  This
2793 will require re-compilation of the @code{Ada.Exceptions} package that can
2794 be found in files @file{a-except.ads} and @file{a-except.adb}.
2795
2796 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2797 distribution) is used to enable the asynchronous abort capability on
2798 targets that do not normally support the capability.  The version of
2799 @code{Poll} in this file makes a call to the appropriate runtime routine
2800 to test for an abort condition.
2801
2802 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2803 the @cite{GNAT User's Guide} for details.
2804
2805 @node Pragma Propagate_Exceptions
2806 @unnumberedsec Pragma Propagate_Exceptions
2807 @findex Propagate_Exceptions
2808 @cindex Zero Cost Exceptions
2809 @noindent
2810 Syntax:
2811
2812 @smallexample @c ada
2813 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2814 @end smallexample
2815
2816 @noindent
2817 This pragma indicates that the given entity, which is the name of an
2818 imported foreign-language subprogram may receive an Ada exception,
2819 and that the exception should be propagated.  It is relevant only if
2820 zero cost exception handling is in use, and is thus never needed if
2821 the alternative @code{longjmp} / @code{setjmp} implementation of
2822 exceptions is used (although it is harmless to use it in such cases).
2823
2824 The implementation of fast exceptions always properly propagates
2825 exceptions through Ada code, as described in the Ada Reference Manual.
2826 However, this manual is silent about the propagation of exceptions
2827 through foreign code.  For example, consider the
2828 situation where @code{P1} calls
2829 @code{P2}, and @code{P2} calls @code{P3}, where
2830 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2831 @code{P3} raises an Ada exception.  The question is whether or not
2832 it will be propagated through @code{P2} and can be handled in
2833 @code{P1}.
2834
2835 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
2836 the answer is always yes.  For some targets on which zero cost exception
2837 handling is implemented, the answer is also always yes.  However, there
2838 are some targets, notably in the current version all x86 architecture
2839 targets, in which the answer is that such propagation does not
2840 happen automatically.  If such propagation is required on these
2841 targets, it is mandatory to use @code{Propagate_Exceptions} to
2842 name all foreign language routines through which Ada exceptions
2843 may be propagated.
2844
2845 @node Pragma Psect_Object
2846 @unnumberedsec Pragma Psect_Object
2847 @findex Psect_Object
2848 @noindent
2849 Syntax:
2850
2851 @smallexample @c ada
2852 pragma Psect_Object (
2853      [Internal =>] LOCAL_NAME,
2854   [, [External =>] EXTERNAL_SYMBOL]
2855   [, [Size     =>] EXTERNAL_SYMBOL]);
2856
2857 EXTERNAL_SYMBOL ::=
2858   IDENTIFIER
2859 | static_string_EXPRESSION
2860 @end smallexample
2861
2862 @noindent
2863 This pragma is identical in effect to pragma @code{Common_Object}.
2864
2865 @node Pragma Pure_Function
2866 @unnumberedsec Pragma Pure_Function
2867 @findex Pure_Function
2868 @noindent
2869 Syntax:
2870
2871 @smallexample @c ada
2872 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
2873 @end smallexample
2874
2875 @noindent
2876 This pragma appears in the same declarative part as a function
2877 declaration (or a set of function declarations if more than one
2878 overloaded declaration exists, in which case the pragma applies
2879 to all entities).  It specifies that the function @code{Entity} is
2880 to be considered pure for the purposes of code generation.  This means
2881 that the compiler can assume that there are no side effects, and
2882 in particular that two calls with identical arguments produce the
2883 same result.  It also means that the function can be used in an
2884 address clause.
2885
2886 Note that, quite deliberately, there are no static checks to try
2887 to ensure that this promise is met, so @code{Pure_Function} can be used
2888 with functions that are conceptually pure, even if they do modify
2889 global variables.  For example, a square root function that is
2890 instrumented to count the number of times it is called is still
2891 conceptually pure, and can still be optimized, even though it
2892 modifies a global variable (the count).  Memo functions are another
2893 example (where a table of previous calls is kept and consulted to
2894 avoid re-computation).
2895
2896 @findex Pure
2897 Note: Most functions in a @code{Pure} package are automatically pure, and
2898 there is no need to use pragma @code{Pure_Function} for such functions.  One
2899 exception is any function that has at least one formal of type
2900 @code{System.Address} or a type derived from it.  Such functions are not
2901 considered pure by default, since the compiler assumes that the
2902 @code{Address} parameter may be functioning as a pointer and that the
2903 referenced data may change even if the address value does not.
2904 Similarly, imported functions are not considered to be pure by default,
2905 since there is no way of checking that they are in fact pure.  The use
2906 of pragma @code{Pure_Function} for such a function will override these default
2907 assumption, and cause the compiler to treat a designated subprogram as pure
2908 in these cases.
2909
2910 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
2911 applies to the underlying renamed function.  This can be used to
2912 disambiguate cases of overloading where some but not all functions
2913 in a set of overloaded functions are to be designated as pure.
2914
2915 @node Pragma Ravenscar
2916 @unnumberedsec Pragma Ravenscar
2917 @findex Ravenscar
2918 @noindent
2919 Syntax:
2920
2921 @smallexample @c ada
2922 pragma Ravenscar;
2923 @end smallexample
2924
2925 @noindent
2926 A configuration pragma that establishes the following set of restrictions:
2927
2928 @table @code
2929 @item No_Abort_Statements
2930 [RM D.7] There are no abort_statements, and there are
2931 no calls to Task_Identification.Abort_Task.
2932
2933 @item No_Select_Statements
2934 There are no select_statements.
2935
2936 @item No_Task_Hierarchy
2937 [RM D.7] All (non-environment) tasks depend
2938 directly on the environment task of the partition.
2939
2940 @item No_Task_Allocators
2941 [RM D.7] There are no allocators for task types
2942 or types containing task subcomponents.
2943
2944 @item No_Dynamic_Priorities
2945 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2946
2947 @item No_Terminate_Alternatives
2948 [RM D.7] There are no selective_accepts with terminate_alternatives
2949
2950 @item No_Dynamic_Interrupts
2951 There are no semantic dependencies on Ada.Interrupts.
2952
2953 @item No_Implicit_Heap_Allocations
2954 [RM D.7] No constructs are allowed to cause implicit heap allocation
2955
2956 @item No_Protected_Type_Allocators
2957 There are no allocators for protected types or
2958 types containing protected subcomponents.
2959
2960 @item No_Local_Protected_Objects
2961 Protected objects and access types that designate
2962 such objects shall be declared only at library level.
2963
2964 @item No_Requeue_Statements
2965 Requeue statements are not allowed.
2966
2967 @item No_Calendar
2968 There are no semantic dependencies on the package Ada.Calendar.
2969
2970 @item No_Relative_Delay
2971 There are no delay_relative_statements.
2972
2973 @item No_Task_Attributes
2974 There are no semantic dependencies on the Ada.Task_Attributes package and
2975 there are no references to the attributes Callable and Terminated [RM 9.9].
2976
2977 @item Boolean_Entry_Barriers
2978 Entry barrier condition expressions shall be boolean
2979 objects which are declared in the protected type
2980 which contains the entry.
2981
2982 @item Max_Asynchronous_Select_Nesting = 0
2983 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous_selects.
2984 A value of zero prevents the use of any asynchronous_select.
2985
2986 @item Max_Task_Entries = 0
2987 [RM D.7] Specifies the maximum number of entries
2988 per task.  The bounds of every entry family
2989 of a task unit shall be static, or shall be
2990 defined by a discriminant of a subtype whose
2991 corresponding bound is static.  A value of zero
2992 indicates that no rendezvous are possible.  For
2993 the Ravenscar pragma, the value of Max_Task_Entries is always
2994 0 (zero).
2995
2996 @item Max_Protected_Entries = 1
2997 [RM D.7] Specifies the maximum number of entries per
2998 protected type.  The bounds of every entry family of
2999 a protected unit shall be static, or shall be defined
3000 by a discriminant of a subtype whose corresponding
3001 bound is static.  For the Ravenscar pragma the value of
3002 Max_Protected_Entries is always 1.
3003
3004 @item Max_Select_Alternatives = 0
3005 [RM D.7] Specifies the maximum number of alternatives in a selective_accept.
3006 For the Ravenscar pragma the value is always 0.
3007
3008 @item No_Task_Termination
3009 Tasks which terminate are erroneous.
3010
3011 @item No_Entry_Queue
3012 No task can be queued on a protected entry.  Note that this restrictions is
3013 checked at run time.  The violation of this restriction generates a
3014 Program_Error exception.
3015 @end table
3016
3017 @noindent
3018 This set of restrictions corresponds to the definition of the ``Ravenscar
3019 Profile'' for limited tasking, devised and published by the
3020 @cite{International Real-Time Ada Workshop}, 1997,
3021 and whose most recent description is available at
3022 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3023
3024 The above set is a superset of the restrictions provided by pragma
3025 @code{Restricted_Run_Time}, it includes five additional restrictions
3026 (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements},
3027 @code{No_Calendar},
3028 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3029 that pragma @code{Ravenscar}, like the pragma @code{Restricted_Run_Time},
3030 automatically causes the use of a simplified, more efficient version
3031 of the tasking run-time system.
3032
3033 @node Pragma Restricted_Run_Time
3034 @unnumberedsec Pragma Restricted_Run_Time
3035 @findex Restricted_Run_Time
3036 @noindent
3037 Syntax:
3038
3039 @smallexample @c ada
3040 pragma Restricted_Run_Time;
3041 @end smallexample
3042
3043 @noindent
3044 A configuration pragma that establishes the following set of restrictions:
3045
3046 @itemize @bullet
3047 @item No_Abort_Statements
3048 @item No_Entry_Queue
3049 @item No_Task_Hierarchy
3050 @item No_Task_Allocators
3051 @item No_Dynamic_Priorities
3052 @item No_Terminate_Alternatives
3053 @item No_Dynamic_Interrupts
3054 @item No_Protected_Type_Allocators
3055 @item No_Local_Protected_Objects
3056 @item No_Requeue_Statements
3057 @item No_Task_Attributes
3058 @item Max_Asynchronous_Select_Nesting =  0
3059 @item Max_Task_Entries =  0
3060 @item Max_Protected_Entries = 1
3061 @item Max_Select_Alternatives = 0
3062 @end itemize
3063
3064 @noindent
3065 This set of restrictions causes the automatic selection of a simplified
3066 version of the run time that provides improved performance for the
3067 limited set of tasking functionality permitted by this set of restrictions.
3068
3069 @node Pragma Restriction_Warnings
3070 @unnumberedsec Pragma Restriction_Warnings
3071 @findex Restriction_Warnings
3072 @noindent
3073 Syntax:
3074
3075 @smallexample @c ada
3076 pragma Restriction_Warnings
3077   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3078 @end smallexample
3079
3080 @noindent
3081 This pragma allows a series of restriction identifiers to be
3082 specified (the list of allowed identifiers is the same as for
3083 pragma @code{Restrictions}). For each of these identifiers
3084 the compiler checks for violations of the restriction, but
3085 generates a warning message rather than an error message
3086 if the restriction is violated.
3087
3088 @node Pragma Source_File_Name
3089 @unnumberedsec Pragma Source_File_Name
3090 @findex Source_File_Name
3091 @noindent
3092 Syntax:
3093
3094 @smallexample @c ada
3095 pragma Source_File_Name (
3096   [Unit_Name   =>] unit_NAME,
3097   Spec_File_Name =>  STRING_LITERAL);
3098
3099 pragma Source_File_Name (
3100   [Unit_Name   =>] unit_NAME,
3101   Body_File_Name =>  STRING_LITERAL);
3102 @end smallexample
3103
3104 @noindent
3105 Use this to override the normal naming convention.  It is a configuration
3106 pragma, and so has the usual applicability of configuration pragmas
3107 (i.e.@: it applies to either an entire partition, or to all units in a
3108 compilation, or to a single unit, depending on how it is used.
3109 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3110 the second argument is required, and indicates whether this is the file
3111 name for the spec or for the body.
3112
3113 Another form of the @code{Source_File_Name} pragma allows
3114 the specification of patterns defining alternative file naming schemes
3115 to apply to all files.
3116
3117 @smallexample @c ada
3118 pragma Source_File_Name
3119   (Spec_File_Name => STRING_LITERAL
3120    [,Casing => CASING_SPEC]
3121    [,Dot_Replacement => STRING_LITERAL]);
3122
3123 pragma Source_File_Name
3124   (Body_File_Name => STRING_LITERAL
3125    [,Casing => CASING_SPEC]
3126    [,Dot_Replacement => STRING_LITERAL]);
3127
3128 pragma Source_File_Name
3129   (Subunit_File_Name => STRING_LITERAL
3130    [,Casing => CASING_SPEC]
3131    [,Dot_Replacement => STRING_LITERAL]);
3132
3133 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3134 @end smallexample
3135
3136 @noindent
3137 The first argument is a pattern that contains a single asterisk indicating
3138 the point at which the unit name is to be inserted in the pattern string
3139 to form the file name.  The second argument is optional.  If present it
3140 specifies the casing of the unit name in the resulting file name string.
3141 The default is lower case.  Finally the third argument allows for systematic
3142 replacement of any dots in the unit name by the specified string literal.
3143
3144 A pragma Source_File_Name cannot appear after a
3145 @ref{Pragma Source_File_Name_Project}.
3146
3147 For more details on the use of the @code{Source_File_Name} pragma,
3148 see the sections ``Using Other File Names'' and
3149 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3150
3151 @node Pragma Source_File_Name_Project
3152 @unnumberedsec Pragma Source_File_Name_Project
3153 @findex Source_File_Name_Project
3154 @noindent
3155
3156 This pragma has the same syntax and semantics as pragma Source_File_Name.
3157 It is only allowed as a stand alone configuration pragma.
3158 It cannot appear after a @ref{Pragma Source_File_Name}, and
3159 most importantly, once pragma Source_File_Name_Project appears,
3160 no further Source_File_Name pragmas are allowed.
3161
3162 The intention is that Source_File_Name_Project pragmas are always
3163 generated by the Project Manager in a manner consistent with the naming
3164 specified in a project file, and when naming is controlled in this manner,
3165 it is not permissible to attempt to modify this naming scheme using
3166 Source_File_Name pragmas (which would not be known to the project manager).
3167
3168 @node Pragma Source_Reference
3169 @unnumberedsec Pragma Source_Reference
3170 @findex Source_Reference
3171 @noindent
3172 Syntax:
3173
3174 @smallexample @c ada
3175 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3176 @end smallexample
3177
3178 @noindent
3179 This pragma must appear as the first line of a source file.
3180 @var{integer_literal} is the logical line number of the line following
3181 the pragma line (for use in error messages and debugging
3182 information).  @var{string_literal} is a static string constant that
3183 specifies the file name to be used in error messages and debugging
3184 information.  This is most notably used for the output of @code{gnatchop}
3185 with the @code{-r} switch, to make sure that the original unchopped
3186 source file is the one referred to.
3187
3188 The second argument must be a string literal, it cannot be a static
3189 string expression other than a string literal.  This is because its value
3190 is needed for error messages issued by all phases of the compiler.
3191
3192 @node Pragma Stream_Convert
3193 @unnumberedsec Pragma Stream_Convert
3194 @findex Stream_Convert
3195 @noindent
3196 Syntax:
3197
3198 @smallexample @c ada
3199 pragma Stream_Convert (
3200   [Entity =>] type_LOCAL_NAME,
3201   [Read   =>] function_NAME,
3202   [Write  =>] function_NAME);
3203 @end smallexample
3204
3205 @noindent
3206 This pragma provides an efficient way of providing stream functions for
3207 types defined in packages.  Not only is it simpler to use than declaring
3208 the necessary functions with attribute representation clauses, but more
3209 significantly, it allows the declaration to made in such a way that the
3210 stream packages are not loaded unless they are needed.  The use of
3211 the Stream_Convert pragma adds no overhead at all, unless the stream
3212 attributes are actually used on the designated type.
3213
3214 The first argument specifies the type for which stream functions are
3215 provided.  The second parameter provides a function used to read values
3216 of this type.  It must name a function whose argument type may be any
3217 subtype, and whose returned type must be the type given as the first
3218 argument to the pragma.
3219
3220 The meaning of the @var{Read}
3221 parameter is that if a stream attribute directly
3222 or indirectly specifies reading of the type given as the first parameter,
3223 then a value of the type given as the argument to the Read function is
3224 read from the stream, and then the Read function is used to convert this
3225 to the required target type.
3226
3227 Similarly the @var{Write} parameter specifies how to treat write attributes
3228 that directly or indirectly apply to the type given as the first parameter.
3229 It must have an input parameter of the type specified by the first parameter,
3230 and the return type must be the same as the input type of the Read function.
3231 The effect is to first call the Write function to convert to the given stream
3232 type, and then write the result type to the stream.
3233
3234 The Read and Write functions must not be overloaded subprograms.  If necessary
3235 renamings can be supplied to meet this requirement.
3236 The usage of this attribute is best illustrated by a simple example, taken
3237 from the GNAT implementation of package Ada.Strings.Unbounded:
3238
3239 @smallexample @c ada
3240 function To_Unbounded (S : String)
3241            return Unbounded_String
3242   renames To_Unbounded_String;
3243
3244 pragma Stream_Convert
3245   (Unbounded_String, To_Unbounded, To_String);
3246 @end smallexample
3247
3248 @noindent
3249 The specifications of the referenced functions, as given in the Ada 95
3250 Reference Manual are:
3251
3252 @smallexample @c ada
3253 function To_Unbounded_String (Source : String)
3254   return Unbounded_String;
3255
3256 function To_String (Source : Unbounded_String)
3257   return String;
3258 @end smallexample
3259
3260 @noindent
3261 The effect is that if the value of an unbounded string is written to a
3262 stream, then the representation of the item in the stream is in the same
3263 format used for @code{Standard.String}, and this same representation is
3264 expected when a value of this type is read from the stream.
3265
3266 @node Pragma Style_Checks
3267 @unnumberedsec Pragma Style_Checks
3268 @findex Style_Checks
3269 @noindent
3270 Syntax:
3271
3272 @smallexample @c ada
3273 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3274                      On | Off [, LOCAL_NAME]);
3275 @end smallexample
3276
3277 @noindent
3278 This pragma is used in conjunction with compiler switches to control the
3279 built in style checking provided by GNAT@.  The compiler switches, if set,
3280 provide an initial setting for the switches, and this pragma may be used
3281 to modify these settings, or the settings may be provided entirely by
3282 the use of the pragma.  This pragma can be used anywhere that a pragma
3283 is legal, including use as a configuration pragma (including use in
3284 the @file{gnat.adc} file).
3285
3286 The form with a string literal specifies which style options are to be
3287 activated.  These are additive, so they apply in addition to any previously
3288 set style check options.  The codes for the options are the same as those
3289 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3290 For example the following two methods can be used to enable
3291 layout checking:
3292
3293 @itemize @bullet
3294 @item
3295 @smallexample @c ada
3296 pragma Style_Checks ("l");
3297 @end smallexample
3298
3299 @item
3300 @smallexample
3301 gcc -c -gnatyl @dots{}
3302 @end smallexample
3303 @end itemize
3304
3305 @noindent
3306 The form ALL_CHECKS activates all standard checks (its use is equivalent
3307 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3308 Guide for details.
3309
3310 The forms with @code{Off} and @code{On}
3311 can be used to temporarily disable style checks
3312 as shown in the following example:
3313
3314 @smallexample @c ada
3315 @iftex
3316 @leftskip=0cm
3317 @end iftex
3318 pragma Style_Checks ("k"); -- requires keywords in lower case
3319 pragma Style_Checks (Off); -- turn off style checks
3320 NULL;                      -- this will not generate an error message
3321 pragma Style_Checks (On);  -- turn style checks back on
3322 NULL;                      -- this will generate an error message
3323 @end smallexample
3324
3325 @noindent
3326 Finally the two argument form is allowed only if the first argument is
3327 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3328 for the specified entity, as shown in the following example:
3329
3330 @smallexample @c ada
3331 @iftex
3332 @leftskip=0cm
3333 @end iftex
3334 pragma Style_Checks ("r"); -- require consistency of identifier casing
3335 Arg : Integer;
3336 Rf1 : Integer := ARG;      -- incorrect, wrong case
3337 pragma Style_Checks (Off, Arg);
3338 Rf2 : Integer := ARG;      -- OK, no error
3339 @end smallexample
3340
3341 @node Pragma Subtitle
3342 @unnumberedsec Pragma Subtitle
3343 @findex Subtitle
3344 @noindent
3345 Syntax:
3346
3347 @smallexample @c ada
3348 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3349 @end smallexample
3350
3351 @noindent
3352 This pragma is recognized for compatibility with other Ada compilers
3353 but is ignored by GNAT@.
3354
3355 @node Pragma Suppress_All
3356 @unnumberedsec Pragma Suppress_All
3357 @findex Suppress_All
3358 @noindent
3359 Syntax:
3360
3361 @smallexample @c ada
3362 pragma Suppress_All;
3363 @end smallexample
3364
3365 @noindent
3366 This pragma can only appear immediately following a compilation
3367 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3368 which it follows.  This pragma is implemented for compatibility with DEC
3369 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3370 configuration pragma is the preferred usage in GNAT@.
3371
3372 @node Pragma Suppress_Exception_Locations
3373 @unnumberedsec Pragma Suppress_Exception_Locations
3374 @findex Suppress_Exception_Locations
3375 @noindent
3376 Syntax:
3377
3378 @smallexample @c ada
3379 pragma Suppress_Exception_Locations;
3380 @end smallexample
3381
3382 @noindent
3383 In normal mode, a raise statement for an exception by default generates
3384 an exception message giving the file name and line number for the location
3385 of the raise. This is useful for debugging and logging purposes, but this
3386 entails extra space for the strings for the messages. The configuration
3387 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3388 generation of these strings, with the result that space is saved, but the
3389 exception message for such raises is null. This configuration pragma may
3390 appear in a global configuration pragma file, or in a specific unit as
3391 usual. It is not required that this pragma be used consistently within
3392 a partition, so it is fine to have some units within a partition compiled
3393 with this pragma and others compiled in normal mode without it.
3394
3395 @node Pragma Suppress_Initialization
3396 @unnumberedsec Pragma Suppress_Initialization
3397 @findex Suppress_Initialization
3398 @cindex Suppressing initialization
3399 @cindex Initialization, suppression of
3400 @noindent
3401 Syntax:
3402
3403 @smallexample @c ada
3404 pragma Suppress_Initialization ([Entity =>] type_Name);
3405 @end smallexample
3406
3407 @noindent
3408 This pragma suppresses any implicit or explicit initialization
3409 associated with the given type name for all variables of this type.
3410
3411 @node Pragma Task_Info
3412 @unnumberedsec Pragma Task_Info
3413 @findex Task_Info
3414 @noindent
3415 Syntax
3416
3417 @smallexample @c ada
3418 pragma Task_Info (EXPRESSION);
3419 @end smallexample
3420
3421 @noindent
3422 This pragma appears within a task definition (like pragma
3423 @code{Priority}) and applies to the task in which it appears.  The
3424 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3425 The @code{Task_Info} pragma provides system dependent control over
3426 aspects of tasking implementation, for example, the ability to map
3427 tasks to specific processors.  For details on the facilities available
3428 for the version of GNAT that you are using, see the documentation
3429 in the specification of package System.Task_Info in the runtime
3430 library.
3431
3432 @node Pragma Task_Name
3433 @unnumberedsec Pragma Task_Name
3434 @findex Task_Name
3435 @noindent
3436 Syntax
3437
3438 @smallexample @c ada
3439 pragma Task_Name (string_EXPRESSION);
3440 @end smallexample
3441
3442 @noindent
3443 This pragma appears within a task definition (like pragma
3444 @code{Priority}) and applies to the task in which it appears.  The
3445 argument must be of type String, and provides a name to be used for
3446 the task instance when the task is created.  Note that this expression
3447 is not required to be static, and in particular, it can contain
3448 references to task discriminants.  This facility can be used to
3449 provide different names for different tasks as they are created,
3450 as illustrated in the example below.
3451
3452 The task name is recorded internally in the run-time structures
3453 and is accessible to tools like the debugger.  In addition the
3454 routine @code{Ada.Task_Identification.Image} will return this
3455 string, with a unique task address appended.
3456
3457 @smallexample @c ada
3458 --  Example of the use of pragma Task_Name
3459
3460 with Ada.Task_Identification;
3461 use Ada.Task_Identification;
3462 with Text_IO; use Text_IO;
3463 procedure t3 is
3464
3465    type Astring is access String;
3466
3467    task type Task_Typ (Name : access String) is
3468       pragma Task_Name (Name.all);
3469    end Task_Typ;
3470
3471    task body Task_Typ is
3472       Nam : constant String := Image (Current_Task);
3473    begin
3474       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3475    end Task_Typ;
3476
3477    type Ptr_Task is access Task_Typ;
3478    Task_Var : Ptr_Task;
3479
3480 begin
3481    Task_Var :=
3482      new Task_Typ (new String'("This is task 1"));
3483    Task_Var :=
3484      new Task_Typ (new String'("This is task 2"));
3485 end;
3486 @end smallexample
3487
3488 @node Pragma Task_Storage
3489 @unnumberedsec Pragma Task_Storage
3490 @findex Task_Storage
3491 Syntax:
3492
3493 @smallexample @c ada
3494 pragma Task_Storage (
3495   [Task_Type =>] LOCAL_NAME,
3496   [Top_Guard =>] static_integer_EXPRESSION);
3497 @end smallexample
3498
3499 @noindent
3500 This pragma specifies the length of the guard area for tasks.  The guard
3501 area is an additional storage area allocated to a task.  A value of zero
3502 means that either no guard area is created or a minimal guard area is
3503 created, depending on the target.  This pragma can appear anywhere a
3504 @code{Storage_Size} attribute definition clause is allowed for a task
3505 type.
3506
3507 @node Pragma Thread_Body
3508 @unnumberedsec Pragma Thread_Body
3509 @findex Thread_Body
3510 Syntax:
3511
3512 @smallexample @c ada
3513 pragma Thread_Body (
3514   [Entity =>] LOCAL_NAME,
3515  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3516 @end smallexample
3517
3518 @noindent
3519 This pragma specifies that the subprogram whose name is given as the
3520 @code{Entity} argument is a thread body, which will be activated
3521 by being called via its Address from foreign code. The purpose is
3522 to allow execution and registration of the foreign thread within the
3523 Ada run-time system.
3524
3525 See the library unit @code{System.Threads} for details on the expansion of
3526 a thread body subprogram, including the calls made to subprograms
3527 within System.Threads to register the task.  This unit also lists the
3528 targets and runtime systems for which this pragma is supported.
3529
3530 A thread body subprogram may not be called directly from Ada code, and
3531 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3532 to such a subprogram. The only legitimate way of calling such a subprogram
3533 is to pass its Address to foreign code and then make the call from the
3534 foreign code.
3535
3536 A thread body subprogram may have any parameters, and it may be a function
3537 returning a result. The convention of the thread body subprogram may be
3538 set in the usual manner using @code{pragma Convention}.
3539
3540 The secondary stack size parameter, if given, is used to set the size
3541 of secondary stack for the thread. The secondary stack is allocated as
3542 a local variable of the expanded thread body subprogram, and thus is
3543 allocated out of the main thread stack size. If no secondary stack
3544 size parameter is present, the default size (from the declaration in
3545 @code{System.Secondary_Stack} is used.
3546
3547 @node Pragma Time_Slice
3548 @unnumberedsec Pragma Time_Slice
3549 @findex Time_Slice
3550 @noindent
3551 Syntax:
3552
3553 @smallexample @c ada
3554 pragma Time_Slice (static_duration_EXPRESSION);
3555 @end smallexample
3556
3557 @noindent
3558 For implementations of GNAT on operating systems where it is possible
3559 to supply a time slice value, this pragma may be used for this purpose.
3560 It is ignored if it is used in a system that does not allow this control,
3561 or if it appears in other than the main program unit.
3562 @cindex OpenVMS
3563 Note that the effect of this pragma is identical to the effect of the
3564 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3565
3566 @node Pragma Title
3567 @unnumberedsec Pragma Title
3568 @findex Title
3569 @noindent
3570 Syntax:
3571
3572 @smallexample @c ada
3573 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3574
3575 TITLING_OPTION ::=
3576   [Title    =>] STRING_LITERAL,
3577 | [Subtitle =>] STRING_LITERAL
3578 @end smallexample
3579
3580 @noindent
3581 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3582 pragma used in DEC Ada 83 implementations to provide a title and/or
3583 subtitle for the program listing.  The program listing generated by GNAT
3584 does not have titles or subtitles.
3585
3586 Unlike other pragmas, the full flexibility of named notation is allowed
3587 for this pragma, i.e.@: the parameters may be given in any order if named
3588 notation is used, and named and positional notation can be mixed
3589 following the normal rules for procedure calls in Ada.
3590
3591 @node Pragma Unchecked_Union
3592 @unnumberedsec Pragma Unchecked_Union
3593 @cindex Unions in C
3594 @findex Unchecked_Union
3595 @noindent
3596 Syntax:
3597
3598 @smallexample @c ada
3599 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3600 @end smallexample
3601
3602 @noindent
3603 This pragma is used to declare that the specified type should be represented
3604 in a manner
3605 equivalent to a C union type, and is intended only for use in
3606 interfacing with C code that uses union types.  In Ada terms, the named
3607 type must obey the following rules:
3608
3609 @itemize @bullet
3610 @item
3611 It is a non-tagged non-limited record type.
3612 @item
3613 It has a single discrete discriminant with a default value.
3614 @item
3615 The component list consists of a single variant part.
3616 @item
3617 Each variant has a component list with a single component.
3618 @item
3619 No nested variants are allowed.
3620 @item
3621 No component has an explicit default value.
3622 @item
3623 No component has a non-static constraint.
3624 @end itemize
3625
3626 @noindent
3627 In addition, given a type that meets the above requirements, the
3628 following restrictions apply to its use throughout the program:
3629
3630 @itemize @bullet
3631 @item
3632 The discriminant name can be mentioned only in an aggregate.
3633 @item
3634 No subtypes may be created of this type.
3635 @item
3636 The type may not be constrained by giving a discriminant value.
3637 @item
3638 The type cannot be passed as the actual for a generic formal with a
3639 discriminant.
3640 @end itemize
3641
3642 @noindent
3643 Equality and inequality operations on @code{unchecked_unions} are not
3644 available, since there is no discriminant to compare and the compiler
3645 does not even know how many bits to compare.  It is implementation
3646 dependent whether this is detected at compile time as an illegality or
3647 whether it is undetected and considered to be an erroneous construct.  In
3648 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3649 the composite case (where two composites are compared that contain an
3650 unchecked union component), so such comparisons are simply considered
3651 erroneous.
3652
3653 The layout of the resulting type corresponds exactly to a C union, where
3654 each branch of the union corresponds to a single variant in the Ada
3655 record.  The semantics of the Ada program is not changed in any way by
3656 the pragma, i.e.@: provided the above restrictions are followed, and no
3657 erroneous incorrect references to fields or erroneous comparisons occur,
3658 the semantics is exactly as described by the Ada reference manual.
3659 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3660 type and the default convention is C.
3661
3662 @node Pragma Unimplemented_Unit
3663 @unnumberedsec Pragma Unimplemented_Unit
3664 @findex Unimplemented_Unit
3665 @noindent
3666 Syntax:
3667
3668 @smallexample @c ada
3669 pragma Unimplemented_Unit;
3670 @end smallexample
3671
3672 @noindent
3673 If this pragma occurs in a unit that is processed by the compiler, GNAT
3674 aborts with the message @samp{@var{xxx} not implemented}, where
3675 @var{xxx} is the name of the current compilation unit.  This pragma is
3676 intended to allow the compiler to handle unimplemented library units in
3677 a clean manner.
3678
3679 The abort only happens if code is being generated.  Thus you can use
3680 specs of unimplemented packages in syntax or semantic checking mode.
3681
3682 @node Pragma Universal_Data
3683 @unnumberedsec Pragma Universal_Data
3684 @findex Universal_Data
3685 @noindent
3686 Syntax:
3687
3688 @smallexample @c ada
3689 pragma Universal_Data [(library_unit_Name)];
3690 @end smallexample
3691
3692 @noindent
3693 This pragma is supported only for the AAMP target and is ignored for
3694 other targets. The pragma specifies that all library-level objects
3695 (Counter 0 data) associated with the library unit are to be accessed
3696 and updated using universal addressing (24-bit addresses for AAMP5)
3697 rather than the default of 16-bit Data Environment (DENV) addressing.
3698 Use of this pragma will generally result in less efficient code for
3699 references to global data associated with the library unit, but
3700 allows such data to be located anywhere in memory. This pragma is
3701 a library unit pragma, but can also be used as a configuration pragma
3702 (including use in the @file{gnat.adc} file). The functionality
3703 of this pragma is also available by applying the -univ switch on the
3704 compilations of units where universal addressing of the data is desired.
3705
3706 @node Pragma Unreferenced
3707 @unnumberedsec Pragma Unreferenced
3708 @findex Unreferenced
3709 @cindex Warnings, unreferenced
3710 @noindent
3711 Syntax:
3712
3713 @smallexample @c ada
3714 pragma Unreferenced (local_Name @{, local_Name@});
3715 @end smallexample
3716
3717 @noindent
3718 This pragma signals that the entities whose names are listed are
3719 deliberately not referenced in the current source unit. This
3720 suppresses warnings about the
3721 entities being unreferenced, and in addition a warning will be
3722 generated if one of these entities is in fact referenced in the
3723 same unit as the pragma (or in the corresponding body, or one
3724 of its subunits).
3725
3726 This is particularly useful for clearly signaling that a particular
3727 parameter is not referenced in some particular subprogram implementation
3728 and that this is deliberate. It can also be useful in the case of
3729 objects declared only for their initialization or finalization side
3730 effects.
3731
3732 If @code{local_Name} identifies more than one matching homonym in the
3733 current scope, then the entity most recently declared is the one to which
3734 the pragma applies.
3735
3736 The left hand side of an assignment does not count as a reference for the
3737 purpose of this pragma. Thus it is fine to assign to an entity for which
3738 pragma Unreferenced is given.
3739
3740 @node Pragma Unreserve_All_Interrupts
3741 @unnumberedsec Pragma Unreserve_All_Interrupts
3742 @findex Unreserve_All_Interrupts
3743 @noindent
3744 Syntax:
3745
3746 @smallexample @c ada
3747 pragma Unreserve_All_Interrupts;
3748 @end smallexample
3749
3750 @noindent
3751 Normally certain interrupts are reserved to the implementation.  Any attempt
3752 to attach an interrupt causes Program_Error to be raised, as described in
3753 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3754 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3755 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3756 interrupt execution.
3757
3758 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3759 a program, then all such interrupts are unreserved.  This allows the
3760 program to handle these interrupts, but disables their standard
3761 functions.  For example, if this pragma is used, then pressing
3762 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3763 a program can then handle the @code{SIGINT} interrupt as it chooses.
3764
3765 For a full list of the interrupts handled in a specific implementation,
3766 see the source code for the specification of @code{Ada.Interrupts.Names} in
3767 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3768 list of interrupts recognized for a given target.  The documentation in
3769 this file also specifies what interrupts are affected by the use of
3770 the @code{Unreserve_All_Interrupts} pragma.
3771
3772 For a more general facility for controlling what interrupts can be
3773 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3774 of the @code{Unreserve_All_Interrupts} pragma.
3775
3776 @node Pragma Unsuppress
3777 @unnumberedsec Pragma Unsuppress
3778 @findex Unsuppress
3779 @noindent
3780 Syntax:
3781
3782 @smallexample @c ada
3783 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3784 @end smallexample
3785
3786 @noindent
3787 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3788 there is no corresponding pragma @code{Suppress} in effect, it has no
3789 effect.  The range of the effect is the same as for pragma
3790 @code{Suppress}.  The meaning of the arguments is identical to that used
3791 in pragma @code{Suppress}.
3792
3793 One important application is to ensure that checks are on in cases where
3794 code depends on the checks for its correct functioning, so that the code
3795 will compile correctly even if the compiler switches are set to suppress
3796 checks.
3797
3798 @node Pragma Use_VADS_Size
3799 @unnumberedsec Pragma Use_VADS_Size
3800 @cindex @code{Size}, VADS compatibility
3801 @findex Use_VADS_Size
3802 @noindent
3803 Syntax:
3804
3805 @smallexample @c ada
3806 pragma Use_VADS_Size;
3807 @end smallexample
3808
3809 @noindent
3810 This is a configuration pragma.  In a unit to which it applies, any use
3811 of the 'Size attribute is automatically interpreted as a use of the
3812 'VADS_Size attribute.  Note that this may result in incorrect semantic
3813 processing of valid Ada 95 programs.  This is intended to aid in the
3814 handling of legacy code which depends on the interpretation of Size
3815 as implemented in the VADS compiler.  See description of the VADS_Size
3816 attribute for further details.
3817
3818 @node Pragma Validity_Checks
3819 @unnumberedsec Pragma Validity_Checks
3820 @findex Validity_Checks
3821 @noindent
3822 Syntax:
3823
3824 @smallexample @c ada
3825 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3826 @end smallexample
3827
3828 @noindent
3829 This pragma is used in conjunction with compiler switches to control the
3830 built-in validity checking provided by GNAT@.  The compiler switches, if set
3831 provide an initial setting for the switches, and this pragma may be used
3832 to modify these settings, or the settings may be provided entirely by
3833 the use of the pragma.  This pragma can be used anywhere that a pragma
3834 is legal, including use as a configuration pragma (including use in
3835 the @file{gnat.adc} file).
3836
3837 The form with a string literal specifies which validity options are to be
3838 activated.  The validity checks are first set to include only the default
3839 reference manual settings, and then a string of letters in the string
3840 specifies the exact set of options required.  The form of this string
3841 is exactly as described for the @code{-gnatVx} compiler switch (see the
3842 GNAT users guide for details).  For example the following two methods
3843 can be used to enable validity checking for mode @code{in} and
3844 @code{in out} subprogram parameters:
3845
3846 @itemize @bullet
3847 @item
3848 @smallexample @c ada
3849 pragma Validity_Checks ("im");
3850 @end smallexample
3851
3852 @item
3853 @smallexample
3854 gcc -c -gnatVim @dots{}
3855 @end smallexample
3856 @end itemize
3857
3858 @noindent
3859 The form ALL_CHECKS activates all standard checks (its use is equivalent
3860 to the use of the @code{gnatva} switch.
3861
3862 The forms with @code{Off} and @code{On}
3863 can be used to temporarily disable validity checks
3864 as shown in the following example:
3865
3866 @smallexample @c ada
3867 @iftex
3868 @leftskip=0cm
3869 @end iftex
3870 pragma Validity_Checks ("c"); -- validity checks for copies
3871 pragma Validity_Checks (Off); -- turn off validity checks
3872 A := B;                       -- B will not be validity checked
3873 pragma Validity_Checks (On);  -- turn validity checks back on
3874 A := C;                       -- C will be validity checked
3875 @end smallexample
3876
3877 @node Pragma Volatile
3878 @unnumberedsec Pragma Volatile
3879 @findex Volatile
3880 @noindent
3881 Syntax:
3882
3883 @smallexample @c ada
3884 pragma Volatile (local_NAME);
3885 @end smallexample
3886
3887 @noindent
3888 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3889 implementation is fully conformant with this definition.  The reason it
3890 is mentioned in this section is that a pragma of the same name was supplied
3891 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3892 of pragma Volatile is upwards compatible with the implementation in
3893 Dec Ada 83.
3894
3895 @node Pragma Warnings
3896 @unnumberedsec Pragma Warnings
3897 @findex Warnings
3898 @noindent
3899 Syntax:
3900
3901 @smallexample @c ada
3902 pragma Warnings (On | Off [, LOCAL_NAME]);
3903 @end smallexample
3904
3905 @noindent
3906 Normally warnings are enabled, with the output being controlled by
3907 the command line switch.  Warnings (@code{Off}) turns off generation of
3908 warnings until a Warnings (@code{On}) is encountered or the end of the
3909 current unit.  If generation of warnings is turned off using this
3910 pragma, then no warning messages are output, regardless of the
3911 setting of the command line switches.
3912
3913 The form with a single argument is a configuration pragma.
3914
3915 If the @var{local_name} parameter is present, warnings are suppressed for
3916 the specified entity.  This suppression is effective from the point where
3917 it occurs till the end of the extended scope of the variable (similar to
3918 the scope of @code{Suppress}).
3919
3920 @node Pragma Weak_External
3921 @unnumberedsec Pragma Weak_External
3922 @findex Weak_External
3923 @noindent
3924 Syntax:
3925
3926 @smallexample @c ada
3927 pragma Weak_External ([Entity =>] LOCAL_NAME);
3928 @end smallexample
3929
3930 @noindent
3931 This pragma specifies that the given entity should be marked as a weak
3932 external (one that does not have to be resolved) for the linker.  For
3933 further details, consult the GCC manual.
3934
3935 @node Implementation Defined Attributes
3936 @chapter Implementation Defined Attributes
3937 Ada 95 defines (throughout the Ada 95 reference manual,
3938 summarized in annex K),
3939 a set of attributes that provide useful additional functionality in all
3940 areas of the language.  These language defined attributes are implemented
3941 in GNAT and work as described in the Ada 95 Reference Manual.
3942
3943 In addition, Ada 95 allows implementations to define additional
3944 attributes whose meaning is defined by the implementation.  GNAT provides
3945 a number of these implementation-dependent attributes which can be used
3946 to extend and enhance the functionality of the compiler.  This section of
3947 the GNAT reference manual describes these additional attributes.
3948
3949 Note that any program using these attributes may not be portable to
3950 other compilers (although GNAT implements this set of attributes on all
3951 platforms).  Therefore if portability to other compilers is an important
3952 consideration, you should minimize the use of these attributes.
3953
3954 @menu
3955 * Abort_Signal::
3956 * Address_Size::
3957 * Asm_Input::
3958 * Asm_Output::
3959 * AST_Entry::
3960 * Bit::
3961 * Bit_Position::
3962 * Code_Address::
3963 * Default_Bit_Order::
3964 * Elaborated::
3965 * Elab_Body::
3966 * Elab_Spec::
3967 * Emax::
3968 * Enum_Rep::
3969 * Epsilon::
3970 * Fixed_Value::
3971 * Has_Discriminants::
3972 * Img::
3973 * Integer_Value::
3974 * Large::
3975 * Machine_Size::
3976 * Mantissa::
3977 * Max_Interrupt_Priority::
3978 * Max_Priority::
3979 * Maximum_Alignment::
3980 * Mechanism_Code::
3981 * Null_Parameter::
3982 * Object_Size::
3983 * Passed_By_Reference::
3984 * Range_Length::
3985 * Safe_Emax::
3986 * Safe_Large::
3987 * Small::
3988 * Storage_Unit::
3989 * Target_Name::
3990 * Tick::
3991 * To_Address::
3992 * Type_Class::
3993 * UET_Address::
3994 * Unconstrained_Array::
3995 * Universal_Literal_String::
3996 * Unrestricted_Access::
3997 * VADS_Size::
3998 * Value_Size::
3999 * Wchar_T_Size::
4000 * Word_Size::
4001 @end menu
4002
4003 @node Abort_Signal
4004 @unnumberedsec Abort_Signal
4005 @findex Abort_Signal
4006 @noindent
4007 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4008 prefix) provides the entity for the special exception used to signal
4009 task abort or asynchronous transfer of control.  Normally this attribute
4010 should only be used in the tasking runtime (it is highly peculiar, and
4011 completely outside the normal semantics of Ada, for a user program to
4012 intercept the abort exception).
4013
4014 @node Address_Size
4015 @unnumberedsec Address_Size
4016 @cindex Size of @code{Address}
4017 @findex Address_Size
4018 @noindent
4019 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4020 prefix) is a static constant giving the number of bits in an
4021 @code{Address}. It is the same value as System.Address'Size,
4022 but has the advantage of being static, while a direct
4023 reference to System.Address'Size is non-static because Address
4024 is a private type.
4025
4026 @node Asm_Input
4027 @unnumberedsec Asm_Input
4028 @findex Asm_Input
4029 @noindent
4030 The @code{Asm_Input} attribute denotes a function that takes two
4031 parameters.  The first is a string, the second is an expression of the
4032 type designated by the prefix.  The first (string) argument is required
4033 to be a static expression, and is the constraint for the parameter,
4034 (e.g.@: what kind of register is required).  The second argument is the
4035 value to be used as the input argument.  The possible values for the
4036 constant are the same as those used in the RTL, and are dependent on
4037 the configuration file used to built the GCC back end.
4038 @ref{Machine Code Insertions}
4039
4040 @node Asm_Output
4041 @unnumberedsec Asm_Output
4042 @findex Asm_Output
4043 @noindent
4044 The @code{Asm_Output} attribute denotes a function that takes two
4045 parameters.  The first is a string, the second is the name of a variable
4046 of the type designated by the attribute prefix.  The first (string)
4047 argument is required to be a static expression and designates the
4048 constraint for the parameter (e.g.@: what kind of register is
4049 required).  The second argument is the variable to be updated with the
4050 result.  The possible values for constraint are the same as those used in
4051 the RTL, and are dependent on the configuration file used to build the
4052 GCC back end.  If there are no output operands, then this argument may
4053 either be omitted, or explicitly given as @code{No_Output_Operands}.
4054 @ref{Machine Code Insertions}
4055
4056 @node AST_Entry
4057 @unnumberedsec AST_Entry
4058 @cindex OpenVMS
4059 @findex AST_Entry
4060 @noindent
4061 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4062 the name of an entry, it yields a value of the predefined type AST_Handler
4063 (declared in the predefined package System, as extended by the use of
4064 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4065 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4066 Language Reference Manual}, section 9.12a.
4067
4068 @node Bit
4069 @unnumberedsec Bit
4070 @findex Bit
4071 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4072 offset within the storage unit (byte) that contains the first bit of
4073 storage allocated for the object.  The value of this attribute is of the
4074 type @code{Universal_Integer}, and is always a non-negative number not
4075 exceeding the value of @code{System.Storage_Unit}.
4076
4077 For an object that is a variable or a constant allocated in a register,
4078 the value is zero.  (The use of this attribute does not force the
4079 allocation of a variable to memory).
4080
4081 For an object that is a formal parameter, this attribute applies
4082 to either the matching actual parameter or to a copy of the
4083 matching actual parameter.
4084
4085 For an access object the value is zero.  Note that
4086 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4087 designated object.  Similarly for a record component
4088 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4089 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4090 are subject to index checks.
4091
4092 This attribute is designed to be compatible with the DEC Ada 83 definition
4093 and implementation of the @code{Bit} attribute.
4094
4095 @node Bit_Position
4096 @unnumberedsec Bit_Position
4097 @findex Bit_Position
4098 @noindent
4099 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4100 of the fields of the record type, yields the bit
4101 offset within the record contains the first bit of
4102 storage allocated for the object.  The value of this attribute is of the
4103 type @code{Universal_Integer}.  The value depends only on the field
4104 @var{C} and is independent of the alignment of
4105 the containing record @var{R}.
4106
4107 @node Code_Address
4108 @unnumberedsec Code_Address
4109 @findex Code_Address
4110 @cindex Subprogram address
4111 @cindex Address of subprogram code
4112 @noindent
4113 The @code{'Address}
4114 attribute may be applied to subprograms in Ada 95, but the
4115 intended effect from the Ada 95 reference manual seems to be to provide
4116 an address value which can be used to call the subprogram by means of
4117 an address clause as in the following example:
4118
4119 @smallexample @c ada
4120 procedure K is @dots{}
4121
4122 procedure L;
4123 for L'Address use K'Address;
4124 pragma Import (Ada, L);
4125 @end smallexample
4126
4127 @noindent
4128 A call to @code{L} is then expected to result in a call to @code{K}@.
4129 In Ada 83, where there were no access-to-subprogram values, this was
4130 a common work around for getting the effect of an indirect call.
4131 GNAT implements the above use of @code{Address} and the technique
4132 illustrated by the example code works correctly.
4133
4134 However, for some purposes, it is useful to have the address of the start
4135 of the generated code for the subprogram.  On some architectures, this is
4136 not necessarily the same as the @code{Address} value described above.
4137 For example, the @code{Address} value may reference a subprogram
4138 descriptor rather than the subprogram itself.
4139
4140 The @code{'Code_Address} attribute, which can only be applied to
4141 subprogram entities, always returns the address of the start of the
4142 generated code of the specified subprogram, which may or may not be
4143 the same value as is returned by the corresponding @code{'Address}
4144 attribute.
4145
4146 @node Default_Bit_Order
4147 @unnumberedsec Default_Bit_Order
4148 @cindex Big endian
4149 @cindex Little endian
4150 @findex Default_Bit_Order
4151 @noindent
4152 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4153 permissible prefix), provides the value @code{System.Default_Bit_Order}
4154 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4155 @code{Low_Order_First}).  This is used to construct the definition of
4156 @code{Default_Bit_Order} in package @code{System}.
4157
4158 @node Elaborated
4159 @unnumberedsec Elaborated
4160 @findex Elaborated
4161 @noindent
4162 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4163 value is a Boolean which indicates whether or not the given unit has been
4164 elaborated.  This attribute is primarily intended for internal use by the
4165 generated code for dynamic elaboration checking, but it can also be used
4166 in user programs.  The value will always be True once elaboration of all
4167 units has been completed.  An exception is for units which need no
4168 elaboration, the value is always False for such units.
4169
4170 @node Elab_Body
4171 @unnumberedsec Elab_Body
4172 @findex Elab_Body
4173 @noindent
4174 This attribute can only be applied to a program unit name.  It returns
4175 the entity for the corresponding elaboration procedure for elaborating
4176 the body of the referenced unit.  This is used in the main generated
4177 elaboration procedure by the binder and is not normally used in any
4178 other context.  However, there may be specialized situations in which it
4179 is useful to be able to call this elaboration procedure from Ada code,
4180 e.g.@: if it is necessary to do selective re-elaboration to fix some
4181 error.
4182
4183 @node Elab_Spec
4184 @unnumberedsec Elab_Spec
4185 @findex Elab_Spec
4186 @noindent
4187 This attribute can only be applied to a program unit name.  It returns
4188 the entity for the corresponding elaboration procedure for elaborating
4189 the specification of the referenced unit.  This is used in the main
4190 generated elaboration procedure by the binder and is not normally used
4191 in any other context.  However, there may be specialized situations in
4192 which it is useful to be able to call this elaboration procedure from
4193 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4194 some error.
4195
4196 @node Emax
4197 @unnumberedsec Emax
4198 @cindex Ada 83 attributes
4199 @findex Emax
4200 @noindent
4201 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4202 the Ada 83 reference manual for an exact description of the semantics of
4203 this attribute.
4204
4205 @node Enum_Rep
4206 @unnumberedsec Enum_Rep
4207 @cindex Representation of enums
4208 @findex Enum_Rep
4209 @noindent
4210 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4211 function with the following spec:
4212
4213 @smallexample @c ada
4214 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4215   return @i{Universal_Integer};
4216 @end smallexample
4217
4218 @noindent
4219 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4220 enumeration type or to a non-overloaded enumeration
4221 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4222 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4223 enumeration literal or object.
4224
4225 The function returns the representation value for the given enumeration
4226 value.  This will be equal to value of the @code{Pos} attribute in the
4227 absence of an enumeration representation clause.  This is a static
4228 attribute (i.e.@: the result is static if the argument is static).
4229
4230 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4231 in which case it simply returns the integer value.  The reason for this
4232 is to allow it to be used for @code{(<>)} discrete formal arguments in
4233 a generic unit that can be instantiated with either enumeration types
4234 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4235 type whose upper bound exceeds the upper bound of the largest signed
4236 integer type, and the argument is a variable, so that the universal
4237 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4238 may raise @code{Constraint_Error}.
4239
4240 @node Epsilon
4241 @unnumberedsec Epsilon
4242 @cindex Ada 83 attributes
4243 @findex Epsilon
4244 @noindent
4245 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4246 the Ada 83 reference manual for an exact description of the semantics of
4247 this attribute.
4248
4249 @node Fixed_Value
4250 @unnumberedsec Fixed_Value
4251 @findex Fixed_Value
4252 @noindent
4253 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4254 function with the following specification:
4255
4256 @smallexample @c ada
4257 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4258   return @var{S};
4259 @end smallexample
4260
4261 @noindent
4262 The value returned is the fixed-point value @var{V} such that
4263
4264 @smallexample @c ada
4265 @var{V} = Arg * @var{S}'Small
4266 @end smallexample
4267
4268 @noindent
4269 The effect is thus similar to first converting the argument to the
4270 integer type used to represent @var{S}, and then doing an unchecked
4271 conversion to the fixed-point type.  The difference is
4272 that there are full range checks, to ensure that the result is in range.
4273 This attribute is primarily intended for use in implementation of the
4274 input-output functions for fixed-point values.
4275
4276 @node Has_Discriminants
4277 @unnumberedsec Has_Discriminants
4278 @cindex Discriminants, testing for
4279 @findex Has_Discriminants
4280 @noindent
4281 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4282 is a Boolean value which is True if the type has discriminants, and False
4283 otherwise.  The intended use of this attribute is in conjunction with generic
4284 definitions.  If the attribute is applied to a generic private type, it
4285 indicates whether or not the corresponding actual type has discriminants.
4286
4287 @node Img
4288 @unnumberedsec Img
4289 @findex Img
4290 @noindent
4291 The @code{Img} attribute differs from @code{Image} in that it may be
4292 applied to objects as well as types, in which case it gives the
4293 @code{Image} for the subtype of the object.  This is convenient for
4294 debugging:
4295
4296 @smallexample @c ada
4297 Put_Line ("X = " & X'Img);
4298 @end smallexample
4299
4300 @noindent
4301 has the same meaning as the more verbose:
4302
4303 @smallexample @c ada
4304 Put_Line ("X = " & @var{T}'Image (X));
4305 @end smallexample
4306
4307 @noindent
4308 where @var{T} is the (sub)type of the object @code{X}.
4309
4310 @node Integer_Value
4311 @unnumberedsec Integer_Value
4312 @findex Integer_Value
4313 @noindent
4314 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4315 function with the following spec:
4316
4317 @smallexample @c ada
4318 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4319   return @var{S};
4320 @end smallexample
4321
4322 @noindent
4323 The value returned is the integer value @var{V}, such that
4324
4325 @smallexample @c ada
4326 Arg = @var{V} * @var{T}'Small
4327 @end smallexample
4328
4329 @noindent
4330 where @var{T} is the type of @code{Arg}.
4331 The effect is thus similar to first doing an unchecked conversion from
4332 the fixed-point type to its corresponding implementation type, and then
4333 converting the result to the target integer type.  The difference is
4334 that there are full range checks, to ensure that the result is in range.
4335 This attribute is primarily intended for use in implementation of the
4336 standard input-output functions for fixed-point values.
4337
4338 @node Large
4339 @unnumberedsec Large
4340 @cindex Ada 83 attributes
4341 @findex Large
4342 @noindent
4343 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4344 the Ada 83 reference manual for an exact description of the semantics of
4345 this attribute.
4346
4347 @node Machine_Size
4348 @unnumberedsec Machine_Size
4349 @findex Machine_Size
4350 @noindent
4351 This attribute is identical to the @code{Object_Size} attribute.  It is
4352 provided for compatibility with the DEC Ada 83 attribute of this name.
4353
4354 @node Mantissa
4355 @unnumberedsec Mantissa
4356 @cindex Ada 83 attributes
4357 @findex Mantissa
4358 @noindent
4359 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4360 the Ada 83 reference manual for an exact description of the semantics of
4361 this attribute.
4362
4363 @node Max_Interrupt_Priority
4364 @unnumberedsec Max_Interrupt_Priority
4365 @cindex Interrupt priority, maximum
4366 @findex Max_Interrupt_Priority
4367 @noindent
4368 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4369 permissible prefix), provides the same value as
4370 @code{System.Max_Interrupt_Priority}.
4371
4372 @node Max_Priority
4373 @unnumberedsec Max_Priority
4374 @cindex Priority, maximum
4375 @findex Max_Priority
4376 @noindent
4377 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4378 prefix) provides the same value as @code{System.Max_Priority}.
4379
4380 @node Maximum_Alignment
4381 @unnumberedsec Maximum_Alignment
4382 @cindex Alignment, maximum
4383 @findex Maximum_Alignment
4384 @noindent
4385 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4386 permissible prefix) provides the maximum useful alignment value for the
4387 target.  This is a static value that can be used to specify the alignment
4388 for an object, guaranteeing that it is properly aligned in all
4389 cases.
4390
4391 @node Mechanism_Code
4392 @unnumberedsec Mechanism_Code
4393 @cindex Return values, passing mechanism
4394 @cindex Parameters, passing mechanism
4395 @findex Mechanism_Code
4396 @noindent
4397 @code{@var{function}'Mechanism_Code} yields an integer code for the
4398 mechanism used for the result of function, and
4399 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4400 used for formal parameter number @var{n} (a static integer value with 1
4401 meaning the first parameter) of @var{subprogram}.  The code returned is:
4402
4403 @table @asis
4404 @item 1
4405 by copy (value)
4406 @item 2
4407 by reference
4408 @item 3
4409 by descriptor (default descriptor class)
4410 @item 4
4411 by descriptor (UBS: unaligned bit string)
4412 @item 5
4413 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4414 @item 6
4415 by descriptor (UBA: unaligned bit array)
4416 @item 7
4417 by descriptor (S: string, also scalar access type parameter)
4418 @item 8
4419 by descriptor (SB: string with arbitrary bounds)
4420 @item 9
4421 by descriptor (A: contiguous array)
4422 @item 10
4423 by descriptor (NCA: non-contiguous array)
4424 @end table
4425
4426 @noindent
4427 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4428 @cindex OpenVMS
4429
4430 @node Null_Parameter
4431 @unnumberedsec Null_Parameter
4432 @cindex Zero address, passing
4433 @findex Null_Parameter
4434 @noindent
4435 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4436 type or subtype @var{T} allocated at machine address zero.  The attribute
4437 is allowed only as the default expression of a formal parameter, or as
4438 an actual expression of a subprogram call.  In either case, the
4439 subprogram must be imported.
4440
4441 The identity of the object is represented by the address zero in the
4442 argument list, independent of the passing mechanism (explicit or
4443 default).
4444
4445 This capability is needed to specify that a zero address should be
4446 passed for a record or other composite object passed by reference.
4447 There is no way of indicating this without the @code{Null_Parameter}
4448 attribute.
4449
4450 @node Object_Size
4451 @unnumberedsec Object_Size
4452 @cindex Size, used for objects
4453 @findex Object_Size
4454 @noindent
4455 The size of an object is not necessarily the same as the size of the type
4456 of an object.  This is because by default object sizes are increased to be
4457 a multiple of the alignment of the object.  For example,
4458 @code{Natural'Size} is
4459 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4460 Similarly, a record containing an integer and a character:
4461
4462 @smallexample @c ada
4463 type Rec is record
4464    I : Integer;
4465    C : Character;
4466 end record;
4467 @end smallexample
4468
4469 @noindent
4470 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4471 alignment will be 4, because of the
4472 integer field, and so the default size of record objects for this type
4473 will be 64 (8 bytes).
4474
4475 The @code{@var{type}'Object_Size} attribute
4476 has been added to GNAT to allow the
4477 default object size of a type to be easily determined.  For example,
4478 @code{Natural'Object_Size} is 32, and
4479 @code{Rec'Object_Size} (for the record type in the above example) will be
4480 64.  Note also that, unlike the situation with the
4481 @code{Size} attribute as defined in the Ada RM, the
4482 @code{Object_Size} attribute can be specified individually
4483 for different subtypes.  For example:
4484
4485 @smallexample @c ada
4486 type R is new Integer;
4487 subtype R1 is R range 1 .. 10;
4488 subtype R2 is R range 1 .. 10;
4489 for R2'Object_Size use 8;
4490 @end smallexample
4491
4492 @noindent
4493 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4494 32 since the default object size for a subtype is the same as the object size
4495 for the parent subtype.  This means that objects of type @code{R}
4496 or @code{R1} will
4497 by default be 32 bits (four bytes).  But objects of type
4498 @code{R2} will be only
4499 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4500
4501 @node Passed_By_Reference
4502 @unnumberedsec Passed_By_Reference
4503 @cindex Parameters, when passed by reference
4504 @findex Passed_By_Reference
4505 @noindent
4506 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4507 a value of type @code{Boolean} value that is @code{True} if the type is
4508 normally passed by reference and @code{False} if the type is normally
4509 passed by copy in calls.  For scalar types, the result is always @code{False}
4510 and is static.  For non-scalar types, the result is non-static.
4511
4512 @node Range_Length
4513 @unnumberedsec Range_Length
4514 @findex Range_Length
4515 @noindent
4516 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4517 the number of values represented by the subtype (zero for a null
4518 range).  The result is static for static subtypes.  @code{Range_Length}
4519 applied to the index subtype of a one dimensional array always gives the
4520 same result as @code{Range} applied to the array itself.
4521
4522 @node Safe_Emax
4523 @unnumberedsec Safe_Emax
4524 @cindex Ada 83 attributes
4525 @findex Safe_Emax
4526 @noindent
4527 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4528 the Ada 83 reference manual for an exact description of the semantics of
4529 this attribute.
4530
4531 @node Safe_Large
4532 @unnumberedsec Safe_Large
4533 @cindex Ada 83 attributes
4534 @findex Safe_Large
4535 @noindent
4536 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4537 the Ada 83 reference manual for an exact description of the semantics of
4538 this attribute.
4539
4540 @node Small
4541 @unnumberedsec Small
4542 @cindex Ada 83 attributes
4543 @findex Small
4544 @noindent
4545 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4546 GNAT also allows this attribute to be applied to floating-point types
4547 for compatibility with Ada 83.  See
4548 the Ada 83 reference manual for an exact description of the semantics of
4549 this attribute when applied to floating-point types.
4550
4551 @node Storage_Unit
4552 @unnumberedsec Storage_Unit
4553 @findex Storage_Unit
4554 @noindent
4555 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4556 prefix) provides the same value as @code{System.Storage_Unit}.
4557
4558 @node Target_Name
4559 @unnumberedsec Target_Name
4560 @findex Target_Name
4561 @noindent
4562 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4563 prefix) provides a static string value that identifies the target
4564 for the current compilation. For GCC implementations, this is the
4565 standard gcc target name without the terminating slash (for
4566 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4567
4568 @node Tick
4569 @unnumberedsec Tick
4570 @findex Tick
4571 @noindent
4572 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4573 provides the same value as @code{System.Tick},
4574
4575 @node To_Address
4576 @unnumberedsec To_Address
4577 @findex To_Address
4578 @noindent
4579 The @code{System'To_Address}
4580 (@code{System} is the only permissible prefix)
4581 denotes a function identical to
4582 @code{System.Storage_Elements.To_Address} except that
4583 it is a static attribute.  This means that if its argument is
4584 a static expression, then the result of the attribute is a
4585 static expression.  The result is that such an expression can be
4586 used in contexts (e.g.@: preelaborable packages) which require a
4587 static expression and where the function call could not be used
4588 (since the function call is always non-static, even if its
4589 argument is static).
4590
4591 @node Type_Class
4592 @unnumberedsec Type_Class
4593 @findex Type_Class
4594 @noindent
4595 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4596 the value of the type class for the full type of @var{type}.  If
4597 @var{type} is a generic formal type, the value is the value for the
4598 corresponding actual subtype.  The value of this attribute is of type
4599 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4600
4601 @smallexample @c ada
4602   type Type_Class is
4603     (Type_Class_Enumeration,
4604      Type_Class_Integer,
4605      Type_Class_Fixed_Point,
4606      Type_Class_Floating_Point,
4607      Type_Class_Array,
4608      Type_Class_Record,
4609      Type_Class_Access,
4610      Type_Class_Task,
4611      Type_Class_Address);
4612 @end smallexample
4613
4614 @noindent
4615 Protected types yield the value @code{Type_Class_Task}, which thus
4616 applies to all concurrent types.  This attribute is designed to
4617 be compatible with the DEC Ada 83 attribute of the same name.
4618
4619 @node UET_Address
4620 @unnumberedsec UET_Address
4621 @findex UET_Address
4622 @noindent
4623 The @code{UET_Address} attribute can only be used for a prefix which
4624 denotes a library package.  It yields the address of the unit exception
4625 table when zero cost exception handling is used.  This attribute is
4626 intended only for use within the GNAT implementation.  See the unit
4627 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4628 for details on how this attribute is used in the implementation.
4629
4630 @node Unconstrained_Array
4631 @unnumberedsec Unconstrained_Array
4632 @findex Unconstrained_Array
4633 @noindent
4634 The @code{Unconstrained_Array} attribute can be used with a prefix that
4635 denotes any type or subtype. It is a static attribute that yields
4636 @code{True} if the prefix designates an unconstrained array,
4637 and @code{False} otherwise. In a generic instance, the result is
4638 still static, and yields the result of applying this test to the
4639 generic actual.
4640
4641 @node Universal_Literal_String
4642 @unnumberedsec Universal_Literal_String
4643 @cindex Named numbers, representation of
4644 @findex Universal_Literal_String
4645 @noindent
4646 The prefix of @code{Universal_Literal_String} must be a named
4647 number.  The static result is the string consisting of the characters of
4648 the number as defined in the original source.  This allows the user
4649 program to access the actual text of named numbers without intermediate
4650 conversions and without the need to enclose the strings in quotes (which
4651 would preclude their use as numbers).  This is used internally for the
4652 construction of values of the floating-point attributes from the file
4653 @file{ttypef.ads}, but may also be used by user programs.
4654
4655 @node Unrestricted_Access
4656 @unnumberedsec Unrestricted_Access
4657 @cindex @code{Access}, unrestricted
4658 @findex Unrestricted_Access
4659 @noindent
4660 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4661 except that all accessibility and aliased view checks are omitted.  This
4662 is a user-beware attribute.  It is similar to
4663 @code{Address}, for which it is a desirable replacement where the value
4664 desired is an access type.  In other words, its effect is identical to
4665 first applying the @code{Address} attribute and then doing an unchecked
4666 conversion to a desired access type.  In GNAT, but not necessarily in
4667 other implementations, the use of static chains for inner level
4668 subprograms means that @code{Unrestricted_Access} applied to a
4669 subprogram yields a value that can be called as long as the subprogram
4670 is in scope (normal Ada 95 accessibility rules restrict this usage).
4671
4672 It is possible to use @code{Unrestricted_Access} for any type, but care
4673 must be excercised if it is used to create pointers to unconstrained
4674 objects. In this case, the resulting pointer has the same scope as the
4675 context of the attribute, and may not be returned to some enclosing
4676 scope. For instance, a function cannot use @code{Unrestricted_Access}
4677 to create a unconstrained pointer and then return that value to the
4678 caller.
4679
4680 @node VADS_Size
4681 @unnumberedsec VADS_Size
4682 @cindex @code{Size}, VADS compatibility
4683 @findex VADS_Size
4684 @noindent
4685 The @code{'VADS_Size} attribute is intended to make it easier to port
4686 legacy code which relies on the semantics of @code{'Size} as implemented
4687 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4688 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4689 to a predefined or other primitive type with no Size clause yields the
4690 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4691 typical machines).  In addition @code{'VADS_Size} applied to an object
4692 gives the result that would be obtained by applying the attribute to
4693 the corresponding type.
4694
4695 @node Value_Size
4696 @unnumberedsec Value_Size
4697 @cindex @code{Size}, setting for not-first subtype
4698 @findex Value_Size
4699 @code{@var{type}'Value_Size} is the number of bits required to represent
4700 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4701 but, unlike @code{Size}, may be set for non-first subtypes.
4702
4703 @node Wchar_T_Size
4704 @unnumberedsec Wchar_T_Size
4705 @findex Wchar_T_Size
4706 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4707 prefix) provides the size in bits of the C @code{wchar_t} type
4708 primarily for constructing the definition of this type in
4709 package @code{Interfaces.C}.
4710
4711 @node Word_Size
4712 @unnumberedsec Word_Size
4713 @findex Word_Size
4714 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4715 prefix) provides the value @code{System.Word_Size}.
4716
4717 @c ------------------------
4718 @node Implementation Advice
4719 @chapter Implementation Advice
4720 @noindent
4721 The main text of the Ada 95 Reference Manual describes the required
4722 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4723 these requirements.
4724
4725 In addition, there are sections throughout the Ada 95
4726 reference manual headed
4727 by the phrase ``implementation advice''.  These sections are not normative,
4728 i.e.@: they do not specify requirements that all compilers must
4729 follow.  Rather they provide advice on generally desirable behavior.  You
4730 may wonder why they are not requirements.  The most typical answer is
4731 that they describe behavior that seems generally desirable, but cannot
4732 be provided on all systems, or which may be undesirable on some systems.
4733
4734 As far as practical, GNAT follows the implementation advice sections in
4735 the Ada 95 Reference Manual.  This chapter contains a table giving the
4736 reference manual section number, paragraph number and several keywords
4737 for each advice.  Each entry consists of the text of the advice followed
4738 by the GNAT interpretation of this advice.  Most often, this simply says
4739 ``followed'', which means that GNAT follows the advice.  However, in a
4740 number of cases, GNAT deliberately deviates from this advice, in which
4741 case the text describes what GNAT does and why.
4742
4743 @cindex Error detection
4744 @unnumberedsec 1.1.3(20): Error Detection
4745 @sp 1
4746 @cartouche
4747 If an implementation detects the use of an unsupported Specialized Needs
4748 Annex feature at run time, it should raise @code{Program_Error} if
4749 feasible.
4750 @end cartouche
4751 Not relevant.  All specialized needs annex features are either supported,
4752 or diagnosed at compile time.
4753
4754 @cindex Child Units
4755 @unnumberedsec 1.1.3(31): Child Units
4756 @sp 1
4757 @cartouche
4758 If an implementation wishes to provide implementation-defined
4759 extensions to the functionality of a language-defined library unit, it
4760 should normally do so by adding children to the library unit.
4761 @end cartouche
4762 Followed.
4763
4764 @cindex Bounded errors
4765 @unnumberedsec 1.1.5(12): Bounded Errors
4766 @sp 1
4767 @cartouche
4768 If an implementation detects a bounded error or erroneous
4769 execution, it should raise @code{Program_Error}.
4770 @end cartouche
4771 Followed in all cases in which the implementation detects a bounded
4772 error or erroneous execution.  Not all such situations are detected at
4773 runtime.
4774
4775 @cindex Pragmas
4776 @unnumberedsec 2.8(16): Pragmas
4777 @sp 1
4778 @cartouche
4779 Normally, implementation-defined pragmas should have no semantic effect
4780 for error-free programs; that is, if the implementation-defined pragmas
4781 are removed from a working program, the program should still be legal,
4782 and should still have the same semantics.
4783 @end cartouche
4784 The following implementation defined pragmas are exceptions to this
4785 rule:
4786
4787 @table @code
4788 @item Abort_Defer
4789 Affects semantics
4790 @item Ada_83
4791 Affects legality
4792 @item Assert
4793 Affects semantics
4794 @item CPP_Class
4795 Affects semantics
4796 @item CPP_Constructor
4797 Affects semantics
4798 @item CPP_Virtual
4799 Affects semantics
4800 @item CPP_Vtable
4801 Affects semantics
4802 @item Debug
4803 Affects semantics
4804 @item Interface_Name
4805 Affects semantics
4806 @item Machine_Attribute
4807 Affects semantics
4808 @item Unimplemented_Unit
4809 Affects legality
4810 @item Unchecked_Union
4811 Affects semantics
4812 @end table
4813
4814 @noindent
4815 In each of the above cases, it is essential to the purpose of the pragma
4816 that this advice not be followed.  For details see the separate section
4817 on implementation defined pragmas.
4818
4819 @unnumberedsec 2.8(17-19): Pragmas
4820 @sp 1
4821 @cartouche
4822 Normally, an implementation should not define pragmas that can
4823 make an illegal program legal, except as follows:
4824 @end cartouche
4825 @sp 1
4826 @cartouche
4827 A pragma used to complete a declaration, such as a pragma @code{Import};
4828 @end cartouche
4829 @sp 1
4830 @cartouche
4831 A pragma used to configure the environment by adding, removing, or
4832 replacing @code{library_items}.
4833 @end cartouche
4834 See response to paragraph 16 of this same section.
4835
4836 @cindex Character Sets
4837 @cindex Alternative Character Sets
4838 @unnumberedsec 3.5.2(5): Alternative Character Sets
4839 @sp 1
4840 @cartouche
4841 If an implementation supports a mode with alternative interpretations
4842 for @code{Character} and @code{Wide_Character}, the set of graphic
4843 characters of @code{Character} should nevertheless remain a proper
4844 subset of the set of graphic characters of @code{Wide_Character}.  Any
4845 character set ``localizations'' should be reflected in the results of
4846 the subprograms defined in the language-defined package
4847 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4848 an alternative interpretation of @code{Character}, the implementation should
4849 also support a corresponding change in what is a legal
4850 @code{identifier_letter}.
4851 @end cartouche
4852 Not all wide character modes follow this advice, in particular the JIS
4853 and IEC modes reflect standard usage in Japan, and in these encoding,
4854 the upper half of the Latin-1 set is not part of the wide-character
4855 subset, since the most significant bit is used for wide character
4856 encoding.  However, this only applies to the external forms.  Internally
4857 there is no such restriction.
4858
4859 @cindex Integer types
4860 @unnumberedsec 3.5.4(28): Integer Types
4861
4862 @sp 1
4863 @cartouche
4864 An implementation should support @code{Long_Integer} in addition to
4865 @code{Integer} if the target machine supports 32-bit (or longer)
4866 arithmetic.  No other named integer subtypes are recommended for package
4867 @code{Standard}.  Instead, appropriate named integer subtypes should be
4868 provided in the library package @code{Interfaces} (see B.2).
4869 @end cartouche
4870 @code{Long_Integer} is supported.  Other standard integer types are supported
4871 so this advice is not fully followed.  These types
4872 are supported for convenient interface to C, and so that all hardware
4873 types of the machine are easily available.
4874 @unnumberedsec 3.5.4(29): Integer Types
4875
4876 @sp 1
4877 @cartouche
4878 An implementation for a two's complement machine should support
4879 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4880 implementation should support a non-binary modules up to @code{Integer'Last}.
4881 @end cartouche
4882 Followed.
4883
4884 @cindex Enumeration values
4885 @unnumberedsec 3.5.5(8): Enumeration Values
4886 @sp 1
4887 @cartouche
4888 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4889 subtype, if the value of the operand does not correspond to the internal
4890 code for any enumeration literal of its type (perhaps due to an
4891 un-initialized variable), then the implementation should raise
4892 @code{Program_Error}.  This is particularly important for enumeration
4893 types with noncontiguous internal codes specified by an
4894 enumeration_representation_clause.
4895 @end cartouche
4896 Followed.
4897
4898 @cindex Float types
4899 @unnumberedsec 3.5.7(17): Float Types
4900 @sp 1
4901 @cartouche
4902 An implementation should support @code{Long_Float} in addition to
4903 @code{Float} if the target machine supports 11 or more digits of
4904 precision.  No other named floating point subtypes are recommended for
4905 package @code{Standard}.  Instead, appropriate named floating point subtypes
4906 should be provided in the library package @code{Interfaces} (see B.2).
4907 @end cartouche
4908 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4909 former provides improved compatibility with other implementations
4910 supporting this type.  The latter corresponds to the highest precision
4911 floating-point type supported by the hardware.  On most machines, this
4912 will be the same as @code{Long_Float}, but on some machines, it will
4913 correspond to the IEEE extended form.  The notable case is all ia32
4914 (x86) implementations, where @code{Long_Long_Float} corresponds to
4915 the 80-bit extended precision format supported in hardware on this
4916 processor.  Note that the 128-bit format on SPARC is not supported,
4917 since this is a software rather than a hardware format.
4918
4919 @cindex Multidimensional arrays
4920 @cindex Arrays, multidimensional
4921 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4922 @sp 1
4923 @cartouche
4924 An implementation should normally represent multidimensional arrays in
4925 row-major order, consistent with the notation used for multidimensional
4926 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
4927 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4928 column-major order should be used instead (see B.5, ``Interfacing with
4929 Fortran'').
4930 @end cartouche
4931 Followed.
4932
4933 @findex Duration'Small
4934 @unnumberedsec 9.6(30-31): Duration'Small
4935 @sp 1
4936 @cartouche
4937 Whenever possible in an implementation, the value of @code{Duration'Small}
4938 should be no greater than 100 microseconds.
4939 @end cartouche
4940 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
4941
4942 @sp 1
4943 @cartouche
4944 The time base for @code{delay_relative_statements} should be monotonic;
4945 it need not be the same time base as used for @code{Calendar.Clock}.
4946 @end cartouche
4947 Followed.
4948
4949 @unnumberedsec 10.2.1(12): Consistent Representation
4950 @sp 1
4951 @cartouche
4952 In an implementation, a type declared in a pre-elaborated package should
4953 have the same representation in every elaboration of a given version of
4954 the package, whether the elaborations occur in distinct executions of
4955 the same program, or in executions of distinct programs or partitions
4956 that include the given version.
4957 @end cartouche
4958 Followed, except in the case of tagged types.  Tagged types involve
4959 implicit pointers to a local copy of a dispatch table, and these pointers
4960 have representations which thus depend on a particular elaboration of the
4961 package.  It is not easy to see how it would be possible to follow this
4962 advice without severely impacting efficiency of execution.
4963
4964 @cindex Exception information
4965 @unnumberedsec 11.4.1(19): Exception Information
4966 @sp 1
4967 @cartouche
4968 @code{Exception_Message} by default and @code{Exception_Information}
4969 should produce information useful for
4970 debugging.  @code{Exception_Message} should be short, about one
4971 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
4972 should not include the
4973 @code{Exception_Name}.  @code{Exception_Information} should include both
4974 the @code{Exception_Name} and the @code{Exception_Message}.
4975 @end cartouche
4976 Followed.  For each exception that doesn't have a specified
4977 @code{Exception_Message}, the compiler generates one containing the location
4978 of the raise statement.  This location has the form ``file:line'', where
4979 file is the short file name (without path information) and line is the line
4980 number in the file.  Note that in the case of the Zero Cost Exception
4981 mechanism, these messages become redundant with the Exception_Information that
4982 contains a full backtrace of the calling sequence, so they are disabled.
4983 To disable explicitly the generation of the source location message, use the
4984 Pragma @code{Discard_Names}.
4985
4986 @cindex Suppression of checks
4987 @cindex Checks, suppression of
4988 @unnumberedsec 11.5(28): Suppression of Checks
4989 @sp 1
4990 @cartouche
4991 The implementation should minimize the code executed for checks that
4992 have been suppressed.
4993 @end cartouche
4994 Followed.
4995
4996 @cindex Representation clauses
4997 @unnumberedsec 13.1 (21-24): Representation Clauses
4998 @sp 1
4999 @cartouche
5000 The recommended level of support for all representation items is
5001 qualified as follows:
5002 @end cartouche
5003 @sp 1
5004 @cartouche
5005 An implementation need not support representation items containing
5006 non-static expressions, except that an implementation should support a
5007 representation item for a given entity if each non-static expression in
5008 the representation item is a name that statically denotes a constant
5009 declared before the entity.
5010 @end cartouche
5011 Followed.  GNAT does not support non-static expressions in representation
5012 clauses unless they are constants declared before the entity.  For
5013 example:
5014
5015 @smallexample @c ada
5016 X : Some_Type;
5017 for X'Address use To_address (16#2000#);
5018 @end smallexample
5019
5020 @noindent
5021 will be rejected, since the To_Address expression is non-static.  Instead
5022 write:
5023
5024 @smallexample @c ada
5025 X_Address : constant Address : = To_Address (16#2000#);
5026 X         : Some_Type;
5027 for X'Address use X_Address;
5028 @end smallexample
5029
5030 @sp 1
5031 @cartouche
5032 An implementation need not support a specification for the @code{Size}
5033 for a given composite subtype, nor the size or storage place for an
5034 object (including a component) of a given composite subtype, unless the
5035 constraints on the subtype and its composite subcomponents (if any) are
5036 all static constraints.
5037 @end cartouche
5038 Followed.  Size Clauses are not permitted on non-static components, as
5039 described above.
5040
5041 @sp 1
5042 @cartouche
5043 An aliased component, or a component whose type is by-reference, should
5044 always be allocated at an addressable location.
5045 @end cartouche
5046 Followed.
5047
5048 @cindex Packed types
5049 @unnumberedsec 13.2(6-8): Packed Types
5050 @sp 1
5051 @cartouche
5052 If a type is packed, then the implementation should try to minimize
5053 storage allocated to objects of the type, possibly at the expense of
5054 speed of accessing components, subject to reasonable complexity in
5055 addressing calculations.
5056 @end cartouche
5057 @sp 1
5058 @cartouche
5059 The recommended level of support pragma @code{Pack} is:
5060
5061 For a packed record type, the components should be packed as tightly as
5062 possible subject to the Sizes of the component subtypes, and subject to
5063 any @code{record_representation_clause} that applies to the type; the
5064 implementation may, but need not, reorder components or cross aligned
5065 word boundaries to improve the packing.  A component whose @code{Size} is
5066 greater than the word size may be allocated an integral number of words.
5067 @end cartouche
5068 Followed.  Tight packing of arrays is supported for all component sizes
5069 up to 64-bits. If the array component size is 1 (that is to say, if
5070 the component is a boolean type or an enumeration type with two values)
5071 then values of the type are implicitly initialized to zero. This
5072 happens both for objects of the packed type, and for objects that have a
5073 subcomponent of the packed type.
5074
5075 @sp 1
5076 @cartouche
5077 An implementation should support Address clauses for imported
5078 subprograms.
5079 @end cartouche
5080 Followed.
5081 @cindex @code{Address} clauses
5082 @unnumberedsec 13.3(14-19): Address Clauses
5083
5084 @sp 1
5085 @cartouche
5086 For an array @var{X}, @code{@var{X}'Address} should point at the first
5087 component of the array, and not at the array bounds.
5088 @end cartouche
5089 Followed.
5090
5091 @sp 1
5092 @cartouche
5093 The recommended level of support for the @code{Address} attribute is:
5094
5095 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5096 object that is aliased or of a by-reference type, or is an entity whose
5097 @code{Address} has been specified.
5098 @end cartouche
5099 Followed.  A valid address will be produced even if none of those
5100 conditions have been met.  If necessary, the object is forced into
5101 memory to ensure the address is valid.
5102
5103 @sp 1
5104 @cartouche
5105 An implementation should support @code{Address} clauses for imported
5106 subprograms.
5107 @end cartouche
5108 Followed.
5109
5110 @sp 1
5111 @cartouche
5112 Objects (including subcomponents) that are aliased or of a by-reference
5113 type should be allocated on storage element boundaries.
5114 @end cartouche
5115 Followed.
5116
5117 @sp 1
5118 @cartouche
5119 If the @code{Address} of an object is specified, or it is imported or exported,
5120 then the implementation should not perform optimizations based on
5121 assumptions of no aliases.
5122 @end cartouche
5123 Followed.
5124
5125 @cindex @code{Alignment} clauses
5126 @unnumberedsec 13.3(29-35): Alignment Clauses
5127 @sp 1
5128 @cartouche
5129 The recommended level of support for the @code{Alignment} attribute for
5130 subtypes is:
5131
5132 An implementation should support specified Alignments that are factors
5133 and multiples of the number of storage elements per word, subject to the
5134 following:
5135 @end cartouche
5136 Followed.
5137
5138 @sp 1
5139 @cartouche
5140 An implementation need not support specified @code{Alignment}s for
5141 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5142 loaded and stored by available machine instructions.
5143 @end cartouche
5144 Followed.
5145
5146 @sp 1
5147 @cartouche
5148 An implementation need not support specified @code{Alignment}s that are
5149 greater than the maximum @code{Alignment} the implementation ever returns by
5150 default.
5151 @end cartouche
5152 Followed.
5153
5154 @sp 1
5155 @cartouche
5156 The recommended level of support for the @code{Alignment} attribute for
5157 objects is:
5158
5159 Same as above, for subtypes, but in addition:
5160 @end cartouche
5161 Followed.
5162
5163 @sp 1
5164 @cartouche
5165 For stand-alone library-level objects of statically constrained
5166 subtypes, the implementation should support all @code{Alignment}s
5167 supported by the target linker.  For example, page alignment is likely to
5168 be supported for such objects, but not for subtypes.
5169 @end cartouche
5170 Followed.
5171
5172 @cindex @code{Size} clauses
5173 @unnumberedsec 13.3(42-43): Size Clauses
5174 @sp 1
5175 @cartouche
5176 The recommended level of support for the @code{Size} attribute of
5177 objects is:
5178
5179 A @code{Size} clause should be supported for an object if the specified
5180 @code{Size} is at least as large as its subtype's @code{Size}, and
5181 corresponds to a size in storage elements that is a multiple of the
5182 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5183 @end cartouche
5184 Followed.
5185
5186 @unnumberedsec 13.3(50-56): Size Clauses
5187 @sp 1
5188 @cartouche
5189 If the @code{Size} of a subtype is specified, and allows for efficient
5190 independent addressability (see 9.10) on the target architecture, then
5191 the @code{Size} of the following objects of the subtype should equal the
5192 @code{Size} of the subtype:
5193
5194 Aliased objects (including components).
5195 @end cartouche
5196 Followed.
5197
5198 @sp 1
5199 @cartouche
5200 @code{Size} clause on a composite subtype should not affect the
5201 internal layout of components.
5202 @end cartouche
5203 Followed.
5204
5205 @sp 1
5206 @cartouche
5207 The recommended level of support for the @code{Size} attribute of subtypes is:
5208 @end cartouche
5209 @sp 1
5210 @cartouche
5211 The @code{Size} (if not specified) of a static discrete or fixed point
5212 subtype should be the number of bits needed to represent each value
5213 belonging to the subtype using an unbiased representation, leaving space
5214 for a sign bit only if the subtype contains negative values.  If such a
5215 subtype is a first subtype, then an implementation should support a
5216 specified @code{Size} for it that reflects this representation.
5217 @end cartouche
5218 Followed.
5219
5220 @sp 1
5221 @cartouche
5222 For a subtype implemented with levels of indirection, the @code{Size}
5223 should include the size of the pointers, but not the size of what they
5224 point at.
5225 @end cartouche
5226 Followed.
5227
5228 @cindex @code{Component_Size} clauses
5229 @unnumberedsec 13.3(71-73): Component Size Clauses
5230 @sp 1
5231 @cartouche
5232 The recommended level of support for the @code{Component_Size}
5233 attribute is:
5234 @end cartouche
5235 @sp 1
5236 @cartouche
5237 An implementation need not support specified @code{Component_Sizes} that are
5238 less than the @code{Size} of the component subtype.
5239 @end cartouche
5240 Followed.
5241
5242 @sp 1
5243 @cartouche
5244 An implementation should support specified @code{Component_Size}s that
5245 are factors and multiples of the word size.  For such
5246 @code{Component_Size}s, the array should contain no gaps between
5247 components.  For other @code{Component_Size}s (if supported), the array
5248 should contain no gaps between components when packing is also
5249 specified; the implementation should forbid this combination in cases
5250 where it cannot support a no-gaps representation.
5251 @end cartouche
5252 Followed.
5253
5254 @cindex Enumeration representation clauses
5255 @cindex Representation clauses, enumeration
5256 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5257 @sp 1
5258 @cartouche
5259 The recommended level of support for enumeration representation clauses
5260 is:
5261
5262 An implementation need not support enumeration representation clauses
5263 for boolean types, but should at minimum support the internal codes in
5264 the range @code{System.Min_Int.System.Max_Int}.
5265 @end cartouche
5266 Followed.
5267
5268 @cindex Record representation clauses
5269 @cindex Representation clauses, records
5270 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5271 @sp 1
5272 @cartouche
5273 The recommended level of support for
5274 @*@code{record_representation_clauses} is:
5275
5276 An implementation should support storage places that can be extracted
5277 with a load, mask, shift sequence of machine code, and set with a load,
5278 shift, mask, store sequence, given the available machine instructions
5279 and run-time model.
5280 @end cartouche
5281 Followed.
5282
5283 @sp 1
5284 @cartouche
5285 A storage place should be supported if its size is equal to the
5286 @code{Size} of the component subtype, and it starts and ends on a
5287 boundary that obeys the @code{Alignment} of the component subtype.
5288 @end cartouche
5289 Followed.
5290
5291 @sp 1
5292 @cartouche
5293 If the default bit ordering applies to the declaration of a given type,
5294 then for a component whose subtype's @code{Size} is less than the word
5295 size, any storage place that does not cross an aligned word boundary
5296 should be supported.
5297 @end cartouche
5298 Followed.
5299
5300 @sp 1
5301 @cartouche
5302 An implementation may reserve a storage place for the tag field of a
5303 tagged type, and disallow other components from overlapping that place.
5304 @end cartouche
5305 Followed.  The storage place for the tag field is the beginning of the tagged
5306 record, and its size is Address'Size.  GNAT will reject an explicit component
5307 clause for the tag field.
5308
5309 @sp 1
5310 @cartouche
5311 An implementation need not support a @code{component_clause} for a
5312 component of an extension part if the storage place is not after the
5313 storage places of all components of the parent type, whether or not
5314 those storage places had been specified.
5315 @end cartouche
5316 Followed.  The above advice on record representation clauses is followed,
5317 and all mentioned features are implemented.
5318
5319 @cindex Storage place attributes
5320 @unnumberedsec 13.5.2(5): Storage Place Attributes
5321 @sp 1
5322 @cartouche
5323 If a component is represented using some form of pointer (such as an
5324 offset) to the actual data of the component, and this data is contiguous
5325 with the rest of the object, then the storage place attributes should
5326 reflect the place of the actual data, not the pointer.  If a component is
5327 allocated discontinuously from the rest of the object, then a warning
5328 should be generated upon reference to one of its storage place
5329 attributes.
5330 @end cartouche
5331 Followed.  There are no such components in GNAT@.
5332
5333 @cindex Bit ordering
5334 @unnumberedsec 13.5.3(7-8): Bit Ordering
5335 @sp 1
5336 @cartouche
5337 The recommended level of support for the non-default bit ordering is:
5338 @end cartouche
5339 @sp 1
5340 @cartouche
5341 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5342 should support the non-default bit ordering in addition to the default
5343 bit ordering.
5344 @end cartouche
5345 Followed.  Word size does not equal storage size in this implementation.
5346 Thus non-default bit ordering is not supported.
5347
5348 @cindex @code{Address}, as private type
5349 @unnumberedsec 13.7(37): Address as Private
5350 @sp 1
5351 @cartouche
5352 @code{Address} should be of a private type.
5353 @end cartouche
5354 Followed.
5355
5356 @cindex Operations, on @code{Address}
5357 @cindex @code{Address}, operations of
5358 @unnumberedsec 13.7.1(16): Address Operations
5359 @sp 1
5360 @cartouche
5361 Operations in @code{System} and its children should reflect the target
5362 environment semantics as closely as is reasonable.  For example, on most
5363 machines, it makes sense for address arithmetic to ``wrap around''.
5364 Operations that do not make sense should raise @code{Program_Error}.
5365 @end cartouche
5366 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5367 operation raises @code{Program_Error}, since all operations make sense.
5368
5369 @cindex Unchecked conversion
5370 @unnumberedsec 13.9(14-17): Unchecked Conversion
5371 @sp 1
5372 @cartouche
5373 The @code{Size} of an array object should not include its bounds; hence,
5374 the bounds should not be part of the converted data.
5375 @end cartouche
5376 Followed.
5377
5378 @sp 1
5379 @cartouche
5380 The implementation should not generate unnecessary run-time checks to
5381 ensure that the representation of @var{S} is a representation of the
5382 target type.  It should take advantage of the permission to return by
5383 reference when possible.  Restrictions on unchecked conversions should be
5384 avoided unless required by the target environment.
5385 @end cartouche
5386 Followed.  There are no restrictions on unchecked conversion.  A warning is
5387 generated if the source and target types do not have the same size since
5388 the semantics in this case may be target dependent.
5389
5390 @sp 1
5391 @cartouche
5392 The recommended level of support for unchecked conversions is:
5393 @end cartouche
5394 @sp 1
5395 @cartouche
5396 Unchecked conversions should be supported and should be reversible in
5397 the cases where this clause defines the result.  To enable meaningful use
5398 of unchecked conversion, a contiguous representation should be used for
5399 elementary subtypes, for statically constrained array subtypes whose
5400 component subtype is one of the subtypes described in this paragraph,
5401 and for record subtypes without discriminants whose component subtypes
5402 are described in this paragraph.
5403 @end cartouche
5404 Followed.
5405
5406 @cindex Heap usage, implicit
5407 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5408 @sp 1
5409 @cartouche
5410 An implementation should document any cases in which it dynamically
5411 allocates heap storage for a purpose other than the evaluation of an
5412 allocator.
5413 @end cartouche
5414 Followed, the only other points at which heap storage is dynamically
5415 allocated are as follows:
5416
5417 @itemize @bullet
5418 @item
5419 At initial elaboration time, to allocate dynamically sized global
5420 objects.
5421
5422 @item
5423 To allocate space for a task when a task is created.
5424
5425 @item
5426 To extend the secondary stack dynamically when needed.  The secondary
5427 stack is used for returning variable length results.
5428 @end itemize
5429
5430 @sp 1
5431 @cartouche
5432 A default (implementation-provided) storage pool for an
5433 access-to-constant type should not have overhead to support deallocation of
5434 individual objects.
5435 @end cartouche
5436 Followed.
5437
5438 @sp 1
5439 @cartouche
5440 A storage pool for an anonymous access type should be created at the
5441 point of an allocator for the type, and be reclaimed when the designated
5442 object becomes inaccessible.
5443 @end cartouche
5444 Followed.
5445
5446 @cindex Unchecked deallocation
5447 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5448 @sp 1
5449 @cartouche
5450 For a standard storage pool, @code{Free} should actually reclaim the
5451 storage.
5452 @end cartouche
5453 Followed.
5454
5455 @cindex Stream oriented attributes
5456 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5457 @sp 1
5458 @cartouche
5459 If a stream element is the same size as a storage element, then the
5460 normal in-memory representation should be used by @code{Read} and
5461 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5462 should use the smallest number of stream elements needed to represent
5463 all values in the base range of the scalar type.
5464 @end cartouche
5465
5466 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5467 which specifies using the size of the first subtype.
5468 However, such an implementation is based on direct binary
5469 representations and is therefore target- and endianness-dependent.
5470 To address this issue, GNAT also supplies an alternate implementation
5471 of the stream attributes @code{Read} and @code{Write},
5472 which uses the target-independent XDR standard representation
5473 for scalar types.
5474 @cindex XDR representation
5475 @cindex @code{Read} attribute
5476 @cindex @code{Write} attribute
5477 @cindex Stream oriented attributes
5478 The XDR implementation is provided as an alternative body of the
5479 @code{System.Stream_Attributes} package, in the file
5480 @file{s-strxdr.adb} in the GNAT library.
5481 There is no @file{s-strxdr.ads} file.
5482 In order to install the XDR implementation, do the following:
5483 @enumerate
5484 @item Replace the default implementation of the
5485 @code{System.Stream_Attributes} package with the XDR implementation.
5486 For example on a Unix platform issue the commands:
5487 @smallexample
5488 $ mv s-stratt.adb s-strold.adb
5489 $ mv s-strxdr.adb s-stratt.adb
5490 @end smallexample
5491
5492 @item
5493 Rebuild the GNAT run-time library as documented in the
5494 @cite{GNAT User's Guide}
5495 @end enumerate
5496
5497 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5498 @sp 1
5499 @cartouche
5500 If an implementation provides additional named predefined integer types,
5501 then the names should end with @samp{Integer} as in
5502 @samp{Long_Integer}.  If an implementation provides additional named
5503 predefined floating point types, then the names should end with
5504 @samp{Float} as in @samp{Long_Float}.
5505 @end cartouche
5506 Followed.
5507
5508 @findex Ada.Characters.Handling
5509 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5510 @sp 1
5511 @cartouche
5512 If an implementation provides a localized definition of @code{Character}
5513 or @code{Wide_Character}, then the effects of the subprograms in
5514 @code{Characters.Handling} should reflect the localizations.  See also
5515 3.5.2.
5516 @end cartouche
5517 Followed.  GNAT provides no such localized definitions.
5518
5519 @cindex Bounded-length strings
5520 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5521 @sp 1
5522 @cartouche
5523 Bounded string objects should not be implemented by implicit pointers
5524 and dynamic allocation.
5525 @end cartouche
5526 Followed.  No implicit pointers or dynamic allocation are used.
5527
5528 @cindex Random number generation
5529 @unnumberedsec A.5.2(46-47): Random Number Generation
5530 @sp 1
5531 @cartouche
5532 Any storage associated with an object of type @code{Generator} should be
5533 reclaimed on exit from the scope of the object.
5534 @end cartouche
5535 Followed.
5536
5537 @sp 1
5538 @cartouche
5539 If the generator period is sufficiently long in relation to the number
5540 of distinct initiator values, then each possible value of
5541 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5542 random numbers that does not, in a practical sense, overlap the sequence
5543 initiated by any other value.  If this is not possible, then the mapping
5544 between initiator values and generator states should be a rapidly
5545 varying function of the initiator value.
5546 @end cartouche
5547 Followed.  The generator period is sufficiently long for the first
5548 condition here to hold true.
5549
5550 @findex Get_Immediate
5551 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5552 @sp 1
5553 @cartouche
5554 The @code{Get_Immediate} procedures should be implemented with
5555 unbuffered input.  For a device such as a keyboard, input should be
5556 @dfn{available} if a key has already been typed, whereas for a disk
5557 file, input should always be available except at end of file.  For a file
5558 associated with a keyboard-like device, any line-editing features of the
5559 underlying operating system should be disabled during the execution of
5560 @code{Get_Immediate}.
5561 @end cartouche
5562 Followed on all targets except VxWorks. For VxWorks, there is no way to
5563 provide this functionality that does not result in the input buffer being
5564 flushed before the @code{Get_Immediate} call. A special unit
5565 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5566 this functionality.
5567
5568 @findex Export
5569 @unnumberedsec B.1(39-41): Pragma @code{Export}
5570 @sp 1
5571 @cartouche
5572 If an implementation supports pragma @code{Export} to a given language,
5573 then it should also allow the main subprogram to be written in that
5574 language.  It should support some mechanism for invoking the elaboration
5575 of the Ada library units included in the system, and for invoking the
5576 finalization of the environment task.  On typical systems, the
5577 recommended mechanism is to provide two subprograms whose link names are
5578 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5579 elaboration code for library units.  @code{adafinal} should contain the
5580 finalization code.  These subprograms should have no effect the second
5581 and subsequent time they are called.
5582 @end cartouche
5583 Followed.
5584
5585 @sp 1
5586 @cartouche
5587 Automatic elaboration of pre-elaborated packages should be
5588 provided when pragma @code{Export} is supported.
5589 @end cartouche
5590 Followed when the main program is in Ada.  If the main program is in a
5591 foreign language, then
5592 @code{adainit} must be called to elaborate pre-elaborated
5593 packages.
5594
5595 @sp 1
5596 @cartouche
5597 For each supported convention @var{L} other than @code{Intrinsic}, an
5598 implementation should support @code{Import} and @code{Export} pragmas
5599 for objects of @var{L}-compatible types and for subprograms, and pragma
5600 @code{Convention} for @var{L}-eligible types and for subprograms,
5601 presuming the other language has corresponding features.  Pragma
5602 @code{Convention} need not be supported for scalar types.
5603 @end cartouche
5604 Followed.
5605
5606 @cindex Package @code{Interfaces}
5607 @findex Interfaces
5608 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5609 @sp 1
5610 @cartouche
5611 For each implementation-defined convention identifier, there should be a
5612 child package of package Interfaces with the corresponding name.  This
5613 package should contain any declarations that would be useful for
5614 interfacing to the language (implementation) represented by the
5615 convention.  Any declarations useful for interfacing to any language on
5616 the given hardware architecture should be provided directly in
5617 @code{Interfaces}.
5618 @end cartouche
5619 Followed.  An additional package not defined
5620 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5621 for interfacing to C++.
5622
5623 @sp 1
5624 @cartouche
5625 An implementation supporting an interface to C, COBOL, or Fortran should
5626 provide the corresponding package or packages described in the following
5627 clauses.
5628 @end cartouche
5629 Followed.  GNAT provides all the packages described in this section.
5630
5631 @cindex C, interfacing with
5632 @unnumberedsec B.3(63-71): Interfacing with C
5633 @sp 1
5634 @cartouche
5635 An implementation should support the following interface correspondences
5636 between Ada and C@.
5637 @end cartouche
5638 Followed.
5639
5640 @sp 1
5641 @cartouche
5642 An Ada procedure corresponds to a void-returning C function.
5643 @end cartouche
5644 Followed.
5645
5646 @sp 1
5647 @cartouche
5648 An Ada function corresponds to a non-void C function.
5649 @end cartouche
5650 Followed.
5651
5652 @sp 1
5653 @cartouche
5654 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5655 function.
5656 @end cartouche
5657 Followed.
5658
5659 @sp 1
5660 @cartouche
5661 An Ada @code{in} parameter of an access-to-object type with designated
5662 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5663 where @var{t} is the C type corresponding to the Ada type @var{T}.
5664 @end cartouche
5665 Followed.
5666
5667 @sp 1
5668 @cartouche
5669 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5670 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5671 argument to a C function, where @var{t} is the C type corresponding to
5672 the Ada type @var{T}.  In the case of an elementary @code{out} or
5673 @code{in out} parameter, a pointer to a temporary copy is used to
5674 preserve by-copy semantics.
5675 @end cartouche
5676 Followed.
5677
5678 @sp 1
5679 @cartouche
5680 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5681 @code{@var{t}*} argument to a C function, where @var{t} is the C
5682 structure corresponding to the Ada type @var{T}.
5683 @end cartouche
5684 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5685 pragma, or Convention, or by explicitly specifying the mechanism for a given
5686 call using an extended import or export pragma.
5687
5688 @sp 1
5689 @cartouche
5690 An Ada parameter of an array type with component type @var{T}, of any
5691 mode, is passed as a @code{@var{t}*} argument to a C function, where
5692 @var{t} is the C type corresponding to the Ada type @var{T}.
5693 @end cartouche
5694 Followed.
5695
5696 @sp 1
5697 @cartouche
5698 An Ada parameter of an access-to-subprogram type is passed as a pointer
5699 to a C function whose prototype corresponds to the designated
5700 subprogram's specification.
5701 @end cartouche
5702 Followed.
5703
5704 @cindex COBOL, interfacing with
5705 @unnumberedsec B.4(95-98): Interfacing with COBOL
5706 @sp 1
5707 @cartouche
5708 An Ada implementation should support the following interface
5709 correspondences between Ada and COBOL@.
5710 @end cartouche
5711 Followed.
5712
5713 @sp 1
5714 @cartouche
5715 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5716 the COBOL type corresponding to @var{T}.
5717 @end cartouche
5718 Followed.
5719
5720 @sp 1
5721 @cartouche
5722 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5723 the corresponding COBOL type.
5724 @end cartouche
5725 Followed.
5726
5727 @sp 1
5728 @cartouche
5729 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5730 COBOL type corresponding to the Ada parameter type; for scalars, a local
5731 copy is used if necessary to ensure by-copy semantics.
5732 @end cartouche
5733 Followed.
5734
5735 @cindex Fortran, interfacing with
5736 @unnumberedsec B.5(22-26): Interfacing with Fortran
5737 @sp 1
5738 @cartouche
5739 An Ada implementation should support the following interface
5740 correspondences between Ada and Fortran:
5741 @end cartouche
5742 Followed.
5743
5744 @sp 1
5745 @cartouche
5746 An Ada procedure corresponds to a Fortran subroutine.
5747 @end cartouche
5748 Followed.
5749
5750 @sp 1
5751 @cartouche
5752 An Ada function corresponds to a Fortran function.
5753 @end cartouche
5754 Followed.
5755
5756 @sp 1
5757 @cartouche
5758 An Ada parameter of an elementary, array, or record type @var{T} is
5759 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5760 the Fortran type corresponding to the Ada type @var{T}, and where the
5761 INTENT attribute of the corresponding dummy argument matches the Ada
5762 formal parameter mode; the Fortran implementation's parameter passing
5763 conventions are used.  For elementary types, a local copy is used if
5764 necessary to ensure by-copy semantics.
5765 @end cartouche
5766 Followed.
5767
5768 @sp 1
5769 @cartouche
5770 An Ada parameter of an access-to-subprogram type is passed as a
5771 reference to a Fortran procedure whose interface corresponds to the
5772 designated subprogram's specification.
5773 @end cartouche
5774 Followed.
5775
5776 @cindex Machine operations
5777 @unnumberedsec C.1(3-5): Access to Machine Operations
5778 @sp 1
5779 @cartouche
5780 The machine code or intrinsic support should allow access to all
5781 operations normally available to assembly language programmers for the
5782 target environment, including privileged instructions, if any.
5783 @end cartouche
5784 Followed.
5785
5786 @sp 1
5787 @cartouche
5788 The interfacing pragmas (see Annex B) should support interface to
5789 assembler; the default assembler should be associated with the
5790 convention identifier @code{Assembler}.
5791 @end cartouche
5792 Followed.
5793
5794 @sp 1
5795 @cartouche
5796 If an entity is exported to assembly language, then the implementation
5797 should allocate it at an addressable location, and should ensure that it
5798 is retained by the linking process, even if not otherwise referenced
5799 from the Ada code.  The implementation should assume that any call to a
5800 machine code or assembler subprogram is allowed to read or update every
5801 object that is specified as exported.
5802 @end cartouche
5803 Followed.
5804
5805 @unnumberedsec C.1(10-16): Access to Machine Operations
5806 @sp 1
5807 @cartouche
5808 The implementation should ensure that little or no overhead is
5809 associated with calling intrinsic and machine-code subprograms.
5810 @end cartouche
5811 Followed for both intrinsics and machine-code subprograms.
5812
5813 @sp 1
5814 @cartouche
5815 It is recommended that intrinsic subprograms be provided for convenient
5816 access to any machine operations that provide special capabilities or
5817 efficiency and that are not otherwise available through the language
5818 constructs.
5819 @end cartouche
5820 Followed.  A full set of machine operation intrinsic subprograms is provided.
5821
5822 @sp 1
5823 @cartouche
5824 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5825 swap, decrement and test, enqueue/dequeue.
5826 @end cartouche
5827 Followed on any target supporting such operations.
5828
5829 @sp 1
5830 @cartouche
5831 Standard numeric functions---e.g.@:, sin, log.
5832 @end cartouche
5833 Followed on any target supporting such operations.
5834
5835 @sp 1
5836 @cartouche
5837 String manipulation operations---e.g.@:, translate and test.
5838 @end cartouche
5839 Followed on any target supporting such operations.
5840
5841 @sp 1
5842 @cartouche
5843 Vector operations---e.g.@:, compare vector against thresholds.
5844 @end cartouche
5845 Followed on any target supporting such operations.
5846
5847 @sp 1
5848 @cartouche
5849 Direct operations on I/O ports.
5850 @end cartouche
5851 Followed on any target supporting such operations.
5852
5853 @cindex Interrupt support
5854 @unnumberedsec C.3(28): Interrupt Support
5855 @sp 1
5856 @cartouche
5857 If the @code{Ceiling_Locking} policy is not in effect, the
5858 implementation should provide means for the application to specify which
5859 interrupts are to be blocked during protected actions, if the underlying
5860 system allows for a finer-grain control of interrupt blocking.
5861 @end cartouche
5862 Followed.  The underlying system does not allow for finer-grain control
5863 of interrupt blocking.
5864
5865 @cindex Protected procedure handlers
5866 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5867 @sp 1
5868 @cartouche
5869 Whenever possible, the implementation should allow interrupt handlers to
5870 be called directly by the hardware.
5871 @end cartouche
5872 @c SGI info:
5873 @ignore
5874 This is never possible under IRIX, so this is followed by default.
5875 @end ignore
5876 Followed on any target where the underlying operating system permits
5877 such direct calls.
5878
5879 @sp 1
5880 @cartouche
5881 Whenever practical, violations of any
5882 implementation-defined restrictions should be detected before run time.
5883 @end cartouche
5884 Followed.  Compile time warnings are given when possible.
5885
5886 @cindex Package @code{Interrupts}
5887 @findex Interrupts
5888 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5889
5890 @sp 1
5891 @cartouche
5892 If implementation-defined forms of interrupt handler procedures are
5893 supported, such as protected procedures with parameters, then for each
5894 such form of a handler, a type analogous to @code{Parameterless_Handler}
5895 should be specified in a child package of @code{Interrupts}, with the
5896 same operations as in the predefined package Interrupts.
5897 @end cartouche
5898 Followed.
5899
5900 @cindex Pre-elaboration requirements
5901 @unnumberedsec C.4(14): Pre-elaboration Requirements
5902 @sp 1
5903 @cartouche
5904 It is recommended that pre-elaborated packages be implemented in such a
5905 way that there should be little or no code executed at run time for the
5906 elaboration of entities not already covered by the Implementation
5907 Requirements.
5908 @end cartouche
5909 Followed.  Executable code is generated in some cases, e.g.@: loops
5910 to initialize large arrays.
5911
5912 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5913
5914 @sp 1
5915 @cartouche
5916 If the pragma applies to an entity, then the implementation should
5917 reduce the amount of storage used for storing names associated with that
5918 entity.
5919 @end cartouche
5920 Followed.
5921
5922 @cindex Package @code{Task_Attributes}
5923 @findex Task_Attributes
5924 @unnumberedsec C.7.2(30): The Package Task_Attributes
5925 @sp 1
5926 @cartouche
5927 Some implementations are targeted to domains in which memory use at run
5928 time must be completely deterministic.  For such implementations, it is
5929 recommended that the storage for task attributes will be pre-allocated
5930 statically and not from the heap.  This can be accomplished by either
5931 placing restrictions on the number and the size of the task's
5932 attributes, or by using the pre-allocated storage for the first @var{N}
5933 attribute objects, and the heap for the others.  In the latter case,
5934 @var{N} should be documented.
5935 @end cartouche
5936 Not followed.  This implementation is not targeted to such a domain.
5937
5938 @cindex Locking Policies
5939 @unnumberedsec D.3(17): Locking Policies
5940
5941 @sp 1
5942 @cartouche
5943 The implementation should use names that end with @samp{_Locking} for
5944 locking policies defined by the implementation.
5945 @end cartouche
5946 Followed.  A single implementation-defined locking policy is defined,
5947 whose name (@code{Inheritance_Locking}) follows this suggestion.
5948
5949 @cindex Entry queuing policies
5950 @unnumberedsec D.4(16): Entry Queuing Policies
5951 @sp 1
5952 @cartouche
5953 Names that end with @samp{_Queuing} should be used
5954 for all implementation-defined queuing policies.
5955 @end cartouche
5956 Followed.  No such implementation-defined queuing policies exist.
5957
5958 @cindex Preemptive abort
5959 @unnumberedsec D.6(9-10): Preemptive Abort
5960 @sp 1
5961 @cartouche
5962 Even though the @code{abort_statement} is included in the list of
5963 potentially blocking operations (see 9.5.1), it is recommended that this
5964 statement be implemented in a way that never requires the task executing
5965 the @code{abort_statement} to block.
5966 @end cartouche
5967 Followed.
5968
5969 @sp 1
5970 @cartouche
5971 On a multi-processor, the delay associated with aborting a task on
5972 another processor should be bounded; the implementation should use
5973 periodic polling, if necessary, to achieve this.
5974 @end cartouche
5975 Followed.
5976
5977 @cindex Tasking restrictions
5978 @unnumberedsec D.7(21): Tasking Restrictions
5979 @sp 1
5980 @cartouche
5981 When feasible, the implementation should take advantage of the specified
5982 restrictions to produce a more efficient implementation.
5983 @end cartouche
5984 GNAT currently takes advantage of these restrictions by providing an optimized
5985 run time when the Ravenscar profile and the GNAT restricted run time set
5986 of restrictions are specified.  See pragma @code{Ravenscar} and pragma
5987 @code{Restricted_Run_Time} for more details.
5988
5989 @cindex Time, monotonic
5990 @unnumberedsec D.8(47-49): Monotonic Time
5991 @sp 1
5992 @cartouche
5993 When appropriate, implementations should provide configuration
5994 mechanisms to change the value of @code{Tick}.
5995 @end cartouche
5996 Such configuration mechanisms are not appropriate to this implementation
5997 and are thus not supported.
5998
5999 @sp 1
6000 @cartouche
6001 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6002 be implemented as transformations of the same time base.
6003 @end cartouche
6004 Followed.
6005
6006 @sp 1
6007 @cartouche
6008 It is recommended that the @dfn{best} time base which exists in
6009 the underlying system be available to the application through
6010 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6011 @end cartouche
6012 Followed.
6013
6014 @cindex Partition communication subsystem
6015 @cindex PCS
6016 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6017 @sp 1
6018 @cartouche
6019 Whenever possible, the PCS on the called partition should allow for
6020 multiple tasks to call the RPC-receiver with different messages and
6021 should allow them to block until the corresponding subprogram body
6022 returns.
6023 @end cartouche
6024 Followed by GLADE, a separately supplied PCS that can be used with
6025 GNAT.
6026
6027 @sp 1
6028 @cartouche
6029 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6030 should raise @code{Storage_Error} if it runs out of space trying to
6031 write the @code{Item} into the stream.
6032 @end cartouche
6033 Followed by GLADE, a separately supplied PCS that can be used with
6034 GNAT@.
6035
6036 @cindex COBOL support
6037 @unnumberedsec F(7): COBOL Support
6038 @sp 1
6039 @cartouche
6040 If COBOL (respectively, C) is widely supported in the target
6041 environment, implementations supporting the Information Systems Annex
6042 should provide the child package @code{Interfaces.COBOL} (respectively,
6043 @code{Interfaces.C}) specified in Annex B and should support a
6044 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6045 pragmas (see Annex B), thus allowing Ada programs to interface with
6046 programs written in that language.
6047 @end cartouche
6048 Followed.
6049
6050 @cindex Decimal radix support
6051 @unnumberedsec F.1(2): Decimal Radix Support
6052 @sp 1
6053 @cartouche
6054 Packed decimal should be used as the internal representation for objects
6055 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6056 @end cartouche
6057 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6058 representations.
6059
6060 @cindex Numerics
6061 @unnumberedsec G: Numerics
6062 @sp 2
6063 @cartouche
6064 If Fortran (respectively, C) is widely supported in the target
6065 environment, implementations supporting the Numerics Annex
6066 should provide the child package @code{Interfaces.Fortran} (respectively,
6067 @code{Interfaces.C}) specified in Annex B and should support a
6068 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6069 pragmas (see Annex B), thus allowing Ada programs to interface with
6070 programs written in that language.
6071 @end cartouche
6072 Followed.
6073
6074 @cindex Complex types
6075 @unnumberedsec G.1.1(56-58): Complex Types
6076 @sp 2
6077 @cartouche
6078 Because the usual mathematical meaning of multiplication of a complex
6079 operand and a real operand is that of the scaling of both components of
6080 the former by the latter, an implementation should not perform this
6081 operation by first promoting the real operand to complex type and then
6082 performing a full complex multiplication.  In systems that, in the
6083 future, support an Ada binding to IEC 559:1989, the latter technique
6084 will not generate the required result when one of the components of the
6085 complex operand is infinite.  (Explicit multiplication of the infinite
6086 component by the zero component obtained during promotion yields a NaN
6087 that propagates into the final result.) Analogous advice applies in the
6088 case of multiplication of a complex operand and a pure-imaginary
6089 operand, and in the case of division of a complex operand by a real or
6090 pure-imaginary operand.
6091 @end cartouche
6092 Not followed.
6093
6094 @sp 1
6095 @cartouche
6096 Similarly, because the usual mathematical meaning of addition of a
6097 complex operand and a real operand is that the imaginary operand remains
6098 unchanged, an implementation should not perform this operation by first
6099 promoting the real operand to complex type and then performing a full
6100 complex addition.  In implementations in which the @code{Signed_Zeros}
6101 attribute of the component type is @code{True} (and which therefore
6102 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6103 predefined arithmetic operations), the latter technique will not
6104 generate the required result when the imaginary component of the complex
6105 operand is a negatively signed zero.  (Explicit addition of the negative
6106 zero to the zero obtained during promotion yields a positive zero.)
6107 Analogous advice applies in the case of addition of a complex operand
6108 and a pure-imaginary operand, and in the case of subtraction of a
6109 complex operand and a real or pure-imaginary operand.
6110 @end cartouche
6111 Not followed.
6112
6113 @sp 1
6114 @cartouche
6115 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6116 attempt to provide a rational treatment of the signs of zero results and
6117 result components.  As one example, the result of the @code{Argument}
6118 function should have the sign of the imaginary component of the
6119 parameter @code{X} when the point represented by that parameter lies on
6120 the positive real axis; as another, the sign of the imaginary component
6121 of the @code{Compose_From_Polar} function should be the same as
6122 (respectively, the opposite of) that of the @code{Argument} parameter when that
6123 parameter has a value of zero and the @code{Modulus} parameter has a
6124 nonnegative (respectively, negative) value.
6125 @end cartouche
6126 Followed.
6127
6128 @cindex Complex elementary functions
6129 @unnumberedsec G.1.2(49): Complex Elementary Functions
6130 @sp 1
6131 @cartouche
6132 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6133 @code{True} should attempt to provide a rational treatment of the signs
6134 of zero results and result components.  For example, many of the complex
6135 elementary functions have components that are odd functions of one of
6136 the parameter components; in these cases, the result component should
6137 have the sign of the parameter component at the origin.  Other complex
6138 elementary functions have zero components whose sign is opposite that of
6139 a parameter component at the origin, or is always positive or always
6140 negative.
6141 @end cartouche
6142 Followed.
6143
6144 @cindex Accuracy requirements
6145 @unnumberedsec G.2.4(19): Accuracy Requirements
6146 @sp 1
6147 @cartouche
6148 The versions of the forward trigonometric functions without a
6149 @code{Cycle} parameter should not be implemented by calling the
6150 corresponding version with a @code{Cycle} parameter of
6151 @code{2.0*Numerics.Pi}, since this will not provide the required
6152 accuracy in some portions of the domain.  For the same reason, the
6153 version of @code{Log} without a @code{Base} parameter should not be
6154 implemented by calling the corresponding version with a @code{Base}
6155 parameter of @code{Numerics.e}.
6156 @end cartouche
6157 Followed.
6158
6159 @cindex Complex arithmetic accuracy
6160 @cindex Accuracy, complex arithmetic
6161 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6162
6163 @sp 1
6164 @cartouche
6165 The version of the @code{Compose_From_Polar} function without a
6166 @code{Cycle} parameter should not be implemented by calling the
6167 corresponding version with a @code{Cycle} parameter of
6168 @code{2.0*Numerics.Pi}, since this will not provide the required
6169 accuracy in some portions of the domain.
6170 @end cartouche
6171 Followed.
6172
6173 @c -----------------------------------------
6174 @node Implementation Defined Characteristics
6175 @chapter Implementation Defined Characteristics
6176
6177 @noindent
6178 In addition to the implementation dependent pragmas and attributes, and
6179 the implementation advice, there are a number of other features of Ada
6180 95 that are potentially implementation dependent.  These are mentioned
6181 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6182
6183 A requirement for conforming Ada compilers is that they provide
6184 documentation describing how the implementation deals with each of these
6185 issues.  In this chapter, you will find each point in annex M listed
6186 followed by a description in italic font of how GNAT
6187 @c SGI info:
6188 @ignore
6189 in the ProDev Ada
6190 implementation on IRIX 5.3 operating system or greater
6191 @end ignore
6192 handles the implementation dependence.
6193
6194 You can use this chapter as a guide to minimizing implementation
6195 dependent features in your programs if portability to other compilers
6196 and other operating systems is an important consideration.  The numbers
6197 in each section below correspond to the paragraph number in the Ada 95
6198 Reference Manual.
6199
6200 @sp 1
6201 @cartouche
6202 @noindent
6203 @strong{2}.  Whether or not each recommendation given in Implementation
6204 Advice is followed.  See 1.1.2(37).
6205 @end cartouche
6206 @noindent
6207 @xref{Implementation Advice}.
6208
6209 @sp 1
6210 @cartouche
6211 @noindent
6212 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6213 @end cartouche
6214 @noindent
6215 The complexity of programs that can be processed is limited only by the
6216 total amount of available virtual memory, and disk space for the
6217 generated object files.
6218
6219 @sp 1
6220 @cartouche
6221 @noindent
6222 @strong{4}.  Variations from the standard that are impractical to avoid
6223 given the implementation's execution environment.  See 1.1.3(6).
6224 @end cartouche
6225 @noindent
6226 There are no variations from the standard.
6227
6228 @sp 1
6229 @cartouche
6230 @noindent
6231 @strong{5}.  Which @code{code_statement}s cause external
6232 interactions.  See 1.1.3(10).
6233 @end cartouche
6234 @noindent
6235 Any @code{code_statement} can potentially cause external interactions.
6236
6237 @sp 1
6238 @cartouche
6239 @noindent
6240 @strong{6}.  The coded representation for the text of an Ada
6241 program.  See 2.1(4).
6242 @end cartouche
6243 @noindent
6244 See separate section on source representation.
6245
6246 @sp 1
6247 @cartouche
6248 @noindent
6249 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6250 @end cartouche
6251 @noindent
6252 See separate section on source representation.
6253
6254 @sp 1
6255 @cartouche
6256 @noindent
6257 @strong{8}.  The representation for an end of line.  See 2.2(2).
6258 @end cartouche
6259 @noindent
6260 See separate section on source representation.
6261
6262 @sp 1
6263 @cartouche
6264 @noindent
6265 @strong{9}.  Maximum supported line length and lexical element
6266 length.  See 2.2(15).
6267 @end cartouche
6268 @noindent
6269 The maximum line length is 255 characters an the maximum length of a
6270 lexical element is also 255 characters.
6271
6272 @sp 1
6273 @cartouche
6274 @noindent
6275 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6276 @end cartouche
6277 @noindent
6278
6279 @xref{Implementation Defined Pragmas}.
6280
6281 @sp 1
6282 @cartouche
6283 @noindent
6284 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6285 @end cartouche
6286 @noindent
6287 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6288 parameter, checks that the optimization flag is set, and aborts if it is
6289 not.
6290
6291 @sp 1
6292 @cartouche
6293 @noindent
6294 @strong{12}.  The sequence of characters of the value returned by
6295 @code{@var{S}'Image} when some of the graphic characters of
6296 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6297 3.5(37).
6298 @end cartouche
6299 @noindent
6300 The sequence of characters is as defined by the wide character encoding
6301 method used for the source.  See section on source representation for
6302 further details.
6303
6304 @sp 1
6305 @cartouche
6306 @noindent
6307 @strong{13}.  The predefined integer types declared in
6308 @code{Standard}.  See 3.5.4(25).
6309 @end cartouche
6310 @noindent
6311 @table @code
6312 @item Short_Short_Integer
6313 8 bit signed
6314 @item Short_Integer
6315 (Short) 16 bit signed
6316 @item Integer
6317 32 bit signed
6318 @item Long_Integer
6319 64 bit signed (Alpha OpenVMS only)
6320 32 bit signed (all other targets)
6321 @item Long_Long_Integer
6322 64 bit signed
6323 @end table
6324
6325 @sp 1
6326 @cartouche
6327 @noindent
6328 @strong{14}.  Any nonstandard integer types and the operators defined
6329 for them.  See 3.5.4(26).
6330 @end cartouche
6331 @noindent
6332 There are no nonstandard integer types.
6333
6334 @sp 1
6335 @cartouche
6336 @noindent
6337 @strong{15}.  Any nonstandard real types and the operators defined for
6338 them.  See 3.5.6(8).
6339 @end cartouche
6340 @noindent
6341 There are no nonstandard real types.
6342
6343 @sp 1
6344 @cartouche
6345 @noindent
6346 @strong{16}.  What combinations of requested decimal precision and range
6347 are supported for floating point types.  See 3.5.7(7).
6348 @end cartouche
6349 @noindent
6350 The precision and range is as defined by the IEEE standard.
6351
6352 @sp 1
6353 @cartouche
6354 @noindent
6355 @strong{17}.  The predefined floating point types declared in
6356 @code{Standard}.  See 3.5.7(16).
6357 @end cartouche
6358 @noindent
6359 @table @code
6360 @item Short_Float
6361 32 bit IEEE short
6362 @item Float
6363 (Short) 32 bit IEEE short
6364 @item Long_Float
6365 64 bit IEEE long
6366 @item Long_Long_Float
6367 64 bit IEEE long (80 bit IEEE long on x86 processors)
6368 @end table
6369
6370 @sp 1
6371 @cartouche
6372 @noindent
6373 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6374 @end cartouche
6375 @noindent
6376 @code{Fine_Delta} is 2**(@minus{}63)
6377
6378 @sp 1
6379 @cartouche
6380 @noindent
6381 @strong{19}.  What combinations of small, range, and digits are
6382 supported for fixed point types.  See 3.5.9(10).
6383 @end cartouche
6384 @noindent
6385 Any combinations are permitted that do not result in a small less than
6386 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6387 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6388 is 64 bits (true of all architectures except ia32), then the output from
6389 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6390 is because floating-point conversions are used to convert fixed point.
6391
6392 @sp 1
6393 @cartouche
6394 @noindent
6395 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6396 within an unnamed @code{block_statement}.  See 3.9(10).
6397 @end cartouche
6398 @noindent
6399 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6400 decimal integer are allocated.
6401
6402 @sp 1
6403 @cartouche
6404 @noindent
6405 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6406 @end cartouche
6407 @noindent
6408 @xref{Implementation Defined Attributes}.
6409
6410 @sp 1
6411 @cartouche
6412 @noindent
6413 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6414 @end cartouche
6415 @noindent
6416 There are no implementation-defined time types.
6417
6418 @sp 1
6419 @cartouche
6420 @noindent
6421 @strong{23}.  The time base associated with relative delays.
6422 @end cartouche
6423 @noindent
6424 See 9.6(20).  The time base used is that provided by the C library
6425 function @code{gettimeofday}.
6426
6427 @sp 1
6428 @cartouche
6429 @noindent
6430 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6431 9.6(23).
6432 @end cartouche
6433 @noindent
6434 The time base used is that provided by the C library function
6435 @code{gettimeofday}.
6436
6437 @sp 1
6438 @cartouche
6439 @noindent
6440 @strong{25}.  The time zone used for package @code{Calendar}
6441 operations.  See 9.6(24).
6442 @end cartouche
6443 @noindent
6444 The time zone used by package @code{Calendar} is the current system time zone
6445 setting for local time, as accessed by the C library function
6446 @code{localtime}.
6447
6448 @sp 1
6449 @cartouche
6450 @noindent
6451 @strong{26}.  Any limit on @code{delay_until_statements} of
6452 @code{select_statements}.  See 9.6(29).
6453 @end cartouche
6454 @noindent
6455 There are no such limits.
6456
6457 @sp 1
6458 @cartouche
6459 @noindent
6460 @strong{27}.  Whether or not two non overlapping parts of a composite
6461 object are independently addressable, in the case where packing, record
6462 layout, or @code{Component_Size} is specified for the object.  See
6463 9.10(1).
6464 @end cartouche
6465 @noindent
6466 Separate components are independently addressable if they do not share
6467 overlapping storage units.
6468
6469 @sp 1
6470 @cartouche
6471 @noindent
6472 @strong{28}.  The representation for a compilation.  See 10.1(2).
6473 @end cartouche
6474 @noindent
6475 A compilation is represented by a sequence of files presented to the
6476 compiler in a single invocation of the @code{gcc} command.
6477
6478 @sp 1
6479 @cartouche
6480 @noindent
6481 @strong{29}.  Any restrictions on compilations that contain multiple
6482 compilation_units.  See 10.1(4).
6483 @end cartouche
6484 @noindent
6485 No single file can contain more than one compilation unit, but any
6486 sequence of files can be presented to the compiler as a single
6487 compilation.
6488
6489 @sp 1
6490 @cartouche
6491 @noindent
6492 @strong{30}.  The mechanisms for creating an environment and for adding
6493 and replacing compilation units.  See 10.1.4(3).
6494 @end cartouche
6495 @noindent
6496 See separate section on compilation model.
6497
6498 @sp 1
6499 @cartouche
6500 @noindent
6501 @strong{31}.  The manner of explicitly assigning library units to a
6502 partition.  See 10.2(2).
6503 @end cartouche
6504 @noindent
6505 If a unit contains an Ada main program, then the Ada units for the partition
6506 are determined by recursive application of the rules in the Ada Reference
6507 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6508 are needed by the main program, and then this definition of need is applied
6509 recursively to those units, and the partition contains the transitive
6510 closure determined by this relationship.  In short, all the necessary units
6511 are included, with no need to explicitly specify the list.  If additional
6512 units are required, e.g.@: by foreign language units, then all units must be
6513 mentioned in the context clause of one of the needed Ada units.
6514
6515 If the partition contains no main program, or if the main program is in
6516 a language other than Ada, then GNAT
6517 provides the binder options @code{-z} and @code{-n} respectively, and in
6518 this case a list of units can be explicitly supplied to the binder for
6519 inclusion in the partition (all units needed by these units will also
6520 be included automatically).  For full details on the use of these
6521 options, refer to the @cite{GNAT User's Guide} sections on Binding
6522 and Linking.
6523
6524 @sp 1
6525 @cartouche
6526 @noindent
6527 @strong{32}.  The implementation-defined means, if any, of specifying
6528 which compilation units are needed by a given compilation unit.  See
6529 10.2(2).
6530 @end cartouche
6531 @noindent
6532 The units needed by a given compilation unit are as defined in
6533 the Ada Reference Manual section 10.2(2-6).  There are no
6534 implementation-defined pragmas or other implementation-defined
6535 means for specifying needed units.
6536
6537 @sp 1
6538 @cartouche
6539 @noindent
6540 @strong{33}.  The manner of designating the main subprogram of a
6541 partition.  See 10.2(7).
6542 @end cartouche
6543 @noindent
6544 The main program is designated by providing the name of the
6545 corresponding @file{ALI} file as the input parameter to the binder.
6546
6547 @sp 1
6548 @cartouche
6549 @noindent
6550 @strong{34}.  The order of elaboration of @code{library_items}.  See
6551 10.2(18).
6552 @end cartouche
6553 @noindent
6554 The first constraint on ordering is that it meets the requirements of
6555 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6556 implementation dependent choices, which are resolved by first
6557 elaborating bodies as early as possible (i.e.@: in preference to specs
6558 where there is a choice), and second by evaluating the immediate with
6559 clauses of a unit to determine the probably best choice, and
6560 third by elaborating in alphabetical order of unit names
6561 where a choice still remains.
6562
6563 @sp 1
6564 @cartouche
6565 @noindent
6566 @strong{35}.  Parameter passing and function return for the main
6567 subprogram.  See 10.2(21).
6568 @end cartouche
6569 @noindent
6570 The main program has no parameters.  It may be a procedure, or a function
6571 returning an integer type.  In the latter case, the returned integer
6572 value is the return code of the program (overriding any value that
6573 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6574
6575 @sp 1
6576 @cartouche
6577 @noindent
6578 @strong{36}.  The mechanisms for building and running partitions.  See
6579 10.2(24).
6580 @end cartouche
6581 @noindent
6582 GNAT itself supports programs with only a single partition.  The GNATDIST
6583 tool provided with the GLADE package (which also includes an implementation
6584 of the PCS) provides a completely flexible method for building and running
6585 programs consisting of multiple partitions.  See the separate GLADE manual
6586 for details.
6587
6588 @sp 1
6589 @cartouche
6590 @noindent
6591 @strong{37}.  The details of program execution, including program
6592 termination.  See 10.2(25).
6593 @end cartouche
6594 @noindent
6595 See separate section on compilation model.
6596
6597 @sp 1
6598 @cartouche
6599 @noindent
6600 @strong{38}.  The semantics of any non-active partitions supported by the
6601 implementation.  See 10.2(28).
6602 @end cartouche
6603 @noindent
6604 Passive partitions are supported on targets where shared memory is
6605 provided by the operating system.  See the GLADE reference manual for
6606 further details.
6607
6608 @sp 1
6609 @cartouche
6610 @noindent
6611 @strong{39}.  The information returned by @code{Exception_Message}.  See
6612 11.4.1(10).
6613 @end cartouche
6614 @noindent
6615 Exception message returns the null string unless a specific message has
6616 been passed by the program.
6617
6618 @sp 1
6619 @cartouche
6620 @noindent
6621 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6622 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6623 @end cartouche
6624 @noindent
6625 Blocks have implementation defined names of the form @code{B@var{nnn}}
6626 where @var{nnn} is an integer.
6627
6628 @sp 1
6629 @cartouche
6630 @noindent
6631 @strong{41}.  The information returned by
6632 @code{Exception_Information}.  See 11.4.1(13).
6633 @end cartouche
6634 @noindent
6635 @code{Exception_Information} returns a string in the following format:
6636
6637 @smallexample
6638 @emph{Exception_Name:} nnnnn
6639 @emph{Message:} mmmmm
6640 @emph{PID:} ppp
6641 @emph{Call stack traceback locations:}
6642 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6643 @end smallexample
6644
6645 @noindent
6646 where
6647
6648 @itemize @bullet
6649 @item
6650 @code{nnnn} is the fully qualified name of the exception in all upper
6651 case letters. This line is always present.
6652
6653 @item
6654 @code{mmmm} is the message (this line present only if message is non-null)
6655
6656 @item
6657 @code{ppp} is the Process Id value as a decimal integer (this line is
6658 present only if the Process Id is non-zero). Currently we are
6659 not making use of this field.
6660
6661 @item
6662 The Call stack traceback locations line and the following values
6663 are present only if at least one traceback location was recorded.
6664 The values are given in C style format, with lower case letters
6665 for a-f, and only as many digits present as are necessary.
6666 @end itemize
6667
6668 @noindent
6669 The line terminator sequence at the end of each line, including
6670 the last line is a single @code{LF} character (@code{16#0A#}).
6671
6672 @sp 1
6673 @cartouche
6674 @noindent
6675 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6676 @end cartouche
6677 @noindent
6678 No implementation-defined check names are supported.
6679
6680 @sp 1
6681 @cartouche
6682 @noindent
6683 @strong{43}.  The interpretation of each aspect of representation.  See
6684 13.1(20).
6685 @end cartouche
6686 @noindent
6687 See separate section on data representations.
6688
6689 @sp 1
6690 @cartouche
6691 @noindent
6692 @strong{44}.  Any restrictions placed upon representation items.  See
6693 13.1(20).
6694 @end cartouche
6695 @noindent
6696 See separate section on data representations.
6697
6698 @sp 1
6699 @cartouche
6700 @noindent
6701 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6702 13.3(48).
6703 @end cartouche
6704 @noindent
6705 Size for an indefinite subtype is the maximum possible size, except that
6706 for the case of a subprogram parameter, the size of the parameter object
6707 is the actual size.
6708
6709 @sp 1
6710 @cartouche
6711 @noindent
6712 @strong{46}.  The default external representation for a type tag.  See
6713 13.3(75).
6714 @end cartouche
6715 @noindent
6716 The default external representation for a type tag is the fully expanded
6717 name of the type in upper case letters.
6718
6719 @sp 1
6720 @cartouche
6721 @noindent
6722 @strong{47}.  What determines whether a compilation unit is the same in
6723 two different partitions.  See 13.3(76).
6724 @end cartouche
6725 @noindent
6726 A compilation unit is the same in two different partitions if and only
6727 if it derives from the same source file.
6728
6729 @sp 1
6730 @cartouche
6731 @noindent
6732 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6733 @end cartouche
6734 @noindent
6735 The only implementation defined component is the tag for a tagged type,
6736 which contains a pointer to the dispatching table.
6737
6738 @sp 1
6739 @cartouche
6740 @noindent
6741 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6742 ordering.  See 13.5.3(5).
6743 @end cartouche
6744 @noindent
6745 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6746 implementation, so no non-default bit ordering is supported.  The default
6747 bit ordering corresponds to the natural endianness of the target architecture.
6748
6749 @sp 1
6750 @cartouche
6751 @noindent
6752 @strong{50}.  The contents of the visible part of package @code{System}
6753 and its language-defined children.  See 13.7(2).
6754 @end cartouche
6755 @noindent
6756 See the definition of these packages in files @file{system.ads} and
6757 @file{s-stoele.ads}.
6758
6759 @sp 1
6760 @cartouche
6761 @noindent
6762 @strong{51}.  The contents of the visible part of package
6763 @code{System.Machine_Code}, and the meaning of
6764 @code{code_statements}.  See 13.8(7).
6765 @end cartouche
6766 @noindent
6767 See the definition and documentation in file @file{s-maccod.ads}.
6768
6769 @sp 1
6770 @cartouche
6771 @noindent
6772 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6773 @end cartouche
6774 @noindent
6775 Unchecked conversion between types of the same size
6776 and results in an uninterpreted transmission of the bits from one type
6777 to the other.  If the types are of unequal sizes, then in the case of
6778 discrete types, a shorter source is first zero or sign extended as
6779 necessary, and a shorter target is simply truncated on the left.
6780 For all non-discrete types, the source is first copied if necessary
6781 to ensure that the alignment requirements of the target are met, then
6782 a pointer is constructed to the source value, and the result is obtained
6783 by dereferencing this pointer after converting it to be a pointer to the
6784 target type.
6785
6786 @sp 1
6787 @cartouche
6788 @noindent
6789 @strong{53}.  The manner of choosing a storage pool for an access type
6790 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6791 @end cartouche
6792 @noindent
6793 There are 3 different standard pools used by the compiler when
6794 @code{Storage_Pool} is not specified depending whether the type is local
6795 to a subprogram or defined at the library level and whether
6796 @code{Storage_Size}is specified or not.  See documentation in the runtime
6797 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6798 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6799 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6800 default pools used.
6801
6802 @sp 1
6803 @cartouche
6804 @noindent
6805 @strong{54}.  Whether or not the implementation provides user-accessible
6806 names for the standard pool type(s).  See 13.11(17).
6807 @end cartouche
6808 @noindent
6809
6810 See documentation in the sources of the run time mentioned in paragraph
6811 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6812 these units.
6813
6814 @sp 1
6815 @cartouche
6816 @noindent
6817 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6818 @end cartouche
6819 @noindent
6820 @code{Storage_Size} is measured in storage units, and refers to the
6821 total space available for an access type collection, or to the primary
6822 stack space for a task.
6823
6824 @sp 1
6825 @cartouche
6826 @noindent
6827 @strong{56}.  Implementation-defined aspects of storage pools.  See
6828 13.11(22).
6829 @end cartouche
6830 @noindent
6831 See documentation in the sources of the run time mentioned in paragraph
6832 @strong{53} for details on GNAT-defined aspects of storage pools.
6833
6834 @sp 1
6835 @cartouche
6836 @noindent
6837 @strong{57}.  The set of restrictions allowed in a pragma
6838 @code{Restrictions}.  See 13.12(7).
6839 @end cartouche
6840 @noindent
6841 All RM defined Restriction identifiers are implemented.  The following
6842 additional restriction identifiers are provided.  There are two separate
6843 lists of implementation dependent restriction identifiers.  The first
6844 set requires consistency throughout a partition (in other words, if the
6845 restriction identifier is used for any compilation unit in the partition,
6846 then all compilation units in the partition must obey the restriction.
6847
6848 @table @code
6849
6850 @item Boolean_Entry_Barriers
6851 @findex Boolean_Entry_Barriers
6852 This restriction ensures at compile time that barriers in entry declarations
6853 for protected types are restricted to references to simple boolean variables
6854 defined in the private part of the protected type.  No other form of entry
6855 barriers is permitted.  This is one of the restrictions of the Ravenscar
6856 profile for limited tasking (see also pragma @code{Ravenscar}).
6857
6858 @item Max_Entry_Queue_Depth => Expr
6859 @findex Max_Entry_Queue_Depth
6860 This restriction is a declaration that any protected entry compiled in
6861 the scope of the restriction has at most the specified number of
6862 tasks waiting on the entry
6863 at any one time, and so no queue is required.  This restriction is not
6864 checked at compile time.  A program execution is erroneous if an attempt
6865 is made to queue more than the specified number of tasks on such an entry.
6866
6867 @item No_Calendar
6868 @findex No_Calendar
6869 This restriction ensures at compile time that there is no implicit or
6870 explicit dependence on the package @code{Ada.Calendar}.
6871
6872 @item No_Direct_Boolean_Operators
6873 @findex No_Direct_Boolean_Operators
6874 This restriction ensures that no logical (and/or/xor) or comparison
6875 operators are used on operands of type Boolean (or any type derived
6876 from Boolean). This is intended for use in safety critical programs
6877 where the certification protocol requires the use of short-circuit
6878 (and then, or else) forms for all composite boolean operations.
6879
6880 @item No_Dynamic_Interrupts
6881 @findex No_Dynamic_Interrupts
6882 This restriction ensures at compile time that there is no attempt to
6883 dynamically associate interrupts.  Only static association is allowed.
6884
6885 @item No_Enumeration_Maps
6886 @findex No_Enumeration_Maps
6887 This restriction ensures at compile time that no operations requiring
6888 enumeration maps are used (that is Image and Value attributes applied
6889 to enumeration types).
6890
6891 @item No_Entry_Calls_In_Elaboration_Code
6892 @findex No_Entry_Calls_In_Elaboration_Code
6893 This restriction ensures at compile time that no task or protected entry
6894 calls are made during elaboration code.  As a result of the use of this
6895 restriction, the compiler can assume that no code past an accept statement
6896 in a task can be executed at elaboration time.
6897
6898 @item No_Exception_Handlers
6899 @findex No_Exception_Handlers
6900 This restriction ensures at compile time that there are no explicit
6901 exception handlers. It also indicates that no exception propagation will
6902 be provided. In this mode, exceptions may be raised but will result in
6903 an immediate call to the last chance handler, a routine that the user
6904 must define with the following profile:
6905
6906    procedure Last_Chance_Handler
6907      (Source_Location : System.Address; Line : Integer);
6908    pragma Export (C, Last_Chance_Handler,
6909                   "__gnat_last_chance_handler");
6910
6911    The parameter is a C null-terminated string representing a message to be
6912    associated with the exception (typically the source location of the raise
6913    statement generated by the compiler). The Line parameter when non-zero
6914    represents the line number in the source program where the raise occurs.
6915
6916 @item No_Exception_Streams
6917 @findex No_Exception_Streams
6918 This restriction ensures at compile time that no stream operations for
6919 types Exception_Id or Exception_Occurrence are used. This also makes it
6920 impossible to pass exceptions to or from a partition with this restriction
6921 in a distributed environment. If this exception is active, then the generated
6922 code is simplified by omitting the otherwise-required global registration
6923 of exceptions when they are declared.
6924
6925 @item No_Implicit_Conditionals
6926 @findex No_Implicit_Conditionals
6927 This restriction ensures that the generated code does not contain any
6928 implicit conditionals, either by modifying the generated code where possible,
6929 or by rejecting any construct that would otherwise generate an implicit
6930 conditional.
6931
6932 @item No_Implicit_Dynamic_Code
6933 @findex No_Implicit_Dynamic_Code
6934 This restriction prevents the compiler from building ``trampolines''.
6935 This is a structure that is built on the stack and contains dynamic
6936 code to be executed at run time. A trampoline is needed to indirectly
6937 address a nested subprogram (that is a subprogram that is not at the
6938 library level). The restriction prevents the use of any of the
6939 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
6940 being applied to a subprogram that is not at the library level.
6941
6942 @item No_Implicit_Loops
6943 @findex No_Implicit_Loops
6944 This restriction ensures that the generated code does not contain any
6945 implicit @code{for} loops, either by modifying
6946 the generated code where possible,
6947 or by rejecting any construct that would otherwise generate an implicit
6948 @code{for} loop.
6949
6950 @item No_Initialize_Scalars
6951 @findex No_Initialize_Scalars
6952 This restriction ensures that no unit in the partition is compiled with
6953 pragma Initialize_Scalars. This allows the generation of more efficient
6954 code, and in particular eliminates dummy null initialization routines that
6955 are otherwise generated for some record and array types.
6956
6957 @item No_Local_Protected_Objects
6958 @findex No_Local_Protected_Objects
6959 This restriction ensures at compile time that protected objects are
6960 only declared at the library level.
6961
6962 @item No_Protected_Type_Allocators
6963 @findex No_Protected_Type_Allocators
6964 This restriction ensures at compile time that there are no allocator
6965 expressions that attempt to allocate protected objects.
6966
6967 @item No_Secondary_Stack
6968 @findex No_Secondary_Stack
6969 This restriction ensures at compile time that the generated code does not
6970 contain any reference to the secondary stack.  The secondary stack is used
6971 to implement functions returning unconstrained objects (arrays or records)
6972 on some targets.
6973
6974 @item No_Select_Statements
6975 @findex No_Select_Statements
6976 This restriction ensures at compile time no select statements of any kind
6977 are permitted, that is the keyword @code{select} may not appear.
6978 This is one of the restrictions of the Ravenscar
6979 profile for limited tasking (see also pragma @code{Ravenscar}).
6980
6981 @item No_Standard_Storage_Pools
6982 @findex No_Standard_Storage_Pools
6983 This restriction ensures at compile time that no access types
6984 use the standard default storage pool.  Any access type declared must
6985 have an explicit Storage_Pool attribute defined specifying a
6986 user-defined storage pool.
6987
6988 @item No_Streams
6989 @findex No_Streams
6990 This restriction ensures at compile time that there are no implicit or
6991 explicit dependencies on the package @code{Ada.Streams}.
6992
6993 @item No_Task_Attributes
6994 @findex No_Task_Attributes
6995 This restriction ensures at compile time that there are no implicit or
6996 explicit dependencies on the package @code{Ada.Task_Attributes}.
6997
6998 @item No_Task_Termination
6999 @findex No_Task_Termination
7000 This restriction ensures at compile time that no terminate alternatives
7001 appear in any task body.
7002
7003 @item No_Tasking
7004 @findex No_Tasking
7005 This restriction prevents the declaration of tasks or task types throughout
7006 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7007 except that violations are caught at compile time and cause an error message
7008 to be output either by the compiler or binder.
7009
7010 @item No_Wide_Characters
7011 @findex No_Wide_Characters
7012 This restriction ensures at compile time that no uses of the types
7013 @code{Wide_Character} or @code{Wide_String}
7014 appear, and that no wide character literals
7015 appear in the program (that is literals representing characters not in
7016 type @code{Character}.
7017
7018 @item Static_Priorities
7019 @findex Static_Priorities
7020 This restriction ensures at compile time that all priority expressions
7021 are static, and that there are no dependencies on the package
7022 @code{Ada.Dynamic_Priorities}.
7023
7024 @item Static_Storage_Size
7025 @findex Static_Storage_Size
7026 This restriction ensures at compile time that any expression appearing
7027 in a Storage_Size pragma or attribute definition clause is static.
7028
7029 @end table
7030
7031 @noindent
7032 The second set of implementation dependent restriction identifiers
7033 does not require partition-wide consistency.
7034 The restriction may be enforced for a single
7035 compilation unit without any effect on any of the
7036 other compilation units in the partition.
7037
7038 @table @code
7039
7040 @item No_Elaboration_Code
7041 @findex No_Elaboration_Code
7042 This restriction ensures at compile time that no elaboration code is
7043 generated.  Note that this is not the same condition as is enforced
7044 by pragma @code{Preelaborate}.  There are cases in which pragma
7045 @code{Preelaborate} still permits code to be generated (e.g.@: code
7046 to initialize a large array to all zeroes), and there are cases of units
7047 which do not meet the requirements for pragma @code{Preelaborate},
7048 but for which no elaboration code is generated.  Generally, it is
7049 the case that preelaborable units will meet the restrictions, with
7050 the exception of large aggregates initialized with an others_clause,
7051 and exception declarations (which generate calls to a run-time
7052 registry procedure).  Note that this restriction is enforced on
7053 a unit by unit basis, it need not be obeyed consistently
7054 throughout a partition.
7055
7056 @item No_Entry_Queue
7057 @findex No_Entry_Queue
7058 This restriction is a declaration that any protected entry compiled in
7059 the scope of the restriction has at most one task waiting on the entry
7060 at any one time, and so no queue is required.  This restriction is not
7061 checked at compile time.  A program execution is erroneous if an attempt
7062 is made to queue a second task on such an entry.
7063
7064 @item No_Implementation_Attributes
7065 @findex No_Implementation_Attributes
7066 This restriction checks at compile time that no GNAT-defined attributes
7067 are present.  With this restriction, the only attributes that can be used
7068 are those defined in the Ada 95 Reference Manual.
7069
7070 @item No_Implementation_Pragmas
7071 @findex No_Implementation_Pragmas
7072 This restriction checks at compile time that no GNAT-defined pragmas
7073 are present.  With this restriction, the only pragmas that can be used
7074 are those defined in the Ada 95 Reference Manual.
7075
7076 @item No_Implementation_Restrictions
7077 @findex No_Implementation_Restrictions
7078 This restriction checks at compile time that no GNAT-defined restriction
7079 identifiers (other than @code{No_Implementation_Restrictions} itself)
7080 are present.  With this restriction, the only other restriction identifiers
7081 that can be used are those defined in the Ada 95 Reference Manual.
7082
7083 @end table
7084
7085 @sp 1
7086 @cartouche
7087 @noindent
7088 @strong{58}.  The consequences of violating limitations on
7089 @code{Restrictions} pragmas.  See 13.12(9).
7090 @end cartouche
7091 @noindent
7092 Restrictions that can be checked at compile time result in illegalities
7093 if violated.  Currently there are no other consequences of violating
7094 restrictions.
7095
7096 @sp 1
7097 @cartouche
7098 @noindent
7099 @strong{59}.  The representation used by the @code{Read} and
7100 @code{Write} attributes of elementary types in terms of stream
7101 elements.  See 13.13.2(9).
7102 @end cartouche
7103 @noindent
7104 The representation is the in-memory representation of the base type of
7105 the type, using the number of bits corresponding to the
7106 @code{@var{type}'Size} value, and the natural ordering of the machine.
7107
7108 @sp 1
7109 @cartouche
7110 @noindent
7111 @strong{60}.  The names and characteristics of the numeric subtypes
7112 declared in the visible part of package @code{Standard}.  See A.1(3).
7113 @end cartouche
7114 @noindent
7115 See items describing the integer and floating-point types supported.
7116
7117 @sp 1
7118 @cartouche
7119 @noindent
7120 @strong{61}.  The accuracy actually achieved by the elementary
7121 functions.  See A.5.1(1).
7122 @end cartouche
7123 @noindent
7124 The elementary functions correspond to the functions available in the C
7125 library.  Only fast math mode is implemented.
7126
7127 @sp 1
7128 @cartouche
7129 @noindent
7130 @strong{62}.  The sign of a zero result from some of the operators or
7131 functions in @code{Numerics.Generic_Elementary_Functions}, when
7132 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7133 @end cartouche
7134 @noindent
7135 The sign of zeroes follows the requirements of the IEEE 754 standard on
7136 floating-point.
7137
7138 @sp 1
7139 @cartouche
7140 @noindent
7141 @strong{63}.  The value of
7142 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7143 @end cartouche
7144 @noindent
7145 Maximum image width is 649, see library file @file{a-numran.ads}.
7146
7147 @sp 1
7148 @cartouche
7149 @noindent
7150 @strong{64}.  The value of
7151 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7152 @end cartouche
7153 @noindent
7154 Maximum image width is 80, see library file @file{a-nudira.ads}.
7155
7156 @sp 1
7157 @cartouche
7158 @noindent
7159 @strong{65}.  The algorithms for random number generation.  See
7160 A.5.2(32).
7161 @end cartouche
7162 @noindent
7163 The algorithm is documented in the source files @file{a-numran.ads} and
7164 @file{a-numran.adb}.
7165
7166 @sp 1
7167 @cartouche
7168 @noindent
7169 @strong{66}.  The string representation of a random number generator's
7170 state.  See A.5.2(38).
7171 @end cartouche
7172 @noindent
7173 See the documentation contained in the file @file{a-numran.adb}.
7174
7175 @sp 1
7176 @cartouche
7177 @noindent
7178 @strong{67}.  The minimum time interval between calls to the
7179 time-dependent Reset procedure that are guaranteed to initiate different
7180 random number sequences.  See A.5.2(45).
7181 @end cartouche
7182 @noindent
7183 The minimum period between reset calls to guarantee distinct series of
7184 random numbers is one microsecond.
7185
7186 @sp 1
7187 @cartouche
7188 @noindent
7189 @strong{68}.  The values of the @code{Model_Mantissa},
7190 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7191 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7192 Annex is not supported.  See A.5.3(72).
7193 @end cartouche
7194 @noindent
7195 See the source file @file{ttypef.ads} for the values of all numeric
7196 attributes.
7197
7198 @sp 1
7199 @cartouche
7200 @noindent
7201 @strong{69}.  Any implementation-defined characteristics of the
7202 input-output packages.  See A.7(14).
7203 @end cartouche
7204 @noindent
7205 There are no special implementation defined characteristics for these
7206 packages.
7207
7208 @sp 1
7209 @cartouche
7210 @noindent
7211 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7212 A.9(10).
7213 @end cartouche
7214 @noindent
7215 All type representations are contiguous, and the @code{Buffer_Size} is
7216 the value of @code{@var{type}'Size} rounded up to the next storage unit
7217 boundary.
7218
7219 @sp 1
7220 @cartouche
7221 @noindent
7222 @strong{71}.  External files for standard input, standard output, and
7223 standard error See A.10(5).
7224 @end cartouche
7225 @noindent
7226 These files are mapped onto the files provided by the C streams
7227 libraries.  See source file @file{i-cstrea.ads} for further details.
7228
7229 @sp 1
7230 @cartouche
7231 @noindent
7232 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7233 A.10.9(36).
7234 @end cartouche
7235 @noindent
7236 If more digits are requested in the output than are represented by the
7237 precision of the value, zeroes are output in the corresponding least
7238 significant digit positions.
7239
7240 @sp 1
7241 @cartouche
7242 @noindent
7243 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7244 @code{Command_Name}.  See A.15(1).
7245 @end cartouche
7246 @noindent
7247 These are mapped onto the @code{argv} and @code{argc} parameters of the
7248 main program in the natural manner.
7249
7250 @sp 1
7251 @cartouche
7252 @noindent
7253 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7254 @end cartouche
7255 @noindent
7256 The following convention names are supported
7257
7258 @table @code
7259 @item  Ada
7260 Ada
7261 @item Assembler
7262 Assembly language
7263 @item Asm
7264 Synonym for Assembler
7265 @item Assembly
7266 Synonym for Assembler
7267 @item C
7268 C
7269 @item C_Pass_By_Copy
7270 Allowed only for record types, like C, but also notes that record
7271 is to be passed by copy rather than reference.
7272 @item COBOL
7273 COBOL
7274 @item CPP
7275 C++
7276 @item Default
7277 Treated the same as C
7278 @item External
7279 Treated the same as C
7280 @item Fortran
7281 Fortran
7282 @item Intrinsic
7283 For support of pragma @code{Import} with convention Intrinsic, see
7284 separate section on Intrinsic Subprograms.
7285 @item Stdcall
7286 Stdcall (used for Windows implementations only).  This convention correspond
7287 to the WINAPI (previously called Pascal convention) C/C++ convention under
7288 Windows.  A function with this convention cleans the stack before exit.
7289 @item DLL
7290 Synonym for Stdcall
7291 @item Win32
7292 Synonym for Stdcall
7293 @item Stubbed
7294 Stubbed is a special convention used to indicate that the body of the
7295 subprogram will be entirely ignored.  Any call to the subprogram
7296 is converted into a raise of the @code{Program_Error} exception.  If a
7297 pragma @code{Import} specifies convention @code{stubbed} then no body need
7298 be present at all.  This convention is useful during development for the
7299 inclusion of subprograms whose body has not yet been written.
7300
7301 @end table
7302 @noindent
7303 In addition, all otherwise unrecognized convention names are also
7304 treated as being synonymous with convention C@.  In all implementations
7305 except for VMS, use of such other names results in a warning.  In VMS
7306 implementations, these names are accepted silently.
7307
7308 @sp 1
7309 @cartouche
7310 @noindent
7311 @strong{75}.  The meaning of link names.  See B.1(36).
7312 @end cartouche
7313 @noindent
7314 Link names are the actual names used by the linker.
7315
7316 @sp 1
7317 @cartouche
7318 @noindent
7319 @strong{76}.  The manner of choosing link names when neither the link
7320 name nor the address of an imported or exported entity is specified.  See
7321 B.1(36).
7322 @end cartouche
7323 @noindent
7324 The default linker name is that which would be assigned by the relevant
7325 external language, interpreting the Ada name as being in all lower case
7326 letters.
7327
7328 @sp 1
7329 @cartouche
7330 @noindent
7331 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7332 @end cartouche
7333 @noindent
7334 The string passed to @code{Linker_Options} is presented uninterpreted as
7335 an argument to the link command, unless it contains Ascii.NUL characters.
7336 NUL characters if they appear act as argument separators, so for example
7337
7338 @smallexample @c ada
7339 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7340 @end smallexample
7341
7342 @noindent
7343 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7344 linker. The order of linker options is preserved for a given unit. The final
7345 list of options passed to the linker is in reverse order of the elaboration
7346 order. For example, linker options fo a body always appear before the options
7347 from the corresponding package spec.
7348
7349 @sp 1
7350 @cartouche
7351 @noindent
7352 @strong{78}.  The contents of the visible part of package
7353 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7354 @end cartouche
7355 @noindent
7356 See files with prefix @file{i-} in the distributed library.
7357
7358 @sp 1
7359 @cartouche
7360 @noindent
7361 @strong{79}.  Implementation-defined children of package
7362 @code{Interfaces}.  The contents of the visible part of package
7363 @code{Interfaces}.  See B.2(11).
7364 @end cartouche
7365 @noindent
7366 See files with prefix @file{i-} in the distributed library.
7367
7368 @sp 1
7369 @cartouche
7370 @noindent
7371 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7372 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7373 @code{COBOL_Character}; and the initialization of the variables
7374 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7375 @code{Interfaces.COBOL}.  See B.4(50).
7376 @end cartouche
7377 @noindent
7378 @table @code
7379 @item Floating
7380 Float
7381 @item Long_Floating
7382 (Floating) Long_Float
7383 @item Binary
7384 Integer
7385 @item Long_Binary
7386 Long_Long_Integer
7387 @item Decimal_Element
7388 Character
7389 @item COBOL_Character
7390 Character
7391 @end table
7392
7393 @noindent
7394 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7395
7396 @sp 1
7397 @cartouche
7398 @noindent
7399 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7400 @end cartouche
7401 @noindent
7402 See documentation in file @file{s-maccod.ads} in the distributed library.
7403
7404 @sp 1
7405 @cartouche
7406 @noindent
7407 @strong{82}.  Implementation-defined aspects of access to machine
7408 operations.  See C.1(9).
7409 @end cartouche
7410 @noindent
7411 See documentation in file @file{s-maccod.ads} in the distributed library.
7412
7413 @sp 1
7414 @cartouche
7415 @noindent
7416 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7417 @end cartouche
7418 @noindent
7419 Interrupts are mapped to signals or conditions as appropriate.  See
7420 definition of unit
7421 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7422 on the interrupts supported on a particular target.
7423
7424 @sp 1
7425 @cartouche
7426 @noindent
7427 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7428 C.4(13).
7429 @end cartouche
7430 @noindent
7431 GNAT does not permit a partition to be restarted without reloading,
7432 except under control of the debugger.
7433
7434 @sp 1
7435 @cartouche
7436 @noindent
7437 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7438 @end cartouche
7439 @noindent
7440 Pragma @code{Discard_Names} causes names of enumeration literals to
7441 be suppressed.  In the presence of this pragma, the Image attribute
7442 provides the image of the Pos of the literal, and Value accepts
7443 Pos values.
7444
7445 @sp 1
7446 @cartouche
7447 @noindent
7448 @strong{86}.  The result of the @code{Task_Identification.Image}
7449 attribute.  See C.7.1(7).
7450 @end cartouche
7451 @noindent
7452 The result of this attribute is an 8-digit hexadecimal string
7453 representing the virtual address of the task control block.
7454
7455 @sp 1
7456 @cartouche
7457 @noindent
7458 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7459 or interrupt handler.  See C.7.1(17).
7460 @end cartouche
7461 @noindent
7462 Protected entries or interrupt handlers can be executed by any
7463 convenient thread, so the value of @code{Current_Task} is undefined.
7464
7465 @sp 1
7466 @cartouche
7467 @noindent
7468 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7469 body or interrupt handler.  See C.7.1(19).
7470 @end cartouche
7471 @noindent
7472 The effect of calling @code{Current_Task} from an entry body or
7473 interrupt handler is to return the identification of the task currently
7474 executing the code.
7475
7476 @sp 1
7477 @cartouche
7478 @noindent
7479 @strong{89}.  Implementation-defined aspects of
7480 @code{Task_Attributes}.  See C.7.2(19).
7481 @end cartouche
7482 @noindent
7483 There are no implementation-defined aspects of @code{Task_Attributes}.
7484
7485 @sp 1
7486 @cartouche
7487 @noindent
7488 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7489 @end cartouche
7490 @noindent
7491 The metrics information for GNAT depends on the performance of the
7492 underlying operating system.  The sources of the run-time for tasking
7493 implementation, together with the output from @code{-gnatG} can be
7494 used to determine the exact sequence of operating systems calls made
7495 to implement various tasking constructs.  Together with appropriate
7496 information on the performance of the underlying operating system,
7497 on the exact target in use, this information can be used to determine
7498 the required metrics.
7499
7500 @sp 1
7501 @cartouche
7502 @noindent
7503 @strong{91}.  The declarations of @code{Any_Priority} and
7504 @code{Priority}.  See D.1(11).
7505 @end cartouche
7506 @noindent
7507 See declarations in file @file{system.ads}.
7508
7509 @sp 1
7510 @cartouche
7511 @noindent
7512 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7513 @end cartouche
7514 @noindent
7515 There are no implementation-defined execution resources.
7516
7517 @sp 1
7518 @cartouche
7519 @noindent
7520 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7521 access to a protected object keeps its processor busy.  See D.2.1(3).
7522 @end cartouche
7523 @noindent
7524 On a multi-processor, a task that is waiting for access to a protected
7525 object does not keep its processor busy.
7526
7527 @sp 1
7528 @cartouche
7529 @noindent
7530 @strong{94}.  The affect of implementation defined execution resources
7531 on task dispatching.  See D.2.1(9).
7532 @end cartouche
7533 @noindent
7534 @c SGI info
7535 @ignore
7536 Tasks map to IRIX threads, and the dispatching policy is as defined by
7537 the IRIX implementation of threads.
7538 @end ignore
7539 Tasks map to threads in the threads package used by GNAT@.  Where possible
7540 and appropriate, these threads correspond to native threads of the
7541 underlying operating system.
7542
7543 @sp 1
7544 @cartouche
7545 @noindent
7546 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7547 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7548 @end cartouche
7549 @noindent
7550 There are no implementation-defined policy-identifiers allowed in this
7551 pragma.
7552
7553 @sp 1
7554 @cartouche
7555 @noindent
7556 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7557 D.2.2(16).
7558 @end cartouche
7559 @noindent
7560 Execution of a task cannot be preempted by the implementation processing
7561 of delay expirations for lower priority tasks.
7562
7563 @sp 1
7564 @cartouche
7565 @noindent
7566 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7567 @end cartouche
7568 @noindent
7569 @c SGI info:
7570 @ignore
7571 Tasks map to IRIX threads, and the dispatching policy is as defied by
7572 the IRIX implementation of threads.
7573 @end ignore
7574 The policy is the same as that of the underlying threads implementation.
7575
7576 @sp 1
7577 @cartouche
7578 @noindent
7579 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7580 in a pragma @code{Locking_Policy}.  See D.3(4).
7581 @end cartouche
7582 @noindent
7583 The only implementation defined policy permitted in GNAT is
7584 @code{Inheritance_Locking}.  On targets that support this policy, locking
7585 is implemented by inheritance, i.e.@: the task owning the lock operates
7586 at a priority equal to the highest priority of any task currently
7587 requesting the lock.
7588
7589 @sp 1
7590 @cartouche
7591 @noindent
7592 @strong{99}.  Default ceiling priorities.  See D.3(10).
7593 @end cartouche
7594 @noindent
7595 The ceiling priority of protected objects of the type
7596 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7597 Reference Manual D.3(10),
7598
7599 @sp 1
7600 @cartouche
7601 @noindent
7602 @strong{100}.  The ceiling of any protected object used internally by
7603 the implementation.  See D.3(16).
7604 @end cartouche
7605 @noindent
7606 The ceiling priority of internal protected objects is
7607 @code{System.Priority'Last}.
7608
7609 @sp 1
7610 @cartouche
7611 @noindent
7612 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7613 @end cartouche
7614 @noindent
7615 There are no implementation-defined queueing policies.
7616
7617 @sp 1
7618 @cartouche
7619 @noindent
7620 @strong{102}.  On a multiprocessor, any conditions that cause the
7621 completion of an aborted construct to be delayed later than what is
7622 specified for a single processor.  See D.6(3).
7623 @end cartouche
7624 @noindent
7625 The semantics for abort on a multi-processor is the same as on a single
7626 processor, there are no further delays.
7627
7628 @sp 1
7629 @cartouche
7630 @noindent
7631 @strong{103}.  Any operations that implicitly require heap storage
7632 allocation.  See D.7(8).
7633 @end cartouche
7634 @noindent
7635 The only operation that implicitly requires heap storage allocation is
7636 task creation.
7637
7638 @sp 1
7639 @cartouche
7640 @noindent
7641 @strong{104}.  Implementation-defined aspects of pragma
7642 @code{Restrictions}.  See D.7(20).
7643 @end cartouche
7644 @noindent
7645 There are no such implementation-defined aspects.
7646
7647 @sp 1
7648 @cartouche
7649 @noindent
7650 @strong{105}.  Implementation-defined aspects of package
7651 @code{Real_Time}.  See D.8(17).
7652 @end cartouche
7653 @noindent
7654 There are no implementation defined aspects of package @code{Real_Time}.
7655
7656 @sp 1
7657 @cartouche
7658 @noindent
7659 @strong{106}.  Implementation-defined aspects of
7660 @code{delay_statements}.  See D.9(8).
7661 @end cartouche
7662 @noindent
7663 Any difference greater than one microsecond will cause the task to be
7664 delayed (see D.9(7)).
7665
7666 @sp 1
7667 @cartouche
7668 @noindent
7669 @strong{107}.  The upper bound on the duration of interrupt blocking
7670 caused by the implementation.  See D.12(5).
7671 @end cartouche
7672 @noindent
7673 The upper bound is determined by the underlying operating system.  In
7674 no cases is it more than 10 milliseconds.
7675
7676 @sp 1
7677 @cartouche
7678 @noindent
7679 @strong{108}.  The means for creating and executing distributed
7680 programs.  See E(5).
7681 @end cartouche
7682 @noindent
7683 The GLADE package provides a utility GNATDIST for creating and executing
7684 distributed programs.  See the GLADE reference manual for further details.
7685
7686 @sp 1
7687 @cartouche
7688 @noindent
7689 @strong{109}.  Any events that can result in a partition becoming
7690 inaccessible.  See E.1(7).
7691 @end cartouche
7692 @noindent
7693 See the GLADE reference manual for full details on such events.
7694
7695 @sp 1
7696 @cartouche
7697 @noindent
7698 @strong{110}.  The scheduling policies, treatment of priorities, and
7699 management of shared resources between partitions in certain cases.  See
7700 E.1(11).
7701 @end cartouche
7702 @noindent
7703 See the GLADE reference manual for full details on these aspects of
7704 multi-partition execution.
7705
7706 @sp 1
7707 @cartouche
7708 @noindent
7709 @strong{111}.  Events that cause the version of a compilation unit to
7710 change.  See E.3(5).
7711 @end cartouche
7712 @noindent
7713 Editing the source file of a compilation unit, or the source files of
7714 any units on which it is dependent in a significant way cause the version
7715 to change.  No other actions cause the version number to change.  All changes
7716 are significant except those which affect only layout, capitalization or
7717 comments.
7718
7719 @sp 1
7720 @cartouche
7721 @noindent
7722 @strong{112}.  Whether the execution of the remote subprogram is
7723 immediately aborted as a result of cancellation.  See E.4(13).
7724 @end cartouche
7725 @noindent
7726 See the GLADE reference manual for details on the effect of abort in
7727 a distributed application.
7728
7729 @sp 1
7730 @cartouche
7731 @noindent
7732 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7733 @end cartouche
7734 @noindent
7735 See the GLADE reference manual for a full description of all implementation
7736 defined aspects of the PCS@.
7737
7738 @sp 1
7739 @cartouche
7740 @noindent
7741 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7742 E.5(26).
7743 @end cartouche
7744 @noindent
7745 See the GLADE reference manual for a full description of all
7746 implementation defined interfaces.
7747
7748 @sp 1
7749 @cartouche
7750 @noindent
7751 @strong{115}.  The values of named numbers in the package
7752 @code{Decimal}.  See F.2(7).
7753 @end cartouche
7754 @noindent
7755 @table @code
7756 @item Max_Scale
7757 +18
7758 @item Min_Scale
7759 -18
7760 @item Min_Delta
7761 1.0E-18
7762 @item Max_Delta
7763 1.0E+18
7764 @item Max_Decimal_Digits
7765 18
7766 @end table
7767
7768 @sp 1
7769 @cartouche
7770 @noindent
7771 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7772 @code{Text_IO.Editing}.  See F.3.3(16).
7773 @end cartouche
7774 @noindent
7775 64
7776
7777 @sp 1
7778 @cartouche
7779 @noindent
7780 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7781 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7782 @end cartouche
7783 @noindent
7784 64
7785
7786 @sp 1
7787 @cartouche
7788 @noindent
7789 @strong{118}.  The accuracy actually achieved by the complex elementary
7790 functions and by other complex arithmetic operations.  See G.1(1).
7791 @end cartouche
7792 @noindent
7793 Standard library functions are used for the complex arithmetic
7794 operations.  Only fast math mode is currently supported.
7795
7796 @sp 1
7797 @cartouche
7798 @noindent
7799 @strong{119}.  The sign of a zero result (or a component thereof) from
7800 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7801 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7802 @end cartouche
7803 @noindent
7804 The signs of zero values are as recommended by the relevant
7805 implementation advice.
7806
7807 @sp 1
7808 @cartouche
7809 @noindent
7810 @strong{120}.  The sign of a zero result (or a component thereof) from
7811 any operator or function in
7812 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7813 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7814 @end cartouche
7815 @noindent
7816 The signs of zero values are as recommended by the relevant
7817 implementation advice.
7818
7819 @sp 1
7820 @cartouche
7821 @noindent
7822 @strong{121}.  Whether the strict mode or the relaxed mode is the
7823 default.  See G.2(2).
7824 @end cartouche
7825 @noindent
7826 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7827 provides a highly efficient implementation of strict mode.
7828
7829 @sp 1
7830 @cartouche
7831 @noindent
7832 @strong{122}.  The result interval in certain cases of fixed-to-float
7833 conversion.  See G.2.1(10).
7834 @end cartouche
7835 @noindent
7836 For cases where the result interval is implementation dependent, the
7837 accuracy is that provided by performing all operations in 64-bit IEEE
7838 floating-point format.
7839
7840 @sp 1
7841 @cartouche
7842 @noindent
7843 @strong{123}.  The result of a floating point arithmetic operation in
7844 overflow situations, when the @code{Machine_Overflows} attribute of the
7845 result type is @code{False}.  See G.2.1(13).
7846 @end cartouche
7847 @noindent
7848 Infinite and Nan values are produced as dictated by the IEEE
7849 floating-point standard.
7850
7851 @sp 1
7852 @cartouche
7853 @noindent
7854 @strong{124}.  The result interval for division (or exponentiation by a
7855 negative exponent), when the floating point hardware implements division
7856 as multiplication by a reciprocal.  See G.2.1(16).
7857 @end cartouche
7858 @noindent
7859 Not relevant, division is IEEE exact.
7860
7861 @sp 1
7862 @cartouche
7863 @noindent
7864 @strong{125}.  The definition of close result set, which determines the
7865 accuracy of certain fixed point multiplications and divisions.  See
7866 G.2.3(5).
7867 @end cartouche
7868 @noindent
7869 Operations in the close result set are performed using IEEE long format
7870 floating-point arithmetic.  The input operands are converted to
7871 floating-point, the operation is done in floating-point, and the result
7872 is converted to the target type.
7873
7874 @sp 1
7875 @cartouche
7876 @noindent
7877 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7878 point multiplication or division for which the result shall be in the
7879 perfect result set.  See G.2.3(22).
7880 @end cartouche
7881 @noindent
7882 The result is only defined to be in the perfect result set if the result
7883 can be computed by a single scaling operation involving a scale factor
7884 representable in 64-bits.
7885
7886 @sp 1
7887 @cartouche
7888 @noindent
7889 @strong{127}.  The result of a fixed point arithmetic operation in
7890 overflow situations, when the @code{Machine_Overflows} attribute of the
7891 result type is @code{False}.  See G.2.3(27).
7892 @end cartouche
7893 @noindent
7894 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7895 types.
7896
7897 @sp 1
7898 @cartouche
7899 @noindent
7900 @strong{128}.  The result of an elementary function reference in
7901 overflow situations, when the @code{Machine_Overflows} attribute of the
7902 result type is @code{False}.  See G.2.4(4).
7903 @end cartouche
7904 @noindent
7905 IEEE infinite and Nan values are produced as appropriate.
7906
7907 @sp 1
7908 @cartouche
7909 @noindent
7910 @strong{129}.  The value of the angle threshold, within which certain
7911 elementary functions, complex arithmetic operations, and complex
7912 elementary functions yield results conforming to a maximum relative
7913 error bound.  See G.2.4(10).
7914 @end cartouche
7915 @noindent
7916 Information on this subject is not yet available.
7917
7918 @sp 1
7919 @cartouche
7920 @noindent
7921 @strong{130}.  The accuracy of certain elementary functions for
7922 parameters beyond the angle threshold.  See G.2.4(10).
7923 @end cartouche
7924 @noindent
7925 Information on this subject is not yet available.
7926
7927 @sp 1
7928 @cartouche
7929 @noindent
7930 @strong{131}.  The result of a complex arithmetic operation or complex
7931 elementary function reference in overflow situations, when the
7932 @code{Machine_Overflows} attribute of the corresponding real type is
7933 @code{False}.  See G.2.6(5).
7934 @end cartouche
7935 @noindent
7936 IEEE infinite and Nan values are produced as appropriate.
7937
7938 @sp 1
7939 @cartouche
7940 @noindent
7941 @strong{132}.  The accuracy of certain complex arithmetic operations and
7942 certain complex elementary functions for parameters (or components
7943 thereof) beyond the angle threshold.  See G.2.6(8).
7944 @end cartouche
7945 @noindent
7946 Information on those subjects is not yet available.
7947
7948 @sp 1
7949 @cartouche
7950 @noindent
7951 @strong{133}.  Information regarding bounded errors and erroneous
7952 execution.  See H.2(1).
7953 @end cartouche
7954 @noindent
7955 Information on this subject is not yet available.
7956
7957 @sp 1
7958 @cartouche
7959 @noindent
7960 @strong{134}.  Implementation-defined aspects of pragma
7961 @code{Inspection_Point}.  See H.3.2(8).
7962 @end cartouche
7963 @noindent
7964 Pragma @code{Inspection_Point} ensures that the variable is live and can
7965 be examined by the debugger at the inspection point.
7966
7967 @sp 1
7968 @cartouche
7969 @noindent
7970 @strong{135}.  Implementation-defined aspects of pragma
7971 @code{Restrictions}.  See H.4(25).
7972 @end cartouche
7973 @noindent
7974 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
7975 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
7976 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
7977
7978 @sp 1
7979 @cartouche
7980 @noindent
7981 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
7982 H.4(27).
7983 @end cartouche
7984 @noindent
7985 There are no restrictions on pragma @code{Restrictions}.
7986
7987 @node Intrinsic Subprograms
7988 @chapter Intrinsic Subprograms
7989 @cindex Intrinsic Subprograms
7990
7991 @menu
7992 * Intrinsic Operators::
7993 * Enclosing_Entity::
7994 * Exception_Information::
7995 * Exception_Message::
7996 * Exception_Name::
7997 * File::
7998 * Line::
7999 * Rotate_Left::
8000 * Rotate_Right::
8001 * Shift_Left::
8002 * Shift_Right::
8003 * Shift_Right_Arithmetic::
8004 * Source_Location::
8005 @end menu
8006
8007 @noindent
8008 GNAT allows a user application program to write the declaration:
8009
8010 @smallexample @c ada
8011    pragma Import (Intrinsic, name);
8012 @end smallexample
8013
8014 @noindent
8015 providing that the name corresponds to one of the implemented intrinsic
8016 subprograms in GNAT, and that the parameter profile of the referenced
8017 subprogram meets the requirements.  This chapter describes the set of
8018 implemented intrinsic subprograms, and the requirements on parameter profiles.
8019 Note that no body is supplied; as with other uses of pragma Import, the
8020 body is supplied elsewhere (in this case by the compiler itself).  Note
8021 that any use of this feature is potentially non-portable, since the
8022 Ada standard does not require Ada compilers to implement this feature.
8023
8024 @node Intrinsic Operators
8025 @section Intrinsic Operators
8026 @cindex Intrinsic operator
8027
8028 @noindent
8029 All the predefined numeric operators in package Standard
8030 in @code{pragma Import (Intrinsic,..)}
8031 declarations.  In the binary operator case, the operands must have the same
8032 size.  The operand or operands must also be appropriate for
8033 the operator.  For example, for addition, the operands must
8034 both be floating-point or both be fixed-point, and the
8035 right operand for @code{"**"} must have a root type of
8036 @code{Standard.Integer'Base}.
8037 You can use an intrinsic operator declaration as in the following example:
8038
8039 @smallexample @c ada
8040    type Int1 is new Integer;
8041    type Int2 is new Integer;
8042
8043    function "+" (X1 : Int1; X2 : Int2) return Int1;
8044    function "+" (X1 : Int1; X2 : Int2) return Int2;
8045    pragma Import (Intrinsic, "+");
8046 @end smallexample
8047
8048 @noindent
8049 This declaration would permit ``mixed mode'' arithmetic on items
8050 of the differing types @code{Int1} and @code{Int2}.
8051 It is also possible to specify such operators for private types, if the
8052 full views are appropriate arithmetic types.
8053
8054 @node Enclosing_Entity
8055 @section Enclosing_Entity
8056 @cindex Enclosing_Entity
8057 @noindent
8058 This intrinsic subprogram is used in the implementation of the
8059 library routine @code{GNAT.Source_Info}.  The only useful use of the
8060 intrinsic import in this case is the one in this unit, so an
8061 application program should simply call the function
8062 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8063 the current subprogram, package, task, entry, or protected subprogram.
8064
8065 @node Exception_Information
8066 @section Exception_Information
8067 @cindex Exception_Information'
8068 @noindent
8069 This intrinsic subprogram is used in the implementation of the
8070 library routine @code{GNAT.Current_Exception}.  The only useful
8071 use of the intrinsic import in this case is the one in this unit,
8072 so an application program should simply call the function
8073 @code{GNAT.Current_Exception.Exception_Information} to obtain
8074 the exception information associated with the current exception.
8075
8076 @node Exception_Message
8077 @section Exception_Message
8078 @cindex Exception_Message
8079 @noindent
8080 This intrinsic subprogram is used in the implementation of the
8081 library routine @code{GNAT.Current_Exception}.  The only useful
8082 use of the intrinsic import in this case is the one in this unit,
8083 so an application program should simply call the function
8084 @code{GNAT.Current_Exception.Exception_Message} to obtain
8085 the message associated with the current exception.
8086
8087 @node Exception_Name
8088 @section Exception_Name
8089 @cindex Exception_Name
8090 @noindent
8091 This intrinsic subprogram is used in the implementation of the
8092 library routine @code{GNAT.Current_Exception}.  The only useful
8093 use of the intrinsic import in this case is the one in this unit,
8094 so an application program should simply call the function
8095 @code{GNAT.Current_Exception.Exception_Name} to obtain
8096 the name of the current exception.
8097
8098 @node File
8099 @section File
8100 @cindex File
8101 @noindent
8102 This intrinsic subprogram is used in the implementation of the
8103 library routine @code{GNAT.Source_Info}.  The only useful use of the
8104 intrinsic import in this case is the one in this unit, so an
8105 application program should simply call the function
8106 @code{GNAT.Source_Info.File} to obtain the name of the current
8107 file.
8108
8109 @node Line
8110 @section Line
8111 @cindex Line
8112 @noindent
8113 This intrinsic subprogram is used in the implementation of the
8114 library routine @code{GNAT.Source_Info}.  The only useful use of the
8115 intrinsic import in this case is the one in this unit, so an
8116 application program should simply call the function
8117 @code{GNAT.Source_Info.Line} to obtain the number of the current
8118 source line.
8119
8120 @node Rotate_Left
8121 @section Rotate_Left
8122 @cindex Rotate_Left
8123 @noindent
8124 In standard Ada 95, the @code{Rotate_Left} function is available only
8125 for the predefined modular types in package @code{Interfaces}.  However, in
8126 GNAT it is possible to define a Rotate_Left function for a user
8127 defined modular type or any signed integer type as in this example:
8128
8129 @smallexample @c ada
8130    function Shift_Left
8131      (Value  : My_Modular_Type;
8132       Amount : Natural)
8133       return   My_Modular_Type;
8134 @end smallexample
8135
8136 @noindent
8137 The requirements are that the profile be exactly as in the example
8138 above.  The only modifications allowed are in the formal parameter
8139 names, and in the type of @code{Value} and the return type, which
8140 must be the same, and must be either a signed integer type, or
8141 a modular integer type with a binary modulus, and the size must
8142 be 8.  16, 32 or 64 bits.
8143
8144 @node Rotate_Right
8145 @section Rotate_Right
8146 @cindex Rotate_Right
8147 @noindent
8148 A @code{Rotate_Right} function can be defined for any user defined
8149 binary modular integer type, or signed integer type, as described
8150 above for @code{Rotate_Left}.
8151
8152 @node Shift_Left
8153 @section Shift_Left
8154 @cindex Shift_Left
8155 @noindent
8156 A @code{Shift_Left} function can be defined for any user defined
8157 binary modular integer type, or signed integer type, as described
8158 above for @code{Rotate_Left}.
8159
8160 @node Shift_Right
8161 @section Shift_Right
8162 @cindex Shift_Right
8163 @noindent
8164 A @code{Shift_Right} function can be defined for any user defined
8165 binary modular integer type, or signed integer type, as described
8166 above for @code{Rotate_Left}.
8167
8168 @node Shift_Right_Arithmetic
8169 @section Shift_Right_Arithmetic
8170 @cindex Shift_Right_Arithmetic
8171 @noindent
8172 A @code{Shift_Right_Arithmetic} function can be defined for any user
8173 defined binary modular integer type, or signed integer type, as described
8174 above for @code{Rotate_Left}.
8175
8176 @node Source_Location
8177 @section Source_Location
8178 @cindex Source_Location
8179 @noindent
8180 This intrinsic subprogram is used in the implementation of the
8181 library routine @code{GNAT.Source_Info}.  The only useful use of the
8182 intrinsic import in this case is the one in this unit, so an
8183 application program should simply call the function
8184 @code{GNAT.Source_Info.Source_Location} to obtain the current
8185 source file location.
8186
8187 @node Representation Clauses and Pragmas
8188 @chapter Representation Clauses and Pragmas
8189 @cindex Representation Clauses
8190
8191 @menu
8192 * Alignment Clauses::
8193 * Size Clauses::
8194 * Storage_Size Clauses::
8195 * Size of Variant Record Objects::
8196 * Biased Representation ::
8197 * Value_Size and Object_Size Clauses::
8198 * Component_Size Clauses::
8199 * Bit_Order Clauses::
8200 * Effect of Bit_Order on Byte Ordering::
8201 * Pragma Pack for Arrays::
8202 * Pragma Pack for Records::
8203 * Record Representation Clauses::
8204 * Enumeration Clauses::
8205 * Address Clauses::
8206 * Effect of Convention on Representation::
8207 * Determining the Representations chosen by GNAT::
8208 @end menu
8209
8210 @noindent
8211 @cindex Representation Clause
8212 @cindex Representation Pragma
8213 @cindex Pragma, representation
8214 This section describes the representation clauses accepted by GNAT, and
8215 their effect on the representation of corresponding data objects.
8216
8217 GNAT fully implements Annex C (Systems Programming).  This means that all
8218 the implementation advice sections in chapter 13 are fully implemented.
8219 However, these sections only require a minimal level of support for
8220 representation clauses.  GNAT provides much more extensive capabilities,
8221 and this section describes the additional capabilities provided.
8222
8223 @node Alignment Clauses
8224 @section Alignment Clauses
8225 @cindex Alignment Clause
8226
8227 @noindent
8228 GNAT requires that all alignment clauses specify a power of 2, and all
8229 default alignments are always a power of 2.  The default alignment
8230 values are as follows:
8231
8232 @itemize @bullet
8233 @item @emph{Primitive Types}.
8234 For primitive types, the alignment is the minimum of the actual size of
8235 objects of the type divided by @code{Storage_Unit},
8236 and the maximum alignment supported by the target.
8237 (This maximum alignment is given by the GNAT-specific attribute
8238 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8239 @cindex @code{Maximum_Alignment} attribute
8240 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8241 default alignment will be 8 on any target that supports alignments
8242 this large, but on some targets, the maximum alignment may be smaller
8243 than 8, in which case objects of type @code{Long_Float} will be maximally
8244 aligned.
8245
8246 @item @emph{Arrays}.
8247 For arrays, the alignment is equal to the alignment of the component type
8248 for the normal case where no packing or component size is given.  If the
8249 array is packed, and the packing is effective (see separate section on
8250 packed arrays), then the alignment will be one for long packed arrays,
8251 or arrays whose length is not known at compile time.  For short packed
8252 arrays, which are handled internally as modular types, the alignment
8253 will be as described for primitive types, e.g.@: a packed array of length
8254 31 bits will have an object size of four bytes, and an alignment of 4.
8255
8256 @item @emph{Records}.
8257 For the normal non-packed case, the alignment of a record is equal to
8258 the maximum alignment of any of its components.  For tagged records, this
8259 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8260 used and all fields are packable (see separate section on pragma @code{Pack}),
8261 then the resulting alignment is 1.
8262
8263 A special case is when:
8264 @itemize @bullet
8265 @item
8266 the size of the record is given explicitly, or a
8267 full record representation clause is given, and
8268 @item
8269 the size of the record is 2, 4, or 8 bytes.
8270 @end itemize
8271 @noindent
8272 In this case, an alignment is chosen to match the
8273 size of the record. For example, if we have:
8274
8275 @smallexample @c ada
8276    type Small is record
8277       A, B : Character;
8278    end record;
8279    for Small'Size use 16;
8280 @end smallexample
8281
8282 @noindent
8283 then the default alignment of the record type @code{Small} is 2, not 1. This
8284 leads to more efficient code when the record is treated as a unit, and also
8285 allows the type to specified as @code{Atomic} on architectures requiring
8286 strict alignment.
8287
8288 @end itemize
8289
8290 @noindent
8291 An alignment clause may
8292 always specify a larger alignment than the default value, up to some
8293 maximum value dependent on the target (obtainable by using the
8294 attribute reference @code{Standard'Maximum_Alignment}).
8295 The only case where
8296 it is permissible to specify a smaller alignment than the default value
8297 is for a record with a record representation clause.
8298 In this case, packable fields for which a component clause is
8299 given still result in a default alignment corresponding to the original
8300 type, but this may be overridden, since these components in fact only
8301 require an alignment of one byte.  For example, given
8302
8303 @smallexample @c ada
8304   type V is record
8305      A : Integer;
8306   end record;
8307
8308   for V use record
8309      A at 0  range 0 .. 31;
8310   end record;
8311
8312   for V'alignment use 1;
8313 @end smallexample
8314
8315 @noindent
8316 @cindex Alignment, default
8317 The default alignment for the type @code{V} is 4, as a result of the
8318 Integer field in the record, but since this field is placed with a
8319 component clause, it is permissible, as shown, to override the default
8320 alignment of the record with a smaller value.
8321
8322 @node Size Clauses
8323 @section Size Clauses
8324 @cindex Size Clause
8325
8326 @noindent
8327 The default size for a type @code{T} is obtainable through the
8328 language-defined attribute @code{T'Size} and also through the
8329 equivalent GNAT-defined attribute @code{T'Value_Size}.
8330 For objects of type @code{T}, GNAT will generally increase the type size
8331 so that the object size (obtainable through the GNAT-defined attribute
8332 @code{T'Object_Size})
8333 is a multiple of @code{T'Alignment * Storage_Unit}.
8334 For example
8335
8336 @smallexample @c ada
8337    type Smallint is range 1 .. 6;
8338
8339    type Rec is record
8340       Y1 : integer;
8341       Y2 : boolean;
8342    end record;
8343 @end smallexample
8344
8345 @noindent
8346 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8347 as specified by the RM rules,
8348 but objects of this type will have a size of 8
8349 (@code{Smallint'Object_Size} = 8),
8350 since objects by default occupy an integral number
8351 of storage units.  On some targets, notably older
8352 versions of the Digital Alpha, the size of stand
8353 alone objects of this type may be 32, reflecting
8354 the inability of the hardware to do byte load/stores.
8355
8356 Similarly, the size of type @code{Rec} is 40 bits
8357 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8358 the alignment is 4, so objects of this type will have
8359 their size increased to 64 bits so that it is a multiple
8360 of the alignment (in bits).  The reason for this decision, which is
8361 in accordance with the specific Implementation Advice in RM 13.3(43):
8362
8363 @quotation
8364 A @code{Size} clause should be supported for an object if the specified
8365 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8366 to a size in storage elements that is a multiple of the object's
8367 @code{Alignment} (if the @code{Alignment} is nonzero).
8368 @end quotation
8369
8370 @noindent
8371 An explicit size clause may be used to override the default size by
8372 increasing it.  For example, if we have:
8373
8374 @smallexample @c ada
8375    type My_Boolean is new Boolean;
8376    for My_Boolean'Size use 32;
8377 @end smallexample
8378
8379 @noindent
8380 then values of this type will always be 32 bits long.  In the case of
8381 discrete types, the size can be increased up to 64 bits, with the effect
8382 that the entire specified field is used to hold the value, sign- or
8383 zero-extended as appropriate.  If more than 64 bits is specified, then
8384 padding space is allocated after the value, and a warning is issued that
8385 there are unused bits.
8386
8387 Similarly the size of records and arrays may be increased, and the effect
8388 is to add padding bits after the value.  This also causes a warning message
8389 to be generated.
8390
8391 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8392 Size in bits, this corresponds to an object of size 256 megabytes (minus
8393 one).  This limitation is true on all targets.  The reason for this
8394 limitation is that it improves the quality of the code in many cases
8395 if it is known that a Size value can be accommodated in an object of
8396 type Integer.
8397
8398 @node Storage_Size Clauses
8399 @section Storage_Size Clauses
8400 @cindex Storage_Size Clause
8401
8402 @noindent
8403 For tasks, the @code{Storage_Size} clause specifies the amount of space
8404 to be allocated for the task stack.  This cannot be extended, and if the
8405 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8406 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8407 or a @code{Storage_Size} pragma in the task definition to set the
8408 appropriate required size.  A useful technique is to include in every
8409 task definition a pragma of the form:
8410
8411 @smallexample @c ada
8412    pragma Storage_Size (Default_Stack_Size);
8413 @end smallexample
8414
8415 @noindent
8416 Then @code{Default_Stack_Size} can be defined in a global package, and
8417 modified as required.  Any tasks requiring stack sizes different from the
8418 default can have an appropriate alternative reference in the pragma.
8419
8420 For access types, the @code{Storage_Size} clause specifies the maximum
8421 space available for allocation of objects of the type.  If this space is
8422 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8423 In the case where the access type is declared local to a subprogram, the
8424 use of a @code{Storage_Size} clause triggers automatic use of a special
8425 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8426 space for the pool is automatically reclaimed on exit from the scope in
8427 which the type is declared.
8428
8429 A special case recognized by the compiler is the specification of a
8430 @code{Storage_Size} of zero for an access type.  This means that no
8431 items can be allocated from the pool, and this is recognized at compile
8432 time, and all the overhead normally associated with maintaining a fixed
8433 size storage pool is eliminated.  Consider the following example:
8434
8435 @smallexample @c ada
8436    procedure p is
8437       type R is array (Natural) of Character;
8438       type P is access all R;
8439       for P'Storage_Size use 0;
8440       --  Above access type intended only for interfacing purposes
8441
8442       y : P;
8443
8444       procedure g (m : P);
8445       pragma Import (C, g);
8446
8447       --  @dots{}
8448
8449    begin
8450       --  @dots{}
8451       y := new R;
8452    end;
8453 @end smallexample
8454
8455 @noindent
8456 As indicated in this example, these dummy storage pools are often useful in
8457 connection with interfacing where no object will ever be allocated.  If you
8458 compile the above example, you get the warning:
8459
8460 @smallexample
8461    p.adb:16:09: warning: allocation from empty storage pool
8462    p.adb:16:09: warning: Storage_Error will be raised at run time
8463 @end smallexample
8464
8465 @noindent
8466 Of course in practice, there will not be any explicit allocators in the
8467 case of such an access declaration.
8468
8469 @node Size of Variant Record Objects
8470 @section Size of Variant Record Objects
8471 @cindex Size, variant record objects
8472 @cindex Variant record objects, size
8473
8474 @noindent
8475 In the case of variant record objects, there is a question whether Size gives
8476 information about a particular variant, or the maximum size required
8477 for any variant.  Consider the following program
8478
8479 @smallexample @c ada
8480 with Text_IO; use Text_IO;
8481 procedure q is
8482    type R1 (A : Boolean := False) is record
8483      case A is
8484        when True  => X : Character;
8485        when False => null;
8486      end case;
8487    end record;
8488
8489    V1 : R1 (False);
8490    V2 : R1;
8491
8492 begin
8493    Put_Line (Integer'Image (V1'Size));
8494    Put_Line (Integer'Image (V2'Size));
8495 end q;
8496 @end smallexample
8497
8498 @noindent
8499 Here we are dealing with a variant record, where the True variant
8500 requires 16 bits, and the False variant requires 8 bits.
8501 In the above example, both V1 and V2 contain the False variant,
8502 which is only 8 bits long.  However, the result of running the
8503 program is:
8504
8505 @smallexample
8506 8
8507 16
8508 @end smallexample
8509
8510 @noindent
8511 The reason for the difference here is that the discriminant value of
8512 V1 is fixed, and will always be False.  It is not possible to assign
8513 a True variant value to V1, therefore 8 bits is sufficient.  On the
8514 other hand, in the case of V2, the initial discriminant value is
8515 False (from the default), but it is possible to assign a True
8516 variant value to V2, therefore 16 bits must be allocated for V2
8517 in the general case, even fewer bits may be needed at any particular
8518 point during the program execution.
8519
8520 As can be seen from the output of this program, the @code{'Size}
8521 attribute applied to such an object in GNAT gives the actual allocated
8522 size of the variable, which is the largest size of any of the variants.
8523 The Ada Reference Manual is not completely clear on what choice should
8524 be made here, but the GNAT behavior seems most consistent with the
8525 language in the RM@.
8526
8527 In some cases, it may be desirable to obtain the size of the current
8528 variant, rather than the size of the largest variant.  This can be
8529 achieved in GNAT by making use of the fact that in the case of a
8530 subprogram parameter, GNAT does indeed return the size of the current
8531 variant (because a subprogram has no way of knowing how much space
8532 is actually allocated for the actual).
8533
8534 Consider the following modified version of the above program:
8535
8536 @smallexample @c ada
8537 with Text_IO; use Text_IO;
8538 procedure q is
8539    type R1 (A : Boolean := False) is record
8540      case A is
8541        when True  => X : Character;
8542        when False => null;
8543      end case;
8544    end record;
8545
8546    V2 : R1;
8547
8548    function Size (V : R1) return Integer is
8549    begin
8550       return V'Size;
8551    end Size;
8552
8553 begin
8554    Put_Line (Integer'Image (V2'Size));
8555    Put_Line (Integer'IMage (Size (V2)));
8556    V2 := (True, 'x');
8557    Put_Line (Integer'Image (V2'Size));
8558    Put_Line (Integer'IMage (Size (V2)));
8559 end q;
8560 @end smallexample
8561
8562 @noindent
8563 The output from this program is
8564
8565 @smallexample
8566 16
8567 8
8568 16
8569 16
8570 @end smallexample
8571
8572 @noindent
8573 Here we see that while the @code{'Size} attribute always returns
8574 the maximum size, regardless of the current variant value, the
8575 @code{Size} function does indeed return the size of the current
8576 variant value.
8577
8578 @node Biased Representation
8579 @section Biased Representation
8580 @cindex Size for biased representation
8581 @cindex Biased representation
8582
8583 @noindent
8584 In the case of scalars with a range starting at other than zero, it is
8585 possible in some cases to specify a size smaller than the default minimum
8586 value, and in such cases, GNAT uses an unsigned biased representation,
8587 in which zero is used to represent the lower bound, and successive values
8588 represent successive values of the type.
8589
8590 For example, suppose we have the declaration:
8591
8592 @smallexample @c ada
8593    type Small is range -7 .. -4;
8594    for Small'Size use 2;
8595 @end smallexample
8596
8597 @noindent
8598 Although the default size of type @code{Small} is 4, the @code{Size}
8599 clause is accepted by GNAT and results in the following representation
8600 scheme:
8601
8602 @smallexample
8603   -7 is represented as 2#00#
8604   -6 is represented as 2#01#
8605   -5 is represented as 2#10#
8606   -4 is represented as 2#11#
8607 @end smallexample
8608
8609 @noindent
8610 Biased representation is only used if the specified @code{Size} clause
8611 cannot be accepted in any other manner.  These reduced sizes that force
8612 biased representation can be used for all discrete types except for
8613 enumeration types for which a representation clause is given.
8614
8615 @node Value_Size and Object_Size Clauses
8616 @section Value_Size and Object_Size Clauses
8617 @findex Value_Size
8618 @findex Object_Size
8619 @cindex Size, of objects
8620
8621 @noindent
8622 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8623 required to hold values of type @code{T}.  Although this interpretation was
8624 allowed in Ada 83, it was not required, and this requirement in practice
8625 can cause some significant difficulties.  For example, in most Ada 83
8626 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8627 @code{Natural'Size} is
8628 typically 31.  This means that code may change in behavior when moving
8629 from Ada 83 to Ada 95.  For example, consider:
8630
8631 @smallexample @c ada
8632    type Rec is record;
8633       A : Natural;
8634       B : Natural;
8635    end record;
8636
8637    for Rec use record
8638       at 0  range 0 .. Natural'Size - 1;
8639       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8640    end record;
8641 @end smallexample
8642
8643 @noindent
8644 In the above code, since the typical size of @code{Natural} objects
8645 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8646 unexpected inefficient packing in Ada 95, and in general there are
8647 cases where the fact that the object size can exceed the
8648 size of the type causes surprises.
8649
8650 To help get around this problem GNAT provides two implementation
8651 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8652 applied to a type, these attributes yield the size of the type
8653 (corresponding to the RM defined size attribute), and the size of
8654 objects of the type respectively.
8655
8656 The @code{Object_Size} is used for determining the default size of
8657 objects and components.  This size value can be referred to using the
8658 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8659 the basis of the determination of the size.  The backend is free to
8660 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8661 character might be stored in 32 bits on a machine with no efficient
8662 byte access instructions such as the Alpha.
8663
8664 The default rules for the value of @code{Object_Size} for
8665 discrete types are as follows:
8666
8667 @itemize @bullet
8668 @item
8669 The @code{Object_Size} for base subtypes reflect the natural hardware
8670 size in bits (run the compiler with @option{-gnatS} to find those values
8671 for numeric types). Enumeration types and fixed-point base subtypes have
8672 8, 16, 32 or 64 bits for this size, depending on the range of values
8673 to be stored.
8674
8675 @item
8676 The @code{Object_Size} of a subtype is the same as the
8677 @code{Object_Size} of
8678 the type from which it is obtained.
8679
8680 @item
8681 The @code{Object_Size} of a derived base type is copied from the parent
8682 base type, and the @code{Object_Size} of a derived first subtype is copied
8683 from the parent first subtype.
8684 @end itemize
8685
8686 @noindent
8687 The @code{Value_Size} attribute
8688 is the (minimum) number of bits required to store a value
8689 of the type.
8690 This value is used to determine how tightly to pack
8691 records or arrays with components of this type, and also affects
8692 the semantics of unchecked conversion (unchecked conversions where
8693 the @code{Value_Size} values differ generate a warning, and are potentially
8694 target dependent).
8695
8696 The default rules for the value of @code{Value_Size} are as follows:
8697
8698 @itemize @bullet
8699 @item
8700 The @code{Value_Size} for a base subtype is the minimum number of bits
8701 required to store all values of the type (including the sign bit
8702 only if negative values are possible).
8703
8704 @item
8705 If a subtype statically matches the first subtype of a given type, then it has
8706 by default the same @code{Value_Size} as the first subtype.  This is a
8707 consequence of RM 13.1(14) (``if two subtypes statically match,
8708 then their subtype-specific aspects are the same''.)
8709
8710 @item
8711 All other subtypes have a @code{Value_Size} corresponding to the minimum
8712 number of bits required to store all values of the subtype.  For
8713 dynamic bounds, it is assumed that the value can range down or up
8714 to the corresponding bound of the ancestor
8715 @end itemize
8716
8717 @noindent
8718 The RM defined attribute @code{Size} corresponds to the
8719 @code{Value_Size} attribute.
8720
8721 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8722 the @code{Value_Size} of
8723 the first-named subtype to the given value, and the
8724 @code{Object_Size} of this first-named subtype to the given value padded up
8725 to an appropriate boundary.  It is a consequence of the default rules
8726 above that this @code{Object_Size} will apply to all further subtypes.  On the
8727 other hand, @code{Value_Size} is affected only for the first subtype, any
8728 dynamic subtypes obtained from it directly, and any statically matching
8729 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8730
8731 @code{Value_Size} and
8732 @code{Object_Size} may be explicitly set for any subtype using
8733 an attribute definition clause.  Note that the use of these attributes
8734 can cause the RM 13.1(14) rule to be violated.  If two access types
8735 reference aliased objects whose subtypes have differing @code{Object_Size}
8736 values as a result of explicit attribute definition clauses, then it
8737 is erroneous to convert from one access subtype to the other.
8738
8739 At the implementation level, Esize stores the Object_Size and the
8740 RM_Size field stores the @code{Value_Size} (and hence the value of the
8741 @code{Size} attribute,
8742 which, as noted above, is equivalent to @code{Value_Size}).
8743
8744 To get a feel for the difference, consider the following examples (note
8745 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8746
8747 @smallexample
8748                                        Object_Size     Value_Size
8749
8750 type x1 is range 0 .. 5;                    8               3
8751
8752 type x2 is range 0 .. 5;
8753 for x2'size use 12;                        16              12
8754
8755 subtype x3 is x2 range 0 .. 3;             16               2
8756
8757 subtype x4 is x2'base range 0 .. 10;        8               4
8758
8759 subtype x5 is x2 range 0 .. dynamic;       16               3*
8760
8761 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8762
8763 @end smallexample
8764
8765 @noindent
8766 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8767 but it seems in the spirit of the RM rules to allocate the minimum number
8768 of bits (here 3, given the range for @code{x2})
8769 known to be large enough to hold the given range of values.
8770
8771 So far, so good, but GNAT has to obey the RM rules, so the question is
8772 under what conditions must the RM @code{Size} be used.
8773 The following is a list
8774 of the occasions on which the RM @code{Size} must be used:
8775
8776 @itemize @bullet
8777 @item
8778 Component size for packed arrays or records
8779
8780 @item
8781 Value of the attribute @code{Size} for a type
8782
8783 @item
8784 Warning about sizes not matching for unchecked conversion
8785 @end itemize
8786
8787 @noindent
8788 For record types, the @code{Object_Size} is always a multiple of the
8789 alignment of the type (this is true for all types). In some cases the
8790 @code{Value_Size} can be smaller. Consider:
8791
8792 @smallexample
8793    type R is record
8794      X : Integer;
8795      Y : Character;
8796    end record;
8797 @end smallexample
8798
8799 @noindent
8800 On a typical 32-bit architecture, the X component will be four bytes, and
8801 require four-byte alignment, and the Y component will be one byte. In this
8802 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8803 required to store a value of this type, and for example, it is permissible
8804 to have a component of type R in an outer record whose component size is
8805 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8806 since it must be rounded up so that this value is a multiple of the
8807 alignment (4 bytes = 32 bits).
8808
8809 @noindent
8810 For all other types, the @code{Object_Size}
8811 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8812 Only @code{Size} may be specified for such types.
8813
8814 @node Component_Size Clauses
8815 @section Component_Size Clauses
8816 @cindex Component_Size Clause
8817
8818 @noindent
8819 Normally, the value specified in a component clause must be consistent
8820 with the subtype of the array component with regard to size and alignment.
8821 In other words, the value specified must be at least equal to the size
8822 of this subtype, and must be a multiple of the alignment value.
8823
8824 In addition, component size clauses are allowed which cause the array
8825 to be packed, by specifying a smaller value.  The cases in which this
8826 is allowed are for component size values in the range 1 through 63.  The value
8827 specified must not be smaller than the Size of the subtype.  GNAT will
8828 accurately honor all packing requests in this range.  For example, if
8829 we have:
8830
8831 @smallexample @c ada
8832 type r is array (1 .. 8) of Natural;
8833 for r'Component_Size use 31;
8834 @end smallexample
8835
8836 @noindent
8837 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8838 Of course access to the components of such an array is considerably
8839 less efficient than if the natural component size of 32 is used.
8840
8841 @node Bit_Order Clauses
8842 @section Bit_Order Clauses
8843 @cindex Bit_Order Clause
8844 @cindex bit ordering
8845 @cindex ordering, of bits
8846
8847 @noindent
8848 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8849 attribute.  The specification may either correspond to the default bit
8850 order for the target, in which case the specification has no effect and
8851 places no additional restrictions, or it may be for the non-standard
8852 setting (that is the opposite of the default).
8853
8854 In the case where the non-standard value is specified, the effect is
8855 to renumber bits within each byte, but the ordering of bytes is not
8856 affected.  There are certain
8857 restrictions placed on component clauses as follows:
8858
8859 @itemize @bullet
8860
8861 @item Components fitting within a single storage unit.
8862 @noindent
8863 These are unrestricted, and the effect is merely to renumber bits.  For
8864 example if we are on a little-endian machine with @code{Low_Order_First}
8865 being the default, then the following two declarations have exactly
8866 the same effect:
8867
8868 @smallexample @c ada
8869    type R1 is record
8870       A : Boolean;
8871       B : Integer range 1 .. 120;
8872    end record;
8873
8874    for R1 use record
8875       A at 0 range 0 .. 0;
8876       B at 0 range 1 .. 7;
8877    end record;
8878
8879    type R2 is record
8880       A : Boolean;
8881       B : Integer range 1 .. 120;
8882    end record;
8883
8884    for R2'Bit_Order use High_Order_First;
8885
8886    for R2 use record
8887       A at 0 range 7 .. 7;
8888       B at 0 range 0 .. 6;
8889    end record;
8890 @end smallexample
8891
8892 @noindent
8893 The useful application here is to write the second declaration with the
8894 @code{Bit_Order} attribute definition clause, and know that it will be treated
8895 the same, regardless of whether the target is little-endian or big-endian.
8896
8897 @item Components occupying an integral number of bytes.
8898 @noindent
8899 These are components that exactly fit in two or more bytes.  Such component
8900 declarations are allowed, but have no effect, since it is important to realize
8901 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8902 In particular, the following attempt at getting an endian-independent integer
8903 does not work:
8904
8905 @smallexample @c ada
8906    type R2 is record
8907       A : Integer;
8908    end record;
8909
8910    for R2'Bit_Order use High_Order_First;
8911
8912    for R2 use record
8913       A at 0 range 0 .. 31;
8914    end record;
8915 @end smallexample
8916
8917 @noindent
8918 This declaration will result in a little-endian integer on a
8919 little-endian machine, and a big-endian integer on a big-endian machine.
8920 If byte flipping is required for interoperability between big- and
8921 little-endian machines, this must be explicitly programmed.  This capability
8922 is not provided by @code{Bit_Order}.
8923
8924 @item Components that are positioned across byte boundaries
8925 @noindent
8926 but do not occupy an integral number of bytes.  Given that bytes are not
8927 reordered, such fields would occupy a non-contiguous sequence of bits
8928 in memory, requiring non-trivial code to reassemble.  They are for this
8929 reason not permitted, and any component clause specifying such a layout
8930 will be flagged as illegal by GNAT@.
8931
8932 @end itemize
8933
8934 @noindent
8935 Since the misconception that Bit_Order automatically deals with all
8936 endian-related incompatibilities is a common one, the specification of
8937 a component field that is an integral number of bytes will always
8938 generate a warning.  This warning may be suppressed using
8939 @code{pragma Suppress} if desired.  The following section contains additional
8940 details regarding the issue of byte ordering.
8941
8942 @node Effect of Bit_Order on Byte Ordering
8943 @section Effect of Bit_Order on Byte Ordering
8944 @cindex byte ordering
8945 @cindex ordering, of bytes
8946
8947 @noindent
8948 In this section we will review the effect of the @code{Bit_Order} attribute
8949 definition clause on byte ordering.  Briefly, it has no effect at all, but
8950 a detailed example will be helpful.  Before giving this
8951 example, let us review the precise
8952 definition of the effect of defining @code{Bit_Order}.  The effect of a
8953 non-standard bit order is described in section 15.5.3 of the Ada
8954 Reference Manual:
8955
8956 @quotation
8957 2   A bit ordering is a method of interpreting the meaning of
8958 the storage place attributes.
8959 @end quotation
8960
8961 @noindent
8962 To understand the precise definition of storage place attributes in
8963 this context, we visit section 13.5.1 of the manual:
8964
8965 @quotation
8966 13   A record_representation_clause (without the mod_clause)
8967 specifies the layout.  The storage place attributes (see 13.5.2)
8968 are taken from the values of the position, first_bit, and last_bit
8969 expressions after normalizing those values so that first_bit is
8970 less than Storage_Unit.
8971 @end quotation
8972
8973 @noindent
8974 The critical point here is that storage places are taken from
8975 the values after normalization, not before.  So the @code{Bit_Order}
8976 interpretation applies to normalized values.  The interpretation
8977 is described in the later part of the 15.5.3 paragraph:
8978
8979 @quotation
8980 2   A bit ordering is a method of interpreting the meaning of
8981 the storage place attributes.  High_Order_First (known in the
8982 vernacular as ``big endian'') means that the first bit of a
8983 storage element (bit 0) is the most significant bit (interpreting
8984 the sequence of bits that represent a component as an unsigned
8985 integer value).  Low_Order_First (known in the vernacular as
8986 ``little endian'') means the opposite: the first bit is the
8987 least significant.
8988 @end quotation
8989
8990 @noindent
8991 Note that the numbering is with respect to the bits of a storage
8992 unit.  In other words, the specification affects only the numbering
8993 of bits within a single storage unit.
8994
8995 We can make the effect clearer by giving an example.
8996
8997 Suppose that we have an external device which presents two bytes, the first
8998 byte presented, which is the first (low addressed byte) of the two byte
8999 record is called Master, and the second byte is called Slave.
9000
9001 The left most (most significant bit is called Control for each byte, and
9002 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9003 (least significant) bit.
9004
9005 On a big-endian machine, we can write the following representation clause
9006
9007 @smallexample @c ada
9008    type Data is record
9009       Master_Control : Bit;
9010       Master_V1      : Bit;
9011       Master_V2      : Bit;
9012       Master_V3      : Bit;
9013       Master_V4      : Bit;
9014       Master_V5      : Bit;
9015       Master_V6      : Bit;
9016       Master_V7      : Bit;
9017       Slave_Control  : Bit;
9018       Slave_V1       : Bit;
9019       Slave_V2       : Bit;
9020       Slave_V3       : Bit;
9021       Slave_V4       : Bit;
9022       Slave_V5       : Bit;
9023       Slave_V6       : Bit;
9024       Slave_V7       : Bit;
9025    end record;
9026
9027    for Data use record
9028       Master_Control at 0 range 0 .. 0;
9029       Master_V1      at 0 range 1 .. 1;
9030       Master_V2      at 0 range 2 .. 2;
9031       Master_V3      at 0 range 3 .. 3;
9032       Master_V4      at 0 range 4 .. 4;
9033       Master_V5      at 0 range 5 .. 5;
9034       Master_V6      at 0 range 6 .. 6;
9035       Master_V7      at 0 range 7 .. 7;
9036       Slave_Control  at 1 range 0 .. 0;
9037       Slave_V1       at 1 range 1 .. 1;
9038       Slave_V2       at 1 range 2 .. 2;
9039       Slave_V3       at 1 range 3 .. 3;
9040       Slave_V4       at 1 range 4 .. 4;
9041       Slave_V5       at 1 range 5 .. 5;
9042       Slave_V6       at 1 range 6 .. 6;
9043       Slave_V7       at 1 range 7 .. 7;
9044    end record;
9045 @end smallexample
9046
9047 @noindent
9048 Now if we move this to a little endian machine, then the bit ordering within
9049 the byte is backwards, so we have to rewrite the record rep clause as:
9050
9051 @smallexample @c ada
9052    for Data use record
9053       Master_Control at 0 range 7 .. 7;
9054       Master_V1      at 0 range 6 .. 6;
9055       Master_V2      at 0 range 5 .. 5;
9056       Master_V3      at 0 range 4 .. 4;
9057       Master_V4      at 0 range 3 .. 3;
9058       Master_V5      at 0 range 2 .. 2;
9059       Master_V6      at 0 range 1 .. 1;
9060       Master_V7      at 0 range 0 .. 0;
9061       Slave_Control  at 1 range 7 .. 7;
9062       Slave_V1       at 1 range 6 .. 6;
9063       Slave_V2       at 1 range 5 .. 5;
9064       Slave_V3       at 1 range 4 .. 4;
9065       Slave_V4       at 1 range 3 .. 3;
9066       Slave_V5       at 1 range 2 .. 2;
9067       Slave_V6       at 1 range 1 .. 1;
9068       Slave_V7       at 1 range 0 .. 0;
9069    end record;
9070 @end smallexample
9071
9072 @noindent
9073 It is a nuisance to have to rewrite the clause, especially if
9074 the code has to be maintained on both machines.  However,
9075 this is a case that we can handle with the
9076 @code{Bit_Order} attribute if it is implemented.
9077 Note that the implementation is not required on byte addressed
9078 machines, but it is indeed implemented in GNAT.
9079 This means that we can simply use the
9080 first record clause, together with the declaration
9081
9082 @smallexample @c ada
9083    for Data'Bit_Order use High_Order_First;
9084 @end smallexample
9085
9086 @noindent
9087 and the effect is what is desired, namely the layout is exactly the same,
9088 independent of whether the code is compiled on a big-endian or little-endian
9089 machine.
9090
9091 The important point to understand is that byte ordering is not affected.
9092 A @code{Bit_Order} attribute definition never affects which byte a field
9093 ends up in, only where it ends up in that byte.
9094 To make this clear, let us rewrite the record rep clause of the previous
9095 example as:
9096
9097 @smallexample @c ada
9098    for Data'Bit_Order use High_Order_First;
9099    for Data use record
9100       Master_Control at 0 range  0 .. 0;
9101       Master_V1      at 0 range  1 .. 1;
9102       Master_V2      at 0 range  2 .. 2;
9103       Master_V3      at 0 range  3 .. 3;
9104       Master_V4      at 0 range  4 .. 4;
9105       Master_V5      at 0 range  5 .. 5;
9106       Master_V6      at 0 range  6 .. 6;
9107       Master_V7      at 0 range  7 .. 7;
9108       Slave_Control  at 0 range  8 .. 8;
9109       Slave_V1       at 0 range  9 .. 9;
9110       Slave_V2       at 0 range 10 .. 10;
9111       Slave_V3       at 0 range 11 .. 11;
9112       Slave_V4       at 0 range 12 .. 12;
9113       Slave_V5       at 0 range 13 .. 13;
9114       Slave_V6       at 0 range 14 .. 14;
9115       Slave_V7       at 0 range 15 .. 15;
9116    end record;
9117 @end smallexample
9118
9119 @noindent
9120 This is exactly equivalent to saying (a repeat of the first example):
9121
9122 @smallexample @c ada
9123    for Data'Bit_Order use High_Order_First;
9124    for Data use record
9125       Master_Control at 0 range 0 .. 0;
9126       Master_V1      at 0 range 1 .. 1;
9127       Master_V2      at 0 range 2 .. 2;
9128       Master_V3      at 0 range 3 .. 3;
9129       Master_V4      at 0 range 4 .. 4;
9130       Master_V5      at 0 range 5 .. 5;
9131       Master_V6      at 0 range 6 .. 6;
9132       Master_V7      at 0 range 7 .. 7;
9133       Slave_Control  at 1 range 0 .. 0;
9134       Slave_V1       at 1 range 1 .. 1;
9135       Slave_V2       at 1 range 2 .. 2;
9136       Slave_V3       at 1 range 3 .. 3;
9137       Slave_V4       at 1 range 4 .. 4;
9138       Slave_V5       at 1 range 5 .. 5;
9139       Slave_V6       at 1 range 6 .. 6;
9140       Slave_V7       at 1 range 7 .. 7;
9141    end record;
9142 @end smallexample
9143
9144 @noindent
9145 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9146 field.  The storage place attributes are obtained by normalizing the
9147 values given so that the @code{First_Bit} value is less than 8.  After
9148 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9149 we specified in the other case.
9150
9151 Now one might expect that the @code{Bit_Order} attribute might affect
9152 bit numbering within the entire record component (two bytes in this
9153 case, thus affecting which byte fields end up in), but that is not
9154 the way this feature is defined, it only affects numbering of bits,
9155 not which byte they end up in.
9156
9157 Consequently it never makes sense to specify a starting bit number
9158 greater than 7 (for a byte addressable field) if an attribute
9159 definition for @code{Bit_Order} has been given, and indeed it
9160 may be actively confusing to specify such a value, so the compiler
9161 generates a warning for such usage.
9162
9163 If you do need to control byte ordering then appropriate conditional
9164 values must be used.  If in our example, the slave byte came first on
9165 some machines we might write:
9166
9167 @smallexample @c ada
9168    Master_Byte_First constant Boolean := @dots{};
9169
9170    Master_Byte : constant Natural :=
9171                    1 - Boolean'Pos (Master_Byte_First);
9172    Slave_Byte  : constant Natural :=
9173                    Boolean'Pos (Master_Byte_First);
9174
9175    for Data'Bit_Order use High_Order_First;
9176    for Data use record
9177       Master_Control at Master_Byte range 0 .. 0;
9178       Master_V1      at Master_Byte range 1 .. 1;
9179       Master_V2      at Master_Byte range 2 .. 2;
9180       Master_V3      at Master_Byte range 3 .. 3;
9181       Master_V4      at Master_Byte range 4 .. 4;
9182       Master_V5      at Master_Byte range 5 .. 5;
9183       Master_V6      at Master_Byte range 6 .. 6;
9184       Master_V7      at Master_Byte range 7 .. 7;
9185       Slave_Control  at Slave_Byte  range 0 .. 0;
9186       Slave_V1       at Slave_Byte  range 1 .. 1;
9187       Slave_V2       at Slave_Byte  range 2 .. 2;
9188       Slave_V3       at Slave_Byte  range 3 .. 3;
9189       Slave_V4       at Slave_Byte  range 4 .. 4;
9190       Slave_V5       at Slave_Byte  range 5 .. 5;
9191       Slave_V6       at Slave_Byte  range 6 .. 6;
9192       Slave_V7       at Slave_Byte  range 7 .. 7;
9193    end record;
9194 @end smallexample
9195
9196 @noindent
9197 Now to switch between machines, all that is necessary is
9198 to set the boolean constant @code{Master_Byte_First} in
9199 an appropriate manner.
9200
9201 @node Pragma Pack for Arrays
9202 @section Pragma Pack for Arrays
9203 @cindex Pragma Pack (for arrays)
9204
9205 @noindent
9206 Pragma @code{Pack} applied to an array has no effect unless the component type
9207 is packable.  For a component type to be packable, it must be one of the
9208 following cases:
9209
9210 @itemize @bullet
9211 @item
9212 Any scalar type
9213 @item
9214 Any type whose size is specified with a size clause
9215 @item
9216 Any packed array type with a static size
9217 @end itemize
9218
9219 @noindent
9220 For all these cases, if the component subtype size is in the range
9221 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9222 component size were specified giving the component subtype size.
9223 For example if we have:
9224
9225 @smallexample @c ada
9226    type r is range 0 .. 17;
9227
9228    type ar is array (1 .. 8) of r;
9229    pragma Pack (ar);
9230 @end smallexample
9231
9232 @noindent
9233 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9234 and the size of the array @code{ar} will be exactly 40 bits.
9235
9236 Note that in some cases this rather fierce approach to packing can produce
9237 unexpected effects.  For example, in Ada 95, type Natural typically has a
9238 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9239 close packing, which saves a few bits, but results in far less efficient
9240 access.  Since many other Ada compilers will ignore such a packing request,
9241 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9242 might not be what is intended.  You can easily remove this warning by
9243 using an explicit @code{Component_Size} setting instead, which never generates
9244 a warning, since the intention of the programmer is clear in this case.
9245
9246 GNAT treats packed arrays in one of two ways.  If the size of the array is
9247 known at compile time and is less than 64 bits, then internally the array
9248 is represented as a single modular type, of exactly the appropriate number
9249 of bits.  If the length is greater than 63 bits, or is not known at compile
9250 time, then the packed array is represented as an array of bytes, and the
9251 length is always a multiple of 8 bits.
9252
9253 Note that to represent a packed array as a modular type, the alignment must
9254 be suitable for the modular type involved. For example, on typical machines
9255 a 32-bit packed array will be represented by a 32-bit modular integer with
9256 an alignment of four bytes. If you explicitly override the default alignment
9257 with an alignment clause that is too small, the modular representation
9258 cannot be used. For example, consider the following set of declarations:
9259
9260 @smallexample @c ada
9261    type R is range 1 .. 3;
9262    type S is array (1 .. 31) of R;
9263    for S'Component_Size use 2;
9264    for S'Size use 62;
9265    for S'Alignment use 1;
9266 @end smallexample
9267
9268 @noindent
9269 If the alignment clause were not present, then a 62-bit modular
9270 representation would be chosen (typically with an alignment of 4 or 8
9271 bytes depending on the target). But the default alignment is overridden
9272 with the explicit alignment clause. This means that the modular
9273 representation cannot be used, and instead the array of bytes
9274 representation must be used, meaning that the length must be a multiple
9275 of 8. Thus the above set of declarations will result in a diagnostic
9276 rejecting the size clause and noting that the minimum size allowed is 64.
9277
9278 @cindex Pragma Pack (for type Natural)
9279 @cindex Pragma Pack warning
9280
9281 One special case that is worth noting occurs when the base type of the
9282 component size is 8/16/32 and the subtype is one bit less. Notably this
9283 occurs with subtype @code{Natural}. Consider:
9284
9285 @smallexample @c ada
9286    type Arr is array (1 .. 32) of Natural;
9287    pragma Pack (Arr);
9288 @end smallexample
9289
9290 @noindent
9291 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9292 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9293 Ada 83 compilers did not attempt 31 bit packing.
9294
9295 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9296 does pack 31-bit subtype to 31 bits. This may result in a substantial
9297 unintended performance penalty when porting legacy Ada 83 code. To help
9298 prevent this, GNAT generates a warning in such cases. If you really want 31
9299 bit packing in a case like this, you can set the component size explicitly:
9300
9301 @smallexample @c ada
9302    type Arr is array (1 .. 32) of Natural;
9303    for Arr'Component_Size use 31;
9304 @end smallexample
9305
9306 @noindent
9307 Here 31-bit packing is achieved as required, and no warning is generated,
9308 since in this case the programmer intention is clear.
9309
9310 @node Pragma Pack for Records
9311 @section Pragma Pack for Records
9312 @cindex Pragma Pack (for records)
9313
9314 @noindent
9315 Pragma @code{Pack} applied to a record will pack the components to reduce
9316 wasted space from alignment gaps and by reducing the amount of space
9317 taken by components.  We distinguish between @emph{packable} components and
9318 @emph{non-packable} components.
9319 Components of the following types are considered packable:
9320 @itemize @bullet
9321 @item
9322 All primitive types are packable.
9323
9324 @item
9325 Small packed arrays, whose size does not exceed 64 bits, and where the
9326 size is statically known at compile time, are represented internally
9327 as modular integers, and so they are also packable.
9328
9329 @end itemize
9330
9331 @noindent
9332 All packable components occupy the exact number of bits corresponding to
9333 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9334 can start on an arbitrary bit boundary.
9335
9336 All other types are non-packable, they occupy an integral number of
9337 storage units, and
9338 are placed at a boundary corresponding to their alignment requirements.
9339
9340 For example, consider the record
9341
9342 @smallexample @c ada
9343    type Rb1 is array (1 .. 13) of Boolean;
9344    pragma Pack (rb1);
9345
9346    type Rb2 is array (1 .. 65) of Boolean;
9347    pragma Pack (rb2);
9348
9349    type x2 is record
9350       l1 : Boolean;
9351       l2 : Duration;
9352       l3 : Float;
9353       l4 : Boolean;
9354       l5 : Rb1;
9355       l6 : Rb2;
9356    end record;
9357    pragma Pack (x2);
9358 @end smallexample
9359
9360 @noindent
9361 The representation for the record x2 is as follows:
9362
9363 @smallexample @c ada
9364 for x2'Size use 224;
9365 for x2 use record
9366    l1 at  0 range  0 .. 0;
9367    l2 at  0 range  1 .. 64;
9368    l3 at 12 range  0 .. 31;
9369    l4 at 16 range  0 .. 0;
9370    l5 at 16 range  1 .. 13;
9371    l6 at 18 range  0 .. 71;
9372 end record;
9373 @end smallexample
9374
9375 @noindent
9376 Studying this example, we see that the packable fields @code{l1}
9377 and @code{l2} are
9378 of length equal to their sizes, and placed at specific bit boundaries (and
9379 not byte boundaries) to
9380 eliminate padding.  But @code{l3} is of a non-packable float type, so
9381 it is on the next appropriate alignment boundary.
9382
9383 The next two fields are fully packable, so @code{l4} and @code{l5} are
9384 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9385 array that is longer than 64 bits, so it is itself non-packable.  Thus
9386 the @code{l6} field is aligned to the next byte boundary, and takes an
9387 integral number of bytes, i.e.@: 72 bits.
9388
9389 @node Record Representation Clauses
9390 @section Record Representation Clauses
9391 @cindex Record Representation Clause
9392
9393 @noindent
9394 Record representation clauses may be given for all record types, including
9395 types obtained by record extension.  Component clauses are allowed for any
9396 static component.  The restrictions on component clauses depend on the type
9397 of the component.
9398
9399 @cindex Component Clause
9400 For all components of an elementary type, the only restriction on component
9401 clauses is that the size must be at least the 'Size value of the type
9402 (actually the Value_Size).  There are no restrictions due to alignment,
9403 and such components may freely cross storage boundaries.
9404
9405 Packed arrays with a size up to and including 64 bits are represented
9406 internally using a modular type with the appropriate number of bits, and
9407 thus the same lack of restriction applies.  For example, if you declare:
9408
9409 @smallexample @c ada
9410    type R is array (1 .. 49) of Boolean;
9411    pragma Pack (R);
9412    for R'Size use 49;
9413 @end smallexample
9414
9415 @noindent
9416 then a component clause for a component of type R may start on any
9417 specified bit boundary, and may specify a value of 49 bits or greater.
9418
9419 The rules for other types are different for GNAT 3 and GNAT 5 versions
9420 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9421 may also be placed on arbitrary boundaries, so for example, the following
9422 is permitted:
9423
9424 @smallexample @c ada
9425    type R is array (1 .. 79) of Boolean;
9426    pragma Pack (R);
9427    for R'Size use 79;
9428
9429    type Q is record
9430       G, H : Boolean;
9431       L, M : R;
9432    end record;
9433
9434    for Q use record
9435       G at 0 range  0 ..   0;
9436       H at 0 range  1 ..   1;
9437       L at 0 range  2 ..  80;
9438       R at 0 range 81 .. 159;
9439    end record;
9440 @end smallexample
9441
9442 @noindent
9443 In GNAT 3, there are more severe restrictions on larger components.
9444 For non-primitive types, including packed arrays with a size greater than
9445 64 bits, component clauses must respect the alignment requirement of the
9446 type, in particular, always starting on a byte boundary, and the length
9447 must be a multiple of the storage unit.
9448
9449 The following rules regarding tagged types are enforced in both GNAT 3 and
9450 GNAT 5:
9451
9452 The tag field of a tagged type always occupies an address sized field at
9453 the start of the record.  No component clause may attempt to overlay this
9454 tag.
9455
9456 In the case of a record extension T1, of a type T, no component clause applied
9457 to the type T1 can specify a storage location that would overlap the first
9458 T'Size bytes of the record.
9459
9460 @node Enumeration Clauses
9461 @section Enumeration Clauses
9462
9463 The only restriction on enumeration clauses is that the range of values
9464 must be representable.  For the signed case, if one or more of the
9465 representation values are negative, all values must be in the range:
9466
9467 @smallexample @c ada
9468    System.Min_Int .. System.Max_Int
9469 @end smallexample
9470
9471 @noindent
9472 For the unsigned case, where all values are non negative, the values must
9473 be in the range:
9474
9475 @smallexample @c ada
9476    0 .. System.Max_Binary_Modulus;
9477 @end smallexample
9478
9479 @noindent
9480 A @emph{confirming} representation clause is one in which the values range
9481 from 0 in sequence, i.e.@: a clause that confirms the default representation
9482 for an enumeration type.
9483 Such a confirming representation
9484 is permitted by these rules, and is specially recognized by the compiler so
9485 that no extra overhead results from the use of such a clause.
9486
9487 If an array has an index type which is an enumeration type to which an
9488 enumeration clause has been applied, then the array is stored in a compact
9489 manner.  Consider the declarations:
9490
9491 @smallexample @c ada
9492    type r is (A, B, C);
9493    for r use (A => 1, B => 5, C => 10);
9494    type t is array (r) of Character;
9495 @end smallexample
9496
9497 @noindent
9498 The array type t corresponds to a vector with exactly three elements and
9499 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9500 use of space, but means that accesses to elements of the array will incur
9501 the overhead of converting representation values to the corresponding
9502 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9503
9504 @node Address Clauses
9505 @section Address Clauses
9506 @cindex Address Clause
9507
9508 The reference manual allows a general restriction on representation clauses,
9509 as found in RM 13.1(22):
9510
9511 @quotation
9512 An implementation need not support representation
9513 items containing nonstatic expressions, except that
9514 an implementation should support a representation item
9515 for a given entity if each nonstatic expression in the
9516 representation item is a name that statically denotes
9517 a constant declared before the entity.
9518 @end quotation
9519
9520 @noindent
9521 In practice this is applicable only to address clauses, since this is the
9522 only case in which a non-static expression is permitted by the syntax.  As
9523 the AARM notes in sections 13.1 (22.a-22.h):
9524
9525 @display
9526   22.a   Reason: This is to avoid the following sort of thing:
9527
9528   22.b        X : Integer := F(@dots{});
9529               Y : Address := G(@dots{});
9530               for X'Address use Y;
9531
9532   22.c   In the above, we have to evaluate the
9533          initialization expression for X before we
9534          know where to put the result.  This seems
9535          like an unreasonable implementation burden.
9536
9537   22.d   The above code should instead be written
9538          like this:
9539
9540   22.e        Y : constant Address := G(@dots{});
9541               X : Integer := F(@dots{});
9542               for X'Address use Y;
9543
9544   22.f   This allows the expression ``Y'' to be safely
9545          evaluated before X is created.
9546
9547   22.g   The constant could be a formal parameter of mode in.
9548
9549   22.h   An implementation can support other nonstatic
9550          expressions if it wants to.  Expressions of type
9551          Address are hardly ever static, but their value
9552          might be known at compile time anyway in many
9553          cases.
9554 @end display
9555
9556 @noindent
9557 GNAT does indeed permit many additional cases of non-static expressions.  In
9558 particular, if the type involved is elementary there are no restrictions
9559 (since in this case, holding a temporary copy of the initialization value,
9560 if one is present, is inexpensive).  In addition, if there is no implicit or
9561 explicit initialization, then there are no restrictions.  GNAT will reject
9562 only the case where all three of these conditions hold:
9563
9564 @itemize @bullet
9565
9566 @item
9567 The type of the item is non-elementary (e.g.@: a record or array).
9568
9569 @item
9570 There is explicit or implicit initialization required for the object.
9571 Note that access values are always implicitly initialized, and also
9572 in GNAT, certain bit-packed arrays (those having a dynamic length or
9573 a length greater than 64) will also be implicitly initialized to zero.
9574
9575 @item
9576 The address value is non-static.  Here GNAT is more permissive than the
9577 RM, and allows the address value to be the address of a previously declared
9578 stand-alone variable, as long as it does not itself have an address clause.
9579
9580 @smallexample @c ada
9581            Anchor  : Some_Initialized_Type;
9582            Overlay : Some_Initialized_Type;
9583            for Overlay'Address use Anchor'Address;
9584 @end smallexample
9585
9586 @noindent
9587 However, the prefix of the address clause cannot be an array component, or
9588 a component of a discriminated record.
9589
9590 @end itemize
9591
9592 @noindent
9593 As noted above in section 22.h, address values are typically non-static.  In
9594 particular the To_Address function, even if applied to a literal value, is
9595 a non-static function call.  To avoid this minor annoyance, GNAT provides
9596 the implementation defined attribute 'To_Address.  The following two
9597 expressions have identical values:
9598
9599 @findex Attribute
9600 @findex To_Address
9601 @smallexample @c ada
9602    To_Address (16#1234_0000#)
9603    System'To_Address (16#1234_0000#);
9604 @end smallexample
9605
9606 @noindent
9607 except that the second form is considered to be a static expression, and
9608 thus when used as an address clause value is always permitted.
9609
9610 @noindent
9611 Additionally, GNAT treats as static an address clause that is an
9612 unchecked_conversion of a static integer value.  This simplifies the porting
9613 of legacy code, and provides a portable equivalent to the GNAT attribute
9614 @code{To_Address}.
9615
9616 Another issue with address clauses is the interaction with alignment
9617 requirements.  When an address clause is given for an object, the address
9618 value must be consistent with the alignment of the object (which is usually
9619 the same as the alignment of the type of the object).  If an address clause
9620 is given that specifies an inappropriately aligned address value, then the
9621 program execution is erroneous.
9622
9623 Since this source of erroneous behavior can have unfortunate effects, GNAT
9624 checks (at compile time if possible, generating a warning, or at execution
9625 time with a run-time check) that the alignment is appropriate.  If the
9626 run-time check fails, then @code{Program_Error} is raised.  This run-time
9627 check is suppressed if range checks are suppressed, or if
9628 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9629
9630 @findex Export
9631 An address clause cannot be given for an exported object.  More
9632 understandably the real restriction is that objects with an address
9633 clause cannot be exported.  This is because such variables are not
9634 defined by the Ada program, so there is no external object to export.
9635
9636 @findex Import
9637 It is permissible to give an address clause and a pragma Import for the
9638 same object.  In this case, the variable is not really defined by the
9639 Ada program, so there is no external symbol to be linked.  The link name
9640 and the external name are ignored in this case.  The reason that we allow this
9641 combination is that it provides a useful idiom to avoid unwanted
9642 initializations on objects with address clauses.
9643
9644 When an address clause is given for an object that has implicit or
9645 explicit initialization, then by default initialization takes place.  This
9646 means that the effect of the object declaration is to overwrite the
9647 memory at the specified address.  This is almost always not what the
9648 programmer wants, so GNAT will output a warning:
9649
9650 @smallexample
9651   with System;
9652   package G is
9653      type R is record
9654         M : Integer := 0;
9655      end record;
9656
9657      Ext : R;
9658      for Ext'Address use System'To_Address (16#1234_1234#);
9659          |
9660   >>> warning: implicit initialization of "Ext" may
9661       modify overlaid storage
9662   >>> warning: use pragma Import for "Ext" to suppress
9663       initialization (RM B(24))
9664
9665   end G;
9666 @end smallexample
9667
9668 @noindent
9669 As indicated by the warning message, the solution is to use a (dummy) pragma
9670 Import to suppress this initialization.  The pragma tell the compiler that the
9671 object is declared and initialized elsewhere.  The following package compiles
9672 without warnings (and the initialization is suppressed):
9673
9674 @smallexample @c ada
9675    with System;
9676    package G is
9677       type R is record
9678          M : Integer := 0;
9679       end record;
9680
9681       Ext : R;
9682       for Ext'Address use System'To_Address (16#1234_1234#);
9683       pragma Import (Ada, Ext);
9684    end G;
9685 @end smallexample
9686
9687 @noindent
9688 A final issue with address clauses involves their use for overlaying
9689 variables, as in the following example:
9690 @cindex Overlaying of objects
9691
9692 @smallexample @c ada
9693   A : Integer;
9694   B : Integer;
9695   for B'Address use A'Address;
9696 @end smallexample
9697
9698 @noindent
9699 or alternatively, using the form recommended by the RM:
9700
9701 @smallexample @c ada
9702   A    : Integer;
9703   Addr : constant Address := A'Address;
9704   B    : Integer;
9705   for B'Address use Addr;
9706 @end smallexample
9707
9708 @noindent
9709 In both of these cases, @code{A}
9710 and @code{B} become aliased to one another via the
9711 address clause. This use of address clauses to overlay
9712 variables, achieving an effect similar to unchecked
9713 conversion was erroneous in Ada 83, but in Ada 95
9714 the effect is implementation defined. Furthermore, the
9715 Ada 95 RM specifically recommends that in a situation
9716 like this, @code{B} should be subject to the following
9717 implementation advice (RM 13.3(19)):
9718
9719 @quotation
9720 19  If the Address of an object is specified, or it is imported
9721     or exported, then the implementation should not perform
9722     optimizations based on assumptions of no aliases.
9723 @end quotation
9724
9725 @noindent
9726 GNAT follows this recommendation, and goes further by also applying
9727 this recommendation to the overlaid variable (@code{A}
9728 in the above example) in this case. This means that the overlay
9729 works "as expected", in that a modification to one of the variables
9730 will affect the value of the other.
9731
9732 @node Effect of Convention on Representation
9733 @section Effect of Convention on Representation
9734 @cindex Convention, effect on representation
9735
9736 @noindent
9737 Normally the specification of a foreign language convention for a type or
9738 an object has no effect on the chosen representation.  In particular, the
9739 representation chosen for data in GNAT generally meets the standard system
9740 conventions, and for example records are laid out in a manner that is
9741 consistent with C@.  This means that specifying convention C (for example)
9742 has no effect.
9743
9744 There are three exceptions to this general rule:
9745
9746 @itemize @bullet
9747
9748 @item Convention Fortran and array subtypes
9749 If pragma Convention Fortran is specified for an array subtype, then in
9750 accordance with the implementation advice in section 3.6.2(11) of the
9751 Ada Reference Manual, the array will be stored in a Fortran-compatible
9752 column-major manner, instead of the normal default row-major order.
9753
9754 @item Convention C and enumeration types
9755 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9756 to accommodate all values of the type.  For example, for the enumeration
9757 type declared by:
9758
9759 @smallexample @c ada
9760    type Color is (Red, Green, Blue);
9761 @end smallexample
9762
9763 @noindent
9764 8 bits is sufficient to store all values of the type, so by default, objects
9765 of type @code{Color} will be represented using 8 bits.  However, normal C
9766 convention is to use 32 bits for all enum values in C, since enum values
9767 are essentially of type int.  If pragma @code{Convention C} is specified for an
9768 Ada enumeration type, then the size is modified as necessary (usually to
9769 32 bits) to be consistent with the C convention for enum values.
9770
9771 @item Convention C/Fortran and Boolean types
9772 In C, the usual convention for boolean values, that is values used for
9773 conditions, is that zero represents false, and nonzero values represent
9774 true.  In Ada, the normal convention is that two specific values, typically
9775 0/1, are used to represent false/true respectively.
9776
9777 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9778 value represents true).
9779
9780 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9781 C or Fortran convention for a derived Boolean, as in the following example:
9782
9783 @smallexample @c ada
9784    type C_Switch is new Boolean;
9785    pragma Convention (C, C_Switch);
9786 @end smallexample
9787
9788 @noindent
9789 then the GNAT generated code will treat any nonzero value as true.  For truth
9790 values generated by GNAT, the conventional value 1 will be used for True, but
9791 when one of these values is read, any nonzero value is treated as True.
9792
9793 @end itemize
9794
9795 @node Determining the Representations chosen by GNAT
9796 @section Determining the Representations chosen by GNAT
9797 @cindex Representation, determination of
9798 @cindex @code{-gnatR} switch
9799
9800 @noindent
9801 Although the descriptions in this section are intended to be complete, it is
9802 often easier to simply experiment to see what GNAT accepts and what the
9803 effect is on the layout of types and objects.
9804
9805 As required by the Ada RM, if a representation clause is not accepted, then
9806 it must be rejected as illegal by the compiler.  However, when a
9807 representation clause or pragma is accepted, there can still be questions
9808 of what the compiler actually does.  For example, if a partial record
9809 representation clause specifies the location of some components and not
9810 others, then where are the non-specified components placed? Or if pragma
9811 @code{Pack} is used on a record, then exactly where are the resulting
9812 fields placed? The section on pragma @code{Pack} in this chapter can be
9813 used to answer the second question, but it is often easier to just see
9814 what the compiler does.
9815
9816 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9817 with this option, then the compiler will output information on the actual
9818 representations chosen, in a format similar to source representation
9819 clauses.  For example, if we compile the package:
9820
9821 @smallexample @c ada
9822 package q is
9823    type r (x : boolean) is tagged record
9824       case x is
9825          when True => S : String (1 .. 100);
9826          when False => null;
9827       end case;
9828    end record;
9829
9830    type r2 is new r (false) with record
9831       y2 : integer;
9832    end record;
9833
9834    for r2 use record
9835       y2 at 16 range 0 .. 31;
9836    end record;
9837
9838    type x is record
9839       y : character;
9840    end record;
9841
9842    type x1 is array (1 .. 10) of x;
9843    for x1'component_size use 11;
9844
9845    type ia is access integer;
9846
9847    type Rb1 is array (1 .. 13) of Boolean;
9848    pragma Pack (rb1);
9849
9850    type Rb2 is array (1 .. 65) of Boolean;
9851    pragma Pack (rb2);
9852
9853    type x2 is record
9854       l1 : Boolean;
9855       l2 : Duration;
9856       l3 : Float;
9857       l4 : Boolean;
9858       l5 : Rb1;
9859       l6 : Rb2;
9860    end record;
9861    pragma Pack (x2);
9862 end q;
9863 @end smallexample
9864
9865 @noindent
9866 using the switch @code{-gnatR} we obtain the following output:
9867
9868 @smallexample
9869 Representation information for unit q
9870 -------------------------------------
9871
9872 for r'Size use ??;
9873 for r'Alignment use 4;
9874 for r use record
9875    x    at 4 range  0 .. 7;
9876    _tag at 0 range  0 .. 31;
9877    s    at 5 range  0 .. 799;
9878 end record;
9879
9880 for r2'Size use 160;
9881 for r2'Alignment use 4;
9882 for r2 use record
9883    x       at  4 range  0 .. 7;
9884    _tag    at  0 range  0 .. 31;
9885    _parent at  0 range  0 .. 63;
9886    y2      at 16 range  0 .. 31;
9887 end record;
9888
9889 for x'Size use 8;
9890 for x'Alignment use 1;
9891 for x use record
9892    y at 0 range  0 .. 7;
9893 end record;
9894
9895 for x1'Size use 112;
9896 for x1'Alignment use 1;
9897 for x1'Component_Size use 11;
9898
9899 for rb1'Size use 13;
9900 for rb1'Alignment use 2;
9901 for rb1'Component_Size use 1;
9902
9903 for rb2'Size use 72;
9904 for rb2'Alignment use 1;
9905 for rb2'Component_Size use 1;
9906
9907 for x2'Size use 224;
9908 for x2'Alignment use 4;
9909 for x2 use record
9910    l1 at  0 range  0 .. 0;
9911    l2 at  0 range  1 .. 64;
9912    l3 at 12 range  0 .. 31;
9913    l4 at 16 range  0 .. 0;
9914    l5 at 16 range  1 .. 13;
9915    l6 at 18 range  0 .. 71;
9916 end record;
9917 @end smallexample
9918
9919 @noindent
9920 The Size values are actually the Object_Size, i.e.@: the default size that
9921 will be allocated for objects of the type.
9922 The ?? size for type r indicates that we have a variant record, and the
9923 actual size of objects will depend on the discriminant value.
9924
9925 The Alignment values show the actual alignment chosen by the compiler
9926 for each record or array type.
9927
9928 The record representation clause for type r shows where all fields
9929 are placed, including the compiler generated tag field (whose location
9930 cannot be controlled by the programmer).
9931
9932 The record representation clause for the type extension r2 shows all the
9933 fields present, including the parent field, which is a copy of the fields
9934 of the parent type of r2, i.e.@: r1.
9935
9936 The component size and size clauses for types rb1 and rb2 show
9937 the exact effect of pragma @code{Pack} on these arrays, and the record
9938 representation clause for type x2 shows how pragma @code{Pack} affects
9939 this record type.
9940
9941 In some cases, it may be useful to cut and paste the representation clauses
9942 generated by the compiler into the original source to fix and guarantee
9943 the actual representation to be used.
9944
9945 @node Standard Library Routines
9946 @chapter Standard Library Routines
9947
9948 @noindent
9949 The Ada 95 Reference Manual contains in Annex A a full description of an
9950 extensive set of standard library routines that can be used in any Ada
9951 program, and which must be provided by all Ada compilers.  They are
9952 analogous to the standard C library used by C programs.
9953
9954 GNAT implements all of the facilities described in annex A, and for most
9955 purposes the description in the Ada 95
9956 reference manual, or appropriate Ada
9957 text book, will be sufficient for making use of these facilities.
9958
9959 In the case of the input-output facilities, @xref{The Implementation of
9960 Standard I/O}, gives details on exactly how GNAT interfaces to the
9961 file system.  For the remaining packages, the Ada 95 reference manual
9962 should be sufficient.  The following is a list of the packages included,
9963 together with a brief description of the functionality that is provided.
9964
9965 For completeness, references are included to other predefined library
9966 routines defined in other sections of the Ada 95 reference manual (these are
9967 cross-indexed from annex A).
9968
9969 @table @code
9970 @item Ada (A.2)
9971 This is a parent package for all the standard library packages.  It is
9972 usually included implicitly in your program, and itself contains no
9973 useful data or routines.
9974
9975 @item Ada.Calendar (9.6)
9976 @code{Calendar} provides time of day access, and routines for
9977 manipulating times and durations.
9978
9979 @item Ada.Characters (A.3.1)
9980 This is a dummy parent package that contains no useful entities
9981
9982 @item Ada.Characters.Handling (A.3.2)
9983 This package provides some basic character handling capabilities,
9984 including classification functions for classes of characters (e.g.@: test
9985 for letters, or digits).
9986
9987 @item Ada.Characters.Latin_1 (A.3.3)
9988 This package includes a complete set of definitions of the characters
9989 that appear in type CHARACTER@.  It is useful for writing programs that
9990 will run in international environments.  For example, if you want an
9991 upper case E with an acute accent in a string, it is often better to use
9992 the definition of @code{UC_E_Acute} in this package.  Then your program
9993 will print in an understandable manner even if your environment does not
9994 support these extended characters.
9995
9996 @item Ada.Command_Line (A.15)
9997 This package provides access to the command line parameters and the name
9998 of the current program (analogous to the use of @code{argc} and @code{argv}
9999 in C), and also allows the exit status for the program to be set in a
10000 system-independent manner.
10001
10002 @item Ada.Decimal (F.2)
10003 This package provides constants describing the range of decimal numbers
10004 implemented, and also a decimal divide routine (analogous to the COBOL
10005 verb DIVIDE .. GIVING .. REMAINDER ..)
10006
10007 @item Ada.Direct_IO (A.8.4)
10008 This package provides input-output using a model of a set of records of
10009 fixed-length, containing an arbitrary definite Ada type, indexed by an
10010 integer record number.
10011
10012 @item Ada.Dynamic_Priorities (D.5)
10013 This package allows the priorities of a task to be adjusted dynamically
10014 as the task is running.
10015
10016 @item Ada.Exceptions (11.4.1)
10017 This package provides additional information on exceptions, and also
10018 contains facilities for treating exceptions as data objects, and raising
10019 exceptions with associated messages.
10020
10021 @item Ada.Finalization (7.6)
10022 This package contains the declarations and subprograms to support the
10023 use of controlled types, providing for automatic initialization and
10024 finalization (analogous to the constructors and destructors of C++)
10025
10026 @item Ada.Interrupts (C.3.2)
10027 This package provides facilities for interfacing to interrupts, which
10028 includes the set of signals or conditions that can be raised and
10029 recognized as interrupts.
10030
10031 @item Ada.Interrupts.Names (C.3.2)
10032 This package provides the set of interrupt names (actually signal
10033 or condition names) that can be handled by GNAT@.
10034
10035 @item Ada.IO_Exceptions (A.13)
10036 This package defines the set of exceptions that can be raised by use of
10037 the standard IO packages.
10038
10039 @item Ada.Numerics
10040 This package contains some standard constants and exceptions used
10041 throughout the numerics packages.  Note that the constants pi and e are
10042 defined here, and it is better to use these definitions than rolling
10043 your own.
10044
10045 @item Ada.Numerics.Complex_Elementary_Functions
10046 Provides the implementation of standard elementary functions (such as
10047 log and trigonometric functions) operating on complex numbers using the
10048 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10049 created by the package @code{Numerics.Complex_Types}.
10050
10051 @item Ada.Numerics.Complex_Types
10052 This is a predefined instantiation of
10053 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10054 build the type @code{Complex} and @code{Imaginary}.
10055
10056 @item Ada.Numerics.Discrete_Random
10057 This package provides a random number generator suitable for generating
10058 random integer values from a specified range.
10059
10060 @item Ada.Numerics.Float_Random
10061 This package provides a random number generator suitable for generating
10062 uniformly distributed floating point values.
10063
10064 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10065 This is a generic version of the package that provides the
10066 implementation of standard elementary functions (such as log and
10067 trigonometric functions) for an arbitrary complex type.
10068
10069 The following predefined instantiations of this package are provided:
10070
10071 @table @code
10072 @item Short_Float
10073 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10074 @item Float
10075 @code{Ada.Numerics.Complex_Elementary_Functions}
10076 @item Long_Float
10077 @code{Ada.Numerics.
10078  Long_Complex_Elementary_Functions}
10079 @end table
10080
10081 @item Ada.Numerics.Generic_Complex_Types
10082 This is a generic package that allows the creation of complex types,
10083 with associated complex arithmetic operations.
10084
10085 The following predefined instantiations of this package exist
10086 @table @code
10087 @item Short_Float
10088 @code{Ada.Numerics.Short_Complex_Complex_Types}
10089 @item Float
10090 @code{Ada.Numerics.Complex_Complex_Types}
10091 @item Long_Float
10092 @code{Ada.Numerics.Long_Complex_Complex_Types}
10093 @end table
10094
10095 @item Ada.Numerics.Generic_Elementary_Functions
10096 This is a generic package that provides the implementation of standard
10097 elementary functions (such as log an trigonometric functions) for an
10098 arbitrary float type.
10099
10100 The following predefined instantiations of this package exist
10101
10102 @table @code
10103 @item Short_Float
10104 @code{Ada.Numerics.Short_Elementary_Functions}
10105 @item Float
10106 @code{Ada.Numerics.Elementary_Functions}
10107 @item Long_Float
10108 @code{Ada.Numerics.Long_Elementary_Functions}
10109 @end table
10110
10111 @item Ada.Real_Time (D.8)
10112 This package provides facilities similar to those of @code{Calendar}, but
10113 operating with a finer clock suitable for real time control. Note that
10114 annex D requires that there be no backward clock jumps, and GNAT generally
10115 guarantees this behavior, but of course if the external clock on which
10116 the GNAT runtime depends is deliberately reset by some external event,
10117 then such a backward jump may occur.
10118
10119 @item Ada.Sequential_IO (A.8.1)
10120 This package provides input-output facilities for sequential files,
10121 which can contain a sequence of values of a single type, which can be
10122 any Ada type, including indefinite (unconstrained) types.
10123
10124 @item Ada.Storage_IO (A.9)
10125 This package provides a facility for mapping arbitrary Ada types to and
10126 from a storage buffer.  It is primarily intended for the creation of new
10127 IO packages.
10128
10129 @item Ada.Streams (13.13.1)
10130 This is a generic package that provides the basic support for the
10131 concept of streams as used by the stream attributes (@code{Input},
10132 @code{Output}, @code{Read} and @code{Write}).
10133
10134 @item Ada.Streams.Stream_IO (A.12.1)
10135 This package is a specialization of the type @code{Streams} defined in
10136 package @code{Streams} together with a set of operations providing
10137 Stream_IO capability.  The Stream_IO model permits both random and
10138 sequential access to a file which can contain an arbitrary set of values
10139 of one or more Ada types.
10140
10141 @item Ada.Strings (A.4.1)
10142 This package provides some basic constants used by the string handling
10143 packages.
10144
10145 @item Ada.Strings.Bounded (A.4.4)
10146 This package provides facilities for handling variable length
10147 strings.  The bounded model requires a maximum length.  It is thus
10148 somewhat more limited than the unbounded model, but avoids the use of
10149 dynamic allocation or finalization.
10150
10151 @item Ada.Strings.Fixed (A.4.3)
10152 This package provides facilities for handling fixed length strings.
10153
10154 @item Ada.Strings.Maps (A.4.2)
10155 This package provides facilities for handling character mappings and
10156 arbitrarily defined subsets of characters.  For instance it is useful in
10157 defining specialized translation tables.
10158
10159 @item Ada.Strings.Maps.Constants (A.4.6)
10160 This package provides a standard set of predefined mappings and
10161 predefined character sets.  For example, the standard upper to lower case
10162 conversion table is found in this package.  Note that upper to lower case
10163 conversion is non-trivial if you want to take the entire set of
10164 characters, including extended characters like E with an acute accent,
10165 into account.  You should use the mappings in this package (rather than
10166 adding 32 yourself) to do case mappings.
10167
10168 @item Ada.Strings.Unbounded (A.4.5)
10169 This package provides facilities for handling variable length
10170 strings.  The unbounded model allows arbitrary length strings, but
10171 requires the use of dynamic allocation and finalization.
10172
10173 @item Ada.Strings.Wide_Bounded (A.4.7)
10174 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10175 @itemx Ada.Strings.Wide_Maps (A.4.7)
10176 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10177 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10178 These packages provide analogous capabilities to the corresponding
10179 packages without @samp{Wide_} in the name, but operate with the types
10180 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10181 and @code{Character}.
10182
10183 @item Ada.Synchronous_Task_Control (D.10)
10184 This package provides some standard facilities for controlling task
10185 communication in a synchronous manner.
10186
10187 @item Ada.Tags
10188 This package contains definitions for manipulation of the tags of tagged
10189 values.
10190
10191 @item Ada.Task_Attributes
10192 This package provides the capability of associating arbitrary
10193 task-specific data with separate tasks.
10194
10195 @item Ada.Text_IO
10196 This package provides basic text input-output capabilities for
10197 character, string and numeric data.  The subpackages of this
10198 package are listed next.
10199
10200 @item Ada.Text_IO.Decimal_IO
10201 Provides input-output facilities for decimal fixed-point types
10202
10203 @item Ada.Text_IO.Enumeration_IO
10204 Provides input-output facilities for enumeration types.
10205
10206 @item Ada.Text_IO.Fixed_IO
10207 Provides input-output facilities for ordinary fixed-point types.
10208
10209 @item Ada.Text_IO.Float_IO
10210 Provides input-output facilities for float types.  The following
10211 predefined instantiations of this generic package are available:
10212
10213 @table @code
10214 @item Short_Float
10215 @code{Short_Float_Text_IO}
10216 @item Float
10217 @code{Float_Text_IO}
10218 @item Long_Float
10219 @code{Long_Float_Text_IO}
10220 @end table
10221
10222 @item Ada.Text_IO.Integer_IO
10223 Provides input-output facilities for integer types.  The following
10224 predefined instantiations of this generic package are available:
10225
10226 @table @code
10227 @item Short_Short_Integer
10228 @code{Ada.Short_Short_Integer_Text_IO}
10229 @item Short_Integer
10230 @code{Ada.Short_Integer_Text_IO}
10231 @item Integer
10232 @code{Ada.Integer_Text_IO}
10233 @item Long_Integer
10234 @code{Ada.Long_Integer_Text_IO}
10235 @item Long_Long_Integer
10236 @code{Ada.Long_Long_Integer_Text_IO}
10237 @end table
10238
10239 @item Ada.Text_IO.Modular_IO
10240 Provides input-output facilities for modular (unsigned) types
10241
10242 @item Ada.Text_IO.Complex_IO (G.1.3)
10243 This package provides basic text input-output capabilities for complex
10244 data.
10245
10246 @item Ada.Text_IO.Editing (F.3.3)
10247 This package contains routines for edited output, analogous to the use
10248 of pictures in COBOL@.  The picture formats used by this package are a
10249 close copy of the facility in COBOL@.
10250
10251 @item Ada.Text_IO.Text_Streams (A.12.2)
10252 This package provides a facility that allows Text_IO files to be treated
10253 as streams, so that the stream attributes can be used for writing
10254 arbitrary data, including binary data, to Text_IO files.
10255
10256 @item Ada.Unchecked_Conversion (13.9)
10257 This generic package allows arbitrary conversion from one type to
10258 another of the same size, providing for breaking the type safety in
10259 special circumstances.
10260
10261 If the types have the same Size (more accurately the same Value_Size),
10262 then the effect is simply to transfer the bits from the source to the
10263 target type without any modification.  This usage is well defined, and
10264 for simple types whose representation is typically the same across
10265 all implementations, gives a portable method of performing such
10266 conversions.
10267
10268 If the types do not have the same size, then the result is implementation
10269 defined, and thus may be non-portable.  The following describes how GNAT
10270 handles such unchecked conversion cases.
10271
10272 If the types are of different sizes, and are both discrete types, then
10273 the effect is of a normal type conversion without any constraint checking.
10274 In particular if the result type has a larger size, the result will be
10275 zero or sign extended.  If the result type has a smaller size, the result
10276 will be truncated by ignoring high order bits.
10277
10278 If the types are of different sizes, and are not both discrete types,
10279 then the conversion works as though pointers were created to the source
10280 and target, and the pointer value is converted.  The effect is that bits
10281 are copied from successive low order storage units and bits of the source
10282 up to the length of the target type.
10283
10284 A warning is issued if the lengths differ, since the effect in this
10285 case is implementation dependent, and the above behavior may not match
10286 that of some other compiler.
10287
10288 A pointer to one type may be converted to a pointer to another type using
10289 unchecked conversion.  The only case in which the effect is undefined is
10290 when one or both pointers are pointers to unconstrained array types.  In
10291 this case, the bounds information may get incorrectly transferred, and in
10292 particular, GNAT uses double size pointers for such types, and it is
10293 meaningless to convert between such pointer types.  GNAT will issue a
10294 warning if the alignment of the target designated type is more strict
10295 than the alignment of the source designated type (since the result may
10296 be unaligned in this case).
10297
10298 A pointer other than a pointer to an unconstrained array type may be
10299 converted to and from System.Address.  Such usage is common in Ada 83
10300 programs, but note that Ada.Address_To_Access_Conversions is the
10301 preferred method of performing such conversions in Ada 95.  Neither
10302 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10303 used in conjunction with pointers to unconstrained objects, since
10304 the bounds information cannot be handled correctly in this case.
10305
10306 @item Ada.Unchecked_Deallocation (13.11.2)
10307 This generic package allows explicit freeing of storage previously
10308 allocated by use of an allocator.
10309
10310 @item Ada.Wide_Text_IO (A.11)
10311 This package is similar to @code{Ada.Text_IO}, except that the external
10312 file supports wide character representations, and the internal types are
10313 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10314 and @code{String}.  It contains generic subpackages listed next.
10315
10316 @item Ada.Wide_Text_IO.Decimal_IO
10317 Provides input-output facilities for decimal fixed-point types
10318
10319 @item Ada.Wide_Text_IO.Enumeration_IO
10320 Provides input-output facilities for enumeration types.
10321
10322 @item Ada.Wide_Text_IO.Fixed_IO
10323 Provides input-output facilities for ordinary fixed-point types.
10324
10325 @item Ada.Wide_Text_IO.Float_IO
10326 Provides input-output facilities for float types.  The following
10327 predefined instantiations of this generic package are available:
10328
10329 @table @code
10330 @item Short_Float
10331 @code{Short_Float_Wide_Text_IO}
10332 @item Float
10333 @code{Float_Wide_Text_IO}
10334 @item Long_Float
10335 @code{Long_Float_Wide_Text_IO}
10336 @end table
10337
10338 @item Ada.Wide_Text_IO.Integer_IO
10339 Provides input-output facilities for integer types.  The following
10340 predefined instantiations of this generic package are available:
10341
10342 @table @code
10343 @item Short_Short_Integer
10344 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10345 @item Short_Integer
10346 @code{Ada.Short_Integer_Wide_Text_IO}
10347 @item Integer
10348 @code{Ada.Integer_Wide_Text_IO}
10349 @item Long_Integer
10350 @code{Ada.Long_Integer_Wide_Text_IO}
10351 @item Long_Long_Integer
10352 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10353 @end table
10354
10355 @item Ada.Wide_Text_IO.Modular_IO
10356 Provides input-output facilities for modular (unsigned) types
10357
10358 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10359 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10360 external file supports wide character representations.
10361
10362 @item Ada.Wide_Text_IO.Editing (F.3.4)
10363 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10364 types are @code{Wide_Character} and @code{Wide_String} instead of
10365 @code{Character} and @code{String}.
10366
10367 @item Ada.Wide_Text_IO.Streams (A.12.3)
10368 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10369 types are @code{Wide_Character} and @code{Wide_String} instead of
10370 @code{Character} and @code{String}.
10371 @end table
10372
10373 @node The Implementation of Standard I/O
10374 @chapter The Implementation of Standard I/O
10375
10376 @noindent
10377 GNAT implements all the required input-output facilities described in
10378 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10379 required behavior of these packages from the Ada point of view, and if
10380 you are writing a portable Ada program that does not need to know the
10381 exact manner in which Ada maps to the outside world when it comes to
10382 reading or writing external files, then you do not need to read this
10383 chapter.  As long as your files are all regular files (not pipes or
10384 devices), and as long as you write and read the files only from Ada, the
10385 description in the Ada 95 reference manual is sufficient.
10386
10387 However, if you want to do input-output to pipes or other devices, such
10388 as the keyboard or screen, or if the files you are dealing with are
10389 either generated by some other language, or to be read by some other
10390 language, then you need to know more about the details of how the GNAT
10391 implementation of these input-output facilities behaves.
10392
10393 In this chapter we give a detailed description of exactly how GNAT
10394 interfaces to the file system.  As always, the sources of the system are
10395 available to you for answering questions at an even more detailed level,
10396 but for most purposes the information in this chapter will suffice.
10397
10398 Another reason that you may need to know more about how input-output is
10399 implemented arises when you have a program written in mixed languages
10400 where, for example, files are shared between the C and Ada sections of
10401 the same program.  GNAT provides some additional facilities, in the form
10402 of additional child library packages, that facilitate this sharing, and
10403 these additional facilities are also described in this chapter.
10404
10405 @menu
10406 * Standard I/O Packages::
10407 * FORM Strings::
10408 * Direct_IO::
10409 * Sequential_IO::
10410 * Text_IO::
10411 * Wide_Text_IO::
10412 * Stream_IO::
10413 * Shared Files::
10414 * Open Modes::
10415 * Operations on C Streams::
10416 * Interfacing to C Streams::
10417 @end menu
10418
10419 @node Standard I/O Packages
10420 @section Standard I/O Packages
10421
10422 @noindent
10423 The Standard I/O packages described in Annex A for
10424
10425 @itemize @bullet
10426 @item
10427 Ada.Text_IO
10428 @item
10429 Ada.Text_IO.Complex_IO
10430 @item
10431 Ada.Text_IO.Text_Streams,
10432 @item
10433 Ada.Wide_Text_IO
10434 @item
10435 Ada.Wide_Text_IO.Complex_IO,
10436 @item
10437 Ada.Wide_Text_IO.Text_Streams
10438 @item
10439 Ada.Stream_IO
10440 @item
10441 Ada.Sequential_IO
10442 @item
10443 Ada.Direct_IO
10444 @end itemize
10445
10446 @noindent
10447 are implemented using the C
10448 library streams facility; where
10449
10450 @itemize @bullet
10451 @item
10452 All files are opened using @code{fopen}.
10453 @item
10454 All input/output operations use @code{fread}/@code{fwrite}.
10455 @end itemize
10456
10457 @noindent
10458 There is no internal buffering of any kind at the Ada library level.  The
10459 only buffering is that provided at the system level in the
10460 implementation of the C library routines that support streams.  This
10461 facilitates shared use of these streams by mixed language programs.
10462
10463 @node FORM Strings
10464 @section FORM Strings
10465
10466 @noindent
10467 The format of a FORM string in GNAT is:
10468
10469 @smallexample
10470 "keyword=value,keyword=value,@dots{},keyword=value"
10471 @end smallexample
10472
10473 @noindent
10474 where letters may be in upper or lower case, and there are no spaces
10475 between values.  The order of the entries is not important.  Currently
10476 there are two keywords defined.
10477
10478 @smallexample
10479 SHARED=[YES|NO]
10480 WCEM=[n|h|u|s\e]
10481 @end smallexample
10482
10483 @noindent
10484 The use of these parameters is described later in this section.
10485
10486 @node Direct_IO
10487 @section Direct_IO
10488
10489 @noindent
10490 Direct_IO can only be instantiated for definite types.  This is a
10491 restriction of the Ada language, which means that the records are fixed
10492 length (the length being determined by @code{@var{type}'Size}, rounded
10493 up to the next storage unit boundary if necessary).
10494
10495 The records of a Direct_IO file are simply written to the file in index
10496 sequence, with the first record starting at offset zero, and subsequent
10497 records following.  There is no control information of any kind.  For
10498 example, if 32-bit integers are being written, each record takes
10499 4-bytes, so the record at index @var{K} starts at offset
10500 (@var{K}@minus{}1)*4.
10501
10502 There is no limit on the size of Direct_IO files, they are expanded as
10503 necessary to accommodate whatever records are written to the file.
10504
10505 @node Sequential_IO
10506 @section Sequential_IO
10507
10508 @noindent
10509 Sequential_IO may be instantiated with either a definite (constrained)
10510 or indefinite (unconstrained) type.
10511
10512 For the definite type case, the elements written to the file are simply
10513 the memory images of the data values with no control information of any
10514 kind.  The resulting file should be read using the same type, no validity
10515 checking is performed on input.
10516
10517 For the indefinite type case, the elements written consist of two
10518 parts.  First is the size of the data item, written as the memory image
10519 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10520 the data value.  The resulting file can only be read using the same
10521 (unconstrained) type.  Normal assignment checks are performed on these
10522 read operations, and if these checks fail, @code{Data_Error} is
10523 raised.  In particular, in the array case, the lengths must match, and in
10524 the variant record case, if the variable for a particular read operation
10525 is constrained, the discriminants must match.
10526
10527 Note that it is not possible to use Sequential_IO to write variable
10528 length array items, and then read the data back into different length
10529 arrays.  For example, the following will raise @code{Data_Error}:
10530
10531 @smallexample @c ada
10532  package IO is new Sequential_IO (String);
10533  F : IO.File_Type;
10534  S : String (1..4);
10535  @dots{}
10536  IO.Create (F)
10537  IO.Write (F, "hello!")
10538  IO.Reset (F, Mode=>In_File);
10539  IO.Read (F, S);
10540  Put_Line (S);
10541
10542 @end smallexample
10543
10544 @noindent
10545 On some Ada implementations, this will print @code{hell}, but the program is
10546 clearly incorrect, since there is only one element in the file, and that
10547 element is the string @code{hello!}.
10548
10549 In Ada 95, this kind of behavior can be legitimately achieved using
10550 Stream_IO, and this is the preferred mechanism.  In particular, the above
10551 program fragment rewritten to use Stream_IO will work correctly.
10552
10553 @node Text_IO
10554 @section Text_IO
10555
10556 @noindent
10557 Text_IO files consist of a stream of characters containing the following
10558 special control characters:
10559
10560 @smallexample
10561 LF (line feed, 16#0A#) Line Mark
10562 FF (form feed, 16#0C#) Page Mark
10563 @end smallexample
10564
10565 @noindent
10566 A canonical Text_IO file is defined as one in which the following
10567 conditions are met:
10568
10569 @itemize @bullet
10570 @item
10571 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10572 of the line.
10573
10574 @item
10575 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10576 end of a page and consequently can appear only immediately following a
10577 @code{LF} (line mark) character.
10578
10579 @item
10580 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10581 (line mark, page mark).  In the former case, the page mark is implicitly
10582 assumed to be present.
10583 @end itemize
10584
10585 @noindent
10586 A file written using Text_IO will be in canonical form provided that no
10587 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10588 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10589 the file unless an explicit @code{New_Page} operation was performed
10590 before closing the file.
10591
10592 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10593 pipe, can be read using any of the routines in Text_IO@.  The
10594 semantics in this case will be exactly as defined in the Ada 95 reference
10595 manual and all the routines in Text_IO are fully implemented.
10596
10597 A text file that does not meet the requirements for a canonical Text_IO
10598 file has one of the following:
10599
10600 @itemize @bullet
10601 @item
10602 The file contains @code{FF} characters not immediately following a
10603 @code{LF} character.
10604
10605 @item
10606 The file contains @code{LF} or @code{FF} characters written by
10607 @code{Put} or @code{Put_Line}, which are not logically considered to be
10608 line marks or page marks.
10609
10610 @item
10611 The file ends in a character other than @code{LF} or @code{FF},
10612 i.e.@: there is no explicit line mark or page mark at the end of the file.
10613 @end itemize
10614
10615 @noindent
10616 Text_IO can be used to read such non-standard text files but subprograms
10617 to do with line or page numbers do not have defined meanings.  In
10618 particular, a @code{FF} character that does not follow a @code{LF}
10619 character may or may not be treated as a page mark from the point of
10620 view of page and line numbering.  Every @code{LF} character is considered
10621 to end a line, and there is an implied @code{LF} character at the end of
10622 the file.
10623
10624 @menu
10625 * Text_IO Stream Pointer Positioning::
10626 * Text_IO Reading and Writing Non-Regular Files::
10627 * Get_Immediate::
10628 * Treating Text_IO Files as Streams::
10629 * Text_IO Extensions::
10630 * Text_IO Facilities for Unbounded Strings::
10631 @end menu
10632
10633 @node Text_IO Stream Pointer Positioning
10634 @subsection Stream Pointer Positioning
10635
10636 @noindent
10637 @code{Ada.Text_IO} has a definition of current position for a file that
10638 is being read.  No internal buffering occurs in Text_IO, and usually the
10639 physical position in the stream used to implement the file corresponds
10640 to this logical position defined by Text_IO@.  There are two exceptions:
10641
10642 @itemize @bullet
10643 @item
10644 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10645 is positioned past the @code{LF} (line mark) that precedes the page
10646 mark.  Text_IO maintains an internal flag so that subsequent read
10647 operations properly handle the logical position which is unchanged by
10648 the @code{End_Of_Page} call.
10649
10650 @item
10651 After a call to @code{End_Of_File} that returns @code{True}, if the
10652 Text_IO file was positioned before the line mark at the end of file
10653 before the call, then the logical position is unchanged, but the stream
10654 is physically positioned right at the end of file (past the line mark,
10655 and past a possible page mark following the line mark.  Again Text_IO
10656 maintains internal flags so that subsequent read operations properly
10657 handle the logical position.
10658 @end itemize
10659
10660 @noindent
10661 These discrepancies have no effect on the observable behavior of
10662 Text_IO, but if a single Ada stream is shared between a C program and
10663 Ada program, or shared (using @samp{shared=yes} in the form string)
10664 between two Ada files, then the difference may be observable in some
10665 situations.
10666
10667 @node Text_IO Reading and Writing Non-Regular Files
10668 @subsection Reading and Writing Non-Regular Files
10669
10670 @noindent
10671 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10672 can be used for reading and writing.  Writing is not affected and the
10673 sequence of characters output is identical to the normal file case, but
10674 for reading, the behavior of Text_IO is modified to avoid undesirable
10675 look-ahead as follows:
10676
10677 An input file that is not a regular file is considered to have no page
10678 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10679 page mark) appearing in the file are considered to be data
10680 characters.  In particular:
10681
10682 @itemize @bullet
10683 @item
10684 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10685 following a line mark.  If a page mark appears, it will be treated as a
10686 data character.
10687
10688 @item
10689 This avoids the need to wait for an extra character to be typed or
10690 entered from the pipe to complete one of these operations.
10691
10692 @item
10693 @code{End_Of_Page} always returns @code{False}
10694
10695 @item
10696 @code{End_Of_File} will return @code{False} if there is a page mark at
10697 the end of the file.
10698 @end itemize
10699
10700 @noindent
10701 Output to non-regular files is the same as for regular files.  Page marks
10702 may be written to non-regular files using @code{New_Page}, but as noted
10703 above they will not be treated as page marks on input if the output is
10704 piped to another Ada program.
10705
10706 Another important discrepancy when reading non-regular files is that the end
10707 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10708 pressing the @key{EOT} key,
10709 then end of file
10710 is signaled once (i.e.@: the test @code{End_Of_File}
10711 will yield @code{True}, or a read will
10712 raise @code{End_Error}), but then reading can resume
10713 to read data past that end of
10714 file indication, until another end of file indication is entered.
10715
10716 @node Get_Immediate
10717 @subsection Get_Immediate
10718 @cindex Get_Immediate
10719
10720 @noindent
10721 Get_Immediate returns the next character (including control characters)
10722 from the input file.  In particular, Get_Immediate will return LF or FF
10723 characters used as line marks or page marks.  Such operations leave the
10724 file positioned past the control character, and it is thus not treated
10725 as having its normal function.  This means that page, line and column
10726 counts after this kind of Get_Immediate call are set as though the mark
10727 did not occur.  In the case where a Get_Immediate leaves the file
10728 positioned between the line mark and page mark (which is not normally
10729 possible), it is undefined whether the FF character will be treated as a
10730 page mark.
10731
10732 @node Treating Text_IO Files as Streams
10733 @subsection Treating Text_IO Files as Streams
10734 @cindex Stream files
10735
10736 @noindent
10737 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10738 as a stream.  Data written to a Text_IO file in this stream mode is
10739 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10740 16#0C# (@code{FF}), the resulting file may have non-standard
10741 format.  Similarly if read operations are used to read from a Text_IO
10742 file treated as a stream, then @code{LF} and @code{FF} characters may be
10743 skipped and the effect is similar to that described above for
10744 @code{Get_Immediate}.
10745
10746 @node Text_IO Extensions
10747 @subsection Text_IO Extensions
10748 @cindex Text_IO extensions
10749
10750 @noindent
10751 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10752 to the standard @code{Text_IO} package:
10753
10754 @itemize @bullet
10755 @item function File_Exists (Name : String) return Boolean;
10756 Determines if a file of the given name exists.
10757
10758 @item function Get_Line return String;
10759 Reads a string from the standard input file.  The value returned is exactly
10760 the length of the line that was read.
10761
10762 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10763 Similar, except that the parameter File specifies the file from which
10764 the string is to be read.
10765
10766 @end itemize
10767
10768 @node Text_IO Facilities for Unbounded Strings
10769 @subsection Text_IO Facilities for Unbounded Strings
10770 @cindex Text_IO for unbounded strings
10771 @cindex Unbounded_String, Text_IO operations
10772
10773 @noindent
10774 The package @code{Ada.Strings.Unbounded.Text_IO}
10775 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10776 subprograms useful for Text_IO operations on unbounded strings:
10777
10778 @itemize @bullet
10779
10780 @item function Get_Line (File : File_Type) return Unbounded_String;
10781 Reads a line from the specified file
10782 and returns the result as an unbounded string.
10783
10784 @item procedure Put (File : File_Type; U : Unbounded_String);
10785 Writes the value of the given unbounded string to the specified file
10786 Similar to the effect of
10787 @code{Put (To_String (U))} except that an extra copy is avoided.
10788
10789 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10790 Writes the value of the given unbounded string to the specified file,
10791 followed by a @code{New_Line}.
10792 Similar to the effect of @code{Put_Line (To_String (U))} except
10793 that an extra copy is avoided.
10794 @end itemize
10795
10796 @noindent
10797 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10798 and is optional.  If the parameter is omitted, then the standard input or
10799 output file is referenced as appropriate.
10800
10801 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10802 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10803 @code{Wide_Text_IO} functionality for unbounded wide strings.
10804
10805 @node Wide_Text_IO
10806 @section Wide_Text_IO
10807
10808 @noindent
10809 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10810 both input and output files may contain special sequences that represent
10811 wide character values.  The encoding scheme for a given file may be
10812 specified using a FORM parameter:
10813
10814 @smallexample
10815 WCEM=@var{x}
10816 @end smallexample
10817
10818 @noindent
10819 as part of the FORM string (WCEM = wide character encoding method),
10820 where @var{x} is one of the following characters
10821
10822 @table @samp
10823 @item h
10824 Hex ESC encoding
10825 @item u
10826 Upper half encoding
10827 @item s
10828 Shift-JIS encoding
10829 @item e
10830 EUC Encoding
10831 @item 8
10832 UTF-8 encoding
10833 @item b
10834 Brackets encoding
10835 @end table
10836
10837 @noindent
10838 The encoding methods match those that
10839 can be used in a source
10840 program, but there is no requirement that the encoding method used for
10841 the source program be the same as the encoding method used for files,
10842 and different files may use different encoding methods.
10843
10844 The default encoding method for the standard files, and for opened files
10845 for which no WCEM parameter is given in the FORM string matches the
10846 wide character encoding specified for the main program (the default
10847 being brackets encoding if no coding method was specified with -gnatW).
10848
10849 @table @asis
10850 @item Hex Coding
10851 In this encoding, a wide character is represented by a five character
10852 sequence:
10853
10854 @smallexample
10855 ESC a b c d
10856 @end smallexample
10857
10858 @noindent
10859 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10860 characters (using upper case letters) of the wide character code.  For
10861 example, ESC A345 is used to represent the wide character with code
10862 16#A345#.  This scheme is compatible with use of the full
10863 @code{Wide_Character} set.
10864
10865 @item Upper Half Coding
10866 The wide character with encoding 16#abcd#, where the upper bit is on
10867 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10868 16#cd#.  The second byte may never be a format control character, but is
10869 not required to be in the upper half.  This method can be also used for
10870 shift-JIS or EUC where the internal coding matches the external coding.
10871
10872 @item Shift JIS Coding
10873 A wide character is represented by a two character sequence 16#ab# and
10874 16#cd#, with the restrictions described for upper half encoding as
10875 described above.  The internal character code is the corresponding JIS
10876 character according to the standard algorithm for Shift-JIS
10877 conversion.  Only characters defined in the JIS code set table can be
10878 used with this encoding method.
10879
10880 @item EUC Coding
10881 A wide character is represented by a two character sequence 16#ab# and
10882 16#cd#, with both characters being in the upper half.  The internal
10883 character code is the corresponding JIS character according to the EUC
10884 encoding algorithm.  Only characters defined in the JIS code set table
10885 can be used with this encoding method.
10886
10887 @item UTF-8 Coding
10888 A wide character is represented using
10889 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10890 10646-1/Am.2.  Depending on the character value, the representation
10891 is a one, two, or three byte sequence:
10892
10893 @smallexample
10894 16#0000#-16#007f#: 2#0xxxxxxx#
10895 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10896 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10897 @end smallexample
10898
10899 @noindent
10900 where the xxx bits correspond to the left-padded bits of the
10901 16-bit character value.  Note that all lower half ASCII characters
10902 are represented as ASCII bytes and all upper half characters and
10903 other wide characters are represented as sequences of upper-half
10904 (The full UTF-8 scheme allows for encoding 31-bit characters as
10905 6-byte sequences, but in this implementation, all UTF-8 sequences
10906 of four or more bytes length will raise a Constraint_Error, as
10907 will all invalid UTF-8 sequences.)
10908
10909 @item Brackets Coding
10910 In this encoding, a wide character is represented by the following eight
10911 character sequence:
10912
10913 @smallexample
10914 [ " a b c d " ]
10915 @end smallexample
10916
10917 @noindent
10918 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
10919 characters (using uppercase letters) of the wide character code.  For
10920 example, @code{["A345"]} is used to represent the wide character with code
10921 @code{16#A345#}.
10922 This scheme is compatible with use of the full Wide_Character set.
10923 On input, brackets coding can also be used for upper half characters,
10924 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
10925 is only used for wide characters with a code greater than @code{16#FF#}.
10926
10927 @end table
10928
10929 @noindent
10930 For the coding schemes other than Hex and Brackets encoding,
10931 not all wide character
10932 values can be represented.  An attempt to output a character that cannot
10933 be represented using the encoding scheme for the file causes
10934 Constraint_Error to be raised.  An invalid wide character sequence on
10935 input also causes Constraint_Error to be raised.
10936
10937 @menu
10938 * Wide_Text_IO Stream Pointer Positioning::
10939 * Wide_Text_IO Reading and Writing Non-Regular Files::
10940 @end menu
10941
10942 @node Wide_Text_IO Stream Pointer Positioning
10943 @subsection Stream Pointer Positioning
10944
10945 @noindent
10946 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
10947 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
10948 case:
10949
10950 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
10951 normal lower ASCII set (i.e.@: a character in the range:
10952
10953 @smallexample @c ada
10954 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
10955 @end smallexample
10956
10957 @noindent
10958 then although the logical position of the file pointer is unchanged by
10959 the @code{Look_Ahead} call, the stream is physically positioned past the
10960 wide character sequence.  Again this is to avoid the need for buffering
10961 or backup, and all @code{Wide_Text_IO} routines check the internal
10962 indication that this situation has occurred so that this is not visible
10963 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
10964 can be observed if the wide text file shares a stream with another file.
10965
10966 @node Wide_Text_IO Reading and Writing Non-Regular Files
10967 @subsection Reading and Writing Non-Regular Files
10968
10969 @noindent
10970 As in the case of Text_IO, when a non-regular file is read, it is
10971 assumed that the file contains no page marks (any form characters are
10972 treated as data characters), and @code{End_Of_Page} always returns
10973 @code{False}.  Similarly, the end of file indication is not sticky, so
10974 it is possible to read beyond an end of file.
10975
10976 @node Stream_IO
10977 @section Stream_IO
10978
10979 @noindent
10980 A stream file is a sequence of bytes, where individual elements are
10981 written to the file as described in the Ada 95 reference manual.  The type
10982 @code{Stream_Element} is simply a byte.  There are two ways to read or
10983 write a stream file.
10984
10985 @itemize @bullet
10986 @item
10987 The operations @code{Read} and @code{Write} directly read or write a
10988 sequence of stream elements with no control information.
10989
10990 @item
10991 The stream attributes applied to a stream file transfer data in the
10992 manner described for stream attributes.
10993 @end itemize
10994
10995 @node Shared Files
10996 @section Shared Files
10997
10998 @noindent
10999 Section A.14 of the Ada 95 Reference Manual allows implementations to
11000 provide a wide variety of behavior if an attempt is made to access the
11001 same external file with two or more internal files.
11002
11003 To provide a full range of functionality, while at the same time
11004 minimizing the problems of portability caused by this implementation
11005 dependence, GNAT handles file sharing as follows:
11006
11007 @itemize @bullet
11008 @item
11009 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11010 to open two or more files with the same full name is considered an error
11011 and is not supported.  The exception @code{Use_Error} will be
11012 raised.  Note that a file that is not explicitly closed by the program
11013 remains open until the program terminates.
11014
11015 @item
11016 If the form parameter @samp{shared=no} appears in the form string, the
11017 file can be opened or created with its own separate stream identifier,
11018 regardless of whether other files sharing the same external file are
11019 opened.  The exact effect depends on how the C stream routines handle
11020 multiple accesses to the same external files using separate streams.
11021
11022 @item
11023 If the form parameter @samp{shared=yes} appears in the form string for
11024 each of two or more files opened using the same full name, the same
11025 stream is shared between these files, and the semantics are as described
11026 in Ada 95 Reference Manual, Section A.14.
11027 @end itemize
11028
11029 @noindent
11030 When a program that opens multiple files with the same name is ported
11031 from another Ada compiler to GNAT, the effect will be that
11032 @code{Use_Error} is raised.
11033
11034 The documentation of the original compiler and the documentation of the
11035 program should then be examined to determine if file sharing was
11036 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11037 and @code{Create} calls as required.
11038
11039 When a program is ported from GNAT to some other Ada compiler, no
11040 special attention is required unless the @samp{shared=@var{xxx}} form
11041 parameter is used in the program.  In this case, you must examine the
11042 documentation of the new compiler to see if it supports the required
11043 file sharing semantics, and form strings modified appropriately.  Of
11044 course it may be the case that the program cannot be ported if the
11045 target compiler does not support the required functionality.  The best
11046 approach in writing portable code is to avoid file sharing (and hence
11047 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11048 completely.
11049
11050 One common use of file sharing in Ada 83 is the use of instantiations of
11051 Sequential_IO on the same file with different types, to achieve
11052 heterogeneous input-output.  Although this approach will work in GNAT if
11053 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11054 for this purpose (using the stream attributes)
11055
11056 @node Open Modes
11057 @section Open Modes
11058
11059 @noindent
11060 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11061 using the mode shown in the following table:
11062
11063 @sp 2
11064 @center @code{Open} and @code{Create} Call Modes
11065 @smallexample
11066                                @b{OPEN }           @b{CREATE}
11067 Append_File                    "r+"             "w+"
11068 In_File                        "r"              "w+"
11069 Out_File (Direct_IO)           "r+"             "w"
11070 Out_File (all other cases)     "w"              "w"
11071 Inout_File                     "r+"             "w+"
11072 @end smallexample
11073
11074 @noindent
11075 If text file translation is required, then either @samp{b} or @samp{t}
11076 is added to the mode, depending on the setting of Text.  Text file
11077 translation refers to the mapping of CR/LF sequences in an external file
11078 to LF characters internally.  This mapping only occurs in DOS and
11079 DOS-like systems, and is not relevant to other systems.
11080
11081 A special case occurs with Stream_IO@.  As shown in the above table, the
11082 file is initially opened in @samp{r} or @samp{w} mode for the
11083 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11084 subsequently requires switching from reading to writing or vice-versa,
11085 then the file is reopened in @samp{r+} mode to permit the required operation.
11086
11087 @node Operations on C Streams
11088 @section Operations on C Streams
11089 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11090 access to the C library functions for operations on C streams:
11091
11092 @smallexample @c adanocomment
11093 package Interfaces.C_Streams is
11094   -- Note: the reason we do not use the types that are in
11095   -- Interfaces.C is that we want to avoid dragging in the
11096   -- code in this unit if possible.
11097   subtype chars is System.Address;
11098   -- Pointer to null-terminated array of characters
11099   subtype FILEs is System.Address;
11100   -- Corresponds to the C type FILE*
11101   subtype voids is System.Address;
11102   -- Corresponds to the C type void*
11103   subtype int is Integer;
11104   subtype long is Long_Integer;
11105   -- Note: the above types are subtypes deliberately, and it
11106   -- is part of this spec that the above correspondences are
11107   -- guaranteed.  This means that it is legitimate to, for
11108   -- example, use Integer instead of int.  We provide these
11109   -- synonyms for clarity, but in some cases it may be
11110   -- convenient to use the underlying types (for example to
11111   -- avoid an unnecessary dependency of a spec on the spec
11112   -- of this unit).
11113   type size_t is mod 2 ** Standard'Address_Size;
11114   NULL_Stream : constant FILEs;
11115   -- Value returned (NULL in C) to indicate an
11116   -- fdopen/fopen/tmpfile error
11117   ----------------------------------
11118   -- Constants Defined in stdio.h --
11119   ----------------------------------
11120   EOF : constant int;
11121   -- Used by a number of routines to indicate error or
11122   -- end of file
11123   IOFBF : constant int;
11124   IOLBF : constant int;
11125   IONBF : constant int;
11126   -- Used to indicate buffering mode for setvbuf call
11127   SEEK_CUR : constant int;
11128   SEEK_END : constant int;
11129   SEEK_SET : constant int;
11130   -- Used to indicate origin for fseek call
11131   function stdin return FILEs;
11132   function stdout return FILEs;
11133   function stderr return FILEs;
11134   -- Streams associated with standard files
11135   --------------------------
11136   -- Standard C functions --
11137   --------------------------
11138   -- The functions selected below are ones that are
11139   -- available in DOS, OS/2, UNIX and Xenix (but not
11140   -- necessarily in ANSI C).  These are very thin interfaces
11141   -- which copy exactly the C headers.  For more
11142   -- documentation on these functions, see the Microsoft C
11143   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11144   -- ISBN 1-55615-225-6), which includes useful information
11145   -- on system compatibility.
11146   procedure clearerr (stream : FILEs);
11147   function fclose (stream : FILEs) return int;
11148   function fdopen (handle : int; mode : chars) return FILEs;
11149   function feof (stream : FILEs) return int;
11150   function ferror (stream : FILEs) return int;
11151   function fflush (stream : FILEs) return int;
11152   function fgetc (stream : FILEs) return int;
11153   function fgets (strng : chars; n : int; stream : FILEs)
11154       return chars;
11155   function fileno (stream : FILEs) return int;
11156   function fopen (filename : chars; Mode : chars)
11157       return FILEs;
11158   -- Note: to maintain target independence, use
11159   -- text_translation_required, a boolean variable defined in
11160   -- a-sysdep.c to deal with the target dependent text
11161   -- translation requirement.  If this variable is set,
11162   -- then  b/t should be appended to the standard mode
11163   -- argument to set the text translation mode off or on
11164   -- as required.
11165   function fputc (C : int; stream : FILEs) return int;
11166   function fputs (Strng : chars; Stream : FILEs) return int;
11167   function fread
11168      (buffer : voids;
11169       size : size_t;
11170       count : size_t;
11171       stream : FILEs)
11172       return size_t;
11173   function freopen
11174      (filename : chars;
11175       mode : chars;
11176       stream : FILEs)
11177       return FILEs;
11178   function fseek
11179      (stream : FILEs;
11180       offset : long;
11181       origin : int)
11182       return int;
11183   function ftell (stream : FILEs) return long;
11184   function fwrite
11185      (buffer : voids;
11186       size : size_t;
11187       count : size_t;
11188       stream : FILEs)
11189       return size_t;
11190   function isatty (handle : int) return int;
11191   procedure mktemp (template : chars);
11192   -- The return value (which is just a pointer to template)
11193   -- is discarded
11194   procedure rewind (stream : FILEs);
11195   function rmtmp return int;
11196   function setvbuf
11197      (stream : FILEs;
11198       buffer : chars;
11199       mode : int;
11200       size : size_t)
11201       return int;
11202
11203   function tmpfile return FILEs;
11204   function ungetc (c : int; stream : FILEs) return int;
11205   function unlink (filename : chars) return int;
11206   ---------------------
11207   -- Extra functions --
11208   ---------------------
11209   -- These functions supply slightly thicker bindings than
11210   -- those above.  They are derived from functions in the
11211   -- C Run-Time Library, but may do a bit more work than
11212   -- just directly calling one of the Library functions.
11213   function is_regular_file (handle : int) return int;
11214   -- Tests if given handle is for a regular file (result 1)
11215   -- or for a non-regular file (pipe or device, result 0).
11216   ---------------------------------
11217   -- Control of Text/Binary Mode --
11218   ---------------------------------
11219   -- If text_translation_required is true, then the following
11220   -- functions may be used to dynamically switch a file from
11221   -- binary to text mode or vice versa.  These functions have
11222   -- no effect if text_translation_required is false (i.e.  in
11223   -- normal UNIX mode).  Use fileno to get a stream handle.
11224   procedure set_binary_mode (handle : int);
11225   procedure set_text_mode (handle : int);
11226   ----------------------------
11227   -- Full Path Name support --
11228   ----------------------------
11229   procedure full_name (nam : chars; buffer : chars);
11230   -- Given a NUL terminated string representing a file
11231   -- name, returns in buffer a NUL terminated string
11232   -- representing the full path name for the file name.
11233   -- On systems where it is relevant the   drive is also
11234   -- part of the full path name.  It is the responsibility
11235   -- of the caller to pass an actual parameter for buffer
11236   -- that is big enough for any full path name.  Use
11237   -- max_path_len given below as the size of buffer.
11238   max_path_len : integer;
11239   -- Maximum length of an allowable full path name on the
11240   -- system, including a terminating NUL character.
11241 end Interfaces.C_Streams;
11242 @end smallexample
11243
11244 @node Interfacing to C Streams
11245 @section Interfacing to C Streams
11246
11247 @noindent
11248 The packages in this section permit interfacing Ada files to C Stream
11249 operations.
11250
11251 @smallexample @c ada
11252  with Interfaces.C_Streams;
11253  package Ada.Sequential_IO.C_Streams is
11254     function C_Stream (F : File_Type)
11255        return Interfaces.C_Streams.FILEs;
11256     procedure Open
11257       (File : in out File_Type;
11258        Mode : in File_Mode;
11259        C_Stream : in Interfaces.C_Streams.FILEs;
11260        Form : in String := "");
11261  end Ada.Sequential_IO.C_Streams;
11262
11263   with Interfaces.C_Streams;
11264   package Ada.Direct_IO.C_Streams is
11265      function C_Stream (F : File_Type)
11266         return Interfaces.C_Streams.FILEs;
11267      procedure Open
11268        (File : in out File_Type;
11269         Mode : in File_Mode;
11270         C_Stream : in Interfaces.C_Streams.FILEs;
11271         Form : in String := "");
11272   end Ada.Direct_IO.C_Streams;
11273
11274   with Interfaces.C_Streams;
11275   package Ada.Text_IO.C_Streams is
11276      function C_Stream (F : File_Type)
11277         return Interfaces.C_Streams.FILEs;
11278      procedure Open
11279        (File : in out File_Type;
11280         Mode : in File_Mode;
11281         C_Stream : in Interfaces.C_Streams.FILEs;
11282         Form : in String := "");
11283   end Ada.Text_IO.C_Streams;
11284
11285   with Interfaces.C_Streams;
11286   package Ada.Wide_Text_IO.C_Streams is
11287      function C_Stream (F : File_Type)
11288         return Interfaces.C_Streams.FILEs;
11289      procedure Open
11290        (File : in out File_Type;
11291         Mode : in File_Mode;
11292         C_Stream : in Interfaces.C_Streams.FILEs;
11293         Form : in String := "");
11294  end Ada.Wide_Text_IO.C_Streams;
11295
11296  with Interfaces.C_Streams;
11297  package Ada.Stream_IO.C_Streams is
11298     function C_Stream (F : File_Type)
11299        return Interfaces.C_Streams.FILEs;
11300     procedure Open
11301       (File : in out File_Type;
11302        Mode : in File_Mode;
11303        C_Stream : in Interfaces.C_Streams.FILEs;
11304        Form : in String := "");
11305  end Ada.Stream_IO.C_Streams;
11306 @end smallexample
11307
11308 @noindent
11309 In each of these five packages, the @code{C_Stream} function obtains the
11310 @code{FILE} pointer from a currently opened Ada file.  It is then
11311 possible to use the @code{Interfaces.C_Streams} package to operate on
11312 this stream, or the stream can be passed to a C program which can
11313 operate on it directly.  Of course the program is responsible for
11314 ensuring that only appropriate sequences of operations are executed.
11315
11316 One particular use of relevance to an Ada program is that the
11317 @code{setvbuf} function can be used to control the buffering of the
11318 stream used by an Ada file.  In the absence of such a call the standard
11319 default buffering is used.
11320
11321 The @code{Open} procedures in these packages open a file giving an
11322 existing C Stream instead of a file name.  Typically this stream is
11323 imported from a C program, allowing an Ada file to operate on an
11324 existing C file.
11325
11326 @node The GNAT Library
11327 @chapter The GNAT Library
11328
11329 @noindent
11330 The GNAT library contains a number of general and special purpose packages.
11331 It represents functionality that the GNAT developers have found useful, and
11332 which is made available to GNAT users.  The packages described here are fully
11333 supported, and upwards compatibility will be maintained in future releases,
11334 so you can use these facilities with the confidence that the same functionality
11335 will be available in future releases.
11336
11337 The chapter here simply gives a brief summary of the facilities available.
11338 The full documentation is found in the spec file for the package.  The full
11339 sources of these library packages, including both spec and body, are provided
11340 with all GNAT releases.  For example, to find out the full specifications of
11341 the SPITBOL pattern matching capability, including a full tutorial and
11342 extensive examples, look in the @file{g-spipat.ads} file in the library.
11343
11344 For each entry here, the package name (as it would appear in a @code{with}
11345 clause) is given, followed by the name of the corresponding spec file in
11346 parentheses.  The packages are children in four hierarchies, @code{Ada},
11347 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11348 GNAT-specific hierarchy.
11349
11350 Note that an application program should only use packages in one of these
11351 four hierarchies if the package is defined in the Ada Reference Manual,
11352 or is listed in this section of the GNAT Programmers Reference Manual.
11353 All other units should be considered internal implementation units and
11354 should not be directly @code{with}'ed by application code.  The use of
11355 a @code{with} statement that references one of these internal implementation
11356 units makes an application potentially dependent on changes in versions
11357 of GNAT, and will generate a warning message.
11358
11359 @menu
11360 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11361 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11362 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11363 * Ada.Command_Line.Remove (a-colire.ads)::
11364 * Ada.Command_Line.Environment (a-colien.ads)::
11365 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11366 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11367 * Ada.Exceptions.Traceback (a-exctra.ads)::
11368 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11369 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11370 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11371 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11372 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11373 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11374 * GNAT.Array_Split (g-arrspl.ads)::
11375 * GNAT.AWK (g-awk.ads)::
11376 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11377 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11378 * GNAT.Bubble_Sort (g-bubsor.ads)::
11379 * GNAT.Bubble_Sort_A (g-busora.ads)::
11380 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11381 * GNAT.Calendar (g-calend.ads)::
11382 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11383 * GNAT.CRC32 (g-crc32.ads)::
11384 * GNAT.Case_Util (g-casuti.ads)::
11385 * GNAT.CGI (g-cgi.ads)::
11386 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11387 * GNAT.CGI.Debug (g-cgideb.ads)::
11388 * GNAT.Command_Line (g-comlin.ads)::
11389 * GNAT.Compiler_Version (g-comver.ads)::
11390 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11391 * GNAT.Current_Exception (g-curexc.ads)::
11392 * GNAT.Debug_Pools (g-debpoo.ads)::
11393 * GNAT.Debug_Utilities (g-debuti.ads)::
11394 * GNAT.Directory_Operations (g-dirope.ads)::
11395 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11396 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11397 * GNAT.Exception_Actions (g-excact.ads)::
11398 * GNAT.Exception_Traces (g-exctra.ads)::
11399 * GNAT.Exceptions (g-except.ads)::
11400 * GNAT.Expect (g-expect.ads)::
11401 * GNAT.Float_Control (g-flocon.ads)::
11402 * GNAT.Heap_Sort (g-heasor.ads)::
11403 * GNAT.Heap_Sort_A (g-hesora.ads)::
11404 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11405 * GNAT.HTable (g-htable.ads)::
11406 * GNAT.IO (g-io.ads)::
11407 * GNAT.IO_Aux (g-io_aux.ads)::
11408 * GNAT.Lock_Files (g-locfil.ads)::
11409 * GNAT.MD5 (g-md5.ads)::
11410 * GNAT.Memory_Dump (g-memdum.ads)::
11411 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11412 * GNAT.OS_Lib (g-os_lib.ads)::
11413 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11414 * GNAT.Regexp (g-regexp.ads)::
11415 * GNAT.Registry (g-regist.ads)::
11416 * GNAT.Regpat (g-regpat.ads)::
11417 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11418 * GNAT.Semaphores (g-semaph.ads)::
11419 * GNAT.Signals (g-signal.ads)::
11420 * GNAT.Sockets (g-socket.ads)::
11421 * GNAT.Source_Info (g-souinf.ads)::
11422 * GNAT.Spell_Checker (g-speche.ads)::
11423 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11424 * GNAT.Spitbol (g-spitbo.ads)::
11425 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11426 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11427 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11428 * GNAT.Strings (g-string.ads)::
11429 * GNAT.String_Split (g-strspl.ads)::
11430 * GNAT.Table (g-table.ads)::
11431 * GNAT.Task_Lock (g-tasloc.ads)::
11432 * GNAT.Threads (g-thread.ads)::
11433 * GNAT.Traceback (g-traceb.ads)::
11434 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11435 * GNAT.Wide_String_Split (g-wistsp.ads)::
11436 * Interfaces.C.Extensions (i-cexten.ads)::
11437 * Interfaces.C.Streams (i-cstrea.ads)::
11438 * Interfaces.CPP (i-cpp.ads)::
11439 * Interfaces.Os2lib (i-os2lib.ads)::
11440 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11441 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11442 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11443 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11444 * Interfaces.VxWorks (i-vxwork.ads)::
11445 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11446 * System.Address_Image (s-addima.ads)::
11447 * System.Assertions (s-assert.ads)::
11448 * System.Memory (s-memory.ads)::
11449 * System.Partition_Interface (s-parint.ads)::
11450 * System.Restrictions (s-restri.ads)::
11451 * System.Rident (s-rident.ads)::
11452 * System.Task_Info (s-tasinf.ads)::
11453 * System.Wch_Cnv (s-wchcnv.ads)::
11454 * System.Wch_Con (s-wchcon.ads)::
11455 @end menu
11456
11457 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11458 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11459 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11460 @cindex Latin_9 constants for Character
11461
11462 @noindent
11463 This child of @code{Ada.Characters}
11464 provides a set of definitions corresponding to those in the
11465 RM-defined package @code{Ada.Characters.Latin_1} but with the
11466 few modifications required for @code{Latin-9}
11467 The provision of such a package
11468 is specifically authorized by the Ada Reference Manual
11469 (RM A.3(27)).
11470
11471 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11472 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11473 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11474 @cindex Latin_1 constants for Wide_Character
11475
11476 @noindent
11477 This child of @code{Ada.Characters}
11478 provides a set of definitions corresponding to those in the
11479 RM-defined package @code{Ada.Characters.Latin_1} but with the
11480 types of the constants being @code{Wide_Character}
11481 instead of @code{Character}.  The provision of such a package
11482 is specifically authorized by the Ada Reference Manual
11483 (RM A.3(27)).
11484
11485 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11486 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11487 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11488 @cindex Latin_9 constants for Wide_Character
11489
11490 @noindent
11491 This child of @code{Ada.Characters}
11492 provides a set of definitions corresponding to those in the
11493 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11494 types of the constants being @code{Wide_Character}
11495 instead of @code{Character}.  The provision of such a package
11496 is specifically authorized by the Ada Reference Manual
11497 (RM A.3(27)).
11498
11499 @node Ada.Command_Line.Remove (a-colire.ads)
11500 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11501 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11502 @cindex Removing command line arguments
11503 @cindex Command line, argument removal
11504
11505 @noindent
11506 This child of @code{Ada.Command_Line}
11507 provides a mechanism for logically removing
11508 arguments from the argument list.  Once removed, an argument is not visible
11509 to further calls on the subprograms in @code{Ada.Command_Line} will not
11510 see the removed argument.
11511
11512 @node Ada.Command_Line.Environment (a-colien.ads)
11513 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11514 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11515 @cindex Environment entries
11516
11517 @noindent
11518 This child of @code{Ada.Command_Line}
11519 provides a mechanism for obtaining environment values on systems
11520 where this concept makes sense.
11521
11522 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11523 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11524 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11525 @cindex C Streams, Interfacing with Direct_IO
11526
11527 @noindent
11528 This package provides subprograms that allow interfacing between
11529 C streams and @code{Direct_IO}.  The stream identifier can be
11530 extracted from a file opened on the Ada side, and an Ada file
11531 can be constructed from a stream opened on the C side.
11532
11533 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11534 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11535 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11536 @cindex Null_Occurrence, testing for
11537
11538 @noindent
11539 This child subprogram provides a way of testing for the null
11540 exception occurrence (@code{Null_Occurrence}) without raising
11541 an exception.
11542
11543 @node Ada.Exceptions.Traceback (a-exctra.ads)
11544 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11545 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11546 @cindex Traceback for Exception Occurrence
11547
11548 @noindent
11549 This child package provides the subprogram (@code{Tracebacks}) to
11550 give a traceback array of addresses based on an exception
11551 occurrence.
11552
11553 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11554 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11555 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11556 @cindex C Streams, Interfacing with Sequential_IO
11557
11558 @noindent
11559 This package provides subprograms that allow interfacing between
11560 C streams and @code{Sequential_IO}.  The stream identifier can be
11561 extracted from a file opened on the Ada side, and an Ada file
11562 can be constructed from a stream opened on the C side.
11563
11564 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11565 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11566 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11567 @cindex C Streams, Interfacing with Stream_IO
11568
11569 @noindent
11570 This package provides subprograms that allow interfacing between
11571 C streams and @code{Stream_IO}.  The stream identifier can be
11572 extracted from a file opened on the Ada side, and an Ada file
11573 can be constructed from a stream opened on the C side.
11574
11575 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11576 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11577 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11578 @cindex @code{Unbounded_String}, IO support
11579 @cindex @code{Text_IO}, extensions for unbounded strings
11580
11581 @noindent
11582 This package provides subprograms for Text_IO for unbounded
11583 strings, avoiding the necessity for an intermediate operation
11584 with ordinary strings.
11585
11586 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11587 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11588 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11589 @cindex @code{Unbounded_Wide_String}, IO support
11590 @cindex @code{Text_IO}, extensions for unbounded wide strings
11591
11592 @noindent
11593 This package provides subprograms for Text_IO for unbounded
11594 wide strings, avoiding the necessity for an intermediate operation
11595 with ordinary wide strings.
11596
11597 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11598 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11599 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11600 @cindex C Streams, Interfacing with @code{Text_IO}
11601
11602 @noindent
11603 This package provides subprograms that allow interfacing between
11604 C streams and @code{Text_IO}.  The stream identifier can be
11605 extracted from a file opened on the Ada side, and an Ada file
11606 can be constructed from a stream opened on the C side.
11607
11608 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11609 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11610 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11611 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11612
11613 @noindent
11614 This package provides subprograms that allow interfacing between
11615 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11616 extracted from a file opened on the Ada side, and an Ada file
11617 can be constructed from a stream opened on the C side.
11618
11619 @node GNAT.Array_Split (g-arrspl.ads)
11620 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11621 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11622 @cindex Array splitter
11623
11624 @noindent
11625 Useful array-manipulation routines: given a set of separators, split
11626 an array wherever the separators appear, and provide direct access
11627 to the resulting slices.
11628
11629 @node GNAT.AWK (g-awk.ads)
11630 @section @code{GNAT.AWK} (@file{g-awk.ads})
11631 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11632 @cindex Parsing
11633 @cindex AWK
11634
11635 @noindent
11636 Provides AWK-like parsing functions, with an easy interface for parsing one
11637 or more files containing formatted data.  The file is viewed as a database
11638 where each record is a line and a field is a data element in this line.
11639
11640 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11641 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11642 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11643 @cindex Parsing
11644 @cindex Bounded Buffers
11645
11646 @noindent
11647 Provides a concurrent generic bounded buffer abstraction.  Instances are
11648 useful directly or as parts of the implementations of other abstractions,
11649 such as mailboxes.
11650
11651 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11652 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11653 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11654 @cindex Parsing
11655 @cindex Mailboxes
11656
11657 @noindent
11658 Provides a thread-safe asynchronous intertask mailbox communication facility.
11659
11660 @node GNAT.Bubble_Sort (g-bubsor.ads)
11661 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11662 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11663 @cindex Sorting
11664 @cindex Bubble sort
11665
11666 @noindent
11667 Provides a general implementation of bubble sort usable for sorting arbitrary
11668 data items.  Exchange and comparison procedures are provided by passing
11669 access-to-procedure values.
11670
11671 @node GNAT.Bubble_Sort_A (g-busora.ads)
11672 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11673 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11674 @cindex Sorting
11675 @cindex Bubble sort
11676
11677 @noindent
11678 Provides a general implementation of bubble sort usable for sorting arbitrary
11679 data items.  Move and comparison procedures are provided by passing
11680 access-to-procedure values. This is an older version, retained for
11681 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11682
11683 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11684 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11685 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11686 @cindex Sorting
11687 @cindex Bubble sort
11688
11689 @noindent
11690 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11691 are provided as generic parameters, this improves efficiency, especially
11692 if the procedures can be inlined, at the expense of duplicating code for
11693 multiple instantiations.
11694
11695 @node GNAT.Calendar (g-calend.ads)
11696 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11697 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11698 @cindex @code{Calendar}
11699
11700 @noindent
11701 Extends the facilities provided by @code{Ada.Calendar} to include handling
11702 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11703 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11704 C @code{timeval} format.
11705
11706 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11707 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11708 @cindex @code{Calendar}
11709 @cindex Time
11710 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11711
11712 @node GNAT.CRC32 (g-crc32.ads)
11713 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11714 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11715 @cindex CRC32
11716 @cindex Cyclic Redundancy Check
11717
11718 @noindent
11719 This package implements the CRC-32 algorithm.  For a full description
11720 of this algorithm see
11721 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11722 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11723 Aug.@: 1988.  Sarwate, D.V@.
11724
11725 @noindent
11726 Provides an extended capability for formatted output of time values with
11727 full user control over the format.  Modeled on the GNU Date specification.
11728
11729 @node GNAT.Case_Util (g-casuti.ads)
11730 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11731 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11732 @cindex Casing utilities
11733 @cindex Character handling (@code{GNAT.Case_Util})
11734
11735 @noindent
11736 A set of simple routines for handling upper and lower casing of strings
11737 without the overhead of the full casing tables
11738 in @code{Ada.Characters.Handling}.
11739
11740 @node GNAT.CGI (g-cgi.ads)
11741 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11742 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11743 @cindex CGI (Common Gateway Interface)
11744
11745 @noindent
11746 This is a package for interfacing a GNAT program with a Web server via the
11747 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11748 parameters, which are a set of key/value pairs sent by the Web server.  It
11749 builds a table whose index is the key and provides some services to deal
11750 with this table.
11751
11752 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11753 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11754 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11755 @cindex CGI (Common Gateway Interface) cookie support
11756 @cindex Cookie support in CGI
11757
11758 @noindent
11759 This is a package to interface a GNAT program with a Web server via the
11760 Common Gateway Interface (CGI).  It exports services to deal with Web
11761 cookies (piece of information kept in the Web client software).
11762
11763 @node GNAT.CGI.Debug (g-cgideb.ads)
11764 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11765 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11766 @cindex CGI (Common Gateway Interface) debugging
11767
11768 @noindent
11769 This is a package to help debugging CGI (Common Gateway Interface)
11770 programs written in Ada.
11771
11772 @node GNAT.Command_Line (g-comlin.ads)
11773 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11774 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11775 @cindex Command line
11776
11777 @noindent
11778 Provides a high level interface to @code{Ada.Command_Line} facilities,
11779 including the ability to scan for named switches with optional parameters
11780 and expand file names using wild card notations.
11781
11782 @node GNAT.Compiler_Version (g-comver.ads)
11783 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11784 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11785 @cindex Compiler Version
11786 @cindex Version, of compiler
11787
11788 @noindent
11789 Provides a routine for obtaining the version of the compiler used to
11790 compile the program. More accurately this is the version of the binder
11791 used to bind the program (this will normally be the same as the version
11792 of the compiler if a consistent tool set is used to compile all units
11793 of a partition).
11794
11795 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11796 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11797 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11798 @cindex Interrupt
11799
11800 @noindent
11801 Provides a simple interface to handle Ctrl-C keyboard events.
11802
11803 @node GNAT.Current_Exception (g-curexc.ads)
11804 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11805 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11806 @cindex Current exception
11807 @cindex Exception retrieval
11808
11809 @noindent
11810 Provides access to information on the current exception that has been raised
11811 without the need for using the Ada-95 exception choice parameter specification
11812 syntax.  This is particularly useful in simulating typical facilities for
11813 obtaining information about exceptions provided by Ada 83 compilers.
11814
11815 @node GNAT.Debug_Pools (g-debpoo.ads)
11816 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11817 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11818 @cindex Debugging
11819 @cindex Debug pools
11820 @cindex Memory corruption debugging
11821
11822 @noindent
11823 Provide a debugging storage pools that helps tracking memory corruption
11824 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11825 the @cite{GNAT User's Guide}.
11826
11827 @node GNAT.Debug_Utilities (g-debuti.ads)
11828 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11829 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11830 @cindex Debugging
11831
11832 @noindent
11833 Provides a few useful utilities for debugging purposes, including conversion
11834 to and from string images of address values. Supports both C and Ada formats
11835 for hexadecimal literals.
11836
11837 @node GNAT.Directory_Operations (g-dirope.ads)
11838 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11839 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11840 @cindex Directory operations
11841
11842 @noindent
11843 Provides a set of routines for manipulating directories, including changing
11844 the current directory, making new directories, and scanning the files in a
11845 directory.
11846
11847 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11848 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11849 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11850 @cindex Hash tables
11851
11852 @noindent
11853 A generic implementation of hash tables that can be used to hash arbitrary
11854 data.  Provided in two forms, a simple form with built in hash functions,
11855 and a more complex form in which the hash function is supplied.
11856
11857 @noindent
11858 This package provides a facility similar to that of @code{GNAT.HTable},
11859 except that this package declares a type that can be used to define
11860 dynamic instances of the hash table, while an instantiation of
11861 @code{GNAT.HTable} creates a single instance of the hash table.
11862
11863 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11864 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11865 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11866 @cindex Table implementation
11867 @cindex Arrays, extendable
11868
11869 @noindent
11870 A generic package providing a single dimension array abstraction where the
11871 length of the array can be dynamically modified.
11872
11873 @noindent
11874 This package provides a facility similar to that of @code{GNAT.Table},
11875 except that this package declares a type that can be used to define
11876 dynamic instances of the table, while an instantiation of
11877 @code{GNAT.Table} creates a single instance of the table type.
11878
11879 @node GNAT.Exception_Actions (g-excact.ads)
11880 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11881 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11882 @cindex Exception actions
11883
11884 @noindent
11885 Provides callbacks when an exception is raised. Callbacks can be registered
11886 for specific exceptions, or when any exception is raised. This
11887 can be used for instance to force a core dump to ease debugging.
11888
11889 @node GNAT.Exception_Traces (g-exctra.ads)
11890 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11891 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11892 @cindex Exception traces
11893 @cindex Debugging
11894
11895 @noindent
11896 Provides an interface allowing to control automatic output upon exception
11897 occurrences.
11898
11899 @node GNAT.Exceptions (g-except.ads)
11900 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11901 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11902 @cindex Exceptions, Pure
11903 @cindex Pure packages, exceptions
11904
11905 @noindent
11906 Normally it is not possible to raise an exception with
11907 a message from a subprogram in a pure package, since the
11908 necessary types and subprograms are in @code{Ada.Exceptions}
11909 which is not a pure unit. @code{GNAT.Exceptions} provides a
11910 facility for getting around this limitation for a few
11911 predefined exceptions, and for example allow raising
11912 @code{Constraint_Error} with a message from a pure subprogram.
11913
11914 @node GNAT.Expect (g-expect.ads)
11915 @section @code{GNAT.Expect} (@file{g-expect.ads})
11916 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
11917
11918 @noindent
11919 Provides a set of subprograms similar to what is available
11920 with the standard Tcl Expect tool.
11921 It allows you to easily spawn and communicate with an external process.
11922 You can send commands or inputs to the process, and compare the output
11923 with some expected regular expression. Currently @code{GNAT.Expect}
11924 is implemented on all native GNAT ports except for OpenVMS@.
11925 It is not implemented for cross ports, and in particular is not
11926 implemented for VxWorks or LynxOS@.
11927
11928 @node GNAT.Float_Control (g-flocon.ads)
11929 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
11930 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
11931 @cindex Floating-Point Processor
11932
11933 @noindent
11934 Provides an interface for resetting the floating-point processor into the
11935 mode required for correct semantic operation in Ada.  Some third party
11936 library calls may cause this mode to be modified, and the Reset procedure
11937 in this package can be used to reestablish the required mode.
11938
11939 @node GNAT.Heap_Sort (g-heasor.ads)
11940 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11941 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11942 @cindex Sorting
11943
11944 @noindent
11945 Provides a general implementation of heap sort usable for sorting arbitrary
11946 data items. Exchange and comparison procedures are provided by passing
11947 access-to-procedure values.  The algorithm used is a modified heap sort
11948 that performs approximately N*log(N) comparisons in the worst case.
11949
11950 @node GNAT.Heap_Sort_A (g-hesora.ads)
11951 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11952 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11953 @cindex Sorting
11954
11955 @noindent
11956 Provides a general implementation of heap sort usable for sorting arbitrary
11957 data items. Move and comparison procedures are provided by passing
11958 access-to-procedure values.  The algorithm used is a modified heap sort
11959 that performs approximately N*log(N) comparisons in the worst case.
11960 This differs from @code{GNAT.Heap_Sort} in having a less convenient
11961 interface, but may be slightly more efficient.
11962
11963 @node GNAT.Heap_Sort_G (g-hesorg.ads)
11964 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11965 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11966 @cindex Sorting
11967
11968 @noindent
11969 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
11970 are provided as generic parameters, this improves efficiency, especially
11971 if the procedures can be inlined, at the expense of duplicating code for
11972 multiple instantiations.
11973
11974 @node GNAT.HTable (g-htable.ads)
11975 @section @code{GNAT.HTable} (@file{g-htable.ads})
11976 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
11977 @cindex Hash tables
11978
11979 @noindent
11980 A generic implementation of hash tables that can be used to hash arbitrary
11981 data.  Provides two approaches, one a simple static approach, and the other
11982 allowing arbitrary dynamic hash tables.
11983
11984 @node GNAT.IO (g-io.ads)
11985 @section @code{GNAT.IO} (@file{g-io.ads})
11986 @cindex @code{GNAT.IO} (@file{g-io.ads})
11987 @cindex Simple I/O
11988 @cindex Input/Output facilities
11989
11990 @noindent
11991 A simple preelaborable input-output package that provides a subset of
11992 simple Text_IO functions for reading characters and strings from
11993 Standard_Input, and writing characters, strings and integers to either
11994 Standard_Output or Standard_Error.
11995
11996 @node GNAT.IO_Aux (g-io_aux.ads)
11997 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
11998 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
11999 @cindex Text_IO
12000 @cindex Input/Output facilities
12001
12002 Provides some auxiliary functions for use with Text_IO, including a test
12003 for whether a file exists, and functions for reading a line of text.
12004
12005 @node GNAT.Lock_Files (g-locfil.ads)
12006 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12007 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12008 @cindex File locking
12009 @cindex Locking using files
12010
12011 @noindent
12012 Provides a general interface for using files as locks.  Can be used for
12013 providing program level synchronization.
12014
12015 @node GNAT.MD5 (g-md5.ads)
12016 @section @code{GNAT.MD5} (@file{g-md5.ads})
12017 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12018 @cindex Message Digest MD5
12019
12020 @noindent
12021 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12022
12023 @node GNAT.Memory_Dump (g-memdum.ads)
12024 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12025 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12026 @cindex Dump Memory
12027
12028 @noindent
12029 Provides a convenient routine for dumping raw memory to either the
12030 standard output or standard error files. Uses GNAT.IO for actual
12031 output.
12032
12033 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12034 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12035 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12036 @cindex Exception, obtaining most recent
12037
12038 @noindent
12039 Provides access to the most recently raised exception.  Can be used for
12040 various logging purposes, including duplicating functionality of some
12041 Ada 83 implementation dependent extensions.
12042
12043 @node GNAT.OS_Lib (g-os_lib.ads)
12044 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12045 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12046 @cindex Operating System interface
12047 @cindex Spawn capability
12048
12049 @noindent
12050 Provides a range of target independent operating system interface functions,
12051 including time/date management, file operations, subprocess management,
12052 including a portable spawn procedure, and access to environment variables
12053 and error return codes.
12054
12055 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12056 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12057 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12058 @cindex Hash functions
12059
12060 @noindent
12061 Provides a generator of static minimal perfect hash functions. No
12062 collisions occur and each item can be retrieved from the table in one
12063 probe (perfect property). The hash table size corresponds to the exact
12064 size of the key set and no larger (minimal property). The key set has to
12065 be know in advance (static property). The hash functions are also order
12066 preservering. If w2 is inserted after w1 in the generator, their
12067 hashcode are in the same order. These hashing functions are very
12068 convenient for use with realtime applications.
12069
12070 @node GNAT.Regexp (g-regexp.ads)
12071 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12072 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12073 @cindex Regular expressions
12074 @cindex Pattern matching
12075
12076 @noindent
12077 A simple implementation of regular expressions, using a subset of regular
12078 expression syntax copied from familiar Unix style utilities.  This is the
12079 simples of the three pattern matching packages provided, and is particularly
12080 suitable for ``file globbing'' applications.
12081
12082 @node GNAT.Registry (g-regist.ads)
12083 @section @code{GNAT.Registry} (@file{g-regist.ads})
12084 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12085 @cindex Windows Registry
12086
12087 @noindent
12088 This is a high level binding to the Windows registry.  It is possible to
12089 do simple things like reading a key value, creating a new key.  For full
12090 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12091 package provided with the Win32Ada binding
12092
12093 @node GNAT.Regpat (g-regpat.ads)
12094 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12095 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12096 @cindex Regular expressions
12097 @cindex Pattern matching
12098
12099 @noindent
12100 A complete implementation of Unix-style regular expression matching, copied
12101 from the original V7 style regular expression library written in C by
12102 Henry Spencer (and binary compatible with this C library).
12103
12104 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12105 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12106 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12107 @cindex Secondary Stack Info
12108
12109 @noindent
12110 Provide the capability to query the high water mark of the current task's
12111 secondary stack.
12112
12113 @node GNAT.Semaphores (g-semaph.ads)
12114 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12115 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12116 @cindex Semaphores
12117
12118 @noindent
12119 Provides classic counting and binary semaphores using protected types.
12120
12121 @node GNAT.Signals (g-signal.ads)
12122 @section @code{GNAT.Signals} (@file{g-signal.ads})
12123 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12124 @cindex Signals
12125
12126 @noindent
12127 Provides the ability to manipulate the blocked status of signals on supported
12128 targets.
12129
12130 @node GNAT.Sockets (g-socket.ads)
12131 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12132 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12133 @cindex Sockets
12134
12135 @noindent
12136 A high level and portable interface to develop sockets based applications.
12137 This package is based on the sockets thin binding found in
12138 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12139 on all native GNAT ports except for OpenVMS@.  It is not implemented
12140 for the LynxOS@ cross port.
12141
12142 @node GNAT.Source_Info (g-souinf.ads)
12143 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12144 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12145 @cindex Source Information
12146
12147 @noindent
12148 Provides subprograms that give access to source code information known at
12149 compile time, such as the current file name and line number.
12150
12151 @node GNAT.Spell_Checker (g-speche.ads)
12152 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12153 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12154 @cindex Spell checking
12155
12156 @noindent
12157 Provides a function for determining whether one string is a plausible
12158 near misspelling of another string.
12159
12160 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12161 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12162 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12163 @cindex SPITBOL pattern matching
12164 @cindex Pattern matching
12165
12166 @noindent
12167 A complete implementation of SNOBOL4 style pattern matching.  This is the
12168 most elaborate of the pattern matching packages provided.  It fully duplicates
12169 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12170 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12171
12172 @node GNAT.Spitbol (g-spitbo.ads)
12173 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12174 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12175 @cindex SPITBOL interface
12176
12177 @noindent
12178 The top level package of the collection of SPITBOL-style functionality, this
12179 package provides basic SNOBOL4 string manipulation functions, such as
12180 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12181 useful for constructing arbitrary mappings from strings in the style of
12182 the SNOBOL4 TABLE function.
12183
12184 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12185 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12186 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12187 @cindex Sets of strings
12188 @cindex SPITBOL Tables
12189
12190 @noindent
12191 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12192 for type @code{Standard.Boolean}, giving an implementation of sets of
12193 string values.
12194
12195 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12196 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12197 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12198 @cindex Integer maps
12199 @cindex Maps
12200 @cindex SPITBOL Tables
12201
12202 @noindent
12203 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12204 for type @code{Standard.Integer}, giving an implementation of maps
12205 from string to integer values.
12206
12207 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12208 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12209 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12210 @cindex String maps
12211 @cindex Maps
12212 @cindex SPITBOL Tables
12213
12214 @noindent
12215 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12216 a variable length string type, giving an implementation of general
12217 maps from strings to strings.
12218
12219 @node GNAT.Strings (g-string.ads)
12220 @section @code{GNAT.Strings} (@file{g-string.ads})
12221 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12222
12223 @noindent
12224 Common String access types and related subprograms. Basically it
12225 defines a string access and an array of string access types.
12226
12227 @node GNAT.String_Split (g-strspl.ads)
12228 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12229 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12230 @cindex String splitter
12231
12232 @noindent
12233 Useful string-manipulation routines: given a set of separators, split
12234 a string wherever the separators appear, and provide direct access
12235 to the resulting slices. This package is instantiated from
12236 @code{GNAT.Array_Split}.
12237
12238 @node GNAT.Table (g-table.ads)
12239 @section @code{GNAT.Table} (@file{g-table.ads})
12240 @cindex @code{GNAT.Table} (@file{g-table.ads})
12241 @cindex Table implementation
12242 @cindex Arrays, extendable
12243
12244 @noindent
12245 A generic package providing a single dimension array abstraction where the
12246 length of the array can be dynamically modified.
12247
12248 @noindent
12249 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12250 except that this package declares a single instance of the table type,
12251 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12252 used to define dynamic instances of the table.
12253
12254 @node GNAT.Task_Lock (g-tasloc.ads)
12255 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12256 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12257 @cindex Task synchronization
12258 @cindex Task locking
12259 @cindex Locking
12260
12261 @noindent
12262 A very simple facility for locking and unlocking sections of code using a
12263 single global task lock.  Appropriate for use in situations where contention
12264 between tasks is very rarely expected.
12265
12266 @node GNAT.Threads (g-thread.ads)
12267 @section @code{GNAT.Threads} (@file{g-thread.ads})
12268 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12269 @cindex Foreign threads
12270 @cindex Threads, foreign
12271
12272 @noindent
12273 Provides facilities for creating and destroying threads with explicit calls.
12274 These threads are known to the GNAT run-time system.  These subprograms are
12275 exported C-convention procedures intended to be called from foreign code.
12276 By using these primitives rather than directly calling operating systems
12277 routines, compatibility with the Ada tasking runt-time is provided.
12278
12279 @node GNAT.Traceback (g-traceb.ads)
12280 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12281 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12282 @cindex Trace back facilities
12283
12284 @noindent
12285 Provides a facility for obtaining non-symbolic traceback information, useful
12286 in various debugging situations.
12287
12288 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12289 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12290 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12291 @cindex Trace back facilities
12292
12293 @noindent
12294 Provides symbolic traceback information that includes the subprogram
12295 name and line number information.
12296
12297 @node GNAT.Wide_String_Split (g-wistsp.ads)
12298 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12299 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12300 @cindex Wide_String splitter
12301
12302 @noindent
12303 Useful wide_string-manipulation routines: given a set of separators, split
12304 a wide_string wherever the separators appear, and provide direct access
12305 to the resulting slices. This package is instantiated from
12306 @code{GNAT.Array_Split}.
12307
12308 @node Interfaces.C.Extensions (i-cexten.ads)
12309 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12310 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12311
12312 @noindent
12313 This package contains additional C-related definitions, intended
12314 for use with either manually or automatically generated bindings
12315 to C libraries.
12316
12317 @node Interfaces.C.Streams (i-cstrea.ads)
12318 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12319 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12320 @cindex  C streams, interfacing
12321
12322 @noindent
12323 This package is a binding for the most commonly used operations
12324 on C streams.
12325
12326 @node Interfaces.CPP (i-cpp.ads)
12327 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12328 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12329 @cindex  C++ interfacing
12330 @cindex  Interfacing, to C++
12331
12332 @noindent
12333 This package provides facilities for use in interfacing to C++.  It
12334 is primarily intended to be used in connection with automated tools
12335 for the generation of C++ interfaces.
12336
12337 @node Interfaces.Os2lib (i-os2lib.ads)
12338 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12339 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12340 @cindex Interfacing, to OS/2
12341 @cindex OS/2 interfacing
12342
12343 @noindent
12344 This package provides interface definitions to the OS/2 library.
12345 It is a thin binding which is a direct translation of the
12346 various @file{<bse@.h>} files.
12347
12348 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12349 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12350 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12351 @cindex OS/2 Error codes
12352 @cindex Interfacing, to OS/2
12353 @cindex OS/2 interfacing
12354
12355 @noindent
12356 This package provides definitions of the OS/2 error codes.
12357
12358 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12359 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12360 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12361 @cindex Interfacing, to OS/2
12362 @cindex Synchronization, OS/2
12363 @cindex OS/2 synchronization primitives
12364
12365 @noindent
12366 This is a child package that provides definitions for interfacing
12367 to the @code{OS/2} synchronization primitives.
12368
12369 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12370 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12371 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12372 @cindex Interfacing, to OS/2
12373 @cindex Thread control, OS/2
12374 @cindex OS/2 thread interfacing
12375
12376 @noindent
12377 This is a child package that provides definitions for interfacing
12378 to the @code{OS/2} thread primitives.
12379
12380 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12381 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12382 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12383 @cindex  IBM Packed Format
12384 @cindex  Packed Decimal
12385
12386 @noindent
12387 This package provides a set of routines for conversions to and
12388 from a packed decimal format compatible with that used on IBM
12389 mainframes.
12390
12391 @node Interfaces.VxWorks (i-vxwork.ads)
12392 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12393 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12394 @cindex Interfacing to VxWorks
12395 @cindex VxWorks, interfacing
12396
12397 @noindent
12398 This package provides a limited binding to the VxWorks API.
12399 In particular, it interfaces with the
12400 VxWorks hardware interrupt facilities.
12401
12402 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12403 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12404 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12405 @cindex Interfacing to VxWorks' I/O
12406 @cindex VxWorks, I/O interfacing
12407 @cindex VxWorks, Get_Immediate
12408 @cindex Get_Immediate, VxWorks
12409
12410 @noindent
12411 This package provides a binding to the ioctl (IO/Control)
12412 function of VxWorks, defining a set of option values and
12413 function codes. A particular use of this package is
12414 to enable the use of Get_Immediate under VxWorks.
12415
12416 @node System.Address_Image (s-addima.ads)
12417 @section @code{System.Address_Image} (@file{s-addima.ads})
12418 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12419 @cindex Address image
12420 @cindex Image, of an address
12421
12422 @noindent
12423 This function provides a useful debugging
12424 function that gives an (implementation dependent)
12425 string which identifies an address.
12426
12427 @node System.Assertions (s-assert.ads)
12428 @section @code{System.Assertions} (@file{s-assert.ads})
12429 @cindex @code{System.Assertions} (@file{s-assert.ads})
12430 @cindex Assertions
12431 @cindex Assert_Failure, exception
12432
12433 @noindent
12434 This package provides the declaration of the exception raised
12435 by an run-time assertion failure, as well as the routine that
12436 is used internally to raise this assertion.
12437
12438 @node System.Memory (s-memory.ads)
12439 @section @code{System.Memory} (@file{s-memory.ads})
12440 @cindex @code{System.Memory} (@file{s-memory.ads})
12441 @cindex Memory allocation
12442
12443 @noindent
12444 This package provides the interface to the low level routines used
12445 by the generated code for allocation and freeing storage for the
12446 default storage pool (analogous to the C routines malloc and free.
12447 It also provides a reallocation interface analogous to the C routine
12448 realloc. The body of this unit may be modified to provide alternative
12449 allocation mechanisms for the default pool, and in addition, direct
12450 calls to this unit may be made for low level allocation uses (for
12451 example see the body of @code{GNAT.Tables}).
12452
12453 @node System.Partition_Interface (s-parint.ads)
12454 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12455 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12456 @cindex Partition intefacing functions
12457
12458 @noindent
12459 This package provides facilities for partition interfacing.  It
12460 is used primarily in a distribution context when using Annex E
12461 with @code{GLADE}.
12462
12463 @node System.Restrictions (s-restri.ads)
12464 @section @code{System.Restrictions} (@file{s-restri.ads})
12465 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12466 @cindex Run-time restrictions access
12467
12468 @noindent
12469 This package provides facilities for accessing at run-time
12470 the status of restrictions specified at compile time for
12471 the partition. Information is available both with regard
12472 to actual restrictions specified, and with regard to
12473 compiler determined information on which restrictions
12474 are violated by one or more packages in the partition.
12475
12476 @node System.Rident (s-rident.ads)
12477 @section @code{System.Rident} (@file{s-rident.ads})
12478 @cindex @code{System.Rident} (@file{s-rident.ads})
12479 @cindex Restrictions definitions
12480
12481 @noindent
12482 This package provides definitions of the restrictions
12483 identifiers supported by GNAT, and also the format of
12484 the restrictions provided in package System.Restrictions.
12485 It is not normally necessary to @code{with} this generic package
12486 since the necessary instantiation is included in
12487 package System.Restrictions.
12488
12489 @node System.Task_Info (s-tasinf.ads)
12490 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12491 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12492 @cindex Task_Info pragma
12493
12494 @noindent
12495 This package provides target dependent functionality that is used
12496 to support the @code{Task_Info} pragma
12497
12498 @node System.Wch_Cnv (s-wchcnv.ads)
12499 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12500 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12501 @cindex Wide Character, Representation
12502 @cindex Wide String, Conversion
12503 @cindex Representation of wide characters
12504
12505 @noindent
12506 This package provides routines for converting between
12507 wide characters and a representation as a value of type
12508 @code{Standard.String}, using a specified wide character
12509 encoding method.  It uses definitions in
12510 package @code{System.Wch_Con}.
12511
12512 @node System.Wch_Con (s-wchcon.ads)
12513 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12514 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12515
12516 @noindent
12517 This package provides definitions and descriptions of
12518 the various methods used for encoding wide characters
12519 in ordinary strings.  These definitions are used by
12520 the package @code{System.Wch_Cnv}.
12521
12522 @node Interfacing to Other Languages
12523 @chapter Interfacing to Other Languages
12524 @noindent
12525 The facilities in annex B of the Ada 95 Reference Manual are fully
12526 implemented in GNAT, and in addition, a full interface to C++ is
12527 provided.
12528
12529 @menu
12530 * Interfacing to C::
12531 * Interfacing to C++::
12532 * Interfacing to COBOL::
12533 * Interfacing to Fortran::
12534 * Interfacing to non-GNAT Ada code::
12535 @end menu
12536
12537 @node Interfacing to C
12538 @section Interfacing to C
12539
12540 @noindent
12541 Interfacing to C with GNAT can use one of two approaches:
12542
12543 @itemize @bullet
12544 @item
12545 The types in the package @code{Interfaces.C} may be used.
12546 @item
12547 Standard Ada types may be used directly.  This may be less portable to
12548 other compilers, but will work on all GNAT compilers, which guarantee
12549 correspondence between the C and Ada types.
12550 @end itemize
12551
12552 @noindent
12553 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12554 effect, since this is the default.  The following table shows the
12555 correspondence between Ada scalar types and the corresponding C types.
12556
12557 @table @code
12558 @item Integer
12559 @code{int}
12560 @item Short_Integer
12561 @code{short}
12562 @item Short_Short_Integer
12563 @code{signed char}
12564 @item Long_Integer
12565 @code{long}
12566 @item Long_Long_Integer
12567 @code{long long}
12568 @item Short_Float
12569 @code{float}
12570 @item Float
12571 @code{float}
12572 @item Long_Float
12573 @code{double}
12574 @item Long_Long_Float
12575 This is the longest floating-point type supported by the hardware.
12576 @end table
12577
12578 @noindent
12579 Additionally, there are the following general correspondences between Ada
12580 and C types:
12581 @itemize @bullet
12582 @item
12583 Ada enumeration types map to C enumeration types directly if pragma
12584 @code{Convention C} is specified, which causes them to have int
12585 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12586 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12587 @code{int}, respectively) depending on the number of values passed.
12588 This is the only case in which pragma @code{Convention C} affects the
12589 representation of an Ada type.
12590
12591 @item
12592 Ada access types map to C pointers, except for the case of pointers to
12593 unconstrained types in Ada, which have no direct C equivalent.
12594
12595 @item
12596 Ada arrays map directly to C arrays.
12597
12598 @item
12599 Ada records map directly to C structures.
12600
12601 @item
12602 Packed Ada records map to C structures where all members are bit fields
12603 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12604 @end itemize
12605
12606 @node Interfacing to C++
12607 @section Interfacing to C++
12608
12609 @noindent
12610 The interface to C++ makes use of the following pragmas, which are
12611 primarily intended to be constructed automatically using a binding generator
12612 tool, although it is possible to construct them by hand.  No suitable binding
12613 generator tool is supplied with GNAT though.
12614
12615 Using these pragmas it is possible to achieve complete
12616 inter-operability between Ada tagged types and C class definitions.
12617 See @ref{Implementation Defined Pragmas}, for more details.
12618
12619 @table @code
12620 @item pragma CPP_Class ([Entity =>] @var{local_name})
12621 The argument denotes an entity in the current declarative region that is
12622 declared as a tagged or untagged record type.  It indicates that the type
12623 corresponds to an externally declared C++ class type, and is to be laid
12624 out the same way that C++ would lay out the type.
12625
12626 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12627 This pragma identifies an imported function (imported in the usual way
12628 with pragma @code{Import}) as corresponding to a C++ constructor.
12629
12630 @item pragma CPP_Vtable @dots{}
12631 One @code{CPP_Vtable} pragma can be present for each component of type
12632 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12633 applies.
12634 @end table
12635
12636 @node Interfacing to COBOL
12637 @section Interfacing to COBOL
12638
12639 @noindent
12640 Interfacing to COBOL is achieved as described in section B.4 of
12641 the Ada 95 reference manual.
12642
12643 @node Interfacing to Fortran
12644 @section Interfacing to Fortran
12645
12646 @noindent
12647 Interfacing to Fortran is achieved as described in section B.5 of the
12648 reference manual.  The pragma @code{Convention Fortran}, applied to a
12649 multi-dimensional array causes the array to be stored in column-major
12650 order as required for convenient interface to Fortran.
12651
12652 @node Interfacing to non-GNAT Ada code
12653 @section Interfacing to non-GNAT Ada code
12654
12655 It is possible to specify the convention @code{Ada} in a pragma
12656 @code{Import} or pragma @code{Export}.  However this refers to
12657 the calling conventions used by GNAT, which may or may not be
12658 similar enough to those used by some other Ada 83 or Ada 95
12659 compiler to allow interoperation.
12660
12661 If arguments types are kept simple, and if the foreign compiler generally
12662 follows system calling conventions, then it may be possible to integrate
12663 files compiled by other Ada compilers, provided that the elaboration
12664 issues are adequately addressed (for example by eliminating the
12665 need for any load time elaboration).
12666
12667 In particular, GNAT running on VMS is designed to
12668 be highly compatible with the DEC Ada 83 compiler, so this is one
12669 case in which it is possible to import foreign units of this type,
12670 provided that the data items passed are restricted to simple scalar
12671 values or simple record types without variants, or simple array
12672 types with fixed bounds.
12673
12674 @node Specialized Needs Annexes
12675 @chapter Specialized Needs Annexes
12676
12677 @noindent
12678 Ada 95 defines a number of specialized needs annexes, which are not
12679 required in all implementations.  However, as described in this chapter,
12680 GNAT implements all of these special needs annexes:
12681
12682 @table @asis
12683 @item Systems Programming (Annex C)
12684 The Systems Programming Annex is fully implemented.
12685
12686 @item Real-Time Systems (Annex D)
12687 The Real-Time Systems Annex is fully implemented.
12688
12689 @item Distributed Systems (Annex E)
12690 Stub generation is fully implemented in the GNAT compiler.  In addition,
12691 a complete compatible PCS is available as part of the GLADE system,
12692 a separate product.  When the two
12693 products are used in conjunction, this annex is fully implemented.
12694
12695 @item Information Systems (Annex F)
12696 The Information Systems annex is fully implemented.
12697
12698 @item Numerics (Annex G)
12699 The Numerics Annex is fully implemented.
12700
12701 @item Safety and Security (Annex H)
12702 The Safety and Security annex is fully implemented.
12703 @end table
12704
12705 @node Implementation of Specific Ada Features
12706 @chapter Implementation of Specific Ada Features
12707
12708 @noindent
12709 This chapter describes the GNAT implementation of several Ada language
12710 facilities.
12711
12712 @menu
12713 * Machine Code Insertions::
12714 * GNAT Implementation of Tasking::
12715 * GNAT Implementation of Shared Passive Packages::
12716 * Code Generation for Array Aggregates::
12717 @end menu
12718
12719 @node Machine Code Insertions
12720 @section Machine Code Insertions
12721
12722 @noindent
12723 Package @code{Machine_Code} provides machine code support as described
12724 in the Ada 95 Reference Manual in two separate forms:
12725 @itemize @bullet
12726 @item
12727 Machine code statements, consisting of qualified expressions that
12728 fit the requirements of RM section 13.8.
12729 @item
12730 An intrinsic callable procedure, providing an alternative mechanism of
12731 including machine instructions in a subprogram.
12732 @end itemize
12733
12734 @noindent
12735 The two features are similar, and both are closely related to the mechanism
12736 provided by the asm instruction in the GNU C compiler.  Full understanding
12737 and use of the facilities in this package requires understanding the asm
12738 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12739 by Richard Stallman. The relevant section is titled ``Extensions to the C
12740 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12741
12742 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12743 semantic restrictions and effects as described below.  Both are provided so
12744 that the procedure call can be used as a statement, and the function call
12745 can be used to form a code_statement.
12746
12747 The first example given in the GCC documentation is the C @code{asm}
12748 instruction:
12749 @smallexample
12750    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12751 @end smallexample
12752
12753 @noindent
12754 The equivalent can be written for GNAT as:
12755
12756 @smallexample @c ada
12757 Asm ("fsinx %1 %0",
12758      My_Float'Asm_Output ("=f", result),
12759      My_Float'Asm_Input  ("f",  angle));
12760 @end smallexample
12761
12762 @noindent
12763 The first argument to @code{Asm} is the assembler template, and is
12764 identical to what is used in GNU C@.  This string must be a static
12765 expression.  The second argument is the output operand list.  It is
12766 either a single @code{Asm_Output} attribute reference, or a list of such
12767 references enclosed in parentheses (technically an array aggregate of
12768 such references).
12769
12770 The @code{Asm_Output} attribute denotes a function that takes two
12771 parameters.  The first is a string, the second is the name of a variable
12772 of the type designated by the attribute prefix.  The first (string)
12773 argument is required to be a static expression and designates the
12774 constraint for the parameter (e.g.@: what kind of register is
12775 required).  The second argument is the variable to be updated with the
12776 result.  The possible values for constraint are the same as those used in
12777 the RTL, and are dependent on the configuration file used to build the
12778 GCC back end.  If there are no output operands, then this argument may
12779 either be omitted, or explicitly given as @code{No_Output_Operands}.
12780
12781 The second argument of @code{@var{my_float}'Asm_Output} functions as
12782 though it were an @code{out} parameter, which is a little curious, but
12783 all names have the form of expressions, so there is no syntactic
12784 irregularity, even though normally functions would not be permitted
12785 @code{out} parameters.  The third argument is the list of input
12786 operands.  It is either a single @code{Asm_Input} attribute reference, or
12787 a list of such references enclosed in parentheses (technically an array
12788 aggregate of such references).
12789
12790 The @code{Asm_Input} attribute denotes a function that takes two
12791 parameters.  The first is a string, the second is an expression of the
12792 type designated by the prefix.  The first (string) argument is required
12793 to be a static expression, and is the constraint for the parameter,
12794 (e.g.@: what kind of register is required).  The second argument is the
12795 value to be used as the input argument.  The possible values for the
12796 constant are the same as those used in the RTL, and are dependent on
12797 the configuration file used to built the GCC back end.
12798
12799 If there are no input operands, this argument may either be omitted, or
12800 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12801 present in the above example, is a list of register names, called the
12802 @dfn{clobber} argument.  This argument, if given, must be a static string
12803 expression, and is a space or comma separated list of names of registers
12804 that must be considered destroyed as a result of the @code{Asm} call.  If
12805 this argument is the null string (the default value), then the code
12806 generator assumes that no additional registers are destroyed.
12807
12808 The fifth argument, not present in the above example, called the
12809 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12810 the literal value @code{True} to indicate to the code generator that all
12811 optimizations with respect to the instruction specified should be
12812 suppressed, and that in particular, for an instruction that has outputs,
12813 the instruction will still be generated, even if none of the outputs are
12814 used.  See the full description in the GCC manual for further details.
12815
12816 The @code{Asm} subprograms may be used in two ways.  First the procedure
12817 forms can be used anywhere a procedure call would be valid, and
12818 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12819 be used to intersperse machine instructions with other Ada statements.
12820 Second, the function forms, which return a dummy value of the limited
12821 private type @code{Asm_Insn}, can be used in code statements, and indeed
12822 this is the only context where such calls are allowed.  Code statements
12823 appear as aggregates of the form:
12824
12825 @smallexample @c ada
12826 Asm_Insn'(Asm (@dots{}));
12827 Asm_Insn'(Asm_Volatile (@dots{}));
12828 @end smallexample
12829
12830 @noindent
12831 In accordance with RM rules, such code statements are allowed only
12832 within subprograms whose entire body consists of such statements.  It is
12833 not permissible to intermix such statements with other Ada statements.
12834
12835 Typically the form using intrinsic procedure calls is more convenient
12836 and more flexible.  The code statement form is provided to meet the RM
12837 suggestion that such a facility should be made available.  The following
12838 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12839 is used, the arguments may be given in arbitrary order, following the
12840 normal rules for use of positional and named arguments)
12841
12842 @smallexample
12843 ASM_CALL ::= Asm (
12844                  [Template =>] static_string_EXPRESSION
12845                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12846                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12847                [,[Clobber  =>] static_string_EXPRESSION ]
12848                [,[Volatile =>] static_boolean_EXPRESSION] )
12849
12850 OUTPUT_OPERAND_LIST ::=
12851   [PREFIX.]No_Output_Operands
12852 | OUTPUT_OPERAND_ATTRIBUTE
12853 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12854
12855 OUTPUT_OPERAND_ATTRIBUTE ::=
12856   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12857
12858 INPUT_OPERAND_LIST ::=
12859   [PREFIX.]No_Input_Operands
12860 | INPUT_OPERAND_ATTRIBUTE
12861 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12862
12863 INPUT_OPERAND_ATTRIBUTE ::=
12864   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12865 @end smallexample
12866
12867 @noindent
12868 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12869 are declared in the package @code{Machine_Code} and must be referenced
12870 according to normal visibility rules. In particular if there is no
12871 @code{use} clause for this package, then appropriate package name
12872 qualification is required.
12873
12874 @node GNAT Implementation of Tasking
12875 @section GNAT Implementation of Tasking
12876
12877 @noindent
12878 This chapter outlines the basic GNAT approach to tasking (in particular,
12879 a multi-layered library for portability) and discusses issues related
12880 to compliance with the Real-Time Systems Annex.
12881
12882 @menu
12883 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12884 * Ensuring Compliance with the Real-Time Annex::
12885 @end menu
12886
12887 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12888 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12889
12890 @noindent
12891 GNAT's run-time support comprises two layers:
12892
12893 @itemize @bullet
12894 @item GNARL (GNAT Run-time Layer)
12895 @item GNULL (GNAT Low-level Library)
12896 @end itemize
12897
12898 @noindent
12899 In GNAT, Ada's tasking services rely on a platform and OS independent
12900 layer known as GNARL@.  This code is responsible for implementing the
12901 correct semantics of Ada's task creation, rendezvous, protected
12902 operations etc.
12903
12904 GNARL decomposes Ada's tasking semantics into simpler lower level
12905 operations such as create a thread, set the priority of a thread,
12906 yield, create a lock, lock/unlock, etc.  The spec for these low-level
12907 operations constitutes GNULLI, the GNULL Interface.  This interface is
12908 directly inspired from the POSIX real-time API@.
12909
12910 If the underlying executive or OS implements the POSIX standard
12911 faithfully, the GNULL Interface maps as is to the services offered by
12912 the underlying kernel.  Otherwise, some target dependent glue code maps
12913 the services offered by the underlying kernel to the semantics expected
12914 by GNARL@.
12915
12916 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
12917 key point is that each Ada task is mapped on a thread in the underlying
12918 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
12919
12920 In addition Ada task priorities map onto the underlying thread priorities.
12921 Mapping Ada tasks onto the underlying kernel threads has several advantages:
12922
12923 @itemize @bullet
12924 @item
12925 The underlying scheduler is used to schedule the Ada tasks.  This
12926 makes Ada tasks as efficient as kernel threads from a scheduling
12927 standpoint.
12928
12929 @item
12930 Interaction with code written in C containing threads is eased
12931 since at the lowest level Ada tasks and C threads map onto the same
12932 underlying kernel concept.
12933
12934 @item
12935 When an Ada task is blocked during I/O the remaining Ada tasks are
12936 able to proceed.
12937
12938 @item
12939 On multiprocessor systems Ada tasks can execute in parallel.
12940 @end itemize
12941
12942 @noindent
12943 Some threads libraries offer a mechanism to fork a new process, with the
12944 child process duplicating the threads from the parent.
12945 GNAT does not
12946 support this functionality when the parent contains more than one task.
12947 @cindex Forking a new process
12948
12949 @node Ensuring Compliance with the Real-Time Annex
12950 @subsection Ensuring Compliance with the Real-Time Annex
12951 @cindex Real-Time Systems Annex compliance
12952
12953 @noindent
12954 Although mapping Ada tasks onto
12955 the underlying threads has significant advantages, it does create some
12956 complications when it comes to respecting the scheduling semantics
12957 specified in the real-time annex (Annex D).
12958
12959 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
12960 scheduling policy states:
12961
12962 @quotation
12963 @emph{When the active priority of a ready task that is not running
12964 changes, or the setting of its base priority takes effect, the
12965 task is removed from the ready queue for its old active priority
12966 and is added at the tail of the ready queue for its new active
12967 priority, except in the case where the active priority is lowered
12968 due to the loss of inherited priority, in which case the task is
12969 added at the head of the ready queue for its new active priority.}
12970 @end quotation
12971
12972 @noindent
12973 While most kernels do put tasks at the end of the priority queue when
12974 a task changes its priority, (which respects the main
12975 FIFO_Within_Priorities requirement), almost none keep a thread at the
12976 beginning of its priority queue when its priority drops from the loss
12977 of inherited priority.
12978
12979 As a result most vendors have provided incomplete Annex D implementations.
12980
12981 The GNAT run-time, has a nice cooperative solution to this problem
12982 which ensures that accurate FIFO_Within_Priorities semantics are
12983 respected.
12984
12985 The principle is as follows.  When an Ada task T is about to start
12986 running, it checks whether some other Ada task R with the same
12987 priority as T has been suspended due to the loss of priority
12988 inheritance.  If this is the case, T yields and is placed at the end of
12989 its priority queue.  When R arrives at the front of the queue it
12990 executes.
12991
12992 Note that this simple scheme preserves the relative order of the tasks
12993 that were ready to execute in the priority queue where R has been
12994 placed at the end.
12995
12996 @node GNAT Implementation of Shared Passive Packages
12997 @section GNAT Implementation of Shared Passive Packages
12998 @cindex Shared passive packages
12999
13000 @noindent
13001 GNAT fully implements the pragma @code{Shared_Passive} for
13002 @cindex pragma @code{Shared_Passive}
13003 the purpose of designating shared passive packages.
13004 This allows the use of passive partitions in the
13005 context described in the Ada Reference Manual; i.e. for communication
13006 between separate partitions of a distributed application using the
13007 features in Annex E.
13008 @cindex Annex E
13009 @cindex Distribution Systems Annex
13010
13011 However, the implementation approach used by GNAT provides for more
13012 extensive usage as follows:
13013
13014 @table @emph
13015 @item Communication between separate programs
13016
13017 This allows separate programs to access the data in passive
13018 partitions, using protected objects for synchronization where
13019 needed. The only requirement is that the two programs have a
13020 common shared file system. It is even possible for programs
13021 running on different machines with different architectures
13022 (e.g. different endianness) to communicate via the data in
13023 a passive partition.
13024
13025 @item Persistence between program runs
13026
13027 The data in a passive package can persist from one run of a
13028 program to another, so that a later program sees the final
13029 values stored by a previous run of the same program.
13030
13031 @end table
13032
13033 @noindent
13034 The implementation approach used is to store the data in files. A
13035 separate stream file is created for each object in the package, and
13036 an access to an object causes the corresponding file to be read or
13037 written.
13038
13039 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13040 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13041 set to the directory to be used for these files.
13042 The files in this directory
13043 have names that correspond to their fully qualified names. For
13044 example, if we have the package
13045
13046 @smallexample @c ada
13047 package X is
13048   pragma Shared_Passive (X);
13049   Y : Integer;
13050   Z : Float;
13051 end X;
13052 @end smallexample
13053
13054 @noindent
13055 and the environment variable is set to @code{/stemp/}, then the files created
13056 will have the names:
13057
13058 @smallexample
13059 /stemp/x.y
13060 /stemp/x.z
13061 @end smallexample
13062
13063 @noindent
13064 These files are created when a value is initially written to the object, and
13065 the files are retained until manually deleted. This provides the persistence
13066 semantics. If no file exists, it means that no partition has assigned a value
13067 to the variable; in this case the initial value declared in the package
13068 will be used. This model ensures that there are no issues in synchronizing
13069 the elaboration process, since elaboration of passive packages elaborates the
13070 initial values, but does not create the files.
13071
13072 The files are written using normal @code{Stream_IO} access.
13073 If you want to be able
13074 to communicate between programs or partitions running on different
13075 architectures, then you should use the XDR versions of the stream attribute
13076 routines, since these are architecture independent.
13077
13078 If active synchronization is required for access to the variables in the
13079 shared passive package, then as described in the Ada Reference Manual, the
13080 package may contain protected objects used for this purpose. In this case
13081 a lock file (whose name is @file{___lock} (three underscores)
13082 is created in the shared memory directory.
13083 @cindex @file{___lock} file (for shared passive packages)
13084 This is used to provide the required locking
13085 semantics for proper protected object synchronization.
13086
13087 As of January 2003, GNAT supports shared passive packages on all platforms
13088 except for OpenVMS.
13089
13090 @node Code Generation for Array Aggregates
13091 @section Code Generation for Array Aggregates
13092
13093 @menu
13094 * Static constant aggregates with static bounds::
13095 * Constant aggregates with an unconstrained nominal types::
13096 * Aggregates with static bounds::
13097 * Aggregates with non-static bounds::
13098 * Aggregates in assignment statements::
13099 @end menu
13100
13101 @noindent
13102 Aggregate have a rich syntax and allow the user to specify the values of
13103 complex data structures by means of a single construct.  As a result, the
13104 code generated for aggregates can be quite complex and involve loops, case
13105 statements and multiple assignments.  In the simplest cases, however, the
13106 compiler will recognize aggregates whose components and constraints are
13107 fully static, and in those cases the compiler will generate little or no
13108 executable code.  The following is an outline of the code that GNAT generates
13109 for various aggregate constructs.  For further details, the user will find it
13110 useful to examine the output produced by the -gnatG flag to see the expanded
13111 source that is input to the code generator.  The user will also want to examine
13112 the assembly code generated at various levels of optimization.
13113
13114 The code generated for aggregates depends on the context, the component values,
13115 and the type.  In the context of an object declaration the code generated is
13116 generally simpler than in the case of an assignment.  As a general rule, static
13117 component values and static subtypes also lead to simpler code.
13118
13119 @node Static constant aggregates with static bounds
13120 @subsection Static constant aggregates with static bounds
13121
13122 @noindent
13123 For the declarations:
13124 @smallexample @c ada
13125     type One_Dim is array (1..10) of integer;
13126     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13127 @end smallexample
13128
13129 @noindent
13130 GNAT generates no executable code: the constant ar0 is placed in static memory.
13131 The same is true for constant aggregates with named associations:
13132
13133 @smallexample @c ada
13134     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13135     Cr3 : constant One_Dim := (others => 7777);
13136 @end smallexample
13137
13138 @noindent
13139 The same is true for multidimensional constant arrays such as:
13140
13141 @smallexample @c ada
13142     type two_dim is array (1..3, 1..3) of integer;
13143     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13144 @end smallexample
13145
13146 @noindent
13147 The same is true for arrays of one-dimensional arrays: the following are
13148 static:
13149
13150 @smallexample @c ada
13151 type ar1b  is array (1..3) of boolean;
13152 type ar_ar is array (1..3) of ar1b;
13153 None  : constant ar1b := (others => false);     --  fully static
13154 None2 : constant ar_ar := (1..3 => None);       --  fully static
13155 @end smallexample
13156
13157 @noindent
13158 However, for multidimensional aggregates with named associations, GNAT will
13159 generate assignments and loops, even if all associations are static.  The
13160 following two declarations generate a loop for the first dimension, and
13161 individual component assignments for the second dimension:
13162
13163 @smallexample @c ada
13164 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13165 Zero2: constant two_dim := (others => (others => 0));
13166 @end smallexample
13167
13168 @node Constant aggregates with an unconstrained nominal types
13169 @subsection Constant aggregates with an unconstrained nominal types
13170
13171 @noindent
13172 In such cases the aggregate itself establishes the subtype, so that
13173 associations with @code{others} cannot be used.  GNAT determines the
13174 bounds for the actual subtype of the aggregate, and allocates the
13175 aggregate statically as well.  No code is generated for the following:
13176
13177 @smallexample @c ada
13178     type One_Unc is array (natural range <>) of integer;
13179     Cr_Unc : constant One_Unc := (12,24,36);
13180 @end smallexample
13181
13182 @node Aggregates with static bounds
13183 @subsection Aggregates with static bounds
13184
13185 @noindent
13186 In all previous examples the aggregate was the initial (and immutable) value
13187 of a constant.  If the aggregate initializes a variable, then code is generated
13188 for it as a combination of individual assignments and loops over the target
13189 object.  The declarations
13190
13191 @smallexample @c ada
13192        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13193        Cr_Var2 : One_Dim := (others > -1);
13194 @end smallexample
13195
13196 @noindent
13197 generate the equivalent of
13198
13199 @smallexample @c ada
13200        Cr_Var1 (1) := 2;
13201        Cr_Var1 (2) := 3;
13202        Cr_Var1 (3) := 5;
13203        Cr_Var1 (4) := 11;
13204
13205        for I in Cr_Var2'range loop
13206           Cr_Var2 (I) := =-1;
13207        end loop;
13208 @end smallexample
13209
13210 @node Aggregates with non-static bounds
13211 @subsection Aggregates with non-static bounds
13212
13213 @noindent
13214 If the bounds of the aggregate are not statically compatible with the bounds
13215 of the nominal subtype  of the target, then constraint checks have to be
13216 generated on the bounds.  For a multidimensional array, constraint checks may
13217 have to be applied to sub-arrays individually, if they do not have statically
13218 compatible subtypes.
13219
13220 @node Aggregates in assignment statements
13221 @subsection Aggregates in assignment statements
13222
13223 @noindent
13224 In general, aggregate assignment requires the construction of a temporary,
13225 and a copy from the temporary to the target of the assignment.  This is because
13226 it is not always possible to convert the assignment into a series of individual
13227 component assignments.  For example, consider the simple case:
13228
13229 @smallexample @c ada
13230         A := (A(2), A(1));
13231 @end smallexample
13232
13233 @noindent
13234 This cannot be converted into:
13235
13236 @smallexample @c ada
13237         A(1) := A(2);
13238         A(2) := A(1);
13239 @end smallexample
13240
13241 @noindent
13242 So the aggregate has to be built first in a separate location, and then
13243 copied into the target.  GNAT recognizes simple cases where this intermediate
13244 step is not required, and the assignments can be performed in place, directly
13245 into the target.  The following sufficient criteria are applied:
13246
13247 @itemize @bullet
13248 @item
13249 The bounds of the aggregate are static, and the associations are static.
13250 @item
13251 The components of the aggregate are static constants, names of
13252 simple variables that are not renamings, or expressions not involving
13253 indexed components whose operands obey these rules.
13254 @end itemize
13255
13256 @noindent
13257 If any of these conditions are violated, the aggregate will be built in
13258 a temporary (created either by the front-end or the code generator) and then
13259 that temporary will be copied onto the target.
13260
13261 @node Project File Reference
13262 @chapter Project File Reference
13263
13264 @noindent
13265 This chapter describes the syntax and semantics of project files.
13266 Project files specify the options to be used when building a system.
13267 Project files can specify global settings for all tools,
13268 as well as tool-specific settings.
13269 See the chapter on project files in the GNAT Users guide for examples of use.
13270
13271 @menu
13272 * Reserved Words::
13273 * Lexical Elements::
13274 * Declarations::
13275 * Typed string declarations::
13276 * Variables::
13277 * Expressions::
13278 * Attributes::
13279 * Project Attributes::
13280 * Attribute References::
13281 * External Values::
13282 * Case Construction::
13283 * Packages::
13284 * Package Renamings::
13285 * Projects::
13286 * Project Extensions::
13287 * Project File Elaboration::
13288 @end menu
13289
13290 @node Reserved Words
13291 @section Reserved Words
13292
13293 @noindent
13294 All Ada95 reserved words are reserved in project files, and cannot be used
13295 as variable names or project names. In addition, the following are
13296 also reserved in project files:
13297
13298 @itemize
13299 @item @code{extends}
13300
13301 @item @code{external}
13302
13303 @item @code{project}
13304
13305 @end itemize
13306
13307 @node Lexical Elements
13308 @section Lexical Elements
13309
13310 @noindent
13311 Rules for identifiers are the same as in Ada95. Identifiers
13312 are case-insensitive.  Strings are case sensitive, except where noted.
13313 Comments have the same form as in Ada95.
13314
13315 @noindent
13316 Syntax:
13317
13318 @smallexample
13319 simple_name ::=
13320   identifier
13321
13322 name ::=
13323   simple_name @{. simple_name@}
13324 @end smallexample
13325
13326 @node Declarations
13327 @section Declarations
13328
13329 @noindent
13330 Declarations introduce new entities that denote types, variables, attributes,
13331 and packages. Some declarations can only appear immediately within a project
13332 declaration. Others can appear within a project or within a package.
13333
13334 Syntax:
13335 @smallexample
13336 declarative_item ::=
13337   simple_declarative_item |
13338   typed_string_declaration |
13339   package_declaration
13340
13341 simple_declarative_item ::=
13342   variable_declaration |
13343   typed_variable_declaration |
13344   attribute_declaration |
13345   case_construction
13346 @end smallexample
13347
13348 @node Typed string declarations
13349 @section Typed string declarations
13350
13351 @noindent
13352 Typed strings are sequences of string literals. Typed strings are the only
13353 named types in project files. They are used in case constructions, where they
13354 provide support for conditional attribute definitions.
13355
13356 Syntax:
13357 @smallexample
13358 typed_string_declaration ::=
13359   @b{type} <typed_string_>_simple_name @b{is}
13360    ( string_literal @{, string_literal@} );
13361 @end smallexample
13362
13363 @noindent
13364 A typed string declaration can only appear immediately within a project
13365 declaration.
13366
13367 All the string literals in a typed string declaration must be distinct.
13368
13369 @node Variables
13370 @section Variables
13371
13372 @noindent
13373 Variables denote values, and appear as constituents of expressions.
13374
13375 @smallexample
13376 typed_variable_declaration ::=
13377   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13378
13379 variable_declaration ::=
13380   <variable_>simple_name := expression;
13381 @end smallexample
13382
13383 @noindent
13384 The elaboration of a variable declaration introduces the variable and
13385 assigns to it the value of the expression. The name of the variable is
13386 available after the assignment symbol.
13387
13388 @noindent
13389 A typed_variable can only be declare once.
13390
13391 @noindent
13392 a non typed variable can be declared multiple times.
13393
13394 @noindent
13395 Before the completion of its first declaration, the value of variable
13396 is the null string.
13397
13398 @node Expressions
13399 @section Expressions
13400
13401 @noindent
13402 An expression is a formula that defines a computation or retrieval of a value.
13403 In a project file the value of an expression is either a string or a list
13404 of strings. A string value in an expression is either a literal, the current
13405 value of a variable, an external value, an attribute reference, or a
13406 concatenation operation.
13407
13408 Syntax:
13409
13410 @smallexample
13411 expression ::=
13412   term @{& term@}
13413
13414 term ::=
13415   string_literal |
13416   string_list |
13417   <variable_>name |
13418   external_value |
13419   attribute_reference
13420
13421 string_literal ::=
13422   (same as Ada)
13423
13424 string_list ::=
13425   ( <string_>expression @{ , <string_>expression @} )
13426 @end smallexample
13427
13428 @subsection Concatenation
13429 @noindent
13430 The following concatenation functions are defined:
13431
13432 @smallexample @c ada
13433   function "&" (X : String;      Y : String)      return String;
13434   function "&" (X : String_List; Y : String)      return String_List;
13435   function "&" (X : String_List; Y : String_List) return String_List;
13436 @end smallexample
13437
13438 @node Attributes
13439 @section Attributes
13440
13441 @noindent
13442 An attribute declaration defines a property of a project or package. This
13443 property can later be queried by means of an attribute reference.
13444 Attribute values are strings or string lists.
13445
13446 Some attributes are associative arrays. These attributes are mappings whose
13447 domain is a set of strings. These attributes are declared one association
13448 at a time, by specifying a point in the domain and the corresponding image
13449 of the attribute. They may also be declared as a full associative array,
13450 getting the same associations as the corresponding attribute in an imported
13451 or extended project.
13452
13453 Attributes that are not associative arrays are called simple attributes.
13454
13455 Syntax:
13456 @smallexample
13457 attribute_declaration ::=
13458   full_associative_array_declaration |
13459   @b{for} attribute_designator @b{use} expression ;
13460
13461 full_associative_array_declaration ::=
13462   @b{for} <associative_array_attribute_>simple_name @b{use}
13463   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13464
13465 attribute_designator ::=
13466   <simple_attribute_>simple_name |
13467   <associative_array_attribute_>simple_name ( string_literal )
13468 @end smallexample
13469
13470 @noindent
13471 Some attributes are project-specific, and can only appear immediately within
13472 a project declaration. Others are package-specific, and can only appear within
13473 the proper package.
13474
13475 The expression in an attribute definition must be a string or a string_list.
13476 The string literal appearing in the attribute_designator of an associative
13477 array attribute is case-insensitive.
13478
13479 @node Project Attributes
13480 @section Project Attributes
13481
13482 @noindent
13483 The following attributes apply to a project. All of them are simple
13484 attributes.
13485
13486 @table @code
13487 @item   Object_Dir
13488 Expression must be a path name. The attribute defines the
13489 directory in which the object files created by the build are to be placed. If
13490 not specified, object files are placed in the project directory.
13491
13492 @item   Exec_Dir
13493 Expression must be a path name. The attribute defines the
13494 directory in which the executables created by the build are to be placed.
13495 If not specified, executables are placed in the object directory.
13496
13497 @item  Source_Dirs
13498 Expression must be a list of path names. The attribute
13499 defines the directories in which the source files for the project are to be
13500 found. If not specified, source files are found in the project directory.
13501
13502 @item  Source_Files
13503 Expression must be a list of file names. The attribute
13504 defines the individual files, in the project directory, which are to be used
13505 as sources for the project. File names are path_names that contain no directory
13506 information. If the project has no sources the attribute must be declared
13507 explicitly with an empty list.
13508
13509 @item  Source_List_File
13510 Expression must a single path name. The attribute
13511 defines a text file that contains a list of source file names to be used
13512 as sources for the project
13513
13514 @item  Library_Dir
13515 Expression must be a path name. The attribute defines the
13516 directory in which a  library is to be built.  The directory must exist, must
13517 be distinct from the project's object directory, and must be writable.
13518
13519 @item  Library_Name
13520 Expression must be a string that is a legal file name,
13521 without extension. The attribute defines a string that is used to generate
13522 the name of the library to be built by the project.
13523
13524 @item  Library_Kind
13525 Argument must be a string value that must be one of the
13526 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13527 string is case-insensitive. If this attribute is not specified, the library is
13528 a static library. Otherwise, the library may be dynamic or relocatable. This
13529 distinction is operating-system dependent.
13530
13531 @item  Library_Version
13532 Expression must be a string value whose interpretation
13533 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13534 libraries as the internal name of the library (the @code{"soname"}). If the
13535 library file name (built from the @code{Library_Name}) is different from the
13536 @code{Library_Version}, then the library file will be a symbolic link to the
13537 actual file whose name will be @code{Library_Version}.
13538
13539 @item Library_Interface
13540 Expression must be a string list. Each element of the string list
13541 must designate a unit of the project.
13542 If this attribute is present in a Library Project File, then the project
13543 file is a Stand-alone Library_Project_File.
13544
13545 @item Library_Auto_Init
13546 Expression must be a single string "true" or "false", case-insensitive.
13547 If this attribute is present in a Stand-alone Library Project File,
13548 it indicates if initialization is automatic when the dynamic library
13549 is loaded.
13550
13551 @item Library_Options
13552 Expression must be a string list. Indicates additional switches that
13553 are to be used when building a shared library.
13554
13555 @item Library_GCC
13556 Expression must be a single string. Designates an alternative to "gcc"
13557 for building shared libraries.
13558
13559 @item  Library_Src_Dir
13560 Expression must be a path name. The attribute defines the
13561 directory in which the sources of the interfaces of a Stand-alone Library will
13562 be copied.  The directory must exist, must be distinct from the project's
13563 object directory and source directories, and must be writable.
13564
13565 @item  Main
13566 Expression must be a list of strings that are legal file names.
13567 These file names designate existing compilation units in the source directory
13568 that are legal main subprograms.
13569
13570 When a project file is elaborated, as part of the execution of a gnatmake
13571 command, one or several executables are built and placed in the Exec_Dir.
13572 If the gnatmake command does not include explicit file names, the executables
13573 that are built correspond to the files specified by this attribute.
13574
13575 @item Main_Language
13576 This is a simple attribute. Its value is a string that specifies the
13577 language of the main program.
13578
13579 @item  Languages
13580 Expression must be a string list. Each string designates
13581 a programming language that is known to GNAT. The strings are case-insensitive.
13582
13583 @item  Locally_Removed_Files
13584 This attribute is legal only in a project file that extends another.
13585 Expression must be a list of strings that are legal file names.
13586 Each file name must designate a source that would normally be inherited
13587 by the current project file. It cannot designate an immediate source that is
13588 not inherited. Each of the source files in the list are not considered to
13589 be sources of the project file: they are not inherited.
13590 @end table
13591
13592 @node Attribute References
13593 @section Attribute References
13594
13595 @noindent
13596 Attribute references are used to retrieve the value of previously defined
13597 attribute for a package or project.
13598 Syntax:
13599 @smallexample
13600 attribute_reference ::=
13601   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13602
13603 attribute_prefix ::=
13604   @b{project} |
13605   <project_simple_name | package_identifier |
13606   <project_>simple_name . package_identifier
13607 @end smallexample
13608
13609 @noindent
13610 If an attribute has not been specified for a given package or project, its
13611 value is the null string or the empty list.
13612
13613 @node External Values
13614 @section External Values
13615
13616 @noindent
13617 An external value is an expression whose value is obtained from the command
13618 that invoked the processing of the current project file (typically a
13619 gnatmake command).
13620
13621 Syntax:
13622 @smallexample
13623 external_value ::=
13624   @b{external} ( string_literal [, string_literal] )
13625 @end smallexample
13626
13627 @noindent
13628 The first string_literal is the string to be used on the command line or
13629 in the environment to specify the external value. The second string_literal,
13630 if present, is the default to use if there is no specification for this
13631 external value either on the command line or in the environment.
13632
13633 @node Case Construction
13634 @section Case Construction
13635
13636 @noindent
13637 A case construction supports attribute declarations that depend on the value of
13638 a previously declared variable.
13639
13640 Syntax:
13641 @smallexample
13642 case_construction ::=
13643   @b{case} <typed_variable_>name @b{is}
13644     @{case_item@}
13645   @b{end case} ;
13646
13647 case_item ::=
13648   @b{when} discrete_choice_list =>
13649     @{case_construction | attribute_declaration@}
13650
13651 discrete_choice_list ::=
13652   string_literal @{| string_literal@} |
13653     @b{others}
13654 @end smallexample
13655
13656 @noindent
13657 All choices in a choice list must be distinct. The choice lists of two
13658 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13659 alternatives do not need to include all values of the type. An @code{others}
13660 choice must appear last in the list of alternatives.
13661
13662 @node Packages
13663 @section Packages
13664
13665 @noindent
13666 A package provides a grouping of variable declarations and attribute
13667 declarations to be used when invoking various GNAT tools. The name of
13668 the package indicates the tool(s) to which it applies.
13669 Syntax:
13670
13671 @smallexample
13672 package_declaration ::=
13673   package_specification | package_renaming
13674
13675 package_specification ::=
13676   @b{package} package_identifier @b{is}
13677     @{simple_declarative_item@}
13678   @b{end} package_identifier ;
13679
13680 package_identifier ::=
13681   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13682   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13683   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13684 @end smallexample
13685
13686 @subsection Package Naming
13687
13688 @noindent
13689 The attributes of a @code{Naming} package specifies the naming conventions
13690 that apply to the source files in a project. When invoking other GNAT tools,
13691 they will use the sources in the source directories that satisfy these
13692 naming conventions.
13693
13694 The following attributes apply to a @code{Naming} package:
13695
13696 @table @code
13697 @item Casing
13698 This is a simple attribute whose value is a string. Legal values of this
13699 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13700 These strings are themselves case insensitive.
13701
13702 @noindent
13703 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13704
13705 @item Dot_Replacement
13706 This is a simple attribute whose string value satisfies the following
13707 requirements:
13708
13709 @itemize @bullet
13710 @item It must not be empty
13711 @item It cannot start or end with an alphanumeric character
13712 @item It cannot be a single underscore
13713 @item It cannot start with an underscore followed by an alphanumeric
13714 @item It cannot contain a dot @code{'.'} if longer than one character
13715 @end itemize
13716
13717 @noindent
13718 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13719
13720 @item Spec_Suffix
13721 This is an associative array attribute, defined on language names,
13722 whose image is a string that must satisfy the following
13723 conditions:
13724
13725 @itemize @bullet
13726 @item It must not be empty
13727 @item It cannot start with an alphanumeric character
13728 @item It cannot start with an underscore followed by an alphanumeric character
13729 @end itemize
13730
13731 @noindent
13732 For Ada, the attribute denotes the suffix used in file names that contain
13733 library unit declarations, that is to say units that are package and
13734 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13735 specified, then the default is @code{".ads"}.
13736
13737 For C and C++, the attribute denotes the suffix used in file names that
13738 contain prototypes.
13739
13740 @item Body_Suffix
13741 This is an associative array attribute defined on language names,
13742 whose image is a string that must satisfy the following
13743 conditions:
13744
13745 @itemize @bullet
13746 @item It must not be empty
13747 @item It cannot start with an alphanumeric character
13748 @item It cannot start with an underscore followed by an alphanumeric character
13749 @item It cannot be a suffix of @code{Spec_Suffix}
13750 @end itemize
13751
13752 @noindent
13753 For Ada, the attribute denotes the suffix used in file names that contain
13754 library bodies, that is to say units that are package and subprogram bodies.
13755 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13756 @code{".adb"}.
13757
13758 For C and C++, the attribute denotes the suffix used in file names that contain
13759 source code.
13760
13761 @item Separate_Suffix
13762 This is a simple attribute whose value satisfies the same conditions as
13763 @code{Body_Suffix}.
13764
13765 This attribute is specific to Ada. It denotes the suffix used in file names
13766 that contain separate bodies. If it is not specified, then it defaults to same
13767 value as @code{Body_Suffix ("Ada")}.
13768
13769 @item Spec
13770 This is an associative array attribute, specific to Ada, defined over
13771 compilation unit names. The image is a string that is the name of the file
13772 that contains that library unit. The file name is case sensitive if the
13773 conventions of the host operating system require it.
13774
13775 @item Body
13776 This is an associative array attribute, specific to Ada, defined over
13777 compilation unit names. The image is a string that is the name of the file
13778 that contains the library unit body for the named unit. The file name is case
13779 sensitive if the conventions of the host operating system require it.
13780
13781 @item Specification_Exceptions
13782 This is an associative array attribute defined on language names,
13783 whose value is a list of strings.
13784
13785 This attribute is not significant for Ada.
13786
13787 For C and C++, each string in the list denotes the name of a file that
13788 contains prototypes, but whose suffix is not necessarily the
13789 @code{Spec_Suffix} for the language.
13790
13791 @item Implementation_Exceptions
13792 This is an associative array attribute defined on language names,
13793 whose value is a list of strings.
13794
13795 This attribute is not significant for Ada.
13796
13797 For C and C++, each string in the list denotes the name of a file that
13798 contains source code, but whose suffix is not necessarily the
13799 @code{Body_Suffix} for the language.
13800 @end table
13801
13802 The following attributes of package @code{Naming} are obsolescent. They are
13803 kept as synonyms of other attributes for compatibility with previous versions
13804 of the Project Manager.
13805
13806 @table @code
13807 @item Specification_Suffix
13808 This is a synonym of @code{Spec_Suffix}.
13809
13810 @item Implementation_Suffix
13811 This is a synonym of @code{Body_Suffix}.
13812
13813 @item Specification
13814 This is a synonym of @code{Spec}.
13815
13816 @item Implementation
13817 This is a synonym of @code{Body}.
13818 @end table
13819
13820 @subsection package Compiler
13821
13822 @noindent
13823 The attributes of the @code{Compiler} package specify the compilation options
13824 to be used by the underlying compiler.
13825
13826 @table @code
13827 @item  Default_Switches
13828 This is an associative array attribute. Its
13829 domain is a set of language names. Its range is a string list that
13830 specifies the compilation options to be used when compiling a component
13831 written in that language, for which no file-specific switches have been
13832 specified..
13833
13834 @item  Switches
13835 This is an associative array attribute. Its domain is
13836 a set of file names. Its range is a string list that specifies the
13837 compilation options to be used when compiling the named file. If a file
13838 is not specified in the Switches attribute, it is compiled with the
13839 settings specified by Default_Switches.
13840
13841 @item  Local_Configuration_Pragmas.
13842 This is a simple attribute, whose
13843 value is a path name that designates a file containing configuration pragmas
13844 to be used for all invocations of the compiler for immediate sources of the
13845 project.
13846
13847 @item Executable
13848 This is an associative array attribute. Its domain is
13849 a set of main source file names. Its range is a simple string that specifies
13850 the executable file name to be used when linking the specified main source.
13851 If a main source is not specified in the Executable attribute, the executable
13852 file name is deducted from the main source file name.
13853 @end table
13854
13855 @subsection package Builder
13856
13857 @noindent
13858 The attributes of package @code{Builder} specify the compilation, binding, and
13859 linking options to be used when building an executable for a project. The
13860 following attributes apply to package @code{Builder}:
13861
13862 @table @code
13863 @item Default_Switches
13864 As above.
13865
13866 @item Switches
13867 As above.
13868
13869 @item Global_Configuration_Pragmas
13870 This is a simple attribute, whose
13871 value is a path name that designates a file that contains configuration pragmas
13872 to be used in every build of an executable. If both local and global
13873 configuration pragmas are specified, a compilation makes use of both sets.
13874
13875 @item Executable
13876 This is an associative array attribute, defined over
13877 compilation unit names. The image is a string that is the name of the
13878 executable file corresponding to the main source file index.
13879 This attribute has no effect if its value is the empty string.
13880
13881 @item Executable_Suffix
13882 This is a simple attribute whose value is a suffix to be added to
13883 the executables that don't have an attribute Executable specified.
13884 @end table
13885
13886 @subsection package Gnatls
13887
13888 @noindent
13889 The attributes of package @code{Gnatls} specify the tool options to be used
13890 when invoking the library browser @command{gnatls}.
13891 The following attributes apply to package @code{Gnatls}:
13892
13893 @table @code
13894 @item Switches
13895 As above.
13896 @end table
13897
13898 @subsection package Binder
13899
13900 @noindent
13901 The attributes of package @code{Binder} specify the options to be used
13902 when invoking the binder in the construction of an executable.
13903 The following attributes apply to package @code{Binder}:
13904
13905 @table @code
13906 @item     Default_Switches
13907 As above.
13908 @item     Switches
13909 As above.
13910 @end table
13911
13912 @subsection package Linker
13913
13914 @noindent
13915 The attributes of package @code{Linker} specify the options to be used when
13916 invoking the linker in the construction of an executable.
13917 The following attributes apply to package @code{Linker}:
13918
13919 @table @code
13920 @item     Default_Switches
13921 As above
13922 @item     Switches
13923 As above.
13924 @end table
13925
13926 @subsection package Cross_Reference
13927
13928 @noindent
13929 The attributes of package @code{Cross_Reference} specify the tool options
13930 to be used
13931 when invoking the library tool @command{gnatxref}.
13932 The following attributes apply to package @code{Cross_Reference}:
13933
13934 @table @code
13935 @item     Default_Switches
13936 As above.
13937 @item     Switches
13938 As above.
13939 @end table
13940
13941 @subsection package   Finder
13942
13943 @noindent
13944 The attributes of package @code{Finder} specify the tool options to be used
13945 when invoking the search tool @command{gnatfind}.
13946 The following attributes apply to package @code{Finder}:
13947
13948 @table @code
13949 @item     Default_Switches
13950 As above.
13951 @item     Switches
13952 As above.
13953 @end table
13954
13955 @subsection package Pretty_Printer
13956
13957 @noindent
13958 The attributes of package @code{Pretty_Printer}
13959 specify the tool options to be used
13960 when invoking the formatting tool @command{gnatpp}.
13961 The following attributes apply to package @code{Pretty_Printer}:
13962
13963 @table @code
13964 @item     Default_switches
13965 As above.
13966 @item     Switches
13967 As above.
13968 @end table
13969
13970 @subsection  package IDE
13971
13972 @noindent
13973 The attributes of package @code{IDE} specify the options to be used when using
13974 an Integrated Development Environment such as @command{GPS}.
13975
13976 @table @code
13977 @item Remote_Host
13978 This is a simple attribute. Its value is a string that designates the remote
13979 host in a cross-compilation environment, to be used for remote compilation and
13980 debugging. This field should not be specified when running on the local
13981 machine.
13982
13983 @item Program_Host
13984 This is a simple attribute. Its value is a string that specifies the
13985 name of IP address of the embedded target in a cross-compilation environment,
13986 on which the program should execute.
13987
13988 @item Communication_Protocol
13989 This is a simple string attribute. Its value is the name of the protocol
13990 to use to communicate with the target in a cross-compilation environment,
13991 e.g. @code{"wtx"} or @code{"vxworks"}.
13992
13993 @item Compiler_Command
13994 This is an associative array attribute, whose domain is a language name. Its
13995 value is  string that denotes the command to be used to invoke the compiler.
13996 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
13997 gnatmake, in particular in the handling of switches.
13998
13999 @item Debugger_Command
14000 This is simple attribute, Its value is a string that specifies the name of
14001 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14002
14003 @item Default_Switches
14004 This is an associative array attribute. Its indexes are the name of the
14005 external tools that the GNAT Programming System (GPS) is supporting. Its
14006 value is a list of switches to use when invoking that tool.
14007
14008 @item  Gnatlist
14009 This is a simple attribute.  Its value is a string that specifies the name
14010 of the @command{gnatls} utility to be used to retrieve information about the
14011 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14012
14013 @item VCS_Kind
14014 This is a simple atribute. Is value is a string used to specify the
14015 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14016 ClearCase or Perforce.
14017
14018 @item VCS_File_Check
14019 This is a simple attribute. Its value is a string that specifies the
14020 command used by the VCS to check the validity of a file, either
14021 when the user explicitly asks for a check, or as a sanity check before
14022 doing the check-in.
14023
14024 @item VCS_Log_Check
14025 This is a simple attribute. Its value is a string that specifies
14026 the command used by the VCS to check the validity of a log file.
14027
14028 @end table
14029
14030 @node Package Renamings
14031 @section Package Renamings
14032
14033 @noindent
14034 A package can be defined by a renaming declaration. The new package renames
14035 a package declared in a different project file, and has the same attributes
14036 as the package it renames.
14037 Syntax:
14038 @smallexample
14039 package_renaming ::==
14040   @b{package} package_identifier @b{renames}
14041        <project_>simple_name.package_identifier ;
14042 @end smallexample
14043
14044 @noindent
14045 The package_identifier of the renamed package must be the same as the
14046 package_identifier. The project whose name is the prefix of the renamed
14047 package must contain a package declaration with this name. This project
14048 must appear in the context_clause of the enclosing project declaration,
14049 or be the parent project of the enclosing child project.
14050
14051 @node Projects
14052 @section Projects
14053
14054 @noindent
14055 A project file specifies a set of rules for constructing a software system.
14056 A project file can be self-contained, or depend on other project files.
14057 Dependencies are expressed through a context clause that names other projects.
14058
14059 Syntax:
14060
14061 @smallexample
14062 project ::=
14063   context_clause project_declaration
14064
14065 project_declaration ::=
14066   simple_project_declaration | project_extension
14067
14068 simple_project_declaration ::=
14069   @b{project} <project_>simple_name @b{is}
14070     @{declarative_item@}
14071   @b{end} <project_>simple_name;
14072
14073 context_clause ::=
14074   @{with_clause@}
14075
14076 with_clause ::=
14077   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14078
14079 path_name ::=
14080    string_literal
14081 @end smallexample
14082
14083 @noindent
14084 A path name denotes a project file. A path name can be absolute or relative.
14085 An absolute path name includes a sequence of directories, in the syntax of
14086 the host operating system, that identifies uniquely the project file in the
14087 file system. A relative path name identifies the project file, relative
14088 to the directory that contains the current project, or relative to a
14089 directory listed in the environment variable ADA_PROJECT_PATH.
14090 Path names are case sensitive if file names in the host operating system
14091 are case sensitive.
14092
14093 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14094 directory names separated by colons (semicolons on Windows).
14095
14096 A given project name can appear only once in a context_clause.
14097
14098 It is illegal for a project imported by a context clause to refer, directly
14099 or indirectly, to the project in which this context clause appears (the
14100 dependency graph cannot contain cycles), except when one of the with_clause
14101 in the cycle is a @code{limited with}.
14102
14103 @node Project Extensions
14104 @section Project Extensions
14105
14106 @noindent
14107 A project extension introduces a new project, which inherits the declarations
14108 of another project.
14109 Syntax:
14110 @smallexample
14111
14112 project_extension ::=
14113   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14114     @{declarative_item@}
14115   @b{end} <project_>simple_name;
14116 @end smallexample
14117
14118 @noindent
14119 The project extension declares a child project. The child project inherits
14120 all the declarations and all the files of the parent project, These inherited
14121 declaration can be overridden in the child project, by means of suitable
14122 declarations.
14123
14124 @node Project File Elaboration
14125 @section Project File Elaboration
14126
14127 @noindent
14128 A project file is processed as part of the invocation of a gnat tool that
14129 uses the project option. Elaboration of the process file consists in the
14130 sequential elaboration of all its declarations. The computed values of
14131 attributes and variables in the project are then used to establish the
14132 environment in which the gnat tool will execute.
14133
14134 @include fdl.texi
14135 @c GNU Free Documentation License
14136
14137 @node Index,,GNU Free Documentation License, Top
14138 @unnumbered Index
14139
14140 @printindex cp
14141
14142 @contents
14143
14144 @bye