OSDN Git Service

2004-04-23 Emmanuel Briot <briot@act-europe.fr>
[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 (RM | Static);
1312 @end smallexample
1313
1314 @noindent
1315 This is a configuration pragma that provides control over the
1316 elaboration model used by the compilation affected by the
1317 pragma.  If the parameter is RM, then the dynamic elaboration
1318 model described in the Ada Reference Manual is used, as though
1319 the @code{-gnatE} switch had been specified on the command
1320 line.  If the parameter is Static, then the default GNAT static
1321 model is used.  This configuration pragma overrides the setting
1322 of the command line.  For full details on the elaboration models
1323 used by the GNAT compiler, see section ``Elaboration Order
1324 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1325
1326 @node Pragma Eliminate
1327 @unnumberedsec Pragma Eliminate
1328 @cindex Elimination of unused subprograms
1329 @findex Eliminate
1330 @noindent
1331 Syntax:
1332
1333 @smallexample @c ada
1334 pragma Eliminate (
1335     [Unit_Name =>] IDENTIFIER |
1336                    SELECTED_COMPONENT);
1337
1338 pragma Eliminate (
1339     [Unit_Name       =>]  IDENTIFIER |
1340                           SELECTED_COMPONENT,
1341     [Entity          =>]  IDENTIFIER |
1342                           SELECTED_COMPONENT |
1343                           STRING_LITERAL
1344     [,OVERLOADING_RESOLUTION]);
1345
1346 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1347                            SOURCE_LOCATION
1348
1349 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1350                                       FUNCTION_PROFILE
1351
1352 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1353
1354 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1355                       Result_Type => result_SUBTYPE_NAME]
1356
1357 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1358 SUBTYPE_NAME    ::= STRING_LITERAL
1359
1360 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1361 SOURCE_TRACE    ::= STRING_LITERAL
1362 @end smallexample
1363
1364 @noindent
1365 This pragma indicates that the given entity is not used outside the
1366 compilation unit it is defined in. The entity must be an explicitly declared
1367 subprogram; this includes  generic subprogram instances and
1368 subprograms declared in generic package instances.
1369
1370 If the entity to be eliminated is a library level subprogram, then
1371 the first form of pragma @code{Eliminate} is used with only a single argument.
1372 In this form, the @code{Unit_Name} argument specifies the name of the
1373 library  level unit to be eliminated.
1374
1375 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1376 are required. If item is an entity of a library package, then the first
1377 argument specifies the unit name, and the second argument specifies
1378 the particular entity.  If the second argument is in string form, it must
1379 correspond to the internal manner in which GNAT stores entity names (see
1380 compilation unit Namet in the compiler sources for details).
1381
1382 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1383 to distinguish between overloaded subprograms. If a pragma does not contain
1384 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1385 subprograms denoted by the first two parameters.
1386
1387 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1388 to be eliminated in a manner similar to that used for the extended
1389 @code{Import} and @code{Export} pragmas, except that the subtype names are
1390 always given as string literals. At the moment, this form of distinguishing
1391 overloaded subprograms is implemented only partially, so we do not recommend
1392 using it for practical subprogram elimination.
1393
1394 Note, that in case of a parameterless procedure its profile is represented
1395 as @code{Parameter_Types => ("")}
1396
1397 Alternatively, the @code{Source_Location} parameter is used to specify
1398 which overloaded alternative is to be eliminated by pointing to the
1399 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1400 source text. The string literal submitted as SOURCE_TRACE should have
1401 the following format:
1402
1403 @smallexample @c ada
1404 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1405
1406 LBRACKET ::= [
1407 RBRACKET ::= ]
1408
1409 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1410 FILE_NAME       ::= STRING_LITERAL
1411 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1412 @end smallexample
1413
1414 SOURCE_TRACE should be the short name of the source file (with no directory
1415 information), and LINE_NUMBER is supposed to point to the line where the
1416 defining name of the subprogram is located.
1417
1418 For the subprograms that are not a part of generic instantiations, only one
1419 SOURCE_LOCATION is used. If a subprogram is declared in a package
1420 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1421 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1422 second one denotes the declaration of the corresponding subprogram in the
1423 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1424 in case of nested instantiations.
1425
1426 The effect of the pragma is to allow the compiler to eliminate
1427 the code or data associated with the named entity.  Any reference to
1428 an eliminated entity outside the compilation unit it is defined in,
1429 causes a compile time or link time error.
1430
1431 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1432 in a system independent manner, with unused entities eliminated, without
1433 the requirement of modifying the source text.  Normally the required set
1434 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1435 tool. Elimination of unused entities local to a compilation unit is
1436 automatic, without requiring the use of pragma @code{Eliminate}.
1437
1438 Note that the reason this pragma takes string literals where names might
1439 be expected is that a pragma @code{Eliminate} can appear in a context where the
1440 relevant names are not visible.
1441
1442 Note that any change in the source files that includes removing, splitting of
1443 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1444 parameter illegal.
1445
1446 @node Pragma Export_Exception
1447 @unnumberedsec Pragma Export_Exception
1448 @cindex OpenVMS
1449 @findex Export_Exception
1450 @noindent
1451 Syntax:
1452
1453 @smallexample @c ada
1454 pragma Export_Exception (
1455      [Internal =>] LOCAL_NAME,
1456   [, [External =>] EXTERNAL_SYMBOL,]
1457   [, [Form     =>] Ada | VMS]
1458   [, [Code     =>] static_integer_EXPRESSION]);
1459
1460 EXTERNAL_SYMBOL ::=
1461   IDENTIFIER
1462 | static_string_EXPRESSION
1463 @end smallexample
1464
1465 @noindent
1466 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1467 causes the specified exception to be propagated outside of the Ada program,
1468 so that it can be handled by programs written in other OpenVMS languages.
1469 This pragma establishes an external name for an Ada exception and makes the
1470 name available to the OpenVMS Linker as a global symbol.  For further details
1471 on this pragma, see the
1472 DEC Ada Language Reference Manual, section 13.9a3.2.
1473
1474 @node Pragma Export_Function
1475 @unnumberedsec Pragma Export_Function
1476 @cindex Argument passing mechanisms
1477 @findex Export_Function
1478
1479 @noindent
1480 Syntax:
1481
1482 @smallexample @c ada
1483 pragma Export_Function (
1484      [Internal         =>] LOCAL_NAME,
1485   [, [External         =>] EXTERNAL_SYMBOL]
1486   [, [Parameter_Types  =>] PARAMETER_TYPES]
1487   [, [Result_Type      =>] result_SUBTYPE_MARK]
1488   [, [Mechanism        =>] MECHANISM]
1489   [, [Result_Mechanism =>] MECHANISM_NAME]);
1490
1491 EXTERNAL_SYMBOL ::=
1492   IDENTIFIER
1493 | static_string_EXPRESSION
1494 | ""
1495
1496 PARAMETER_TYPES ::=
1497   null
1498 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1499
1500 TYPE_DESIGNATOR ::=
1501   subtype_NAME
1502 | subtype_Name ' Access
1503
1504 MECHANISM ::=
1505   MECHANISM_NAME
1506 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1507
1508 MECHANISM_ASSOCIATION ::=
1509   [formal_parameter_NAME =>] MECHANISM_NAME
1510
1511 MECHANISM_NAME ::=
1512   Value
1513 | Reference
1514 @end smallexample
1515
1516 @noindent
1517 Use this pragma to make a function externally callable and optionally
1518 provide information on mechanisms to be used for passing parameter and
1519 result values.  We recommend, for the purposes of improving portability,
1520 this pragma always be used in conjunction with a separate pragma
1521 @code{Export}, which must precede the pragma @code{Export_Function}.
1522 GNAT does not require a separate pragma @code{Export}, but if none is
1523 present, @code{Convention Ada} is assumed, which is usually
1524 not what is wanted, so it is usually appropriate to use this
1525 pragma in conjunction with a @code{Export} or @code{Convention}
1526 pragma that specifies the desired foreign convention.
1527 Pragma @code{Export_Function}
1528 (and @code{Export}, if present) must appear in the same declarative
1529 region as the function to which they apply.
1530
1531 @var{internal_name} must uniquely designate the function to which the
1532 pragma applies.  If more than one function name exists of this name in
1533 the declarative part you must use the @code{Parameter_Types} and
1534 @code{Result_Type} parameters is mandatory to achieve the required
1535 unique designation.  @var{subtype_ mark}s in these parameters must
1536 exactly match the subtypes in the corresponding function specification,
1537 using positional notation to match parameters with subtype marks.
1538 The form with an @code{'Access} attribute can be used to match an
1539 anonymous access parameter.
1540
1541 @cindex OpenVMS
1542 @cindex Passing by descriptor
1543 Note that passing by descriptor is not supported, even on the OpenVMS
1544 ports of GNAT@.
1545
1546 @cindex Suppressing external name
1547 Special treatment is given if the EXTERNAL is an explicit null
1548 string or a static string expressions that evaluates to the null
1549 string. In this case, no external name is generated. This form
1550 still allows the specification of parameter mechanisms.
1551
1552 @node Pragma Export_Object
1553 @unnumberedsec Pragma Export_Object
1554 @findex Export_Object
1555 @noindent
1556 Syntax:
1557
1558 @smallexample @c ada
1559 pragma Export_Object
1560       [Internal =>] LOCAL_NAME,
1561    [, [External =>] EXTERNAL_SYMBOL]
1562    [, [Size     =>] EXTERNAL_SYMBOL]
1563
1564 EXTERNAL_SYMBOL ::=
1565   IDENTIFIER
1566 | static_string_EXPRESSION
1567 @end smallexample
1568
1569 @noindent
1570 This pragma designates an object as exported, and apart from the
1571 extended rules for external symbols, is identical in effect to the use of
1572 the normal @code{Export} pragma applied to an object.  You may use a
1573 separate Export pragma (and you probably should from the point of view
1574 of portability), but it is not required.  @var{Size} is syntax checked,
1575 but otherwise ignored by GNAT@.
1576
1577 @node Pragma Export_Procedure
1578 @unnumberedsec Pragma Export_Procedure
1579 @findex Export_Procedure
1580 @noindent
1581 Syntax:
1582
1583 @smallexample @c ada
1584 pragma Export_Procedure (
1585      [Internal        =>] LOCAL_NAME
1586   [, [External        =>] EXTERNAL_SYMBOL]
1587   [, [Parameter_Types =>] PARAMETER_TYPES]
1588   [, [Mechanism       =>] MECHANISM]);
1589
1590 EXTERNAL_SYMBOL ::=
1591   IDENTIFIER
1592 | static_string_EXPRESSION
1593 | ""
1594
1595 PARAMETER_TYPES ::=
1596   null
1597 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1598
1599 TYPE_DESIGNATOR ::=
1600   subtype_NAME
1601 | subtype_Name ' Access
1602
1603 MECHANISM ::=
1604   MECHANISM_NAME
1605 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1606
1607 MECHANISM_ASSOCIATION ::=
1608   [formal_parameter_NAME =>] MECHANISM_NAME
1609
1610 MECHANISM_NAME ::=
1611   Value
1612 | Reference
1613 @end smallexample
1614
1615 @noindent
1616 This pragma is identical to @code{Export_Function} except that it
1617 applies to a procedure rather than a function and the parameters
1618 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1619 GNAT does not require a separate pragma @code{Export}, but if none is
1620 present, @code{Convention Ada} is assumed, which is usually
1621 not what is wanted, so it is usually appropriate to use this
1622 pragma in conjunction with a @code{Export} or @code{Convention}
1623 pragma that specifies the desired foreign convention.
1624
1625 @cindex OpenVMS
1626 @cindex Passing by descriptor
1627 Note that passing by descriptor is not supported, even on the OpenVMS
1628 ports of GNAT@.
1629
1630 @cindex Suppressing external name
1631 Special treatment is given if the EXTERNAL is an explicit null
1632 string or a static string expressions that evaluates to the null
1633 string. In this case, no external name is generated. This form
1634 still allows the specification of parameter mechanisms.
1635
1636 @node Pragma Export_Value
1637 @unnumberedsec Pragma Export_Value
1638 @findex Export_Value
1639 @noindent
1640 Syntax:
1641
1642 @smallexample @c ada
1643 pragma Export_Value (
1644   [Value     =>] static_integer_EXPRESSION,
1645   [Link_Name =>] static_string_EXPRESSION);
1646 @end smallexample
1647
1648 @noindent
1649 This pragma serves to export a static integer value for external use.
1650 The first argument specifies the value to be exported. The Link_Name
1651 argument specifies the symbolic name to be associated with the integer
1652 value. This pragma is useful for defining a named static value in Ada
1653 that can be referenced in assembly language units to be linked with
1654 the application. This pragma is currently supported only for the
1655 AAMP target and is ignored for other targets.
1656
1657 @node Pragma Export_Valued_Procedure
1658 @unnumberedsec Pragma Export_Valued_Procedure
1659 @findex Export_Valued_Procedure
1660 @noindent
1661 Syntax:
1662
1663 @smallexample @c ada
1664 pragma Export_Valued_Procedure (
1665      [Internal        =>] LOCAL_NAME
1666   [, [External        =>] EXTERNAL_SYMBOL]
1667   [, [Parameter_Types =>] PARAMETER_TYPES]
1668   [, [Mechanism       =>] MECHANISM]);
1669
1670 EXTERNAL_SYMBOL ::=
1671   IDENTIFIER
1672 | static_string_EXPRESSION
1673 | ""
1674
1675 PARAMETER_TYPES ::=
1676   null
1677 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1678
1679 TYPE_DESIGNATOR ::=
1680   subtype_NAME
1681 | subtype_Name ' Access
1682
1683 MECHANISM ::=
1684   MECHANISM_NAME
1685 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1686
1687 MECHANISM_ASSOCIATION ::=
1688   [formal_parameter_NAME =>] MECHANISM_NAME
1689
1690 MECHANISM_NAME ::=
1691   Value
1692 | Reference
1693 @end smallexample
1694
1695 @noindent
1696 This pragma is identical to @code{Export_Procedure} except that the
1697 first parameter of @var{local_name}, which must be present, must be of
1698 mode @code{OUT}, and externally the subprogram is treated as a function
1699 with this parameter as the result of the function.  GNAT provides for
1700 this capability to allow the use of @code{OUT} and @code{IN OUT}
1701 parameters in interfacing to external functions (which are not permitted
1702 in Ada functions).
1703 GNAT does not require a separate pragma @code{Export}, but if none is
1704 present, @code{Convention Ada} is assumed, which is almost certainly
1705 not what is wanted since the whole point of this pragma is to interface
1706 with foreign language functions, so it is usually appropriate to use this
1707 pragma in conjunction with a @code{Export} or @code{Convention}
1708 pragma that specifies the desired foreign convention.
1709
1710 @cindex OpenVMS
1711 @cindex Passing by descriptor
1712 Note that passing by descriptor is not supported, even on the OpenVMS
1713 ports of GNAT@.
1714
1715 @cindex Suppressing external name
1716 Special treatment is given if the EXTERNAL is an explicit null
1717 string or a static string expressions that evaluates to the null
1718 string. In this case, no external name is generated. This form
1719 still allows the specification of parameter mechanisms.
1720
1721 @node Pragma Extend_System
1722 @unnumberedsec Pragma Extend_System
1723 @cindex @code{system}, extending
1724 @cindex Dec Ada 83
1725 @findex Extend_System
1726 @noindent
1727 Syntax:
1728
1729 @smallexample @c ada
1730 pragma Extend_System ([Name =>] IDENTIFIER);
1731 @end smallexample
1732
1733 @noindent
1734 This pragma is used to provide backwards compatibility with other
1735 implementations that extend the facilities of package @code{System}.  In
1736 GNAT, @code{System} contains only the definitions that are present in
1737 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1738 implementation, provide many extensions to package @code{System}.
1739
1740 For each such implementation accommodated by this pragma, GNAT provides a
1741 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1742 implementation, which provides the required additional definitions.  You
1743 can use this package in two ways.  You can @code{with} it in the normal
1744 way and access entities either by selection or using a @code{use}
1745 clause.  In this case no special processing is required.
1746
1747 However, if existing code contains references such as
1748 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1749 definitions provided in package @code{System}, you may use this pragma
1750 to extend visibility in @code{System} in a non-standard way that
1751 provides greater compatibility with the existing code.  Pragma
1752 @code{Extend_System} is a configuration pragma whose single argument is
1753 the name of the package containing the extended definition
1754 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1755 control of this pragma will be processed using special visibility
1756 processing that looks in package @code{System.Aux_@var{xxx}} where
1757 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1758 package @code{System}, but not found in package @code{System}.
1759
1760 You can use this pragma either to access a predefined @code{System}
1761 extension supplied with the compiler, for example @code{Aux_DEC} or
1762 you can construct your own extension unit following the above
1763 definition.  Note that such a package is a child of @code{System}
1764 and thus is considered part of the implementation.  To compile
1765 it you will have to use the appropriate switch for compiling
1766 system units.  See the GNAT User's Guide for details.
1767
1768 @node Pragma External
1769 @unnumberedsec Pragma External
1770 @findex External
1771 @noindent
1772 Syntax:
1773
1774 @smallexample @c ada
1775 pragma External (
1776   [   Convention    =>] convention_IDENTIFIER,
1777   [   Entity        =>] local_NAME
1778   [, [External_Name =>] static_string_EXPRESSION ]
1779   [, [Link_Name     =>] static_string_EXPRESSION ]);
1780 @end smallexample
1781
1782 @noindent
1783 This pragma is identical in syntax and semantics to pragma
1784 @code{Export} as defined in the Ada Reference Manual.  It is
1785 provided for compatibility with some Ada 83 compilers that
1786 used this pragma for exactly the same purposes as pragma
1787 @code{Export} before the latter was standardized.
1788
1789 @node Pragma External_Name_Casing
1790 @unnumberedsec Pragma External_Name_Casing
1791 @cindex Dec Ada 83 casing compatibility
1792 @cindex External Names, casing
1793 @cindex Casing of External names
1794 @findex External_Name_Casing
1795 @noindent
1796 Syntax:
1797
1798 @smallexample @c ada
1799 pragma External_Name_Casing (
1800   Uppercase | Lowercase
1801   [, Uppercase | Lowercase | As_Is]);
1802 @end smallexample
1803
1804 @noindent
1805 This pragma provides control over the casing of external names associated
1806 with Import and Export pragmas.  There are two cases to consider:
1807
1808 @table @asis
1809 @item Implicit external names
1810 Implicit external names are derived from identifiers.  The most common case
1811 arises when a standard Ada 95 Import or Export pragma is used with only two
1812 arguments, as in:
1813
1814 @smallexample @c ada
1815    pragma Import (C, C_Routine);
1816 @end smallexample
1817
1818 @noindent
1819 Since Ada is a case insensitive language, the spelling of the identifier in
1820 the Ada source program does not provide any information on the desired
1821 casing of the external name, and so a convention is needed.  In GNAT the
1822 default treatment is that such names are converted to all lower case
1823 letters.  This corresponds to the normal C style in many environments.
1824 The first argument of pragma @code{External_Name_Casing} can be used to
1825 control this treatment.  If @code{Uppercase} is specified, then the name
1826 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1827 then the normal default of all lower case letters will be used.
1828
1829 This same implicit treatment is also used in the case of extended DEC Ada 83
1830 compatible Import and Export pragmas where an external name is explicitly
1831 specified using an identifier rather than a string.
1832
1833 @item Explicit external names
1834 Explicit external names are given as string literals.  The most common case
1835 arises when a standard Ada 95 Import or Export pragma is used with three
1836 arguments, as in:
1837
1838 @smallexample @c ada
1839 pragma Import (C, C_Routine, "C_routine");
1840 @end smallexample
1841
1842 @noindent
1843 In this case, the string literal normally provides the exact casing required
1844 for the external name.  The second argument of pragma
1845 @code{External_Name_Casing} may be used to modify this behavior.
1846 If @code{Uppercase} is specified, then the name
1847 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1848 then the name will be forced to all lowercase letters.  A specification of
1849 @code{As_Is} provides the normal default behavior in which the casing is
1850 taken from the string provided.
1851 @end table
1852
1853 @noindent
1854 This pragma may appear anywhere that a pragma is valid.  In particular, it
1855 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1856 case it applies to all subsequent compilations, or it can be used as a program
1857 unit pragma, in which case it only applies to the current unit, or it can
1858 be used more locally to control individual Import/Export pragmas.
1859
1860 It is primarily intended for use with OpenVMS systems, where many
1861 compilers convert all symbols to upper case by default.  For interfacing to
1862 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1863 the pragma:
1864
1865 @smallexample @c ada
1866 pragma External_Name_Casing (Uppercase, Uppercase);
1867 @end smallexample
1868
1869 @noindent
1870 to enforce the upper casing of all external symbols.
1871
1872 @node Pragma Finalize_Storage_Only
1873 @unnumberedsec Pragma Finalize_Storage_Only
1874 @findex Finalize_Storage_Only
1875 @noindent
1876 Syntax:
1877
1878 @smallexample @c ada
1879 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1880 @end smallexample
1881
1882 @noindent
1883 This pragma allows the compiler not to emit a Finalize call for objects
1884 defined at the library level.  This is mostly useful for types where
1885 finalization is only used to deal with storage reclamation since in most
1886 environments it is not necessary to reclaim memory just before terminating
1887 execution, hence the name.
1888
1889 @node Pragma Float_Representation
1890 @unnumberedsec Pragma Float_Representation
1891 @cindex OpenVMS
1892 @findex Float_Representation
1893 @noindent
1894 Syntax:
1895
1896 @smallexample @c ada
1897 pragma Float_Representation (FLOAT_REP);
1898
1899 FLOAT_REP ::= VAX_Float | IEEE_Float
1900 @end smallexample
1901
1902 @noindent
1903 This pragma
1904 allows control over the internal representation chosen for the predefined
1905 floating point types declared in the packages @code{Standard} and
1906 @code{System}. On all systems other than OpenVMS, the argument must
1907 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1908 argument may be @code{VAX_Float} to specify the use of the VAX float
1909 format for the floating-point types in Standard. This requires that
1910 the standard runtime libraries be recompiled. See the
1911 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1912 of the GNAT Users Guide for details on the use of this command.
1913
1914 @node Pragma Ident
1915 @unnumberedsec Pragma Ident
1916 @findex Ident
1917 @noindent
1918 Syntax:
1919
1920 @smallexample @c ada
1921 pragma Ident (static_string_EXPRESSION);
1922 @end smallexample
1923
1924 @noindent
1925 This pragma provides a string identification in the generated object file,
1926 if the system supports the concept of this kind of identification string.
1927 This pragma is allowed only in the outermost declarative part or
1928 declarative items of a compilation unit. If more than one @code{Ident}
1929 pragma is given, only the last one processed is effective.
1930 @cindex OpenVMS
1931 On OpenVMS systems, the effect of the pragma is identical to the effect of
1932 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1933 maximum allowed length is 31 characters, so if it is important to
1934 maintain compatibility with this compiler, you should obey this length
1935 limit.
1936
1937 @node Pragma Import_Exception
1938 @unnumberedsec Pragma Import_Exception
1939 @cindex OpenVMS
1940 @findex Import_Exception
1941 @noindent
1942 Syntax:
1943
1944 @smallexample @c ada
1945 pragma Import_Exception (
1946      [Internal =>] LOCAL_NAME,
1947   [, [External =>] EXTERNAL_SYMBOL,]
1948   [, [Form     =>] Ada | VMS]
1949   [, [Code     =>] static_integer_EXPRESSION]);
1950
1951 EXTERNAL_SYMBOL ::=
1952   IDENTIFIER
1953 | static_string_EXPRESSION
1954 @end smallexample
1955
1956 @noindent
1957 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1958 It allows OpenVMS conditions (for example, from OpenVMS system services or
1959 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1960 The pragma specifies that the exception associated with an exception
1961 declaration in an Ada program be defined externally (in non-Ada code).
1962 For further details on this pragma, see the
1963 DEC Ada Language Reference Manual, section 13.9a.3.1.
1964
1965 @node Pragma Import_Function
1966 @unnumberedsec Pragma Import_Function
1967 @findex Import_Function
1968 @noindent
1969 Syntax:
1970
1971 @smallexample @c ada
1972 pragma Import_Function (
1973      [Internal                 =>] LOCAL_NAME,
1974   [, [External                 =>] EXTERNAL_SYMBOL]
1975   [, [Parameter_Types          =>] PARAMETER_TYPES]
1976   [, [Result_Type              =>] SUBTYPE_MARK]
1977   [, [Mechanism                =>] MECHANISM]
1978   [, [Result_Mechanism         =>] MECHANISM_NAME]
1979   [, [First_Optional_Parameter =>] IDENTIFIER]);
1980
1981 EXTERNAL_SYMBOL ::=
1982   IDENTIFIER
1983 | static_string_EXPRESSION
1984
1985 PARAMETER_TYPES ::=
1986   null
1987 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1988
1989 TYPE_DESIGNATOR ::=
1990   subtype_NAME
1991 | subtype_Name ' Access
1992
1993 MECHANISM ::=
1994   MECHANISM_NAME
1995 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1996
1997 MECHANISM_ASSOCIATION ::=
1998   [formal_parameter_NAME =>] MECHANISM_NAME
1999
2000 MECHANISM_NAME ::=
2001   Value
2002 | Reference
2003 | Descriptor [([Class =>] CLASS_NAME)]
2004
2005 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2006 @end smallexample
2007
2008 @noindent
2009 This pragma is used in conjunction with a pragma @code{Import} to
2010 specify additional information for an imported function.  The pragma
2011 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2012 @code{Import_Function} pragma and both must appear in the same
2013 declarative part as the function specification.
2014
2015 The @var{Internal} argument must uniquely designate
2016 the function to which the
2017 pragma applies.  If more than one function name exists of this name in
2018 the declarative part you must use the @code{Parameter_Types} and
2019 @var{Result_Type} parameters to achieve the required unique
2020 designation.  Subtype marks in these parameters must exactly match the
2021 subtypes in the corresponding function specification, using positional
2022 notation to match parameters with subtype marks.
2023 The form with an @code{'Access} attribute can be used to match an
2024 anonymous access parameter.
2025
2026 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2027 parameters to specify passing mechanisms for the
2028 parameters and result.  If you specify a single mechanism name, it
2029 applies to all parameters.  Otherwise you may specify a mechanism on a
2030 parameter by parameter basis using either positional or named
2031 notation.  If the mechanism is not specified, the default mechanism
2032 is used.
2033
2034 @cindex OpenVMS
2035 @cindex Passing by descriptor
2036 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2037
2038 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2039 It specifies that the designated parameter and all following parameters
2040 are optional, meaning that they are not passed at the generated code
2041 level (this is distinct from the notion of optional parameters in Ada
2042 where the parameters are passed anyway with the designated optional
2043 parameters).  All optional parameters must be of mode @code{IN} and have
2044 default parameter values that are either known at compile time
2045 expressions, or uses of the @code{'Null_Parameter} attribute.
2046
2047 @node Pragma Import_Object
2048 @unnumberedsec Pragma Import_Object
2049 @findex Import_Object
2050 @noindent
2051 Syntax:
2052
2053 @smallexample @c ada
2054 pragma Import_Object
2055      [Internal =>] LOCAL_NAME,
2056   [, [External =>] EXTERNAL_SYMBOL],
2057   [, [Size     =>] EXTERNAL_SYMBOL]);
2058
2059 EXTERNAL_SYMBOL ::=
2060   IDENTIFIER
2061 | static_string_EXPRESSION
2062 @end smallexample
2063
2064 @noindent
2065 This pragma designates an object as imported, and apart from the
2066 extended rules for external symbols, is identical in effect to the use of
2067 the normal @code{Import} pragma applied to an object.  Unlike the
2068 subprogram case, you need not use a separate @code{Import} pragma,
2069 although you may do so (and probably should do so from a portability
2070 point of view).  @var{size} is syntax checked, but otherwise ignored by
2071 GNAT@.
2072
2073 @node Pragma Import_Procedure
2074 @unnumberedsec Pragma Import_Procedure
2075 @findex Import_Procedure
2076 @noindent
2077 Syntax:
2078
2079 @smallexample @c ada
2080 pragma Import_Procedure (
2081      [Internal                 =>] LOCAL_NAME,
2082   [, [External                 =>] EXTERNAL_SYMBOL]
2083   [, [Parameter_Types          =>] PARAMETER_TYPES]
2084   [, [Mechanism                =>] MECHANISM]
2085   [, [First_Optional_Parameter =>] IDENTIFIER]);
2086
2087 EXTERNAL_SYMBOL ::=
2088   IDENTIFIER
2089 | static_string_EXPRESSION
2090
2091 PARAMETER_TYPES ::=
2092   null
2093 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2094
2095 TYPE_DESIGNATOR ::=
2096   subtype_NAME
2097 | subtype_Name ' Access
2098
2099 MECHANISM ::=
2100   MECHANISM_NAME
2101 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2102
2103 MECHANISM_ASSOCIATION ::=
2104   [formal_parameter_NAME =>] MECHANISM_NAME
2105
2106 MECHANISM_NAME ::=
2107   Value
2108 | Reference
2109 | Descriptor [([Class =>] CLASS_NAME)]
2110
2111 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2112 @end smallexample
2113
2114 @noindent
2115 This pragma is identical to @code{Import_Function} except that it
2116 applies to a procedure rather than a function and the parameters
2117 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2118
2119 @node Pragma Import_Valued_Procedure
2120 @unnumberedsec Pragma Import_Valued_Procedure
2121 @findex Import_Valued_Procedure
2122 @noindent
2123 Syntax:
2124
2125 @smallexample @c ada
2126 pragma Import_Valued_Procedure (
2127      [Internal                 =>] LOCAL_NAME,
2128   [, [External                 =>] EXTERNAL_SYMBOL]
2129   [, [Parameter_Types          =>] PARAMETER_TYPES]
2130   [, [Mechanism                =>] MECHANISM]
2131   [, [First_Optional_Parameter =>] IDENTIFIER]);
2132
2133 EXTERNAL_SYMBOL ::=
2134   IDENTIFIER
2135 | static_string_EXPRESSION
2136
2137 PARAMETER_TYPES ::=
2138   null
2139 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2140
2141 TYPE_DESIGNATOR ::=
2142   subtype_NAME
2143 | subtype_Name ' Access
2144
2145 MECHANISM ::=
2146   MECHANISM_NAME
2147 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2148
2149 MECHANISM_ASSOCIATION ::=
2150   [formal_parameter_NAME =>] MECHANISM_NAME
2151
2152 MECHANISM_NAME ::=
2153   Value
2154 | Reference
2155 | Descriptor [([Class =>] CLASS_NAME)]
2156
2157 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2158 @end smallexample
2159
2160 @noindent
2161 This pragma is identical to @code{Import_Procedure} except that the
2162 first parameter of @var{local_name}, which must be present, must be of
2163 mode @code{OUT}, and externally the subprogram is treated as a function
2164 with this parameter as the result of the function.  The purpose of this
2165 capability is to allow the use of @code{OUT} and @code{IN OUT}
2166 parameters in interfacing to external functions (which are not permitted
2167 in Ada functions).  You may optionally use the @code{Mechanism}
2168 parameters to specify passing mechanisms for the parameters.
2169 If you specify a single mechanism name, it applies to all parameters.
2170 Otherwise you may specify a mechanism on a parameter by parameter
2171 basis using either positional or named notation.  If the mechanism is not
2172 specified, the default mechanism is used.
2173
2174 Note that it is important to use this pragma in conjunction with a separate
2175 pragma Import that specifies the desired convention, since otherwise the
2176 default convention is Ada, which is almost certainly not what is required.
2177
2178 @node Pragma Initialize_Scalars
2179 @unnumberedsec Pragma Initialize_Scalars
2180 @findex Initialize_Scalars
2181 @cindex debugging with Initialize_Scalars
2182 @noindent
2183 Syntax:
2184
2185 @smallexample @c ada
2186 pragma Initialize_Scalars;
2187 @end smallexample
2188
2189 @noindent
2190 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2191 two important differences.  First, there is no requirement for the pragma
2192 to be used uniformly in all units of a partition, in particular, it is fine
2193 to use this just for some or all of the application units of a partition,
2194 without needing to recompile the run-time library.
2195
2196 In the case where some units are compiled with the pragma, and some without,
2197 then a declaration of a variable where the type is defined in package
2198 Standard or is locally declared will always be subject to initialization,
2199 as will any declaration of a scalar variable.  For composite variables,
2200 whether the variable is initialized may also depend on whether the package
2201 in which the type of the variable is declared is compiled with the pragma.
2202
2203 The other important difference is that there is control over the value used
2204 for initializing scalar objects.  At bind time, you can select whether to
2205 initialize with invalid values (like Normalize_Scalars), or with high or
2206 low values, or with a specified bit pattern.  See the users guide for binder
2207 options for specifying these cases.
2208
2209 This means that you can compile a program, and then without having to
2210 recompile the program, you can run it with different values being used
2211 for initializing otherwise uninitialized values, to test if your program
2212 behavior depends on the choice.  Of course the behavior should not change,
2213 and if it does, then most likely you have an erroneous reference to an
2214 uninitialized value.
2215
2216 Note that pragma @code{Initialize_Scalars} is particularly useful in
2217 conjunction with the enhanced validity checking that is now provided
2218 in GNAT, which checks for invalid values under more conditions.
2219 Using this feature (see description of the @code{-gnatV} flag in the
2220 users guide) in conjunction with pragma @code{Initialize_Scalars}
2221 provides a powerful new tool to assist in the detection of problems
2222 caused by uninitialized variables.
2223
2224 @node Pragma Inline_Always
2225 @unnumberedsec Pragma Inline_Always
2226 @findex Inline_Always
2227 @noindent
2228 Syntax:
2229
2230 @smallexample @c ada
2231 pragma Inline_Always (NAME [, NAME]);
2232 @end smallexample
2233
2234 @noindent
2235 Similar to pragma @code{Inline} except that inlining is not subject to
2236 the use of option @code{-gnatn} and the inlining happens regardless of
2237 whether this option is used.
2238
2239 @node Pragma Inline_Generic
2240 @unnumberedsec Pragma Inline_Generic
2241 @findex Inline_Generic
2242 @noindent
2243 Syntax:
2244
2245 @smallexample @c ada
2246 pragma Inline_Generic (generic_package_NAME);
2247 @end smallexample
2248
2249 @noindent
2250 This is implemented for compatibility with DEC Ada 83 and is recognized,
2251 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2252 by default when using GNAT@.
2253
2254 @node Pragma Interface
2255 @unnumberedsec Pragma Interface
2256 @findex Interface
2257 @noindent
2258 Syntax:
2259
2260 @smallexample @c ada
2261 pragma Interface (
2262      [Convention    =>] convention_identifier,
2263      [Entity =>] local_name
2264   [, [External_Name =>] static_string_expression],
2265   [, [Link_Name     =>] static_string_expression]);
2266 @end smallexample
2267
2268 @noindent
2269 This pragma is identical in syntax and semantics to
2270 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2271 with Ada 83.  The definition is upwards compatible both with pragma
2272 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2273 with some extended implementations of this pragma in certain Ada 83
2274 implementations.
2275
2276 @node Pragma Interface_Name
2277 @unnumberedsec Pragma Interface_Name
2278 @findex Interface_Name
2279 @noindent
2280 Syntax:
2281
2282 @smallexample @c ada
2283 pragma Interface_Name (
2284      [Entity        =>] LOCAL_NAME
2285   [, [External_Name =>] static_string_EXPRESSION]
2286   [, [Link_Name     =>] static_string_EXPRESSION]);
2287 @end smallexample
2288
2289 @noindent
2290 This pragma provides an alternative way of specifying the interface name
2291 for an interfaced subprogram, and is provided for compatibility with Ada
2292 83 compilers that use the pragma for this purpose.  You must provide at
2293 least one of @var{External_Name} or @var{Link_Name}.
2294
2295 @node Pragma Interrupt_Handler
2296 @unnumberedsec Pragma Interrupt_Handler
2297 @findex Interrupt_Handler
2298 @noindent
2299 Syntax:
2300
2301 @smallexample @c ada
2302 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2303 @end smallexample
2304
2305 @noindent
2306 This program unit pragma is supported for parameterless protected procedures
2307 as described in Annex C of the Ada Reference Manual. On the AAMP target
2308 the pragma can also be specified for nonprotected parameterless procedures
2309 that are declared at the library level (which includes procedures
2310 declared at the top level of a library package). In the case of AAMP,
2311 when this pragma is applied to a nonprotected procedure, the instruction
2312 @code{IERET} is generated for returns from the procedure, enabling
2313 maskable interrupts, in place of the normal return instruction.
2314
2315 @node Pragma Interrupt_State
2316 @unnumberedsec Pragma Interrupt_State
2317 @findex Interrupt_State
2318 @noindent
2319 Syntax:
2320
2321 @smallexample @c ada
2322 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2323 @end smallexample
2324
2325 @noindent
2326 Normally certain interrupts are reserved to the implementation.  Any attempt
2327 to attach an interrupt causes Program_Error to be raised, as described in
2328 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2329 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2330 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2331 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2332 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2333 Ada exceptions, or used to implement run-time functions such as the
2334 @code{abort} statement and stack overflow checking.
2335
2336 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2337 such uses of interrupts.  It subsumes the functionality of pragma
2338 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2339 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2340 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2341 and may be used to mark interrupts required by the board support package
2342 as reserved.
2343
2344 Interrupts can be in one of three states:
2345 @itemize @bullet
2346 @item System
2347
2348 The interrupt is reserved (no Ada handler can be installed), and the
2349 Ada run-time may not install a handler. As a result you are guaranteed
2350 standard system default action if this interrupt is raised.
2351
2352 @item Runtime
2353
2354 The interrupt is reserved (no Ada handler can be installed). The run time
2355 is allowed to install a handler for internal control purposes, but is
2356 not required to do so.
2357
2358 @item User
2359
2360 The interrupt is unreserved.  The user may install a handler to provide
2361 some other action.
2362 @end itemize
2363
2364 @noindent
2365 These states are the allowed values of the @code{State} parameter of the
2366 pragma.  The @code{Name} parameter is a value of the type
2367 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2368 @code{Ada.Interrupts.Names}.
2369
2370 This is a configuration pragma, and the binder will check that there
2371 are no inconsistencies between different units in a partition in how a
2372 given interrupt is specified. It may appear anywhere a pragma is legal.
2373
2374 The effect is to move the interrupt to the specified state.
2375
2376 By declaring interrupts to be SYSTEM, you guarantee the standard system
2377 action, such as a core dump.
2378
2379 By declaring interrupts to be USER, you guarantee that you can install
2380 a handler.
2381
2382 Note that certain signals on many operating systems cannot be caught and
2383 handled by applications.  In such cases, the pragma is ignored.  See the
2384 operating system documentation, or the value of the array @code{Reserved}
2385 declared in the specification of package @code{System.OS_Interface}.
2386
2387 Overriding the default state of signals used by the Ada runtime may interfere
2388 with an application's runtime behavior in the cases of the synchronous signals,
2389 and in the case of the signal used to implement the @code{abort} statement.
2390
2391 @node Pragma Keep_Names
2392 @unnumberedsec Pragma Keep_Names
2393 @findex Keep_Names
2394 @noindent
2395 Syntax:
2396
2397 @smallexample @c ada
2398 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2399 @end smallexample
2400
2401 @noindent
2402 The @var{LOCAL_NAME} argument
2403 must refer to an enumeration first subtype
2404 in the current declarative part. The effect is to retain the enumeration
2405 literal names for use by @code{Image} and @code{Value} even if a global
2406 @code{Discard_Names} pragma applies. This is useful when you want to
2407 generally suppress enumeration literal names and for example you therefore
2408 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2409 want to retain the names for specific enumeration types.
2410
2411 @node Pragma License
2412 @unnumberedsec Pragma License
2413 @findex License
2414 @cindex License checking
2415 @noindent
2416 Syntax:
2417
2418 @smallexample @c ada
2419 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2420 @end smallexample
2421
2422 @noindent
2423 This pragma is provided to allow automated checking for appropriate license
2424 conditions with respect to the standard and modified GPL@.  A pragma
2425 @code{License}, which is a configuration pragma that typically appears at
2426 the start of a source file or in a separate @file{gnat.adc} file, specifies
2427 the licensing conditions of a unit as follows:
2428
2429 @itemize @bullet
2430 @item Unrestricted
2431 This is used for a unit that can be freely used with no license restrictions.
2432 Examples of such units are public domain units, and units from the Ada
2433 Reference Manual.
2434
2435 @item GPL
2436 This is used for a unit that is licensed under the unmodified GPL, and which
2437 therefore cannot be @code{with}'ed by a restricted unit.
2438
2439 @item Modified_GPL
2440 This is used for a unit licensed under the GNAT modified GPL that includes
2441 a special exception paragraph that specifically permits the inclusion of
2442 the unit in programs without requiring the entire program to be released
2443 under the GPL@.  This is the license used for the GNAT run-time which ensures
2444 that the run-time can be used freely in any program without GPL concerns.
2445
2446 @item Restricted
2447 This is used for a unit that is restricted in that it is not permitted to
2448 depend on units that are licensed under the GPL@.  Typical examples are
2449 proprietary code that is to be released under more restrictive license
2450 conditions.  Note that restricted units are permitted to @code{with} units
2451 which are licensed under the modified GPL (this is the whole point of the
2452 modified GPL).
2453
2454 @end itemize
2455
2456 @noindent
2457 Normally a unit with no @code{License} pragma is considered to have an
2458 unknown license, and no checking is done.  However, standard GNAT headers
2459 are recognized, and license information is derived from them as follows.
2460
2461 @itemize @bullet
2462
2463 A GNAT license header starts with a line containing 78 hyphens.  The following
2464 comment text is searched for the appearance of any of the following strings.
2465
2466 If the string ``GNU General Public License'' is found, then the unit is assumed
2467 to have GPL license, unless the string ``As a special exception'' follows, in
2468 which case the license is assumed to be modified GPL@.
2469
2470 If one of the strings
2471 ``This specification is adapted from the Ada Semantic Interface'' or
2472 ``This specification is derived from the Ada Reference Manual'' is found
2473 then the unit is assumed to be unrestricted.
2474 @end itemize
2475
2476 @noindent
2477 These default actions means that a program with a restricted license pragma
2478 will automatically get warnings if a GPL unit is inappropriately
2479 @code{with}'ed.  For example, the program:
2480
2481 @smallexample @c ada
2482 with Sem_Ch3;
2483 with GNAT.Sockets;
2484 procedure Secret_Stuff is
2485   @dots{}
2486 end Secret_Stuff
2487 @end smallexample
2488
2489 @noindent
2490 if compiled with pragma @code{License} (@code{Restricted}) in a
2491 @file{gnat.adc} file will generate the warning:
2492
2493 @smallexample
2494 1.  with Sem_Ch3;
2495         |
2496    >>> license of withed unit "Sem_Ch3" is incompatible
2497
2498 2.  with GNAT.Sockets;
2499 3.  procedure Secret_Stuff is
2500 @end smallexample
2501
2502 @noindent
2503 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2504 compiler and is licensed under the
2505 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2506 run time, and is therefore licensed under the modified GPL@.
2507
2508 @node Pragma Link_With
2509 @unnumberedsec Pragma Link_With
2510 @findex Link_With
2511 @noindent
2512 Syntax:
2513
2514 @smallexample @c ada
2515 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2516 @end smallexample
2517
2518 @noindent
2519 This pragma is provided for compatibility with certain Ada 83 compilers.
2520 It has exactly the same effect as pragma @code{Linker_Options} except
2521 that spaces occurring within one of the string expressions are treated
2522 as separators. For example, in the following case:
2523
2524 @smallexample @c ada
2525 pragma Link_With ("-labc -ldef");
2526 @end smallexample
2527
2528 @noindent
2529 results in passing the strings @code{-labc} and @code{-ldef} as two
2530 separate arguments to the linker. In addition pragma Link_With allows
2531 multiple arguments, with the same effect as successive pragmas.
2532
2533 @node Pragma Linker_Alias
2534 @unnumberedsec Pragma Linker_Alias
2535 @findex Linker_Alias
2536 @noindent
2537 Syntax:
2538
2539 @smallexample @c ada
2540 pragma Linker_Alias (
2541   [Entity =>] LOCAL_NAME
2542   [Alias  =>] static_string_EXPRESSION);
2543 @end smallexample
2544
2545 @noindent
2546 This pragma establishes a linker alias for the given named entity.  For
2547 further details on the exact effect, consult the GCC manual.
2548
2549 @node Pragma Linker_Section
2550 @unnumberedsec Pragma Linker_Section
2551 @findex Linker_Section
2552 @noindent
2553 Syntax:
2554
2555 @smallexample @c ada
2556 pragma Linker_Section (
2557   [Entity  =>] LOCAL_NAME
2558   [Section =>] static_string_EXPRESSION);
2559 @end smallexample
2560
2561 @noindent
2562 This pragma specifies the name of the linker section for the given entity.
2563 For further details on the exact effect, consult the GCC manual.
2564
2565 @node Pragma Long_Float
2566 @unnumberedsec Pragma Long_Float
2567 @cindex OpenVMS
2568 @findex Long_Float
2569 @noindent
2570 Syntax:
2571
2572 @smallexample @c ada
2573 pragma Long_Float (FLOAT_FORMAT);
2574
2575 FLOAT_FORMAT ::= D_Float | G_Float
2576 @end smallexample
2577
2578 @noindent
2579 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2580 It allows control over the internal representation chosen for the predefined
2581 type @code{Long_Float} and for floating point type representations with
2582 @code{digits} specified in the range 7 through 15.
2583 For further details on this pragma, see the
2584 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2585 this pragma, the standard runtime libraries must be recompiled.  See the
2586 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2587 of the GNAT User's Guide for details on the use of this command.
2588
2589 @node Pragma Machine_Attribute
2590 @unnumberedsec Pragma Machine_Attribute
2591 @findex Machine_Attribute
2592 @noindent
2593 Syntax:
2594
2595 @smallexample @c ada
2596 pragma Machine_Attribute (
2597   [Attribute_Name =>] string_EXPRESSION,
2598   [Entity         =>] LOCAL_NAME);
2599 @end smallexample
2600
2601 @noindent
2602 Machine dependent attributes can be specified for types and/or
2603 declarations.  Currently only subprogram entities are supported.  This
2604 pragma is semantically equivalent to
2605 @code{__attribute__((@var{string_expression}))} in GNU C,
2606 where @code{@var{string_expression}} is
2607 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2608 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2609 configuration header file @file{tm.h} for each machine.  See the GCC
2610 manual for further information.
2611
2612 @node Pragma Main_Storage
2613 @unnumberedsec Pragma Main_Storage
2614 @cindex OpenVMS
2615 @findex Main_Storage
2616 @noindent
2617 Syntax:
2618
2619 @smallexample @c ada
2620 pragma Main_Storage
2621   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2622
2623 MAIN_STORAGE_OPTION ::=
2624   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2625 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2626
2627 @end smallexample
2628
2629 @noindent
2630 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2631 no effect in GNAT, other than being syntax checked.  Note that the pragma
2632 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2633
2634 @node Pragma No_Return
2635 @unnumberedsec Pragma No_Return
2636 @findex No_Return
2637 @noindent
2638 Syntax:
2639
2640 @smallexample @c ada
2641 pragma No_Return (procedure_LOCAL_NAME);
2642 @end smallexample
2643
2644 @noindent
2645 @var{procedure_local_NAME} must refer to one or more procedure
2646 declarations in the current declarative part.  A procedure to which this
2647 pragma is applied may not contain any explicit @code{return} statements,
2648 and also may not contain any implicit return statements from falling off
2649 the end of a statement sequence.  One use of this pragma is to identify
2650 procedures whose only purpose is to raise an exception.
2651
2652 Another use of this pragma is to suppress incorrect warnings about
2653 missing returns in functions, where the last statement of a function
2654 statement sequence is a call to such a procedure.
2655
2656 @node Pragma Normalize_Scalars
2657 @unnumberedsec Pragma Normalize_Scalars
2658 @findex Normalize_Scalars
2659 @noindent
2660 Syntax:
2661
2662 @smallexample @c ada
2663 pragma Normalize_Scalars;
2664 @end smallexample
2665
2666 @noindent
2667 This is a language defined pragma which is fully implemented in GNAT@.  The
2668 effect is to cause all scalar objects that are not otherwise initialized
2669 to be initialized.  The initial values are implementation dependent and
2670 are as follows:
2671
2672 @table @code
2673 @item Standard.Character
2674 @noindent
2675 Objects whose root type is Standard.Character are initialized to
2676 Character'Last.  This will be out of range of the subtype only if
2677 the subtype range excludes this value.
2678
2679 @item Standard.Wide_Character
2680 @noindent
2681 Objects whose root type is Standard.Wide_Character are initialized to
2682 Wide_Character'Last.  This will be out of range of the subtype only if
2683 the subtype range excludes this value.
2684
2685 @item Integer types
2686 @noindent
2687 Objects of an integer type are initialized to base_type'First, where
2688 base_type is the base type of the object type.  This will be out of range
2689 of the subtype only if the subtype range excludes this value.  For example,
2690 if you declare the subtype:
2691
2692 @smallexample @c ada
2693 subtype Ityp is integer range 1 .. 10;
2694 @end smallexample
2695
2696 @noindent
2697 then objects of type x will be initialized to Integer'First, a negative
2698 number that is certainly outside the range of subtype @code{Ityp}.
2699
2700 @item Real types
2701 Objects of all real types (fixed and floating) are initialized to
2702 base_type'First, where base_Type is the base type of the object type.
2703 This will be out of range of the subtype only if the subtype range
2704 excludes this value.
2705
2706 @item Modular types
2707 Objects of a modular type are initialized to typ'Last.  This will be out
2708 of range of the subtype only if the subtype excludes this value.
2709
2710 @item Enumeration types
2711 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2712 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2713 enumeration subtype in all cases except where the subtype contains
2714 exactly 2**8, 2**16, or 2**32 elements.
2715
2716 @end table
2717
2718 @node Pragma Obsolescent
2719 @unnumberedsec Pragma Obsolescent
2720 @findex Obsolescent
2721 @noindent
2722 Syntax:
2723
2724 @smallexample @c ada
2725 pragma Obsolescent [(static_string_EXPRESSION)];
2726 @end smallexample
2727
2728 @noindent
2729 This pragma must occur immediately following a subprogram
2730 declaration. It indicates that the associated function or procedure
2731 is considered obsolescent and should not be used. Typically this is
2732 used when an API must be modified by eventually removing or modifying
2733 existing subprograms. The pragma can be used at an intermediate stage
2734 when the subprogram is still present, but will be removed later.
2735
2736 The effect of this pragma is to output a warning message that the
2737 subprogram is obsolescent if the appropriate warning option in the
2738 compiler is activated. If a parameter is present, then a second
2739 warning message is given containing this text.
2740
2741 @node Pragma Passive
2742 @unnumberedsec Pragma Passive
2743 @findex Passive
2744 @noindent
2745 Syntax:
2746
2747 @smallexample @c ada
2748 pragma Passive ([Semaphore | No]);
2749 @end smallexample
2750
2751 @noindent
2752 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2753 compatibility with DEC Ada 83 implementations, where it is used within a
2754 task definition to request that a task be made passive.  If the argument
2755 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2756 treats the pragma as an assertion that the containing task is passive
2757 and that optimization of context switch with this task is permitted and
2758 desired.  If the argument @code{No} is present, the task must not be
2759 optimized.  GNAT does not attempt to optimize any tasks in this manner
2760 (since protected objects are available in place of passive tasks).
2761
2762 @node Pragma Polling
2763 @unnumberedsec Pragma Polling
2764 @findex Polling
2765 @noindent
2766 Syntax:
2767
2768 @smallexample @c ada
2769 pragma Polling (ON | OFF);
2770 @end smallexample
2771
2772 @noindent
2773 This pragma controls the generation of polling code.  This is normally off.
2774 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2775 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2776 runtime library, and can be found in file @file{a-excpol.adb}.
2777
2778 Pragma @code{Polling} can appear as a configuration pragma (for example it
2779 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2780 can be used in the statement or declaration sequence to control polling
2781 more locally.
2782
2783 A call to the polling routine is generated at the start of every loop and
2784 at the start of every subprogram call.  This guarantees that the @code{Poll}
2785 routine is called frequently, and places an upper bound (determined by
2786 the complexity of the code) on the period between two @code{Poll} calls.
2787
2788 The primary purpose of the polling interface is to enable asynchronous
2789 aborts on targets that cannot otherwise support it (for example Windows
2790 NT), but it may be used for any other purpose requiring periodic polling.
2791 The standard version is null, and can be replaced by a user program.  This
2792 will require re-compilation of the @code{Ada.Exceptions} package that can
2793 be found in files @file{a-except.ads} and @file{a-except.adb}.
2794
2795 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2796 distribution) is used to enable the asynchronous abort capability on
2797 targets that do not normally support the capability.  The version of
2798 @code{Poll} in this file makes a call to the appropriate runtime routine
2799 to test for an abort condition.
2800
2801 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2802 the @cite{GNAT User's Guide} for details.
2803
2804 @node Pragma Propagate_Exceptions
2805 @unnumberedsec Pragma Propagate_Exceptions
2806 @findex Propagate_Exceptions
2807 @cindex Zero Cost Exceptions
2808 @noindent
2809 Syntax:
2810
2811 @smallexample @c ada
2812 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2813 @end smallexample
2814
2815 @noindent
2816 This pragma indicates that the given entity, which is the name of an
2817 imported foreign-language subprogram may receive an Ada exception,
2818 and that the exception should be propagated.  It is relevant only if
2819 zero cost exception handling is in use, and is thus never needed if
2820 the alternative @code{longjmp} / @code{setjmp} implementation of
2821 exceptions is used (although it is harmless to use it in such cases).
2822
2823 The implementation of fast exceptions always properly propagates
2824 exceptions through Ada code, as described in the Ada Reference Manual.
2825 However, this manual is silent about the propagation of exceptions
2826 through foreign code.  For example, consider the
2827 situation where @code{P1} calls
2828 @code{P2}, and @code{P2} calls @code{P3}, where
2829 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2830 @code{P3} raises an Ada exception.  The question is whether or not
2831 it will be propagated through @code{P2} and can be handled in
2832 @code{P1}.
2833
2834 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
2835 the answer is always yes.  For some targets on which zero cost exception
2836 handling is implemented, the answer is also always yes.  However, there
2837 are some targets, notably in the current version all x86 architecture
2838 targets, in which the answer is that such propagation does not
2839 happen automatically.  If such propagation is required on these
2840 targets, it is mandatory to use @code{Propagate_Exceptions} to
2841 name all foreign language routines through which Ada exceptions
2842 may be propagated.
2843
2844 @node Pragma Psect_Object
2845 @unnumberedsec Pragma Psect_Object
2846 @findex Psect_Object
2847 @noindent
2848 Syntax:
2849
2850 @smallexample @c ada
2851 pragma Psect_Object (
2852      [Internal =>] LOCAL_NAME,
2853   [, [External =>] EXTERNAL_SYMBOL]
2854   [, [Size     =>] EXTERNAL_SYMBOL]);
2855
2856 EXTERNAL_SYMBOL ::=
2857   IDENTIFIER
2858 | static_string_EXPRESSION
2859 @end smallexample
2860
2861 @noindent
2862 This pragma is identical in effect to pragma @code{Common_Object}.
2863
2864 @node Pragma Pure_Function
2865 @unnumberedsec Pragma Pure_Function
2866 @findex Pure_Function
2867 @noindent
2868 Syntax:
2869
2870 @smallexample @c ada
2871 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
2872 @end smallexample
2873
2874 @noindent
2875 This pragma appears in the same declarative part as a function
2876 declaration (or a set of function declarations if more than one
2877 overloaded declaration exists, in which case the pragma applies
2878 to all entities).  It specifies that the function @code{Entity} is
2879 to be considered pure for the purposes of code generation.  This means
2880 that the compiler can assume that there are no side effects, and
2881 in particular that two calls with identical arguments produce the
2882 same result.  It also means that the function can be used in an
2883 address clause.
2884
2885 Note that, quite deliberately, there are no static checks to try
2886 to ensure that this promise is met, so @code{Pure_Function} can be used
2887 with functions that are conceptually pure, even if they do modify
2888 global variables.  For example, a square root function that is
2889 instrumented to count the number of times it is called is still
2890 conceptually pure, and can still be optimized, even though it
2891 modifies a global variable (the count).  Memo functions are another
2892 example (where a table of previous calls is kept and consulted to
2893 avoid re-computation).
2894
2895 @findex Pure
2896 Note: Most functions in a @code{Pure} package are automatically pure, and
2897 there is no need to use pragma @code{Pure_Function} for such functions.  One
2898 exception is any function that has at least one formal of type
2899 @code{System.Address} or a type derived from it.  Such functions are not
2900 considered pure by default, since the compiler assumes that the
2901 @code{Address} parameter may be functioning as a pointer and that the
2902 referenced data may change even if the address value does not.
2903 Similarly, imported functions are not considered to be pure by default,
2904 since there is no way of checking that they are in fact pure.  The use
2905 of pragma @code{Pure_Function} for such a function will override these default
2906 assumption, and cause the compiler to treat a designated subprogram as pure
2907 in these cases.
2908
2909 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
2910 applies to the underlying renamed function.  This can be used to
2911 disambiguate cases of overloading where some but not all functions
2912 in a set of overloaded functions are to be designated as pure.
2913
2914 @node Pragma Ravenscar
2915 @unnumberedsec Pragma Ravenscar
2916 @findex Ravenscar
2917 @noindent
2918 Syntax:
2919
2920 @smallexample @c ada
2921 pragma Ravenscar;
2922 @end smallexample
2923
2924 @noindent
2925 A configuration pragma that establishes the following set of restrictions:
2926
2927 @table @code
2928 @item No_Abort_Statements
2929 [RM D.7] There are no abort_statements, and there are
2930 no calls to Task_Identification.Abort_Task.
2931
2932 @item No_Select_Statements
2933 There are no select_statements.
2934
2935 @item No_Task_Hierarchy
2936 [RM D.7] All (non-environment) tasks depend
2937 directly on the environment task of the partition.
2938
2939 @item No_Task_Allocators
2940 [RM D.7] There are no allocators for task types
2941 or types containing task subcomponents.
2942
2943 @item No_Dynamic_Priorities
2944 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2945
2946 @item No_Terminate_Alternatives
2947 [RM D.7] There are no selective_accepts with terminate_alternatives
2948
2949 @item No_Dynamic_Interrupts
2950 There are no semantic dependencies on Ada.Interrupts.
2951
2952 @item No_Implicit_Heap_Allocations
2953 [RM D.7] No constructs are allowed to cause implicit heap allocation
2954
2955 @item No_Protected_Type_Allocators
2956 There are no allocators for protected types or
2957 types containing protected subcomponents.
2958
2959 @item No_Local_Protected_Objects
2960 Protected objects and access types that designate
2961 such objects shall be declared only at library level.
2962
2963 @item No_Requeue_Statements
2964 Requeue statements are not allowed.
2965
2966 @item No_Calendar
2967 There are no semantic dependencies on the package Ada.Calendar.
2968
2969 @item No_Relative_Delay
2970 There are no delay_relative_statements.
2971
2972 @item No_Task_Attributes
2973 There are no semantic dependencies on the Ada.Task_Attributes package and
2974 there are no references to the attributes Callable and Terminated [RM 9.9].
2975
2976 @item Boolean_Entry_Barriers
2977 Entry barrier condition expressions shall be boolean
2978 objects which are declared in the protected type
2979 which contains the entry.
2980
2981 @item Max_Asynchronous_Select_Nesting = 0
2982 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous_selects.
2983 A value of zero prevents the use of any asynchronous_select.
2984
2985 @item Max_Task_Entries = 0
2986 [RM D.7] Specifies the maximum number of entries
2987 per task.  The bounds of every entry family
2988 of a task unit shall be static, or shall be
2989 defined by a discriminant of a subtype whose
2990 corresponding bound is static.  A value of zero
2991 indicates that no rendezvous are possible.  For
2992 the Ravenscar pragma, the value of Max_Task_Entries is always
2993 0 (zero).
2994
2995 @item Max_Protected_Entries = 1
2996 [RM D.7] Specifies the maximum number of entries per
2997 protected type.  The bounds of every entry family of
2998 a protected unit shall be static, or shall be defined
2999 by a discriminant of a subtype whose corresponding
3000 bound is static.  For the Ravenscar pragma the value of
3001 Max_Protected_Entries is always 1.
3002
3003 @item Max_Select_Alternatives = 0
3004 [RM D.7] Specifies the maximum number of alternatives in a selective_accept.
3005 For the Ravenscar pragma the value is always 0.
3006
3007 @item No_Task_Termination
3008 Tasks which terminate are erroneous.
3009
3010 @item No_Entry_Queue
3011 No task can be queued on a protected entry.  Note that this restrictions is
3012 checked at run time.  The violation of this restriction generates a
3013 Program_Error exception.
3014 @end table
3015
3016 @noindent
3017 This set of restrictions corresponds to the definition of the ``Ravenscar
3018 Profile'' for limited tasking, devised and published by the
3019 @cite{International Real-Time Ada Workshop}, 1997,
3020 and whose most recent description is available at
3021 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3022
3023 The above set is a superset of the restrictions provided by pragma
3024 @code{Restricted_Run_Time}, it includes five additional restrictions
3025 (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements},
3026 @code{No_Calendar},
3027 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3028 that pragma @code{Ravenscar}, like the pragma @code{Restricted_Run_Time},
3029 automatically causes the use of a simplified, more efficient version
3030 of the tasking run-time system.
3031
3032 @node Pragma Restricted_Run_Time
3033 @unnumberedsec Pragma Restricted_Run_Time
3034 @findex Restricted_Run_Time
3035 @noindent
3036 Syntax:
3037
3038 @smallexample @c ada
3039 pragma Restricted_Run_Time;
3040 @end smallexample
3041
3042 @noindent
3043 A configuration pragma that establishes the following set of restrictions:
3044
3045 @itemize @bullet
3046 @item No_Abort_Statements
3047 @item No_Entry_Queue
3048 @item No_Task_Hierarchy
3049 @item No_Task_Allocators
3050 @item No_Dynamic_Priorities
3051 @item No_Terminate_Alternatives
3052 @item No_Dynamic_Interrupts
3053 @item No_Protected_Type_Allocators
3054 @item No_Local_Protected_Objects
3055 @item No_Requeue_Statements
3056 @item No_Task_Attributes
3057 @item Max_Asynchronous_Select_Nesting =  0
3058 @item Max_Task_Entries =  0
3059 @item Max_Protected_Entries = 1
3060 @item Max_Select_Alternatives = 0
3061 @end itemize
3062
3063 @noindent
3064 This set of restrictions causes the automatic selection of a simplified
3065 version of the run time that provides improved performance for the
3066 limited set of tasking functionality permitted by this set of restrictions.
3067
3068 @node Pragma Restriction_Warnings
3069 @unnumberedsec Pragma Restriction_Warnings
3070 @findex Restriction_Warnings
3071 @noindent
3072 Syntax:
3073
3074 @smallexample @c ada
3075 pragma Restriction_Warnings
3076   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3077 @end smallexample
3078
3079 @noindent
3080 This pragma allows a series of restriction identifiers to be
3081 specified (the list of allowed identifiers is the same as for
3082 pragma @code{Restrictions}). For each of these identifiers
3083 the compiler checks for violations of the restriction, but
3084 generates a warning message rather than an error message
3085 if the restriction is violated.
3086
3087 @node Pragma Source_File_Name
3088 @unnumberedsec Pragma Source_File_Name
3089 @findex Source_File_Name
3090 @noindent
3091 Syntax:
3092
3093 @smallexample @c ada
3094 pragma Source_File_Name (
3095   [Unit_Name   =>] unit_NAME,
3096   Spec_File_Name =>  STRING_LITERAL);
3097
3098 pragma Source_File_Name (
3099   [Unit_Name   =>] unit_NAME,
3100   Body_File_Name =>  STRING_LITERAL);
3101 @end smallexample
3102
3103 @noindent
3104 Use this to override the normal naming convention.  It is a configuration
3105 pragma, and so has the usual applicability of configuration pragmas
3106 (i.e.@: it applies to either an entire partition, or to all units in a
3107 compilation, or to a single unit, depending on how it is used.
3108 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3109 the second argument is required, and indicates whether this is the file
3110 name for the spec or for the body.
3111
3112 Another form of the @code{Source_File_Name} pragma allows
3113 the specification of patterns defining alternative file naming schemes
3114 to apply to all files.
3115
3116 @smallexample @c ada
3117 pragma Source_File_Name
3118   (Spec_File_Name => STRING_LITERAL
3119    [,Casing => CASING_SPEC]
3120    [,Dot_Replacement => STRING_LITERAL]);
3121
3122 pragma Source_File_Name
3123   (Body_File_Name => STRING_LITERAL
3124    [,Casing => CASING_SPEC]
3125    [,Dot_Replacement => STRING_LITERAL]);
3126
3127 pragma Source_File_Name
3128   (Subunit_File_Name => STRING_LITERAL
3129    [,Casing => CASING_SPEC]
3130    [,Dot_Replacement => STRING_LITERAL]);
3131
3132 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3133 @end smallexample
3134
3135 @noindent
3136 The first argument is a pattern that contains a single asterisk indicating
3137 the point at which the unit name is to be inserted in the pattern string
3138 to form the file name.  The second argument is optional.  If present it
3139 specifies the casing of the unit name in the resulting file name string.
3140 The default is lower case.  Finally the third argument allows for systematic
3141 replacement of any dots in the unit name by the specified string literal.
3142
3143 A pragma Source_File_Name cannot appear after a
3144 @ref{Pragma Source_File_Name_Project}.
3145
3146 For more details on the use of the @code{Source_File_Name} pragma,
3147 see the sections ``Using Other File Names'' and
3148 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3149
3150 @node Pragma Source_File_Name_Project
3151 @unnumberedsec Pragma Source_File_Name_Project
3152 @findex Source_File_Name_Project
3153 @noindent
3154
3155 This pragma has the same syntax and semantics as pragma Source_File_Name.
3156 It is only allowed as a stand alone configuration pragma.
3157 It cannot appear after a @ref{Pragma Source_File_Name}, and
3158 most importantly, once pragma Source_File_Name_Project appears,
3159 no further Source_File_Name pragmas are allowed.
3160
3161 The intention is that Source_File_Name_Project pragmas are always
3162 generated by the Project Manager in a manner consistent with the naming
3163 specified in a project file, and when naming is controlled in this manner,
3164 it is not permissible to attempt to modify this naming scheme using
3165 Source_File_Name pragmas (which would not be known to the project manager).
3166
3167 @node Pragma Source_Reference
3168 @unnumberedsec Pragma Source_Reference
3169 @findex Source_Reference
3170 @noindent
3171 Syntax:
3172
3173 @smallexample @c ada
3174 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3175 @end smallexample
3176
3177 @noindent
3178 This pragma must appear as the first line of a source file.
3179 @var{integer_literal} is the logical line number of the line following
3180 the pragma line (for use in error messages and debugging
3181 information).  @var{string_literal} is a static string constant that
3182 specifies the file name to be used in error messages and debugging
3183 information.  This is most notably used for the output of @code{gnatchop}
3184 with the @code{-r} switch, to make sure that the original unchopped
3185 source file is the one referred to.
3186
3187 The second argument must be a string literal, it cannot be a static
3188 string expression other than a string literal.  This is because its value
3189 is needed for error messages issued by all phases of the compiler.
3190
3191 @node Pragma Stream_Convert
3192 @unnumberedsec Pragma Stream_Convert
3193 @findex Stream_Convert
3194 @noindent
3195 Syntax:
3196
3197 @smallexample @c ada
3198 pragma Stream_Convert (
3199   [Entity =>] type_LOCAL_NAME,
3200   [Read   =>] function_NAME,
3201   [Write  =>] function_NAME);
3202 @end smallexample
3203
3204 @noindent
3205 This pragma provides an efficient way of providing stream functions for
3206 types defined in packages.  Not only is it simpler to use than declaring
3207 the necessary functions with attribute representation clauses, but more
3208 significantly, it allows the declaration to made in such a way that the
3209 stream packages are not loaded unless they are needed.  The use of
3210 the Stream_Convert pragma adds no overhead at all, unless the stream
3211 attributes are actually used on the designated type.
3212
3213 The first argument specifies the type for which stream functions are
3214 provided.  The second parameter provides a function used to read values
3215 of this type.  It must name a function whose argument type may be any
3216 subtype, and whose returned type must be the type given as the first
3217 argument to the pragma.
3218
3219 The meaning of the @var{Read}
3220 parameter is that if a stream attribute directly
3221 or indirectly specifies reading of the type given as the first parameter,
3222 then a value of the type given as the argument to the Read function is
3223 read from the stream, and then the Read function is used to convert this
3224 to the required target type.
3225
3226 Similarly the @var{Write} parameter specifies how to treat write attributes
3227 that directly or indirectly apply to the type given as the first parameter.
3228 It must have an input parameter of the type specified by the first parameter,
3229 and the return type must be the same as the input type of the Read function.
3230 The effect is to first call the Write function to convert to the given stream
3231 type, and then write the result type to the stream.
3232
3233 The Read and Write functions must not be overloaded subprograms.  If necessary
3234 renamings can be supplied to meet this requirement.
3235 The usage of this attribute is best illustrated by a simple example, taken
3236 from the GNAT implementation of package Ada.Strings.Unbounded:
3237
3238 @smallexample @c ada
3239 function To_Unbounded (S : String)
3240            return Unbounded_String
3241   renames To_Unbounded_String;
3242
3243 pragma Stream_Convert
3244   (Unbounded_String, To_Unbounded, To_String);
3245 @end smallexample
3246
3247 @noindent
3248 The specifications of the referenced functions, as given in the Ada 95
3249 Reference Manual are:
3250
3251 @smallexample @c ada
3252 function To_Unbounded_String (Source : String)
3253   return Unbounded_String;
3254
3255 function To_String (Source : Unbounded_String)
3256   return String;
3257 @end smallexample
3258
3259 @noindent
3260 The effect is that if the value of an unbounded string is written to a
3261 stream, then the representation of the item in the stream is in the same
3262 format used for @code{Standard.String}, and this same representation is
3263 expected when a value of this type is read from the stream.
3264
3265 @node Pragma Style_Checks
3266 @unnumberedsec Pragma Style_Checks
3267 @findex Style_Checks
3268 @noindent
3269 Syntax:
3270
3271 @smallexample @c ada
3272 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3273                      On | Off [, LOCAL_NAME]);
3274 @end smallexample
3275
3276 @noindent
3277 This pragma is used in conjunction with compiler switches to control the
3278 built in style checking provided by GNAT@.  The compiler switches, if set,
3279 provide an initial setting for the switches, and this pragma may be used
3280 to modify these settings, or the settings may be provided entirely by
3281 the use of the pragma.  This pragma can be used anywhere that a pragma
3282 is legal, including use as a configuration pragma (including use in
3283 the @file{gnat.adc} file).
3284
3285 The form with a string literal specifies which style options are to be
3286 activated.  These are additive, so they apply in addition to any previously
3287 set style check options.  The codes for the options are the same as those
3288 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3289 For example the following two methods can be used to enable
3290 layout checking:
3291
3292 @itemize @bullet
3293 @item
3294 @smallexample @c ada
3295 pragma Style_Checks ("l");
3296 @end smallexample
3297
3298 @item
3299 @smallexample
3300 gcc -c -gnatyl @dots{}
3301 @end smallexample
3302 @end itemize
3303
3304 @noindent
3305 The form ALL_CHECKS activates all standard checks (its use is equivalent
3306 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3307 Guide for details.
3308
3309 The forms with @code{Off} and @code{On}
3310 can be used to temporarily disable style checks
3311 as shown in the following example:
3312
3313 @smallexample @c ada
3314 @iftex
3315 @leftskip=0cm
3316 @end iftex
3317 pragma Style_Checks ("k"); -- requires keywords in lower case
3318 pragma Style_Checks (Off); -- turn off style checks
3319 NULL;                      -- this will not generate an error message
3320 pragma Style_Checks (On);  -- turn style checks back on
3321 NULL;                      -- this will generate an error message
3322 @end smallexample
3323
3324 @noindent
3325 Finally the two argument form is allowed only if the first argument is
3326 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3327 for the specified entity, as shown in the following example:
3328
3329 @smallexample @c ada
3330 @iftex
3331 @leftskip=0cm
3332 @end iftex
3333 pragma Style_Checks ("r"); -- require consistency of identifier casing
3334 Arg : Integer;
3335 Rf1 : Integer := ARG;      -- incorrect, wrong case
3336 pragma Style_Checks (Off, Arg);
3337 Rf2 : Integer := ARG;      -- OK, no error
3338 @end smallexample
3339
3340 @node Pragma Subtitle
3341 @unnumberedsec Pragma Subtitle
3342 @findex Subtitle
3343 @noindent
3344 Syntax:
3345
3346 @smallexample @c ada
3347 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3348 @end smallexample
3349
3350 @noindent
3351 This pragma is recognized for compatibility with other Ada compilers
3352 but is ignored by GNAT@.
3353
3354 @node Pragma Suppress_All
3355 @unnumberedsec Pragma Suppress_All
3356 @findex Suppress_All
3357 @noindent
3358 Syntax:
3359
3360 @smallexample @c ada
3361 pragma Suppress_All;
3362 @end smallexample
3363
3364 @noindent
3365 This pragma can only appear immediately following a compilation
3366 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3367 which it follows.  This pragma is implemented for compatibility with DEC
3368 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3369 configuration pragma is the preferred usage in GNAT@.
3370
3371 @node Pragma Suppress_Exception_Locations
3372 @unnumberedsec Pragma Suppress_Exception_Locations
3373 @findex Suppress_Exception_Locations
3374 @noindent
3375 Syntax:
3376
3377 @smallexample @c ada
3378 pragma Suppress_Exception_Locations;
3379 @end smallexample
3380
3381 @noindent
3382 In normal mode, a raise statement for an exception by default generates
3383 an exception message giving the file name and line number for the location
3384 of the raise. This is useful for debugging and logging purposes, but this
3385 entails extra space for the strings for the messages. The configuration
3386 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3387 generation of these strings, with the result that space is saved, but the
3388 exception message for such raises is null. This configuration pragma may
3389 appear in a global configuration pragma file, or in a specific unit as
3390 usual. It is not required that this pragma be used consistently within
3391 a partition, so it is fine to have some units within a partition compiled
3392 with this pragma and others compiled in normal mode without it.
3393
3394 @node Pragma Suppress_Initialization
3395 @unnumberedsec Pragma Suppress_Initialization
3396 @findex Suppress_Initialization
3397 @cindex Suppressing initialization
3398 @cindex Initialization, suppression of
3399 @noindent
3400 Syntax:
3401
3402 @smallexample @c ada
3403 pragma Suppress_Initialization ([Entity =>] type_Name);
3404 @end smallexample
3405
3406 @noindent
3407 This pragma suppresses any implicit or explicit initialization
3408 associated with the given type name for all variables of this type.
3409
3410 @node Pragma Task_Info
3411 @unnumberedsec Pragma Task_Info
3412 @findex Task_Info
3413 @noindent
3414 Syntax
3415
3416 @smallexample @c ada
3417 pragma Task_Info (EXPRESSION);
3418 @end smallexample
3419
3420 @noindent
3421 This pragma appears within a task definition (like pragma
3422 @code{Priority}) and applies to the task in which it appears.  The
3423 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3424 The @code{Task_Info} pragma provides system dependent control over
3425 aspects of tasking implementation, for example, the ability to map
3426 tasks to specific processors.  For details on the facilities available
3427 for the version of GNAT that you are using, see the documentation
3428 in the specification of package System.Task_Info in the runtime
3429 library.
3430
3431 @node Pragma Task_Name
3432 @unnumberedsec Pragma Task_Name
3433 @findex Task_Name
3434 @noindent
3435 Syntax
3436
3437 @smallexample @c ada
3438 pragma Task_Name (string_EXPRESSION);
3439 @end smallexample
3440
3441 @noindent
3442 This pragma appears within a task definition (like pragma
3443 @code{Priority}) and applies to the task in which it appears.  The
3444 argument must be of type String, and provides a name to be used for
3445 the task instance when the task is created.  Note that this expression
3446 is not required to be static, and in particular, it can contain
3447 references to task discriminants.  This facility can be used to
3448 provide different names for different tasks as they are created,
3449 as illustrated in the example below.
3450
3451 The task name is recorded internally in the run-time structures
3452 and is accessible to tools like the debugger.  In addition the
3453 routine @code{Ada.Task_Identification.Image} will return this
3454 string, with a unique task address appended.
3455
3456 @smallexample @c ada
3457 --  Example of the use of pragma Task_Name
3458
3459 with Ada.Task_Identification;
3460 use Ada.Task_Identification;
3461 with Text_IO; use Text_IO;
3462 procedure t3 is
3463
3464    type Astring is access String;
3465
3466    task type Task_Typ (Name : access String) is
3467       pragma Task_Name (Name.all);
3468    end Task_Typ;
3469
3470    task body Task_Typ is
3471       Nam : constant String := Image (Current_Task);
3472    begin
3473       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3474    end Task_Typ;
3475
3476    type Ptr_Task is access Task_Typ;
3477    Task_Var : Ptr_Task;
3478
3479 begin
3480    Task_Var :=
3481      new Task_Typ (new String'("This is task 1"));
3482    Task_Var :=
3483      new Task_Typ (new String'("This is task 2"));
3484 end;
3485 @end smallexample
3486
3487 @node Pragma Task_Storage
3488 @unnumberedsec Pragma Task_Storage
3489 @findex Task_Storage
3490 Syntax:
3491
3492 @smallexample @c ada
3493 pragma Task_Storage (
3494   [Task_Type =>] LOCAL_NAME,
3495   [Top_Guard =>] static_integer_EXPRESSION);
3496 @end smallexample
3497
3498 @noindent
3499 This pragma specifies the length of the guard area for tasks.  The guard
3500 area is an additional storage area allocated to a task.  A value of zero
3501 means that either no guard area is created or a minimal guard area is
3502 created, depending on the target.  This pragma can appear anywhere a
3503 @code{Storage_Size} attribute definition clause is allowed for a task
3504 type.
3505
3506 @node Pragma Thread_Body
3507 @unnumberedsec Pragma Thread_Body
3508 @findex Thread_Body
3509 Syntax:
3510
3511 @smallexample @c ada
3512 pragma Thread_Body (
3513   [Entity =>] LOCAL_NAME,
3514  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3515 @end smallexample
3516
3517 @noindent
3518 This pragma specifies that the subprogram whose name is given as the
3519 @code{Entity} argument is a thread body, which will be activated
3520 by being called via its Address from foreign code. The purpose is
3521 to allow execution and registration of the foreign thread within the
3522 Ada run-time system.
3523
3524 See the library unit @code{System.Threads} for details on the expansion of
3525 a thread body subprogram, including the calls made to subprograms
3526 within System.Threads to register the task.  This unit also lists the
3527 targets and runtime systems for which this pragma is supported.
3528
3529 A thread body subprogram may not be called directly from Ada code, and
3530 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3531 to such a subprogram. The only legitimate way of calling such a subprogram
3532 is to pass its Address to foreign code and then make the call from the
3533 foreign code.
3534
3535 A thread body subprogram may have any parameters, and it may be a function
3536 returning a result. The convention of the thread body subprogram may be
3537 set in the usual manner using @code{pragma Convention}.
3538
3539 The secondary stack size parameter, if given, is used to set the size
3540 of secondary stack for the thread. The secondary stack is allocated as
3541 a local variable of the expanded thread body subprogram, and thus is
3542 allocated out of the main thread stack size. If no secondary stack
3543 size parameter is present, the default size (from the declaration in
3544 @code{System.Secondary_Stack} is used.
3545
3546 @node Pragma Time_Slice
3547 @unnumberedsec Pragma Time_Slice
3548 @findex Time_Slice
3549 @noindent
3550 Syntax:
3551
3552 @smallexample @c ada
3553 pragma Time_Slice (static_duration_EXPRESSION);
3554 @end smallexample
3555
3556 @noindent
3557 For implementations of GNAT on operating systems where it is possible
3558 to supply a time slice value, this pragma may be used for this purpose.
3559 It is ignored if it is used in a system that does not allow this control,
3560 or if it appears in other than the main program unit.
3561 @cindex OpenVMS
3562 Note that the effect of this pragma is identical to the effect of the
3563 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3564
3565 @node Pragma Title
3566 @unnumberedsec Pragma Title
3567 @findex Title
3568 @noindent
3569 Syntax:
3570
3571 @smallexample @c ada
3572 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3573
3574 TITLING_OPTION ::=
3575   [Title    =>] STRING_LITERAL,
3576 | [Subtitle =>] STRING_LITERAL
3577 @end smallexample
3578
3579 @noindent
3580 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3581 pragma used in DEC Ada 83 implementations to provide a title and/or
3582 subtitle for the program listing.  The program listing generated by GNAT
3583 does not have titles or subtitles.
3584
3585 Unlike other pragmas, the full flexibility of named notation is allowed
3586 for this pragma, i.e.@: the parameters may be given in any order if named
3587 notation is used, and named and positional notation can be mixed
3588 following the normal rules for procedure calls in Ada.
3589
3590 @node Pragma Unchecked_Union
3591 @unnumberedsec Pragma Unchecked_Union
3592 @cindex Unions in C
3593 @findex Unchecked_Union
3594 @noindent
3595 Syntax:
3596
3597 @smallexample @c ada
3598 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3599 @end smallexample
3600
3601 @noindent
3602 This pragma is used to declare that the specified type should be represented
3603 in a manner
3604 equivalent to a C union type, and is intended only for use in
3605 interfacing with C code that uses union types.  In Ada terms, the named
3606 type must obey the following rules:
3607
3608 @itemize @bullet
3609 @item
3610 It is a non-tagged non-limited record type.
3611 @item
3612 It has a single discrete discriminant with a default value.
3613 @item
3614 The component list consists of a single variant part.
3615 @item
3616 Each variant has a component list with a single component.
3617 @item
3618 No nested variants are allowed.
3619 @item
3620 No component has an explicit default value.
3621 @item
3622 No component has a non-static constraint.
3623 @end itemize
3624
3625 @noindent
3626 In addition, given a type that meets the above requirements, the
3627 following restrictions apply to its use throughout the program:
3628
3629 @itemize @bullet
3630 @item
3631 The discriminant name can be mentioned only in an aggregate.
3632 @item
3633 No subtypes may be created of this type.
3634 @item
3635 The type may not be constrained by giving a discriminant value.
3636 @item
3637 The type cannot be passed as the actual for a generic formal with a
3638 discriminant.
3639 @end itemize
3640
3641 @noindent
3642 Equality and inequality operations on @code{unchecked_unions} are not
3643 available, since there is no discriminant to compare and the compiler
3644 does not even know how many bits to compare.  It is implementation
3645 dependent whether this is detected at compile time as an illegality or
3646 whether it is undetected and considered to be an erroneous construct.  In
3647 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3648 the composite case (where two composites are compared that contain an
3649 unchecked union component), so such comparisons are simply considered
3650 erroneous.
3651
3652 The layout of the resulting type corresponds exactly to a C union, where
3653 each branch of the union corresponds to a single variant in the Ada
3654 record.  The semantics of the Ada program is not changed in any way by
3655 the pragma, i.e.@: provided the above restrictions are followed, and no
3656 erroneous incorrect references to fields or erroneous comparisons occur,
3657 the semantics is exactly as described by the Ada reference manual.
3658 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3659 type and the default convention is C.
3660
3661 @node Pragma Unimplemented_Unit
3662 @unnumberedsec Pragma Unimplemented_Unit
3663 @findex Unimplemented_Unit
3664 @noindent
3665 Syntax:
3666
3667 @smallexample @c ada
3668 pragma Unimplemented_Unit;
3669 @end smallexample
3670
3671 @noindent
3672 If this pragma occurs in a unit that is processed by the compiler, GNAT
3673 aborts with the message @samp{@var{xxx} not implemented}, where
3674 @var{xxx} is the name of the current compilation unit.  This pragma is
3675 intended to allow the compiler to handle unimplemented library units in
3676 a clean manner.
3677
3678 The abort only happens if code is being generated.  Thus you can use
3679 specs of unimplemented packages in syntax or semantic checking mode.
3680
3681 @node Pragma Universal_Data
3682 @unnumberedsec Pragma Universal_Data
3683 @findex Universal_Data
3684 @noindent
3685 Syntax:
3686
3687 @smallexample @c ada
3688 pragma Universal_Data [(library_unit_Name)];
3689 @end smallexample
3690
3691 @noindent
3692 This pragma is supported only for the AAMP target and is ignored for
3693 other targets. The pragma specifies that all library-level objects
3694 (Counter 0 data) associated with the library unit are to be accessed
3695 and updated using universal addressing (24-bit addresses for AAMP5)
3696 rather than the default of 16-bit Data Environment (DENV) addressing.
3697 Use of this pragma will generally result in less efficient code for
3698 references to global data associated with the library unit, but
3699 allows such data to be located anywhere in memory. This pragma is
3700 a library unit pragma, but can also be used as a configuration pragma
3701 (including use in the @file{gnat.adc} file). The functionality
3702 of this pragma is also available by applying the -univ switch on the
3703 compilations of units where universal addressing of the data is desired.
3704
3705 @node Pragma Unreferenced
3706 @unnumberedsec Pragma Unreferenced
3707 @findex Unreferenced
3708 @cindex Warnings, unreferenced
3709 @noindent
3710 Syntax:
3711
3712 @smallexample @c ada
3713 pragma Unreferenced (local_Name @{, local_Name@});
3714 @end smallexample
3715
3716 @noindent
3717 This pragma signals that the entities whose names are listed are
3718 deliberately not referenced in the current source unit. This
3719 suppresses warnings about the
3720 entities being unreferenced, and in addition a warning will be
3721 generated if one of these entities is in fact referenced in the
3722 same unit as the pragma (or in the corresponding body, or one
3723 of its subunits).
3724
3725 This is particularly useful for clearly signaling that a particular
3726 parameter is not referenced in some particular subprogram implementation
3727 and that this is deliberate. It can also be useful in the case of
3728 objects declared only for their initialization or finalization side
3729 effects.
3730
3731 If @code{local_Name} identifies more than one matching homonym in the
3732 current scope, then the entity most recently declared is the one to which
3733 the pragma applies.
3734
3735 The left hand side of an assignment does not count as a reference for the
3736 purpose of this pragma. Thus it is fine to assign to an entity for which
3737 pragma Unreferenced is given.
3738
3739 @node Pragma Unreserve_All_Interrupts
3740 @unnumberedsec Pragma Unreserve_All_Interrupts
3741 @findex Unreserve_All_Interrupts
3742 @noindent
3743 Syntax:
3744
3745 @smallexample @c ada
3746 pragma Unreserve_All_Interrupts;
3747 @end smallexample
3748
3749 @noindent
3750 Normally certain interrupts are reserved to the implementation.  Any attempt
3751 to attach an interrupt causes Program_Error to be raised, as described in
3752 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3753 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3754 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3755 interrupt execution.
3756
3757 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3758 a program, then all such interrupts are unreserved.  This allows the
3759 program to handle these interrupts, but disables their standard
3760 functions.  For example, if this pragma is used, then pressing
3761 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3762 a program can then handle the @code{SIGINT} interrupt as it chooses.
3763
3764 For a full list of the interrupts handled in a specific implementation,
3765 see the source code for the specification of @code{Ada.Interrupts.Names} in
3766 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3767 list of interrupts recognized for a given target.  The documentation in
3768 this file also specifies what interrupts are affected by the use of
3769 the @code{Unreserve_All_Interrupts} pragma.
3770
3771 For a more general facility for controlling what interrupts can be
3772 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3773 of the @code{Unreserve_All_Interrupts} pragma.
3774
3775 @node Pragma Unsuppress
3776 @unnumberedsec Pragma Unsuppress
3777 @findex Unsuppress
3778 @noindent
3779 Syntax:
3780
3781 @smallexample @c ada
3782 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3783 @end smallexample
3784
3785 @noindent
3786 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3787 there is no corresponding pragma @code{Suppress} in effect, it has no
3788 effect.  The range of the effect is the same as for pragma
3789 @code{Suppress}.  The meaning of the arguments is identical to that used
3790 in pragma @code{Suppress}.
3791
3792 One important application is to ensure that checks are on in cases where
3793 code depends on the checks for its correct functioning, so that the code
3794 will compile correctly even if the compiler switches are set to suppress
3795 checks.
3796
3797 @node Pragma Use_VADS_Size
3798 @unnumberedsec Pragma Use_VADS_Size
3799 @cindex @code{Size}, VADS compatibility
3800 @findex Use_VADS_Size
3801 @noindent
3802 Syntax:
3803
3804 @smallexample @c ada
3805 pragma Use_VADS_Size;
3806 @end smallexample
3807
3808 @noindent
3809 This is a configuration pragma.  In a unit to which it applies, any use
3810 of the 'Size attribute is automatically interpreted as a use of the
3811 'VADS_Size attribute.  Note that this may result in incorrect semantic
3812 processing of valid Ada 95 programs.  This is intended to aid in the
3813 handling of legacy code which depends on the interpretation of Size
3814 as implemented in the VADS compiler.  See description of the VADS_Size
3815 attribute for further details.
3816
3817 @node Pragma Validity_Checks
3818 @unnumberedsec Pragma Validity_Checks
3819 @findex Validity_Checks
3820 @noindent
3821 Syntax:
3822
3823 @smallexample @c ada
3824 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3825 @end smallexample
3826
3827 @noindent
3828 This pragma is used in conjunction with compiler switches to control the
3829 built-in validity checking provided by GNAT@.  The compiler switches, if set
3830 provide an initial setting for the switches, and this pragma may be used
3831 to modify these settings, or the settings may be provided entirely by
3832 the use of the pragma.  This pragma can be used anywhere that a pragma
3833 is legal, including use as a configuration pragma (including use in
3834 the @file{gnat.adc} file).
3835
3836 The form with a string literal specifies which validity options are to be
3837 activated.  The validity checks are first set to include only the default
3838 reference manual settings, and then a string of letters in the string
3839 specifies the exact set of options required.  The form of this string
3840 is exactly as described for the @code{-gnatVx} compiler switch (see the
3841 GNAT users guide for details).  For example the following two methods
3842 can be used to enable validity checking for mode @code{in} and
3843 @code{in out} subprogram parameters:
3844
3845 @itemize @bullet
3846 @item
3847 @smallexample @c ada
3848 pragma Validity_Checks ("im");
3849 @end smallexample
3850
3851 @item
3852 @smallexample
3853 gcc -c -gnatVim @dots{}
3854 @end smallexample
3855 @end itemize
3856
3857 @noindent
3858 The form ALL_CHECKS activates all standard checks (its use is equivalent
3859 to the use of the @code{gnatva} switch.
3860
3861 The forms with @code{Off} and @code{On}
3862 can be used to temporarily disable validity checks
3863 as shown in the following example:
3864
3865 @smallexample @c ada
3866 @iftex
3867 @leftskip=0cm
3868 @end iftex
3869 pragma Validity_Checks ("c"); -- validity checks for copies
3870 pragma Validity_Checks (Off); -- turn off validity checks
3871 A := B;                       -- B will not be validity checked
3872 pragma Validity_Checks (On);  -- turn validity checks back on
3873 A := C;                       -- C will be validity checked
3874 @end smallexample
3875
3876 @node Pragma Volatile
3877 @unnumberedsec Pragma Volatile
3878 @findex Volatile
3879 @noindent
3880 Syntax:
3881
3882 @smallexample @c ada
3883 pragma Volatile (local_NAME);
3884 @end smallexample
3885
3886 @noindent
3887 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3888 implementation is fully conformant with this definition.  The reason it
3889 is mentioned in this section is that a pragma of the same name was supplied
3890 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3891 of pragma Volatile is upwards compatible with the implementation in
3892 Dec Ada 83.
3893
3894 @node Pragma Warnings
3895 @unnumberedsec Pragma Warnings
3896 @findex Warnings
3897 @noindent
3898 Syntax:
3899
3900 @smallexample @c ada
3901 pragma Warnings (On | Off [, LOCAL_NAME]);
3902 @end smallexample
3903
3904 @noindent
3905 Normally warnings are enabled, with the output being controlled by
3906 the command line switch.  Warnings (@code{Off}) turns off generation of
3907 warnings until a Warnings (@code{On}) is encountered or the end of the
3908 current unit.  If generation of warnings is turned off using this
3909 pragma, then no warning messages are output, regardless of the
3910 setting of the command line switches.
3911
3912 The form with a single argument is a configuration pragma.
3913
3914 If the @var{local_name} parameter is present, warnings are suppressed for
3915 the specified entity.  This suppression is effective from the point where
3916 it occurs till the end of the extended scope of the variable (similar to
3917 the scope of @code{Suppress}).
3918
3919 @node Pragma Weak_External
3920 @unnumberedsec Pragma Weak_External
3921 @findex Weak_External
3922 @noindent
3923 Syntax:
3924
3925 @smallexample @c ada
3926 pragma Weak_External ([Entity =>] LOCAL_NAME);
3927 @end smallexample
3928
3929 @noindent
3930 This pragma specifies that the given entity should be marked as a weak
3931 external (one that does not have to be resolved) for the linker.  For
3932 further details, consult the GCC manual.
3933
3934 @node Implementation Defined Attributes
3935 @chapter Implementation Defined Attributes
3936 Ada 95 defines (throughout the Ada 95 reference manual,
3937 summarized in annex K),
3938 a set of attributes that provide useful additional functionality in all
3939 areas of the language.  These language defined attributes are implemented
3940 in GNAT and work as described in the Ada 95 Reference Manual.
3941
3942 In addition, Ada 95 allows implementations to define additional
3943 attributes whose meaning is defined by the implementation.  GNAT provides
3944 a number of these implementation-dependent attributes which can be used
3945 to extend and enhance the functionality of the compiler.  This section of
3946 the GNAT reference manual describes these additional attributes.
3947
3948 Note that any program using these attributes may not be portable to
3949 other compilers (although GNAT implements this set of attributes on all
3950 platforms).  Therefore if portability to other compilers is an important
3951 consideration, you should minimize the use of these attributes.
3952
3953 @menu
3954 * Abort_Signal::
3955 * Address_Size::
3956 * Asm_Input::
3957 * Asm_Output::
3958 * AST_Entry::
3959 * Bit::
3960 * Bit_Position::
3961 * Code_Address::
3962 * Default_Bit_Order::
3963 * Elaborated::
3964 * Elab_Body::
3965 * Elab_Spec::
3966 * Emax::
3967 * Enum_Rep::
3968 * Epsilon::
3969 * Fixed_Value::
3970 * Has_Discriminants::
3971 * Img::
3972 * Integer_Value::
3973 * Large::
3974 * Machine_Size::
3975 * Mantissa::
3976 * Max_Interrupt_Priority::
3977 * Max_Priority::
3978 * Maximum_Alignment::
3979 * Mechanism_Code::
3980 * Null_Parameter::
3981 * Object_Size::
3982 * Passed_By_Reference::
3983 * Range_Length::
3984 * Safe_Emax::
3985 * Safe_Large::
3986 * Small::
3987 * Storage_Unit::
3988 * Target_Name::
3989 * Tick::
3990 * To_Address::
3991 * Type_Class::
3992 * UET_Address::
3993 * Unconstrained_Array::
3994 * Universal_Literal_String::
3995 * Unrestricted_Access::
3996 * VADS_Size::
3997 * Value_Size::
3998 * Wchar_T_Size::
3999 * Word_Size::
4000 @end menu
4001
4002 @node Abort_Signal
4003 @unnumberedsec Abort_Signal
4004 @findex Abort_Signal
4005 @noindent
4006 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4007 prefix) provides the entity for the special exception used to signal
4008 task abort or asynchronous transfer of control.  Normally this attribute
4009 should only be used in the tasking runtime (it is highly peculiar, and
4010 completely outside the normal semantics of Ada, for a user program to
4011 intercept the abort exception).
4012
4013 @node Address_Size
4014 @unnumberedsec Address_Size
4015 @cindex Size of @code{Address}
4016 @findex Address_Size
4017 @noindent
4018 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4019 prefix) is a static constant giving the number of bits in an
4020 @code{Address}. It is the same value as System.Address'Size,
4021 but has the advantage of being static, while a direct
4022 reference to System.Address'Size is non-static because Address
4023 is a private type.
4024
4025 @node Asm_Input
4026 @unnumberedsec Asm_Input
4027 @findex Asm_Input
4028 @noindent
4029 The @code{Asm_Input} attribute denotes a function that takes two
4030 parameters.  The first is a string, the second is an expression of the
4031 type designated by the prefix.  The first (string) argument is required
4032 to be a static expression, and is the constraint for the parameter,
4033 (e.g.@: what kind of register is required).  The second argument is the
4034 value to be used as the input argument.  The possible values for the
4035 constant are the same as those used in the RTL, and are dependent on
4036 the configuration file used to built the GCC back end.
4037 @ref{Machine Code Insertions}
4038
4039 @node Asm_Output
4040 @unnumberedsec Asm_Output
4041 @findex Asm_Output
4042 @noindent
4043 The @code{Asm_Output} attribute denotes a function that takes two
4044 parameters.  The first is a string, the second is the name of a variable
4045 of the type designated by the attribute prefix.  The first (string)
4046 argument is required to be a static expression and designates the
4047 constraint for the parameter (e.g.@: what kind of register is
4048 required).  The second argument is the variable to be updated with the
4049 result.  The possible values for constraint are the same as those used in
4050 the RTL, and are dependent on the configuration file used to build the
4051 GCC back end.  If there are no output operands, then this argument may
4052 either be omitted, or explicitly given as @code{No_Output_Operands}.
4053 @ref{Machine Code Insertions}
4054
4055 @node AST_Entry
4056 @unnumberedsec AST_Entry
4057 @cindex OpenVMS
4058 @findex AST_Entry
4059 @noindent
4060 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4061 the name of an entry, it yields a value of the predefined type AST_Handler
4062 (declared in the predefined package System, as extended by the use of
4063 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4064 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4065 Language Reference Manual}, section 9.12a.
4066
4067 @node Bit
4068 @unnumberedsec Bit
4069 @findex Bit
4070 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4071 offset within the storage unit (byte) that contains the first bit of
4072 storage allocated for the object.  The value of this attribute is of the
4073 type @code{Universal_Integer}, and is always a non-negative number not
4074 exceeding the value of @code{System.Storage_Unit}.
4075
4076 For an object that is a variable or a constant allocated in a register,
4077 the value is zero.  (The use of this attribute does not force the
4078 allocation of a variable to memory).
4079
4080 For an object that is a formal parameter, this attribute applies
4081 to either the matching actual parameter or to a copy of the
4082 matching actual parameter.
4083
4084 For an access object the value is zero.  Note that
4085 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4086 designated object.  Similarly for a record component
4087 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4088 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4089 are subject to index checks.
4090
4091 This attribute is designed to be compatible with the DEC Ada 83 definition
4092 and implementation of the @code{Bit} attribute.
4093
4094 @node Bit_Position
4095 @unnumberedsec Bit_Position
4096 @findex Bit_Position
4097 @noindent
4098 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4099 of the fields of the record type, yields the bit
4100 offset within the record contains the first bit of
4101 storage allocated for the object.  The value of this attribute is of the
4102 type @code{Universal_Integer}.  The value depends only on the field
4103 @var{C} and is independent of the alignment of
4104 the containing record @var{R}.
4105
4106 @node Code_Address
4107 @unnumberedsec Code_Address
4108 @findex Code_Address
4109 @cindex Subprogram address
4110 @cindex Address of subprogram code
4111 @noindent
4112 The @code{'Address}
4113 attribute may be applied to subprograms in Ada 95, but the
4114 intended effect from the Ada 95 reference manual seems to be to provide
4115 an address value which can be used to call the subprogram by means of
4116 an address clause as in the following example:
4117
4118 @smallexample @c ada
4119 procedure K is @dots{}
4120
4121 procedure L;
4122 for L'Address use K'Address;
4123 pragma Import (Ada, L);
4124 @end smallexample
4125
4126 @noindent
4127 A call to @code{L} is then expected to result in a call to @code{K}@.
4128 In Ada 83, where there were no access-to-subprogram values, this was
4129 a common work around for getting the effect of an indirect call.
4130 GNAT implements the above use of @code{Address} and the technique
4131 illustrated by the example code works correctly.
4132
4133 However, for some purposes, it is useful to have the address of the start
4134 of the generated code for the subprogram.  On some architectures, this is
4135 not necessarily the same as the @code{Address} value described above.
4136 For example, the @code{Address} value may reference a subprogram
4137 descriptor rather than the subprogram itself.
4138
4139 The @code{'Code_Address} attribute, which can only be applied to
4140 subprogram entities, always returns the address of the start of the
4141 generated code of the specified subprogram, which may or may not be
4142 the same value as is returned by the corresponding @code{'Address}
4143 attribute.
4144
4145 @node Default_Bit_Order
4146 @unnumberedsec Default_Bit_Order
4147 @cindex Big endian
4148 @cindex Little endian
4149 @findex Default_Bit_Order
4150 @noindent
4151 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4152 permissible prefix), provides the value @code{System.Default_Bit_Order}
4153 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4154 @code{Low_Order_First}).  This is used to construct the definition of
4155 @code{Default_Bit_Order} in package @code{System}.
4156
4157 @node Elaborated
4158 @unnumberedsec Elaborated
4159 @findex Elaborated
4160 @noindent
4161 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4162 value is a Boolean which indicates whether or not the given unit has been
4163 elaborated.  This attribute is primarily intended for internal use by the
4164 generated code for dynamic elaboration checking, but it can also be used
4165 in user programs.  The value will always be True once elaboration of all
4166 units has been completed.  An exception is for units which need no
4167 elaboration, the value is always False for such units.
4168
4169 @node Elab_Body
4170 @unnumberedsec Elab_Body
4171 @findex Elab_Body
4172 @noindent
4173 This attribute can only be applied to a program unit name.  It returns
4174 the entity for the corresponding elaboration procedure for elaborating
4175 the body of the referenced unit.  This is used in the main generated
4176 elaboration procedure by the binder and is not normally used in any
4177 other context.  However, there may be specialized situations in which it
4178 is useful to be able to call this elaboration procedure from Ada code,
4179 e.g.@: if it is necessary to do selective re-elaboration to fix some
4180 error.
4181
4182 @node Elab_Spec
4183 @unnumberedsec Elab_Spec
4184 @findex Elab_Spec
4185 @noindent
4186 This attribute can only be applied to a program unit name.  It returns
4187 the entity for the corresponding elaboration procedure for elaborating
4188 the specification of the referenced unit.  This is used in the main
4189 generated elaboration procedure by the binder and is not normally used
4190 in any other context.  However, there may be specialized situations in
4191 which it is useful to be able to call this elaboration procedure from
4192 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4193 some error.
4194
4195 @node Emax
4196 @unnumberedsec Emax
4197 @cindex Ada 83 attributes
4198 @findex Emax
4199 @noindent
4200 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4201 the Ada 83 reference manual for an exact description of the semantics of
4202 this attribute.
4203
4204 @node Enum_Rep
4205 @unnumberedsec Enum_Rep
4206 @cindex Representation of enums
4207 @findex Enum_Rep
4208 @noindent
4209 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4210 function with the following spec:
4211
4212 @smallexample @c ada
4213 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4214   return @i{Universal_Integer};
4215 @end smallexample
4216
4217 @noindent
4218 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4219 enumeration type or to a non-overloaded enumeration
4220 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4221 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4222 enumeration literal or object.
4223
4224 The function returns the representation value for the given enumeration
4225 value.  This will be equal to value of the @code{Pos} attribute in the
4226 absence of an enumeration representation clause.  This is a static
4227 attribute (i.e.@: the result is static if the argument is static).
4228
4229 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4230 in which case it simply returns the integer value.  The reason for this
4231 is to allow it to be used for @code{(<>)} discrete formal arguments in
4232 a generic unit that can be instantiated with either enumeration types
4233 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4234 type whose upper bound exceeds the upper bound of the largest signed
4235 integer type, and the argument is a variable, so that the universal
4236 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4237 may raise @code{Constraint_Error}.
4238
4239 @node Epsilon
4240 @unnumberedsec Epsilon
4241 @cindex Ada 83 attributes
4242 @findex Epsilon
4243 @noindent
4244 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4245 the Ada 83 reference manual for an exact description of the semantics of
4246 this attribute.
4247
4248 @node Fixed_Value
4249 @unnumberedsec Fixed_Value
4250 @findex Fixed_Value
4251 @noindent
4252 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4253 function with the following specification:
4254
4255 @smallexample @c ada
4256 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4257   return @var{S};
4258 @end smallexample
4259
4260 @noindent
4261 The value returned is the fixed-point value @var{V} such that
4262
4263 @smallexample @c ada
4264 @var{V} = Arg * @var{S}'Small
4265 @end smallexample
4266
4267 @noindent
4268 The effect is thus similar to first converting the argument to the
4269 integer type used to represent @var{S}, and then doing an unchecked
4270 conversion to the fixed-point type.  The difference is
4271 that there are full range checks, to ensure that the result is in range.
4272 This attribute is primarily intended for use in implementation of the
4273 input-output functions for fixed-point values.
4274
4275 @node Has_Discriminants
4276 @unnumberedsec Has_Discriminants
4277 @cindex Discriminants, testing for
4278 @findex Has_Discriminants
4279 @noindent
4280 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4281 is a Boolean value which is True if the type has discriminants, and False
4282 otherwise.  The intended use of this attribute is in conjunction with generic
4283 definitions.  If the attribute is applied to a generic private type, it
4284 indicates whether or not the corresponding actual type has discriminants.
4285
4286 @node Img
4287 @unnumberedsec Img
4288 @findex Img
4289 @noindent
4290 The @code{Img} attribute differs from @code{Image} in that it may be
4291 applied to objects as well as types, in which case it gives the
4292 @code{Image} for the subtype of the object.  This is convenient for
4293 debugging:
4294
4295 @smallexample @c ada
4296 Put_Line ("X = " & X'Img);
4297 @end smallexample
4298
4299 @noindent
4300 has the same meaning as the more verbose:
4301
4302 @smallexample @c ada
4303 Put_Line ("X = " & @var{T}'Image (X));
4304 @end smallexample
4305
4306 @noindent
4307 where @var{T} is the (sub)type of the object @code{X}.
4308
4309 @node Integer_Value
4310 @unnumberedsec Integer_Value
4311 @findex Integer_Value
4312 @noindent
4313 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4314 function with the following spec:
4315
4316 @smallexample @c ada
4317 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4318   return @var{S};
4319 @end smallexample
4320
4321 @noindent
4322 The value returned is the integer value @var{V}, such that
4323
4324 @smallexample @c ada
4325 Arg = @var{V} * @var{T}'Small
4326 @end smallexample
4327
4328 @noindent
4329 where @var{T} is the type of @code{Arg}.
4330 The effect is thus similar to first doing an unchecked conversion from
4331 the fixed-point type to its corresponding implementation type, and then
4332 converting the result to the target integer type.  The difference is
4333 that there are full range checks, to ensure that the result is in range.
4334 This attribute is primarily intended for use in implementation of the
4335 standard input-output functions for fixed-point values.
4336
4337 @node Large
4338 @unnumberedsec Large
4339 @cindex Ada 83 attributes
4340 @findex Large
4341 @noindent
4342 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4343 the Ada 83 reference manual for an exact description of the semantics of
4344 this attribute.
4345
4346 @node Machine_Size
4347 @unnumberedsec Machine_Size
4348 @findex Machine_Size
4349 @noindent
4350 This attribute is identical to the @code{Object_Size} attribute.  It is
4351 provided for compatibility with the DEC Ada 83 attribute of this name.
4352
4353 @node Mantissa
4354 @unnumberedsec Mantissa
4355 @cindex Ada 83 attributes
4356 @findex Mantissa
4357 @noindent
4358 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4359 the Ada 83 reference manual for an exact description of the semantics of
4360 this attribute.
4361
4362 @node Max_Interrupt_Priority
4363 @unnumberedsec Max_Interrupt_Priority
4364 @cindex Interrupt priority, maximum
4365 @findex Max_Interrupt_Priority
4366 @noindent
4367 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4368 permissible prefix), provides the same value as
4369 @code{System.Max_Interrupt_Priority}.
4370
4371 @node Max_Priority
4372 @unnumberedsec Max_Priority
4373 @cindex Priority, maximum
4374 @findex Max_Priority
4375 @noindent
4376 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4377 prefix) provides the same value as @code{System.Max_Priority}.
4378
4379 @node Maximum_Alignment
4380 @unnumberedsec Maximum_Alignment
4381 @cindex Alignment, maximum
4382 @findex Maximum_Alignment
4383 @noindent
4384 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4385 permissible prefix) provides the maximum useful alignment value for the
4386 target.  This is a static value that can be used to specify the alignment
4387 for an object, guaranteeing that it is properly aligned in all
4388 cases.
4389
4390 @node Mechanism_Code
4391 @unnumberedsec Mechanism_Code
4392 @cindex Return values, passing mechanism
4393 @cindex Parameters, passing mechanism
4394 @findex Mechanism_Code
4395 @noindent
4396 @code{@var{function}'Mechanism_Code} yields an integer code for the
4397 mechanism used for the result of function, and
4398 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4399 used for formal parameter number @var{n} (a static integer value with 1
4400 meaning the first parameter) of @var{subprogram}.  The code returned is:
4401
4402 @table @asis
4403 @item 1
4404 by copy (value)
4405 @item 2
4406 by reference
4407 @item 3
4408 by descriptor (default descriptor class)
4409 @item 4
4410 by descriptor (UBS: unaligned bit string)
4411 @item 5
4412 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4413 @item 6
4414 by descriptor (UBA: unaligned bit array)
4415 @item 7
4416 by descriptor (S: string, also scalar access type parameter)
4417 @item 8
4418 by descriptor (SB: string with arbitrary bounds)
4419 @item 9
4420 by descriptor (A: contiguous array)
4421 @item 10
4422 by descriptor (NCA: non-contiguous array)
4423 @end table
4424
4425 @noindent
4426 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4427 @cindex OpenVMS
4428
4429 @node Null_Parameter
4430 @unnumberedsec Null_Parameter
4431 @cindex Zero address, passing
4432 @findex Null_Parameter
4433 @noindent
4434 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4435 type or subtype @var{T} allocated at machine address zero.  The attribute
4436 is allowed only as the default expression of a formal parameter, or as
4437 an actual expression of a subprogram call.  In either case, the
4438 subprogram must be imported.
4439
4440 The identity of the object is represented by the address zero in the
4441 argument list, independent of the passing mechanism (explicit or
4442 default).
4443
4444 This capability is needed to specify that a zero address should be
4445 passed for a record or other composite object passed by reference.
4446 There is no way of indicating this without the @code{Null_Parameter}
4447 attribute.
4448
4449 @node Object_Size
4450 @unnumberedsec Object_Size
4451 @cindex Size, used for objects
4452 @findex Object_Size
4453 @noindent
4454 The size of an object is not necessarily the same as the size of the type
4455 of an object.  This is because by default object sizes are increased to be
4456 a multiple of the alignment of the object.  For example,
4457 @code{Natural'Size} is
4458 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4459 Similarly, a record containing an integer and a character:
4460
4461 @smallexample @c ada
4462 type Rec is record
4463    I : Integer;
4464    C : Character;
4465 end record;
4466 @end smallexample
4467
4468 @noindent
4469 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4470 alignment will be 4, because of the
4471 integer field, and so the default size of record objects for this type
4472 will be 64 (8 bytes).
4473
4474 The @code{@var{type}'Object_Size} attribute
4475 has been added to GNAT to allow the
4476 default object size of a type to be easily determined.  For example,
4477 @code{Natural'Object_Size} is 32, and
4478 @code{Rec'Object_Size} (for the record type in the above example) will be
4479 64.  Note also that, unlike the situation with the
4480 @code{Size} attribute as defined in the Ada RM, the
4481 @code{Object_Size} attribute can be specified individually
4482 for different subtypes.  For example:
4483
4484 @smallexample @c ada
4485 type R is new Integer;
4486 subtype R1 is R range 1 .. 10;
4487 subtype R2 is R range 1 .. 10;
4488 for R2'Object_Size use 8;
4489 @end smallexample
4490
4491 @noindent
4492 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4493 32 since the default object size for a subtype is the same as the object size
4494 for the parent subtype.  This means that objects of type @code{R}
4495 or @code{R1} will
4496 by default be 32 bits (four bytes).  But objects of type
4497 @code{R2} will be only
4498 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4499
4500 @node Passed_By_Reference
4501 @unnumberedsec Passed_By_Reference
4502 @cindex Parameters, when passed by reference
4503 @findex Passed_By_Reference
4504 @noindent
4505 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4506 a value of type @code{Boolean} value that is @code{True} if the type is
4507 normally passed by reference and @code{False} if the type is normally
4508 passed by copy in calls.  For scalar types, the result is always @code{False}
4509 and is static.  For non-scalar types, the result is non-static.
4510
4511 @node Range_Length
4512 @unnumberedsec Range_Length
4513 @findex Range_Length
4514 @noindent
4515 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4516 the number of values represented by the subtype (zero for a null
4517 range).  The result is static for static subtypes.  @code{Range_Length}
4518 applied to the index subtype of a one dimensional array always gives the
4519 same result as @code{Range} applied to the array itself.
4520
4521 @node Safe_Emax
4522 @unnumberedsec Safe_Emax
4523 @cindex Ada 83 attributes
4524 @findex Safe_Emax
4525 @noindent
4526 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4527 the Ada 83 reference manual for an exact description of the semantics of
4528 this attribute.
4529
4530 @node Safe_Large
4531 @unnumberedsec Safe_Large
4532 @cindex Ada 83 attributes
4533 @findex Safe_Large
4534 @noindent
4535 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4536 the Ada 83 reference manual for an exact description of the semantics of
4537 this attribute.
4538
4539 @node Small
4540 @unnumberedsec Small
4541 @cindex Ada 83 attributes
4542 @findex Small
4543 @noindent
4544 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4545 GNAT also allows this attribute to be applied to floating-point types
4546 for compatibility with Ada 83.  See
4547 the Ada 83 reference manual for an exact description of the semantics of
4548 this attribute when applied to floating-point types.
4549
4550 @node Storage_Unit
4551 @unnumberedsec Storage_Unit
4552 @findex Storage_Unit
4553 @noindent
4554 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4555 prefix) provides the same value as @code{System.Storage_Unit}.
4556
4557 @node Target_Name
4558 @unnumberedsec Target_Name
4559 @findex Target_Name
4560 @noindent
4561 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4562 prefix) provides a static string value that identifies the target
4563 for the current compilation. For GCC implementations, this is the
4564 standard gcc target name without the terminating slash (for
4565 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4566
4567 @node Tick
4568 @unnumberedsec Tick
4569 @findex Tick
4570 @noindent
4571 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4572 provides the same value as @code{System.Tick},
4573
4574 @node To_Address
4575 @unnumberedsec To_Address
4576 @findex To_Address
4577 @noindent
4578 The @code{System'To_Address}
4579 (@code{System} is the only permissible prefix)
4580 denotes a function identical to
4581 @code{System.Storage_Elements.To_Address} except that
4582 it is a static attribute.  This means that if its argument is
4583 a static expression, then the result of the attribute is a
4584 static expression.  The result is that such an expression can be
4585 used in contexts (e.g.@: preelaborable packages) which require a
4586 static expression and where the function call could not be used
4587 (since the function call is always non-static, even if its
4588 argument is static).
4589
4590 @node Type_Class
4591 @unnumberedsec Type_Class
4592 @findex Type_Class
4593 @noindent
4594 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4595 the value of the type class for the full type of @var{type}.  If
4596 @var{type} is a generic formal type, the value is the value for the
4597 corresponding actual subtype.  The value of this attribute is of type
4598 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4599
4600 @smallexample @c ada
4601   type Type_Class is
4602     (Type_Class_Enumeration,
4603      Type_Class_Integer,
4604      Type_Class_Fixed_Point,
4605      Type_Class_Floating_Point,
4606      Type_Class_Array,
4607      Type_Class_Record,
4608      Type_Class_Access,
4609      Type_Class_Task,
4610      Type_Class_Address);
4611 @end smallexample
4612
4613 @noindent
4614 Protected types yield the value @code{Type_Class_Task}, which thus
4615 applies to all concurrent types.  This attribute is designed to
4616 be compatible with the DEC Ada 83 attribute of the same name.
4617
4618 @node UET_Address
4619 @unnumberedsec UET_Address
4620 @findex UET_Address
4621 @noindent
4622 The @code{UET_Address} attribute can only be used for a prefix which
4623 denotes a library package.  It yields the address of the unit exception
4624 table when zero cost exception handling is used.  This attribute is
4625 intended only for use within the GNAT implementation.  See the unit
4626 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4627 for details on how this attribute is used in the implementation.
4628
4629 @node Unconstrained_Array
4630 @unnumberedsec Unconstrained_Array
4631 @findex Unconstrained_Array
4632 @noindent
4633 The @code{Unconstrained_Array} attribute can be used with a prefix that
4634 denotes any type or subtype. It is a static attribute that yields
4635 @code{True} if the prefix designates an unconstrained array,
4636 and @code{False} otherwise. In a generic instance, the result is
4637 still static, and yields the result of applying this test to the
4638 generic actual.
4639
4640 @node Universal_Literal_String
4641 @unnumberedsec Universal_Literal_String
4642 @cindex Named numbers, representation of
4643 @findex Universal_Literal_String
4644 @noindent
4645 The prefix of @code{Universal_Literal_String} must be a named
4646 number.  The static result is the string consisting of the characters of
4647 the number as defined in the original source.  This allows the user
4648 program to access the actual text of named numbers without intermediate
4649 conversions and without the need to enclose the strings in quotes (which
4650 would preclude their use as numbers).  This is used internally for the
4651 construction of values of the floating-point attributes from the file
4652 @file{ttypef.ads}, but may also be used by user programs.
4653
4654 @node Unrestricted_Access
4655 @unnumberedsec Unrestricted_Access
4656 @cindex @code{Access}, unrestricted
4657 @findex Unrestricted_Access
4658 @noindent
4659 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4660 except that all accessibility and aliased view checks are omitted.  This
4661 is a user-beware attribute.  It is similar to
4662 @code{Address}, for which it is a desirable replacement where the value
4663 desired is an access type.  In other words, its effect is identical to
4664 first applying the @code{Address} attribute and then doing an unchecked
4665 conversion to a desired access type.  In GNAT, but not necessarily in
4666 other implementations, the use of static chains for inner level
4667 subprograms means that @code{Unrestricted_Access} applied to a
4668 subprogram yields a value that can be called as long as the subprogram
4669 is in scope (normal Ada 95 accessibility rules restrict this usage).
4670
4671 It is possible to use @code{Unrestricted_Access} for any type, but care
4672 must be excercised if it is used to create pointers to unconstrained
4673 objects. In this case, the resulting pointer has the same scope as the
4674 context of the attribute, and may not be returned to some enclosing
4675 scope. For instance, a function cannot use @code{Unrestricted_Access}
4676 to create a unconstrained pointer and then return that value to the
4677 caller.
4678
4679 @node VADS_Size
4680 @unnumberedsec VADS_Size
4681 @cindex @code{Size}, VADS compatibility
4682 @findex VADS_Size
4683 @noindent
4684 The @code{'VADS_Size} attribute is intended to make it easier to port
4685 legacy code which relies on the semantics of @code{'Size} as implemented
4686 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4687 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4688 to a predefined or other primitive type with no Size clause yields the
4689 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4690 typical machines).  In addition @code{'VADS_Size} applied to an object
4691 gives the result that would be obtained by applying the attribute to
4692 the corresponding type.
4693
4694 @node Value_Size
4695 @unnumberedsec Value_Size
4696 @cindex @code{Size}, setting for not-first subtype
4697 @findex Value_Size
4698 @code{@var{type}'Value_Size} is the number of bits required to represent
4699 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4700 but, unlike @code{Size}, may be set for non-first subtypes.
4701
4702 @node Wchar_T_Size
4703 @unnumberedsec Wchar_T_Size
4704 @findex Wchar_T_Size
4705 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4706 prefix) provides the size in bits of the C @code{wchar_t} type
4707 primarily for constructing the definition of this type in
4708 package @code{Interfaces.C}.
4709
4710 @node Word_Size
4711 @unnumberedsec Word_Size
4712 @findex Word_Size
4713 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4714 prefix) provides the value @code{System.Word_Size}.
4715
4716 @c ------------------------
4717 @node Implementation Advice
4718 @chapter Implementation Advice
4719 @noindent
4720 The main text of the Ada 95 Reference Manual describes the required
4721 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4722 these requirements.
4723
4724 In addition, there are sections throughout the Ada 95
4725 reference manual headed
4726 by the phrase ``implementation advice''.  These sections are not normative,
4727 i.e.@: they do not specify requirements that all compilers must
4728 follow.  Rather they provide advice on generally desirable behavior.  You
4729 may wonder why they are not requirements.  The most typical answer is
4730 that they describe behavior that seems generally desirable, but cannot
4731 be provided on all systems, or which may be undesirable on some systems.
4732
4733 As far as practical, GNAT follows the implementation advice sections in
4734 the Ada 95 Reference Manual.  This chapter contains a table giving the
4735 reference manual section number, paragraph number and several keywords
4736 for each advice.  Each entry consists of the text of the advice followed
4737 by the GNAT interpretation of this advice.  Most often, this simply says
4738 ``followed'', which means that GNAT follows the advice.  However, in a
4739 number of cases, GNAT deliberately deviates from this advice, in which
4740 case the text describes what GNAT does and why.
4741
4742 @cindex Error detection
4743 @unnumberedsec 1.1.3(20): Error Detection
4744 @sp 1
4745 @cartouche
4746 If an implementation detects the use of an unsupported Specialized Needs
4747 Annex feature at run time, it should raise @code{Program_Error} if
4748 feasible.
4749 @end cartouche
4750 Not relevant.  All specialized needs annex features are either supported,
4751 or diagnosed at compile time.
4752
4753 @cindex Child Units
4754 @unnumberedsec 1.1.3(31): Child Units
4755 @sp 1
4756 @cartouche
4757 If an implementation wishes to provide implementation-defined
4758 extensions to the functionality of a language-defined library unit, it
4759 should normally do so by adding children to the library unit.
4760 @end cartouche
4761 Followed.
4762
4763 @cindex Bounded errors
4764 @unnumberedsec 1.1.5(12): Bounded Errors
4765 @sp 1
4766 @cartouche
4767 If an implementation detects a bounded error or erroneous
4768 execution, it should raise @code{Program_Error}.
4769 @end cartouche
4770 Followed in all cases in which the implementation detects a bounded
4771 error or erroneous execution.  Not all such situations are detected at
4772 runtime.
4773
4774 @cindex Pragmas
4775 @unnumberedsec 2.8(16): Pragmas
4776 @sp 1
4777 @cartouche
4778 Normally, implementation-defined pragmas should have no semantic effect
4779 for error-free programs; that is, if the implementation-defined pragmas
4780 are removed from a working program, the program should still be legal,
4781 and should still have the same semantics.
4782 @end cartouche
4783 The following implementation defined pragmas are exceptions to this
4784 rule:
4785
4786 @table @code
4787 @item Abort_Defer
4788 Affects semantics
4789 @item Ada_83
4790 Affects legality
4791 @item Assert
4792 Affects semantics
4793 @item CPP_Class
4794 Affects semantics
4795 @item CPP_Constructor
4796 Affects semantics
4797 @item CPP_Virtual
4798 Affects semantics
4799 @item CPP_Vtable
4800 Affects semantics
4801 @item Debug
4802 Affects semantics
4803 @item Interface_Name
4804 Affects semantics
4805 @item Machine_Attribute
4806 Affects semantics
4807 @item Unimplemented_Unit
4808 Affects legality
4809 @item Unchecked_Union
4810 Affects semantics
4811 @end table
4812
4813 @noindent
4814 In each of the above cases, it is essential to the purpose of the pragma
4815 that this advice not be followed.  For details see the separate section
4816 on implementation defined pragmas.
4817
4818 @unnumberedsec 2.8(17-19): Pragmas
4819 @sp 1
4820 @cartouche
4821 Normally, an implementation should not define pragmas that can
4822 make an illegal program legal, except as follows:
4823 @end cartouche
4824 @sp 1
4825 @cartouche
4826 A pragma used to complete a declaration, such as a pragma @code{Import};
4827 @end cartouche
4828 @sp 1
4829 @cartouche
4830 A pragma used to configure the environment by adding, removing, or
4831 replacing @code{library_items}.
4832 @end cartouche
4833 See response to paragraph 16 of this same section.
4834
4835 @cindex Character Sets
4836 @cindex Alternative Character Sets
4837 @unnumberedsec 3.5.2(5): Alternative Character Sets
4838 @sp 1
4839 @cartouche
4840 If an implementation supports a mode with alternative interpretations
4841 for @code{Character} and @code{Wide_Character}, the set of graphic
4842 characters of @code{Character} should nevertheless remain a proper
4843 subset of the set of graphic characters of @code{Wide_Character}.  Any
4844 character set ``localizations'' should be reflected in the results of
4845 the subprograms defined in the language-defined package
4846 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4847 an alternative interpretation of @code{Character}, the implementation should
4848 also support a corresponding change in what is a legal
4849 @code{identifier_letter}.
4850 @end cartouche
4851 Not all wide character modes follow this advice, in particular the JIS
4852 and IEC modes reflect standard usage in Japan, and in these encoding,
4853 the upper half of the Latin-1 set is not part of the wide-character
4854 subset, since the most significant bit is used for wide character
4855 encoding.  However, this only applies to the external forms.  Internally
4856 there is no such restriction.
4857
4858 @cindex Integer types
4859 @unnumberedsec 3.5.4(28): Integer Types
4860
4861 @sp 1
4862 @cartouche
4863 An implementation should support @code{Long_Integer} in addition to
4864 @code{Integer} if the target machine supports 32-bit (or longer)
4865 arithmetic.  No other named integer subtypes are recommended for package
4866 @code{Standard}.  Instead, appropriate named integer subtypes should be
4867 provided in the library package @code{Interfaces} (see B.2).
4868 @end cartouche
4869 @code{Long_Integer} is supported.  Other standard integer types are supported
4870 so this advice is not fully followed.  These types
4871 are supported for convenient interface to C, and so that all hardware
4872 types of the machine are easily available.
4873 @unnumberedsec 3.5.4(29): Integer Types
4874
4875 @sp 1
4876 @cartouche
4877 An implementation for a two's complement machine should support
4878 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4879 implementation should support a non-binary modules up to @code{Integer'Last}.
4880 @end cartouche
4881 Followed.
4882
4883 @cindex Enumeration values
4884 @unnumberedsec 3.5.5(8): Enumeration Values
4885 @sp 1
4886 @cartouche
4887 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4888 subtype, if the value of the operand does not correspond to the internal
4889 code for any enumeration literal of its type (perhaps due to an
4890 un-initialized variable), then the implementation should raise
4891 @code{Program_Error}.  This is particularly important for enumeration
4892 types with noncontiguous internal codes specified by an
4893 enumeration_representation_clause.
4894 @end cartouche
4895 Followed.
4896
4897 @cindex Float types
4898 @unnumberedsec 3.5.7(17): Float Types
4899 @sp 1
4900 @cartouche
4901 An implementation should support @code{Long_Float} in addition to
4902 @code{Float} if the target machine supports 11 or more digits of
4903 precision.  No other named floating point subtypes are recommended for
4904 package @code{Standard}.  Instead, appropriate named floating point subtypes
4905 should be provided in the library package @code{Interfaces} (see B.2).
4906 @end cartouche
4907 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4908 former provides improved compatibility with other implementations
4909 supporting this type.  The latter corresponds to the highest precision
4910 floating-point type supported by the hardware.  On most machines, this
4911 will be the same as @code{Long_Float}, but on some machines, it will
4912 correspond to the IEEE extended form.  The notable case is all ia32
4913 (x86) implementations, where @code{Long_Long_Float} corresponds to
4914 the 80-bit extended precision format supported in hardware on this
4915 processor.  Note that the 128-bit format on SPARC is not supported,
4916 since this is a software rather than a hardware format.
4917
4918 @cindex Multidimensional arrays
4919 @cindex Arrays, multidimensional
4920 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4921 @sp 1
4922 @cartouche
4923 An implementation should normally represent multidimensional arrays in
4924 row-major order, consistent with the notation used for multidimensional
4925 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
4926 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4927 column-major order should be used instead (see B.5, ``Interfacing with
4928 Fortran'').
4929 @end cartouche
4930 Followed.
4931
4932 @findex Duration'Small
4933 @unnumberedsec 9.6(30-31): Duration'Small
4934 @sp 1
4935 @cartouche
4936 Whenever possible in an implementation, the value of @code{Duration'Small}
4937 should be no greater than 100 microseconds.
4938 @end cartouche
4939 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
4940
4941 @sp 1
4942 @cartouche
4943 The time base for @code{delay_relative_statements} should be monotonic;
4944 it need not be the same time base as used for @code{Calendar.Clock}.
4945 @end cartouche
4946 Followed.
4947
4948 @unnumberedsec 10.2.1(12): Consistent Representation
4949 @sp 1
4950 @cartouche
4951 In an implementation, a type declared in a pre-elaborated package should
4952 have the same representation in every elaboration of a given version of
4953 the package, whether the elaborations occur in distinct executions of
4954 the same program, or in executions of distinct programs or partitions
4955 that include the given version.
4956 @end cartouche
4957 Followed, except in the case of tagged types.  Tagged types involve
4958 implicit pointers to a local copy of a dispatch table, and these pointers
4959 have representations which thus depend on a particular elaboration of the
4960 package.  It is not easy to see how it would be possible to follow this
4961 advice without severely impacting efficiency of execution.
4962
4963 @cindex Exception information
4964 @unnumberedsec 11.4.1(19): Exception Information
4965 @sp 1
4966 @cartouche
4967 @code{Exception_Message} by default and @code{Exception_Information}
4968 should produce information useful for
4969 debugging.  @code{Exception_Message} should be short, about one
4970 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
4971 should not include the
4972 @code{Exception_Name}.  @code{Exception_Information} should include both
4973 the @code{Exception_Name} and the @code{Exception_Message}.
4974 @end cartouche
4975 Followed.  For each exception that doesn't have a specified
4976 @code{Exception_Message}, the compiler generates one containing the location
4977 of the raise statement.  This location has the form ``file:line'', where
4978 file is the short file name (without path information) and line is the line
4979 number in the file.  Note that in the case of the Zero Cost Exception
4980 mechanism, these messages become redundant with the Exception_Information that
4981 contains a full backtrace of the calling sequence, so they are disabled.
4982 To disable explicitly the generation of the source location message, use the
4983 Pragma @code{Discard_Names}.
4984
4985 @cindex Suppression of checks
4986 @cindex Checks, suppression of
4987 @unnumberedsec 11.5(28): Suppression of Checks
4988 @sp 1
4989 @cartouche
4990 The implementation should minimize the code executed for checks that
4991 have been suppressed.
4992 @end cartouche
4993 Followed.
4994
4995 @cindex Representation clauses
4996 @unnumberedsec 13.1 (21-24): Representation Clauses
4997 @sp 1
4998 @cartouche
4999 The recommended level of support for all representation items is
5000 qualified as follows:
5001 @end cartouche
5002 @sp 1
5003 @cartouche
5004 An implementation need not support representation items containing
5005 non-static expressions, except that an implementation should support a
5006 representation item for a given entity if each non-static expression in
5007 the representation item is a name that statically denotes a constant
5008 declared before the entity.
5009 @end cartouche
5010 Followed.  GNAT does not support non-static expressions in representation
5011 clauses unless they are constants declared before the entity.  For
5012 example:
5013
5014 @smallexample @c ada
5015 X : Some_Type;
5016 for X'Address use To_address (16#2000#);
5017 @end smallexample
5018
5019 @noindent
5020 will be rejected, since the To_Address expression is non-static.  Instead
5021 write:
5022
5023 @smallexample @c ada
5024 X_Address : constant Address : = To_Address (16#2000#);
5025 X         : Some_Type;
5026 for X'Address use X_Address;
5027 @end smallexample
5028
5029 @sp 1
5030 @cartouche
5031 An implementation need not support a specification for the @code{Size}
5032 for a given composite subtype, nor the size or storage place for an
5033 object (including a component) of a given composite subtype, unless the
5034 constraints on the subtype and its composite subcomponents (if any) are
5035 all static constraints.
5036 @end cartouche
5037 Followed.  Size Clauses are not permitted on non-static components, as
5038 described above.
5039
5040 @sp 1
5041 @cartouche
5042 An aliased component, or a component whose type is by-reference, should
5043 always be allocated at an addressable location.
5044 @end cartouche
5045 Followed.
5046
5047 @cindex Packed types
5048 @unnumberedsec 13.2(6-8): Packed Types
5049 @sp 1
5050 @cartouche
5051 If a type is packed, then the implementation should try to minimize
5052 storage allocated to objects of the type, possibly at the expense of
5053 speed of accessing components, subject to reasonable complexity in
5054 addressing calculations.
5055 @end cartouche
5056 @sp 1
5057 @cartouche
5058 The recommended level of support pragma @code{Pack} is:
5059
5060 For a packed record type, the components should be packed as tightly as
5061 possible subject to the Sizes of the component subtypes, and subject to
5062 any @code{record_representation_clause} that applies to the type; the
5063 implementation may, but need not, reorder components or cross aligned
5064 word boundaries to improve the packing.  A component whose @code{Size} is
5065 greater than the word size may be allocated an integral number of words.
5066 @end cartouche
5067 Followed.  Tight packing of arrays is supported for all component sizes
5068 up to 64-bits. If the array component size is 1 (that is to say, if
5069 the component is a boolean type or an enumeration type with two values)
5070 then values of the type are implicitly initialized to zero. This
5071 happens both for objects of the packed type, and for objects that have a
5072 subcomponent of the packed type.
5073
5074 @sp 1
5075 @cartouche
5076 An implementation should support Address clauses for imported
5077 subprograms.
5078 @end cartouche
5079 Followed.
5080 @cindex @code{Address} clauses
5081 @unnumberedsec 13.3(14-19): Address Clauses
5082
5083 @sp 1
5084 @cartouche
5085 For an array @var{X}, @code{@var{X}'Address} should point at the first
5086 component of the array, and not at the array bounds.
5087 @end cartouche
5088 Followed.
5089
5090 @sp 1
5091 @cartouche
5092 The recommended level of support for the @code{Address} attribute is:
5093
5094 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5095 object that is aliased or of a by-reference type, or is an entity whose
5096 @code{Address} has been specified.
5097 @end cartouche
5098 Followed.  A valid address will be produced even if none of those
5099 conditions have been met.  If necessary, the object is forced into
5100 memory to ensure the address is valid.
5101
5102 @sp 1
5103 @cartouche
5104 An implementation should support @code{Address} clauses for imported
5105 subprograms.
5106 @end cartouche
5107 Followed.
5108
5109 @sp 1
5110 @cartouche
5111 Objects (including subcomponents) that are aliased or of a by-reference
5112 type should be allocated on storage element boundaries.
5113 @end cartouche
5114 Followed.
5115
5116 @sp 1
5117 @cartouche
5118 If the @code{Address} of an object is specified, or it is imported or exported,
5119 then the implementation should not perform optimizations based on
5120 assumptions of no aliases.
5121 @end cartouche
5122 Followed.
5123
5124 @cindex @code{Alignment} clauses
5125 @unnumberedsec 13.3(29-35): Alignment Clauses
5126 @sp 1
5127 @cartouche
5128 The recommended level of support for the @code{Alignment} attribute for
5129 subtypes is:
5130
5131 An implementation should support specified Alignments that are factors
5132 and multiples of the number of storage elements per word, subject to the
5133 following:
5134 @end cartouche
5135 Followed.
5136
5137 @sp 1
5138 @cartouche
5139 An implementation need not support specified @code{Alignment}s for
5140 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5141 loaded and stored by available machine instructions.
5142 @end cartouche
5143 Followed.
5144
5145 @sp 1
5146 @cartouche
5147 An implementation need not support specified @code{Alignment}s that are
5148 greater than the maximum @code{Alignment} the implementation ever returns by
5149 default.
5150 @end cartouche
5151 Followed.
5152
5153 @sp 1
5154 @cartouche
5155 The recommended level of support for the @code{Alignment} attribute for
5156 objects is:
5157
5158 Same as above, for subtypes, but in addition:
5159 @end cartouche
5160 Followed.
5161
5162 @sp 1
5163 @cartouche
5164 For stand-alone library-level objects of statically constrained
5165 subtypes, the implementation should support all @code{Alignment}s
5166 supported by the target linker.  For example, page alignment is likely to
5167 be supported for such objects, but not for subtypes.
5168 @end cartouche
5169 Followed.
5170
5171 @cindex @code{Size} clauses
5172 @unnumberedsec 13.3(42-43): Size Clauses
5173 @sp 1
5174 @cartouche
5175 The recommended level of support for the @code{Size} attribute of
5176 objects is:
5177
5178 A @code{Size} clause should be supported for an object if the specified
5179 @code{Size} is at least as large as its subtype's @code{Size}, and
5180 corresponds to a size in storage elements that is a multiple of the
5181 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5182 @end cartouche
5183 Followed.
5184
5185 @unnumberedsec 13.3(50-56): Size Clauses
5186 @sp 1
5187 @cartouche
5188 If the @code{Size} of a subtype is specified, and allows for efficient
5189 independent addressability (see 9.10) on the target architecture, then
5190 the @code{Size} of the following objects of the subtype should equal the
5191 @code{Size} of the subtype:
5192
5193 Aliased objects (including components).
5194 @end cartouche
5195 Followed.
5196
5197 @sp 1
5198 @cartouche
5199 @code{Size} clause on a composite subtype should not affect the
5200 internal layout of components.
5201 @end cartouche
5202 Followed.
5203
5204 @sp 1
5205 @cartouche
5206 The recommended level of support for the @code{Size} attribute of subtypes is:
5207 @end cartouche
5208 @sp 1
5209 @cartouche
5210 The @code{Size} (if not specified) of a static discrete or fixed point
5211 subtype should be the number of bits needed to represent each value
5212 belonging to the subtype using an unbiased representation, leaving space
5213 for a sign bit only if the subtype contains negative values.  If such a
5214 subtype is a first subtype, then an implementation should support a
5215 specified @code{Size} for it that reflects this representation.
5216 @end cartouche
5217 Followed.
5218
5219 @sp 1
5220 @cartouche
5221 For a subtype implemented with levels of indirection, the @code{Size}
5222 should include the size of the pointers, but not the size of what they
5223 point at.
5224 @end cartouche
5225 Followed.
5226
5227 @cindex @code{Component_Size} clauses
5228 @unnumberedsec 13.3(71-73): Component Size Clauses
5229 @sp 1
5230 @cartouche
5231 The recommended level of support for the @code{Component_Size}
5232 attribute is:
5233 @end cartouche
5234 @sp 1
5235 @cartouche
5236 An implementation need not support specified @code{Component_Sizes} that are
5237 less than the @code{Size} of the component subtype.
5238 @end cartouche
5239 Followed.
5240
5241 @sp 1
5242 @cartouche
5243 An implementation should support specified @code{Component_Size}s that
5244 are factors and multiples of the word size.  For such
5245 @code{Component_Size}s, the array should contain no gaps between
5246 components.  For other @code{Component_Size}s (if supported), the array
5247 should contain no gaps between components when packing is also
5248 specified; the implementation should forbid this combination in cases
5249 where it cannot support a no-gaps representation.
5250 @end cartouche
5251 Followed.
5252
5253 @cindex Enumeration representation clauses
5254 @cindex Representation clauses, enumeration
5255 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5256 @sp 1
5257 @cartouche
5258 The recommended level of support for enumeration representation clauses
5259 is:
5260
5261 An implementation need not support enumeration representation clauses
5262 for boolean types, but should at minimum support the internal codes in
5263 the range @code{System.Min_Int.System.Max_Int}.
5264 @end cartouche
5265 Followed.
5266
5267 @cindex Record representation clauses
5268 @cindex Representation clauses, records
5269 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5270 @sp 1
5271 @cartouche
5272 The recommended level of support for
5273 @*@code{record_representation_clauses} is:
5274
5275 An implementation should support storage places that can be extracted
5276 with a load, mask, shift sequence of machine code, and set with a load,
5277 shift, mask, store sequence, given the available machine instructions
5278 and run-time model.
5279 @end cartouche
5280 Followed.
5281
5282 @sp 1
5283 @cartouche
5284 A storage place should be supported if its size is equal to the
5285 @code{Size} of the component subtype, and it starts and ends on a
5286 boundary that obeys the @code{Alignment} of the component subtype.
5287 @end cartouche
5288 Followed.
5289
5290 @sp 1
5291 @cartouche
5292 If the default bit ordering applies to the declaration of a given type,
5293 then for a component whose subtype's @code{Size} is less than the word
5294 size, any storage place that does not cross an aligned word boundary
5295 should be supported.
5296 @end cartouche
5297 Followed.
5298
5299 @sp 1
5300 @cartouche
5301 An implementation may reserve a storage place for the tag field of a
5302 tagged type, and disallow other components from overlapping that place.
5303 @end cartouche
5304 Followed.  The storage place for the tag field is the beginning of the tagged
5305 record, and its size is Address'Size.  GNAT will reject an explicit component
5306 clause for the tag field.
5307
5308 @sp 1
5309 @cartouche
5310 An implementation need not support a @code{component_clause} for a
5311 component of an extension part if the storage place is not after the
5312 storage places of all components of the parent type, whether or not
5313 those storage places had been specified.
5314 @end cartouche
5315 Followed.  The above advice on record representation clauses is followed,
5316 and all mentioned features are implemented.
5317
5318 @cindex Storage place attributes
5319 @unnumberedsec 13.5.2(5): Storage Place Attributes
5320 @sp 1
5321 @cartouche
5322 If a component is represented using some form of pointer (such as an
5323 offset) to the actual data of the component, and this data is contiguous
5324 with the rest of the object, then the storage place attributes should
5325 reflect the place of the actual data, not the pointer.  If a component is
5326 allocated discontinuously from the rest of the object, then a warning
5327 should be generated upon reference to one of its storage place
5328 attributes.
5329 @end cartouche
5330 Followed.  There are no such components in GNAT@.
5331
5332 @cindex Bit ordering
5333 @unnumberedsec 13.5.3(7-8): Bit Ordering
5334 @sp 1
5335 @cartouche
5336 The recommended level of support for the non-default bit ordering is:
5337 @end cartouche
5338 @sp 1
5339 @cartouche
5340 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5341 should support the non-default bit ordering in addition to the default
5342 bit ordering.
5343 @end cartouche
5344 Followed.  Word size does not equal storage size in this implementation.
5345 Thus non-default bit ordering is not supported.
5346
5347 @cindex @code{Address}, as private type
5348 @unnumberedsec 13.7(37): Address as Private
5349 @sp 1
5350 @cartouche
5351 @code{Address} should be of a private type.
5352 @end cartouche
5353 Followed.
5354
5355 @cindex Operations, on @code{Address}
5356 @cindex @code{Address}, operations of
5357 @unnumberedsec 13.7.1(16): Address Operations
5358 @sp 1
5359 @cartouche
5360 Operations in @code{System} and its children should reflect the target
5361 environment semantics as closely as is reasonable.  For example, on most
5362 machines, it makes sense for address arithmetic to ``wrap around''.
5363 Operations that do not make sense should raise @code{Program_Error}.
5364 @end cartouche
5365 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5366 operation raises @code{Program_Error}, since all operations make sense.
5367
5368 @cindex Unchecked conversion
5369 @unnumberedsec 13.9(14-17): Unchecked Conversion
5370 @sp 1
5371 @cartouche
5372 The @code{Size} of an array object should not include its bounds; hence,
5373 the bounds should not be part of the converted data.
5374 @end cartouche
5375 Followed.
5376
5377 @sp 1
5378 @cartouche
5379 The implementation should not generate unnecessary run-time checks to
5380 ensure that the representation of @var{S} is a representation of the
5381 target type.  It should take advantage of the permission to return by
5382 reference when possible.  Restrictions on unchecked conversions should be
5383 avoided unless required by the target environment.
5384 @end cartouche
5385 Followed.  There are no restrictions on unchecked conversion.  A warning is
5386 generated if the source and target types do not have the same size since
5387 the semantics in this case may be target dependent.
5388
5389 @sp 1
5390 @cartouche
5391 The recommended level of support for unchecked conversions is:
5392 @end cartouche
5393 @sp 1
5394 @cartouche
5395 Unchecked conversions should be supported and should be reversible in
5396 the cases where this clause defines the result.  To enable meaningful use
5397 of unchecked conversion, a contiguous representation should be used for
5398 elementary subtypes, for statically constrained array subtypes whose
5399 component subtype is one of the subtypes described in this paragraph,
5400 and for record subtypes without discriminants whose component subtypes
5401 are described in this paragraph.
5402 @end cartouche
5403 Followed.
5404
5405 @cindex Heap usage, implicit
5406 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5407 @sp 1
5408 @cartouche
5409 An implementation should document any cases in which it dynamically
5410 allocates heap storage for a purpose other than the evaluation of an
5411 allocator.
5412 @end cartouche
5413 Followed, the only other points at which heap storage is dynamically
5414 allocated are as follows:
5415
5416 @itemize @bullet
5417 @item
5418 At initial elaboration time, to allocate dynamically sized global
5419 objects.
5420
5421 @item
5422 To allocate space for a task when a task is created.
5423
5424 @item
5425 To extend the secondary stack dynamically when needed.  The secondary
5426 stack is used for returning variable length results.
5427 @end itemize
5428
5429 @sp 1
5430 @cartouche
5431 A default (implementation-provided) storage pool for an
5432 access-to-constant type should not have overhead to support deallocation of
5433 individual objects.
5434 @end cartouche
5435 Followed.
5436
5437 @sp 1
5438 @cartouche
5439 A storage pool for an anonymous access type should be created at the
5440 point of an allocator for the type, and be reclaimed when the designated
5441 object becomes inaccessible.
5442 @end cartouche
5443 Followed.
5444
5445 @cindex Unchecked deallocation
5446 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5447 @sp 1
5448 @cartouche
5449 For a standard storage pool, @code{Free} should actually reclaim the
5450 storage.
5451 @end cartouche
5452 Followed.
5453
5454 @cindex Stream oriented attributes
5455 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5456 @sp 1
5457 @cartouche
5458 If a stream element is the same size as a storage element, then the
5459 normal in-memory representation should be used by @code{Read} and
5460 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5461 should use the smallest number of stream elements needed to represent
5462 all values in the base range of the scalar type.
5463 @end cartouche
5464
5465 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5466 which specifies using the size of the first subtype.
5467 However, such an implementation is based on direct binary
5468 representations and is therefore target- and endianness-dependent.
5469 To address this issue, GNAT also supplies an alternate implementation
5470 of the stream attributes @code{Read} and @code{Write},
5471 which uses the target-independent XDR standard representation
5472 for scalar types.
5473 @cindex XDR representation
5474 @cindex @code{Read} attribute
5475 @cindex @code{Write} attribute
5476 @cindex Stream oriented attributes
5477 The XDR implementation is provided as an alternative body of the
5478 @code{System.Stream_Attributes} package, in the file
5479 @file{s-strxdr.adb} in the GNAT library.
5480 There is no @file{s-strxdr.ads} file.
5481 In order to install the XDR implementation, do the following:
5482 @enumerate
5483 @item Replace the default implementation of the
5484 @code{System.Stream_Attributes} package with the XDR implementation.
5485 For example on a Unix platform issue the commands:
5486 @smallexample
5487 $ mv s-stratt.adb s-strold.adb
5488 $ mv s-strxdr.adb s-stratt.adb
5489 @end smallexample
5490
5491 @item
5492 Rebuild the GNAT run-time library as documented in the
5493 @cite{GNAT User's Guide}
5494 @end enumerate
5495
5496 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5497 @sp 1
5498 @cartouche
5499 If an implementation provides additional named predefined integer types,
5500 then the names should end with @samp{Integer} as in
5501 @samp{Long_Integer}.  If an implementation provides additional named
5502 predefined floating point types, then the names should end with
5503 @samp{Float} as in @samp{Long_Float}.
5504 @end cartouche
5505 Followed.
5506
5507 @findex Ada.Characters.Handling
5508 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5509 @sp 1
5510 @cartouche
5511 If an implementation provides a localized definition of @code{Character}
5512 or @code{Wide_Character}, then the effects of the subprograms in
5513 @code{Characters.Handling} should reflect the localizations.  See also
5514 3.5.2.
5515 @end cartouche
5516 Followed.  GNAT provides no such localized definitions.
5517
5518 @cindex Bounded-length strings
5519 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5520 @sp 1
5521 @cartouche
5522 Bounded string objects should not be implemented by implicit pointers
5523 and dynamic allocation.
5524 @end cartouche
5525 Followed.  No implicit pointers or dynamic allocation are used.
5526
5527 @cindex Random number generation
5528 @unnumberedsec A.5.2(46-47): Random Number Generation
5529 @sp 1
5530 @cartouche
5531 Any storage associated with an object of type @code{Generator} should be
5532 reclaimed on exit from the scope of the object.
5533 @end cartouche
5534 Followed.
5535
5536 @sp 1
5537 @cartouche
5538 If the generator period is sufficiently long in relation to the number
5539 of distinct initiator values, then each possible value of
5540 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5541 random numbers that does not, in a practical sense, overlap the sequence
5542 initiated by any other value.  If this is not possible, then the mapping
5543 between initiator values and generator states should be a rapidly
5544 varying function of the initiator value.
5545 @end cartouche
5546 Followed.  The generator period is sufficiently long for the first
5547 condition here to hold true.
5548
5549 @findex Get_Immediate
5550 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5551 @sp 1
5552 @cartouche
5553 The @code{Get_Immediate} procedures should be implemented with
5554 unbuffered input.  For a device such as a keyboard, input should be
5555 @dfn{available} if a key has already been typed, whereas for a disk
5556 file, input should always be available except at end of file.  For a file
5557 associated with a keyboard-like device, any line-editing features of the
5558 underlying operating system should be disabled during the execution of
5559 @code{Get_Immediate}.
5560 @end cartouche
5561 Followed on all targets except VxWorks. For VxWorks, there is no way to
5562 provide this functionality that does not result in the input buffer being
5563 flushed before the @code{Get_Immediate} call. A special unit
5564 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5565 this functionality.
5566
5567 @findex Export
5568 @unnumberedsec B.1(39-41): Pragma @code{Export}
5569 @sp 1
5570 @cartouche
5571 If an implementation supports pragma @code{Export} to a given language,
5572 then it should also allow the main subprogram to be written in that
5573 language.  It should support some mechanism for invoking the elaboration
5574 of the Ada library units included in the system, and for invoking the
5575 finalization of the environment task.  On typical systems, the
5576 recommended mechanism is to provide two subprograms whose link names are
5577 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5578 elaboration code for library units.  @code{adafinal} should contain the
5579 finalization code.  These subprograms should have no effect the second
5580 and subsequent time they are called.
5581 @end cartouche
5582 Followed.
5583
5584 @sp 1
5585 @cartouche
5586 Automatic elaboration of pre-elaborated packages should be
5587 provided when pragma @code{Export} is supported.
5588 @end cartouche
5589 Followed when the main program is in Ada.  If the main program is in a
5590 foreign language, then
5591 @code{adainit} must be called to elaborate pre-elaborated
5592 packages.
5593
5594 @sp 1
5595 @cartouche
5596 For each supported convention @var{L} other than @code{Intrinsic}, an
5597 implementation should support @code{Import} and @code{Export} pragmas
5598 for objects of @var{L}-compatible types and for subprograms, and pragma
5599 @code{Convention} for @var{L}-eligible types and for subprograms,
5600 presuming the other language has corresponding features.  Pragma
5601 @code{Convention} need not be supported for scalar types.
5602 @end cartouche
5603 Followed.
5604
5605 @cindex Package @code{Interfaces}
5606 @findex Interfaces
5607 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5608 @sp 1
5609 @cartouche
5610 For each implementation-defined convention identifier, there should be a
5611 child package of package Interfaces with the corresponding name.  This
5612 package should contain any declarations that would be useful for
5613 interfacing to the language (implementation) represented by the
5614 convention.  Any declarations useful for interfacing to any language on
5615 the given hardware architecture should be provided directly in
5616 @code{Interfaces}.
5617 @end cartouche
5618 Followed.  An additional package not defined
5619 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5620 for interfacing to C++.
5621
5622 @sp 1
5623 @cartouche
5624 An implementation supporting an interface to C, COBOL, or Fortran should
5625 provide the corresponding package or packages described in the following
5626 clauses.
5627 @end cartouche
5628 Followed.  GNAT provides all the packages described in this section.
5629
5630 @cindex C, interfacing with
5631 @unnumberedsec B.3(63-71): Interfacing with C
5632 @sp 1
5633 @cartouche
5634 An implementation should support the following interface correspondences
5635 between Ada and C@.
5636 @end cartouche
5637 Followed.
5638
5639 @sp 1
5640 @cartouche
5641 An Ada procedure corresponds to a void-returning C function.
5642 @end cartouche
5643 Followed.
5644
5645 @sp 1
5646 @cartouche
5647 An Ada function corresponds to a non-void C function.
5648 @end cartouche
5649 Followed.
5650
5651 @sp 1
5652 @cartouche
5653 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5654 function.
5655 @end cartouche
5656 Followed.
5657
5658 @sp 1
5659 @cartouche
5660 An Ada @code{in} parameter of an access-to-object type with designated
5661 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5662 where @var{t} is the C type corresponding to the Ada type @var{T}.
5663 @end cartouche
5664 Followed.
5665
5666 @sp 1
5667 @cartouche
5668 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5669 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5670 argument to a C function, where @var{t} is the C type corresponding to
5671 the Ada type @var{T}.  In the case of an elementary @code{out} or
5672 @code{in out} parameter, a pointer to a temporary copy is used to
5673 preserve by-copy semantics.
5674 @end cartouche
5675 Followed.
5676
5677 @sp 1
5678 @cartouche
5679 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5680 @code{@var{t}*} argument to a C function, where @var{t} is the C
5681 structure corresponding to the Ada type @var{T}.
5682 @end cartouche
5683 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5684 pragma, or Convention, or by explicitly specifying the mechanism for a given
5685 call using an extended import or export pragma.
5686
5687 @sp 1
5688 @cartouche
5689 An Ada parameter of an array type with component type @var{T}, of any
5690 mode, is passed as a @code{@var{t}*} argument to a C function, where
5691 @var{t} is the C type corresponding to the Ada type @var{T}.
5692 @end cartouche
5693 Followed.
5694
5695 @sp 1
5696 @cartouche
5697 An Ada parameter of an access-to-subprogram type is passed as a pointer
5698 to a C function whose prototype corresponds to the designated
5699 subprogram's specification.
5700 @end cartouche
5701 Followed.
5702
5703 @cindex COBOL, interfacing with
5704 @unnumberedsec B.4(95-98): Interfacing with COBOL
5705 @sp 1
5706 @cartouche
5707 An Ada implementation should support the following interface
5708 correspondences between Ada and COBOL@.
5709 @end cartouche
5710 Followed.
5711
5712 @sp 1
5713 @cartouche
5714 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5715 the COBOL type corresponding to @var{T}.
5716 @end cartouche
5717 Followed.
5718
5719 @sp 1
5720 @cartouche
5721 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5722 the corresponding COBOL type.
5723 @end cartouche
5724 Followed.
5725
5726 @sp 1
5727 @cartouche
5728 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5729 COBOL type corresponding to the Ada parameter type; for scalars, a local
5730 copy is used if necessary to ensure by-copy semantics.
5731 @end cartouche
5732 Followed.
5733
5734 @cindex Fortran, interfacing with
5735 @unnumberedsec B.5(22-26): Interfacing with Fortran
5736 @sp 1
5737 @cartouche
5738 An Ada implementation should support the following interface
5739 correspondences between Ada and Fortran:
5740 @end cartouche
5741 Followed.
5742
5743 @sp 1
5744 @cartouche
5745 An Ada procedure corresponds to a Fortran subroutine.
5746 @end cartouche
5747 Followed.
5748
5749 @sp 1
5750 @cartouche
5751 An Ada function corresponds to a Fortran function.
5752 @end cartouche
5753 Followed.
5754
5755 @sp 1
5756 @cartouche
5757 An Ada parameter of an elementary, array, or record type @var{T} is
5758 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5759 the Fortran type corresponding to the Ada type @var{T}, and where the
5760 INTENT attribute of the corresponding dummy argument matches the Ada
5761 formal parameter mode; the Fortran implementation's parameter passing
5762 conventions are used.  For elementary types, a local copy is used if
5763 necessary to ensure by-copy semantics.
5764 @end cartouche
5765 Followed.
5766
5767 @sp 1
5768 @cartouche
5769 An Ada parameter of an access-to-subprogram type is passed as a
5770 reference to a Fortran procedure whose interface corresponds to the
5771 designated subprogram's specification.
5772 @end cartouche
5773 Followed.
5774
5775 @cindex Machine operations
5776 @unnumberedsec C.1(3-5): Access to Machine Operations
5777 @sp 1
5778 @cartouche
5779 The machine code or intrinsic support should allow access to all
5780 operations normally available to assembly language programmers for the
5781 target environment, including privileged instructions, if any.
5782 @end cartouche
5783 Followed.
5784
5785 @sp 1
5786 @cartouche
5787 The interfacing pragmas (see Annex B) should support interface to
5788 assembler; the default assembler should be associated with the
5789 convention identifier @code{Assembler}.
5790 @end cartouche
5791 Followed.
5792
5793 @sp 1
5794 @cartouche
5795 If an entity is exported to assembly language, then the implementation
5796 should allocate it at an addressable location, and should ensure that it
5797 is retained by the linking process, even if not otherwise referenced
5798 from the Ada code.  The implementation should assume that any call to a
5799 machine code or assembler subprogram is allowed to read or update every
5800 object that is specified as exported.
5801 @end cartouche
5802 Followed.
5803
5804 @unnumberedsec C.1(10-16): Access to Machine Operations
5805 @sp 1
5806 @cartouche
5807 The implementation should ensure that little or no overhead is
5808 associated with calling intrinsic and machine-code subprograms.
5809 @end cartouche
5810 Followed for both intrinsics and machine-code subprograms.
5811
5812 @sp 1
5813 @cartouche
5814 It is recommended that intrinsic subprograms be provided for convenient
5815 access to any machine operations that provide special capabilities or
5816 efficiency and that are not otherwise available through the language
5817 constructs.
5818 @end cartouche
5819 Followed.  A full set of machine operation intrinsic subprograms is provided.
5820
5821 @sp 1
5822 @cartouche
5823 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5824 swap, decrement and test, enqueue/dequeue.
5825 @end cartouche
5826 Followed on any target supporting such operations.
5827
5828 @sp 1
5829 @cartouche
5830 Standard numeric functions---e.g.@:, sin, log.
5831 @end cartouche
5832 Followed on any target supporting such operations.
5833
5834 @sp 1
5835 @cartouche
5836 String manipulation operations---e.g.@:, translate and test.
5837 @end cartouche
5838 Followed on any target supporting such operations.
5839
5840 @sp 1
5841 @cartouche
5842 Vector operations---e.g.@:, compare vector against thresholds.
5843 @end cartouche
5844 Followed on any target supporting such operations.
5845
5846 @sp 1
5847 @cartouche
5848 Direct operations on I/O ports.
5849 @end cartouche
5850 Followed on any target supporting such operations.
5851
5852 @cindex Interrupt support
5853 @unnumberedsec C.3(28): Interrupt Support
5854 @sp 1
5855 @cartouche
5856 If the @code{Ceiling_Locking} policy is not in effect, the
5857 implementation should provide means for the application to specify which
5858 interrupts are to be blocked during protected actions, if the underlying
5859 system allows for a finer-grain control of interrupt blocking.
5860 @end cartouche
5861 Followed.  The underlying system does not allow for finer-grain control
5862 of interrupt blocking.
5863
5864 @cindex Protected procedure handlers
5865 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5866 @sp 1
5867 @cartouche
5868 Whenever possible, the implementation should allow interrupt handlers to
5869 be called directly by the hardware.
5870 @end cartouche
5871 @c SGI info:
5872 @ignore
5873 This is never possible under IRIX, so this is followed by default.
5874 @end ignore
5875 Followed on any target where the underlying operating system permits
5876 such direct calls.
5877
5878 @sp 1
5879 @cartouche
5880 Whenever practical, violations of any
5881 implementation-defined restrictions should be detected before run time.
5882 @end cartouche
5883 Followed.  Compile time warnings are given when possible.
5884
5885 @cindex Package @code{Interrupts}
5886 @findex Interrupts
5887 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5888
5889 @sp 1
5890 @cartouche
5891 If implementation-defined forms of interrupt handler procedures are
5892 supported, such as protected procedures with parameters, then for each
5893 such form of a handler, a type analogous to @code{Parameterless_Handler}
5894 should be specified in a child package of @code{Interrupts}, with the
5895 same operations as in the predefined package Interrupts.
5896 @end cartouche
5897 Followed.
5898
5899 @cindex Pre-elaboration requirements
5900 @unnumberedsec C.4(14): Pre-elaboration Requirements
5901 @sp 1
5902 @cartouche
5903 It is recommended that pre-elaborated packages be implemented in such a
5904 way that there should be little or no code executed at run time for the
5905 elaboration of entities not already covered by the Implementation
5906 Requirements.
5907 @end cartouche
5908 Followed.  Executable code is generated in some cases, e.g.@: loops
5909 to initialize large arrays.
5910
5911 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5912
5913 @sp 1
5914 @cartouche
5915 If the pragma applies to an entity, then the implementation should
5916 reduce the amount of storage used for storing names associated with that
5917 entity.
5918 @end cartouche
5919 Followed.
5920
5921 @cindex Package @code{Task_Attributes}
5922 @findex Task_Attributes
5923 @unnumberedsec C.7.2(30): The Package Task_Attributes
5924 @sp 1
5925 @cartouche
5926 Some implementations are targeted to domains in which memory use at run
5927 time must be completely deterministic.  For such implementations, it is
5928 recommended that the storage for task attributes will be pre-allocated
5929 statically and not from the heap.  This can be accomplished by either
5930 placing restrictions on the number and the size of the task's
5931 attributes, or by using the pre-allocated storage for the first @var{N}
5932 attribute objects, and the heap for the others.  In the latter case,
5933 @var{N} should be documented.
5934 @end cartouche
5935 Not followed.  This implementation is not targeted to such a domain.
5936
5937 @cindex Locking Policies
5938 @unnumberedsec D.3(17): Locking Policies
5939
5940 @sp 1
5941 @cartouche
5942 The implementation should use names that end with @samp{_Locking} for
5943 locking policies defined by the implementation.
5944 @end cartouche
5945 Followed.  A single implementation-defined locking policy is defined,
5946 whose name (@code{Inheritance_Locking}) follows this suggestion.
5947
5948 @cindex Entry queuing policies
5949 @unnumberedsec D.4(16): Entry Queuing Policies
5950 @sp 1
5951 @cartouche
5952 Names that end with @samp{_Queuing} should be used
5953 for all implementation-defined queuing policies.
5954 @end cartouche
5955 Followed.  No such implementation-defined queuing policies exist.
5956
5957 @cindex Preemptive abort
5958 @unnumberedsec D.6(9-10): Preemptive Abort
5959 @sp 1
5960 @cartouche
5961 Even though the @code{abort_statement} is included in the list of
5962 potentially blocking operations (see 9.5.1), it is recommended that this
5963 statement be implemented in a way that never requires the task executing
5964 the @code{abort_statement} to block.
5965 @end cartouche
5966 Followed.
5967
5968 @sp 1
5969 @cartouche
5970 On a multi-processor, the delay associated with aborting a task on
5971 another processor should be bounded; the implementation should use
5972 periodic polling, if necessary, to achieve this.
5973 @end cartouche
5974 Followed.
5975
5976 @cindex Tasking restrictions
5977 @unnumberedsec D.7(21): Tasking Restrictions
5978 @sp 1
5979 @cartouche
5980 When feasible, the implementation should take advantage of the specified
5981 restrictions to produce a more efficient implementation.
5982 @end cartouche
5983 GNAT currently takes advantage of these restrictions by providing an optimized
5984 run time when the Ravenscar profile and the GNAT restricted run time set
5985 of restrictions are specified.  See pragma @code{Ravenscar} and pragma
5986 @code{Restricted_Run_Time} for more details.
5987
5988 @cindex Time, monotonic
5989 @unnumberedsec D.8(47-49): Monotonic Time
5990 @sp 1
5991 @cartouche
5992 When appropriate, implementations should provide configuration
5993 mechanisms to change the value of @code{Tick}.
5994 @end cartouche
5995 Such configuration mechanisms are not appropriate to this implementation
5996 and are thus not supported.
5997
5998 @sp 1
5999 @cartouche
6000 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6001 be implemented as transformations of the same time base.
6002 @end cartouche
6003 Followed.
6004
6005 @sp 1
6006 @cartouche
6007 It is recommended that the @dfn{best} time base which exists in
6008 the underlying system be available to the application through
6009 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6010 @end cartouche
6011 Followed.
6012
6013 @cindex Partition communication subsystem
6014 @cindex PCS
6015 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6016 @sp 1
6017 @cartouche
6018 Whenever possible, the PCS on the called partition should allow for
6019 multiple tasks to call the RPC-receiver with different messages and
6020 should allow them to block until the corresponding subprogram body
6021 returns.
6022 @end cartouche
6023 Followed by GLADE, a separately supplied PCS that can be used with
6024 GNAT.
6025
6026 @sp 1
6027 @cartouche
6028 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6029 should raise @code{Storage_Error} if it runs out of space trying to
6030 write the @code{Item} into the stream.
6031 @end cartouche
6032 Followed by GLADE, a separately supplied PCS that can be used with
6033 GNAT@.
6034
6035 @cindex COBOL support
6036 @unnumberedsec F(7): COBOL Support
6037 @sp 1
6038 @cartouche
6039 If COBOL (respectively, C) is widely supported in the target
6040 environment, implementations supporting the Information Systems Annex
6041 should provide the child package @code{Interfaces.COBOL} (respectively,
6042 @code{Interfaces.C}) specified in Annex B and should support a
6043 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6044 pragmas (see Annex B), thus allowing Ada programs to interface with
6045 programs written in that language.
6046 @end cartouche
6047 Followed.
6048
6049 @cindex Decimal radix support
6050 @unnumberedsec F.1(2): Decimal Radix Support
6051 @sp 1
6052 @cartouche
6053 Packed decimal should be used as the internal representation for objects
6054 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6055 @end cartouche
6056 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6057 representations.
6058
6059 @cindex Numerics
6060 @unnumberedsec G: Numerics
6061 @sp 2
6062 @cartouche
6063 If Fortran (respectively, C) is widely supported in the target
6064 environment, implementations supporting the Numerics Annex
6065 should provide the child package @code{Interfaces.Fortran} (respectively,
6066 @code{Interfaces.C}) specified in Annex B and should support a
6067 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6068 pragmas (see Annex B), thus allowing Ada programs to interface with
6069 programs written in that language.
6070 @end cartouche
6071 Followed.
6072
6073 @cindex Complex types
6074 @unnumberedsec G.1.1(56-58): Complex Types
6075 @sp 2
6076 @cartouche
6077 Because the usual mathematical meaning of multiplication of a complex
6078 operand and a real operand is that of the scaling of both components of
6079 the former by the latter, an implementation should not perform this
6080 operation by first promoting the real operand to complex type and then
6081 performing a full complex multiplication.  In systems that, in the
6082 future, support an Ada binding to IEC 559:1989, the latter technique
6083 will not generate the required result when one of the components of the
6084 complex operand is infinite.  (Explicit multiplication of the infinite
6085 component by the zero component obtained during promotion yields a NaN
6086 that propagates into the final result.) Analogous advice applies in the
6087 case of multiplication of a complex operand and a pure-imaginary
6088 operand, and in the case of division of a complex operand by a real or
6089 pure-imaginary operand.
6090 @end cartouche
6091 Not followed.
6092
6093 @sp 1
6094 @cartouche
6095 Similarly, because the usual mathematical meaning of addition of a
6096 complex operand and a real operand is that the imaginary operand remains
6097 unchanged, an implementation should not perform this operation by first
6098 promoting the real operand to complex type and then performing a full
6099 complex addition.  In implementations in which the @code{Signed_Zeros}
6100 attribute of the component type is @code{True} (and which therefore
6101 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6102 predefined arithmetic operations), the latter technique will not
6103 generate the required result when the imaginary component of the complex
6104 operand is a negatively signed zero.  (Explicit addition of the negative
6105 zero to the zero obtained during promotion yields a positive zero.)
6106 Analogous advice applies in the case of addition of a complex operand
6107 and a pure-imaginary operand, and in the case of subtraction of a
6108 complex operand and a real or pure-imaginary operand.
6109 @end cartouche
6110 Not followed.
6111
6112 @sp 1
6113 @cartouche
6114 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6115 attempt to provide a rational treatment of the signs of zero results and
6116 result components.  As one example, the result of the @code{Argument}
6117 function should have the sign of the imaginary component of the
6118 parameter @code{X} when the point represented by that parameter lies on
6119 the positive real axis; as another, the sign of the imaginary component
6120 of the @code{Compose_From_Polar} function should be the same as
6121 (respectively, the opposite of) that of the @code{Argument} parameter when that
6122 parameter has a value of zero and the @code{Modulus} parameter has a
6123 nonnegative (respectively, negative) value.
6124 @end cartouche
6125 Followed.
6126
6127 @cindex Complex elementary functions
6128 @unnumberedsec G.1.2(49): Complex Elementary Functions
6129 @sp 1
6130 @cartouche
6131 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6132 @code{True} should attempt to provide a rational treatment of the signs
6133 of zero results and result components.  For example, many of the complex
6134 elementary functions have components that are odd functions of one of
6135 the parameter components; in these cases, the result component should
6136 have the sign of the parameter component at the origin.  Other complex
6137 elementary functions have zero components whose sign is opposite that of
6138 a parameter component at the origin, or is always positive or always
6139 negative.
6140 @end cartouche
6141 Followed.
6142
6143 @cindex Accuracy requirements
6144 @unnumberedsec G.2.4(19): Accuracy Requirements
6145 @sp 1
6146 @cartouche
6147 The versions of the forward trigonometric functions without a
6148 @code{Cycle} parameter should not be implemented by calling the
6149 corresponding version with a @code{Cycle} parameter of
6150 @code{2.0*Numerics.Pi}, since this will not provide the required
6151 accuracy in some portions of the domain.  For the same reason, the
6152 version of @code{Log} without a @code{Base} parameter should not be
6153 implemented by calling the corresponding version with a @code{Base}
6154 parameter of @code{Numerics.e}.
6155 @end cartouche
6156 Followed.
6157
6158 @cindex Complex arithmetic accuracy
6159 @cindex Accuracy, complex arithmetic
6160 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6161
6162 @sp 1
6163 @cartouche
6164 The version of the @code{Compose_From_Polar} function without a
6165 @code{Cycle} parameter should not be implemented by calling the
6166 corresponding version with a @code{Cycle} parameter of
6167 @code{2.0*Numerics.Pi}, since this will not provide the required
6168 accuracy in some portions of the domain.
6169 @end cartouche
6170 Followed.
6171
6172 @c -----------------------------------------
6173 @node Implementation Defined Characteristics
6174 @chapter Implementation Defined Characteristics
6175
6176 @noindent
6177 In addition to the implementation dependent pragmas and attributes, and
6178 the implementation advice, there are a number of other features of Ada
6179 95 that are potentially implementation dependent.  These are mentioned
6180 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6181
6182 A requirement for conforming Ada compilers is that they provide
6183 documentation describing how the implementation deals with each of these
6184 issues.  In this chapter, you will find each point in annex M listed
6185 followed by a description in italic font of how GNAT
6186 @c SGI info:
6187 @ignore
6188 in the ProDev Ada
6189 implementation on IRIX 5.3 operating system or greater
6190 @end ignore
6191 handles the implementation dependence.
6192
6193 You can use this chapter as a guide to minimizing implementation
6194 dependent features in your programs if portability to other compilers
6195 and other operating systems is an important consideration.  The numbers
6196 in each section below correspond to the paragraph number in the Ada 95
6197 Reference Manual.
6198
6199 @sp 1
6200 @cartouche
6201 @noindent
6202 @strong{2}.  Whether or not each recommendation given in Implementation
6203 Advice is followed.  See 1.1.2(37).
6204 @end cartouche
6205 @noindent
6206 @xref{Implementation Advice}.
6207
6208 @sp 1
6209 @cartouche
6210 @noindent
6211 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6212 @end cartouche
6213 @noindent
6214 The complexity of programs that can be processed is limited only by the
6215 total amount of available virtual memory, and disk space for the
6216 generated object files.
6217
6218 @sp 1
6219 @cartouche
6220 @noindent
6221 @strong{4}.  Variations from the standard that are impractical to avoid
6222 given the implementation's execution environment.  See 1.1.3(6).
6223 @end cartouche
6224 @noindent
6225 There are no variations from the standard.
6226
6227 @sp 1
6228 @cartouche
6229 @noindent
6230 @strong{5}.  Which @code{code_statement}s cause external
6231 interactions.  See 1.1.3(10).
6232 @end cartouche
6233 @noindent
6234 Any @code{code_statement} can potentially cause external interactions.
6235
6236 @sp 1
6237 @cartouche
6238 @noindent
6239 @strong{6}.  The coded representation for the text of an Ada
6240 program.  See 2.1(4).
6241 @end cartouche
6242 @noindent
6243 See separate section on source representation.
6244
6245 @sp 1
6246 @cartouche
6247 @noindent
6248 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6249 @end cartouche
6250 @noindent
6251 See separate section on source representation.
6252
6253 @sp 1
6254 @cartouche
6255 @noindent
6256 @strong{8}.  The representation for an end of line.  See 2.2(2).
6257 @end cartouche
6258 @noindent
6259 See separate section on source representation.
6260
6261 @sp 1
6262 @cartouche
6263 @noindent
6264 @strong{9}.  Maximum supported line length and lexical element
6265 length.  See 2.2(15).
6266 @end cartouche
6267 @noindent
6268 The maximum line length is 255 characters an the maximum length of a
6269 lexical element is also 255 characters.
6270
6271 @sp 1
6272 @cartouche
6273 @noindent
6274 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6275 @end cartouche
6276 @noindent
6277
6278 @xref{Implementation Defined Pragmas}.
6279
6280 @sp 1
6281 @cartouche
6282 @noindent
6283 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6284 @end cartouche
6285 @noindent
6286 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6287 parameter, checks that the optimization flag is set, and aborts if it is
6288 not.
6289
6290 @sp 1
6291 @cartouche
6292 @noindent
6293 @strong{12}.  The sequence of characters of the value returned by
6294 @code{@var{S}'Image} when some of the graphic characters of
6295 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6296 3.5(37).
6297 @end cartouche
6298 @noindent
6299 The sequence of characters is as defined by the wide character encoding
6300 method used for the source.  See section on source representation for
6301 further details.
6302
6303 @sp 1
6304 @cartouche
6305 @noindent
6306 @strong{13}.  The predefined integer types declared in
6307 @code{Standard}.  See 3.5.4(25).
6308 @end cartouche
6309 @noindent
6310 @table @code
6311 @item Short_Short_Integer
6312 8 bit signed
6313 @item Short_Integer
6314 (Short) 16 bit signed
6315 @item Integer
6316 32 bit signed
6317 @item Long_Integer
6318 64 bit signed (Alpha OpenVMS only)
6319 32 bit signed (all other targets)
6320 @item Long_Long_Integer
6321 64 bit signed
6322 @end table
6323
6324 @sp 1
6325 @cartouche
6326 @noindent
6327 @strong{14}.  Any nonstandard integer types and the operators defined
6328 for them.  See 3.5.4(26).
6329 @end cartouche
6330 @noindent
6331 There are no nonstandard integer types.
6332
6333 @sp 1
6334 @cartouche
6335 @noindent
6336 @strong{15}.  Any nonstandard real types and the operators defined for
6337 them.  See 3.5.6(8).
6338 @end cartouche
6339 @noindent
6340 There are no nonstandard real types.
6341
6342 @sp 1
6343 @cartouche
6344 @noindent
6345 @strong{16}.  What combinations of requested decimal precision and range
6346 are supported for floating point types.  See 3.5.7(7).
6347 @end cartouche
6348 @noindent
6349 The precision and range is as defined by the IEEE standard.
6350
6351 @sp 1
6352 @cartouche
6353 @noindent
6354 @strong{17}.  The predefined floating point types declared in
6355 @code{Standard}.  See 3.5.7(16).
6356 @end cartouche
6357 @noindent
6358 @table @code
6359 @item Short_Float
6360 32 bit IEEE short
6361 @item Float
6362 (Short) 32 bit IEEE short
6363 @item Long_Float
6364 64 bit IEEE long
6365 @item Long_Long_Float
6366 64 bit IEEE long (80 bit IEEE long on x86 processors)
6367 @end table
6368
6369 @sp 1
6370 @cartouche
6371 @noindent
6372 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6373 @end cartouche
6374 @noindent
6375 @code{Fine_Delta} is 2**(@minus{}63)
6376
6377 @sp 1
6378 @cartouche
6379 @noindent
6380 @strong{19}.  What combinations of small, range, and digits are
6381 supported for fixed point types.  See 3.5.9(10).
6382 @end cartouche
6383 @noindent
6384 Any combinations are permitted that do not result in a small less than
6385 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6386 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6387 is 64 bits (true of all architectures except ia32), then the output from
6388 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6389 is because floating-point conversions are used to convert fixed point.
6390
6391 @sp 1
6392 @cartouche
6393 @noindent
6394 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6395 within an unnamed @code{block_statement}.  See 3.9(10).
6396 @end cartouche
6397 @noindent
6398 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6399 decimal integer are allocated.
6400
6401 @sp 1
6402 @cartouche
6403 @noindent
6404 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6405 @end cartouche
6406 @noindent
6407 @xref{Implementation Defined Attributes}.
6408
6409 @sp 1
6410 @cartouche
6411 @noindent
6412 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6413 @end cartouche
6414 @noindent
6415 There are no implementation-defined time types.
6416
6417 @sp 1
6418 @cartouche
6419 @noindent
6420 @strong{23}.  The time base associated with relative delays.
6421 @end cartouche
6422 @noindent
6423 See 9.6(20).  The time base used is that provided by the C library
6424 function @code{gettimeofday}.
6425
6426 @sp 1
6427 @cartouche
6428 @noindent
6429 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6430 9.6(23).
6431 @end cartouche
6432 @noindent
6433 The time base used is that provided by the C library function
6434 @code{gettimeofday}.
6435
6436 @sp 1
6437 @cartouche
6438 @noindent
6439 @strong{25}.  The time zone used for package @code{Calendar}
6440 operations.  See 9.6(24).
6441 @end cartouche
6442 @noindent
6443 The time zone used by package @code{Calendar} is the current system time zone
6444 setting for local time, as accessed by the C library function
6445 @code{localtime}.
6446
6447 @sp 1
6448 @cartouche
6449 @noindent
6450 @strong{26}.  Any limit on @code{delay_until_statements} of
6451 @code{select_statements}.  See 9.6(29).
6452 @end cartouche
6453 @noindent
6454 There are no such limits.
6455
6456 @sp 1
6457 @cartouche
6458 @noindent
6459 @strong{27}.  Whether or not two non overlapping parts of a composite
6460 object are independently addressable, in the case where packing, record
6461 layout, or @code{Component_Size} is specified for the object.  See
6462 9.10(1).
6463 @end cartouche
6464 @noindent
6465 Separate components are independently addressable if they do not share
6466 overlapping storage units.
6467
6468 @sp 1
6469 @cartouche
6470 @noindent
6471 @strong{28}.  The representation for a compilation.  See 10.1(2).
6472 @end cartouche
6473 @noindent
6474 A compilation is represented by a sequence of files presented to the
6475 compiler in a single invocation of the @code{gcc} command.
6476
6477 @sp 1
6478 @cartouche
6479 @noindent
6480 @strong{29}.  Any restrictions on compilations that contain multiple
6481 compilation_units.  See 10.1(4).
6482 @end cartouche
6483 @noindent
6484 No single file can contain more than one compilation unit, but any
6485 sequence of files can be presented to the compiler as a single
6486 compilation.
6487
6488 @sp 1
6489 @cartouche
6490 @noindent
6491 @strong{30}.  The mechanisms for creating an environment and for adding
6492 and replacing compilation units.  See 10.1.4(3).
6493 @end cartouche
6494 @noindent
6495 See separate section on compilation model.
6496
6497 @sp 1
6498 @cartouche
6499 @noindent
6500 @strong{31}.  The manner of explicitly assigning library units to a
6501 partition.  See 10.2(2).
6502 @end cartouche
6503 @noindent
6504 If a unit contains an Ada main program, then the Ada units for the partition
6505 are determined by recursive application of the rules in the Ada Reference
6506 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6507 are needed by the main program, and then this definition of need is applied
6508 recursively to those units, and the partition contains the transitive
6509 closure determined by this relationship.  In short, all the necessary units
6510 are included, with no need to explicitly specify the list.  If additional
6511 units are required, e.g.@: by foreign language units, then all units must be
6512 mentioned in the context clause of one of the needed Ada units.
6513
6514 If the partition contains no main program, or if the main program is in
6515 a language other than Ada, then GNAT
6516 provides the binder options @code{-z} and @code{-n} respectively, and in
6517 this case a list of units can be explicitly supplied to the binder for
6518 inclusion in the partition (all units needed by these units will also
6519 be included automatically).  For full details on the use of these
6520 options, refer to the @cite{GNAT User's Guide} sections on Binding
6521 and Linking.
6522
6523 @sp 1
6524 @cartouche
6525 @noindent
6526 @strong{32}.  The implementation-defined means, if any, of specifying
6527 which compilation units are needed by a given compilation unit.  See
6528 10.2(2).
6529 @end cartouche
6530 @noindent
6531 The units needed by a given compilation unit are as defined in
6532 the Ada Reference Manual section 10.2(2-6).  There are no
6533 implementation-defined pragmas or other implementation-defined
6534 means for specifying needed units.
6535
6536 @sp 1
6537 @cartouche
6538 @noindent
6539 @strong{33}.  The manner of designating the main subprogram of a
6540 partition.  See 10.2(7).
6541 @end cartouche
6542 @noindent
6543 The main program is designated by providing the name of the
6544 corresponding @file{ALI} file as the input parameter to the binder.
6545
6546 @sp 1
6547 @cartouche
6548 @noindent
6549 @strong{34}.  The order of elaboration of @code{library_items}.  See
6550 10.2(18).
6551 @end cartouche
6552 @noindent
6553 The first constraint on ordering is that it meets the requirements of
6554 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6555 implementation dependent choices, which are resolved by first
6556 elaborating bodies as early as possible (i.e.@: in preference to specs
6557 where there is a choice), and second by evaluating the immediate with
6558 clauses of a unit to determine the probably best choice, and
6559 third by elaborating in alphabetical order of unit names
6560 where a choice still remains.
6561
6562 @sp 1
6563 @cartouche
6564 @noindent
6565 @strong{35}.  Parameter passing and function return for the main
6566 subprogram.  See 10.2(21).
6567 @end cartouche
6568 @noindent
6569 The main program has no parameters.  It may be a procedure, or a function
6570 returning an integer type.  In the latter case, the returned integer
6571 value is the return code of the program (overriding any value that
6572 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6573
6574 @sp 1
6575 @cartouche
6576 @noindent
6577 @strong{36}.  The mechanisms for building and running partitions.  See
6578 10.2(24).
6579 @end cartouche
6580 @noindent
6581 GNAT itself supports programs with only a single partition.  The GNATDIST
6582 tool provided with the GLADE package (which also includes an implementation
6583 of the PCS) provides a completely flexible method for building and running
6584 programs consisting of multiple partitions.  See the separate GLADE manual
6585 for details.
6586
6587 @sp 1
6588 @cartouche
6589 @noindent
6590 @strong{37}.  The details of program execution, including program
6591 termination.  See 10.2(25).
6592 @end cartouche
6593 @noindent
6594 See separate section on compilation model.
6595
6596 @sp 1
6597 @cartouche
6598 @noindent
6599 @strong{38}.  The semantics of any non-active partitions supported by the
6600 implementation.  See 10.2(28).
6601 @end cartouche
6602 @noindent
6603 Passive partitions are supported on targets where shared memory is
6604 provided by the operating system.  See the GLADE reference manual for
6605 further details.
6606
6607 @sp 1
6608 @cartouche
6609 @noindent
6610 @strong{39}.  The information returned by @code{Exception_Message}.  See
6611 11.4.1(10).
6612 @end cartouche
6613 @noindent
6614 Exception message returns the null string unless a specific message has
6615 been passed by the program.
6616
6617 @sp 1
6618 @cartouche
6619 @noindent
6620 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6621 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6622 @end cartouche
6623 @noindent
6624 Blocks have implementation defined names of the form @code{B@var{nnn}}
6625 where @var{nnn} is an integer.
6626
6627 @sp 1
6628 @cartouche
6629 @noindent
6630 @strong{41}.  The information returned by
6631 @code{Exception_Information}.  See 11.4.1(13).
6632 @end cartouche
6633 @noindent
6634 @code{Exception_Information} returns a string in the following format:
6635
6636 @smallexample
6637 @emph{Exception_Name:} nnnnn
6638 @emph{Message:} mmmmm
6639 @emph{PID:} ppp
6640 @emph{Call stack traceback locations:}
6641 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6642 @end smallexample
6643
6644 @noindent
6645 where
6646
6647 @itemize @bullet
6648 @item
6649 @code{nnnn} is the fully qualified name of the exception in all upper
6650 case letters. This line is always present.
6651
6652 @item
6653 @code{mmmm} is the message (this line present only if message is non-null)
6654
6655 @item
6656 @code{ppp} is the Process Id value as a decimal integer (this line is
6657 present only if the Process Id is non-zero). Currently we are
6658 not making use of this field.
6659
6660 @item
6661 The Call stack traceback locations line and the following values
6662 are present only if at least one traceback location was recorded.
6663 The values are given in C style format, with lower case letters
6664 for a-f, and only as many digits present as are necessary.
6665 @end itemize
6666
6667 @noindent
6668 The line terminator sequence at the end of each line, including
6669 the last line is a single @code{LF} character (@code{16#0A#}).
6670
6671 @sp 1
6672 @cartouche
6673 @noindent
6674 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6675 @end cartouche
6676 @noindent
6677 No implementation-defined check names are supported.
6678
6679 @sp 1
6680 @cartouche
6681 @noindent
6682 @strong{43}.  The interpretation of each aspect of representation.  See
6683 13.1(20).
6684 @end cartouche
6685 @noindent
6686 See separate section on data representations.
6687
6688 @sp 1
6689 @cartouche
6690 @noindent
6691 @strong{44}.  Any restrictions placed upon representation items.  See
6692 13.1(20).
6693 @end cartouche
6694 @noindent
6695 See separate section on data representations.
6696
6697 @sp 1
6698 @cartouche
6699 @noindent
6700 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6701 13.3(48).
6702 @end cartouche
6703 @noindent
6704 Size for an indefinite subtype is the maximum possible size, except that
6705 for the case of a subprogram parameter, the size of the parameter object
6706 is the actual size.
6707
6708 @sp 1
6709 @cartouche
6710 @noindent
6711 @strong{46}.  The default external representation for a type tag.  See
6712 13.3(75).
6713 @end cartouche
6714 @noindent
6715 The default external representation for a type tag is the fully expanded
6716 name of the type in upper case letters.
6717
6718 @sp 1
6719 @cartouche
6720 @noindent
6721 @strong{47}.  What determines whether a compilation unit is the same in
6722 two different partitions.  See 13.3(76).
6723 @end cartouche
6724 @noindent
6725 A compilation unit is the same in two different partitions if and only
6726 if it derives from the same source file.
6727
6728 @sp 1
6729 @cartouche
6730 @noindent
6731 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6732 @end cartouche
6733 @noindent
6734 The only implementation defined component is the tag for a tagged type,
6735 which contains a pointer to the dispatching table.
6736
6737 @sp 1
6738 @cartouche
6739 @noindent
6740 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6741 ordering.  See 13.5.3(5).
6742 @end cartouche
6743 @noindent
6744 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6745 implementation, so no non-default bit ordering is supported.  The default
6746 bit ordering corresponds to the natural endianness of the target architecture.
6747
6748 @sp 1
6749 @cartouche
6750 @noindent
6751 @strong{50}.  The contents of the visible part of package @code{System}
6752 and its language-defined children.  See 13.7(2).
6753 @end cartouche
6754 @noindent
6755 See the definition of these packages in files @file{system.ads} and
6756 @file{s-stoele.ads}.
6757
6758 @sp 1
6759 @cartouche
6760 @noindent
6761 @strong{51}.  The contents of the visible part of package
6762 @code{System.Machine_Code}, and the meaning of
6763 @code{code_statements}.  See 13.8(7).
6764 @end cartouche
6765 @noindent
6766 See the definition and documentation in file @file{s-maccod.ads}.
6767
6768 @sp 1
6769 @cartouche
6770 @noindent
6771 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6772 @end cartouche
6773 @noindent
6774 Unchecked conversion between types of the same size
6775 and results in an uninterpreted transmission of the bits from one type
6776 to the other.  If the types are of unequal sizes, then in the case of
6777 discrete types, a shorter source is first zero or sign extended as
6778 necessary, and a shorter target is simply truncated on the left.
6779 For all non-discrete types, the source is first copied if necessary
6780 to ensure that the alignment requirements of the target are met, then
6781 a pointer is constructed to the source value, and the result is obtained
6782 by dereferencing this pointer after converting it to be a pointer to the
6783 target type.
6784
6785 @sp 1
6786 @cartouche
6787 @noindent
6788 @strong{53}.  The manner of choosing a storage pool for an access type
6789 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6790 @end cartouche
6791 @noindent
6792 There are 3 different standard pools used by the compiler when
6793 @code{Storage_Pool} is not specified depending whether the type is local
6794 to a subprogram or defined at the library level and whether
6795 @code{Storage_Size}is specified or not.  See documentation in the runtime
6796 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6797 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6798 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6799 default pools used.
6800
6801 @sp 1
6802 @cartouche
6803 @noindent
6804 @strong{54}.  Whether or not the implementation provides user-accessible
6805 names for the standard pool type(s).  See 13.11(17).
6806 @end cartouche
6807 @noindent
6808
6809 See documentation in the sources of the run time mentioned in paragraph
6810 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6811 these units.
6812
6813 @sp 1
6814 @cartouche
6815 @noindent
6816 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6817 @end cartouche
6818 @noindent
6819 @code{Storage_Size} is measured in storage units, and refers to the
6820 total space available for an access type collection, or to the primary
6821 stack space for a task.
6822
6823 @sp 1
6824 @cartouche
6825 @noindent
6826 @strong{56}.  Implementation-defined aspects of storage pools.  See
6827 13.11(22).
6828 @end cartouche
6829 @noindent
6830 See documentation in the sources of the run time mentioned in paragraph
6831 @strong{53} for details on GNAT-defined aspects of storage pools.
6832
6833 @sp 1
6834 @cartouche
6835 @noindent
6836 @strong{57}.  The set of restrictions allowed in a pragma
6837 @code{Restrictions}.  See 13.12(7).
6838 @end cartouche
6839 @noindent
6840 All RM defined Restriction identifiers are implemented.  The following
6841 additional restriction identifiers are provided.  There are two separate
6842 lists of implementation dependent restriction identifiers.  The first
6843 set requires consistency throughout a partition (in other words, if the
6844 restriction identifier is used for any compilation unit in the partition,
6845 then all compilation units in the partition must obey the restriction.
6846
6847 @table @code
6848
6849 @item Boolean_Entry_Barriers
6850 @findex Boolean_Entry_Barriers
6851 This restriction ensures at compile time that barriers in entry declarations
6852 for protected types are restricted to references to simple boolean variables
6853 defined in the private part of the protected type.  No other form of entry
6854 barriers is permitted.  This is one of the restrictions of the Ravenscar
6855 profile for limited tasking (see also pragma @code{Ravenscar}).
6856
6857 @item Max_Entry_Queue_Depth => Expr
6858 @findex Max_Entry_Queue_Depth
6859 This restriction is a declaration that any protected entry compiled in
6860 the scope of the restriction has at most the specified number of
6861 tasks waiting on the entry
6862 at any one time, and so no queue is required.  This restriction is not
6863 checked at compile time.  A program execution is erroneous if an attempt
6864 is made to queue more than the specified number of tasks on such an entry.
6865
6866 @item No_Calendar
6867 @findex No_Calendar
6868 This restriction ensures at compile time that there is no implicit or
6869 explicit dependence on the package @code{Ada.Calendar}.
6870
6871 @item No_Direct_Boolean_Operators
6872 @findex No_Direct_Boolean_Operators
6873 This restriction ensures that no logical (and/or/xor) or comparison
6874 operators are used on operands of type Boolean (or any type derived
6875 from Boolean). This is intended for use in safety critical programs
6876 where the certification protocol requires the use of short-circuit
6877 (and then, or else) forms for all composite boolean operations.
6878
6879 @item No_Dynamic_Interrupts
6880 @findex No_Dynamic_Interrupts
6881 This restriction ensures at compile time that there is no attempt to
6882 dynamically associate interrupts.  Only static association is allowed.
6883
6884 @item No_Enumeration_Maps
6885 @findex No_Enumeration_Maps
6886 This restriction ensures at compile time that no operations requiring
6887 enumeration maps are used (that is Image and Value attributes applied
6888 to enumeration types).
6889
6890 @item No_Entry_Calls_In_Elaboration_Code
6891 @findex No_Entry_Calls_In_Elaboration_Code
6892 This restriction ensures at compile time that no task or protected entry
6893 calls are made during elaboration code.  As a result of the use of this
6894 restriction, the compiler can assume that no code past an accept statement
6895 in a task can be executed at elaboration time.
6896
6897 @item No_Exception_Handlers
6898 @findex No_Exception_Handlers
6899 This restriction ensures at compile time that there are no explicit
6900 exception handlers. It also indicates that no exception propagation will
6901 be provided. In this mode, exceptions may be raised but will result in
6902 an immediate call to the last chance handler, a routine that the user
6903 must define with the following profile:
6904
6905    procedure Last_Chance_Handler
6906      (Source_Location : System.Address; Line : Integer);
6907    pragma Export (C, Last_Chance_Handler,
6908                   "__gnat_last_chance_handler");
6909
6910    The parameter is a C null-terminated string representing a message to be
6911    associated with the exception (typically the source location of the raise
6912    statement generated by the compiler). The Line parameter when non-zero
6913    represents the line number in the source program where the raise occurs.
6914
6915 @item No_Exception_Streams
6916 @findex No_Exception_Streams
6917 This restriction ensures at compile time that no stream operations for
6918 types Exception_Id or Exception_Occurrence are used. This also makes it
6919 impossible to pass exceptions to or from a partition with this restriction
6920 in a distributed environment. If this exception is active, then the generated
6921 code is simplified by omitting the otherwise-required global registration
6922 of exceptions when they are declared.
6923
6924 @item No_Implicit_Conditionals
6925 @findex No_Implicit_Conditionals
6926 This restriction ensures that the generated code does not contain any
6927 implicit conditionals, either by modifying the generated code where possible,
6928 or by rejecting any construct that would otherwise generate an implicit
6929 conditional.
6930
6931 @item No_Implicit_Dynamic_Code
6932 @findex No_Implicit_Dynamic_Code
6933 This restriction prevents the compiler from building ``trampolines''.
6934 This is a structure that is built on the stack and contains dynamic
6935 code to be executed at run time. A trampoline is needed to indirectly
6936 address a nested subprogram (that is a subprogram that is not at the
6937 library level). The restriction prevents the use of any of the
6938 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
6939 being applied to a subprogram that is not at the library level.
6940
6941 @item No_Implicit_Loops
6942 @findex No_Implicit_Loops
6943 This restriction ensures that the generated code does not contain any
6944 implicit @code{for} loops, either by modifying
6945 the generated code where possible,
6946 or by rejecting any construct that would otherwise generate an implicit
6947 @code{for} loop.
6948
6949 @item No_Initialize_Scalars
6950 @findex No_Initialize_Scalars
6951 This restriction ensures that no unit in the partition is compiled with
6952 pragma Initialize_Scalars. This allows the generation of more efficient
6953 code, and in particular eliminates dummy null initialization routines that
6954 are otherwise generated for some record and array types.
6955
6956 @item No_Local_Protected_Objects
6957 @findex No_Local_Protected_Objects
6958 This restriction ensures at compile time that protected objects are
6959 only declared at the library level.
6960
6961 @item No_Protected_Type_Allocators
6962 @findex No_Protected_Type_Allocators
6963 This restriction ensures at compile time that there are no allocator
6964 expressions that attempt to allocate protected objects.
6965
6966 @item No_Secondary_Stack
6967 @findex No_Secondary_Stack
6968 This restriction ensures at compile time that the generated code does not
6969 contain any reference to the secondary stack.  The secondary stack is used
6970 to implement functions returning unconstrained objects (arrays or records)
6971 on some targets.
6972
6973 @item No_Select_Statements
6974 @findex No_Select_Statements
6975 This restriction ensures at compile time no select statements of any kind
6976 are permitted, that is the keyword @code{select} may not appear.
6977 This is one of the restrictions of the Ravenscar
6978 profile for limited tasking (see also pragma @code{Ravenscar}).
6979
6980 @item No_Standard_Storage_Pools
6981 @findex No_Standard_Storage_Pools
6982 This restriction ensures at compile time that no access types
6983 use the standard default storage pool.  Any access type declared must
6984 have an explicit Storage_Pool attribute defined specifying a
6985 user-defined storage pool.
6986
6987 @item No_Streams
6988 @findex No_Streams
6989 This restriction ensures at compile time that there are no implicit or
6990 explicit dependencies on the package @code{Ada.Streams}.
6991
6992 @item No_Task_Attributes
6993 @findex No_Task_Attributes
6994 This restriction ensures at compile time that there are no implicit or
6995 explicit dependencies on the package @code{Ada.Task_Attributes}.
6996
6997 @item No_Task_Termination
6998 @findex No_Task_Termination
6999 This restriction ensures at compile time that no terminate alternatives
7000 appear in any task body.
7001
7002 @item No_Tasking
7003 @findex No_Tasking
7004 This restriction prevents the declaration of tasks or task types throughout
7005 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7006 except that violations are caught at compile time and cause an error message
7007 to be output either by the compiler or binder.
7008
7009 @item No_Wide_Characters
7010 @findex No_Wide_Characters
7011 This restriction ensures at compile time that no uses of the types
7012 @code{Wide_Character} or @code{Wide_String}
7013 appear, and that no wide character literals
7014 appear in the program (that is literals representing characters not in
7015 type @code{Character}.
7016
7017 @item Static_Priorities
7018 @findex Static_Priorities
7019 This restriction ensures at compile time that all priority expressions
7020 are static, and that there are no dependencies on the package
7021 @code{Ada.Dynamic_Priorities}.
7022
7023 @item Static_Storage_Size
7024 @findex Static_Storage_Size
7025 This restriction ensures at compile time that any expression appearing
7026 in a Storage_Size pragma or attribute definition clause is static.
7027
7028 @end table
7029
7030 @noindent
7031 The second set of implementation dependent restriction identifiers
7032 does not require partition-wide consistency.
7033 The restriction may be enforced for a single
7034 compilation unit without any effect on any of the
7035 other compilation units in the partition.
7036
7037 @table @code
7038
7039 @item No_Elaboration_Code
7040 @findex No_Elaboration_Code
7041 This restriction ensures at compile time that no elaboration code is
7042 generated.  Note that this is not the same condition as is enforced
7043 by pragma @code{Preelaborate}.  There are cases in which pragma
7044 @code{Preelaborate} still permits code to be generated (e.g.@: code
7045 to initialize a large array to all zeroes), and there are cases of units
7046 which do not meet the requirements for pragma @code{Preelaborate},
7047 but for which no elaboration code is generated.  Generally, it is
7048 the case that preelaborable units will meet the restrictions, with
7049 the exception of large aggregates initialized with an others_clause,
7050 and exception declarations (which generate calls to a run-time
7051 registry procedure).  Note that this restriction is enforced on
7052 a unit by unit basis, it need not be obeyed consistently
7053 throughout a partition.
7054
7055 @item No_Entry_Queue
7056 @findex No_Entry_Queue
7057 This restriction is a declaration that any protected entry compiled in
7058 the scope of the restriction has at most one task waiting on the entry
7059 at any one time, and so no queue is required.  This restriction is not
7060 checked at compile time.  A program execution is erroneous if an attempt
7061 is made to queue a second task on such an entry.
7062
7063 @item No_Implementation_Attributes
7064 @findex No_Implementation_Attributes
7065 This restriction checks at compile time that no GNAT-defined attributes
7066 are present.  With this restriction, the only attributes that can be used
7067 are those defined in the Ada 95 Reference Manual.
7068
7069 @item No_Implementation_Pragmas
7070 @findex No_Implementation_Pragmas
7071 This restriction checks at compile time that no GNAT-defined pragmas
7072 are present.  With this restriction, the only pragmas that can be used
7073 are those defined in the Ada 95 Reference Manual.
7074
7075 @item No_Implementation_Restrictions
7076 @findex No_Implementation_Restrictions
7077 This restriction checks at compile time that no GNAT-defined restriction
7078 identifiers (other than @code{No_Implementation_Restrictions} itself)
7079 are present.  With this restriction, the only other restriction identifiers
7080 that can be used are those defined in the Ada 95 Reference Manual.
7081
7082 @end table
7083
7084 @sp 1
7085 @cartouche
7086 @noindent
7087 @strong{58}.  The consequences of violating limitations on
7088 @code{Restrictions} pragmas.  See 13.12(9).
7089 @end cartouche
7090 @noindent
7091 Restrictions that can be checked at compile time result in illegalities
7092 if violated.  Currently there are no other consequences of violating
7093 restrictions.
7094
7095 @sp 1
7096 @cartouche
7097 @noindent
7098 @strong{59}.  The representation used by the @code{Read} and
7099 @code{Write} attributes of elementary types in terms of stream
7100 elements.  See 13.13.2(9).
7101 @end cartouche
7102 @noindent
7103 The representation is the in-memory representation of the base type of
7104 the type, using the number of bits corresponding to the
7105 @code{@var{type}'Size} value, and the natural ordering of the machine.
7106
7107 @sp 1
7108 @cartouche
7109 @noindent
7110 @strong{60}.  The names and characteristics of the numeric subtypes
7111 declared in the visible part of package @code{Standard}.  See A.1(3).
7112 @end cartouche
7113 @noindent
7114 See items describing the integer and floating-point types supported.
7115
7116 @sp 1
7117 @cartouche
7118 @noindent
7119 @strong{61}.  The accuracy actually achieved by the elementary
7120 functions.  See A.5.1(1).
7121 @end cartouche
7122 @noindent
7123 The elementary functions correspond to the functions available in the C
7124 library.  Only fast math mode is implemented.
7125
7126 @sp 1
7127 @cartouche
7128 @noindent
7129 @strong{62}.  The sign of a zero result from some of the operators or
7130 functions in @code{Numerics.Generic_Elementary_Functions}, when
7131 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7132 @end cartouche
7133 @noindent
7134 The sign of zeroes follows the requirements of the IEEE 754 standard on
7135 floating-point.
7136
7137 @sp 1
7138 @cartouche
7139 @noindent
7140 @strong{63}.  The value of
7141 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7142 @end cartouche
7143 @noindent
7144 Maximum image width is 649, see library file @file{a-numran.ads}.
7145
7146 @sp 1
7147 @cartouche
7148 @noindent
7149 @strong{64}.  The value of
7150 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7151 @end cartouche
7152 @noindent
7153 Maximum image width is 80, see library file @file{a-nudira.ads}.
7154
7155 @sp 1
7156 @cartouche
7157 @noindent
7158 @strong{65}.  The algorithms for random number generation.  See
7159 A.5.2(32).
7160 @end cartouche
7161 @noindent
7162 The algorithm is documented in the source files @file{a-numran.ads} and
7163 @file{a-numran.adb}.
7164
7165 @sp 1
7166 @cartouche
7167 @noindent
7168 @strong{66}.  The string representation of a random number generator's
7169 state.  See A.5.2(38).
7170 @end cartouche
7171 @noindent
7172 See the documentation contained in the file @file{a-numran.adb}.
7173
7174 @sp 1
7175 @cartouche
7176 @noindent
7177 @strong{67}.  The minimum time interval between calls to the
7178 time-dependent Reset procedure that are guaranteed to initiate different
7179 random number sequences.  See A.5.2(45).
7180 @end cartouche
7181 @noindent
7182 The minimum period between reset calls to guarantee distinct series of
7183 random numbers is one microsecond.
7184
7185 @sp 1
7186 @cartouche
7187 @noindent
7188 @strong{68}.  The values of the @code{Model_Mantissa},
7189 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7190 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7191 Annex is not supported.  See A.5.3(72).
7192 @end cartouche
7193 @noindent
7194 See the source file @file{ttypef.ads} for the values of all numeric
7195 attributes.
7196
7197 @sp 1
7198 @cartouche
7199 @noindent
7200 @strong{69}.  Any implementation-defined characteristics of the
7201 input-output packages.  See A.7(14).
7202 @end cartouche
7203 @noindent
7204 There are no special implementation defined characteristics for these
7205 packages.
7206
7207 @sp 1
7208 @cartouche
7209 @noindent
7210 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7211 A.9(10).
7212 @end cartouche
7213 @noindent
7214 All type representations are contiguous, and the @code{Buffer_Size} is
7215 the value of @code{@var{type}'Size} rounded up to the next storage unit
7216 boundary.
7217
7218 @sp 1
7219 @cartouche
7220 @noindent
7221 @strong{71}.  External files for standard input, standard output, and
7222 standard error See A.10(5).
7223 @end cartouche
7224 @noindent
7225 These files are mapped onto the files provided by the C streams
7226 libraries.  See source file @file{i-cstrea.ads} for further details.
7227
7228 @sp 1
7229 @cartouche
7230 @noindent
7231 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7232 A.10.9(36).
7233 @end cartouche
7234 @noindent
7235 If more digits are requested in the output than are represented by the
7236 precision of the value, zeroes are output in the corresponding least
7237 significant digit positions.
7238
7239 @sp 1
7240 @cartouche
7241 @noindent
7242 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7243 @code{Command_Name}.  See A.15(1).
7244 @end cartouche
7245 @noindent
7246 These are mapped onto the @code{argv} and @code{argc} parameters of the
7247 main program in the natural manner.
7248
7249 @sp 1
7250 @cartouche
7251 @noindent
7252 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7253 @end cartouche
7254 @noindent
7255 The following convention names are supported
7256
7257 @table @code
7258 @item  Ada
7259 Ada
7260 @item Assembler
7261 Assembly language
7262 @item Asm
7263 Synonym for Assembler
7264 @item Assembly
7265 Synonym for Assembler
7266 @item C
7267 C
7268 @item C_Pass_By_Copy
7269 Allowed only for record types, like C, but also notes that record
7270 is to be passed by copy rather than reference.
7271 @item COBOL
7272 COBOL
7273 @item CPP
7274 C++
7275 @item Default
7276 Treated the same as C
7277 @item External
7278 Treated the same as C
7279 @item Fortran
7280 Fortran
7281 @item Intrinsic
7282 For support of pragma @code{Import} with convention Intrinsic, see
7283 separate section on Intrinsic Subprograms.
7284 @item Stdcall
7285 Stdcall (used for Windows implementations only).  This convention correspond
7286 to the WINAPI (previously called Pascal convention) C/C++ convention under
7287 Windows.  A function with this convention cleans the stack before exit.
7288 @item DLL
7289 Synonym for Stdcall
7290 @item Win32
7291 Synonym for Stdcall
7292 @item Stubbed
7293 Stubbed is a special convention used to indicate that the body of the
7294 subprogram will be entirely ignored.  Any call to the subprogram
7295 is converted into a raise of the @code{Program_Error} exception.  If a
7296 pragma @code{Import} specifies convention @code{stubbed} then no body need
7297 be present at all.  This convention is useful during development for the
7298 inclusion of subprograms whose body has not yet been written.
7299
7300 @end table
7301 @noindent
7302 In addition, all otherwise unrecognized convention names are also
7303 treated as being synonymous with convention C@.  In all implementations
7304 except for VMS, use of such other names results in a warning.  In VMS
7305 implementations, these names are accepted silently.
7306
7307 @sp 1
7308 @cartouche
7309 @noindent
7310 @strong{75}.  The meaning of link names.  See B.1(36).
7311 @end cartouche
7312 @noindent
7313 Link names are the actual names used by the linker.
7314
7315 @sp 1
7316 @cartouche
7317 @noindent
7318 @strong{76}.  The manner of choosing link names when neither the link
7319 name nor the address of an imported or exported entity is specified.  See
7320 B.1(36).
7321 @end cartouche
7322 @noindent
7323 The default linker name is that which would be assigned by the relevant
7324 external language, interpreting the Ada name as being in all lower case
7325 letters.
7326
7327 @sp 1
7328 @cartouche
7329 @noindent
7330 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7331 @end cartouche
7332 @noindent
7333 The string passed to @code{Linker_Options} is presented uninterpreted as
7334 an argument to the link command, unless it contains Ascii.NUL characters.
7335 NUL characters if they appear act as argument separators, so for example
7336
7337 @smallexample @c ada
7338 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7339 @end smallexample
7340
7341 @noindent
7342 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7343 linker. The order of linker options is preserved for a given unit. The final
7344 list of options passed to the linker is in reverse order of the elaboration
7345 order. For example, linker options fo a body always appear before the options
7346 from the corresponding package spec.
7347
7348 @sp 1
7349 @cartouche
7350 @noindent
7351 @strong{78}.  The contents of the visible part of package
7352 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7353 @end cartouche
7354 @noindent
7355 See files with prefix @file{i-} in the distributed library.
7356
7357 @sp 1
7358 @cartouche
7359 @noindent
7360 @strong{79}.  Implementation-defined children of package
7361 @code{Interfaces}.  The contents of the visible part of package
7362 @code{Interfaces}.  See B.2(11).
7363 @end cartouche
7364 @noindent
7365 See files with prefix @file{i-} in the distributed library.
7366
7367 @sp 1
7368 @cartouche
7369 @noindent
7370 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7371 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7372 @code{COBOL_Character}; and the initialization of the variables
7373 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7374 @code{Interfaces.COBOL}.  See B.4(50).
7375 @end cartouche
7376 @noindent
7377 @table @code
7378 @item Floating
7379 Float
7380 @item Long_Floating
7381 (Floating) Long_Float
7382 @item Binary
7383 Integer
7384 @item Long_Binary
7385 Long_Long_Integer
7386 @item Decimal_Element
7387 Character
7388 @item COBOL_Character
7389 Character
7390 @end table
7391
7392 @noindent
7393 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7394
7395 @sp 1
7396 @cartouche
7397 @noindent
7398 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7399 @end cartouche
7400 @noindent
7401 See documentation in file @file{s-maccod.ads} in the distributed library.
7402
7403 @sp 1
7404 @cartouche
7405 @noindent
7406 @strong{82}.  Implementation-defined aspects of access to machine
7407 operations.  See C.1(9).
7408 @end cartouche
7409 @noindent
7410 See documentation in file @file{s-maccod.ads} in the distributed library.
7411
7412 @sp 1
7413 @cartouche
7414 @noindent
7415 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7416 @end cartouche
7417 @noindent
7418 Interrupts are mapped to signals or conditions as appropriate.  See
7419 definition of unit
7420 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7421 on the interrupts supported on a particular target.
7422
7423 @sp 1
7424 @cartouche
7425 @noindent
7426 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7427 C.4(13).
7428 @end cartouche
7429 @noindent
7430 GNAT does not permit a partition to be restarted without reloading,
7431 except under control of the debugger.
7432
7433 @sp 1
7434 @cartouche
7435 @noindent
7436 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7437 @end cartouche
7438 @noindent
7439 Pragma @code{Discard_Names} causes names of enumeration literals to
7440 be suppressed.  In the presence of this pragma, the Image attribute
7441 provides the image of the Pos of the literal, and Value accepts
7442 Pos values.
7443
7444 @sp 1
7445 @cartouche
7446 @noindent
7447 @strong{86}.  The result of the @code{Task_Identification.Image}
7448 attribute.  See C.7.1(7).
7449 @end cartouche
7450 @noindent
7451 The result of this attribute is an 8-digit hexadecimal string
7452 representing the virtual address of the task control block.
7453
7454 @sp 1
7455 @cartouche
7456 @noindent
7457 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7458 or interrupt handler.  See C.7.1(17).
7459 @end cartouche
7460 @noindent
7461 Protected entries or interrupt handlers can be executed by any
7462 convenient thread, so the value of @code{Current_Task} is undefined.
7463
7464 @sp 1
7465 @cartouche
7466 @noindent
7467 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7468 body or interrupt handler.  See C.7.1(19).
7469 @end cartouche
7470 @noindent
7471 The effect of calling @code{Current_Task} from an entry body or
7472 interrupt handler is to return the identification of the task currently
7473 executing the code.
7474
7475 @sp 1
7476 @cartouche
7477 @noindent
7478 @strong{89}.  Implementation-defined aspects of
7479 @code{Task_Attributes}.  See C.7.2(19).
7480 @end cartouche
7481 @noindent
7482 There are no implementation-defined aspects of @code{Task_Attributes}.
7483
7484 @sp 1
7485 @cartouche
7486 @noindent
7487 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7488 @end cartouche
7489 @noindent
7490 The metrics information for GNAT depends on the performance of the
7491 underlying operating system.  The sources of the run-time for tasking
7492 implementation, together with the output from @code{-gnatG} can be
7493 used to determine the exact sequence of operating systems calls made
7494 to implement various tasking constructs.  Together with appropriate
7495 information on the performance of the underlying operating system,
7496 on the exact target in use, this information can be used to determine
7497 the required metrics.
7498
7499 @sp 1
7500 @cartouche
7501 @noindent
7502 @strong{91}.  The declarations of @code{Any_Priority} and
7503 @code{Priority}.  See D.1(11).
7504 @end cartouche
7505 @noindent
7506 See declarations in file @file{system.ads}.
7507
7508 @sp 1
7509 @cartouche
7510 @noindent
7511 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7512 @end cartouche
7513 @noindent
7514 There are no implementation-defined execution resources.
7515
7516 @sp 1
7517 @cartouche
7518 @noindent
7519 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7520 access to a protected object keeps its processor busy.  See D.2.1(3).
7521 @end cartouche
7522 @noindent
7523 On a multi-processor, a task that is waiting for access to a protected
7524 object does not keep its processor busy.
7525
7526 @sp 1
7527 @cartouche
7528 @noindent
7529 @strong{94}.  The affect of implementation defined execution resources
7530 on task dispatching.  See D.2.1(9).
7531 @end cartouche
7532 @noindent
7533 @c SGI info
7534 @ignore
7535 Tasks map to IRIX threads, and the dispatching policy is as defined by
7536 the IRIX implementation of threads.
7537 @end ignore
7538 Tasks map to threads in the threads package used by GNAT@.  Where possible
7539 and appropriate, these threads correspond to native threads of the
7540 underlying operating system.
7541
7542 @sp 1
7543 @cartouche
7544 @noindent
7545 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7546 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7547 @end cartouche
7548 @noindent
7549 There are no implementation-defined policy-identifiers allowed in this
7550 pragma.
7551
7552 @sp 1
7553 @cartouche
7554 @noindent
7555 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7556 D.2.2(16).
7557 @end cartouche
7558 @noindent
7559 Execution of a task cannot be preempted by the implementation processing
7560 of delay expirations for lower priority tasks.
7561
7562 @sp 1
7563 @cartouche
7564 @noindent
7565 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7566 @end cartouche
7567 @noindent
7568 @c SGI info:
7569 @ignore
7570 Tasks map to IRIX threads, and the dispatching policy is as defied by
7571 the IRIX implementation of threads.
7572 @end ignore
7573 The policy is the same as that of the underlying threads implementation.
7574
7575 @sp 1
7576 @cartouche
7577 @noindent
7578 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7579 in a pragma @code{Locking_Policy}.  See D.3(4).
7580 @end cartouche
7581 @noindent
7582 The only implementation defined policy permitted in GNAT is
7583 @code{Inheritance_Locking}.  On targets that support this policy, locking
7584 is implemented by inheritance, i.e.@: the task owning the lock operates
7585 at a priority equal to the highest priority of any task currently
7586 requesting the lock.
7587
7588 @sp 1
7589 @cartouche
7590 @noindent
7591 @strong{99}.  Default ceiling priorities.  See D.3(10).
7592 @end cartouche
7593 @noindent
7594 The ceiling priority of protected objects of the type
7595 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7596 Reference Manual D.3(10),
7597
7598 @sp 1
7599 @cartouche
7600 @noindent
7601 @strong{100}.  The ceiling of any protected object used internally by
7602 the implementation.  See D.3(16).
7603 @end cartouche
7604 @noindent
7605 The ceiling priority of internal protected objects is
7606 @code{System.Priority'Last}.
7607
7608 @sp 1
7609 @cartouche
7610 @noindent
7611 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7612 @end cartouche
7613 @noindent
7614 There are no implementation-defined queueing policies.
7615
7616 @sp 1
7617 @cartouche
7618 @noindent
7619 @strong{102}.  On a multiprocessor, any conditions that cause the
7620 completion of an aborted construct to be delayed later than what is
7621 specified for a single processor.  See D.6(3).
7622 @end cartouche
7623 @noindent
7624 The semantics for abort on a multi-processor is the same as on a single
7625 processor, there are no further delays.
7626
7627 @sp 1
7628 @cartouche
7629 @noindent
7630 @strong{103}.  Any operations that implicitly require heap storage
7631 allocation.  See D.7(8).
7632 @end cartouche
7633 @noindent
7634 The only operation that implicitly requires heap storage allocation is
7635 task creation.
7636
7637 @sp 1
7638 @cartouche
7639 @noindent
7640 @strong{104}.  Implementation-defined aspects of pragma
7641 @code{Restrictions}.  See D.7(20).
7642 @end cartouche
7643 @noindent
7644 There are no such implementation-defined aspects.
7645
7646 @sp 1
7647 @cartouche
7648 @noindent
7649 @strong{105}.  Implementation-defined aspects of package
7650 @code{Real_Time}.  See D.8(17).
7651 @end cartouche
7652 @noindent
7653 There are no implementation defined aspects of package @code{Real_Time}.
7654
7655 @sp 1
7656 @cartouche
7657 @noindent
7658 @strong{106}.  Implementation-defined aspects of
7659 @code{delay_statements}.  See D.9(8).
7660 @end cartouche
7661 @noindent
7662 Any difference greater than one microsecond will cause the task to be
7663 delayed (see D.9(7)).
7664
7665 @sp 1
7666 @cartouche
7667 @noindent
7668 @strong{107}.  The upper bound on the duration of interrupt blocking
7669 caused by the implementation.  See D.12(5).
7670 @end cartouche
7671 @noindent
7672 The upper bound is determined by the underlying operating system.  In
7673 no cases is it more than 10 milliseconds.
7674
7675 @sp 1
7676 @cartouche
7677 @noindent
7678 @strong{108}.  The means for creating and executing distributed
7679 programs.  See E(5).
7680 @end cartouche
7681 @noindent
7682 The GLADE package provides a utility GNATDIST for creating and executing
7683 distributed programs.  See the GLADE reference manual for further details.
7684
7685 @sp 1
7686 @cartouche
7687 @noindent
7688 @strong{109}.  Any events that can result in a partition becoming
7689 inaccessible.  See E.1(7).
7690 @end cartouche
7691 @noindent
7692 See the GLADE reference manual for full details on such events.
7693
7694 @sp 1
7695 @cartouche
7696 @noindent
7697 @strong{110}.  The scheduling policies, treatment of priorities, and
7698 management of shared resources between partitions in certain cases.  See
7699 E.1(11).
7700 @end cartouche
7701 @noindent
7702 See the GLADE reference manual for full details on these aspects of
7703 multi-partition execution.
7704
7705 @sp 1
7706 @cartouche
7707 @noindent
7708 @strong{111}.  Events that cause the version of a compilation unit to
7709 change.  See E.3(5).
7710 @end cartouche
7711 @noindent
7712 Editing the source file of a compilation unit, or the source files of
7713 any units on which it is dependent in a significant way cause the version
7714 to change.  No other actions cause the version number to change.  All changes
7715 are significant except those which affect only layout, capitalization or
7716 comments.
7717
7718 @sp 1
7719 @cartouche
7720 @noindent
7721 @strong{112}.  Whether the execution of the remote subprogram is
7722 immediately aborted as a result of cancellation.  See E.4(13).
7723 @end cartouche
7724 @noindent
7725 See the GLADE reference manual for details on the effect of abort in
7726 a distributed application.
7727
7728 @sp 1
7729 @cartouche
7730 @noindent
7731 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7732 @end cartouche
7733 @noindent
7734 See the GLADE reference manual for a full description of all implementation
7735 defined aspects of the PCS@.
7736
7737 @sp 1
7738 @cartouche
7739 @noindent
7740 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7741 E.5(26).
7742 @end cartouche
7743 @noindent
7744 See the GLADE reference manual for a full description of all
7745 implementation defined interfaces.
7746
7747 @sp 1
7748 @cartouche
7749 @noindent
7750 @strong{115}.  The values of named numbers in the package
7751 @code{Decimal}.  See F.2(7).
7752 @end cartouche
7753 @noindent
7754 @table @code
7755 @item Max_Scale
7756 +18
7757 @item Min_Scale
7758 -18
7759 @item Min_Delta
7760 1.0E-18
7761 @item Max_Delta
7762 1.0E+18
7763 @item Max_Decimal_Digits
7764 18
7765 @end table
7766
7767 @sp 1
7768 @cartouche
7769 @noindent
7770 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7771 @code{Text_IO.Editing}.  See F.3.3(16).
7772 @end cartouche
7773 @noindent
7774 64
7775
7776 @sp 1
7777 @cartouche
7778 @noindent
7779 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7780 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7781 @end cartouche
7782 @noindent
7783 64
7784
7785 @sp 1
7786 @cartouche
7787 @noindent
7788 @strong{118}.  The accuracy actually achieved by the complex elementary
7789 functions and by other complex arithmetic operations.  See G.1(1).
7790 @end cartouche
7791 @noindent
7792 Standard library functions are used for the complex arithmetic
7793 operations.  Only fast math mode is currently supported.
7794
7795 @sp 1
7796 @cartouche
7797 @noindent
7798 @strong{119}.  The sign of a zero result (or a component thereof) from
7799 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7800 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7801 @end cartouche
7802 @noindent
7803 The signs of zero values are as recommended by the relevant
7804 implementation advice.
7805
7806 @sp 1
7807 @cartouche
7808 @noindent
7809 @strong{120}.  The sign of a zero result (or a component thereof) from
7810 any operator or function in
7811 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7812 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7813 @end cartouche
7814 @noindent
7815 The signs of zero values are as recommended by the relevant
7816 implementation advice.
7817
7818 @sp 1
7819 @cartouche
7820 @noindent
7821 @strong{121}.  Whether the strict mode or the relaxed mode is the
7822 default.  See G.2(2).
7823 @end cartouche
7824 @noindent
7825 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7826 provides a highly efficient implementation of strict mode.
7827
7828 @sp 1
7829 @cartouche
7830 @noindent
7831 @strong{122}.  The result interval in certain cases of fixed-to-float
7832 conversion.  See G.2.1(10).
7833 @end cartouche
7834 @noindent
7835 For cases where the result interval is implementation dependent, the
7836 accuracy is that provided by performing all operations in 64-bit IEEE
7837 floating-point format.
7838
7839 @sp 1
7840 @cartouche
7841 @noindent
7842 @strong{123}.  The result of a floating point arithmetic operation in
7843 overflow situations, when the @code{Machine_Overflows} attribute of the
7844 result type is @code{False}.  See G.2.1(13).
7845 @end cartouche
7846 @noindent
7847 Infinite and Nan values are produced as dictated by the IEEE
7848 floating-point standard.
7849
7850 @sp 1
7851 @cartouche
7852 @noindent
7853 @strong{124}.  The result interval for division (or exponentiation by a
7854 negative exponent), when the floating point hardware implements division
7855 as multiplication by a reciprocal.  See G.2.1(16).
7856 @end cartouche
7857 @noindent
7858 Not relevant, division is IEEE exact.
7859
7860 @sp 1
7861 @cartouche
7862 @noindent
7863 @strong{125}.  The definition of close result set, which determines the
7864 accuracy of certain fixed point multiplications and divisions.  See
7865 G.2.3(5).
7866 @end cartouche
7867 @noindent
7868 Operations in the close result set are performed using IEEE long format
7869 floating-point arithmetic.  The input operands are converted to
7870 floating-point, the operation is done in floating-point, and the result
7871 is converted to the target type.
7872
7873 @sp 1
7874 @cartouche
7875 @noindent
7876 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7877 point multiplication or division for which the result shall be in the
7878 perfect result set.  See G.2.3(22).
7879 @end cartouche
7880 @noindent
7881 The result is only defined to be in the perfect result set if the result
7882 can be computed by a single scaling operation involving a scale factor
7883 representable in 64-bits.
7884
7885 @sp 1
7886 @cartouche
7887 @noindent
7888 @strong{127}.  The result of a fixed point arithmetic operation in
7889 overflow situations, when the @code{Machine_Overflows} attribute of the
7890 result type is @code{False}.  See G.2.3(27).
7891 @end cartouche
7892 @noindent
7893 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7894 types.
7895
7896 @sp 1
7897 @cartouche
7898 @noindent
7899 @strong{128}.  The result of an elementary function reference in
7900 overflow situations, when the @code{Machine_Overflows} attribute of the
7901 result type is @code{False}.  See G.2.4(4).
7902 @end cartouche
7903 @noindent
7904 IEEE infinite and Nan values are produced as appropriate.
7905
7906 @sp 1
7907 @cartouche
7908 @noindent
7909 @strong{129}.  The value of the angle threshold, within which certain
7910 elementary functions, complex arithmetic operations, and complex
7911 elementary functions yield results conforming to a maximum relative
7912 error bound.  See G.2.4(10).
7913 @end cartouche
7914 @noindent
7915 Information on this subject is not yet available.
7916
7917 @sp 1
7918 @cartouche
7919 @noindent
7920 @strong{130}.  The accuracy of certain elementary functions for
7921 parameters beyond the angle threshold.  See G.2.4(10).
7922 @end cartouche
7923 @noindent
7924 Information on this subject is not yet available.
7925
7926 @sp 1
7927 @cartouche
7928 @noindent
7929 @strong{131}.  The result of a complex arithmetic operation or complex
7930 elementary function reference in overflow situations, when the
7931 @code{Machine_Overflows} attribute of the corresponding real type is
7932 @code{False}.  See G.2.6(5).
7933 @end cartouche
7934 @noindent
7935 IEEE infinite and Nan values are produced as appropriate.
7936
7937 @sp 1
7938 @cartouche
7939 @noindent
7940 @strong{132}.  The accuracy of certain complex arithmetic operations and
7941 certain complex elementary functions for parameters (or components
7942 thereof) beyond the angle threshold.  See G.2.6(8).
7943 @end cartouche
7944 @noindent
7945 Information on those subjects is not yet available.
7946
7947 @sp 1
7948 @cartouche
7949 @noindent
7950 @strong{133}.  Information regarding bounded errors and erroneous
7951 execution.  See H.2(1).
7952 @end cartouche
7953 @noindent
7954 Information on this subject is not yet available.
7955
7956 @sp 1
7957 @cartouche
7958 @noindent
7959 @strong{134}.  Implementation-defined aspects of pragma
7960 @code{Inspection_Point}.  See H.3.2(8).
7961 @end cartouche
7962 @noindent
7963 Pragma @code{Inspection_Point} ensures that the variable is live and can
7964 be examined by the debugger at the inspection point.
7965
7966 @sp 1
7967 @cartouche
7968 @noindent
7969 @strong{135}.  Implementation-defined aspects of pragma
7970 @code{Restrictions}.  See H.4(25).
7971 @end cartouche
7972 @noindent
7973 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
7974 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
7975 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
7976
7977 @sp 1
7978 @cartouche
7979 @noindent
7980 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
7981 H.4(27).
7982 @end cartouche
7983 @noindent
7984 There are no restrictions on pragma @code{Restrictions}.
7985
7986 @node Intrinsic Subprograms
7987 @chapter Intrinsic Subprograms
7988 @cindex Intrinsic Subprograms
7989
7990 @menu
7991 * Intrinsic Operators::
7992 * Enclosing_Entity::
7993 * Exception_Information::
7994 * Exception_Message::
7995 * Exception_Name::
7996 * File::
7997 * Line::
7998 * Rotate_Left::
7999 * Rotate_Right::
8000 * Shift_Left::
8001 * Shift_Right::
8002 * Shift_Right_Arithmetic::
8003 * Source_Location::
8004 @end menu
8005
8006 @noindent
8007 GNAT allows a user application program to write the declaration:
8008
8009 @smallexample @c ada
8010    pragma Import (Intrinsic, name);
8011 @end smallexample
8012
8013 @noindent
8014 providing that the name corresponds to one of the implemented intrinsic
8015 subprograms in GNAT, and that the parameter profile of the referenced
8016 subprogram meets the requirements.  This chapter describes the set of
8017 implemented intrinsic subprograms, and the requirements on parameter profiles.
8018 Note that no body is supplied; as with other uses of pragma Import, the
8019 body is supplied elsewhere (in this case by the compiler itself).  Note
8020 that any use of this feature is potentially non-portable, since the
8021 Ada standard does not require Ada compilers to implement this feature.
8022
8023 @node Intrinsic Operators
8024 @section Intrinsic Operators
8025 @cindex Intrinsic operator
8026
8027 @noindent
8028 All the predefined numeric operators in package Standard
8029 in @code{pragma Import (Intrinsic,..)}
8030 declarations.  In the binary operator case, the operands must have the same
8031 size.  The operand or operands must also be appropriate for
8032 the operator.  For example, for addition, the operands must
8033 both be floating-point or both be fixed-point, and the
8034 right operand for @code{"**"} must have a root type of
8035 @code{Standard.Integer'Base}.
8036 You can use an intrinsic operator declaration as in the following example:
8037
8038 @smallexample @c ada
8039    type Int1 is new Integer;
8040    type Int2 is new Integer;
8041
8042    function "+" (X1 : Int1; X2 : Int2) return Int1;
8043    function "+" (X1 : Int1; X2 : Int2) return Int2;
8044    pragma Import (Intrinsic, "+");
8045 @end smallexample
8046
8047 @noindent
8048 This declaration would permit ``mixed mode'' arithmetic on items
8049 of the differing types @code{Int1} and @code{Int2}.
8050 It is also possible to specify such operators for private types, if the
8051 full views are appropriate arithmetic types.
8052
8053 @node Enclosing_Entity
8054 @section Enclosing_Entity
8055 @cindex Enclosing_Entity
8056 @noindent
8057 This intrinsic subprogram is used in the implementation of the
8058 library routine @code{GNAT.Source_Info}.  The only useful use of the
8059 intrinsic import in this case is the one in this unit, so an
8060 application program should simply call the function
8061 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8062 the current subprogram, package, task, entry, or protected subprogram.
8063
8064 @node Exception_Information
8065 @section Exception_Information
8066 @cindex Exception_Information'
8067 @noindent
8068 This intrinsic subprogram is used in the implementation of the
8069 library routine @code{GNAT.Current_Exception}.  The only useful
8070 use of the intrinsic import in this case is the one in this unit,
8071 so an application program should simply call the function
8072 @code{GNAT.Current_Exception.Exception_Information} to obtain
8073 the exception information associated with the current exception.
8074
8075 @node Exception_Message
8076 @section Exception_Message
8077 @cindex Exception_Message
8078 @noindent
8079 This intrinsic subprogram is used in the implementation of the
8080 library routine @code{GNAT.Current_Exception}.  The only useful
8081 use of the intrinsic import in this case is the one in this unit,
8082 so an application program should simply call the function
8083 @code{GNAT.Current_Exception.Exception_Message} to obtain
8084 the message associated with the current exception.
8085
8086 @node Exception_Name
8087 @section Exception_Name
8088 @cindex Exception_Name
8089 @noindent
8090 This intrinsic subprogram is used in the implementation of the
8091 library routine @code{GNAT.Current_Exception}.  The only useful
8092 use of the intrinsic import in this case is the one in this unit,
8093 so an application program should simply call the function
8094 @code{GNAT.Current_Exception.Exception_Name} to obtain
8095 the name of the current exception.
8096
8097 @node File
8098 @section File
8099 @cindex File
8100 @noindent
8101 This intrinsic subprogram is used in the implementation of the
8102 library routine @code{GNAT.Source_Info}.  The only useful use of the
8103 intrinsic import in this case is the one in this unit, so an
8104 application program should simply call the function
8105 @code{GNAT.Source_Info.File} to obtain the name of the current
8106 file.
8107
8108 @node Line
8109 @section Line
8110 @cindex Line
8111 @noindent
8112 This intrinsic subprogram is used in the implementation of the
8113 library routine @code{GNAT.Source_Info}.  The only useful use of the
8114 intrinsic import in this case is the one in this unit, so an
8115 application program should simply call the function
8116 @code{GNAT.Source_Info.Line} to obtain the number of the current
8117 source line.
8118
8119 @node Rotate_Left
8120 @section Rotate_Left
8121 @cindex Rotate_Left
8122 @noindent
8123 In standard Ada 95, the @code{Rotate_Left} function is available only
8124 for the predefined modular types in package @code{Interfaces}.  However, in
8125 GNAT it is possible to define a Rotate_Left function for a user
8126 defined modular type or any signed integer type as in this example:
8127
8128 @smallexample @c ada
8129    function Shift_Left
8130      (Value  : My_Modular_Type;
8131       Amount : Natural)
8132       return   My_Modular_Type;
8133 @end smallexample
8134
8135 @noindent
8136 The requirements are that the profile be exactly as in the example
8137 above.  The only modifications allowed are in the formal parameter
8138 names, and in the type of @code{Value} and the return type, which
8139 must be the same, and must be either a signed integer type, or
8140 a modular integer type with a binary modulus, and the size must
8141 be 8.  16, 32 or 64 bits.
8142
8143 @node Rotate_Right
8144 @section Rotate_Right
8145 @cindex Rotate_Right
8146 @noindent
8147 A @code{Rotate_Right} function can be defined for any user defined
8148 binary modular integer type, or signed integer type, as described
8149 above for @code{Rotate_Left}.
8150
8151 @node Shift_Left
8152 @section Shift_Left
8153 @cindex Shift_Left
8154 @noindent
8155 A @code{Shift_Left} function can be defined for any user defined
8156 binary modular integer type, or signed integer type, as described
8157 above for @code{Rotate_Left}.
8158
8159 @node Shift_Right
8160 @section Shift_Right
8161 @cindex Shift_Right
8162 @noindent
8163 A @code{Shift_Right} function can be defined for any user defined
8164 binary modular integer type, or signed integer type, as described
8165 above for @code{Rotate_Left}.
8166
8167 @node Shift_Right_Arithmetic
8168 @section Shift_Right_Arithmetic
8169 @cindex Shift_Right_Arithmetic
8170 @noindent
8171 A @code{Shift_Right_Arithmetic} function can be defined for any user
8172 defined binary modular integer type, or signed integer type, as described
8173 above for @code{Rotate_Left}.
8174
8175 @node Source_Location
8176 @section Source_Location
8177 @cindex Source_Location
8178 @noindent
8179 This intrinsic subprogram is used in the implementation of the
8180 library routine @code{GNAT.Source_Info}.  The only useful use of the
8181 intrinsic import in this case is the one in this unit, so an
8182 application program should simply call the function
8183 @code{GNAT.Source_Info.Source_Location} to obtain the current
8184 source file location.
8185
8186 @node Representation Clauses and Pragmas
8187 @chapter Representation Clauses and Pragmas
8188 @cindex Representation Clauses
8189
8190 @menu
8191 * Alignment Clauses::
8192 * Size Clauses::
8193 * Storage_Size Clauses::
8194 * Size of Variant Record Objects::
8195 * Biased Representation ::
8196 * Value_Size and Object_Size Clauses::
8197 * Component_Size Clauses::
8198 * Bit_Order Clauses::
8199 * Effect of Bit_Order on Byte Ordering::
8200 * Pragma Pack for Arrays::
8201 * Pragma Pack for Records::
8202 * Record Representation Clauses::
8203 * Enumeration Clauses::
8204 * Address Clauses::
8205 * Effect of Convention on Representation::
8206 * Determining the Representations chosen by GNAT::
8207 @end menu
8208
8209 @noindent
8210 @cindex Representation Clause
8211 @cindex Representation Pragma
8212 @cindex Pragma, representation
8213 This section describes the representation clauses accepted by GNAT, and
8214 their effect on the representation of corresponding data objects.
8215
8216 GNAT fully implements Annex C (Systems Programming).  This means that all
8217 the implementation advice sections in chapter 13 are fully implemented.
8218 However, these sections only require a minimal level of support for
8219 representation clauses.  GNAT provides much more extensive capabilities,
8220 and this section describes the additional capabilities provided.
8221
8222 @node Alignment Clauses
8223 @section Alignment Clauses
8224 @cindex Alignment Clause
8225
8226 @noindent
8227 GNAT requires that all alignment clauses specify a power of 2, and all
8228 default alignments are always a power of 2.  The default alignment
8229 values are as follows:
8230
8231 @itemize @bullet
8232 @item @emph{Primitive Types}.
8233 For primitive types, the alignment is the minimum of the actual size of
8234 objects of the type divided by @code{Storage_Unit},
8235 and the maximum alignment supported by the target.
8236 (This maximum alignment is given by the GNAT-specific attribute
8237 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8238 @cindex @code{Maximum_Alignment} attribute
8239 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8240 default alignment will be 8 on any target that supports alignments
8241 this large, but on some targets, the maximum alignment may be smaller
8242 than 8, in which case objects of type @code{Long_Float} will be maximally
8243 aligned.
8244
8245 @item @emph{Arrays}.
8246 For arrays, the alignment is equal to the alignment of the component type
8247 for the normal case where no packing or component size is given.  If the
8248 array is packed, and the packing is effective (see separate section on
8249 packed arrays), then the alignment will be one for long packed arrays,
8250 or arrays whose length is not known at compile time.  For short packed
8251 arrays, which are handled internally as modular types, the alignment
8252 will be as described for primitive types, e.g.@: a packed array of length
8253 31 bits will have an object size of four bytes, and an alignment of 4.
8254
8255 @item @emph{Records}.
8256 For the normal non-packed case, the alignment of a record is equal to
8257 the maximum alignment of any of its components.  For tagged records, this
8258 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8259 used and all fields are packable (see separate section on pragma @code{Pack}),
8260 then the resulting alignment is 1.
8261
8262 A special case is when:
8263 @itemize @bullet
8264 @item
8265 the size of the record is given explicitly, or a
8266 full record representation clause is given, and
8267 @item
8268 the size of the record is 2, 4, or 8 bytes.
8269 @end itemize
8270 @noindent
8271 In this case, an alignment is chosen to match the
8272 size of the record. For example, if we have:
8273
8274 @smallexample @c ada
8275    type Small is record
8276       A, B : Character;
8277    end record;
8278    for Small'Size use 16;
8279 @end smallexample
8280
8281 @noindent
8282 then the default alignment of the record type @code{Small} is 2, not 1. This
8283 leads to more efficient code when the record is treated as a unit, and also
8284 allows the type to specified as @code{Atomic} on architectures requiring
8285 strict alignment.
8286
8287 @end itemize
8288
8289 @noindent
8290 An alignment clause may
8291 always specify a larger alignment than the default value, up to some
8292 maximum value dependent on the target (obtainable by using the
8293 attribute reference @code{Standard'Maximum_Alignment}).
8294 The only case where
8295 it is permissible to specify a smaller alignment than the default value
8296 is for a record with a record representation clause.
8297 In this case, packable fields for which a component clause is
8298 given still result in a default alignment corresponding to the original
8299 type, but this may be overridden, since these components in fact only
8300 require an alignment of one byte.  For example, given
8301
8302 @smallexample @c ada
8303   type V is record
8304      A : Integer;
8305   end record;
8306
8307   for V use record
8308      A at 0  range 0 .. 31;
8309   end record;
8310
8311   for V'alignment use 1;
8312 @end smallexample
8313
8314 @noindent
8315 @cindex Alignment, default
8316 The default alignment for the type @code{V} is 4, as a result of the
8317 Integer field in the record, but since this field is placed with a
8318 component clause, it is permissible, as shown, to override the default
8319 alignment of the record with a smaller value.
8320
8321 @node Size Clauses
8322 @section Size Clauses
8323 @cindex Size Clause
8324
8325 @noindent
8326 The default size for a type @code{T} is obtainable through the
8327 language-defined attribute @code{T'Size} and also through the
8328 equivalent GNAT-defined attribute @code{T'Value_Size}.
8329 For objects of type @code{T}, GNAT will generally increase the type size
8330 so that the object size (obtainable through the GNAT-defined attribute
8331 @code{T'Object_Size})
8332 is a multiple of @code{T'Alignment * Storage_Unit}.
8333 For example
8334
8335 @smallexample @c ada
8336    type Smallint is range 1 .. 6;
8337
8338    type Rec is record
8339       Y1 : integer;
8340       Y2 : boolean;
8341    end record;
8342 @end smallexample
8343
8344 @noindent
8345 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8346 as specified by the RM rules,
8347 but objects of this type will have a size of 8
8348 (@code{Smallint'Object_Size} = 8),
8349 since objects by default occupy an integral number
8350 of storage units.  On some targets, notably older
8351 versions of the Digital Alpha, the size of stand
8352 alone objects of this type may be 32, reflecting
8353 the inability of the hardware to do byte load/stores.
8354
8355 Similarly, the size of type @code{Rec} is 40 bits
8356 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8357 the alignment is 4, so objects of this type will have
8358 their size increased to 64 bits so that it is a multiple
8359 of the alignment (in bits).  The reason for this decision, which is
8360 in accordance with the specific Implementation Advice in RM 13.3(43):
8361
8362 @quotation
8363 A @code{Size} clause should be supported for an object if the specified
8364 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8365 to a size in storage elements that is a multiple of the object's
8366 @code{Alignment} (if the @code{Alignment} is nonzero).
8367 @end quotation
8368
8369 @noindent
8370 An explicit size clause may be used to override the default size by
8371 increasing it.  For example, if we have:
8372
8373 @smallexample @c ada
8374    type My_Boolean is new Boolean;
8375    for My_Boolean'Size use 32;
8376 @end smallexample
8377
8378 @noindent
8379 then values of this type will always be 32 bits long.  In the case of
8380 discrete types, the size can be increased up to 64 bits, with the effect
8381 that the entire specified field is used to hold the value, sign- or
8382 zero-extended as appropriate.  If more than 64 bits is specified, then
8383 padding space is allocated after the value, and a warning is issued that
8384 there are unused bits.
8385
8386 Similarly the size of records and arrays may be increased, and the effect
8387 is to add padding bits after the value.  This also causes a warning message
8388 to be generated.
8389
8390 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8391 Size in bits, this corresponds to an object of size 256 megabytes (minus
8392 one).  This limitation is true on all targets.  The reason for this
8393 limitation is that it improves the quality of the code in many cases
8394 if it is known that a Size value can be accommodated in an object of
8395 type Integer.
8396
8397 @node Storage_Size Clauses
8398 @section Storage_Size Clauses
8399 @cindex Storage_Size Clause
8400
8401 @noindent
8402 For tasks, the @code{Storage_Size} clause specifies the amount of space
8403 to be allocated for the task stack.  This cannot be extended, and if the
8404 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8405 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8406 or a @code{Storage_Size} pragma in the task definition to set the
8407 appropriate required size.  A useful technique is to include in every
8408 task definition a pragma of the form:
8409
8410 @smallexample @c ada
8411    pragma Storage_Size (Default_Stack_Size);
8412 @end smallexample
8413
8414 @noindent
8415 Then @code{Default_Stack_Size} can be defined in a global package, and
8416 modified as required.  Any tasks requiring stack sizes different from the
8417 default can have an appropriate alternative reference in the pragma.
8418
8419 For access types, the @code{Storage_Size} clause specifies the maximum
8420 space available for allocation of objects of the type.  If this space is
8421 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8422 In the case where the access type is declared local to a subprogram, the
8423 use of a @code{Storage_Size} clause triggers automatic use of a special
8424 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8425 space for the pool is automatically reclaimed on exit from the scope in
8426 which the type is declared.
8427
8428 A special case recognized by the compiler is the specification of a
8429 @code{Storage_Size} of zero for an access type.  This means that no
8430 items can be allocated from the pool, and this is recognized at compile
8431 time, and all the overhead normally associated with maintaining a fixed
8432 size storage pool is eliminated.  Consider the following example:
8433
8434 @smallexample @c ada
8435    procedure p is
8436       type R is array (Natural) of Character;
8437       type P is access all R;
8438       for P'Storage_Size use 0;
8439       --  Above access type intended only for interfacing purposes
8440
8441       y : P;
8442
8443       procedure g (m : P);
8444       pragma Import (C, g);
8445
8446       --  @dots{}
8447
8448    begin
8449       --  @dots{}
8450       y := new R;
8451    end;
8452 @end smallexample
8453
8454 @noindent
8455 As indicated in this example, these dummy storage pools are often useful in
8456 connection with interfacing where no object will ever be allocated.  If you
8457 compile the above example, you get the warning:
8458
8459 @smallexample
8460    p.adb:16:09: warning: allocation from empty storage pool
8461    p.adb:16:09: warning: Storage_Error will be raised at run time
8462 @end smallexample
8463
8464 @noindent
8465 Of course in practice, there will not be any explicit allocators in the
8466 case of such an access declaration.
8467
8468 @node Size of Variant Record Objects
8469 @section Size of Variant Record Objects
8470 @cindex Size, variant record objects
8471 @cindex Variant record objects, size
8472
8473 @noindent
8474 In the case of variant record objects, there is a question whether Size gives
8475 information about a particular variant, or the maximum size required
8476 for any variant.  Consider the following program
8477
8478 @smallexample @c ada
8479 with Text_IO; use Text_IO;
8480 procedure q is
8481    type R1 (A : Boolean := False) is record
8482      case A is
8483        when True  => X : Character;
8484        when False => null;
8485      end case;
8486    end record;
8487
8488    V1 : R1 (False);
8489    V2 : R1;
8490
8491 begin
8492    Put_Line (Integer'Image (V1'Size));
8493    Put_Line (Integer'Image (V2'Size));
8494 end q;
8495 @end smallexample
8496
8497 @noindent
8498 Here we are dealing with a variant record, where the True variant
8499 requires 16 bits, and the False variant requires 8 bits.
8500 In the above example, both V1 and V2 contain the False variant,
8501 which is only 8 bits long.  However, the result of running the
8502 program is:
8503
8504 @smallexample
8505 8
8506 16
8507 @end smallexample
8508
8509 @noindent
8510 The reason for the difference here is that the discriminant value of
8511 V1 is fixed, and will always be False.  It is not possible to assign
8512 a True variant value to V1, therefore 8 bits is sufficient.  On the
8513 other hand, in the case of V2, the initial discriminant value is
8514 False (from the default), but it is possible to assign a True
8515 variant value to V2, therefore 16 bits must be allocated for V2
8516 in the general case, even fewer bits may be needed at any particular
8517 point during the program execution.
8518
8519 As can be seen from the output of this program, the @code{'Size}
8520 attribute applied to such an object in GNAT gives the actual allocated
8521 size of the variable, which is the largest size of any of the variants.
8522 The Ada Reference Manual is not completely clear on what choice should
8523 be made here, but the GNAT behavior seems most consistent with the
8524 language in the RM@.
8525
8526 In some cases, it may be desirable to obtain the size of the current
8527 variant, rather than the size of the largest variant.  This can be
8528 achieved in GNAT by making use of the fact that in the case of a
8529 subprogram parameter, GNAT does indeed return the size of the current
8530 variant (because a subprogram has no way of knowing how much space
8531 is actually allocated for the actual).
8532
8533 Consider the following modified version of the above program:
8534
8535 @smallexample @c ada
8536 with Text_IO; use Text_IO;
8537 procedure q is
8538    type R1 (A : Boolean := False) is record
8539      case A is
8540        when True  => X : Character;
8541        when False => null;
8542      end case;
8543    end record;
8544
8545    V2 : R1;
8546
8547    function Size (V : R1) return Integer is
8548    begin
8549       return V'Size;
8550    end Size;
8551
8552 begin
8553    Put_Line (Integer'Image (V2'Size));
8554    Put_Line (Integer'IMage (Size (V2)));
8555    V2 := (True, 'x');
8556    Put_Line (Integer'Image (V2'Size));
8557    Put_Line (Integer'IMage (Size (V2)));
8558 end q;
8559 @end smallexample
8560
8561 @noindent
8562 The output from this program is
8563
8564 @smallexample
8565 16
8566 8
8567 16
8568 16
8569 @end smallexample
8570
8571 @noindent
8572 Here we see that while the @code{'Size} attribute always returns
8573 the maximum size, regardless of the current variant value, the
8574 @code{Size} function does indeed return the size of the current
8575 variant value.
8576
8577 @node Biased Representation
8578 @section Biased Representation
8579 @cindex Size for biased representation
8580 @cindex Biased representation
8581
8582 @noindent
8583 In the case of scalars with a range starting at other than zero, it is
8584 possible in some cases to specify a size smaller than the default minimum
8585 value, and in such cases, GNAT uses an unsigned biased representation,
8586 in which zero is used to represent the lower bound, and successive values
8587 represent successive values of the type.
8588
8589 For example, suppose we have the declaration:
8590
8591 @smallexample @c ada
8592    type Small is range -7 .. -4;
8593    for Small'Size use 2;
8594 @end smallexample
8595
8596 @noindent
8597 Although the default size of type @code{Small} is 4, the @code{Size}
8598 clause is accepted by GNAT and results in the following representation
8599 scheme:
8600
8601 @smallexample
8602   -7 is represented as 2#00#
8603   -6 is represented as 2#01#
8604   -5 is represented as 2#10#
8605   -4 is represented as 2#11#
8606 @end smallexample
8607
8608 @noindent
8609 Biased representation is only used if the specified @code{Size} clause
8610 cannot be accepted in any other manner.  These reduced sizes that force
8611 biased representation can be used for all discrete types except for
8612 enumeration types for which a representation clause is given.
8613
8614 @node Value_Size and Object_Size Clauses
8615 @section Value_Size and Object_Size Clauses
8616 @findex Value_Size
8617 @findex Object_Size
8618 @cindex Size, of objects
8619
8620 @noindent
8621 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8622 required to hold values of type @code{T}.  Although this interpretation was
8623 allowed in Ada 83, it was not required, and this requirement in practice
8624 can cause some significant difficulties.  For example, in most Ada 83
8625 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8626 @code{Natural'Size} is
8627 typically 31.  This means that code may change in behavior when moving
8628 from Ada 83 to Ada 95.  For example, consider:
8629
8630 @smallexample @c ada
8631    type Rec is record;
8632       A : Natural;
8633       B : Natural;
8634    end record;
8635
8636    for Rec use record
8637       at 0  range 0 .. Natural'Size - 1;
8638       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8639    end record;
8640 @end smallexample
8641
8642 @noindent
8643 In the above code, since the typical size of @code{Natural} objects
8644 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8645 unexpected inefficient packing in Ada 95, and in general there are
8646 cases where the fact that the object size can exceed the
8647 size of the type causes surprises.
8648
8649 To help get around this problem GNAT provides two implementation
8650 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8651 applied to a type, these attributes yield the size of the type
8652 (corresponding to the RM defined size attribute), and the size of
8653 objects of the type respectively.
8654
8655 The @code{Object_Size} is used for determining the default size of
8656 objects and components.  This size value can be referred to using the
8657 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8658 the basis of the determination of the size.  The backend is free to
8659 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8660 character might be stored in 32 bits on a machine with no efficient
8661 byte access instructions such as the Alpha.
8662
8663 The default rules for the value of @code{Object_Size} for
8664 discrete types are as follows:
8665
8666 @itemize @bullet
8667 @item
8668 The @code{Object_Size} for base subtypes reflect the natural hardware
8669 size in bits (run the compiler with @option{-gnatS} to find those values
8670 for numeric types). Enumeration types and fixed-point base subtypes have
8671 8, 16, 32 or 64 bits for this size, depending on the range of values
8672 to be stored.
8673
8674 @item
8675 The @code{Object_Size} of a subtype is the same as the
8676 @code{Object_Size} of
8677 the type from which it is obtained.
8678
8679 @item
8680 The @code{Object_Size} of a derived base type is copied from the parent
8681 base type, and the @code{Object_Size} of a derived first subtype is copied
8682 from the parent first subtype.
8683 @end itemize
8684
8685 @noindent
8686 The @code{Value_Size} attribute
8687 is the (minimum) number of bits required to store a value
8688 of the type.
8689 This value is used to determine how tightly to pack
8690 records or arrays with components of this type, and also affects
8691 the semantics of unchecked conversion (unchecked conversions where
8692 the @code{Value_Size} values differ generate a warning, and are potentially
8693 target dependent).
8694
8695 The default rules for the value of @code{Value_Size} are as follows:
8696
8697 @itemize @bullet
8698 @item
8699 The @code{Value_Size} for a base subtype is the minimum number of bits
8700 required to store all values of the type (including the sign bit
8701 only if negative values are possible).
8702
8703 @item
8704 If a subtype statically matches the first subtype of a given type, then it has
8705 by default the same @code{Value_Size} as the first subtype.  This is a
8706 consequence of RM 13.1(14) (``if two subtypes statically match,
8707 then their subtype-specific aspects are the same''.)
8708
8709 @item
8710 All other subtypes have a @code{Value_Size} corresponding to the minimum
8711 number of bits required to store all values of the subtype.  For
8712 dynamic bounds, it is assumed that the value can range down or up
8713 to the corresponding bound of the ancestor
8714 @end itemize
8715
8716 @noindent
8717 The RM defined attribute @code{Size} corresponds to the
8718 @code{Value_Size} attribute.
8719
8720 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8721 the @code{Value_Size} of
8722 the first-named subtype to the given value, and the
8723 @code{Object_Size} of this first-named subtype to the given value padded up
8724 to an appropriate boundary.  It is a consequence of the default rules
8725 above that this @code{Object_Size} will apply to all further subtypes.  On the
8726 other hand, @code{Value_Size} is affected only for the first subtype, any
8727 dynamic subtypes obtained from it directly, and any statically matching
8728 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8729
8730 @code{Value_Size} and
8731 @code{Object_Size} may be explicitly set for any subtype using
8732 an attribute definition clause.  Note that the use of these attributes
8733 can cause the RM 13.1(14) rule to be violated.  If two access types
8734 reference aliased objects whose subtypes have differing @code{Object_Size}
8735 values as a result of explicit attribute definition clauses, then it
8736 is erroneous to convert from one access subtype to the other.
8737
8738 At the implementation level, Esize stores the Object_Size and the
8739 RM_Size field stores the @code{Value_Size} (and hence the value of the
8740 @code{Size} attribute,
8741 which, as noted above, is equivalent to @code{Value_Size}).
8742
8743 To get a feel for the difference, consider the following examples (note
8744 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8745
8746 @smallexample
8747                                        Object_Size     Value_Size
8748
8749 type x1 is range 0 .. 5;                    8               3
8750
8751 type x2 is range 0 .. 5;
8752 for x2'size use 12;                        16              12
8753
8754 subtype x3 is x2 range 0 .. 3;             16               2
8755
8756 subtype x4 is x2'base range 0 .. 10;        8               4
8757
8758 subtype x5 is x2 range 0 .. dynamic;       16               3*
8759
8760 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8761
8762 @end smallexample
8763
8764 @noindent
8765 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8766 but it seems in the spirit of the RM rules to allocate the minimum number
8767 of bits (here 3, given the range for @code{x2})
8768 known to be large enough to hold the given range of values.
8769
8770 So far, so good, but GNAT has to obey the RM rules, so the question is
8771 under what conditions must the RM @code{Size} be used.
8772 The following is a list
8773 of the occasions on which the RM @code{Size} must be used:
8774
8775 @itemize @bullet
8776 @item
8777 Component size for packed arrays or records
8778
8779 @item
8780 Value of the attribute @code{Size} for a type
8781
8782 @item
8783 Warning about sizes not matching for unchecked conversion
8784 @end itemize
8785
8786 @noindent
8787 For record types, the @code{Object_Size} is always a multiple of the
8788 alignment of the type (this is true for all types). In some cases the
8789 @code{Value_Size} can be smaller. Consider:
8790
8791 @smallexample
8792    type R is record
8793      X : Integer;
8794      Y : Character;
8795    end record;
8796 @end smallexample
8797
8798 @noindent
8799 On a typical 32-bit architecture, the X component will be four bytes, and
8800 require four-byte alignment, and the Y component will be one byte. In this
8801 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8802 required to store a value of this type, and for example, it is permissible
8803 to have a component of type R in an outer record whose component size is
8804 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8805 since it must be rounded up so that this value is a multiple of the
8806 alignment (4 bytes = 32 bits).
8807
8808 @noindent
8809 For all other types, the @code{Object_Size}
8810 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8811 Only @code{Size} may be specified for such types.
8812
8813 @node Component_Size Clauses
8814 @section Component_Size Clauses
8815 @cindex Component_Size Clause
8816
8817 @noindent
8818 Normally, the value specified in a component clause must be consistent
8819 with the subtype of the array component with regard to size and alignment.
8820 In other words, the value specified must be at least equal to the size
8821 of this subtype, and must be a multiple of the alignment value.
8822
8823 In addition, component size clauses are allowed which cause the array
8824 to be packed, by specifying a smaller value.  The cases in which this
8825 is allowed are for component size values in the range 1 through 63.  The value
8826 specified must not be smaller than the Size of the subtype.  GNAT will
8827 accurately honor all packing requests in this range.  For example, if
8828 we have:
8829
8830 @smallexample @c ada
8831 type r is array (1 .. 8) of Natural;
8832 for r'Component_Size use 31;
8833 @end smallexample
8834
8835 @noindent
8836 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8837 Of course access to the components of such an array is considerably
8838 less efficient than if the natural component size of 32 is used.
8839
8840 @node Bit_Order Clauses
8841 @section Bit_Order Clauses
8842 @cindex Bit_Order Clause
8843 @cindex bit ordering
8844 @cindex ordering, of bits
8845
8846 @noindent
8847 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8848 attribute.  The specification may either correspond to the default bit
8849 order for the target, in which case the specification has no effect and
8850 places no additional restrictions, or it may be for the non-standard
8851 setting (that is the opposite of the default).
8852
8853 In the case where the non-standard value is specified, the effect is
8854 to renumber bits within each byte, but the ordering of bytes is not
8855 affected.  There are certain
8856 restrictions placed on component clauses as follows:
8857
8858 @itemize @bullet
8859
8860 @item Components fitting within a single storage unit.
8861 @noindent
8862 These are unrestricted, and the effect is merely to renumber bits.  For
8863 example if we are on a little-endian machine with @code{Low_Order_First}
8864 being the default, then the following two declarations have exactly
8865 the same effect:
8866
8867 @smallexample @c ada
8868    type R1 is record
8869       A : Boolean;
8870       B : Integer range 1 .. 120;
8871    end record;
8872
8873    for R1 use record
8874       A at 0 range 0 .. 0;
8875       B at 0 range 1 .. 7;
8876    end record;
8877
8878    type R2 is record
8879       A : Boolean;
8880       B : Integer range 1 .. 120;
8881    end record;
8882
8883    for R2'Bit_Order use High_Order_First;
8884
8885    for R2 use record
8886       A at 0 range 7 .. 7;
8887       B at 0 range 0 .. 6;
8888    end record;
8889 @end smallexample
8890
8891 @noindent
8892 The useful application here is to write the second declaration with the
8893 @code{Bit_Order} attribute definition clause, and know that it will be treated
8894 the same, regardless of whether the target is little-endian or big-endian.
8895
8896 @item Components occupying an integral number of bytes.
8897 @noindent
8898 These are components that exactly fit in two or more bytes.  Such component
8899 declarations are allowed, but have no effect, since it is important to realize
8900 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8901 In particular, the following attempt at getting an endian-independent integer
8902 does not work:
8903
8904 @smallexample @c ada
8905    type R2 is record
8906       A : Integer;
8907    end record;
8908
8909    for R2'Bit_Order use High_Order_First;
8910
8911    for R2 use record
8912       A at 0 range 0 .. 31;
8913    end record;
8914 @end smallexample
8915
8916 @noindent
8917 This declaration will result in a little-endian integer on a
8918 little-endian machine, and a big-endian integer on a big-endian machine.
8919 If byte flipping is required for interoperability between big- and
8920 little-endian machines, this must be explicitly programmed.  This capability
8921 is not provided by @code{Bit_Order}.
8922
8923 @item Components that are positioned across byte boundaries
8924 @noindent
8925 but do not occupy an integral number of bytes.  Given that bytes are not
8926 reordered, such fields would occupy a non-contiguous sequence of bits
8927 in memory, requiring non-trivial code to reassemble.  They are for this
8928 reason not permitted, and any component clause specifying such a layout
8929 will be flagged as illegal by GNAT@.
8930
8931 @end itemize
8932
8933 @noindent
8934 Since the misconception that Bit_Order automatically deals with all
8935 endian-related incompatibilities is a common one, the specification of
8936 a component field that is an integral number of bytes will always
8937 generate a warning.  This warning may be suppressed using
8938 @code{pragma Suppress} if desired.  The following section contains additional
8939 details regarding the issue of byte ordering.
8940
8941 @node Effect of Bit_Order on Byte Ordering
8942 @section Effect of Bit_Order on Byte Ordering
8943 @cindex byte ordering
8944 @cindex ordering, of bytes
8945
8946 @noindent
8947 In this section we will review the effect of the @code{Bit_Order} attribute
8948 definition clause on byte ordering.  Briefly, it has no effect at all, but
8949 a detailed example will be helpful.  Before giving this
8950 example, let us review the precise
8951 definition of the effect of defining @code{Bit_Order}.  The effect of a
8952 non-standard bit order is described in section 15.5.3 of the Ada
8953 Reference Manual:
8954
8955 @quotation
8956 2   A bit ordering is a method of interpreting the meaning of
8957 the storage place attributes.
8958 @end quotation
8959
8960 @noindent
8961 To understand the precise definition of storage place attributes in
8962 this context, we visit section 13.5.1 of the manual:
8963
8964 @quotation
8965 13   A record_representation_clause (without the mod_clause)
8966 specifies the layout.  The storage place attributes (see 13.5.2)
8967 are taken from the values of the position, first_bit, and last_bit
8968 expressions after normalizing those values so that first_bit is
8969 less than Storage_Unit.
8970 @end quotation
8971
8972 @noindent
8973 The critical point here is that storage places are taken from
8974 the values after normalization, not before.  So the @code{Bit_Order}
8975 interpretation applies to normalized values.  The interpretation
8976 is described in the later part of the 15.5.3 paragraph:
8977
8978 @quotation
8979 2   A bit ordering is a method of interpreting the meaning of
8980 the storage place attributes.  High_Order_First (known in the
8981 vernacular as ``big endian'') means that the first bit of a
8982 storage element (bit 0) is the most significant bit (interpreting
8983 the sequence of bits that represent a component as an unsigned
8984 integer value).  Low_Order_First (known in the vernacular as
8985 ``little endian'') means the opposite: the first bit is the
8986 least significant.
8987 @end quotation
8988
8989 @noindent
8990 Note that the numbering is with respect to the bits of a storage
8991 unit.  In other words, the specification affects only the numbering
8992 of bits within a single storage unit.
8993
8994 We can make the effect clearer by giving an example.
8995
8996 Suppose that we have an external device which presents two bytes, the first
8997 byte presented, which is the first (low addressed byte) of the two byte
8998 record is called Master, and the second byte is called Slave.
8999
9000 The left most (most significant bit is called Control for each byte, and
9001 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9002 (least significant) bit.
9003
9004 On a big-endian machine, we can write the following representation clause
9005
9006 @smallexample @c ada
9007    type Data is record
9008       Master_Control : Bit;
9009       Master_V1      : Bit;
9010       Master_V2      : Bit;
9011       Master_V3      : Bit;
9012       Master_V4      : Bit;
9013       Master_V5      : Bit;
9014       Master_V6      : Bit;
9015       Master_V7      : Bit;
9016       Slave_Control  : Bit;
9017       Slave_V1       : Bit;
9018       Slave_V2       : Bit;
9019       Slave_V3       : Bit;
9020       Slave_V4       : Bit;
9021       Slave_V5       : Bit;
9022       Slave_V6       : Bit;
9023       Slave_V7       : Bit;
9024    end record;
9025
9026    for Data use record
9027       Master_Control at 0 range 0 .. 0;
9028       Master_V1      at 0 range 1 .. 1;
9029       Master_V2      at 0 range 2 .. 2;
9030       Master_V3      at 0 range 3 .. 3;
9031       Master_V4      at 0 range 4 .. 4;
9032       Master_V5      at 0 range 5 .. 5;
9033       Master_V6      at 0 range 6 .. 6;
9034       Master_V7      at 0 range 7 .. 7;
9035       Slave_Control  at 1 range 0 .. 0;
9036       Slave_V1       at 1 range 1 .. 1;
9037       Slave_V2       at 1 range 2 .. 2;
9038       Slave_V3       at 1 range 3 .. 3;
9039       Slave_V4       at 1 range 4 .. 4;
9040       Slave_V5       at 1 range 5 .. 5;
9041       Slave_V6       at 1 range 6 .. 6;
9042       Slave_V7       at 1 range 7 .. 7;
9043    end record;
9044 @end smallexample
9045
9046 @noindent
9047 Now if we move this to a little endian machine, then the bit ordering within
9048 the byte is backwards, so we have to rewrite the record rep clause as:
9049
9050 @smallexample @c ada
9051    for Data use record
9052       Master_Control at 0 range 7 .. 7;
9053       Master_V1      at 0 range 6 .. 6;
9054       Master_V2      at 0 range 5 .. 5;
9055       Master_V3      at 0 range 4 .. 4;
9056       Master_V4      at 0 range 3 .. 3;
9057       Master_V5      at 0 range 2 .. 2;
9058       Master_V6      at 0 range 1 .. 1;
9059       Master_V7      at 0 range 0 .. 0;
9060       Slave_Control  at 1 range 7 .. 7;
9061       Slave_V1       at 1 range 6 .. 6;
9062       Slave_V2       at 1 range 5 .. 5;
9063       Slave_V3       at 1 range 4 .. 4;
9064       Slave_V4       at 1 range 3 .. 3;
9065       Slave_V5       at 1 range 2 .. 2;
9066       Slave_V6       at 1 range 1 .. 1;
9067       Slave_V7       at 1 range 0 .. 0;
9068    end record;
9069 @end smallexample
9070
9071 @noindent
9072 It is a nuisance to have to rewrite the clause, especially if
9073 the code has to be maintained on both machines.  However,
9074 this is a case that we can handle with the
9075 @code{Bit_Order} attribute if it is implemented.
9076 Note that the implementation is not required on byte addressed
9077 machines, but it is indeed implemented in GNAT.
9078 This means that we can simply use the
9079 first record clause, together with the declaration
9080
9081 @smallexample @c ada
9082    for Data'Bit_Order use High_Order_First;
9083 @end smallexample
9084
9085 @noindent
9086 and the effect is what is desired, namely the layout is exactly the same,
9087 independent of whether the code is compiled on a big-endian or little-endian
9088 machine.
9089
9090 The important point to understand is that byte ordering is not affected.
9091 A @code{Bit_Order} attribute definition never affects which byte a field
9092 ends up in, only where it ends up in that byte.
9093 To make this clear, let us rewrite the record rep clause of the previous
9094 example as:
9095
9096 @smallexample @c ada
9097    for Data'Bit_Order use High_Order_First;
9098    for Data use record
9099       Master_Control at 0 range  0 .. 0;
9100       Master_V1      at 0 range  1 .. 1;
9101       Master_V2      at 0 range  2 .. 2;
9102       Master_V3      at 0 range  3 .. 3;
9103       Master_V4      at 0 range  4 .. 4;
9104       Master_V5      at 0 range  5 .. 5;
9105       Master_V6      at 0 range  6 .. 6;
9106       Master_V7      at 0 range  7 .. 7;
9107       Slave_Control  at 0 range  8 .. 8;
9108       Slave_V1       at 0 range  9 .. 9;
9109       Slave_V2       at 0 range 10 .. 10;
9110       Slave_V3       at 0 range 11 .. 11;
9111       Slave_V4       at 0 range 12 .. 12;
9112       Slave_V5       at 0 range 13 .. 13;
9113       Slave_V6       at 0 range 14 .. 14;
9114       Slave_V7       at 0 range 15 .. 15;
9115    end record;
9116 @end smallexample
9117
9118 @noindent
9119 This is exactly equivalent to saying (a repeat of the first example):
9120
9121 @smallexample @c ada
9122    for Data'Bit_Order use High_Order_First;
9123    for Data use record
9124       Master_Control at 0 range 0 .. 0;
9125       Master_V1      at 0 range 1 .. 1;
9126       Master_V2      at 0 range 2 .. 2;
9127       Master_V3      at 0 range 3 .. 3;
9128       Master_V4      at 0 range 4 .. 4;
9129       Master_V5      at 0 range 5 .. 5;
9130       Master_V6      at 0 range 6 .. 6;
9131       Master_V7      at 0 range 7 .. 7;
9132       Slave_Control  at 1 range 0 .. 0;
9133       Slave_V1       at 1 range 1 .. 1;
9134       Slave_V2       at 1 range 2 .. 2;
9135       Slave_V3       at 1 range 3 .. 3;
9136       Slave_V4       at 1 range 4 .. 4;
9137       Slave_V5       at 1 range 5 .. 5;
9138       Slave_V6       at 1 range 6 .. 6;
9139       Slave_V7       at 1 range 7 .. 7;
9140    end record;
9141 @end smallexample
9142
9143 @noindent
9144 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9145 field.  The storage place attributes are obtained by normalizing the
9146 values given so that the @code{First_Bit} value is less than 8.  After
9147 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9148 we specified in the other case.
9149
9150 Now one might expect that the @code{Bit_Order} attribute might affect
9151 bit numbering within the entire record component (two bytes in this
9152 case, thus affecting which byte fields end up in), but that is not
9153 the way this feature is defined, it only affects numbering of bits,
9154 not which byte they end up in.
9155
9156 Consequently it never makes sense to specify a starting bit number
9157 greater than 7 (for a byte addressable field) if an attribute
9158 definition for @code{Bit_Order} has been given, and indeed it
9159 may be actively confusing to specify such a value, so the compiler
9160 generates a warning for such usage.
9161
9162 If you do need to control byte ordering then appropriate conditional
9163 values must be used.  If in our example, the slave byte came first on
9164 some machines we might write:
9165
9166 @smallexample @c ada
9167    Master_Byte_First constant Boolean := @dots{};
9168
9169    Master_Byte : constant Natural :=
9170                    1 - Boolean'Pos (Master_Byte_First);
9171    Slave_Byte  : constant Natural :=
9172                    Boolean'Pos (Master_Byte_First);
9173
9174    for Data'Bit_Order use High_Order_First;
9175    for Data use record
9176       Master_Control at Master_Byte range 0 .. 0;
9177       Master_V1      at Master_Byte range 1 .. 1;
9178       Master_V2      at Master_Byte range 2 .. 2;
9179       Master_V3      at Master_Byte range 3 .. 3;
9180       Master_V4      at Master_Byte range 4 .. 4;
9181       Master_V5      at Master_Byte range 5 .. 5;
9182       Master_V6      at Master_Byte range 6 .. 6;
9183       Master_V7      at Master_Byte range 7 .. 7;
9184       Slave_Control  at Slave_Byte  range 0 .. 0;
9185       Slave_V1       at Slave_Byte  range 1 .. 1;
9186       Slave_V2       at Slave_Byte  range 2 .. 2;
9187       Slave_V3       at Slave_Byte  range 3 .. 3;
9188       Slave_V4       at Slave_Byte  range 4 .. 4;
9189       Slave_V5       at Slave_Byte  range 5 .. 5;
9190       Slave_V6       at Slave_Byte  range 6 .. 6;
9191       Slave_V7       at Slave_Byte  range 7 .. 7;
9192    end record;
9193 @end smallexample
9194
9195 @noindent
9196 Now to switch between machines, all that is necessary is
9197 to set the boolean constant @code{Master_Byte_First} in
9198 an appropriate manner.
9199
9200 @node Pragma Pack for Arrays
9201 @section Pragma Pack for Arrays
9202 @cindex Pragma Pack (for arrays)
9203
9204 @noindent
9205 Pragma @code{Pack} applied to an array has no effect unless the component type
9206 is packable.  For a component type to be packable, it must be one of the
9207 following cases:
9208
9209 @itemize @bullet
9210 @item
9211 Any scalar type
9212 @item
9213 Any type whose size is specified with a size clause
9214 @item
9215 Any packed array type with a static size
9216 @end itemize
9217
9218 @noindent
9219 For all these cases, if the component subtype size is in the range
9220 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9221 component size were specified giving the component subtype size.
9222 For example if we have:
9223
9224 @smallexample @c ada
9225    type r is range 0 .. 17;
9226
9227    type ar is array (1 .. 8) of r;
9228    pragma Pack (ar);
9229 @end smallexample
9230
9231 @noindent
9232 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9233 and the size of the array @code{ar} will be exactly 40 bits.
9234
9235 Note that in some cases this rather fierce approach to packing can produce
9236 unexpected effects.  For example, in Ada 95, type Natural typically has a
9237 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9238 close packing, which saves a few bits, but results in far less efficient
9239 access.  Since many other Ada compilers will ignore such a packing request,
9240 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9241 might not be what is intended.  You can easily remove this warning by
9242 using an explicit @code{Component_Size} setting instead, which never generates
9243 a warning, since the intention of the programmer is clear in this case.
9244
9245 GNAT treats packed arrays in one of two ways.  If the size of the array is
9246 known at compile time and is less than 64 bits, then internally the array
9247 is represented as a single modular type, of exactly the appropriate number
9248 of bits.  If the length is greater than 63 bits, or is not known at compile
9249 time, then the packed array is represented as an array of bytes, and the
9250 length is always a multiple of 8 bits.
9251
9252 Note that to represent a packed array as a modular type, the alignment must
9253 be suitable for the modular type involved. For example, on typical machines
9254 a 32-bit packed array will be represented by a 32-bit modular integer with
9255 an alignment of four bytes. If you explicitly override the default alignment
9256 with an alignment clause that is too small, the modular representation
9257 cannot be used. For example, consider the following set of declarations:
9258
9259 @smallexample @c ada
9260    type R is range 1 .. 3;
9261    type S is array (1 .. 31) of R;
9262    for S'Component_Size use 2;
9263    for S'Size use 62;
9264    for S'Alignment use 1;
9265 @end smallexample
9266
9267 @noindent
9268 If the alignment clause were not present, then a 62-bit modular
9269 representation would be chosen (typically with an alignment of 4 or 8
9270 bytes depending on the target). But the default alignment is overridden
9271 with the explicit alignment clause. This means that the modular
9272 representation cannot be used, and instead the array of bytes
9273 representation must be used, meaning that the length must be a multiple
9274 of 8. Thus the above set of declarations will result in a diagnostic
9275 rejecting the size clause and noting that the minimum size allowed is 64.
9276
9277 @cindex Pragma Pack (for type Natural)
9278 @cindex Pragma Pack warning
9279
9280 One special case that is worth noting occurs when the base type of the
9281 component size is 8/16/32 and the subtype is one bit less. Notably this
9282 occurs with subtype @code{Natural}. Consider:
9283
9284 @smallexample @c ada
9285    type Arr is array (1 .. 32) of Natural;
9286    pragma Pack (Arr);
9287 @end smallexample
9288
9289 @noindent
9290 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9291 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9292 Ada 83 compilers did not attempt 31 bit packing.
9293
9294 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9295 does pack 31-bit subtype to 31 bits. This may result in a substantial
9296 unintended performance penalty when porting legacy Ada 83 code. To help
9297 prevent this, GNAT generates a warning in such cases. If you really want 31
9298 bit packing in a case like this, you can set the component size explicitly:
9299
9300 @smallexample @c ada
9301    type Arr is array (1 .. 32) of Natural;
9302    for Arr'Component_Size use 31;
9303 @end smallexample
9304
9305 @noindent
9306 Here 31-bit packing is achieved as required, and no warning is generated,
9307 since in this case the programmer intention is clear.
9308
9309 @node Pragma Pack for Records
9310 @section Pragma Pack for Records
9311 @cindex Pragma Pack (for records)
9312
9313 @noindent
9314 Pragma @code{Pack} applied to a record will pack the components to reduce
9315 wasted space from alignment gaps and by reducing the amount of space
9316 taken by components.  We distinguish between @emph{packable} components and
9317 @emph{non-packable} components.
9318 Components of the following types are considered packable:
9319 @itemize @bullet
9320 @item
9321 All primitive types are packable.
9322
9323 @item
9324 Small packed arrays, whose size does not exceed 64 bits, and where the
9325 size is statically known at compile time, are represented internally
9326 as modular integers, and so they are also packable.
9327
9328 @end itemize
9329
9330 @noindent
9331 All packable components occupy the exact number of bits corresponding to
9332 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9333 can start on an arbitrary bit boundary.
9334
9335 All other types are non-packable, they occupy an integral number of
9336 storage units, and
9337 are placed at a boundary corresponding to their alignment requirements.
9338
9339 For example, consider the record
9340
9341 @smallexample @c ada
9342    type Rb1 is array (1 .. 13) of Boolean;
9343    pragma Pack (rb1);
9344
9345    type Rb2 is array (1 .. 65) of Boolean;
9346    pragma Pack (rb2);
9347
9348    type x2 is record
9349       l1 : Boolean;
9350       l2 : Duration;
9351       l3 : Float;
9352       l4 : Boolean;
9353       l5 : Rb1;
9354       l6 : Rb2;
9355    end record;
9356    pragma Pack (x2);
9357 @end smallexample
9358
9359 @noindent
9360 The representation for the record x2 is as follows:
9361
9362 @smallexample @c ada
9363 for x2'Size use 224;
9364 for x2 use record
9365    l1 at  0 range  0 .. 0;
9366    l2 at  0 range  1 .. 64;
9367    l3 at 12 range  0 .. 31;
9368    l4 at 16 range  0 .. 0;
9369    l5 at 16 range  1 .. 13;
9370    l6 at 18 range  0 .. 71;
9371 end record;
9372 @end smallexample
9373
9374 @noindent
9375 Studying this example, we see that the packable fields @code{l1}
9376 and @code{l2} are
9377 of length equal to their sizes, and placed at specific bit boundaries (and
9378 not byte boundaries) to
9379 eliminate padding.  But @code{l3} is of a non-packable float type, so
9380 it is on the next appropriate alignment boundary.
9381
9382 The next two fields are fully packable, so @code{l4} and @code{l5} are
9383 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9384 array that is longer than 64 bits, so it is itself non-packable.  Thus
9385 the @code{l6} field is aligned to the next byte boundary, and takes an
9386 integral number of bytes, i.e.@: 72 bits.
9387
9388 @node Record Representation Clauses
9389 @section Record Representation Clauses
9390 @cindex Record Representation Clause
9391
9392 @noindent
9393 Record representation clauses may be given for all record types, including
9394 types obtained by record extension.  Component clauses are allowed for any
9395 static component.  The restrictions on component clauses depend on the type
9396 of the component.
9397
9398 @cindex Component Clause
9399 For all components of an elementary type, the only restriction on component
9400 clauses is that the size must be at least the 'Size value of the type
9401 (actually the Value_Size).  There are no restrictions due to alignment,
9402 and such components may freely cross storage boundaries.
9403
9404 Packed arrays with a size up to and including 64 bits are represented
9405 internally using a modular type with the appropriate number of bits, and
9406 thus the same lack of restriction applies.  For example, if you declare:
9407
9408 @smallexample @c ada
9409    type R is array (1 .. 49) of Boolean;
9410    pragma Pack (R);
9411    for R'Size use 49;
9412 @end smallexample
9413
9414 @noindent
9415 then a component clause for a component of type R may start on any
9416 specified bit boundary, and may specify a value of 49 bits or greater.
9417
9418 The rules for other types are different for GNAT 3 and GNAT 5 versions
9419 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9420 may also be placed on arbitrary boundaries, so for example, the following
9421 is permitted:
9422
9423 @smallexample @c ada
9424    type R is array (1 .. 79) of Boolean;
9425    pragma Pack (R);
9426    for R'Size use 79;
9427
9428    type Q is record
9429       G, H : Boolean;
9430       L, M : R;
9431    end record;
9432
9433    for Q use record
9434       G at 0 range  0 ..   0;
9435       H at 0 range  1 ..   1;
9436       L at 0 range  2 ..  80;
9437       R at 0 range 81 .. 159;
9438    end record;
9439 @end smallexample
9440
9441 @noindent
9442 In GNAT 3, there are more severe restrictions on larger components.
9443 For non-primitive types, including packed arrays with a size greater than
9444 64 bits, component clauses must respect the alignment requirement of the
9445 type, in particular, always starting on a byte boundary, and the length
9446 must be a multiple of the storage unit.
9447
9448 The following rules regarding tagged types are enforced in both GNAT 3 and
9449 GNAT 5:
9450
9451 The tag field of a tagged type always occupies an address sized field at
9452 the start of the record.  No component clause may attempt to overlay this
9453 tag.
9454
9455 In the case of a record extension T1, of a type T, no component clause applied
9456 to the type T1 can specify a storage location that would overlap the first
9457 T'Size bytes of the record.
9458
9459 @node Enumeration Clauses
9460 @section Enumeration Clauses
9461
9462 The only restriction on enumeration clauses is that the range of values
9463 must be representable.  For the signed case, if one or more of the
9464 representation values are negative, all values must be in the range:
9465
9466 @smallexample @c ada
9467    System.Min_Int .. System.Max_Int
9468 @end smallexample
9469
9470 @noindent
9471 For the unsigned case, where all values are non negative, the values must
9472 be in the range:
9473
9474 @smallexample @c ada
9475    0 .. System.Max_Binary_Modulus;
9476 @end smallexample
9477
9478 @noindent
9479 A @emph{confirming} representation clause is one in which the values range
9480 from 0 in sequence, i.e.@: a clause that confirms the default representation
9481 for an enumeration type.
9482 Such a confirming representation
9483 is permitted by these rules, and is specially recognized by the compiler so
9484 that no extra overhead results from the use of such a clause.
9485
9486 If an array has an index type which is an enumeration type to which an
9487 enumeration clause has been applied, then the array is stored in a compact
9488 manner.  Consider the declarations:
9489
9490 @smallexample @c ada
9491    type r is (A, B, C);
9492    for r use (A => 1, B => 5, C => 10);
9493    type t is array (r) of Character;
9494 @end smallexample
9495
9496 @noindent
9497 The array type t corresponds to a vector with exactly three elements and
9498 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9499 use of space, but means that accesses to elements of the array will incur
9500 the overhead of converting representation values to the corresponding
9501 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9502
9503 @node Address Clauses
9504 @section Address Clauses
9505 @cindex Address Clause
9506
9507 The reference manual allows a general restriction on representation clauses,
9508 as found in RM 13.1(22):
9509
9510 @quotation
9511 An implementation need not support representation
9512 items containing nonstatic expressions, except that
9513 an implementation should support a representation item
9514 for a given entity if each nonstatic expression in the
9515 representation item is a name that statically denotes
9516 a constant declared before the entity.
9517 @end quotation
9518
9519 @noindent
9520 In practice this is applicable only to address clauses, since this is the
9521 only case in which a non-static expression is permitted by the syntax.  As
9522 the AARM notes in sections 13.1 (22.a-22.h):
9523
9524 @display
9525   22.a   Reason: This is to avoid the following sort of thing:
9526
9527   22.b        X : Integer := F(@dots{});
9528               Y : Address := G(@dots{});
9529               for X'Address use Y;
9530
9531   22.c   In the above, we have to evaluate the
9532          initialization expression for X before we
9533          know where to put the result.  This seems
9534          like an unreasonable implementation burden.
9535
9536   22.d   The above code should instead be written
9537          like this:
9538
9539   22.e        Y : constant Address := G(@dots{});
9540               X : Integer := F(@dots{});
9541               for X'Address use Y;
9542
9543   22.f   This allows the expression ``Y'' to be safely
9544          evaluated before X is created.
9545
9546   22.g   The constant could be a formal parameter of mode in.
9547
9548   22.h   An implementation can support other nonstatic
9549          expressions if it wants to.  Expressions of type
9550          Address are hardly ever static, but their value
9551          might be known at compile time anyway in many
9552          cases.
9553 @end display
9554
9555 @noindent
9556 GNAT does indeed permit many additional cases of non-static expressions.  In
9557 particular, if the type involved is elementary there are no restrictions
9558 (since in this case, holding a temporary copy of the initialization value,
9559 if one is present, is inexpensive).  In addition, if there is no implicit or
9560 explicit initialization, then there are no restrictions.  GNAT will reject
9561 only the case where all three of these conditions hold:
9562
9563 @itemize @bullet
9564
9565 @item
9566 The type of the item is non-elementary (e.g.@: a record or array).
9567
9568 @item
9569 There is explicit or implicit initialization required for the object.
9570 Note that access values are always implicitly initialized, and also
9571 in GNAT, certain bit-packed arrays (those having a dynamic length or
9572 a length greater than 64) will also be implicitly initialized to zero.
9573
9574 @item
9575 The address value is non-static.  Here GNAT is more permissive than the
9576 RM, and allows the address value to be the address of a previously declared
9577 stand-alone variable, as long as it does not itself have an address clause.
9578
9579 @smallexample @c ada
9580            Anchor  : Some_Initialized_Type;
9581            Overlay : Some_Initialized_Type;
9582            for Overlay'Address use Anchor'Address;
9583 @end smallexample
9584
9585 @noindent
9586 However, the prefix of the address clause cannot be an array component, or
9587 a component of a discriminated record.
9588
9589 @end itemize
9590
9591 @noindent
9592 As noted above in section 22.h, address values are typically non-static.  In
9593 particular the To_Address function, even if applied to a literal value, is
9594 a non-static function call.  To avoid this minor annoyance, GNAT provides
9595 the implementation defined attribute 'To_Address.  The following two
9596 expressions have identical values:
9597
9598 @findex Attribute
9599 @findex To_Address
9600 @smallexample @c ada
9601    To_Address (16#1234_0000#)
9602    System'To_Address (16#1234_0000#);
9603 @end smallexample
9604
9605 @noindent
9606 except that the second form is considered to be a static expression, and
9607 thus when used as an address clause value is always permitted.
9608
9609 @noindent
9610 Additionally, GNAT treats as static an address clause that is an
9611 unchecked_conversion of a static integer value.  This simplifies the porting
9612 of legacy code, and provides a portable equivalent to the GNAT attribute
9613 @code{To_Address}.
9614
9615 Another issue with address clauses is the interaction with alignment
9616 requirements.  When an address clause is given for an object, the address
9617 value must be consistent with the alignment of the object (which is usually
9618 the same as the alignment of the type of the object).  If an address clause
9619 is given that specifies an inappropriately aligned address value, then the
9620 program execution is erroneous.
9621
9622 Since this source of erroneous behavior can have unfortunate effects, GNAT
9623 checks (at compile time if possible, generating a warning, or at execution
9624 time with a run-time check) that the alignment is appropriate.  If the
9625 run-time check fails, then @code{Program_Error} is raised.  This run-time
9626 check is suppressed if range checks are suppressed, or if
9627 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9628
9629 @findex Export
9630 An address clause cannot be given for an exported object.  More
9631 understandably the real restriction is that objects with an address
9632 clause cannot be exported.  This is because such variables are not
9633 defined by the Ada program, so there is no external object to export.
9634
9635 @findex Import
9636 It is permissible to give an address clause and a pragma Import for the
9637 same object.  In this case, the variable is not really defined by the
9638 Ada program, so there is no external symbol to be linked.  The link name
9639 and the external name are ignored in this case.  The reason that we allow this
9640 combination is that it provides a useful idiom to avoid unwanted
9641 initializations on objects with address clauses.
9642
9643 When an address clause is given for an object that has implicit or
9644 explicit initialization, then by default initialization takes place.  This
9645 means that the effect of the object declaration is to overwrite the
9646 memory at the specified address.  This is almost always not what the
9647 programmer wants, so GNAT will output a warning:
9648
9649 @smallexample
9650   with System;
9651   package G is
9652      type R is record
9653         M : Integer := 0;
9654      end record;
9655
9656      Ext : R;
9657      for Ext'Address use System'To_Address (16#1234_1234#);
9658          |
9659   >>> warning: implicit initialization of "Ext" may
9660       modify overlaid storage
9661   >>> warning: use pragma Import for "Ext" to suppress
9662       initialization (RM B(24))
9663
9664   end G;
9665 @end smallexample
9666
9667 @noindent
9668 As indicated by the warning message, the solution is to use a (dummy) pragma
9669 Import to suppress this initialization.  The pragma tell the compiler that the
9670 object is declared and initialized elsewhere.  The following package compiles
9671 without warnings (and the initialization is suppressed):
9672
9673 @smallexample @c ada
9674    with System;
9675    package G is
9676       type R is record
9677          M : Integer := 0;
9678       end record;
9679
9680       Ext : R;
9681       for Ext'Address use System'To_Address (16#1234_1234#);
9682       pragma Import (Ada, Ext);
9683    end G;
9684 @end smallexample
9685
9686 @noindent
9687 A final issue with address clauses involves their use for overlaying
9688 variables, as in the following example:
9689 @cindex Overlaying of objects
9690
9691 @smallexample @c ada
9692   A : Integer;
9693   B : Integer;
9694   for B'Address use A'Address;
9695 @end smallexample
9696
9697 @noindent
9698 or alternatively, using the form recommended by the RM:
9699
9700 @smallexample @c ada
9701   A    : Integer;
9702   Addr : constant Address := A'Address;
9703   B    : Integer;
9704   for B'Address use Addr;
9705 @end smallexample
9706
9707 @noindent
9708 In both of these cases, @code{A}
9709 and @code{B} become aliased to one another via the
9710 address clause. This use of address clauses to overlay
9711 variables, achieving an effect similar to unchecked
9712 conversion was erroneous in Ada 83, but in Ada 95
9713 the effect is implementation defined. Furthermore, the
9714 Ada 95 RM specifically recommends that in a situation
9715 like this, @code{B} should be subject to the following
9716 implementation advice (RM 13.3(19)):
9717
9718 @quotation
9719 19  If the Address of an object is specified, or it is imported
9720     or exported, then the implementation should not perform
9721     optimizations based on assumptions of no aliases.
9722 @end quotation
9723
9724 @noindent
9725 GNAT follows this recommendation, and goes further by also applying
9726 this recommendation to the overlaid variable (@code{A}
9727 in the above example) in this case. This means that the overlay
9728 works "as expected", in that a modification to one of the variables
9729 will affect the value of the other.
9730
9731 @node Effect of Convention on Representation
9732 @section Effect of Convention on Representation
9733 @cindex Convention, effect on representation
9734
9735 @noindent
9736 Normally the specification of a foreign language convention for a type or
9737 an object has no effect on the chosen representation.  In particular, the
9738 representation chosen for data in GNAT generally meets the standard system
9739 conventions, and for example records are laid out in a manner that is
9740 consistent with C@.  This means that specifying convention C (for example)
9741 has no effect.
9742
9743 There are three exceptions to this general rule:
9744
9745 @itemize @bullet
9746
9747 @item Convention Fortran and array subtypes
9748 If pragma Convention Fortran is specified for an array subtype, then in
9749 accordance with the implementation advice in section 3.6.2(11) of the
9750 Ada Reference Manual, the array will be stored in a Fortran-compatible
9751 column-major manner, instead of the normal default row-major order.
9752
9753 @item Convention C and enumeration types
9754 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9755 to accommodate all values of the type.  For example, for the enumeration
9756 type declared by:
9757
9758 @smallexample @c ada
9759    type Color is (Red, Green, Blue);
9760 @end smallexample
9761
9762 @noindent
9763 8 bits is sufficient to store all values of the type, so by default, objects
9764 of type @code{Color} will be represented using 8 bits.  However, normal C
9765 convention is to use 32 bits for all enum values in C, since enum values
9766 are essentially of type int.  If pragma @code{Convention C} is specified for an
9767 Ada enumeration type, then the size is modified as necessary (usually to
9768 32 bits) to be consistent with the C convention for enum values.
9769
9770 @item Convention C/Fortran and Boolean types
9771 In C, the usual convention for boolean values, that is values used for
9772 conditions, is that zero represents false, and nonzero values represent
9773 true.  In Ada, the normal convention is that two specific values, typically
9774 0/1, are used to represent false/true respectively.
9775
9776 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9777 value represents true).
9778
9779 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9780 C or Fortran convention for a derived Boolean, as in the following example:
9781
9782 @smallexample @c ada
9783    type C_Switch is new Boolean;
9784    pragma Convention (C, C_Switch);
9785 @end smallexample
9786
9787 @noindent
9788 then the GNAT generated code will treat any nonzero value as true.  For truth
9789 values generated by GNAT, the conventional value 1 will be used for True, but
9790 when one of these values is read, any nonzero value is treated as True.
9791
9792 @end itemize
9793
9794 @node Determining the Representations chosen by GNAT
9795 @section Determining the Representations chosen by GNAT
9796 @cindex Representation, determination of
9797 @cindex @code{-gnatR} switch
9798
9799 @noindent
9800 Although the descriptions in this section are intended to be complete, it is
9801 often easier to simply experiment to see what GNAT accepts and what the
9802 effect is on the layout of types and objects.
9803
9804 As required by the Ada RM, if a representation clause is not accepted, then
9805 it must be rejected as illegal by the compiler.  However, when a
9806 representation clause or pragma is accepted, there can still be questions
9807 of what the compiler actually does.  For example, if a partial record
9808 representation clause specifies the location of some components and not
9809 others, then where are the non-specified components placed? Or if pragma
9810 @code{Pack} is used on a record, then exactly where are the resulting
9811 fields placed? The section on pragma @code{Pack} in this chapter can be
9812 used to answer the second question, but it is often easier to just see
9813 what the compiler does.
9814
9815 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9816 with this option, then the compiler will output information on the actual
9817 representations chosen, in a format similar to source representation
9818 clauses.  For example, if we compile the package:
9819
9820 @smallexample @c ada
9821 package q is
9822    type r (x : boolean) is tagged record
9823       case x is
9824          when True => S : String (1 .. 100);
9825          when False => null;
9826       end case;
9827    end record;
9828
9829    type r2 is new r (false) with record
9830       y2 : integer;
9831    end record;
9832
9833    for r2 use record
9834       y2 at 16 range 0 .. 31;
9835    end record;
9836
9837    type x is record
9838       y : character;
9839    end record;
9840
9841    type x1 is array (1 .. 10) of x;
9842    for x1'component_size use 11;
9843
9844    type ia is access integer;
9845
9846    type Rb1 is array (1 .. 13) of Boolean;
9847    pragma Pack (rb1);
9848
9849    type Rb2 is array (1 .. 65) of Boolean;
9850    pragma Pack (rb2);
9851
9852    type x2 is record
9853       l1 : Boolean;
9854       l2 : Duration;
9855       l3 : Float;
9856       l4 : Boolean;
9857       l5 : Rb1;
9858       l6 : Rb2;
9859    end record;
9860    pragma Pack (x2);
9861 end q;
9862 @end smallexample
9863
9864 @noindent
9865 using the switch @code{-gnatR} we obtain the following output:
9866
9867 @smallexample
9868 Representation information for unit q
9869 -------------------------------------
9870
9871 for r'Size use ??;
9872 for r'Alignment use 4;
9873 for r use record
9874    x    at 4 range  0 .. 7;
9875    _tag at 0 range  0 .. 31;
9876    s    at 5 range  0 .. 799;
9877 end record;
9878
9879 for r2'Size use 160;
9880 for r2'Alignment use 4;
9881 for r2 use record
9882    x       at  4 range  0 .. 7;
9883    _tag    at  0 range  0 .. 31;
9884    _parent at  0 range  0 .. 63;
9885    y2      at 16 range  0 .. 31;
9886 end record;
9887
9888 for x'Size use 8;
9889 for x'Alignment use 1;
9890 for x use record
9891    y at 0 range  0 .. 7;
9892 end record;
9893
9894 for x1'Size use 112;
9895 for x1'Alignment use 1;
9896 for x1'Component_Size use 11;
9897
9898 for rb1'Size use 13;
9899 for rb1'Alignment use 2;
9900 for rb1'Component_Size use 1;
9901
9902 for rb2'Size use 72;
9903 for rb2'Alignment use 1;
9904 for rb2'Component_Size use 1;
9905
9906 for x2'Size use 224;
9907 for x2'Alignment use 4;
9908 for x2 use record
9909    l1 at  0 range  0 .. 0;
9910    l2 at  0 range  1 .. 64;
9911    l3 at 12 range  0 .. 31;
9912    l4 at 16 range  0 .. 0;
9913    l5 at 16 range  1 .. 13;
9914    l6 at 18 range  0 .. 71;
9915 end record;
9916 @end smallexample
9917
9918 @noindent
9919 The Size values are actually the Object_Size, i.e.@: the default size that
9920 will be allocated for objects of the type.
9921 The ?? size for type r indicates that we have a variant record, and the
9922 actual size of objects will depend on the discriminant value.
9923
9924 The Alignment values show the actual alignment chosen by the compiler
9925 for each record or array type.
9926
9927 The record representation clause for type r shows where all fields
9928 are placed, including the compiler generated tag field (whose location
9929 cannot be controlled by the programmer).
9930
9931 The record representation clause for the type extension r2 shows all the
9932 fields present, including the parent field, which is a copy of the fields
9933 of the parent type of r2, i.e.@: r1.
9934
9935 The component size and size clauses for types rb1 and rb2 show
9936 the exact effect of pragma @code{Pack} on these arrays, and the record
9937 representation clause for type x2 shows how pragma @code{Pack} affects
9938 this record type.
9939
9940 In some cases, it may be useful to cut and paste the representation clauses
9941 generated by the compiler into the original source to fix and guarantee
9942 the actual representation to be used.
9943
9944 @node Standard Library Routines
9945 @chapter Standard Library Routines
9946
9947 @noindent
9948 The Ada 95 Reference Manual contains in Annex A a full description of an
9949 extensive set of standard library routines that can be used in any Ada
9950 program, and which must be provided by all Ada compilers.  They are
9951 analogous to the standard C library used by C programs.
9952
9953 GNAT implements all of the facilities described in annex A, and for most
9954 purposes the description in the Ada 95
9955 reference manual, or appropriate Ada
9956 text book, will be sufficient for making use of these facilities.
9957
9958 In the case of the input-output facilities, @xref{The Implementation of
9959 Standard I/O}, gives details on exactly how GNAT interfaces to the
9960 file system.  For the remaining packages, the Ada 95 reference manual
9961 should be sufficient.  The following is a list of the packages included,
9962 together with a brief description of the functionality that is provided.
9963
9964 For completeness, references are included to other predefined library
9965 routines defined in other sections of the Ada 95 reference manual (these are
9966 cross-indexed from annex A).
9967
9968 @table @code
9969 @item Ada (A.2)
9970 This is a parent package for all the standard library packages.  It is
9971 usually included implicitly in your program, and itself contains no
9972 useful data or routines.
9973
9974 @item Ada.Calendar (9.6)
9975 @code{Calendar} provides time of day access, and routines for
9976 manipulating times and durations.
9977
9978 @item Ada.Characters (A.3.1)
9979 This is a dummy parent package that contains no useful entities
9980
9981 @item Ada.Characters.Handling (A.3.2)
9982 This package provides some basic character handling capabilities,
9983 including classification functions for classes of characters (e.g.@: test
9984 for letters, or digits).
9985
9986 @item Ada.Characters.Latin_1 (A.3.3)
9987 This package includes a complete set of definitions of the characters
9988 that appear in type CHARACTER@.  It is useful for writing programs that
9989 will run in international environments.  For example, if you want an
9990 upper case E with an acute accent in a string, it is often better to use
9991 the definition of @code{UC_E_Acute} in this package.  Then your program
9992 will print in an understandable manner even if your environment does not
9993 support these extended characters.
9994
9995 @item Ada.Command_Line (A.15)
9996 This package provides access to the command line parameters and the name
9997 of the current program (analogous to the use of @code{argc} and @code{argv}
9998 in C), and also allows the exit status for the program to be set in a
9999 system-independent manner.
10000
10001 @item Ada.Decimal (F.2)
10002 This package provides constants describing the range of decimal numbers
10003 implemented, and also a decimal divide routine (analogous to the COBOL
10004 verb DIVIDE .. GIVING .. REMAINDER ..)
10005
10006 @item Ada.Direct_IO (A.8.4)
10007 This package provides input-output using a model of a set of records of
10008 fixed-length, containing an arbitrary definite Ada type, indexed by an
10009 integer record number.
10010
10011 @item Ada.Dynamic_Priorities (D.5)
10012 This package allows the priorities of a task to be adjusted dynamically
10013 as the task is running.
10014
10015 @item Ada.Exceptions (11.4.1)
10016 This package provides additional information on exceptions, and also
10017 contains facilities for treating exceptions as data objects, and raising
10018 exceptions with associated messages.
10019
10020 @item Ada.Finalization (7.6)
10021 This package contains the declarations and subprograms to support the
10022 use of controlled types, providing for automatic initialization and
10023 finalization (analogous to the constructors and destructors of C++)
10024
10025 @item Ada.Interrupts (C.3.2)
10026 This package provides facilities for interfacing to interrupts, which
10027 includes the set of signals or conditions that can be raised and
10028 recognized as interrupts.
10029
10030 @item Ada.Interrupts.Names (C.3.2)
10031 This package provides the set of interrupt names (actually signal
10032 or condition names) that can be handled by GNAT@.
10033
10034 @item Ada.IO_Exceptions (A.13)
10035 This package defines the set of exceptions that can be raised by use of
10036 the standard IO packages.
10037
10038 @item Ada.Numerics
10039 This package contains some standard constants and exceptions used
10040 throughout the numerics packages.  Note that the constants pi and e are
10041 defined here, and it is better to use these definitions than rolling
10042 your own.
10043
10044 @item Ada.Numerics.Complex_Elementary_Functions
10045 Provides the implementation of standard elementary functions (such as
10046 log and trigonometric functions) operating on complex numbers using the
10047 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10048 created by the package @code{Numerics.Complex_Types}.
10049
10050 @item Ada.Numerics.Complex_Types
10051 This is a predefined instantiation of
10052 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10053 build the type @code{Complex} and @code{Imaginary}.
10054
10055 @item Ada.Numerics.Discrete_Random
10056 This package provides a random number generator suitable for generating
10057 random integer values from a specified range.
10058
10059 @item Ada.Numerics.Float_Random
10060 This package provides a random number generator suitable for generating
10061 uniformly distributed floating point values.
10062
10063 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10064 This is a generic version of the package that provides the
10065 implementation of standard elementary functions (such as log and
10066 trigonometric functions) for an arbitrary complex type.
10067
10068 The following predefined instantiations of this package are provided:
10069
10070 @table @code
10071 @item Short_Float
10072 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10073 @item Float
10074 @code{Ada.Numerics.Complex_Elementary_Functions}
10075 @item Long_Float
10076 @code{Ada.Numerics.
10077  Long_Complex_Elementary_Functions}
10078 @end table
10079
10080 @item Ada.Numerics.Generic_Complex_Types
10081 This is a generic package that allows the creation of complex types,
10082 with associated complex arithmetic operations.
10083
10084 The following predefined instantiations of this package exist
10085 @table @code
10086 @item Short_Float
10087 @code{Ada.Numerics.Short_Complex_Complex_Types}
10088 @item Float
10089 @code{Ada.Numerics.Complex_Complex_Types}
10090 @item Long_Float
10091 @code{Ada.Numerics.Long_Complex_Complex_Types}
10092 @end table
10093
10094 @item Ada.Numerics.Generic_Elementary_Functions
10095 This is a generic package that provides the implementation of standard
10096 elementary functions (such as log an trigonometric functions) for an
10097 arbitrary float type.
10098
10099 The following predefined instantiations of this package exist
10100
10101 @table @code
10102 @item Short_Float
10103 @code{Ada.Numerics.Short_Elementary_Functions}
10104 @item Float
10105 @code{Ada.Numerics.Elementary_Functions}
10106 @item Long_Float
10107 @code{Ada.Numerics.Long_Elementary_Functions}
10108 @end table
10109
10110 @item Ada.Real_Time (D.8)
10111 This package provides facilities similar to those of @code{Calendar}, but
10112 operating with a finer clock suitable for real time control. Note that
10113 annex D requires that there be no backward clock jumps, and GNAT generally
10114 guarantees this behavior, but of course if the external clock on which
10115 the GNAT runtime depends is deliberately reset by some external event,
10116 then such a backward jump may occur.
10117
10118 @item Ada.Sequential_IO (A.8.1)
10119 This package provides input-output facilities for sequential files,
10120 which can contain a sequence of values of a single type, which can be
10121 any Ada type, including indefinite (unconstrained) types.
10122
10123 @item Ada.Storage_IO (A.9)
10124 This package provides a facility for mapping arbitrary Ada types to and
10125 from a storage buffer.  It is primarily intended for the creation of new
10126 IO packages.
10127
10128 @item Ada.Streams (13.13.1)
10129 This is a generic package that provides the basic support for the
10130 concept of streams as used by the stream attributes (@code{Input},
10131 @code{Output}, @code{Read} and @code{Write}).
10132
10133 @item Ada.Streams.Stream_IO (A.12.1)
10134 This package is a specialization of the type @code{Streams} defined in
10135 package @code{Streams} together with a set of operations providing
10136 Stream_IO capability.  The Stream_IO model permits both random and
10137 sequential access to a file which can contain an arbitrary set of values
10138 of one or more Ada types.
10139
10140 @item Ada.Strings (A.4.1)
10141 This package provides some basic constants used by the string handling
10142 packages.
10143
10144 @item Ada.Strings.Bounded (A.4.4)
10145 This package provides facilities for handling variable length
10146 strings.  The bounded model requires a maximum length.  It is thus
10147 somewhat more limited than the unbounded model, but avoids the use of
10148 dynamic allocation or finalization.
10149
10150 @item Ada.Strings.Fixed (A.4.3)
10151 This package provides facilities for handling fixed length strings.
10152
10153 @item Ada.Strings.Maps (A.4.2)
10154 This package provides facilities for handling character mappings and
10155 arbitrarily defined subsets of characters.  For instance it is useful in
10156 defining specialized translation tables.
10157
10158 @item Ada.Strings.Maps.Constants (A.4.6)
10159 This package provides a standard set of predefined mappings and
10160 predefined character sets.  For example, the standard upper to lower case
10161 conversion table is found in this package.  Note that upper to lower case
10162 conversion is non-trivial if you want to take the entire set of
10163 characters, including extended characters like E with an acute accent,
10164 into account.  You should use the mappings in this package (rather than
10165 adding 32 yourself) to do case mappings.
10166
10167 @item Ada.Strings.Unbounded (A.4.5)
10168 This package provides facilities for handling variable length
10169 strings.  The unbounded model allows arbitrary length strings, but
10170 requires the use of dynamic allocation and finalization.
10171
10172 @item Ada.Strings.Wide_Bounded (A.4.7)
10173 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10174 @itemx Ada.Strings.Wide_Maps (A.4.7)
10175 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10176 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10177 These packages provide analogous capabilities to the corresponding
10178 packages without @samp{Wide_} in the name, but operate with the types
10179 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10180 and @code{Character}.
10181
10182 @item Ada.Synchronous_Task_Control (D.10)
10183 This package provides some standard facilities for controlling task
10184 communication in a synchronous manner.
10185
10186 @item Ada.Tags
10187 This package contains definitions for manipulation of the tags of tagged
10188 values.
10189
10190 @item Ada.Task_Attributes
10191 This package provides the capability of associating arbitrary
10192 task-specific data with separate tasks.
10193
10194 @item Ada.Text_IO
10195 This package provides basic text input-output capabilities for
10196 character, string and numeric data.  The subpackages of this
10197 package are listed next.
10198
10199 @item Ada.Text_IO.Decimal_IO
10200 Provides input-output facilities for decimal fixed-point types
10201
10202 @item Ada.Text_IO.Enumeration_IO
10203 Provides input-output facilities for enumeration types.
10204
10205 @item Ada.Text_IO.Fixed_IO
10206 Provides input-output facilities for ordinary fixed-point types.
10207
10208 @item Ada.Text_IO.Float_IO
10209 Provides input-output facilities for float types.  The following
10210 predefined instantiations of this generic package are available:
10211
10212 @table @code
10213 @item Short_Float
10214 @code{Short_Float_Text_IO}
10215 @item Float
10216 @code{Float_Text_IO}
10217 @item Long_Float
10218 @code{Long_Float_Text_IO}
10219 @end table
10220
10221 @item Ada.Text_IO.Integer_IO
10222 Provides input-output facilities for integer types.  The following
10223 predefined instantiations of this generic package are available:
10224
10225 @table @code
10226 @item Short_Short_Integer
10227 @code{Ada.Short_Short_Integer_Text_IO}
10228 @item Short_Integer
10229 @code{Ada.Short_Integer_Text_IO}
10230 @item Integer
10231 @code{Ada.Integer_Text_IO}
10232 @item Long_Integer
10233 @code{Ada.Long_Integer_Text_IO}
10234 @item Long_Long_Integer
10235 @code{Ada.Long_Long_Integer_Text_IO}
10236 @end table
10237
10238 @item Ada.Text_IO.Modular_IO
10239 Provides input-output facilities for modular (unsigned) types
10240
10241 @item Ada.Text_IO.Complex_IO (G.1.3)
10242 This package provides basic text input-output capabilities for complex
10243 data.
10244
10245 @item Ada.Text_IO.Editing (F.3.3)
10246 This package contains routines for edited output, analogous to the use
10247 of pictures in COBOL@.  The picture formats used by this package are a
10248 close copy of the facility in COBOL@.
10249
10250 @item Ada.Text_IO.Text_Streams (A.12.2)
10251 This package provides a facility that allows Text_IO files to be treated
10252 as streams, so that the stream attributes can be used for writing
10253 arbitrary data, including binary data, to Text_IO files.
10254
10255 @item Ada.Unchecked_Conversion (13.9)
10256 This generic package allows arbitrary conversion from one type to
10257 another of the same size, providing for breaking the type safety in
10258 special circumstances.
10259
10260 If the types have the same Size (more accurately the same Value_Size),
10261 then the effect is simply to transfer the bits from the source to the
10262 target type without any modification.  This usage is well defined, and
10263 for simple types whose representation is typically the same across
10264 all implementations, gives a portable method of performing such
10265 conversions.
10266
10267 If the types do not have the same size, then the result is implementation
10268 defined, and thus may be non-portable.  The following describes how GNAT
10269 handles such unchecked conversion cases.
10270
10271 If the types are of different sizes, and are both discrete types, then
10272 the effect is of a normal type conversion without any constraint checking.
10273 In particular if the result type has a larger size, the result will be
10274 zero or sign extended.  If the result type has a smaller size, the result
10275 will be truncated by ignoring high order bits.
10276
10277 If the types are of different sizes, and are not both discrete types,
10278 then the conversion works as though pointers were created to the source
10279 and target, and the pointer value is converted.  The effect is that bits
10280 are copied from successive low order storage units and bits of the source
10281 up to the length of the target type.
10282
10283 A warning is issued if the lengths differ, since the effect in this
10284 case is implementation dependent, and the above behavior may not match
10285 that of some other compiler.
10286
10287 A pointer to one type may be converted to a pointer to another type using
10288 unchecked conversion.  The only case in which the effect is undefined is
10289 when one or both pointers are pointers to unconstrained array types.  In
10290 this case, the bounds information may get incorrectly transferred, and in
10291 particular, GNAT uses double size pointers for such types, and it is
10292 meaningless to convert between such pointer types.  GNAT will issue a
10293 warning if the alignment of the target designated type is more strict
10294 than the alignment of the source designated type (since the result may
10295 be unaligned in this case).
10296
10297 A pointer other than a pointer to an unconstrained array type may be
10298 converted to and from System.Address.  Such usage is common in Ada 83
10299 programs, but note that Ada.Address_To_Access_Conversions is the
10300 preferred method of performing such conversions in Ada 95.  Neither
10301 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10302 used in conjunction with pointers to unconstrained objects, since
10303 the bounds information cannot be handled correctly in this case.
10304
10305 @item Ada.Unchecked_Deallocation (13.11.2)
10306 This generic package allows explicit freeing of storage previously
10307 allocated by use of an allocator.
10308
10309 @item Ada.Wide_Text_IO (A.11)
10310 This package is similar to @code{Ada.Text_IO}, except that the external
10311 file supports wide character representations, and the internal types are
10312 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10313 and @code{String}.  It contains generic subpackages listed next.
10314
10315 @item Ada.Wide_Text_IO.Decimal_IO
10316 Provides input-output facilities for decimal fixed-point types
10317
10318 @item Ada.Wide_Text_IO.Enumeration_IO
10319 Provides input-output facilities for enumeration types.
10320
10321 @item Ada.Wide_Text_IO.Fixed_IO
10322 Provides input-output facilities for ordinary fixed-point types.
10323
10324 @item Ada.Wide_Text_IO.Float_IO
10325 Provides input-output facilities for float types.  The following
10326 predefined instantiations of this generic package are available:
10327
10328 @table @code
10329 @item Short_Float
10330 @code{Short_Float_Wide_Text_IO}
10331 @item Float
10332 @code{Float_Wide_Text_IO}
10333 @item Long_Float
10334 @code{Long_Float_Wide_Text_IO}
10335 @end table
10336
10337 @item Ada.Wide_Text_IO.Integer_IO
10338 Provides input-output facilities for integer types.  The following
10339 predefined instantiations of this generic package are available:
10340
10341 @table @code
10342 @item Short_Short_Integer
10343 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10344 @item Short_Integer
10345 @code{Ada.Short_Integer_Wide_Text_IO}
10346 @item Integer
10347 @code{Ada.Integer_Wide_Text_IO}
10348 @item Long_Integer
10349 @code{Ada.Long_Integer_Wide_Text_IO}
10350 @item Long_Long_Integer
10351 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10352 @end table
10353
10354 @item Ada.Wide_Text_IO.Modular_IO
10355 Provides input-output facilities for modular (unsigned) types
10356
10357 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10358 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10359 external file supports wide character representations.
10360
10361 @item Ada.Wide_Text_IO.Editing (F.3.4)
10362 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10363 types are @code{Wide_Character} and @code{Wide_String} instead of
10364 @code{Character} and @code{String}.
10365
10366 @item Ada.Wide_Text_IO.Streams (A.12.3)
10367 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10368 types are @code{Wide_Character} and @code{Wide_String} instead of
10369 @code{Character} and @code{String}.
10370 @end table
10371
10372 @node The Implementation of Standard I/O
10373 @chapter The Implementation of Standard I/O
10374
10375 @noindent
10376 GNAT implements all the required input-output facilities described in
10377 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10378 required behavior of these packages from the Ada point of view, and if
10379 you are writing a portable Ada program that does not need to know the
10380 exact manner in which Ada maps to the outside world when it comes to
10381 reading or writing external files, then you do not need to read this
10382 chapter.  As long as your files are all regular files (not pipes or
10383 devices), and as long as you write and read the files only from Ada, the
10384 description in the Ada 95 reference manual is sufficient.
10385
10386 However, if you want to do input-output to pipes or other devices, such
10387 as the keyboard or screen, or if the files you are dealing with are
10388 either generated by some other language, or to be read by some other
10389 language, then you need to know more about the details of how the GNAT
10390 implementation of these input-output facilities behaves.
10391
10392 In this chapter we give a detailed description of exactly how GNAT
10393 interfaces to the file system.  As always, the sources of the system are
10394 available to you for answering questions at an even more detailed level,
10395 but for most purposes the information in this chapter will suffice.
10396
10397 Another reason that you may need to know more about how input-output is
10398 implemented arises when you have a program written in mixed languages
10399 where, for example, files are shared between the C and Ada sections of
10400 the same program.  GNAT provides some additional facilities, in the form
10401 of additional child library packages, that facilitate this sharing, and
10402 these additional facilities are also described in this chapter.
10403
10404 @menu
10405 * Standard I/O Packages::
10406 * FORM Strings::
10407 * Direct_IO::
10408 * Sequential_IO::
10409 * Text_IO::
10410 * Wide_Text_IO::
10411 * Stream_IO::
10412 * Shared Files::
10413 * Open Modes::
10414 * Operations on C Streams::
10415 * Interfacing to C Streams::
10416 @end menu
10417
10418 @node Standard I/O Packages
10419 @section Standard I/O Packages
10420
10421 @noindent
10422 The Standard I/O packages described in Annex A for
10423
10424 @itemize @bullet
10425 @item
10426 Ada.Text_IO
10427 @item
10428 Ada.Text_IO.Complex_IO
10429 @item
10430 Ada.Text_IO.Text_Streams,
10431 @item
10432 Ada.Wide_Text_IO
10433 @item
10434 Ada.Wide_Text_IO.Complex_IO,
10435 @item
10436 Ada.Wide_Text_IO.Text_Streams
10437 @item
10438 Ada.Stream_IO
10439 @item
10440 Ada.Sequential_IO
10441 @item
10442 Ada.Direct_IO
10443 @end itemize
10444
10445 @noindent
10446 are implemented using the C
10447 library streams facility; where
10448
10449 @itemize @bullet
10450 @item
10451 All files are opened using @code{fopen}.
10452 @item
10453 All input/output operations use @code{fread}/@code{fwrite}.
10454 @end itemize
10455
10456 @noindent
10457 There is no internal buffering of any kind at the Ada library level.  The
10458 only buffering is that provided at the system level in the
10459 implementation of the C library routines that support streams.  This
10460 facilitates shared use of these streams by mixed language programs.
10461
10462 @node FORM Strings
10463 @section FORM Strings
10464
10465 @noindent
10466 The format of a FORM string in GNAT is:
10467
10468 @smallexample
10469 "keyword=value,keyword=value,@dots{},keyword=value"
10470 @end smallexample
10471
10472 @noindent
10473 where letters may be in upper or lower case, and there are no spaces
10474 between values.  The order of the entries is not important.  Currently
10475 there are two keywords defined.
10476
10477 @smallexample
10478 SHARED=[YES|NO]
10479 WCEM=[n|h|u|s\e]
10480 @end smallexample
10481
10482 @noindent
10483 The use of these parameters is described later in this section.
10484
10485 @node Direct_IO
10486 @section Direct_IO
10487
10488 @noindent
10489 Direct_IO can only be instantiated for definite types.  This is a
10490 restriction of the Ada language, which means that the records are fixed
10491 length (the length being determined by @code{@var{type}'Size}, rounded
10492 up to the next storage unit boundary if necessary).
10493
10494 The records of a Direct_IO file are simply written to the file in index
10495 sequence, with the first record starting at offset zero, and subsequent
10496 records following.  There is no control information of any kind.  For
10497 example, if 32-bit integers are being written, each record takes
10498 4-bytes, so the record at index @var{K} starts at offset
10499 (@var{K}@minus{}1)*4.
10500
10501 There is no limit on the size of Direct_IO files, they are expanded as
10502 necessary to accommodate whatever records are written to the file.
10503
10504 @node Sequential_IO
10505 @section Sequential_IO
10506
10507 @noindent
10508 Sequential_IO may be instantiated with either a definite (constrained)
10509 or indefinite (unconstrained) type.
10510
10511 For the definite type case, the elements written to the file are simply
10512 the memory images of the data values with no control information of any
10513 kind.  The resulting file should be read using the same type, no validity
10514 checking is performed on input.
10515
10516 For the indefinite type case, the elements written consist of two
10517 parts.  First is the size of the data item, written as the memory image
10518 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10519 the data value.  The resulting file can only be read using the same
10520 (unconstrained) type.  Normal assignment checks are performed on these
10521 read operations, and if these checks fail, @code{Data_Error} is
10522 raised.  In particular, in the array case, the lengths must match, and in
10523 the variant record case, if the variable for a particular read operation
10524 is constrained, the discriminants must match.
10525
10526 Note that it is not possible to use Sequential_IO to write variable
10527 length array items, and then read the data back into different length
10528 arrays.  For example, the following will raise @code{Data_Error}:
10529
10530 @smallexample @c ada
10531  package IO is new Sequential_IO (String);
10532  F : IO.File_Type;
10533  S : String (1..4);
10534  @dots{}
10535  IO.Create (F)
10536  IO.Write (F, "hello!")
10537  IO.Reset (F, Mode=>In_File);
10538  IO.Read (F, S);
10539  Put_Line (S);
10540
10541 @end smallexample
10542
10543 @noindent
10544 On some Ada implementations, this will print @code{hell}, but the program is
10545 clearly incorrect, since there is only one element in the file, and that
10546 element is the string @code{hello!}.
10547
10548 In Ada 95, this kind of behavior can be legitimately achieved using
10549 Stream_IO, and this is the preferred mechanism.  In particular, the above
10550 program fragment rewritten to use Stream_IO will work correctly.
10551
10552 @node Text_IO
10553 @section Text_IO
10554
10555 @noindent
10556 Text_IO files consist of a stream of characters containing the following
10557 special control characters:
10558
10559 @smallexample
10560 LF (line feed, 16#0A#) Line Mark
10561 FF (form feed, 16#0C#) Page Mark
10562 @end smallexample
10563
10564 @noindent
10565 A canonical Text_IO file is defined as one in which the following
10566 conditions are met:
10567
10568 @itemize @bullet
10569 @item
10570 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10571 of the line.
10572
10573 @item
10574 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10575 end of a page and consequently can appear only immediately following a
10576 @code{LF} (line mark) character.
10577
10578 @item
10579 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10580 (line mark, page mark).  In the former case, the page mark is implicitly
10581 assumed to be present.
10582 @end itemize
10583
10584 @noindent
10585 A file written using Text_IO will be in canonical form provided that no
10586 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10587 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10588 the file unless an explicit @code{New_Page} operation was performed
10589 before closing the file.
10590
10591 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10592 pipe, can be read using any of the routines in Text_IO@.  The
10593 semantics in this case will be exactly as defined in the Ada 95 reference
10594 manual and all the routines in Text_IO are fully implemented.
10595
10596 A text file that does not meet the requirements for a canonical Text_IO
10597 file has one of the following:
10598
10599 @itemize @bullet
10600 @item
10601 The file contains @code{FF} characters not immediately following a
10602 @code{LF} character.
10603
10604 @item
10605 The file contains @code{LF} or @code{FF} characters written by
10606 @code{Put} or @code{Put_Line}, which are not logically considered to be
10607 line marks or page marks.
10608
10609 @item
10610 The file ends in a character other than @code{LF} or @code{FF},
10611 i.e.@: there is no explicit line mark or page mark at the end of the file.
10612 @end itemize
10613
10614 @noindent
10615 Text_IO can be used to read such non-standard text files but subprograms
10616 to do with line or page numbers do not have defined meanings.  In
10617 particular, a @code{FF} character that does not follow a @code{LF}
10618 character may or may not be treated as a page mark from the point of
10619 view of page and line numbering.  Every @code{LF} character is considered
10620 to end a line, and there is an implied @code{LF} character at the end of
10621 the file.
10622
10623 @menu
10624 * Text_IO Stream Pointer Positioning::
10625 * Text_IO Reading and Writing Non-Regular Files::
10626 * Get_Immediate::
10627 * Treating Text_IO Files as Streams::
10628 * Text_IO Extensions::
10629 * Text_IO Facilities for Unbounded Strings::
10630 @end menu
10631
10632 @node Text_IO Stream Pointer Positioning
10633 @subsection Stream Pointer Positioning
10634
10635 @noindent
10636 @code{Ada.Text_IO} has a definition of current position for a file that
10637 is being read.  No internal buffering occurs in Text_IO, and usually the
10638 physical position in the stream used to implement the file corresponds
10639 to this logical position defined by Text_IO@.  There are two exceptions:
10640
10641 @itemize @bullet
10642 @item
10643 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10644 is positioned past the @code{LF} (line mark) that precedes the page
10645 mark.  Text_IO maintains an internal flag so that subsequent read
10646 operations properly handle the logical position which is unchanged by
10647 the @code{End_Of_Page} call.
10648
10649 @item
10650 After a call to @code{End_Of_File} that returns @code{True}, if the
10651 Text_IO file was positioned before the line mark at the end of file
10652 before the call, then the logical position is unchanged, but the stream
10653 is physically positioned right at the end of file (past the line mark,
10654 and past a possible page mark following the line mark.  Again Text_IO
10655 maintains internal flags so that subsequent read operations properly
10656 handle the logical position.
10657 @end itemize
10658
10659 @noindent
10660 These discrepancies have no effect on the observable behavior of
10661 Text_IO, but if a single Ada stream is shared between a C program and
10662 Ada program, or shared (using @samp{shared=yes} in the form string)
10663 between two Ada files, then the difference may be observable in some
10664 situations.
10665
10666 @node Text_IO Reading and Writing Non-Regular Files
10667 @subsection Reading and Writing Non-Regular Files
10668
10669 @noindent
10670 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10671 can be used for reading and writing.  Writing is not affected and the
10672 sequence of characters output is identical to the normal file case, but
10673 for reading, the behavior of Text_IO is modified to avoid undesirable
10674 look-ahead as follows:
10675
10676 An input file that is not a regular file is considered to have no page
10677 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10678 page mark) appearing in the file are considered to be data
10679 characters.  In particular:
10680
10681 @itemize @bullet
10682 @item
10683 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10684 following a line mark.  If a page mark appears, it will be treated as a
10685 data character.
10686
10687 @item
10688 This avoids the need to wait for an extra character to be typed or
10689 entered from the pipe to complete one of these operations.
10690
10691 @item
10692 @code{End_Of_Page} always returns @code{False}
10693
10694 @item
10695 @code{End_Of_File} will return @code{False} if there is a page mark at
10696 the end of the file.
10697 @end itemize
10698
10699 @noindent
10700 Output to non-regular files is the same as for regular files.  Page marks
10701 may be written to non-regular files using @code{New_Page}, but as noted
10702 above they will not be treated as page marks on input if the output is
10703 piped to another Ada program.
10704
10705 Another important discrepancy when reading non-regular files is that the end
10706 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10707 pressing the @key{EOT} key,
10708 then end of file
10709 is signaled once (i.e.@: the test @code{End_Of_File}
10710 will yield @code{True}, or a read will
10711 raise @code{End_Error}), but then reading can resume
10712 to read data past that end of
10713 file indication, until another end of file indication is entered.
10714
10715 @node Get_Immediate
10716 @subsection Get_Immediate
10717 @cindex Get_Immediate
10718
10719 @noindent
10720 Get_Immediate returns the next character (including control characters)
10721 from the input file.  In particular, Get_Immediate will return LF or FF
10722 characters used as line marks or page marks.  Such operations leave the
10723 file positioned past the control character, and it is thus not treated
10724 as having its normal function.  This means that page, line and column
10725 counts after this kind of Get_Immediate call are set as though the mark
10726 did not occur.  In the case where a Get_Immediate leaves the file
10727 positioned between the line mark and page mark (which is not normally
10728 possible), it is undefined whether the FF character will be treated as a
10729 page mark.
10730
10731 @node Treating Text_IO Files as Streams
10732 @subsection Treating Text_IO Files as Streams
10733 @cindex Stream files
10734
10735 @noindent
10736 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10737 as a stream.  Data written to a Text_IO file in this stream mode is
10738 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10739 16#0C# (@code{FF}), the resulting file may have non-standard
10740 format.  Similarly if read operations are used to read from a Text_IO
10741 file treated as a stream, then @code{LF} and @code{FF} characters may be
10742 skipped and the effect is similar to that described above for
10743 @code{Get_Immediate}.
10744
10745 @node Text_IO Extensions
10746 @subsection Text_IO Extensions
10747 @cindex Text_IO extensions
10748
10749 @noindent
10750 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10751 to the standard @code{Text_IO} package:
10752
10753 @itemize @bullet
10754 @item function File_Exists (Name : String) return Boolean;
10755 Determines if a file of the given name exists.
10756
10757 @item function Get_Line return String;
10758 Reads a string from the standard input file.  The value returned is exactly
10759 the length of the line that was read.
10760
10761 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10762 Similar, except that the parameter File specifies the file from which
10763 the string is to be read.
10764
10765 @end itemize
10766
10767 @node Text_IO Facilities for Unbounded Strings
10768 @subsection Text_IO Facilities for Unbounded Strings
10769 @cindex Text_IO for unbounded strings
10770 @cindex Unbounded_String, Text_IO operations
10771
10772 @noindent
10773 The package @code{Ada.Strings.Unbounded.Text_IO}
10774 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10775 subprograms useful for Text_IO operations on unbounded strings:
10776
10777 @itemize @bullet
10778
10779 @item function Get_Line (File : File_Type) return Unbounded_String;
10780 Reads a line from the specified file
10781 and returns the result as an unbounded string.
10782
10783 @item procedure Put (File : File_Type; U : Unbounded_String);
10784 Writes the value of the given unbounded string to the specified file
10785 Similar to the effect of
10786 @code{Put (To_String (U))} except that an extra copy is avoided.
10787
10788 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10789 Writes the value of the given unbounded string to the specified file,
10790 followed by a @code{New_Line}.
10791 Similar to the effect of @code{Put_Line (To_String (U))} except
10792 that an extra copy is avoided.
10793 @end itemize
10794
10795 @noindent
10796 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10797 and is optional.  If the parameter is omitted, then the standard input or
10798 output file is referenced as appropriate.
10799
10800 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10801 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10802 @code{Wide_Text_IO} functionality for unbounded wide strings.
10803
10804 @node Wide_Text_IO
10805 @section Wide_Text_IO
10806
10807 @noindent
10808 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10809 both input and output files may contain special sequences that represent
10810 wide character values.  The encoding scheme for a given file may be
10811 specified using a FORM parameter:
10812
10813 @smallexample
10814 WCEM=@var{x}
10815 @end smallexample
10816
10817 @noindent
10818 as part of the FORM string (WCEM = wide character encoding method),
10819 where @var{x} is one of the following characters
10820
10821 @table @samp
10822 @item h
10823 Hex ESC encoding
10824 @item u
10825 Upper half encoding
10826 @item s
10827 Shift-JIS encoding
10828 @item e
10829 EUC Encoding
10830 @item 8
10831 UTF-8 encoding
10832 @item b
10833 Brackets encoding
10834 @end table
10835
10836 @noindent
10837 The encoding methods match those that
10838 can be used in a source
10839 program, but there is no requirement that the encoding method used for
10840 the source program be the same as the encoding method used for files,
10841 and different files may use different encoding methods.
10842
10843 The default encoding method for the standard files, and for opened files
10844 for which no WCEM parameter is given in the FORM string matches the
10845 wide character encoding specified for the main program (the default
10846 being brackets encoding if no coding method was specified with -gnatW).
10847
10848 @table @asis
10849 @item Hex Coding
10850 In this encoding, a wide character is represented by a five character
10851 sequence:
10852
10853 @smallexample
10854 ESC a b c d
10855 @end smallexample
10856
10857 @noindent
10858 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10859 characters (using upper case letters) of the wide character code.  For
10860 example, ESC A345 is used to represent the wide character with code
10861 16#A345#.  This scheme is compatible with use of the full
10862 @code{Wide_Character} set.
10863
10864 @item Upper Half Coding
10865 The wide character with encoding 16#abcd#, where the upper bit is on
10866 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10867 16#cd#.  The second byte may never be a format control character, but is
10868 not required to be in the upper half.  This method can be also used for
10869 shift-JIS or EUC where the internal coding matches the external coding.
10870
10871 @item Shift JIS Coding
10872 A wide character is represented by a two character sequence 16#ab# and
10873 16#cd#, with the restrictions described for upper half encoding as
10874 described above.  The internal character code is the corresponding JIS
10875 character according to the standard algorithm for Shift-JIS
10876 conversion.  Only characters defined in the JIS code set table can be
10877 used with this encoding method.
10878
10879 @item EUC Coding
10880 A wide character is represented by a two character sequence 16#ab# and
10881 16#cd#, with both characters being in the upper half.  The internal
10882 character code is the corresponding JIS character according to the EUC
10883 encoding algorithm.  Only characters defined in the JIS code set table
10884 can be used with this encoding method.
10885
10886 @item UTF-8 Coding
10887 A wide character is represented using
10888 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10889 10646-1/Am.2.  Depending on the character value, the representation
10890 is a one, two, or three byte sequence:
10891
10892 @smallexample
10893 16#0000#-16#007f#: 2#0xxxxxxx#
10894 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10895 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10896 @end smallexample
10897
10898 @noindent
10899 where the xxx bits correspond to the left-padded bits of the
10900 16-bit character value.  Note that all lower half ASCII characters
10901 are represented as ASCII bytes and all upper half characters and
10902 other wide characters are represented as sequences of upper-half
10903 (The full UTF-8 scheme allows for encoding 31-bit characters as
10904 6-byte sequences, but in this implementation, all UTF-8 sequences
10905 of four or more bytes length will raise a Constraint_Error, as
10906 will all invalid UTF-8 sequences.)
10907
10908 @item Brackets Coding
10909 In this encoding, a wide character is represented by the following eight
10910 character sequence:
10911
10912 @smallexample
10913 [ " a b c d " ]
10914 @end smallexample
10915
10916 @noindent
10917 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
10918 characters (using uppercase letters) of the wide character code.  For
10919 example, @code{["A345"]} is used to represent the wide character with code
10920 @code{16#A345#}.
10921 This scheme is compatible with use of the full Wide_Character set.
10922 On input, brackets coding can also be used for upper half characters,
10923 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
10924 is only used for wide characters with a code greater than @code{16#FF#}.
10925
10926 @end table
10927
10928 @noindent
10929 For the coding schemes other than Hex and Brackets encoding,
10930 not all wide character
10931 values can be represented.  An attempt to output a character that cannot
10932 be represented using the encoding scheme for the file causes
10933 Constraint_Error to be raised.  An invalid wide character sequence on
10934 input also causes Constraint_Error to be raised.
10935
10936 @menu
10937 * Wide_Text_IO Stream Pointer Positioning::
10938 * Wide_Text_IO Reading and Writing Non-Regular Files::
10939 @end menu
10940
10941 @node Wide_Text_IO Stream Pointer Positioning
10942 @subsection Stream Pointer Positioning
10943
10944 @noindent
10945 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
10946 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
10947 case:
10948
10949 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
10950 normal lower ASCII set (i.e.@: a character in the range:
10951
10952 @smallexample @c ada
10953 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
10954 @end smallexample
10955
10956 @noindent
10957 then although the logical position of the file pointer is unchanged by
10958 the @code{Look_Ahead} call, the stream is physically positioned past the
10959 wide character sequence.  Again this is to avoid the need for buffering
10960 or backup, and all @code{Wide_Text_IO} routines check the internal
10961 indication that this situation has occurred so that this is not visible
10962 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
10963 can be observed if the wide text file shares a stream with another file.
10964
10965 @node Wide_Text_IO Reading and Writing Non-Regular Files
10966 @subsection Reading and Writing Non-Regular Files
10967
10968 @noindent
10969 As in the case of Text_IO, when a non-regular file is read, it is
10970 assumed that the file contains no page marks (any form characters are
10971 treated as data characters), and @code{End_Of_Page} always returns
10972 @code{False}.  Similarly, the end of file indication is not sticky, so
10973 it is possible to read beyond an end of file.
10974
10975 @node Stream_IO
10976 @section Stream_IO
10977
10978 @noindent
10979 A stream file is a sequence of bytes, where individual elements are
10980 written to the file as described in the Ada 95 reference manual.  The type
10981 @code{Stream_Element} is simply a byte.  There are two ways to read or
10982 write a stream file.
10983
10984 @itemize @bullet
10985 @item
10986 The operations @code{Read} and @code{Write} directly read or write a
10987 sequence of stream elements with no control information.
10988
10989 @item
10990 The stream attributes applied to a stream file transfer data in the
10991 manner described for stream attributes.
10992 @end itemize
10993
10994 @node Shared Files
10995 @section Shared Files
10996
10997 @noindent
10998 Section A.14 of the Ada 95 Reference Manual allows implementations to
10999 provide a wide variety of behavior if an attempt is made to access the
11000 same external file with two or more internal files.
11001
11002 To provide a full range of functionality, while at the same time
11003 minimizing the problems of portability caused by this implementation
11004 dependence, GNAT handles file sharing as follows:
11005
11006 @itemize @bullet
11007 @item
11008 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11009 to open two or more files with the same full name is considered an error
11010 and is not supported.  The exception @code{Use_Error} will be
11011 raised.  Note that a file that is not explicitly closed by the program
11012 remains open until the program terminates.
11013
11014 @item
11015 If the form parameter @samp{shared=no} appears in the form string, the
11016 file can be opened or created with its own separate stream identifier,
11017 regardless of whether other files sharing the same external file are
11018 opened.  The exact effect depends on how the C stream routines handle
11019 multiple accesses to the same external files using separate streams.
11020
11021 @item
11022 If the form parameter @samp{shared=yes} appears in the form string for
11023 each of two or more files opened using the same full name, the same
11024 stream is shared between these files, and the semantics are as described
11025 in Ada 95 Reference Manual, Section A.14.
11026 @end itemize
11027
11028 @noindent
11029 When a program that opens multiple files with the same name is ported
11030 from another Ada compiler to GNAT, the effect will be that
11031 @code{Use_Error} is raised.
11032
11033 The documentation of the original compiler and the documentation of the
11034 program should then be examined to determine if file sharing was
11035 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11036 and @code{Create} calls as required.
11037
11038 When a program is ported from GNAT to some other Ada compiler, no
11039 special attention is required unless the @samp{shared=@var{xxx}} form
11040 parameter is used in the program.  In this case, you must examine the
11041 documentation of the new compiler to see if it supports the required
11042 file sharing semantics, and form strings modified appropriately.  Of
11043 course it may be the case that the program cannot be ported if the
11044 target compiler does not support the required functionality.  The best
11045 approach in writing portable code is to avoid file sharing (and hence
11046 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11047 completely.
11048
11049 One common use of file sharing in Ada 83 is the use of instantiations of
11050 Sequential_IO on the same file with different types, to achieve
11051 heterogeneous input-output.  Although this approach will work in GNAT if
11052 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11053 for this purpose (using the stream attributes)
11054
11055 @node Open Modes
11056 @section Open Modes
11057
11058 @noindent
11059 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11060 using the mode shown in the following table:
11061
11062 @sp 2
11063 @center @code{Open} and @code{Create} Call Modes
11064 @smallexample
11065                                @b{OPEN }           @b{CREATE}
11066 Append_File                    "r+"             "w+"
11067 In_File                        "r"              "w+"
11068 Out_File (Direct_IO)           "r+"             "w"
11069 Out_File (all other cases)     "w"              "w"
11070 Inout_File                     "r+"             "w+"
11071 @end smallexample
11072
11073 @noindent
11074 If text file translation is required, then either @samp{b} or @samp{t}
11075 is added to the mode, depending on the setting of Text.  Text file
11076 translation refers to the mapping of CR/LF sequences in an external file
11077 to LF characters internally.  This mapping only occurs in DOS and
11078 DOS-like systems, and is not relevant to other systems.
11079
11080 A special case occurs with Stream_IO@.  As shown in the above table, the
11081 file is initially opened in @samp{r} or @samp{w} mode for the
11082 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11083 subsequently requires switching from reading to writing or vice-versa,
11084 then the file is reopened in @samp{r+} mode to permit the required operation.
11085
11086 @node Operations on C Streams
11087 @section Operations on C Streams
11088 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11089 access to the C library functions for operations on C streams:
11090
11091 @smallexample @c adanocomment
11092 package Interfaces.C_Streams is
11093   -- Note: the reason we do not use the types that are in
11094   -- Interfaces.C is that we want to avoid dragging in the
11095   -- code in this unit if possible.
11096   subtype chars is System.Address;
11097   -- Pointer to null-terminated array of characters
11098   subtype FILEs is System.Address;
11099   -- Corresponds to the C type FILE*
11100   subtype voids is System.Address;
11101   -- Corresponds to the C type void*
11102   subtype int is Integer;
11103   subtype long is Long_Integer;
11104   -- Note: the above types are subtypes deliberately, and it
11105   -- is part of this spec that the above correspondences are
11106   -- guaranteed.  This means that it is legitimate to, for
11107   -- example, use Integer instead of int.  We provide these
11108   -- synonyms for clarity, but in some cases it may be
11109   -- convenient to use the underlying types (for example to
11110   -- avoid an unnecessary dependency of a spec on the spec
11111   -- of this unit).
11112   type size_t is mod 2 ** Standard'Address_Size;
11113   NULL_Stream : constant FILEs;
11114   -- Value returned (NULL in C) to indicate an
11115   -- fdopen/fopen/tmpfile error
11116   ----------------------------------
11117   -- Constants Defined in stdio.h --
11118   ----------------------------------
11119   EOF : constant int;
11120   -- Used by a number of routines to indicate error or
11121   -- end of file
11122   IOFBF : constant int;
11123   IOLBF : constant int;
11124   IONBF : constant int;
11125   -- Used to indicate buffering mode for setvbuf call
11126   SEEK_CUR : constant int;
11127   SEEK_END : constant int;
11128   SEEK_SET : constant int;
11129   -- Used to indicate origin for fseek call
11130   function stdin return FILEs;
11131   function stdout return FILEs;
11132   function stderr return FILEs;
11133   -- Streams associated with standard files
11134   --------------------------
11135   -- Standard C functions --
11136   --------------------------
11137   -- The functions selected below are ones that are
11138   -- available in DOS, OS/2, UNIX and Xenix (but not
11139   -- necessarily in ANSI C).  These are very thin interfaces
11140   -- which copy exactly the C headers.  For more
11141   -- documentation on these functions, see the Microsoft C
11142   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11143   -- ISBN 1-55615-225-6), which includes useful information
11144   -- on system compatibility.
11145   procedure clearerr (stream : FILEs);
11146   function fclose (stream : FILEs) return int;
11147   function fdopen (handle : int; mode : chars) return FILEs;
11148   function feof (stream : FILEs) return int;
11149   function ferror (stream : FILEs) return int;
11150   function fflush (stream : FILEs) return int;
11151   function fgetc (stream : FILEs) return int;
11152   function fgets (strng : chars; n : int; stream : FILEs)
11153       return chars;
11154   function fileno (stream : FILEs) return int;
11155   function fopen (filename : chars; Mode : chars)
11156       return FILEs;
11157   -- Note: to maintain target independence, use
11158   -- text_translation_required, a boolean variable defined in
11159   -- a-sysdep.c to deal with the target dependent text
11160   -- translation requirement.  If this variable is set,
11161   -- then  b/t should be appended to the standard mode
11162   -- argument to set the text translation mode off or on
11163   -- as required.
11164   function fputc (C : int; stream : FILEs) return int;
11165   function fputs (Strng : chars; Stream : FILEs) return int;
11166   function fread
11167      (buffer : voids;
11168       size : size_t;
11169       count : size_t;
11170       stream : FILEs)
11171       return size_t;
11172   function freopen
11173      (filename : chars;
11174       mode : chars;
11175       stream : FILEs)
11176       return FILEs;
11177   function fseek
11178      (stream : FILEs;
11179       offset : long;
11180       origin : int)
11181       return int;
11182   function ftell (stream : FILEs) return long;
11183   function fwrite
11184      (buffer : voids;
11185       size : size_t;
11186       count : size_t;
11187       stream : FILEs)
11188       return size_t;
11189   function isatty (handle : int) return int;
11190   procedure mktemp (template : chars);
11191   -- The return value (which is just a pointer to template)
11192   -- is discarded
11193   procedure rewind (stream : FILEs);
11194   function rmtmp return int;
11195   function setvbuf
11196      (stream : FILEs;
11197       buffer : chars;
11198       mode : int;
11199       size : size_t)
11200       return int;
11201
11202   function tmpfile return FILEs;
11203   function ungetc (c : int; stream : FILEs) return int;
11204   function unlink (filename : chars) return int;
11205   ---------------------
11206   -- Extra functions --
11207   ---------------------
11208   -- These functions supply slightly thicker bindings than
11209   -- those above.  They are derived from functions in the
11210   -- C Run-Time Library, but may do a bit more work than
11211   -- just directly calling one of the Library functions.
11212   function is_regular_file (handle : int) return int;
11213   -- Tests if given handle is for a regular file (result 1)
11214   -- or for a non-regular file (pipe or device, result 0).
11215   ---------------------------------
11216   -- Control of Text/Binary Mode --
11217   ---------------------------------
11218   -- If text_translation_required is true, then the following
11219   -- functions may be used to dynamically switch a file from
11220   -- binary to text mode or vice versa.  These functions have
11221   -- no effect if text_translation_required is false (i.e.  in
11222   -- normal UNIX mode).  Use fileno to get a stream handle.
11223   procedure set_binary_mode (handle : int);
11224   procedure set_text_mode (handle : int);
11225   ----------------------------
11226   -- Full Path Name support --
11227   ----------------------------
11228   procedure full_name (nam : chars; buffer : chars);
11229   -- Given a NUL terminated string representing a file
11230   -- name, returns in buffer a NUL terminated string
11231   -- representing the full path name for the file name.
11232   -- On systems where it is relevant the   drive is also
11233   -- part of the full path name.  It is the responsibility
11234   -- of the caller to pass an actual parameter for buffer
11235   -- that is big enough for any full path name.  Use
11236   -- max_path_len given below as the size of buffer.
11237   max_path_len : integer;
11238   -- Maximum length of an allowable full path name on the
11239   -- system, including a terminating NUL character.
11240 end Interfaces.C_Streams;
11241 @end smallexample
11242
11243 @node Interfacing to C Streams
11244 @section Interfacing to C Streams
11245
11246 @noindent
11247 The packages in this section permit interfacing Ada files to C Stream
11248 operations.
11249
11250 @smallexample @c ada
11251  with Interfaces.C_Streams;
11252  package Ada.Sequential_IO.C_Streams is
11253     function C_Stream (F : File_Type)
11254        return Interfaces.C_Streams.FILEs;
11255     procedure Open
11256       (File : in out File_Type;
11257        Mode : in File_Mode;
11258        C_Stream : in Interfaces.C_Streams.FILEs;
11259        Form : in String := "");
11260  end Ada.Sequential_IO.C_Streams;
11261
11262   with Interfaces.C_Streams;
11263   package Ada.Direct_IO.C_Streams is
11264      function C_Stream (F : File_Type)
11265         return Interfaces.C_Streams.FILEs;
11266      procedure Open
11267        (File : in out File_Type;
11268         Mode : in File_Mode;
11269         C_Stream : in Interfaces.C_Streams.FILEs;
11270         Form : in String := "");
11271   end Ada.Direct_IO.C_Streams;
11272
11273   with Interfaces.C_Streams;
11274   package Ada.Text_IO.C_Streams is
11275      function C_Stream (F : File_Type)
11276         return Interfaces.C_Streams.FILEs;
11277      procedure Open
11278        (File : in out File_Type;
11279         Mode : in File_Mode;
11280         C_Stream : in Interfaces.C_Streams.FILEs;
11281         Form : in String := "");
11282   end Ada.Text_IO.C_Streams;
11283
11284   with Interfaces.C_Streams;
11285   package Ada.Wide_Text_IO.C_Streams is
11286      function C_Stream (F : File_Type)
11287         return Interfaces.C_Streams.FILEs;
11288      procedure Open
11289        (File : in out File_Type;
11290         Mode : in File_Mode;
11291         C_Stream : in Interfaces.C_Streams.FILEs;
11292         Form : in String := "");
11293  end Ada.Wide_Text_IO.C_Streams;
11294
11295  with Interfaces.C_Streams;
11296  package Ada.Stream_IO.C_Streams is
11297     function C_Stream (F : File_Type)
11298        return Interfaces.C_Streams.FILEs;
11299     procedure Open
11300       (File : in out File_Type;
11301        Mode : in File_Mode;
11302        C_Stream : in Interfaces.C_Streams.FILEs;
11303        Form : in String := "");
11304  end Ada.Stream_IO.C_Streams;
11305 @end smallexample
11306
11307 @noindent
11308 In each of these five packages, the @code{C_Stream} function obtains the
11309 @code{FILE} pointer from a currently opened Ada file.  It is then
11310 possible to use the @code{Interfaces.C_Streams} package to operate on
11311 this stream, or the stream can be passed to a C program which can
11312 operate on it directly.  Of course the program is responsible for
11313 ensuring that only appropriate sequences of operations are executed.
11314
11315 One particular use of relevance to an Ada program is that the
11316 @code{setvbuf} function can be used to control the buffering of the
11317 stream used by an Ada file.  In the absence of such a call the standard
11318 default buffering is used.
11319
11320 The @code{Open} procedures in these packages open a file giving an
11321 existing C Stream instead of a file name.  Typically this stream is
11322 imported from a C program, allowing an Ada file to operate on an
11323 existing C file.
11324
11325 @node The GNAT Library
11326 @chapter The GNAT Library
11327
11328 @noindent
11329 The GNAT library contains a number of general and special purpose packages.
11330 It represents functionality that the GNAT developers have found useful, and
11331 which is made available to GNAT users.  The packages described here are fully
11332 supported, and upwards compatibility will be maintained in future releases,
11333 so you can use these facilities with the confidence that the same functionality
11334 will be available in future releases.
11335
11336 The chapter here simply gives a brief summary of the facilities available.
11337 The full documentation is found in the spec file for the package.  The full
11338 sources of these library packages, including both spec and body, are provided
11339 with all GNAT releases.  For example, to find out the full specifications of
11340 the SPITBOL pattern matching capability, including a full tutorial and
11341 extensive examples, look in the @file{g-spipat.ads} file in the library.
11342
11343 For each entry here, the package name (as it would appear in a @code{with}
11344 clause) is given, followed by the name of the corresponding spec file in
11345 parentheses.  The packages are children in four hierarchies, @code{Ada},
11346 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11347 GNAT-specific hierarchy.
11348
11349 Note that an application program should only use packages in one of these
11350 four hierarchies if the package is defined in the Ada Reference Manual,
11351 or is listed in this section of the GNAT Programmers Reference Manual.
11352 All other units should be considered internal implementation units and
11353 should not be directly @code{with}'ed by application code.  The use of
11354 a @code{with} statement that references one of these internal implementation
11355 units makes an application potentially dependent on changes in versions
11356 of GNAT, and will generate a warning message.
11357
11358 @menu
11359 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11360 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11361 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11362 * Ada.Command_Line.Remove (a-colire.ads)::
11363 * Ada.Command_Line.Environment (a-colien.ads)::
11364 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11365 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11366 * Ada.Exceptions.Traceback (a-exctra.ads)::
11367 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11368 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11369 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11370 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11371 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11372 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11373 * GNAT.Array_Split (g-arrspl.ads)::
11374 * GNAT.AWK (g-awk.ads)::
11375 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11376 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11377 * GNAT.Bubble_Sort (g-bubsor.ads)::
11378 * GNAT.Bubble_Sort_A (g-busora.ads)::
11379 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11380 * GNAT.Calendar (g-calend.ads)::
11381 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11382 * GNAT.CRC32 (g-crc32.ads)::
11383 * GNAT.Case_Util (g-casuti.ads)::
11384 * GNAT.CGI (g-cgi.ads)::
11385 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11386 * GNAT.CGI.Debug (g-cgideb.ads)::
11387 * GNAT.Command_Line (g-comlin.ads)::
11388 * GNAT.Compiler_Version (g-comver.ads)::
11389 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11390 * GNAT.Current_Exception (g-curexc.ads)::
11391 * GNAT.Debug_Pools (g-debpoo.ads)::
11392 * GNAT.Debug_Utilities (g-debuti.ads)::
11393 * GNAT.Directory_Operations (g-dirope.ads)::
11394 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11395 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11396 * GNAT.Exception_Actions (g-excact.ads)::
11397 * GNAT.Exception_Traces (g-exctra.ads)::
11398 * GNAT.Exceptions (g-except.ads)::
11399 * GNAT.Expect (g-expect.ads)::
11400 * GNAT.Float_Control (g-flocon.ads)::
11401 * GNAT.Heap_Sort (g-heasor.ads)::
11402 * GNAT.Heap_Sort_A (g-hesora.ads)::
11403 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11404 * GNAT.HTable (g-htable.ads)::
11405 * GNAT.IO (g-io.ads)::
11406 * GNAT.IO_Aux (g-io_aux.ads)::
11407 * GNAT.Lock_Files (g-locfil.ads)::
11408 * GNAT.MD5 (g-md5.ads)::
11409 * GNAT.Memory_Dump (g-memdum.ads)::
11410 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11411 * GNAT.OS_Lib (g-os_lib.ads)::
11412 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11413 * GNAT.Regexp (g-regexp.ads)::
11414 * GNAT.Registry (g-regist.ads)::
11415 * GNAT.Regpat (g-regpat.ads)::
11416 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11417 * GNAT.Semaphores (g-semaph.ads)::
11418 * GNAT.Signals (g-signal.ads)::
11419 * GNAT.Sockets (g-socket.ads)::
11420 * GNAT.Source_Info (g-souinf.ads)::
11421 * GNAT.Spell_Checker (g-speche.ads)::
11422 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11423 * GNAT.Spitbol (g-spitbo.ads)::
11424 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11425 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11426 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11427 * GNAT.Strings (g-string.ads)::
11428 * GNAT.String_Split (g-strspl.ads)::
11429 * GNAT.Table (g-table.ads)::
11430 * GNAT.Task_Lock (g-tasloc.ads)::
11431 * GNAT.Threads (g-thread.ads)::
11432 * GNAT.Traceback (g-traceb.ads)::
11433 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11434 * GNAT.Wide_String_Split (g-wistsp.ads)::
11435 * Interfaces.C.Extensions (i-cexten.ads)::
11436 * Interfaces.C.Streams (i-cstrea.ads)::
11437 * Interfaces.CPP (i-cpp.ads)::
11438 * Interfaces.Os2lib (i-os2lib.ads)::
11439 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11440 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11441 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11442 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11443 * Interfaces.VxWorks (i-vxwork.ads)::
11444 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11445 * System.Address_Image (s-addima.ads)::
11446 * System.Assertions (s-assert.ads)::
11447 * System.Memory (s-memory.ads)::
11448 * System.Partition_Interface (s-parint.ads)::
11449 * System.Restrictions (s-restri.ads)::
11450 * System.Rident (s-rident.ads)::
11451 * System.Task_Info (s-tasinf.ads)::
11452 * System.Wch_Cnv (s-wchcnv.ads)::
11453 * System.Wch_Con (s-wchcon.ads)::
11454 @end menu
11455
11456 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11457 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11458 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11459 @cindex Latin_9 constants for Character
11460
11461 @noindent
11462 This child of @code{Ada.Characters}
11463 provides a set of definitions corresponding to those in the
11464 RM-defined package @code{Ada.Characters.Latin_1} but with the
11465 few modifications required for @code{Latin-9}
11466 The provision of such a package
11467 is specifically authorized by the Ada Reference Manual
11468 (RM A.3(27)).
11469
11470 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11471 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11472 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11473 @cindex Latin_1 constants for Wide_Character
11474
11475 @noindent
11476 This child of @code{Ada.Characters}
11477 provides a set of definitions corresponding to those in the
11478 RM-defined package @code{Ada.Characters.Latin_1} but with the
11479 types of the constants being @code{Wide_Character}
11480 instead of @code{Character}.  The provision of such a package
11481 is specifically authorized by the Ada Reference Manual
11482 (RM A.3(27)).
11483
11484 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11485 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11486 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11487 @cindex Latin_9 constants for Wide_Character
11488
11489 @noindent
11490 This child of @code{Ada.Characters}
11491 provides a set of definitions corresponding to those in the
11492 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11493 types of the constants being @code{Wide_Character}
11494 instead of @code{Character}.  The provision of such a package
11495 is specifically authorized by the Ada Reference Manual
11496 (RM A.3(27)).
11497
11498 @node Ada.Command_Line.Remove (a-colire.ads)
11499 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11500 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11501 @cindex Removing command line arguments
11502 @cindex Command line, argument removal
11503
11504 @noindent
11505 This child of @code{Ada.Command_Line}
11506 provides a mechanism for logically removing
11507 arguments from the argument list.  Once removed, an argument is not visible
11508 to further calls on the subprograms in @code{Ada.Command_Line} will not
11509 see the removed argument.
11510
11511 @node Ada.Command_Line.Environment (a-colien.ads)
11512 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11513 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11514 @cindex Environment entries
11515
11516 @noindent
11517 This child of @code{Ada.Command_Line}
11518 provides a mechanism for obtaining environment values on systems
11519 where this concept makes sense.
11520
11521 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11522 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11523 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11524 @cindex C Streams, Interfacing with Direct_IO
11525
11526 @noindent
11527 This package provides subprograms that allow interfacing between
11528 C streams and @code{Direct_IO}.  The stream identifier can be
11529 extracted from a file opened on the Ada side, and an Ada file
11530 can be constructed from a stream opened on the C side.
11531
11532 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11533 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11534 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11535 @cindex Null_Occurrence, testing for
11536
11537 @noindent
11538 This child subprogram provides a way of testing for the null
11539 exception occurrence (@code{Null_Occurrence}) without raising
11540 an exception.
11541
11542 @node Ada.Exceptions.Traceback (a-exctra.ads)
11543 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11544 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11545 @cindex Traceback for Exception Occurrence
11546
11547 @noindent
11548 This child package provides the subprogram (@code{Tracebacks}) to
11549 give a traceback array of addresses based on an exception
11550 occurrence.
11551
11552 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11553 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11554 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11555 @cindex C Streams, Interfacing with Sequential_IO
11556
11557 @noindent
11558 This package provides subprograms that allow interfacing between
11559 C streams and @code{Sequential_IO}.  The stream identifier can be
11560 extracted from a file opened on the Ada side, and an Ada file
11561 can be constructed from a stream opened on the C side.
11562
11563 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11564 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11565 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11566 @cindex C Streams, Interfacing with Stream_IO
11567
11568 @noindent
11569 This package provides subprograms that allow interfacing between
11570 C streams and @code{Stream_IO}.  The stream identifier can be
11571 extracted from a file opened on the Ada side, and an Ada file
11572 can be constructed from a stream opened on the C side.
11573
11574 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11575 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11576 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11577 @cindex @code{Unbounded_String}, IO support
11578 @cindex @code{Text_IO}, extensions for unbounded strings
11579
11580 @noindent
11581 This package provides subprograms for Text_IO for unbounded
11582 strings, avoiding the necessity for an intermediate operation
11583 with ordinary strings.
11584
11585 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11586 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11587 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11588 @cindex @code{Unbounded_Wide_String}, IO support
11589 @cindex @code{Text_IO}, extensions for unbounded wide strings
11590
11591 @noindent
11592 This package provides subprograms for Text_IO for unbounded
11593 wide strings, avoiding the necessity for an intermediate operation
11594 with ordinary wide strings.
11595
11596 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11597 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11598 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11599 @cindex C Streams, Interfacing with @code{Text_IO}
11600
11601 @noindent
11602 This package provides subprograms that allow interfacing between
11603 C streams and @code{Text_IO}.  The stream identifier can be
11604 extracted from a file opened on the Ada side, and an Ada file
11605 can be constructed from a stream opened on the C side.
11606
11607 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11608 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11609 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11610 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11611
11612 @noindent
11613 This package provides subprograms that allow interfacing between
11614 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11615 extracted from a file opened on the Ada side, and an Ada file
11616 can be constructed from a stream opened on the C side.
11617
11618 @node GNAT.Array_Split (g-arrspl.ads)
11619 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11620 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11621 @cindex Array splitter
11622
11623 @noindent
11624 Useful array-manipulation routines: given a set of separators, split
11625 an array wherever the separators appear, and provide direct access
11626 to the resulting slices.
11627
11628 @node GNAT.AWK (g-awk.ads)
11629 @section @code{GNAT.AWK} (@file{g-awk.ads})
11630 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11631 @cindex Parsing
11632 @cindex AWK
11633
11634 @noindent
11635 Provides AWK-like parsing functions, with an easy interface for parsing one
11636 or more files containing formatted data.  The file is viewed as a database
11637 where each record is a line and a field is a data element in this line.
11638
11639 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11640 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11641 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11642 @cindex Parsing
11643 @cindex Bounded Buffers
11644
11645 @noindent
11646 Provides a concurrent generic bounded buffer abstraction.  Instances are
11647 useful directly or as parts of the implementations of other abstractions,
11648 such as mailboxes.
11649
11650 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11651 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11652 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11653 @cindex Parsing
11654 @cindex Mailboxes
11655
11656 @noindent
11657 Provides a thread-safe asynchronous intertask mailbox communication facility.
11658
11659 @node GNAT.Bubble_Sort (g-bubsor.ads)
11660 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11661 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11662 @cindex Sorting
11663 @cindex Bubble sort
11664
11665 @noindent
11666 Provides a general implementation of bubble sort usable for sorting arbitrary
11667 data items.  Exchange and comparison procedures are provided by passing
11668 access-to-procedure values.
11669
11670 @node GNAT.Bubble_Sort_A (g-busora.ads)
11671 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11672 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11673 @cindex Sorting
11674 @cindex Bubble sort
11675
11676 @noindent
11677 Provides a general implementation of bubble sort usable for sorting arbitrary
11678 data items.  Move and comparison procedures are provided by passing
11679 access-to-procedure values. This is an older version, retained for
11680 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11681
11682 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11683 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11684 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11685 @cindex Sorting
11686 @cindex Bubble sort
11687
11688 @noindent
11689 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11690 are provided as generic parameters, this improves efficiency, especially
11691 if the procedures can be inlined, at the expense of duplicating code for
11692 multiple instantiations.
11693
11694 @node GNAT.Calendar (g-calend.ads)
11695 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11696 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11697 @cindex @code{Calendar}
11698
11699 @noindent
11700 Extends the facilities provided by @code{Ada.Calendar} to include handling
11701 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11702 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11703 C @code{timeval} format.
11704
11705 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11706 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11707 @cindex @code{Calendar}
11708 @cindex Time
11709 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11710
11711 @node GNAT.CRC32 (g-crc32.ads)
11712 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11713 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11714 @cindex CRC32
11715 @cindex Cyclic Redundancy Check
11716
11717 @noindent
11718 This package implements the CRC-32 algorithm.  For a full description
11719 of this algorithm see
11720 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11721 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11722 Aug.@: 1988.  Sarwate, D.V@.
11723
11724 @noindent
11725 Provides an extended capability for formatted output of time values with
11726 full user control over the format.  Modeled on the GNU Date specification.
11727
11728 @node GNAT.Case_Util (g-casuti.ads)
11729 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11730 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11731 @cindex Casing utilities
11732 @cindex Character handling (@code{GNAT.Case_Util})
11733
11734 @noindent
11735 A set of simple routines for handling upper and lower casing of strings
11736 without the overhead of the full casing tables
11737 in @code{Ada.Characters.Handling}.
11738
11739 @node GNAT.CGI (g-cgi.ads)
11740 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11741 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11742 @cindex CGI (Common Gateway Interface)
11743
11744 @noindent
11745 This is a package for interfacing a GNAT program with a Web server via the
11746 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11747 parameters, which are a set of key/value pairs sent by the Web server.  It
11748 builds a table whose index is the key and provides some services to deal
11749 with this table.
11750
11751 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11752 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11753 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11754 @cindex CGI (Common Gateway Interface) cookie support
11755 @cindex Cookie support in CGI
11756
11757 @noindent
11758 This is a package to interface a GNAT program with a Web server via the
11759 Common Gateway Interface (CGI).  It exports services to deal with Web
11760 cookies (piece of information kept in the Web client software).
11761
11762 @node GNAT.CGI.Debug (g-cgideb.ads)
11763 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11764 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11765 @cindex CGI (Common Gateway Interface) debugging
11766
11767 @noindent
11768 This is a package to help debugging CGI (Common Gateway Interface)
11769 programs written in Ada.
11770
11771 @node GNAT.Command_Line (g-comlin.ads)
11772 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11773 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11774 @cindex Command line
11775
11776 @noindent
11777 Provides a high level interface to @code{Ada.Command_Line} facilities,
11778 including the ability to scan for named switches with optional parameters
11779 and expand file names using wild card notations.
11780
11781 @node GNAT.Compiler_Version (g-comver.ads)
11782 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11783 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11784 @cindex Compiler Version
11785 @cindex Version, of compiler
11786
11787 @noindent
11788 Provides a routine for obtaining the version of the compiler used to
11789 compile the program. More accurately this is the version of the binder
11790 used to bind the program (this will normally be the same as the version
11791 of the compiler if a consistent tool set is used to compile all units
11792 of a partition).
11793
11794 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11795 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11796 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11797 @cindex Interrupt
11798
11799 @noindent
11800 Provides a simple interface to handle Ctrl-C keyboard events.
11801
11802 @node GNAT.Current_Exception (g-curexc.ads)
11803 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11804 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11805 @cindex Current exception
11806 @cindex Exception retrieval
11807
11808 @noindent
11809 Provides access to information on the current exception that has been raised
11810 without the need for using the Ada-95 exception choice parameter specification
11811 syntax.  This is particularly useful in simulating typical facilities for
11812 obtaining information about exceptions provided by Ada 83 compilers.
11813
11814 @node GNAT.Debug_Pools (g-debpoo.ads)
11815 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11816 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11817 @cindex Debugging
11818 @cindex Debug pools
11819 @cindex Memory corruption debugging
11820
11821 @noindent
11822 Provide a debugging storage pools that helps tracking memory corruption
11823 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11824 the @cite{GNAT User's Guide}.
11825
11826 @node GNAT.Debug_Utilities (g-debuti.ads)
11827 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11828 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11829 @cindex Debugging
11830
11831 @noindent
11832 Provides a few useful utilities for debugging purposes, including conversion
11833 to and from string images of address values. Supports both C and Ada formats
11834 for hexadecimal literals.
11835
11836 @node GNAT.Directory_Operations (g-dirope.ads)
11837 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11838 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11839 @cindex Directory operations
11840
11841 @noindent
11842 Provides a set of routines for manipulating directories, including changing
11843 the current directory, making new directories, and scanning the files in a
11844 directory.
11845
11846 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11847 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11848 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11849 @cindex Hash tables
11850
11851 @noindent
11852 A generic implementation of hash tables that can be used to hash arbitrary
11853 data.  Provided in two forms, a simple form with built in hash functions,
11854 and a more complex form in which the hash function is supplied.
11855
11856 @noindent
11857 This package provides a facility similar to that of @code{GNAT.HTable},
11858 except that this package declares a type that can be used to define
11859 dynamic instances of the hash table, while an instantiation of
11860 @code{GNAT.HTable} creates a single instance of the hash table.
11861
11862 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11863 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11864 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11865 @cindex Table implementation
11866 @cindex Arrays, extendable
11867
11868 @noindent
11869 A generic package providing a single dimension array abstraction where the
11870 length of the array can be dynamically modified.
11871
11872 @noindent
11873 This package provides a facility similar to that of @code{GNAT.Table},
11874 except that this package declares a type that can be used to define
11875 dynamic instances of the table, while an instantiation of
11876 @code{GNAT.Table} creates a single instance of the table type.
11877
11878 @node GNAT.Exception_Actions (g-excact.ads)
11879 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11880 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11881 @cindex Exception actions
11882
11883 @noindent
11884 Provides callbacks when an exception is raised. Callbacks can be registered
11885 for specific exceptions, or when any exception is raised. This
11886 can be used for instance to force a core dump to ease debugging.
11887
11888 @node GNAT.Exception_Traces (g-exctra.ads)
11889 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11890 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11891 @cindex Exception traces
11892 @cindex Debugging
11893
11894 @noindent
11895 Provides an interface allowing to control automatic output upon exception
11896 occurrences.
11897
11898 @node GNAT.Exceptions (g-except.ads)
11899 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11900 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11901 @cindex Exceptions, Pure
11902 @cindex Pure packages, exceptions
11903
11904 @noindent
11905 Normally it is not possible to raise an exception with
11906 a message from a subprogram in a pure package, since the
11907 necessary types and subprograms are in @code{Ada.Exceptions}
11908 which is not a pure unit. @code{GNAT.Exceptions} provides a
11909 facility for getting around this limitation for a few
11910 predefined exceptions, and for example allow raising
11911 @code{Constraint_Error} with a message from a pure subprogram.
11912
11913 @node GNAT.Expect (g-expect.ads)
11914 @section @code{GNAT.Expect} (@file{g-expect.ads})
11915 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
11916
11917 @noindent
11918 Provides a set of subprograms similar to what is available
11919 with the standard Tcl Expect tool.
11920 It allows you to easily spawn and communicate with an external process.
11921 You can send commands or inputs to the process, and compare the output
11922 with some expected regular expression. Currently @code{GNAT.Expect}
11923 is implemented on all native GNAT ports except for OpenVMS@.
11924 It is not implemented for cross ports, and in particular is not
11925 implemented for VxWorks or LynxOS@.
11926
11927 @node GNAT.Float_Control (g-flocon.ads)
11928 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
11929 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
11930 @cindex Floating-Point Processor
11931
11932 @noindent
11933 Provides an interface for resetting the floating-point processor into the
11934 mode required for correct semantic operation in Ada.  Some third party
11935 library calls may cause this mode to be modified, and the Reset procedure
11936 in this package can be used to reestablish the required mode.
11937
11938 @node GNAT.Heap_Sort (g-heasor.ads)
11939 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11940 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11941 @cindex Sorting
11942
11943 @noindent
11944 Provides a general implementation of heap sort usable for sorting arbitrary
11945 data items. Exchange and comparison procedures are provided by passing
11946 access-to-procedure values.  The algorithm used is a modified heap sort
11947 that performs approximately N*log(N) comparisons in the worst case.
11948
11949 @node GNAT.Heap_Sort_A (g-hesora.ads)
11950 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11951 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11952 @cindex Sorting
11953
11954 @noindent
11955 Provides a general implementation of heap sort usable for sorting arbitrary
11956 data items. Move and comparison procedures are provided by passing
11957 access-to-procedure values.  The algorithm used is a modified heap sort
11958 that performs approximately N*log(N) comparisons in the worst case.
11959 This differs from @code{GNAT.Heap_Sort} in having a less convenient
11960 interface, but may be slightly more efficient.
11961
11962 @node GNAT.Heap_Sort_G (g-hesorg.ads)
11963 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11964 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11965 @cindex Sorting
11966
11967 @noindent
11968 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
11969 are provided as generic parameters, this improves efficiency, especially
11970 if the procedures can be inlined, at the expense of duplicating code for
11971 multiple instantiations.
11972
11973 @node GNAT.HTable (g-htable.ads)
11974 @section @code{GNAT.HTable} (@file{g-htable.ads})
11975 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
11976 @cindex Hash tables
11977
11978 @noindent
11979 A generic implementation of hash tables that can be used to hash arbitrary
11980 data.  Provides two approaches, one a simple static approach, and the other
11981 allowing arbitrary dynamic hash tables.
11982
11983 @node GNAT.IO (g-io.ads)
11984 @section @code{GNAT.IO} (@file{g-io.ads})
11985 @cindex @code{GNAT.IO} (@file{g-io.ads})
11986 @cindex Simple I/O
11987 @cindex Input/Output facilities
11988
11989 @noindent
11990 A simple preelaborable input-output package that provides a subset of
11991 simple Text_IO functions for reading characters and strings from
11992 Standard_Input, and writing characters, strings and integers to either
11993 Standard_Output or Standard_Error.
11994
11995 @node GNAT.IO_Aux (g-io_aux.ads)
11996 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
11997 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
11998 @cindex Text_IO
11999 @cindex Input/Output facilities
12000
12001 Provides some auxiliary functions for use with Text_IO, including a test
12002 for whether a file exists, and functions for reading a line of text.
12003
12004 @node GNAT.Lock_Files (g-locfil.ads)
12005 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12006 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12007 @cindex File locking
12008 @cindex Locking using files
12009
12010 @noindent
12011 Provides a general interface for using files as locks.  Can be used for
12012 providing program level synchronization.
12013
12014 @node GNAT.MD5 (g-md5.ads)
12015 @section @code{GNAT.MD5} (@file{g-md5.ads})
12016 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12017 @cindex Message Digest MD5
12018
12019 @noindent
12020 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12021
12022 @node GNAT.Memory_Dump (g-memdum.ads)
12023 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12024 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12025 @cindex Dump Memory
12026
12027 @noindent
12028 Provides a convenient routine for dumping raw memory to either the
12029 standard output or standard error files. Uses GNAT.IO for actual
12030 output.
12031
12032 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12033 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12034 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12035 @cindex Exception, obtaining most recent
12036
12037 @noindent
12038 Provides access to the most recently raised exception.  Can be used for
12039 various logging purposes, including duplicating functionality of some
12040 Ada 83 implementation dependent extensions.
12041
12042 @node GNAT.OS_Lib (g-os_lib.ads)
12043 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12044 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12045 @cindex Operating System interface
12046 @cindex Spawn capability
12047
12048 @noindent
12049 Provides a range of target independent operating system interface functions,
12050 including time/date management, file operations, subprocess management,
12051 including a portable spawn procedure, and access to environment variables
12052 and error return codes.
12053
12054 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12055 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12056 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12057 @cindex Hash functions
12058
12059 @noindent
12060 Provides a generator of static minimal perfect hash functions. No
12061 collisions occur and each item can be retrieved from the table in one
12062 probe (perfect property). The hash table size corresponds to the exact
12063 size of the key set and no larger (minimal property). The key set has to
12064 be know in advance (static property). The hash functions are also order
12065 preservering. If w2 is inserted after w1 in the generator, their
12066 hashcode are in the same order. These hashing functions are very
12067 convenient for use with realtime applications.
12068
12069 @node GNAT.Regexp (g-regexp.ads)
12070 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12071 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12072 @cindex Regular expressions
12073 @cindex Pattern matching
12074
12075 @noindent
12076 A simple implementation of regular expressions, using a subset of regular
12077 expression syntax copied from familiar Unix style utilities.  This is the
12078 simples of the three pattern matching packages provided, and is particularly
12079 suitable for ``file globbing'' applications.
12080
12081 @node GNAT.Registry (g-regist.ads)
12082 @section @code{GNAT.Registry} (@file{g-regist.ads})
12083 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12084 @cindex Windows Registry
12085
12086 @noindent
12087 This is a high level binding to the Windows registry.  It is possible to
12088 do simple things like reading a key value, creating a new key.  For full
12089 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12090 package provided with the Win32Ada binding
12091
12092 @node GNAT.Regpat (g-regpat.ads)
12093 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12094 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12095 @cindex Regular expressions
12096 @cindex Pattern matching
12097
12098 @noindent
12099 A complete implementation of Unix-style regular expression matching, copied
12100 from the original V7 style regular expression library written in C by
12101 Henry Spencer (and binary compatible with this C library).
12102
12103 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12104 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12105 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12106 @cindex Secondary Stack Info
12107
12108 @noindent
12109 Provide the capability to query the high water mark of the current task's
12110 secondary stack.
12111
12112 @node GNAT.Semaphores (g-semaph.ads)
12113 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12114 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12115 @cindex Semaphores
12116
12117 @noindent
12118 Provides classic counting and binary semaphores using protected types.
12119
12120 @node GNAT.Signals (g-signal.ads)
12121 @section @code{GNAT.Signals} (@file{g-signal.ads})
12122 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12123 @cindex Signals
12124
12125 @noindent
12126 Provides the ability to manipulate the blocked status of signals on supported
12127 targets.
12128
12129 @node GNAT.Sockets (g-socket.ads)
12130 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12131 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12132 @cindex Sockets
12133
12134 @noindent
12135 A high level and portable interface to develop sockets based applications.
12136 This package is based on the sockets thin binding found in
12137 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12138 on all native GNAT ports except for OpenVMS@.  It is not implemented
12139 for the LynxOS@ cross port.
12140
12141 @node GNAT.Source_Info (g-souinf.ads)
12142 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12143 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12144 @cindex Source Information
12145
12146 @noindent
12147 Provides subprograms that give access to source code information known at
12148 compile time, such as the current file name and line number.
12149
12150 @node GNAT.Spell_Checker (g-speche.ads)
12151 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12152 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12153 @cindex Spell checking
12154
12155 @noindent
12156 Provides a function for determining whether one string is a plausible
12157 near misspelling of another string.
12158
12159 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12160 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12161 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12162 @cindex SPITBOL pattern matching
12163 @cindex Pattern matching
12164
12165 @noindent
12166 A complete implementation of SNOBOL4 style pattern matching.  This is the
12167 most elaborate of the pattern matching packages provided.  It fully duplicates
12168 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12169 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12170
12171 @node GNAT.Spitbol (g-spitbo.ads)
12172 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12173 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12174 @cindex SPITBOL interface
12175
12176 @noindent
12177 The top level package of the collection of SPITBOL-style functionality, this
12178 package provides basic SNOBOL4 string manipulation functions, such as
12179 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12180 useful for constructing arbitrary mappings from strings in the style of
12181 the SNOBOL4 TABLE function.
12182
12183 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12184 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12185 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12186 @cindex Sets of strings
12187 @cindex SPITBOL Tables
12188
12189 @noindent
12190 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12191 for type @code{Standard.Boolean}, giving an implementation of sets of
12192 string values.
12193
12194 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12195 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12196 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12197 @cindex Integer maps
12198 @cindex Maps
12199 @cindex SPITBOL Tables
12200
12201 @noindent
12202 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12203 for type @code{Standard.Integer}, giving an implementation of maps
12204 from string to integer values.
12205
12206 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12207 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12208 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12209 @cindex String maps
12210 @cindex Maps
12211 @cindex SPITBOL Tables
12212
12213 @noindent
12214 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12215 a variable length string type, giving an implementation of general
12216 maps from strings to strings.
12217
12218 @node GNAT.Strings (g-string.ads)
12219 @section @code{GNAT.Strings} (@file{g-string.ads})
12220 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12221
12222 @noindent
12223 Common String access types and related subprograms. Basically it
12224 defines a string access and an array of string access types.
12225
12226 @node GNAT.String_Split (g-strspl.ads)
12227 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12228 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12229 @cindex String splitter
12230
12231 @noindent
12232 Useful string-manipulation routines: given a set of separators, split
12233 a string wherever the separators appear, and provide direct access
12234 to the resulting slices. This package is instantiated from
12235 @code{GNAT.Array_Split}.
12236
12237 @node GNAT.Table (g-table.ads)
12238 @section @code{GNAT.Table} (@file{g-table.ads})
12239 @cindex @code{GNAT.Table} (@file{g-table.ads})
12240 @cindex Table implementation
12241 @cindex Arrays, extendable
12242
12243 @noindent
12244 A generic package providing a single dimension array abstraction where the
12245 length of the array can be dynamically modified.
12246
12247 @noindent
12248 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12249 except that this package declares a single instance of the table type,
12250 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12251 used to define dynamic instances of the table.
12252
12253 @node GNAT.Task_Lock (g-tasloc.ads)
12254 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12255 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12256 @cindex Task synchronization
12257 @cindex Task locking
12258 @cindex Locking
12259
12260 @noindent
12261 A very simple facility for locking and unlocking sections of code using a
12262 single global task lock.  Appropriate for use in situations where contention
12263 between tasks is very rarely expected.
12264
12265 @node GNAT.Threads (g-thread.ads)
12266 @section @code{GNAT.Threads} (@file{g-thread.ads})
12267 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12268 @cindex Foreign threads
12269 @cindex Threads, foreign
12270
12271 @noindent
12272 Provides facilities for creating and destroying threads with explicit calls.
12273 These threads are known to the GNAT run-time system.  These subprograms are
12274 exported C-convention procedures intended to be called from foreign code.
12275 By using these primitives rather than directly calling operating systems
12276 routines, compatibility with the Ada tasking runt-time is provided.
12277
12278 @node GNAT.Traceback (g-traceb.ads)
12279 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12280 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12281 @cindex Trace back facilities
12282
12283 @noindent
12284 Provides a facility for obtaining non-symbolic traceback information, useful
12285 in various debugging situations.
12286
12287 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12288 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12289 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12290 @cindex Trace back facilities
12291
12292 @noindent
12293 Provides symbolic traceback information that includes the subprogram
12294 name and line number information.
12295
12296 @node GNAT.Wide_String_Split (g-wistsp.ads)
12297 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12298 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12299 @cindex Wide_String splitter
12300
12301 @noindent
12302 Useful wide_string-manipulation routines: given a set of separators, split
12303 a wide_string wherever the separators appear, and provide direct access
12304 to the resulting slices. This package is instantiated from
12305 @code{GNAT.Array_Split}.
12306
12307 @node Interfaces.C.Extensions (i-cexten.ads)
12308 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12309 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12310
12311 @noindent
12312 This package contains additional C-related definitions, intended
12313 for use with either manually or automatically generated bindings
12314 to C libraries.
12315
12316 @node Interfaces.C.Streams (i-cstrea.ads)
12317 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12318 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12319 @cindex  C streams, interfacing
12320
12321 @noindent
12322 This package is a binding for the most commonly used operations
12323 on C streams.
12324
12325 @node Interfaces.CPP (i-cpp.ads)
12326 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12327 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12328 @cindex  C++ interfacing
12329 @cindex  Interfacing, to C++
12330
12331 @noindent
12332 This package provides facilities for use in interfacing to C++.  It
12333 is primarily intended to be used in connection with automated tools
12334 for the generation of C++ interfaces.
12335
12336 @node Interfaces.Os2lib (i-os2lib.ads)
12337 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12338 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12339 @cindex Interfacing, to OS/2
12340 @cindex OS/2 interfacing
12341
12342 @noindent
12343 This package provides interface definitions to the OS/2 library.
12344 It is a thin binding which is a direct translation of the
12345 various @file{<bse@.h>} files.
12346
12347 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12348 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12349 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12350 @cindex OS/2 Error codes
12351 @cindex Interfacing, to OS/2
12352 @cindex OS/2 interfacing
12353
12354 @noindent
12355 This package provides definitions of the OS/2 error codes.
12356
12357 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12358 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12359 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12360 @cindex Interfacing, to OS/2
12361 @cindex Synchronization, OS/2
12362 @cindex OS/2 synchronization primitives
12363
12364 @noindent
12365 This is a child package that provides definitions for interfacing
12366 to the @code{OS/2} synchronization primitives.
12367
12368 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12369 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12370 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12371 @cindex Interfacing, to OS/2
12372 @cindex Thread control, OS/2
12373 @cindex OS/2 thread interfacing
12374
12375 @noindent
12376 This is a child package that provides definitions for interfacing
12377 to the @code{OS/2} thread primitives.
12378
12379 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12380 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12381 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12382 @cindex  IBM Packed Format
12383 @cindex  Packed Decimal
12384
12385 @noindent
12386 This package provides a set of routines for conversions to and
12387 from a packed decimal format compatible with that used on IBM
12388 mainframes.
12389
12390 @node Interfaces.VxWorks (i-vxwork.ads)
12391 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12392 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12393 @cindex Interfacing to VxWorks
12394 @cindex VxWorks, interfacing
12395
12396 @noindent
12397 This package provides a limited binding to the VxWorks API.
12398 In particular, it interfaces with the
12399 VxWorks hardware interrupt facilities.
12400
12401 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12402 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12403 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12404 @cindex Interfacing to VxWorks' I/O
12405 @cindex VxWorks, I/O interfacing
12406 @cindex VxWorks, Get_Immediate
12407 @cindex Get_Immediate, VxWorks
12408
12409 @noindent
12410 This package provides a binding to the ioctl (IO/Control)
12411 function of VxWorks, defining a set of option values and
12412 function codes. A particular use of this package is
12413 to enable the use of Get_Immediate under VxWorks.
12414
12415 @node System.Address_Image (s-addima.ads)
12416 @section @code{System.Address_Image} (@file{s-addima.ads})
12417 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12418 @cindex Address image
12419 @cindex Image, of an address
12420
12421 @noindent
12422 This function provides a useful debugging
12423 function that gives an (implementation dependent)
12424 string which identifies an address.
12425
12426 @node System.Assertions (s-assert.ads)
12427 @section @code{System.Assertions} (@file{s-assert.ads})
12428 @cindex @code{System.Assertions} (@file{s-assert.ads})
12429 @cindex Assertions
12430 @cindex Assert_Failure, exception
12431
12432 @noindent
12433 This package provides the declaration of the exception raised
12434 by an run-time assertion failure, as well as the routine that
12435 is used internally to raise this assertion.
12436
12437 @node System.Memory (s-memory.ads)
12438 @section @code{System.Memory} (@file{s-memory.ads})
12439 @cindex @code{System.Memory} (@file{s-memory.ads})
12440 @cindex Memory allocation
12441
12442 @noindent
12443 This package provides the interface to the low level routines used
12444 by the generated code for allocation and freeing storage for the
12445 default storage pool (analogous to the C routines malloc and free.
12446 It also provides a reallocation interface analogous to the C routine
12447 realloc. The body of this unit may be modified to provide alternative
12448 allocation mechanisms for the default pool, and in addition, direct
12449 calls to this unit may be made for low level allocation uses (for
12450 example see the body of @code{GNAT.Tables}).
12451
12452 @node System.Partition_Interface (s-parint.ads)
12453 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12454 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12455 @cindex Partition intefacing functions
12456
12457 @noindent
12458 This package provides facilities for partition interfacing.  It
12459 is used primarily in a distribution context when using Annex E
12460 with @code{GLADE}.
12461
12462 @node System.Restrictions (s-restri.ads)
12463 @section @code{System.Restrictions} (@file{s-restri.ads})
12464 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12465 @cindex Run-time restrictions access
12466
12467 @noindent
12468 This package provides facilities for accessing at run-time
12469 the status of restrictions specified at compile time for
12470 the partition. Information is available both with regard
12471 to actual restrictions specified, and with regard to
12472 compiler determined information on which restrictions
12473 are violated by one or more packages in the partition.
12474
12475 @node System.Rident (s-rident.ads)
12476 @section @code{System.Rident} (@file{s-rident.ads})
12477 @cindex @code{System.Rident} (@file{s-rident.ads})
12478 @cindex Restrictions definitions
12479
12480 @noindent
12481 This package provides definitions of the restrictions
12482 identifiers supported by GNAT, and also the format of
12483 the restrictions provided in package System.Restrictions.
12484 It is not normally necessary to @code{with} this generic package
12485 since the necessary instantiation is included in
12486 package System.Restrictions.
12487
12488 @node System.Task_Info (s-tasinf.ads)
12489 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12490 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12491 @cindex Task_Info pragma
12492
12493 @noindent
12494 This package provides target dependent functionality that is used
12495 to support the @code{Task_Info} pragma
12496
12497 @node System.Wch_Cnv (s-wchcnv.ads)
12498 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12499 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12500 @cindex Wide Character, Representation
12501 @cindex Wide String, Conversion
12502 @cindex Representation of wide characters
12503
12504 @noindent
12505 This package provides routines for converting between
12506 wide characters and a representation as a value of type
12507 @code{Standard.String}, using a specified wide character
12508 encoding method.  It uses definitions in
12509 package @code{System.Wch_Con}.
12510
12511 @node System.Wch_Con (s-wchcon.ads)
12512 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12513 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12514
12515 @noindent
12516 This package provides definitions and descriptions of
12517 the various methods used for encoding wide characters
12518 in ordinary strings.  These definitions are used by
12519 the package @code{System.Wch_Cnv}.
12520
12521 @node Interfacing to Other Languages
12522 @chapter Interfacing to Other Languages
12523 @noindent
12524 The facilities in annex B of the Ada 95 Reference Manual are fully
12525 implemented in GNAT, and in addition, a full interface to C++ is
12526 provided.
12527
12528 @menu
12529 * Interfacing to C::
12530 * Interfacing to C++::
12531 * Interfacing to COBOL::
12532 * Interfacing to Fortran::
12533 * Interfacing to non-GNAT Ada code::
12534 @end menu
12535
12536 @node Interfacing to C
12537 @section Interfacing to C
12538
12539 @noindent
12540 Interfacing to C with GNAT can use one of two approaches:
12541
12542 @itemize @bullet
12543 @item
12544 The types in the package @code{Interfaces.C} may be used.
12545 @item
12546 Standard Ada types may be used directly.  This may be less portable to
12547 other compilers, but will work on all GNAT compilers, which guarantee
12548 correspondence between the C and Ada types.
12549 @end itemize
12550
12551 @noindent
12552 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12553 effect, since this is the default.  The following table shows the
12554 correspondence between Ada scalar types and the corresponding C types.
12555
12556 @table @code
12557 @item Integer
12558 @code{int}
12559 @item Short_Integer
12560 @code{short}
12561 @item Short_Short_Integer
12562 @code{signed char}
12563 @item Long_Integer
12564 @code{long}
12565 @item Long_Long_Integer
12566 @code{long long}
12567 @item Short_Float
12568 @code{float}
12569 @item Float
12570 @code{float}
12571 @item Long_Float
12572 @code{double}
12573 @item Long_Long_Float
12574 This is the longest floating-point type supported by the hardware.
12575 @end table
12576
12577 @noindent
12578 Additionally, there are the following general correspondences between Ada
12579 and C types:
12580 @itemize @bullet
12581 @item
12582 Ada enumeration types map to C enumeration types directly if pragma
12583 @code{Convention C} is specified, which causes them to have int
12584 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12585 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12586 @code{int}, respectively) depending on the number of values passed.
12587 This is the only case in which pragma @code{Convention C} affects the
12588 representation of an Ada type.
12589
12590 @item
12591 Ada access types map to C pointers, except for the case of pointers to
12592 unconstrained types in Ada, which have no direct C equivalent.
12593
12594 @item
12595 Ada arrays map directly to C arrays.
12596
12597 @item
12598 Ada records map directly to C structures.
12599
12600 @item
12601 Packed Ada records map to C structures where all members are bit fields
12602 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12603 @end itemize
12604
12605 @node Interfacing to C++
12606 @section Interfacing to C++
12607
12608 @noindent
12609 The interface to C++ makes use of the following pragmas, which are
12610 primarily intended to be constructed automatically using a binding generator
12611 tool, although it is possible to construct them by hand.  No suitable binding
12612 generator tool is supplied with GNAT though.
12613
12614 Using these pragmas it is possible to achieve complete
12615 inter-operability between Ada tagged types and C class definitions.
12616 See @ref{Implementation Defined Pragmas}, for more details.
12617
12618 @table @code
12619 @item pragma CPP_Class ([Entity =>] @var{local_name})
12620 The argument denotes an entity in the current declarative region that is
12621 declared as a tagged or untagged record type.  It indicates that the type
12622 corresponds to an externally declared C++ class type, and is to be laid
12623 out the same way that C++ would lay out the type.
12624
12625 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12626 This pragma identifies an imported function (imported in the usual way
12627 with pragma @code{Import}) as corresponding to a C++ constructor.
12628
12629 @item pragma CPP_Vtable @dots{}
12630 One @code{CPP_Vtable} pragma can be present for each component of type
12631 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12632 applies.
12633 @end table
12634
12635 @node Interfacing to COBOL
12636 @section Interfacing to COBOL
12637
12638 @noindent
12639 Interfacing to COBOL is achieved as described in section B.4 of
12640 the Ada 95 reference manual.
12641
12642 @node Interfacing to Fortran
12643 @section Interfacing to Fortran
12644
12645 @noindent
12646 Interfacing to Fortran is achieved as described in section B.5 of the
12647 reference manual.  The pragma @code{Convention Fortran}, applied to a
12648 multi-dimensional array causes the array to be stored in column-major
12649 order as required for convenient interface to Fortran.
12650
12651 @node Interfacing to non-GNAT Ada code
12652 @section Interfacing to non-GNAT Ada code
12653
12654 It is possible to specify the convention @code{Ada} in a pragma
12655 @code{Import} or pragma @code{Export}.  However this refers to
12656 the calling conventions used by GNAT, which may or may not be
12657 similar enough to those used by some other Ada 83 or Ada 95
12658 compiler to allow interoperation.
12659
12660 If arguments types are kept simple, and if the foreign compiler generally
12661 follows system calling conventions, then it may be possible to integrate
12662 files compiled by other Ada compilers, provided that the elaboration
12663 issues are adequately addressed (for example by eliminating the
12664 need for any load time elaboration).
12665
12666 In particular, GNAT running on VMS is designed to
12667 be highly compatible with the DEC Ada 83 compiler, so this is one
12668 case in which it is possible to import foreign units of this type,
12669 provided that the data items passed are restricted to simple scalar
12670 values or simple record types without variants, or simple array
12671 types with fixed bounds.
12672
12673 @node Specialized Needs Annexes
12674 @chapter Specialized Needs Annexes
12675
12676 @noindent
12677 Ada 95 defines a number of specialized needs annexes, which are not
12678 required in all implementations.  However, as described in this chapter,
12679 GNAT implements all of these special needs annexes:
12680
12681 @table @asis
12682 @item Systems Programming (Annex C)
12683 The Systems Programming Annex is fully implemented.
12684
12685 @item Real-Time Systems (Annex D)
12686 The Real-Time Systems Annex is fully implemented.
12687
12688 @item Distributed Systems (Annex E)
12689 Stub generation is fully implemented in the GNAT compiler.  In addition,
12690 a complete compatible PCS is available as part of the GLADE system,
12691 a separate product.  When the two
12692 products are used in conjunction, this annex is fully implemented.
12693
12694 @item Information Systems (Annex F)
12695 The Information Systems annex is fully implemented.
12696
12697 @item Numerics (Annex G)
12698 The Numerics Annex is fully implemented.
12699
12700 @item Safety and Security (Annex H)
12701 The Safety and Security annex is fully implemented.
12702 @end table
12703
12704 @node Implementation of Specific Ada Features
12705 @chapter Implementation of Specific Ada Features
12706
12707 @noindent
12708 This chapter describes the GNAT implementation of several Ada language
12709 facilities.
12710
12711 @menu
12712 * Machine Code Insertions::
12713 * GNAT Implementation of Tasking::
12714 * GNAT Implementation of Shared Passive Packages::
12715 * Code Generation for Array Aggregates::
12716 @end menu
12717
12718 @node Machine Code Insertions
12719 @section Machine Code Insertions
12720
12721 @noindent
12722 Package @code{Machine_Code} provides machine code support as described
12723 in the Ada 95 Reference Manual in two separate forms:
12724 @itemize @bullet
12725 @item
12726 Machine code statements, consisting of qualified expressions that
12727 fit the requirements of RM section 13.8.
12728 @item
12729 An intrinsic callable procedure, providing an alternative mechanism of
12730 including machine instructions in a subprogram.
12731 @end itemize
12732
12733 @noindent
12734 The two features are similar, and both are closely related to the mechanism
12735 provided by the asm instruction in the GNU C compiler.  Full understanding
12736 and use of the facilities in this package requires understanding the asm
12737 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12738 by Richard Stallman. The relevant section is titled ``Extensions to the C
12739 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12740
12741 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12742 semantic restrictions and effects as described below.  Both are provided so
12743 that the procedure call can be used as a statement, and the function call
12744 can be used to form a code_statement.
12745
12746 The first example given in the GCC documentation is the C @code{asm}
12747 instruction:
12748 @smallexample
12749    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12750 @end smallexample
12751
12752 @noindent
12753 The equivalent can be written for GNAT as:
12754
12755 @smallexample @c ada
12756 Asm ("fsinx %1 %0",
12757      My_Float'Asm_Output ("=f", result),
12758      My_Float'Asm_Input  ("f",  angle));
12759 @end smallexample
12760
12761 @noindent
12762 The first argument to @code{Asm} is the assembler template, and is
12763 identical to what is used in GNU C@.  This string must be a static
12764 expression.  The second argument is the output operand list.  It is
12765 either a single @code{Asm_Output} attribute reference, or a list of such
12766 references enclosed in parentheses (technically an array aggregate of
12767 such references).
12768
12769 The @code{Asm_Output} attribute denotes a function that takes two
12770 parameters.  The first is a string, the second is the name of a variable
12771 of the type designated by the attribute prefix.  The first (string)
12772 argument is required to be a static expression and designates the
12773 constraint for the parameter (e.g.@: what kind of register is
12774 required).  The second argument is the variable to be updated with the
12775 result.  The possible values for constraint are the same as those used in
12776 the RTL, and are dependent on the configuration file used to build the
12777 GCC back end.  If there are no output operands, then this argument may
12778 either be omitted, or explicitly given as @code{No_Output_Operands}.
12779
12780 The second argument of @code{@var{my_float}'Asm_Output} functions as
12781 though it were an @code{out} parameter, which is a little curious, but
12782 all names have the form of expressions, so there is no syntactic
12783 irregularity, even though normally functions would not be permitted
12784 @code{out} parameters.  The third argument is the list of input
12785 operands.  It is either a single @code{Asm_Input} attribute reference, or
12786 a list of such references enclosed in parentheses (technically an array
12787 aggregate of such references).
12788
12789 The @code{Asm_Input} attribute denotes a function that takes two
12790 parameters.  The first is a string, the second is an expression of the
12791 type designated by the prefix.  The first (string) argument is required
12792 to be a static expression, and is the constraint for the parameter,
12793 (e.g.@: what kind of register is required).  The second argument is the
12794 value to be used as the input argument.  The possible values for the
12795 constant are the same as those used in the RTL, and are dependent on
12796 the configuration file used to built the GCC back end.
12797
12798 If there are no input operands, this argument may either be omitted, or
12799 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12800 present in the above example, is a list of register names, called the
12801 @dfn{clobber} argument.  This argument, if given, must be a static string
12802 expression, and is a space or comma separated list of names of registers
12803 that must be considered destroyed as a result of the @code{Asm} call.  If
12804 this argument is the null string (the default value), then the code
12805 generator assumes that no additional registers are destroyed.
12806
12807 The fifth argument, not present in the above example, called the
12808 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12809 the literal value @code{True} to indicate to the code generator that all
12810 optimizations with respect to the instruction specified should be
12811 suppressed, and that in particular, for an instruction that has outputs,
12812 the instruction will still be generated, even if none of the outputs are
12813 used.  See the full description in the GCC manual for further details.
12814
12815 The @code{Asm} subprograms may be used in two ways.  First the procedure
12816 forms can be used anywhere a procedure call would be valid, and
12817 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12818 be used to intersperse machine instructions with other Ada statements.
12819 Second, the function forms, which return a dummy value of the limited
12820 private type @code{Asm_Insn}, can be used in code statements, and indeed
12821 this is the only context where such calls are allowed.  Code statements
12822 appear as aggregates of the form:
12823
12824 @smallexample @c ada
12825 Asm_Insn'(Asm (@dots{}));
12826 Asm_Insn'(Asm_Volatile (@dots{}));
12827 @end smallexample
12828
12829 @noindent
12830 In accordance with RM rules, such code statements are allowed only
12831 within subprograms whose entire body consists of such statements.  It is
12832 not permissible to intermix such statements with other Ada statements.
12833
12834 Typically the form using intrinsic procedure calls is more convenient
12835 and more flexible.  The code statement form is provided to meet the RM
12836 suggestion that such a facility should be made available.  The following
12837 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12838 is used, the arguments may be given in arbitrary order, following the
12839 normal rules for use of positional and named arguments)
12840
12841 @smallexample
12842 ASM_CALL ::= Asm (
12843                  [Template =>] static_string_EXPRESSION
12844                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12845                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12846                [,[Clobber  =>] static_string_EXPRESSION ]
12847                [,[Volatile =>] static_boolean_EXPRESSION] )
12848
12849 OUTPUT_OPERAND_LIST ::=
12850   [PREFIX.]No_Output_Operands
12851 | OUTPUT_OPERAND_ATTRIBUTE
12852 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12853
12854 OUTPUT_OPERAND_ATTRIBUTE ::=
12855   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12856
12857 INPUT_OPERAND_LIST ::=
12858   [PREFIX.]No_Input_Operands
12859 | INPUT_OPERAND_ATTRIBUTE
12860 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12861
12862 INPUT_OPERAND_ATTRIBUTE ::=
12863   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12864 @end smallexample
12865
12866 @noindent
12867 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12868 are declared in the package @code{Machine_Code} and must be referenced
12869 according to normal visibility rules. In particular if there is no
12870 @code{use} clause for this package, then appropriate package name
12871 qualification is required.
12872
12873 @node GNAT Implementation of Tasking
12874 @section GNAT Implementation of Tasking
12875
12876 @noindent
12877 This chapter outlines the basic GNAT approach to tasking (in particular,
12878 a multi-layered library for portability) and discusses issues related
12879 to compliance with the Real-Time Systems Annex.
12880
12881 @menu
12882 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12883 * Ensuring Compliance with the Real-Time Annex::
12884 @end menu
12885
12886 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12887 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12888
12889 @noindent
12890 GNAT's run-time support comprises two layers:
12891
12892 @itemize @bullet
12893 @item GNARL (GNAT Run-time Layer)
12894 @item GNULL (GNAT Low-level Library)
12895 @end itemize
12896
12897 @noindent
12898 In GNAT, Ada's tasking services rely on a platform and OS independent
12899 layer known as GNARL@.  This code is responsible for implementing the
12900 correct semantics of Ada's task creation, rendezvous, protected
12901 operations etc.
12902
12903 GNARL decomposes Ada's tasking semantics into simpler lower level
12904 operations such as create a thread, set the priority of a thread,
12905 yield, create a lock, lock/unlock, etc.  The spec for these low-level
12906 operations constitutes GNULLI, the GNULL Interface.  This interface is
12907 directly inspired from the POSIX real-time API@.
12908
12909 If the underlying executive or OS implements the POSIX standard
12910 faithfully, the GNULL Interface maps as is to the services offered by
12911 the underlying kernel.  Otherwise, some target dependent glue code maps
12912 the services offered by the underlying kernel to the semantics expected
12913 by GNARL@.
12914
12915 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
12916 key point is that each Ada task is mapped on a thread in the underlying
12917 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
12918
12919 In addition Ada task priorities map onto the underlying thread priorities.
12920 Mapping Ada tasks onto the underlying kernel threads has several advantages:
12921
12922 @itemize @bullet
12923 @item
12924 The underlying scheduler is used to schedule the Ada tasks.  This
12925 makes Ada tasks as efficient as kernel threads from a scheduling
12926 standpoint.
12927
12928 @item
12929 Interaction with code written in C containing threads is eased
12930 since at the lowest level Ada tasks and C threads map onto the same
12931 underlying kernel concept.
12932
12933 @item
12934 When an Ada task is blocked during I/O the remaining Ada tasks are
12935 able to proceed.
12936
12937 @item
12938 On multiprocessor systems Ada tasks can execute in parallel.
12939 @end itemize
12940
12941 @noindent
12942 Some threads libraries offer a mechanism to fork a new process, with the
12943 child process duplicating the threads from the parent.
12944 GNAT does not
12945 support this functionality when the parent contains more than one task.
12946 @cindex Forking a new process
12947
12948 @node Ensuring Compliance with the Real-Time Annex
12949 @subsection Ensuring Compliance with the Real-Time Annex
12950 @cindex Real-Time Systems Annex compliance
12951
12952 @noindent
12953 Although mapping Ada tasks onto
12954 the underlying threads has significant advantages, it does create some
12955 complications when it comes to respecting the scheduling semantics
12956 specified in the real-time annex (Annex D).
12957
12958 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
12959 scheduling policy states:
12960
12961 @quotation
12962 @emph{When the active priority of a ready task that is not running
12963 changes, or the setting of its base priority takes effect, the
12964 task is removed from the ready queue for its old active priority
12965 and is added at the tail of the ready queue for its new active
12966 priority, except in the case where the active priority is lowered
12967 due to the loss of inherited priority, in which case the task is
12968 added at the head of the ready queue for its new active priority.}
12969 @end quotation
12970
12971 @noindent
12972 While most kernels do put tasks at the end of the priority queue when
12973 a task changes its priority, (which respects the main
12974 FIFO_Within_Priorities requirement), almost none keep a thread at the
12975 beginning of its priority queue when its priority drops from the loss
12976 of inherited priority.
12977
12978 As a result most vendors have provided incomplete Annex D implementations.
12979
12980 The GNAT run-time, has a nice cooperative solution to this problem
12981 which ensures that accurate FIFO_Within_Priorities semantics are
12982 respected.
12983
12984 The principle is as follows.  When an Ada task T is about to start
12985 running, it checks whether some other Ada task R with the same
12986 priority as T has been suspended due to the loss of priority
12987 inheritance.  If this is the case, T yields and is placed at the end of
12988 its priority queue.  When R arrives at the front of the queue it
12989 executes.
12990
12991 Note that this simple scheme preserves the relative order of the tasks
12992 that were ready to execute in the priority queue where R has been
12993 placed at the end.
12994
12995 @node GNAT Implementation of Shared Passive Packages
12996 @section GNAT Implementation of Shared Passive Packages
12997 @cindex Shared passive packages
12998
12999 @noindent
13000 GNAT fully implements the pragma @code{Shared_Passive} for
13001 @cindex pragma @code{Shared_Passive}
13002 the purpose of designating shared passive packages.
13003 This allows the use of passive partitions in the
13004 context described in the Ada Reference Manual; i.e. for communication
13005 between separate partitions of a distributed application using the
13006 features in Annex E.
13007 @cindex Annex E
13008 @cindex Distribution Systems Annex
13009
13010 However, the implementation approach used by GNAT provides for more
13011 extensive usage as follows:
13012
13013 @table @emph
13014 @item Communication between separate programs
13015
13016 This allows separate programs to access the data in passive
13017 partitions, using protected objects for synchronization where
13018 needed. The only requirement is that the two programs have a
13019 common shared file system. It is even possible for programs
13020 running on different machines with different architectures
13021 (e.g. different endianness) to communicate via the data in
13022 a passive partition.
13023
13024 @item Persistence between program runs
13025
13026 The data in a passive package can persist from one run of a
13027 program to another, so that a later program sees the final
13028 values stored by a previous run of the same program.
13029
13030 @end table
13031
13032 @noindent
13033 The implementation approach used is to store the data in files. A
13034 separate stream file is created for each object in the package, and
13035 an access to an object causes the corresponding file to be read or
13036 written.
13037
13038 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13039 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13040 set to the directory to be used for these files.
13041 The files in this directory
13042 have names that correspond to their fully qualified names. For
13043 example, if we have the package
13044
13045 @smallexample @c ada
13046 package X is
13047   pragma Shared_Passive (X);
13048   Y : Integer;
13049   Z : Float;
13050 end X;
13051 @end smallexample
13052
13053 @noindent
13054 and the environment variable is set to @code{/stemp/}, then the files created
13055 will have the names:
13056
13057 @smallexample
13058 /stemp/x.y
13059 /stemp/x.z
13060 @end smallexample
13061
13062 @noindent
13063 These files are created when a value is initially written to the object, and
13064 the files are retained until manually deleted. This provides the persistence
13065 semantics. If no file exists, it means that no partition has assigned a value
13066 to the variable; in this case the initial value declared in the package
13067 will be used. This model ensures that there are no issues in synchronizing
13068 the elaboration process, since elaboration of passive packages elaborates the
13069 initial values, but does not create the files.
13070
13071 The files are written using normal @code{Stream_IO} access.
13072 If you want to be able
13073 to communicate between programs or partitions running on different
13074 architectures, then you should use the XDR versions of the stream attribute
13075 routines, since these are architecture independent.
13076
13077 If active synchronization is required for access to the variables in the
13078 shared passive package, then as described in the Ada Reference Manual, the
13079 package may contain protected objects used for this purpose. In this case
13080 a lock file (whose name is @file{___lock} (three underscores)
13081 is created in the shared memory directory.
13082 @cindex @file{___lock} file (for shared passive packages)
13083 This is used to provide the required locking
13084 semantics for proper protected object synchronization.
13085
13086 As of January 2003, GNAT supports shared passive packages on all platforms
13087 except for OpenVMS.
13088
13089 @node Code Generation for Array Aggregates
13090 @section Code Generation for Array Aggregates
13091
13092 @menu
13093 * Static constant aggregates with static bounds::
13094 * Constant aggregates with an unconstrained nominal types::
13095 * Aggregates with static bounds::
13096 * Aggregates with non-static bounds::
13097 * Aggregates in assignment statements::
13098 @end menu
13099
13100 @noindent
13101 Aggregate have a rich syntax and allow the user to specify the values of
13102 complex data structures by means of a single construct.  As a result, the
13103 code generated for aggregates can be quite complex and involve loops, case
13104 statements and multiple assignments.  In the simplest cases, however, the
13105 compiler will recognize aggregates whose components and constraints are
13106 fully static, and in those cases the compiler will generate little or no
13107 executable code.  The following is an outline of the code that GNAT generates
13108 for various aggregate constructs.  For further details, the user will find it
13109 useful to examine the output produced by the -gnatG flag to see the expanded
13110 source that is input to the code generator.  The user will also want to examine
13111 the assembly code generated at various levels of optimization.
13112
13113 The code generated for aggregates depends on the context, the component values,
13114 and the type.  In the context of an object declaration the code generated is
13115 generally simpler than in the case of an assignment.  As a general rule, static
13116 component values and static subtypes also lead to simpler code.
13117
13118 @node Static constant aggregates with static bounds
13119 @subsection Static constant aggregates with static bounds
13120
13121 @noindent
13122 For the declarations:
13123 @smallexample @c ada
13124     type One_Dim is array (1..10) of integer;
13125     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13126 @end smallexample
13127
13128 @noindent
13129 GNAT generates no executable code: the constant ar0 is placed in static memory.
13130 The same is true for constant aggregates with named associations:
13131
13132 @smallexample @c ada
13133     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13134     Cr3 : constant One_Dim := (others => 7777);
13135 @end smallexample
13136
13137 @noindent
13138 The same is true for multidimensional constant arrays such as:
13139
13140 @smallexample @c ada
13141     type two_dim is array (1..3, 1..3) of integer;
13142     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13143 @end smallexample
13144
13145 @noindent
13146 The same is true for arrays of one-dimensional arrays: the following are
13147 static:
13148
13149 @smallexample @c ada
13150 type ar1b  is array (1..3) of boolean;
13151 type ar_ar is array (1..3) of ar1b;
13152 None  : constant ar1b := (others => false);     --  fully static
13153 None2 : constant ar_ar := (1..3 => None);       --  fully static
13154 @end smallexample
13155
13156 @noindent
13157 However, for multidimensional aggregates with named associations, GNAT will
13158 generate assignments and loops, even if all associations are static.  The
13159 following two declarations generate a loop for the first dimension, and
13160 individual component assignments for the second dimension:
13161
13162 @smallexample @c ada
13163 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13164 Zero2: constant two_dim := (others => (others => 0));
13165 @end smallexample
13166
13167 @node Constant aggregates with an unconstrained nominal types
13168 @subsection Constant aggregates with an unconstrained nominal types
13169
13170 @noindent
13171 In such cases the aggregate itself establishes the subtype, so that
13172 associations with @code{others} cannot be used.  GNAT determines the
13173 bounds for the actual subtype of the aggregate, and allocates the
13174 aggregate statically as well.  No code is generated for the following:
13175
13176 @smallexample @c ada
13177     type One_Unc is array (natural range <>) of integer;
13178     Cr_Unc : constant One_Unc := (12,24,36);
13179 @end smallexample
13180
13181 @node Aggregates with static bounds
13182 @subsection Aggregates with static bounds
13183
13184 @noindent
13185 In all previous examples the aggregate was the initial (and immutable) value
13186 of a constant.  If the aggregate initializes a variable, then code is generated
13187 for it as a combination of individual assignments and loops over the target
13188 object.  The declarations
13189
13190 @smallexample @c ada
13191        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13192        Cr_Var2 : One_Dim := (others > -1);
13193 @end smallexample
13194
13195 @noindent
13196 generate the equivalent of
13197
13198 @smallexample @c ada
13199        Cr_Var1 (1) := 2;
13200        Cr_Var1 (2) := 3;
13201        Cr_Var1 (3) := 5;
13202        Cr_Var1 (4) := 11;
13203
13204        for I in Cr_Var2'range loop
13205           Cr_Var2 (I) := =-1;
13206        end loop;
13207 @end smallexample
13208
13209 @node Aggregates with non-static bounds
13210 @subsection Aggregates with non-static bounds
13211
13212 @noindent
13213 If the bounds of the aggregate are not statically compatible with the bounds
13214 of the nominal subtype  of the target, then constraint checks have to be
13215 generated on the bounds.  For a multidimensional array, constraint checks may
13216 have to be applied to sub-arrays individually, if they do not have statically
13217 compatible subtypes.
13218
13219 @node Aggregates in assignment statements
13220 @subsection Aggregates in assignment statements
13221
13222 @noindent
13223 In general, aggregate assignment requires the construction of a temporary,
13224 and a copy from the temporary to the target of the assignment.  This is because
13225 it is not always possible to convert the assignment into a series of individual
13226 component assignments.  For example, consider the simple case:
13227
13228 @smallexample @c ada
13229         A := (A(2), A(1));
13230 @end smallexample
13231
13232 @noindent
13233 This cannot be converted into:
13234
13235 @smallexample @c ada
13236         A(1) := A(2);
13237         A(2) := A(1);
13238 @end smallexample
13239
13240 @noindent
13241 So the aggregate has to be built first in a separate location, and then
13242 copied into the target.  GNAT recognizes simple cases where this intermediate
13243 step is not required, and the assignments can be performed in place, directly
13244 into the target.  The following sufficient criteria are applied:
13245
13246 @itemize @bullet
13247 @item
13248 The bounds of the aggregate are static, and the associations are static.
13249 @item
13250 The components of the aggregate are static constants, names of
13251 simple variables that are not renamings, or expressions not involving
13252 indexed components whose operands obey these rules.
13253 @end itemize
13254
13255 @noindent
13256 If any of these conditions are violated, the aggregate will be built in
13257 a temporary (created either by the front-end or the code generator) and then
13258 that temporary will be copied onto the target.
13259
13260 @node Project File Reference
13261 @chapter Project File Reference
13262
13263 @noindent
13264 This chapter describes the syntax and semantics of project files.
13265 Project files specify the options to be used when building a system.
13266 Project files can specify global settings for all tools,
13267 as well as tool-specific settings.
13268 See the chapter on project files in the GNAT Users guide for examples of use.
13269
13270 @menu
13271 * Reserved Words::
13272 * Lexical Elements::
13273 * Declarations::
13274 * Typed string declarations::
13275 * Variables::
13276 * Expressions::
13277 * Attributes::
13278 * Project Attributes::
13279 * Attribute References::
13280 * External Values::
13281 * Case Construction::
13282 * Packages::
13283 * Package Renamings::
13284 * Projects::
13285 * Project Extensions::
13286 * Project File Elaboration::
13287 @end menu
13288
13289 @node Reserved Words
13290 @section Reserved Words
13291
13292 @noindent
13293 All Ada95 reserved words are reserved in project files, and cannot be used
13294 as variable names or project names. In addition, the following are
13295 also reserved in project files:
13296
13297 @itemize
13298 @item @code{extends}
13299
13300 @item @code{external}
13301
13302 @item @code{project}
13303
13304 @end itemize
13305
13306 @node Lexical Elements
13307 @section Lexical Elements
13308
13309 @noindent
13310 Rules for identifiers are the same as in Ada95. Identifiers
13311 are case-insensitive.  Strings are case sensitive, except where noted.
13312 Comments have the same form as in Ada95.
13313
13314 @noindent
13315 Syntax:
13316
13317 @smallexample
13318 simple_name ::=
13319   identifier
13320
13321 name ::=
13322   simple_name @{. simple_name@}
13323 @end smallexample
13324
13325 @node Declarations
13326 @section Declarations
13327
13328 @noindent
13329 Declarations introduce new entities that denote types, variables, attributes,
13330 and packages. Some declarations can only appear immediately within a project
13331 declaration. Others can appear within a project or within a package.
13332
13333 Syntax:
13334 @smallexample
13335 declarative_item ::=
13336   simple_declarative_item |
13337   typed_string_declaration |
13338   package_declaration
13339
13340 simple_declarative_item ::=
13341   variable_declaration |
13342   typed_variable_declaration |
13343   attribute_declaration |
13344   case_construction
13345 @end smallexample
13346
13347 @node Typed string declarations
13348 @section Typed string declarations
13349
13350 @noindent
13351 Typed strings are sequences of string literals. Typed strings are the only
13352 named types in project files. They are used in case constructions, where they
13353 provide support for conditional attribute definitions.
13354
13355 Syntax:
13356 @smallexample
13357 typed_string_declaration ::=
13358   @b{type} <typed_string_>_simple_name @b{is}
13359    ( string_literal @{, string_literal@} );
13360 @end smallexample
13361
13362 @noindent
13363 A typed string declaration can only appear immediately within a project
13364 declaration.
13365
13366 All the string literals in a typed string declaration must be distinct.
13367
13368 @node Variables
13369 @section Variables
13370
13371 @noindent
13372 Variables denote values, and appear as constituents of expressions.
13373
13374 @smallexample
13375 typed_variable_declaration ::=
13376   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13377
13378 variable_declaration ::=
13379   <variable_>simple_name := expression;
13380 @end smallexample
13381
13382 @noindent
13383 The elaboration of a variable declaration introduces the variable and
13384 assigns to it the value of the expression. The name of the variable is
13385 available after the assignment symbol.
13386
13387 @noindent
13388 A typed_variable can only be declare once.
13389
13390 @noindent
13391 a non typed variable can be declared multiple times.
13392
13393 @noindent
13394 Before the completion of its first declaration, the value of variable
13395 is the null string.
13396
13397 @node Expressions
13398 @section Expressions
13399
13400 @noindent
13401 An expression is a formula that defines a computation or retrieval of a value.
13402 In a project file the value of an expression is either a string or a list
13403 of strings. A string value in an expression is either a literal, the current
13404 value of a variable, an external value, an attribute reference, or a
13405 concatenation operation.
13406
13407 Syntax:
13408
13409 @smallexample
13410 expression ::=
13411   term @{& term@}
13412
13413 term ::=
13414   string_literal |
13415   string_list |
13416   <variable_>name |
13417   external_value |
13418   attribute_reference
13419
13420 string_literal ::=
13421   (same as Ada)
13422
13423 string_list ::=
13424   ( <string_>expression @{ , <string_>expression @} )
13425 @end smallexample
13426
13427 @subsection Concatenation
13428 @noindent
13429 The following concatenation functions are defined:
13430
13431 @smallexample @c ada
13432   function "&" (X : String;      Y : String)      return String;
13433   function "&" (X : String_List; Y : String)      return String_List;
13434   function "&" (X : String_List; Y : String_List) return String_List;
13435 @end smallexample
13436
13437 @node Attributes
13438 @section Attributes
13439
13440 @noindent
13441 An attribute declaration defines a property of a project or package. This
13442 property can later be queried by means of an attribute reference.
13443 Attribute values are strings or string lists.
13444
13445 Some attributes are associative arrays. These attributes are mappings whose
13446 domain is a set of strings. These attributes are declared one association
13447 at a time, by specifying a point in the domain and the corresponding image
13448 of the attribute. They may also be declared as a full associative array,
13449 getting the same associations as the corresponding attribute in an imported
13450 or extended project.
13451
13452 Attributes that are not associative arrays are called simple attributes.
13453
13454 Syntax:
13455 @smallexample
13456 attribute_declaration ::=
13457   full_associative_array_declaration |
13458   @b{for} attribute_designator @b{use} expression ;
13459
13460 full_associative_array_declaration ::=
13461   @b{for} <associative_array_attribute_>simple_name @b{use}
13462   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13463
13464 attribute_designator ::=
13465   <simple_attribute_>simple_name |
13466   <associative_array_attribute_>simple_name ( string_literal )
13467 @end smallexample
13468
13469 @noindent
13470 Some attributes are project-specific, and can only appear immediately within
13471 a project declaration. Others are package-specific, and can only appear within
13472 the proper package.
13473
13474 The expression in an attribute definition must be a string or a string_list.
13475 The string literal appearing in the attribute_designator of an associative
13476 array attribute is case-insensitive.
13477
13478 @node Project Attributes
13479 @section Project Attributes
13480
13481 @noindent
13482 The following attributes apply to a project. All of them are simple
13483 attributes.
13484
13485 @table @code
13486 @item   Object_Dir
13487 Expression must be a path name. The attribute defines the
13488 directory in which the object files created by the build are to be placed. If
13489 not specified, object files are placed in the project directory.
13490
13491 @item   Exec_Dir
13492 Expression must be a path name. The attribute defines the
13493 directory in which the executables created by the build are to be placed.
13494 If not specified, executables are placed in the object directory.
13495
13496 @item  Source_Dirs
13497 Expression must be a list of path names. The attribute
13498 defines the directories in which the source files for the project are to be
13499 found. If not specified, source files are found in the project directory.
13500
13501 @item  Source_Files
13502 Expression must be a list of file names. The attribute
13503 defines the individual files, in the project directory, which are to be used
13504 as sources for the project. File names are path_names that contain no directory
13505 information. If the project has no sources the attribute must be declared
13506 explicitly with an empty list.
13507
13508 @item  Source_List_File
13509 Expression must a single path name. The attribute
13510 defines a text file that contains a list of source file names to be used
13511 as sources for the project
13512
13513 @item  Library_Dir
13514 Expression must be a path name. The attribute defines the
13515 directory in which a  library is to be built.  The directory must exist, must
13516 be distinct from the project's object directory, and must be writable.
13517
13518 @item  Library_Name
13519 Expression must be a string that is a legal file name,
13520 without extension. The attribute defines a string that is used to generate
13521 the name of the library to be built by the project.
13522
13523 @item  Library_Kind
13524 Argument must be a string value that must be one of the
13525 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13526 string is case-insensitive. If this attribute is not specified, the library is
13527 a static library. Otherwise, the library may be dynamic or relocatable. This
13528 distinction is operating-system dependent.
13529
13530 @item  Library_Version
13531 Expression must be a string value whose interpretation
13532 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13533 libraries as the internal name of the library (the @code{"soname"}). If the
13534 library file name (built from the @code{Library_Name}) is different from the
13535 @code{Library_Version}, then the library file will be a symbolic link to the
13536 actual file whose name will be @code{Library_Version}.
13537
13538 @item Library_Interface
13539 Expression must be a string list. Each element of the string list
13540 must designate a unit of the project.
13541 If this attribute is present in a Library Project File, then the project
13542 file is a Stand-alone Library_Project_File.
13543
13544 @item Library_Auto_Init
13545 Expression must be a single string "true" or "false", case-insensitive.
13546 If this attribute is present in a Stand-alone Library Project File,
13547 it indicates if initialization is automatic when the dynamic library
13548 is loaded.
13549
13550 @item Library_Options
13551 Expression must be a string list. Indicates additional switches that
13552 are to be used when building a shared library.
13553
13554 @item Library_GCC
13555 Expression must be a single string. Designates an alternative to "gcc"
13556 for building shared libraries.
13557
13558 @item  Library_Src_Dir
13559 Expression must be a path name. The attribute defines the
13560 directory in which the sources of the interfaces of a Stand-alone Library will
13561 be copied.  The directory must exist, must be distinct from the project's
13562 object directory and source directories, and must be writable.
13563
13564 @item  Main
13565 Expression must be a list of strings that are legal file names.
13566 These file names designate existing compilation units in the source directory
13567 that are legal main subprograms.
13568
13569 When a project file is elaborated, as part of the execution of a gnatmake
13570 command, one or several executables are built and placed in the Exec_Dir.
13571 If the gnatmake command does not include explicit file names, the executables
13572 that are built correspond to the files specified by this attribute.
13573
13574 @item Main_Language
13575 This is a simple attribute. Its value is a string that specifies the
13576 language of the main program.
13577
13578 @item  Languages
13579 Expression must be a string list. Each string designates
13580 a programming language that is known to GNAT. The strings are case-insensitive.
13581
13582 @item  Locally_Removed_Files
13583 This attribute is legal only in a project file that extends another.
13584 Expression must be a list of strings that are legal file names.
13585 Each file name must designate a source that would normally be inherited
13586 by the current project file. It cannot designate an immediate source that is
13587 not inherited. Each of the source files in the list are not considered to
13588 be sources of the project file: they are not inherited.
13589 @end table
13590
13591 @node Attribute References
13592 @section Attribute References
13593
13594 @noindent
13595 Attribute references are used to retrieve the value of previously defined
13596 attribute for a package or project.
13597 Syntax:
13598 @smallexample
13599 attribute_reference ::=
13600   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13601
13602 attribute_prefix ::=
13603   @b{project} |
13604   <project_simple_name | package_identifier |
13605   <project_>simple_name . package_identifier
13606 @end smallexample
13607
13608 @noindent
13609 If an attribute has not been specified for a given package or project, its
13610 value is the null string or the empty list.
13611
13612 @node External Values
13613 @section External Values
13614
13615 @noindent
13616 An external value is an expression whose value is obtained from the command
13617 that invoked the processing of the current project file (typically a
13618 gnatmake command).
13619
13620 Syntax:
13621 @smallexample
13622 external_value ::=
13623   @b{external} ( string_literal [, string_literal] )
13624 @end smallexample
13625
13626 @noindent
13627 The first string_literal is the string to be used on the command line or
13628 in the environment to specify the external value. The second string_literal,
13629 if present, is the default to use if there is no specification for this
13630 external value either on the command line or in the environment.
13631
13632 @node Case Construction
13633 @section Case Construction
13634
13635 @noindent
13636 A case construction supports attribute declarations that depend on the value of
13637 a previously declared variable.
13638
13639 Syntax:
13640 @smallexample
13641 case_construction ::=
13642   @b{case} <typed_variable_>name @b{is}
13643     @{case_item@}
13644   @b{end case} ;
13645
13646 case_item ::=
13647   @b{when} discrete_choice_list =>
13648     @{case_construction | attribute_declaration@}
13649
13650 discrete_choice_list ::=
13651   string_literal @{| string_literal@} |
13652     @b{others}
13653 @end smallexample
13654
13655 @noindent
13656 All choices in a choice list must be distinct. The choice lists of two
13657 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13658 alternatives do not need to include all values of the type. An @code{others}
13659 choice must appear last in the list of alternatives.
13660
13661 @node Packages
13662 @section Packages
13663
13664 @noindent
13665 A package provides a grouping of variable declarations and attribute
13666 declarations to be used when invoking various GNAT tools. The name of
13667 the package indicates the tool(s) to which it applies.
13668 Syntax:
13669
13670 @smallexample
13671 package_declaration ::=
13672   package_specification | package_renaming
13673
13674 package_specification ::=
13675   @b{package} package_identifier @b{is}
13676     @{simple_declarative_item@}
13677   @b{end} package_identifier ;
13678
13679 package_identifier ::=
13680   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13681   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13682   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13683 @end smallexample
13684
13685 @subsection Package Naming
13686
13687 @noindent
13688 The attributes of a @code{Naming} package specifies the naming conventions
13689 that apply to the source files in a project. When invoking other GNAT tools,
13690 they will use the sources in the source directories that satisfy these
13691 naming conventions.
13692
13693 The following attributes apply to a @code{Naming} package:
13694
13695 @table @code
13696 @item Casing
13697 This is a simple attribute whose value is a string. Legal values of this
13698 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13699 These strings are themselves case insensitive.
13700
13701 @noindent
13702 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13703
13704 @item Dot_Replacement
13705 This is a simple attribute whose string value satisfies the following
13706 requirements:
13707
13708 @itemize @bullet
13709 @item It must not be empty
13710 @item It cannot start or end with an alphanumeric character
13711 @item It cannot be a single underscore
13712 @item It cannot start with an underscore followed by an alphanumeric
13713 @item It cannot contain a dot @code{'.'} if longer than one character
13714 @end itemize
13715
13716 @noindent
13717 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13718
13719 @item Spec_Suffix
13720 This is an associative array attribute, defined on language names,
13721 whose image is a string that must satisfy the following
13722 conditions:
13723
13724 @itemize @bullet
13725 @item It must not be empty
13726 @item It cannot start with an alphanumeric character
13727 @item It cannot start with an underscore followed by an alphanumeric character
13728 @end itemize
13729
13730 @noindent
13731 For Ada, the attribute denotes the suffix used in file names that contain
13732 library unit declarations, that is to say units that are package and
13733 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13734 specified, then the default is @code{".ads"}.
13735
13736 For C and C++, the attribute denotes the suffix used in file names that
13737 contain prototypes.
13738
13739 @item Body_Suffix
13740 This is an associative array attribute defined on language names,
13741 whose image is a string that must satisfy the following
13742 conditions:
13743
13744 @itemize @bullet
13745 @item It must not be empty
13746 @item It cannot start with an alphanumeric character
13747 @item It cannot start with an underscore followed by an alphanumeric character
13748 @item It cannot be a suffix of @code{Spec_Suffix}
13749 @end itemize
13750
13751 @noindent
13752 For Ada, the attribute denotes the suffix used in file names that contain
13753 library bodies, that is to say units that are package and subprogram bodies.
13754 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13755 @code{".adb"}.
13756
13757 For C and C++, the attribute denotes the suffix used in file names that contain
13758 source code.
13759
13760 @item Separate_Suffix
13761 This is a simple attribute whose value satisfies the same conditions as
13762 @code{Body_Suffix}.
13763
13764 This attribute is specific to Ada. It denotes the suffix used in file names
13765 that contain separate bodies. If it is not specified, then it defaults to same
13766 value as @code{Body_Suffix ("Ada")}.
13767
13768 @item Spec
13769 This is an associative array attribute, specific to Ada, defined over
13770 compilation unit names. The image is a string that is the name of the file
13771 that contains that library unit. The file name is case sensitive if the
13772 conventions of the host operating system require it.
13773
13774 @item Body
13775 This is an associative array attribute, specific to Ada, defined over
13776 compilation unit names. The image is a string that is the name of the file
13777 that contains the library unit body for the named unit. The file name is case
13778 sensitive if the conventions of the host operating system require it.
13779
13780 @item Specification_Exceptions
13781 This is an associative array attribute defined on language names,
13782 whose value is a list of strings.
13783
13784 This attribute is not significant for Ada.
13785
13786 For C and C++, each string in the list denotes the name of a file that
13787 contains prototypes, but whose suffix is not necessarily the
13788 @code{Spec_Suffix} for the language.
13789
13790 @item Implementation_Exceptions
13791 This is an associative array attribute defined on language names,
13792 whose value is a list of strings.
13793
13794 This attribute is not significant for Ada.
13795
13796 For C and C++, each string in the list denotes the name of a file that
13797 contains source code, but whose suffix is not necessarily the
13798 @code{Body_Suffix} for the language.
13799 @end table
13800
13801 The following attributes of package @code{Naming} are obsolescent. They are
13802 kept as synonyms of other attributes for compatibility with previous versions
13803 of the Project Manager.
13804
13805 @table @code
13806 @item Specification_Suffix
13807 This is a synonym of @code{Spec_Suffix}.
13808
13809 @item Implementation_Suffix
13810 This is a synonym of @code{Body_Suffix}.
13811
13812 @item Specification
13813 This is a synonym of @code{Spec}.
13814
13815 @item Implementation
13816 This is a synonym of @code{Body}.
13817 @end table
13818
13819 @subsection package Compiler
13820
13821 @noindent
13822 The attributes of the @code{Compiler} package specify the compilation options
13823 to be used by the underlying compiler.
13824
13825 @table @code
13826 @item  Default_Switches
13827 This is an associative array attribute. Its
13828 domain is a set of language names. Its range is a string list that
13829 specifies the compilation options to be used when compiling a component
13830 written in that language, for which no file-specific switches have been
13831 specified..
13832
13833 @item  Switches
13834 This is an associative array attribute. Its domain is
13835 a set of file names. Its range is a string list that specifies the
13836 compilation options to be used when compiling the named file. If a file
13837 is not specified in the Switches attribute, it is compiled with the
13838 settings specified by Default_Switches.
13839
13840 @item  Local_Configuration_Pragmas.
13841 This is a simple attribute, whose
13842 value is a path name that designates a file containing configuration pragmas
13843 to be used for all invocations of the compiler for immediate sources of the
13844 project.
13845
13846 @item Executable
13847 This is an associative array attribute. Its domain is
13848 a set of main source file names. Its range is a simple string that specifies
13849 the executable file name to be used when linking the specified main source.
13850 If a main source is not specified in the Executable attribute, the executable
13851 file name is deducted from the main source file name.
13852 @end table
13853
13854 @subsection package Builder
13855
13856 @noindent
13857 The attributes of package @code{Builder} specify the compilation, binding, and
13858 linking options to be used when building an executable for a project. The
13859 following attributes apply to package @code{Builder}:
13860
13861 @table @code
13862 @item Default_Switches
13863 As above.
13864
13865 @item Switches
13866 As above.
13867
13868 @item Global_Configuration_Pragmas
13869 This is a simple attribute, whose
13870 value is a path name that designates a file that contains configuration pragmas
13871 to be used in every build of an executable. If both local and global
13872 configuration pragmas are specified, a compilation makes use of both sets.
13873
13874 @item Executable
13875 This is an associative array attribute, defined over
13876 compilation unit names. The image is a string that is the name of the
13877 executable file corresponding to the main source file index.
13878 This attribute has no effect if its value is the empty string.
13879
13880 @item Executable_Suffix
13881 This is a simple attribute whose value is a suffix to be added to
13882 the executables that don't have an attribute Executable specified.
13883 @end table
13884
13885 @subsection package Gnatls
13886
13887 @noindent
13888 The attributes of package @code{Gnatls} specify the tool options to be used
13889 when invoking the library browser @command{gnatls}.
13890 The following attributes apply to package @code{Gnatls}:
13891
13892 @table @code
13893 @item Switches
13894 As above.
13895 @end table
13896
13897 @subsection package Binder
13898
13899 @noindent
13900 The attributes of package @code{Binder} specify the options to be used
13901 when invoking the binder in the construction of an executable.
13902 The following attributes apply to package @code{Binder}:
13903
13904 @table @code
13905 @item     Default_Switches
13906 As above.
13907 @item     Switches
13908 As above.
13909 @end table
13910
13911 @subsection package Linker
13912
13913 @noindent
13914 The attributes of package @code{Linker} specify the options to be used when
13915 invoking the linker in the construction of an executable.
13916 The following attributes apply to package @code{Linker}:
13917
13918 @table @code
13919 @item     Default_Switches
13920 As above
13921 @item     Switches
13922 As above.
13923 @end table
13924
13925 @subsection package Cross_Reference
13926
13927 @noindent
13928 The attributes of package @code{Cross_Reference} specify the tool options
13929 to be used
13930 when invoking the library tool @command{gnatxref}.
13931 The following attributes apply to package @code{Cross_Reference}:
13932
13933 @table @code
13934 @item     Default_Switches
13935 As above.
13936 @item     Switches
13937 As above.
13938 @end table
13939
13940 @subsection package   Finder
13941
13942 @noindent
13943 The attributes of package @code{Finder} specify the tool options to be used
13944 when invoking the search tool @command{gnatfind}.
13945 The following attributes apply to package @code{Finder}:
13946
13947 @table @code
13948 @item     Default_Switches
13949 As above.
13950 @item     Switches
13951 As above.
13952 @end table
13953
13954 @subsection package Pretty_Printer
13955
13956 @noindent
13957 The attributes of package @code{Pretty_Printer}
13958 specify the tool options to be used
13959 when invoking the formatting tool @command{gnatpp}.
13960 The following attributes apply to package @code{Pretty_Printer}:
13961
13962 @table @code
13963 @item     Default_switches
13964 As above.
13965 @item     Switches
13966 As above.
13967 @end table
13968
13969 @subsection  package IDE
13970
13971 @noindent
13972 The attributes of package @code{IDE} specify the options to be used when using
13973 an Integrated Development Environment such as @command{GPS}.
13974
13975 @table @code
13976 @item Remote_Host
13977 This is a simple attribute. Its value is a string that designates the remote
13978 host in a cross-compilation environment, to be used for remote compilation and
13979 debugging. This field should not be specified when running on the local
13980 machine.
13981
13982 @item Program_Host
13983 This is a simple attribute. Its value is a string that specifies the
13984 name of IP address of the embedded target in a cross-compilation environment,
13985 on which the program should execute.
13986
13987 @item Communication_Protocol
13988 This is a simple string attribute. Its value is the name of the protocol
13989 to use to communicate with the target in a cross-compilation environment,
13990 e.g. @code{"wtx"} or @code{"vxworks"}.
13991
13992 @item Compiler_Command
13993 This is an associative array attribute, whose domain is a language name. Its
13994 value is  string that denotes the command to be used to invoke the compiler.
13995 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
13996 gnatmake, in particular in the handling of switches.
13997
13998 @item Debugger_Command
13999 This is simple attribute, Its value is a string that specifies the name of
14000 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14001
14002 @item Default_Switches
14003 This is an associative array attribute. Its indexes are the name of the
14004 external tools that the GNAT Programming System (GPS) is supporting. Its
14005 value is a list of switches to use when invoking that tool.
14006
14007 @item  Gnatlist
14008 This is a simple attribute.  Its value is a string that specifies the name
14009 of the @command{gnatls} utility to be used to retrieve information about the
14010 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14011
14012 @item VCS_Kind
14013 This is a simple atribute. Is value is a string used to specify the
14014 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14015 ClearCase or Perforce.
14016
14017 @item VCS_File_Check
14018 This is a simple attribute. Its value is a string that specifies the
14019 command used by the VCS to check the validity of a file, either
14020 when the user explicitly asks for a check, or as a sanity check before
14021 doing the check-in.
14022
14023 @item VCS_Log_Check
14024 This is a simple attribute. Its value is a string that specifies
14025 the command used by the VCS to check the validity of a log file.
14026
14027 @end table
14028
14029 @node Package Renamings
14030 @section Package Renamings
14031
14032 @noindent
14033 A package can be defined by a renaming declaration. The new package renames
14034 a package declared in a different project file, and has the same attributes
14035 as the package it renames.
14036 Syntax:
14037 @smallexample
14038 package_renaming ::==
14039   @b{package} package_identifier @b{renames}
14040        <project_>simple_name.package_identifier ;
14041 @end smallexample
14042
14043 @noindent
14044 The package_identifier of the renamed package must be the same as the
14045 package_identifier. The project whose name is the prefix of the renamed
14046 package must contain a package declaration with this name. This project
14047 must appear in the context_clause of the enclosing project declaration,
14048 or be the parent project of the enclosing child project.
14049
14050 @node Projects
14051 @section Projects
14052
14053 @noindent
14054 A project file specifies a set of rules for constructing a software system.
14055 A project file can be self-contained, or depend on other project files.
14056 Dependencies are expressed through a context clause that names other projects.
14057
14058 Syntax:
14059
14060 @smallexample
14061 project ::=
14062   context_clause project_declaration
14063
14064 project_declaration ::=
14065   simple_project_declaration | project_extension
14066
14067 simple_project_declaration ::=
14068   @b{project} <project_>simple_name @b{is}
14069     @{declarative_item@}
14070   @b{end} <project_>simple_name;
14071
14072 context_clause ::=
14073   @{with_clause@}
14074
14075 with_clause ::=
14076   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14077
14078 path_name ::=
14079    string_literal
14080 @end smallexample
14081
14082 @noindent
14083 A path name denotes a project file. A path name can be absolute or relative.
14084 An absolute path name includes a sequence of directories, in the syntax of
14085 the host operating system, that identifies uniquely the project file in the
14086 file system. A relative path name identifies the project file, relative
14087 to the directory that contains the current project, or relative to a
14088 directory listed in the environment variable ADA_PROJECT_PATH.
14089 Path names are case sensitive if file names in the host operating system
14090 are case sensitive.
14091
14092 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14093 directory names separated by colons (semicolons on Windows).
14094
14095 A given project name can appear only once in a context_clause.
14096
14097 It is illegal for a project imported by a context clause to refer, directly
14098 or indirectly, to the project in which this context clause appears (the
14099 dependency graph cannot contain cycles), except when one of the with_clause
14100 in the cycle is a @code{limited with}.
14101
14102 @node Project Extensions
14103 @section Project Extensions
14104
14105 @noindent
14106 A project extension introduces a new project, which inherits the declarations
14107 of another project.
14108 Syntax:
14109 @smallexample
14110
14111 project_extension ::=
14112   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14113     @{declarative_item@}
14114   @b{end} <project_>simple_name;
14115 @end smallexample
14116
14117 @noindent
14118 The project extension declares a child project. The child project inherits
14119 all the declarations and all the files of the parent project, These inherited
14120 declaration can be overridden in the child project, by means of suitable
14121 declarations.
14122
14123 @node Project File Elaboration
14124 @section Project File Elaboration
14125
14126 @noindent
14127 A project file is processed as part of the invocation of a gnat tool that
14128 uses the project option. Elaboration of the process file consists in the
14129 sequential elaboration of all its declarations. The computed values of
14130 attributes and variables in the project are then used to establish the
14131 environment in which the gnat tool will execute.
14132
14133 @include fdl.texi
14134 @c GNU Free Documentation License
14135
14136 @node Index,,GNU Free Documentation License, Top
14137 @unnumbered Index
14138
14139 @printindex cp
14140
14141 @contents
14142
14143 @bye