OSDN Git Service

2004-08-13 Olivier Hainque <hainque@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
20 @set FSFEDITION
21
22 @settitle GNAT Reference Manual
23
24 @setchapternewpage odd
25 @syncodeindex fn cp
26
27 @include gcc-common.texi
28
29 @dircategory GNU Ada tools
30 @direntry
31 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
32 @end direntry
33
34 @copying
35 Copyright @copyright{} 1995-2004, Free Software Foundation
36
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.2
39 or any later version published by the Free Software Foundation;
40 with the Invariant Sections being ``GNU Free Documentation License'',
41 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
42 no Back-Cover Texts. A copy of the license is included in the section
43 entitled ``GNU Free Documentation License''.
44 @end copying
45
46 @titlepage
47
48 @title GNAT Reference Manual
49 @subtitle GNAT, The GNU Ada 95 Compiler
50 @subtitle GCC version @value{version-GCC}
51 @author Ada Core Technologies, Inc.
52
53 @page
54 @vskip 0pt plus 1filll
55
56 @insertcopying
57
58 @end titlepage
59
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
63
64 @noindent
65 GNAT Reference Manual
66
67 @noindent
68 GNAT, The GNU Ada 95 Compiler@*
69 GCC version @value{version-GCC}@*
70
71 @noindent
72 Ada Core Technologies, Inc.
73
74 @menu
75 * About This Guide::
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
84 * The GNAT Library::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
91 * Index::
92
93  --- The Detailed Node Listing ---
94
95 About This Guide
96
97 * What This Reference Manual Contains::
98 * Related Information::
99
100 Implementation Defined Pragmas
101
102 * Pragma Abort_Defer::
103 * Pragma Ada_83::
104 * Pragma Ada_95::
105 * Pragma Annotate::
106 * Pragma Assert::
107 * Pragma Ast_Entry::
108 * Pragma C_Pass_By_Copy::
109 * Pragma Comment::
110 * Pragma Common_Object::
111 * Pragma Compile_Time_Warning::
112 * Pragma Complex_Representation::
113 * Pragma Component_Alignment::
114 * Pragma Convention_Identifier::
115 * Pragma CPP_Class::
116 * Pragma CPP_Constructor::
117 * Pragma CPP_Virtual::
118 * Pragma CPP_Vtable::
119 * Pragma Debug::
120 * Pragma Elaboration_Checks::
121 * Pragma Eliminate::
122 * Pragma Export_Exception::
123 * Pragma Export_Function::
124 * Pragma Export_Object::
125 * Pragma Export_Procedure::
126 * Pragma Export_Value::
127 * Pragma Export_Valued_Procedure::
128 * Pragma Extend_System::
129 * Pragma External::
130 * Pragma External_Name_Casing::
131 * Pragma Finalize_Storage_Only::
132 * Pragma Float_Representation::
133 * Pragma Ident::
134 * Pragma Import_Exception::
135 * Pragma Import_Function::
136 * Pragma Import_Object::
137 * Pragma Import_Procedure::
138 * Pragma Import_Valued_Procedure::
139 * Pragma Initialize_Scalars::
140 * Pragma Inline_Always::
141 * Pragma Inline_Generic::
142 * Pragma Interface::
143 * Pragma Interface_Name::
144 * Pragma Interrupt_Handler::
145 * Pragma Interrupt_State::
146 * Pragma Keep_Names::
147 * Pragma License::
148 * Pragma Link_With::
149 * Pragma Linker_Alias::
150 * Pragma Linker_Section::
151 * Pragma Long_Float::
152 * Pragma Machine_Attribute::
153 * Pragma Main_Storage::
154 * Pragma No_Return::
155 * Pragma Normalize_Scalars::
156 * Pragma Obsolescent::
157 * Pragma Passive::
158 * Pragma Polling::
159 * Pragma Profile (Ravenscar)::
160 * Pragma Profile (Restricted)::
161 * Pragma Propagate_Exceptions::
162 * Pragma Psect_Object::
163 * Pragma Pure_Function::
164 * Pragma Restriction_Warnings::
165 * Pragma Source_File_Name::
166 * Pragma Source_File_Name_Project::
167 * Pragma Source_Reference::
168 * Pragma Stream_Convert::
169 * Pragma Style_Checks::
170 * Pragma Subtitle::
171 * Pragma Suppress_All::
172 * Pragma Suppress_Exception_Locations::
173 * Pragma Suppress_Initialization::
174 * Pragma Task_Info::
175 * Pragma Task_Name::
176 * Pragma Task_Storage::
177 * Pragma Thread_Body::
178 * Pragma Time_Slice::
179 * Pragma Title::
180 * Pragma Unchecked_Union::
181 * Pragma Unimplemented_Unit::
182 * Pragma Universal_Data::
183 * Pragma Unreferenced::
184 * Pragma Unreserve_All_Interrupts::
185 * Pragma Unsuppress::
186 * Pragma Use_VADS_Size::
187 * Pragma Validity_Checks::
188 * Pragma Volatile::
189 * Pragma Warnings::
190 * Pragma Weak_External::
191
192 Implementation Defined Attributes
193
194 * Abort_Signal::
195 * Address_Size::
196 * Asm_Input::
197 * Asm_Output::
198 * AST_Entry::
199 * Bit::
200 * Bit_Position::
201 * Code_Address::
202 * Default_Bit_Order::
203 * Elaborated::
204 * Elab_Body::
205 * Elab_Spec::
206 * Emax::
207 * Enum_Rep::
208 * Epsilon::
209 * Fixed_Value::
210 * Has_Access_Values::
211 * Has_Discriminants::
212 * Img::
213 * Integer_Value::
214 * Large::
215 * Machine_Size::
216 * Mantissa::
217 * Max_Interrupt_Priority::
218 * Max_Priority::
219 * Maximum_Alignment::
220 * Mechanism_Code::
221 * Null_Parameter::
222 * Object_Size::
223 * Passed_By_Reference::
224 * Range_Length::
225 * Safe_Emax::
226 * Safe_Large::
227 * Small::
228 * Storage_Unit::
229 * Target_Name::
230 * Tick::
231 * To_Address::
232 * Type_Class::
233 * UET_Address::
234 * Unconstrained_Array::
235 * Universal_Literal_String::
236 * Unrestricted_Access::
237 * VADS_Size::
238 * Value_Size::
239 * Wchar_T_Size::
240 * Word_Size::
241
242 The Implementation of Standard I/O
243
244 * Standard I/O Packages::
245 * FORM Strings::
246 * Direct_IO::
247 * Sequential_IO::
248 * Text_IO::
249 * Wide_Text_IO::
250 * Stream_IO::
251 * Shared Files::
252 * Open Modes::
253 * Operations on C Streams::
254 * Interfacing to C Streams::
255
256 The GNAT Library
257
258 * Ada.Characters.Latin_9 (a-chlat9.ads)::
259 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
260 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
261 * Ada.Command_Line.Remove (a-colire.ads)::
262 * Ada.Command_Line.Environment (a-colien.ads)::
263 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
264 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
265 * Ada.Exceptions.Traceback (a-exctra.ads)::
266 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
267 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
268 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
269 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
270 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
271 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
272 * GNAT.Array_Split (g-arrspl.ads)::
273 * GNAT.AWK (g-awk.ads)::
274 * GNAT.Bounded_Buffers (g-boubuf.ads)::
275 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
276 * GNAT.Bubble_Sort (g-bubsor.ads)::
277 * GNAT.Bubble_Sort_A (g-busora.ads)::
278 * GNAT.Bubble_Sort_G (g-busorg.ads)::
279 * GNAT.Calendar (g-calend.ads)::
280 * GNAT.Calendar.Time_IO (g-catiio.ads)::
281 * GNAT.Case_Util (g-casuti.ads)::
282 * GNAT.CGI (g-cgi.ads)::
283 * GNAT.CGI.Cookie (g-cgicoo.ads)::
284 * GNAT.CGI.Debug (g-cgideb.ads)::
285 * GNAT.Command_Line (g-comlin.ads)::
286 * GNAT.Compiler_Version (g-comver.ads)::
287 * GNAT.Ctrl_C (g-ctrl_c.ads)::
288 * GNAT.CRC32 (g-crc32.ads)::
289 * GNAT.Current_Exception (g-curexc.ads)::
290 * GNAT.Debug_Pools (g-debpoo.ads)::
291 * GNAT.Debug_Utilities (g-debuti.ads)::
292 * GNAT.Directory_Operations (g-dirope.ads)::
293 * GNAT.Dynamic_HTables (g-dynhta.ads)::
294 * GNAT.Dynamic_Tables (g-dyntab.ads)::
295 * GNAT.Exception_Actions (g-excact.ads)::
296 * GNAT.Exception_Traces (g-exctra.ads)::
297 * GNAT.Exceptions (g-except.ads)::
298 * GNAT.Expect (g-expect.ads)::
299 * GNAT.Float_Control (g-flocon.ads)::
300 * GNAT.Heap_Sort (g-heasor.ads)::
301 * GNAT.Heap_Sort_A (g-hesora.ads)::
302 * GNAT.Heap_Sort_G (g-hesorg.ads)::
303 * GNAT.HTable (g-htable.ads)::
304 * GNAT.IO (g-io.ads)::
305 * GNAT.IO_Aux (g-io_aux.ads)::
306 * GNAT.Lock_Files (g-locfil.ads)::
307 * GNAT.MD5 (g-md5.ads)::
308 * GNAT.Memory_Dump (g-memdum.ads)::
309 * GNAT.Most_Recent_Exception (g-moreex.ads)::
310 * GNAT.OS_Lib (g-os_lib.ads)::
311 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
312 * GNAT.Regexp (g-regexp.ads)::
313 * GNAT.Registry (g-regist.ads)::
314 * GNAT.Regpat (g-regpat.ads)::
315 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
316 * GNAT.Semaphores (g-semaph.ads)::
317 * GNAT.Signals (g-signal.ads)::
318 * GNAT.Sockets (g-socket.ads)::
319 * GNAT.Source_Info (g-souinf.ads)::
320 * GNAT.Spell_Checker (g-speche.ads)::
321 * GNAT.Spitbol.Patterns (g-spipat.ads)::
322 * GNAT.Spitbol (g-spitbo.ads)::
323 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
324 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
325 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
326 * GNAT.Strings (g-string.ads)::
327 * GNAT.String_Split (g-strspl.ads)::
328 * GNAT.Table (g-table.ads)::
329 * GNAT.Task_Lock (g-tasloc.ads)::
330 * GNAT.Threads (g-thread.ads)::
331 * GNAT.Traceback (g-traceb.ads)::
332 * GNAT.Traceback.Symbolic (g-trasym.ads)::
333 * GNAT.Wide_String_Split (g-wistsp.ads)::
334 * Interfaces.C.Extensions (i-cexten.ads)::
335 * Interfaces.C.Streams (i-cstrea.ads)::
336 * Interfaces.CPP (i-cpp.ads)::
337 * Interfaces.Os2lib (i-os2lib.ads)::
338 * Interfaces.Os2lib.Errors (i-os2err.ads)::
339 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
340 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
341 * Interfaces.Packed_Decimal (i-pacdec.ads)::
342 * Interfaces.VxWorks (i-vxwork.ads)::
343 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
344 * System.Address_Image (s-addima.ads)::
345 * System.Assertions (s-assert.ads)::
346 * System.Memory (s-memory.ads)::
347 * System.Partition_Interface (s-parint.ads)::
348 * System.Restrictions (s-restri.ads)::
349 * System.Rident (s-rident.ads)::
350 * System.Task_Info (s-tasinf.ads)::
351 * System.Wch_Cnv (s-wchcnv.ads)::
352 * System.Wch_Con (s-wchcon.ads)::
353
354 Text_IO
355
356 * Text_IO Stream Pointer Positioning::
357 * Text_IO Reading and Writing Non-Regular Files::
358 * Get_Immediate::
359 * Treating Text_IO Files as Streams::
360 * Text_IO Extensions::
361 * Text_IO Facilities for Unbounded Strings::
362
363 Wide_Text_IO
364
365 * Wide_Text_IO Stream Pointer Positioning::
366 * Wide_Text_IO Reading and Writing Non-Regular Files::
367
368 Interfacing to Other Languages
369
370 * Interfacing to C::
371 * Interfacing to C++::
372 * Interfacing to COBOL::
373 * Interfacing to Fortran::
374 * Interfacing to non-GNAT Ada code::
375
376 Specialized Needs Annexes
377
378 Implementation of Specific Ada Features
379 * Machine Code Insertions::
380 * GNAT Implementation of Tasking::
381 * GNAT Implementation of Shared Passive Packages::
382 * Code Generation for Array Aggregates::
383 * The Size of Discriminated Records with Default Discriminants::
384
385 Project File Reference
386
387 Obsolescent Features
388
389 GNU Free Documentation License
390
391 Index
392 @end menu
393
394 @end ifnottex
395
396 @node About This Guide
397 @unnumbered About This Guide
398
399 @ifclear PROEDITION
400 @noindent
401 This manual contains useful information in writing programs using the
402 GNAT compiler.  It includes information on implementation dependent
403 characteristics of GNAT, including all the information required by Annex
404 M of the standard.
405 @end ifclear
406
407 @ifset PROEDITION
408 @noindent
409 This manual contains useful information in writing programs using the
410 GNAT Pro compiler.  It includes information on implementation dependent
411 characteristics of GNAT Pro, including all the information required by Annex
412 M of the standard.
413 @end ifset
414
415 Ada 95 is designed to be highly portable.
416 In general, a program will have the same effect even when compiled by
417 different compilers on different platforms.
418 However, since Ada 95 is designed to be used in a
419 wide variety of applications, it also contains a number of system
420 dependent features to be used in interfacing to the external world.
421 @cindex Implementation-dependent features
422 @cindex Portability
423
424 Note: Any program that makes use of implementation-dependent features
425 may be non-portable.  You should follow good programming practice and
426 isolate and clearly document any sections of your program that make use
427 of these features in a non-portable manner.
428
429 @ifset PROEDITION
430 For ease of exposition, ``GNAT Pro'' will be referred to simply as
431 ``GNAT'' in the remainder of this document.
432 @end ifset
433
434 @menu
435 * What This Reference Manual Contains::
436 * Conventions::
437 * Related Information::
438 @end menu
439
440 @node What This Reference Manual Contains
441 @unnumberedsec What This Reference Manual Contains
442
443 @noindent
444 This reference manual contains the following chapters:
445
446 @itemize @bullet
447 @item
448 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
449 pragmas, which can be used to extend and enhance the functionality of the
450 compiler.
451
452 @item
453 @ref{Implementation Defined Attributes}, lists GNAT
454 implementation-dependent attributes which can be used to extend and
455 enhance the functionality of the compiler.
456
457 @item
458 @ref{Implementation Advice}, provides information on generally
459 desirable behavior which are not requirements that all compilers must
460 follow since it cannot be provided on all systems, or which may be
461 undesirable on some systems.
462
463 @item
464 @ref{Implementation Defined Characteristics}, provides a guide to
465 minimizing implementation dependent features.
466
467 @item
468 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
469 implemented by GNAT, and how they can be imported into user
470 application programs.
471
472 @item
473 @ref{Representation Clauses and Pragmas}, describes in detail the
474 way that GNAT represents data, and in particular the exact set
475 of representation clauses and pragmas that is accepted.
476
477 @item
478 @ref{Standard Library Routines}, provides a listing of packages and a
479 brief description of the functionality that is provided by Ada's
480 extensive set of standard library routines as implemented by GNAT@.
481
482 @item
483 @ref{The Implementation of Standard I/O}, details how the GNAT
484 implementation of the input-output facilities.
485
486 @item
487 @ref{The GNAT Library}, is a catalog of packages that complement
488 the Ada predefined library.
489
490 @item
491 @ref{Interfacing to Other Languages}, describes how programs
492 written in Ada using GNAT can be interfaced to other programming
493 languages.
494
495 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
496 of the specialized needs annexes.
497
498 @item
499 @ref{Implementation of Specific Ada Features}, discusses issues related
500 to GNAT's implementation of machine code insertions, tasking, and several
501 other features.
502
503 @item
504 @ref{Project File Reference}, presents the syntax and semantics
505 of project files.
506
507 @item
508 @ref{Obsolescent Features} documents implementation dependent features,
509 including pragmas and attributes, which are considered obsolescent, since
510 there are other preferred ways of achieving the same results. These
511 obsolescent forms are retained for backwards compatibilty.
512
513 @end itemize
514
515 @cindex Ada 95 ISO/ANSI Standard
516 @noindent
517 This reference manual assumes that you are familiar with Ada 95
518 language, as described in the International Standard
519 ANSI/ISO/IEC-8652:1995, Jan 1995.
520
521 @node Conventions
522 @unnumberedsec Conventions
523 @cindex Conventions, typographical
524 @cindex Typographical conventions
525
526 @noindent
527 Following are examples of the typographical and graphic conventions used
528 in this guide:
529
530 @itemize @bullet
531 @item
532 @code{Functions}, @code{utility program names}, @code{standard names},
533 and @code{classes}.
534
535 @item
536 @code{Option flags}
537
538 @item
539 @file{File Names}, @samp{button names}, and @samp{field names}.
540
541 @item
542 @code{Variables}.
543
544 @item
545 @emph{Emphasis}.
546
547 @item
548 [optional information or parameters]
549
550 @item
551 Examples are described by text
552 @smallexample
553 and then shown this way.
554 @end smallexample
555 @end itemize
556
557 @noindent
558 Commands that are entered by the user are preceded in this manual by the
559 characters @samp{$ } (dollar sign followed by space).  If your system uses this
560 sequence as a prompt, then the commands will appear exactly as you see them
561 in the manual.  If your system uses some other prompt, then the command will
562 appear with the @samp{$} replaced by whatever prompt character you are using.
563
564 @node Related Information
565 @unnumberedsec Related Information
566 @noindent
567 See the following documents for further information on GNAT:
568
569 @itemize @bullet
570 @item
571 @cite{GNAT User's Guide}, which provides information on how to use
572 the GNAT compiler system.
573
574 @item
575 @cite{Ada 95 Reference Manual}, which contains all reference
576 material for the Ada 95 programming language.
577
578 @item
579 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
580 of the standard reference manual cited above.  The annotations describe
581 detailed aspects of the design decision, and in particular contain useful
582 sections on Ada 83 compatibility.
583
584 @item
585 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
586 which contains specific information on compatibility between GNAT and
587 DEC Ada 83 systems.
588
589 @item
590 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
591 describes in detail the pragmas and attributes provided by the DEC Ada 83
592 compiler system.
593
594 @end itemize
595
596 @node Implementation Defined Pragmas
597 @chapter Implementation Defined Pragmas
598
599 @noindent
600 Ada 95 defines a set of pragmas that can be used to supply additional
601 information to the compiler.  These language defined pragmas are
602 implemented in GNAT and work as described in the Ada 95 Reference
603 Manual.
604
605 In addition, Ada 95 allows implementations to define additional pragmas
606 whose meaning is defined by the implementation.  GNAT provides a number
607 of these implementation-dependent pragmas which can be used to extend
608 and enhance the functionality of the compiler.  This section of the GNAT
609 Reference Manual describes these additional pragmas.
610
611 Note that any program using these pragmas may not be portable to other
612 compilers (although GNAT implements this set of pragmas on all
613 platforms).  Therefore if portability to other compilers is an important
614 consideration, the use of these pragmas should be minimized.
615
616 @menu
617 * Pragma Abort_Defer::
618 * Pragma Ada_83::
619 * Pragma Ada_95::
620 * Pragma Annotate::
621 * Pragma Assert::
622 * Pragma Ast_Entry::
623 * Pragma C_Pass_By_Copy::
624 * Pragma Comment::
625 * Pragma Common_Object::
626 * Pragma Compile_Time_Warning::
627 * Pragma Complex_Representation::
628 * Pragma Component_Alignment::
629 * Pragma Convention_Identifier::
630 * Pragma CPP_Class::
631 * Pragma CPP_Constructor::
632 * Pragma CPP_Virtual::
633 * Pragma CPP_Vtable::
634 * Pragma Debug::
635 * Pragma Elaboration_Checks::
636 * Pragma Eliminate::
637 * Pragma Export_Exception::
638 * Pragma Export_Function::
639 * Pragma Export_Object::
640 * Pragma Export_Procedure::
641 * Pragma Export_Value::
642 * Pragma Export_Valued_Procedure::
643 * Pragma Extend_System::
644 * Pragma External::
645 * Pragma External_Name_Casing::
646 * Pragma Finalize_Storage_Only::
647 * Pragma Float_Representation::
648 * Pragma Ident::
649 * Pragma Import_Exception::
650 * Pragma Import_Function::
651 * Pragma Import_Object::
652 * Pragma Import_Procedure::
653 * Pragma Import_Valued_Procedure::
654 * Pragma Initialize_Scalars::
655 * Pragma Inline_Always::
656 * Pragma Inline_Generic::
657 * Pragma Interface::
658 * Pragma Interface_Name::
659 * Pragma Interrupt_Handler::
660 * Pragma Interrupt_State::
661 * Pragma Keep_Names::
662 * Pragma License::
663 * Pragma Link_With::
664 * Pragma Linker_Alias::
665 * Pragma Linker_Section::
666 * Pragma Long_Float::
667 * Pragma Machine_Attribute::
668 * Pragma Main_Storage::
669 * Pragma No_Return::
670 * Pragma Normalize_Scalars::
671 * Pragma Obsolescent::
672 * Pragma Passive::
673 * Pragma Polling::
674 * Pragma Profile (Ravenscar)::
675 * Pragma Profile (Restricted)::
676 * Pragma Propagate_Exceptions::
677 * Pragma Psect_Object::
678 * Pragma Pure_Function::
679 * Pragma Restriction_Warnings::
680 * Pragma Source_File_Name::
681 * Pragma Source_File_Name_Project::
682 * Pragma Source_Reference::
683 * Pragma Stream_Convert::
684 * Pragma Style_Checks::
685 * Pragma Subtitle::
686 * Pragma Suppress_All::
687 * Pragma Suppress_Exception_Locations::
688 * Pragma Suppress_Initialization::
689 * Pragma Task_Info::
690 * Pragma Task_Name::
691 * Pragma Task_Storage::
692 * Pragma Thread_Body::
693 * Pragma Time_Slice::
694 * Pragma Title::
695 * Pragma Unchecked_Union::
696 * Pragma Unimplemented_Unit::
697 * Pragma Universal_Data::
698 * Pragma Unreferenced::
699 * Pragma Unreserve_All_Interrupts::
700 * Pragma Unsuppress::
701 * Pragma Use_VADS_Size::
702 * Pragma Validity_Checks::
703 * Pragma Volatile::
704 * Pragma Warnings::
705 * Pragma Weak_External::
706 @end menu
707
708 @node Pragma Abort_Defer
709 @unnumberedsec Pragma Abort_Defer
710 @findex Abort_Defer
711 @cindex Deferring aborts
712 @noindent
713 Syntax:
714 @smallexample
715 pragma Abort_Defer;
716 @end smallexample
717
718 @noindent
719 This pragma must appear at the start of the statement sequence of a
720 handled sequence of statements (right after the @code{begin}).  It has
721 the effect of deferring aborts for the sequence of statements (but not
722 for the declarations or handlers, if any, associated with this statement
723 sequence).
724
725 @node Pragma Ada_83
726 @unnumberedsec Pragma Ada_83
727 @findex Ada_83
728 @noindent
729 Syntax:
730 @smallexample @c ada
731 pragma Ada_83;
732 @end smallexample
733
734 @noindent
735 A configuration pragma that establishes Ada 83 mode for the unit to
736 which it applies, regardless of the mode set by the command line
737 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
738 the syntax and semantics of Ada 83, as defined in the original Ada
739 83 Reference Manual as possible.  In particular, the new Ada 95
740 keywords are not recognized, optional package bodies are allowed,
741 and generics may name types with unknown discriminants without using
742 the @code{(<>)} notation.  In addition, some but not all of the additional
743 restrictions of Ada 83 are enforced.
744
745 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
746 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
747 Secondly, it aids in keeping code backwards compatible with Ada 83.
748 However, there is no guarantee that code that is processed correctly
749 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
750 83 compiler, since GNAT does not enforce all the additional checks
751 required by Ada 83.
752
753 @node Pragma Ada_95
754 @unnumberedsec Pragma Ada_95
755 @findex Ada_95
756 @noindent
757 Syntax:
758 @smallexample @c ada
759 pragma Ada_95;
760 @end smallexample
761
762 @noindent
763 A configuration pragma that establishes Ada 95 mode for the unit to which
764 it applies, regardless of the mode set by the command line switches.
765 This mode is set automatically for the @code{Ada} and @code{System}
766 packages and their children, so you need not specify it in these
767 contexts.  This pragma is useful when writing a reusable component that
768 itself uses Ada 95 features, but which is intended to be usable from
769 either Ada 83 or Ada 95 programs.
770
771 @node Pragma Annotate
772 @unnumberedsec Pragma Annotate
773 @findex Annotate
774 @noindent
775 Syntax:
776 @smallexample @c ada
777 pragma Annotate (IDENTIFIER @{, ARG@});
778
779 ARG ::= NAME | EXPRESSION
780 @end smallexample
781
782 @noindent
783 This pragma is used to annotate programs.  @var{identifier} identifies
784 the type of annotation.  GNAT verifies this is an identifier, but does
785 not otherwise analyze it.  The @var{arg} argument
786 can be either a string literal or an
787 expression.  String literals are assumed to be of type
788 @code{Standard.String}.  Names of entities are simply analyzed as entity
789 names.  All other expressions are analyzed as expressions, and must be
790 unambiguous.
791
792 The analyzed pragma is retained in the tree, but not otherwise processed
793 by any part of the GNAT compiler.  This pragma is intended for use by
794 external tools, including ASIS@.
795
796 @node Pragma Assert
797 @unnumberedsec Pragma Assert
798 @findex Assert
799 @noindent
800 Syntax:
801 @smallexample @c ada
802 pragma Assert (
803   boolean_EXPRESSION
804   [, static_string_EXPRESSION]);
805 @end smallexample
806
807 @noindent
808 The effect of this pragma depends on whether the corresponding command
809 line switch is set to activate assertions.  The pragma expands into code
810 equivalent to the following:
811
812 @smallexample @c ada
813 if assertions-enabled then
814    if not boolean_EXPRESSION then
815       System.Assertions.Raise_Assert_Failure
816         (string_EXPRESSION);
817    end if;
818 end if;
819 @end smallexample
820
821 @noindent
822 The string argument, if given, is the message that will be associated
823 with the exception occurrence if the exception is raised.  If no second
824 argument is given, the default message is @samp{@var{file}:@var{nnn}},
825 where @var{file} is the name of the source file containing the assert,
826 and @var{nnn} is the line number of the assert.  A pragma is not a
827 statement, so if a statement sequence contains nothing but a pragma
828 assert, then a null statement is required in addition, as in:
829
830 @smallexample @c ada
831 @dots{}
832 if J > 3 then
833    pragma Assert (K > 3, "Bad value for K");
834    null;
835 end if;
836 @end smallexample
837
838 @noindent
839 Note that, as with the @code{if} statement to which it is equivalent, the
840 type of the expression is either @code{Standard.Boolean}, or any type derived
841 from this standard type.
842
843 If assertions are disabled (switch @code{-gnata} not used), then there
844 is no effect (and in particular, any side effects from the expression
845 are suppressed).  More precisely it is not quite true that the pragma
846 has no effect, since the expression is analyzed, and may cause types
847 to be frozen if they are mentioned here for the first time.
848
849 If assertions are enabled, then the given expression is tested, and if
850 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
851 which results in the raising of @code{Assert_Failure} with the given message.
852
853 If the boolean expression has side effects, these side effects will turn
854 on and off with the setting of the assertions mode, resulting in
855 assertions that have an effect on the program.  You should generally
856 avoid side effects in the expression arguments of this pragma.  However,
857 the expressions are analyzed for semantic correctness whether or not
858 assertions are enabled, so turning assertions on and off cannot affect
859 the legality of a program.
860
861 @node Pragma Ast_Entry
862 @unnumberedsec Pragma Ast_Entry
863 @cindex OpenVMS
864 @findex Ast_Entry
865 @noindent
866 Syntax:
867 @smallexample @c ada
868 pragma AST_Entry (entry_IDENTIFIER);
869 @end smallexample
870
871 @noindent
872 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
873 argument is the simple name of a single entry; at most one @code{AST_Entry}
874 pragma is allowed for any given entry.  This pragma must be used in
875 conjunction with the @code{AST_Entry} attribute, and is only allowed after
876 the entry declaration and in the same task type specification or single task
877 as the entry to which it applies.  This pragma specifies that the given entry
878 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
879 resulting from an OpenVMS system service call.  The pragma does not affect
880 normal use of the entry.  For further details on this pragma, see the
881 DEC Ada Language Reference Manual, section 9.12a.
882
883 @node Pragma C_Pass_By_Copy
884 @unnumberedsec Pragma C_Pass_By_Copy
885 @cindex Passing by copy
886 @findex C_Pass_By_Copy
887 @noindent
888 Syntax:
889 @smallexample @c ada
890 pragma C_Pass_By_Copy
891   ([Max_Size =>] static_integer_EXPRESSION);
892 @end smallexample
893
894 @noindent
895 Normally the default mechanism for passing C convention records to C
896 convention subprograms is to pass them by reference, as suggested by RM
897 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
898 this default, by requiring that record formal parameters be passed by
899 copy if all of the following conditions are met:
900
901 @itemize @bullet
902 @item
903 The size of the record type does not exceed@*@var{static_integer_expression}.
904 @item
905 The record type has @code{Convention C}.
906 @item
907 The formal parameter has this record type, and the subprogram has a
908 foreign (non-Ada) convention.
909 @end itemize
910
911 @noindent
912 If these conditions are met the argument is passed by copy, i.e.@: in a
913 manner consistent with what C expects if the corresponding formal in the
914 C prototype is a struct (rather than a pointer to a struct).
915
916 You can also pass records by copy by specifying the convention
917 @code{C_Pass_By_Copy} for the record type, or by using the extended
918 @code{Import} and @code{Export} pragmas, which allow specification of
919 passing mechanisms on a parameter by parameter basis.
920
921 @node Pragma Comment
922 @unnumberedsec Pragma Comment
923 @findex Comment
924 @noindent
925 Syntax:
926
927 @smallexample @c ada
928 pragma Comment (static_string_EXPRESSION);
929 @end smallexample
930
931 @noindent
932 This is almost identical in effect to pragma @code{Ident}.  It allows the
933 placement of a comment into the object file and hence into the
934 executable file if the operating system permits such usage.  The
935 difference is that @code{Comment}, unlike @code{Ident}, has
936 no limitations on placement of the pragma (it can be placed
937 anywhere in the main source unit), and if more than one pragma
938 is used, all comments are retained.
939
940 @node Pragma Common_Object
941 @unnumberedsec Pragma Common_Object
942 @findex Common_Object
943 @noindent
944 Syntax:
945
946 @smallexample @c ada
947 pragma Common_Object (
948      [Internal =>] LOCAL_NAME,
949   [, [External =>] EXTERNAL_SYMBOL]
950   [, [Size     =>] EXTERNAL_SYMBOL] );
951
952 EXTERNAL_SYMBOL ::=
953   IDENTIFIER
954 | static_string_EXPRESSION
955 @end smallexample
956
957 @noindent
958 This pragma enables the shared use of variables stored in overlaid
959 linker areas corresponding to the use of @code{COMMON}
960 in Fortran.  The single
961 object @var{local_name} is assigned to the area designated by
962 the @var{External} argument.
963 You may define a record to correspond to a series
964 of fields.  The @var{size} argument
965 is syntax checked in GNAT, but otherwise ignored.
966
967 @code{Common_Object} is not supported on all platforms.  If no
968 support is available, then the code generator will issue a message
969 indicating that the necessary attribute for implementation of this
970 pragma is not available.
971
972 @node Pragma Compile_Time_Warning
973 @unnumberedsec Pragma Compile_Time_Warning
974 @findex Compile_Time_Warning
975 @noindent
976 Syntax:
977
978 @smallexample @c ada
979 pragma Compile_Time_Warning
980          (boolean_EXPRESSION, static_string_EXPRESSION);
981 @end smallexample
982
983 @noindent
984 This pragma can be used to generate additional compile time warnings. It
985 is particularly useful in generics, where warnings can be issued for
986 specific problematic instantiations. The first parameter is a boolean
987 expression. The pragma is effective only if the value of this expression
988 is known at compile time, and has the value True. The set of expressions
989 whose values are known at compile time includes all static boolean
990 expressions, and also other values which the compiler can determine
991 at compile time (e.g. the size of a record type set by an explicit
992 size representation clause, or the value of a variable which was
993 initialized to a constant and is known not to have been modified).
994 If these conditions are met, a warning message is generated using
995 the value given as the second argument. This string value may contain
996 embedded ASCII.LF characters to break the message into multiple lines.
997
998 @node Pragma Complex_Representation
999 @unnumberedsec Pragma Complex_Representation
1000 @findex Complex_Representation
1001 @noindent
1002 Syntax:
1003
1004 @smallexample @c ada
1005 pragma Complex_Representation
1006         ([Entity =>] LOCAL_NAME);
1007 @end smallexample
1008
1009 @noindent
1010 The @var{Entity} argument must be the name of a record type which has
1011 two fields of the same floating-point type.  The effect of this pragma is
1012 to force gcc to use the special internal complex representation form for
1013 this record, which may be more efficient.  Note that this may result in
1014 the code for this type not conforming to standard ABI (application
1015 binary interface) requirements for the handling of record types.  For
1016 example, in some environments, there is a requirement for passing
1017 records by pointer, and the use of this pragma may result in passing
1018 this type in floating-point registers.
1019
1020 @node Pragma Component_Alignment
1021 @unnumberedsec Pragma Component_Alignment
1022 @cindex Alignments of components
1023 @findex Component_Alignment
1024 @noindent
1025 Syntax:
1026
1027 @smallexample @c ada
1028 pragma Component_Alignment (
1029      [Form =>] ALIGNMENT_CHOICE
1030   [, [Name =>] type_LOCAL_NAME]);
1031
1032 ALIGNMENT_CHOICE ::=
1033   Component_Size
1034 | Component_Size_4
1035 | Storage_Unit
1036 | Default
1037 @end smallexample
1038
1039 @noindent
1040 Specifies the alignment of components in array or record types.
1041 The meaning of the @var{Form} argument is as follows:
1042
1043 @table @code
1044 @findex Component_Size
1045 @item Component_Size
1046 Aligns scalar components and subcomponents of the array or record type
1047 on boundaries appropriate to their inherent size (naturally
1048 aligned).  For example, 1-byte components are aligned on byte boundaries,
1049 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1050 integer components are aligned on 4-byte boundaries and so on.  These
1051 alignment rules correspond to the normal rules for C compilers on all
1052 machines except the VAX@.
1053
1054 @findex Component_Size_4
1055 @item Component_Size_4
1056 Naturally aligns components with a size of four or fewer
1057 bytes.  Components that are larger than 4 bytes are placed on the next
1058 4-byte boundary.
1059
1060 @findex Storage_Unit
1061 @item Storage_Unit
1062 Specifies that array or record components are byte aligned, i.e.@:
1063 aligned on boundaries determined by the value of the constant
1064 @code{System.Storage_Unit}.
1065
1066 @cindex OpenVMS
1067 @item Default
1068 Specifies that array or record components are aligned on default
1069 boundaries, appropriate to the underlying hardware or operating system or
1070 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1071 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1072 the @code{Default} choice is the same as @code{Component_Size} (natural
1073 alignment).
1074 @end table
1075
1076 @noindent
1077 If the @code{Name} parameter is present, @var{type_local_name} must
1078 refer to a local record or array type, and the specified alignment
1079 choice applies to the specified type.  The use of
1080 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1081 @code{Component_Alignment} pragma to be ignored.  The use of
1082 @code{Component_Alignment} together with a record representation clause
1083 is only effective for fields not specified by the representation clause.
1084
1085 If the @code{Name} parameter is absent, the pragma can be used as either
1086 a configuration pragma, in which case it applies to one or more units in
1087 accordance with the normal rules for configuration pragmas, or it can be
1088 used within a declarative part, in which case it applies to types that
1089 are declared within this declarative part, or within any nested scope
1090 within this declarative part.  In either case it specifies the alignment
1091 to be applied to any record or array type which has otherwise standard
1092 representation.
1093
1094 If the alignment for a record or array type is not specified (using
1095 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1096 clause), the GNAT uses the default alignment as described previously.
1097
1098 @node Pragma Convention_Identifier
1099 @unnumberedsec Pragma Convention_Identifier
1100 @findex Convention_Identifier
1101 @cindex Conventions, synonyms
1102 @noindent
1103 Syntax:
1104
1105 @smallexample @c ada
1106 pragma Convention_Identifier (
1107          [Name =>]       IDENTIFIER,
1108          [Convention =>] convention_IDENTIFIER);
1109 @end smallexample
1110
1111 @noindent
1112 This pragma provides a mechanism for supplying synonyms for existing
1113 convention identifiers. The @code{Name} identifier can subsequently
1114 be used as a synonym for the given convention in other pragmas (including
1115 for example pragma @code{Import} or another @code{Convention_Identifier}
1116 pragma). As an example of the use of this, suppose you had legacy code
1117 which used Fortran77 as the identifier for Fortran. Then the pragma:
1118
1119 @smallexample @c ada
1120 pragma Convention_Identifier (Fortran77, Fortran);
1121 @end smallexample
1122
1123 @noindent
1124 would allow the use of the convention identifier @code{Fortran77} in
1125 subsequent code, avoiding the need to modify the sources. As another
1126 example, you could use this to parametrize convention requirements
1127 according to systems. Suppose you needed to use @code{Stdcall} on
1128 windows systems, and @code{C} on some other system, then you could
1129 define a convention identifier @code{Library} and use a single
1130 @code{Convention_Identifier} pragma to specify which convention
1131 would be used system-wide.
1132
1133 @node Pragma CPP_Class
1134 @unnumberedsec Pragma CPP_Class
1135 @findex CPP_Class
1136 @cindex Interfacing with C++
1137 @noindent
1138 Syntax:
1139
1140 @smallexample @c ada
1141 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1142 @end smallexample
1143
1144 @noindent
1145 The argument denotes an entity in the current declarative region
1146 that is declared as a tagged or untagged record type.  It indicates that
1147 the type corresponds to an externally declared C++ class type, and is to
1148 be laid out the same way that C++ would lay out the type.
1149
1150 If (and only if) the type is tagged, at least one component in the
1151 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1152 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1153 for dispatching.
1154
1155 Types for which @code{CPP_Class} is specified do not have assignment or
1156 equality operators defined (such operations can be imported or declared
1157 as subprograms as required).  Initialization is allowed only by
1158 constructor functions (see pragma @code{CPP_Constructor}).
1159
1160 Pragma @code{CPP_Class} is intended primarily for automatic generation
1161 using an automatic binding generator tool.
1162 See @ref{Interfacing to C++} for related information.
1163
1164 @node Pragma CPP_Constructor
1165 @unnumberedsec Pragma CPP_Constructor
1166 @cindex Interfacing with C++
1167 @findex CPP_Constructor
1168 @noindent
1169 Syntax:
1170
1171 @smallexample @c ada
1172 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1173 @end smallexample
1174
1175 @noindent
1176 This pragma identifies an imported function (imported in the usual way
1177 with pragma @code{Import}) as corresponding to a C++
1178 constructor.  The argument is a name that must have been
1179 previously mentioned in a pragma @code{Import}
1180 with @code{Convention} = @code{CPP}, and must be of one of the following
1181 forms:
1182
1183 @itemize @bullet
1184 @item
1185 @code{function @var{Fname} return @var{T}'Class}
1186
1187 @item
1188 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1189 @end itemize
1190
1191 @noindent
1192 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1193
1194 The first form is the default constructor, used when an object of type
1195 @var{T} is created on the Ada side with no explicit constructor.  Other
1196 constructors (including the copy constructor, which is simply a special
1197 case of the second form in which the one and only argument is of type
1198 @var{T}), can only appear in two contexts:
1199
1200 @itemize @bullet
1201 @item
1202 On the right side of an initialization of an object of type @var{T}.
1203 @item
1204 In an extension aggregate for an object of a type derived from @var{T}.
1205 @end itemize
1206
1207 @noindent
1208 Although the constructor is described as a function that returns a value
1209 on the Ada side, it is typically a procedure with an extra implicit
1210 argument (the object being initialized) at the implementation
1211 level.  GNAT issues the appropriate call, whatever it is, to get the
1212 object properly initialized.
1213
1214 In the case of derived objects, you may use one of two possible forms
1215 for declaring and creating an object:
1216
1217 @itemize @bullet
1218 @item @code{New_Object : Derived_T}
1219 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1220 @end itemize
1221
1222 @noindent
1223 In the first case the default constructor is called and extension fields
1224 if any are initialized according to the default initialization
1225 expressions in the Ada declaration.  In the second case, the given
1226 constructor is called and the extension aggregate indicates the explicit
1227 values of the extension fields.
1228
1229 If no constructors are imported, it is impossible to create any objects
1230 on the Ada side.  If no default constructor is imported, only the
1231 initialization forms using an explicit call to a constructor are
1232 permitted.
1233
1234 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1235 using an automatic binding generator tool.
1236 See @ref{Interfacing to C++} for more related information.
1237
1238 @node Pragma CPP_Virtual
1239 @unnumberedsec Pragma CPP_Virtual
1240 @cindex Interfacing to C++
1241 @findex CPP_Virtual
1242 @noindent
1243 Syntax:
1244
1245 @smallexample @c ada
1246 pragma CPP_Virtual
1247      [Entity     =>] ENTITY,
1248   [, [Vtable_Ptr =>] vtable_ENTITY,]
1249   [, [Position   =>] static_integer_EXPRESSION]);
1250 @end smallexample
1251
1252 @noindent
1253 This pragma serves the same function as pragma @code{Import} in that
1254 case of a virtual function imported from C++.  The @var{Entity} argument
1255 must be a
1256 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1257 applies.  The @var{Vtable_Ptr} argument specifies
1258 the Vtable_Ptr component which contains the
1259 entry for this virtual function.  The @var{Position} argument
1260 is the sequential number
1261 counting virtual functions for this Vtable starting at 1.
1262
1263 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1264 there is one Vtable_Ptr present (single inheritance case) and all
1265 virtual functions are imported.  In that case the compiler can deduce both
1266 these values.
1267
1268 No @code{External_Name} or @code{Link_Name} arguments are required for a
1269 virtual function, since it is always accessed indirectly via the
1270 appropriate Vtable entry.
1271
1272 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1273 using an automatic binding generator tool.
1274 See @ref{Interfacing to C++} for related information.
1275
1276 @node Pragma CPP_Vtable
1277 @unnumberedsec Pragma CPP_Vtable
1278 @cindex Interfacing with C++
1279 @findex CPP_Vtable
1280 @noindent
1281 Syntax:
1282
1283 @smallexample @c ada
1284 pragma CPP_Vtable (
1285   [Entity      =>] ENTITY,
1286   [Vtable_Ptr  =>] vtable_ENTITY,
1287   [Entry_Count =>] static_integer_EXPRESSION);
1288 @end smallexample
1289
1290 @noindent
1291 Given a record to which the pragma @code{CPP_Class} applies,
1292 this pragma can be specified for each component of type
1293 @code{CPP.Interfaces.Vtable_Ptr}.
1294 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1295 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1296 the number of virtual functions on the C++ side.  Not all of these
1297 functions need to be imported on the Ada side.
1298
1299 You may omit the @code{CPP_Vtable} pragma if there is only one
1300 @code{Vtable_Ptr} component in the record and all virtual functions are
1301 imported on the Ada side (the default value for the entry count in this
1302 case is simply the total number of virtual functions).
1303
1304 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1305 using an automatic binding generator tool.
1306 See @ref{Interfacing to C++} for related information.
1307
1308 @node Pragma Debug
1309 @unnumberedsec Pragma Debug
1310 @findex Debug
1311 @noindent
1312 Syntax:
1313
1314 @smallexample @c ada
1315 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1316
1317 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1318   PROCEDURE_NAME
1319 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1320 @end smallexample
1321
1322 @noindent
1323 The argument has the syntactic form of an expression, meeting the
1324 syntactic requirements for pragmas.
1325
1326 If assertions are not enabled on the command line, this pragma has no
1327 effect.  If asserts are enabled, the semantics of the pragma is exactly
1328 equivalent to the procedure call statement corresponding to the argument
1329 with a terminating semicolon.  Pragmas are permitted in sequences of
1330 declarations, so you can use pragma @code{Debug} to intersperse calls to
1331 debug procedures in the middle of declarations.
1332
1333 @node Pragma Elaboration_Checks
1334 @unnumberedsec Pragma Elaboration_Checks
1335 @cindex Elaboration control
1336 @findex Elaboration_Checks
1337 @noindent
1338 Syntax:
1339
1340 @smallexample @c ada
1341 pragma Elaboration_Checks (Dynamic | Static);
1342 @end smallexample
1343
1344 @noindent
1345 This is a configuration pragma that provides control over the
1346 elaboration model used by the compilation affected by the
1347 pragma.  If the parameter is @code{Dynamic},
1348 then the dynamic elaboration
1349 model described in the Ada Reference Manual is used, as though
1350 the @code{-gnatE} switch had been specified on the command
1351 line.  If the parameter is @code{Static}, then the default GNAT static
1352 model is used.  This configuration pragma overrides the setting
1353 of the command line.  For full details on the elaboration models
1354 used by the GNAT compiler, see section ``Elaboration Order
1355 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1356
1357 @node Pragma Eliminate
1358 @unnumberedsec Pragma Eliminate
1359 @cindex Elimination of unused subprograms
1360 @findex Eliminate
1361 @noindent
1362 Syntax:
1363
1364 @smallexample @c ada
1365 pragma Eliminate (
1366     [Unit_Name =>] IDENTIFIER |
1367                    SELECTED_COMPONENT);
1368
1369 pragma Eliminate (
1370     [Unit_Name       =>]  IDENTIFIER |
1371                           SELECTED_COMPONENT,
1372     [Entity          =>]  IDENTIFIER |
1373                           SELECTED_COMPONENT |
1374                           STRING_LITERAL
1375     [,OVERLOADING_RESOLUTION]);
1376
1377 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1378                            SOURCE_LOCATION
1379
1380 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1381                                       FUNCTION_PROFILE
1382
1383 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1384
1385 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1386                       Result_Type => result_SUBTYPE_NAME]
1387
1388 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1389 SUBTYPE_NAME    ::= STRING_VALUE
1390
1391 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1392 SOURCE_TRACE    ::= STRING_VALUE
1393
1394 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1395 @end smallexample
1396
1397 @noindent
1398 This pragma indicates that the given entity is not used outside the
1399 compilation unit it is defined in. The entity must be an explicitly declared
1400 subprogram; this includes  generic subprogram instances and
1401 subprograms declared in generic package instances.
1402
1403 If the entity to be eliminated is a library level subprogram, then
1404 the first form of pragma @code{Eliminate} is used with only a single argument.
1405 In this form, the @code{Unit_Name} argument specifies the name of the
1406 library  level unit to be eliminated.
1407
1408 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1409 are required. If item is an entity of a library package, then the first
1410 argument specifies the unit name, and the second argument specifies
1411 the particular entity.  If the second argument is in string form, it must
1412 correspond to the internal manner in which GNAT stores entity names (see
1413 compilation unit Namet in the compiler sources for details).
1414
1415 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1416 to distinguish between overloaded subprograms. If a pragma does not contain
1417 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1418 subprograms denoted by the first two parameters.
1419
1420 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1421 to be eliminated in a manner similar to that used for the extended
1422 @code{Import} and @code{Export} pragmas, except that the subtype names are
1423 always given as strings. At the moment, this form of distinguishing
1424 overloaded subprograms is implemented only partially, so we do not recommend
1425 using it for practical subprogram elimination.
1426
1427 Note, that in case of a parameterless procedure its profile is represented
1428 as @code{Parameter_Types => ("")}
1429
1430 Alternatively, the @code{Source_Location} parameter is used to specify
1431 which overloaded alternative is to be eliminated by pointing to the
1432 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1433 source text. The string literal (or concatenation of string literals)
1434 given as SOURCE_TRACE must have the following format:
1435
1436 @smallexample @c ada
1437 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1438
1439 LBRACKET ::= [
1440 RBRACKET ::= ]
1441
1442 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1443 FILE_NAME       ::= STRING_LITERAL
1444 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1445 @end smallexample
1446
1447 SOURCE_TRACE should be the short name of the source file (with no directory
1448 information), and LINE_NUMBER is supposed to point to the line where the
1449 defining name of the subprogram is located.
1450
1451 For the subprograms that are not a part of generic instantiations, only one
1452 SOURCE_LOCATION is used. If a subprogram is declared in a package
1453 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1454 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1455 second one denotes the declaration of the corresponding subprogram in the
1456 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1457 in case of nested instantiations.
1458
1459 The effect of the pragma is to allow the compiler to eliminate
1460 the code or data associated with the named entity.  Any reference to
1461 an eliminated entity outside the compilation unit it is defined in,
1462 causes a compile time or link time error.
1463
1464 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1465 in a system independent manner, with unused entities eliminated, without
1466 the requirement of modifying the source text.  Normally the required set
1467 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1468 tool. Elimination of unused entities local to a compilation unit is
1469 automatic, without requiring the use of pragma @code{Eliminate}.
1470
1471 Note that the reason this pragma takes string literals where names might
1472 be expected is that a pragma @code{Eliminate} can appear in a context where the
1473 relevant names are not visible.
1474
1475 Note that any change in the source files that includes removing, splitting of
1476 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1477 parameter illegal.
1478
1479 @node Pragma Export_Exception
1480 @unnumberedsec Pragma Export_Exception
1481 @cindex OpenVMS
1482 @findex Export_Exception
1483 @noindent
1484 Syntax:
1485
1486 @smallexample @c ada
1487 pragma Export_Exception (
1488      [Internal =>] LOCAL_NAME,
1489   [, [External =>] EXTERNAL_SYMBOL,]
1490   [, [Form     =>] Ada | VMS]
1491   [, [Code     =>] static_integer_EXPRESSION]);
1492
1493 EXTERNAL_SYMBOL ::=
1494   IDENTIFIER
1495 | static_string_EXPRESSION
1496 @end smallexample
1497
1498 @noindent
1499 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1500 causes the specified exception to be propagated outside of the Ada program,
1501 so that it can be handled by programs written in other OpenVMS languages.
1502 This pragma establishes an external name for an Ada exception and makes the
1503 name available to the OpenVMS Linker as a global symbol.  For further details
1504 on this pragma, see the
1505 DEC Ada Language Reference Manual, section 13.9a3.2.
1506
1507 @node Pragma Export_Function
1508 @unnumberedsec Pragma Export_Function
1509 @cindex Argument passing mechanisms
1510 @findex Export_Function
1511
1512 @noindent
1513 Syntax:
1514
1515 @smallexample @c ada
1516 pragma Export_Function (
1517      [Internal         =>] LOCAL_NAME,
1518   [, [External         =>] EXTERNAL_SYMBOL]
1519   [, [Parameter_Types  =>] PARAMETER_TYPES]
1520   [, [Result_Type      =>] result_SUBTYPE_MARK]
1521   [, [Mechanism        =>] MECHANISM]
1522   [, [Result_Mechanism =>] MECHANISM_NAME]);
1523
1524 EXTERNAL_SYMBOL ::=
1525   IDENTIFIER
1526 | static_string_EXPRESSION
1527 | ""
1528
1529 PARAMETER_TYPES ::=
1530   null
1531 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1532
1533 TYPE_DESIGNATOR ::=
1534   subtype_NAME
1535 | subtype_Name ' Access
1536
1537 MECHANISM ::=
1538   MECHANISM_NAME
1539 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1540
1541 MECHANISM_ASSOCIATION ::=
1542   [formal_parameter_NAME =>] MECHANISM_NAME
1543
1544 MECHANISM_NAME ::=
1545   Value
1546 | Reference
1547 @end smallexample
1548
1549 @noindent
1550 Use this pragma to make a function externally callable and optionally
1551 provide information on mechanisms to be used for passing parameter and
1552 result values.  We recommend, for the purposes of improving portability,
1553 this pragma always be used in conjunction with a separate pragma
1554 @code{Export}, which must precede the pragma @code{Export_Function}.
1555 GNAT does not require a separate pragma @code{Export}, but if none is
1556 present, @code{Convention Ada} is assumed, which is usually
1557 not what is wanted, so it is usually appropriate to use this
1558 pragma in conjunction with a @code{Export} or @code{Convention}
1559 pragma that specifies the desired foreign convention.
1560 Pragma @code{Export_Function}
1561 (and @code{Export}, if present) must appear in the same declarative
1562 region as the function to which they apply.
1563
1564 @var{internal_name} must uniquely designate the function to which the
1565 pragma applies.  If more than one function name exists of this name in
1566 the declarative part you must use the @code{Parameter_Types} and
1567 @code{Result_Type} parameters is mandatory to achieve the required
1568 unique designation.  @var{subtype_ mark}s in these parameters must
1569 exactly match the subtypes in the corresponding function specification,
1570 using positional notation to match parameters with subtype marks.
1571 The form with an @code{'Access} attribute can be used to match an
1572 anonymous access parameter.
1573
1574 @cindex OpenVMS
1575 @cindex Passing by descriptor
1576 Note that passing by descriptor is not supported, even on the OpenVMS
1577 ports of GNAT@.
1578
1579 @cindex Suppressing external name
1580 Special treatment is given if the EXTERNAL is an explicit null
1581 string or a static string expressions that evaluates to the null
1582 string. In this case, no external name is generated. This form
1583 still allows the specification of parameter mechanisms.
1584
1585 @node Pragma Export_Object
1586 @unnumberedsec Pragma Export_Object
1587 @findex Export_Object
1588 @noindent
1589 Syntax:
1590
1591 @smallexample @c ada
1592 pragma Export_Object
1593       [Internal =>] LOCAL_NAME,
1594    [, [External =>] EXTERNAL_SYMBOL]
1595    [, [Size     =>] EXTERNAL_SYMBOL]
1596
1597 EXTERNAL_SYMBOL ::=
1598   IDENTIFIER
1599 | static_string_EXPRESSION
1600 @end smallexample
1601
1602 @noindent
1603 This pragma designates an object as exported, and apart from the
1604 extended rules for external symbols, is identical in effect to the use of
1605 the normal @code{Export} pragma applied to an object.  You may use a
1606 separate Export pragma (and you probably should from the point of view
1607 of portability), but it is not required.  @var{Size} is syntax checked,
1608 but otherwise ignored by GNAT@.
1609
1610 @node Pragma Export_Procedure
1611 @unnumberedsec Pragma Export_Procedure
1612 @findex Export_Procedure
1613 @noindent
1614 Syntax:
1615
1616 @smallexample @c ada
1617 pragma Export_Procedure (
1618      [Internal        =>] LOCAL_NAME
1619   [, [External        =>] EXTERNAL_SYMBOL]
1620   [, [Parameter_Types =>] PARAMETER_TYPES]
1621   [, [Mechanism       =>] MECHANISM]);
1622
1623 EXTERNAL_SYMBOL ::=
1624   IDENTIFIER
1625 | static_string_EXPRESSION
1626 | ""
1627
1628 PARAMETER_TYPES ::=
1629   null
1630 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1631
1632 TYPE_DESIGNATOR ::=
1633   subtype_NAME
1634 | subtype_Name ' Access
1635
1636 MECHANISM ::=
1637   MECHANISM_NAME
1638 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1639
1640 MECHANISM_ASSOCIATION ::=
1641   [formal_parameter_NAME =>] MECHANISM_NAME
1642
1643 MECHANISM_NAME ::=
1644   Value
1645 | Reference
1646 @end smallexample
1647
1648 @noindent
1649 This pragma is identical to @code{Export_Function} except that it
1650 applies to a procedure rather than a function and the parameters
1651 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1652 GNAT does not require a separate pragma @code{Export}, but if none is
1653 present, @code{Convention Ada} is assumed, which is usually
1654 not what is wanted, so it is usually appropriate to use this
1655 pragma in conjunction with a @code{Export} or @code{Convention}
1656 pragma that specifies the desired foreign convention.
1657
1658 @cindex OpenVMS
1659 @cindex Passing by descriptor
1660 Note that passing by descriptor is not supported, even on the OpenVMS
1661 ports of GNAT@.
1662
1663 @cindex Suppressing external name
1664 Special treatment is given if the EXTERNAL is an explicit null
1665 string or a static string expressions that evaluates to the null
1666 string. In this case, no external name is generated. This form
1667 still allows the specification of parameter mechanisms.
1668
1669 @node Pragma Export_Value
1670 @unnumberedsec Pragma Export_Value
1671 @findex Export_Value
1672 @noindent
1673 Syntax:
1674
1675 @smallexample @c ada
1676 pragma Export_Value (
1677   [Value     =>] static_integer_EXPRESSION,
1678   [Link_Name =>] static_string_EXPRESSION);
1679 @end smallexample
1680
1681 @noindent
1682 This pragma serves to export a static integer value for external use.
1683 The first argument specifies the value to be exported. The Link_Name
1684 argument specifies the symbolic name to be associated with the integer
1685 value. This pragma is useful for defining a named static value in Ada
1686 that can be referenced in assembly language units to be linked with
1687 the application. This pragma is currently supported only for the
1688 AAMP target and is ignored for other targets.
1689
1690 @node Pragma Export_Valued_Procedure
1691 @unnumberedsec Pragma Export_Valued_Procedure
1692 @findex Export_Valued_Procedure
1693 @noindent
1694 Syntax:
1695
1696 @smallexample @c ada
1697 pragma Export_Valued_Procedure (
1698      [Internal        =>] LOCAL_NAME
1699   [, [External        =>] EXTERNAL_SYMBOL]
1700   [, [Parameter_Types =>] PARAMETER_TYPES]
1701   [, [Mechanism       =>] MECHANISM]);
1702
1703 EXTERNAL_SYMBOL ::=
1704   IDENTIFIER
1705 | static_string_EXPRESSION
1706 | ""
1707
1708 PARAMETER_TYPES ::=
1709   null
1710 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1711
1712 TYPE_DESIGNATOR ::=
1713   subtype_NAME
1714 | subtype_Name ' Access
1715
1716 MECHANISM ::=
1717   MECHANISM_NAME
1718 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1719
1720 MECHANISM_ASSOCIATION ::=
1721   [formal_parameter_NAME =>] MECHANISM_NAME
1722
1723 MECHANISM_NAME ::=
1724   Value
1725 | Reference
1726 @end smallexample
1727
1728 @noindent
1729 This pragma is identical to @code{Export_Procedure} except that the
1730 first parameter of @var{local_name}, which must be present, must be of
1731 mode @code{OUT}, and externally the subprogram is treated as a function
1732 with this parameter as the result of the function.  GNAT provides for
1733 this capability to allow the use of @code{OUT} and @code{IN OUT}
1734 parameters in interfacing to external functions (which are not permitted
1735 in Ada functions).
1736 GNAT does not require a separate pragma @code{Export}, but if none is
1737 present, @code{Convention Ada} is assumed, which is almost certainly
1738 not what is wanted since the whole point of this pragma is to interface
1739 with foreign language functions, so it is usually appropriate to use this
1740 pragma in conjunction with a @code{Export} or @code{Convention}
1741 pragma that specifies the desired foreign convention.
1742
1743 @cindex OpenVMS
1744 @cindex Passing by descriptor
1745 Note that passing by descriptor is not supported, even on the OpenVMS
1746 ports of GNAT@.
1747
1748 @cindex Suppressing external name
1749 Special treatment is given if the EXTERNAL is an explicit null
1750 string or a static string expressions that evaluates to the null
1751 string. In this case, no external name is generated. This form
1752 still allows the specification of parameter mechanisms.
1753
1754 @node Pragma Extend_System
1755 @unnumberedsec Pragma Extend_System
1756 @cindex @code{system}, extending
1757 @cindex Dec Ada 83
1758 @findex Extend_System
1759 @noindent
1760 Syntax:
1761
1762 @smallexample @c ada
1763 pragma Extend_System ([Name =>] IDENTIFIER);
1764 @end smallexample
1765
1766 @noindent
1767 This pragma is used to provide backwards compatibility with other
1768 implementations that extend the facilities of package @code{System}.  In
1769 GNAT, @code{System} contains only the definitions that are present in
1770 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1771 implementation, provide many extensions to package @code{System}.
1772
1773 For each such implementation accommodated by this pragma, GNAT provides a
1774 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1775 implementation, which provides the required additional definitions.  You
1776 can use this package in two ways.  You can @code{with} it in the normal
1777 way and access entities either by selection or using a @code{use}
1778 clause.  In this case no special processing is required.
1779
1780 However, if existing code contains references such as
1781 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1782 definitions provided in package @code{System}, you may use this pragma
1783 to extend visibility in @code{System} in a non-standard way that
1784 provides greater compatibility with the existing code.  Pragma
1785 @code{Extend_System} is a configuration pragma whose single argument is
1786 the name of the package containing the extended definition
1787 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1788 control of this pragma will be processed using special visibility
1789 processing that looks in package @code{System.Aux_@var{xxx}} where
1790 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1791 package @code{System}, but not found in package @code{System}.
1792
1793 You can use this pragma either to access a predefined @code{System}
1794 extension supplied with the compiler, for example @code{Aux_DEC} or
1795 you can construct your own extension unit following the above
1796 definition.  Note that such a package is a child of @code{System}
1797 and thus is considered part of the implementation.  To compile
1798 it you will have to use the appropriate switch for compiling
1799 system units.  See the GNAT User's Guide for details.
1800
1801 @node Pragma External
1802 @unnumberedsec Pragma External
1803 @findex External
1804 @noindent
1805 Syntax:
1806
1807 @smallexample @c ada
1808 pragma External (
1809   [   Convention    =>] convention_IDENTIFIER,
1810   [   Entity        =>] local_NAME
1811   [, [External_Name =>] static_string_EXPRESSION ]
1812   [, [Link_Name     =>] static_string_EXPRESSION ]);
1813 @end smallexample
1814
1815 @noindent
1816 This pragma is identical in syntax and semantics to pragma
1817 @code{Export} as defined in the Ada Reference Manual.  It is
1818 provided for compatibility with some Ada 83 compilers that
1819 used this pragma for exactly the same purposes as pragma
1820 @code{Export} before the latter was standardized.
1821
1822 @node Pragma External_Name_Casing
1823 @unnumberedsec Pragma External_Name_Casing
1824 @cindex Dec Ada 83 casing compatibility
1825 @cindex External Names, casing
1826 @cindex Casing of External names
1827 @findex External_Name_Casing
1828 @noindent
1829 Syntax:
1830
1831 @smallexample @c ada
1832 pragma External_Name_Casing (
1833   Uppercase | Lowercase
1834   [, Uppercase | Lowercase | As_Is]);
1835 @end smallexample
1836
1837 @noindent
1838 This pragma provides control over the casing of external names associated
1839 with Import and Export pragmas.  There are two cases to consider:
1840
1841 @table @asis
1842 @item Implicit external names
1843 Implicit external names are derived from identifiers.  The most common case
1844 arises when a standard Ada 95 Import or Export pragma is used with only two
1845 arguments, as in:
1846
1847 @smallexample @c ada
1848    pragma Import (C, C_Routine);
1849 @end smallexample
1850
1851 @noindent
1852 Since Ada is a case insensitive language, the spelling of the identifier in
1853 the Ada source program does not provide any information on the desired
1854 casing of the external name, and so a convention is needed.  In GNAT the
1855 default treatment is that such names are converted to all lower case
1856 letters.  This corresponds to the normal C style in many environments.
1857 The first argument of pragma @code{External_Name_Casing} can be used to
1858 control this treatment.  If @code{Uppercase} is specified, then the name
1859 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1860 then the normal default of all lower case letters will be used.
1861
1862 This same implicit treatment is also used in the case of extended DEC Ada 83
1863 compatible Import and Export pragmas where an external name is explicitly
1864 specified using an identifier rather than a string.
1865
1866 @item Explicit external names
1867 Explicit external names are given as string literals.  The most common case
1868 arises when a standard Ada 95 Import or Export pragma is used with three
1869 arguments, as in:
1870
1871 @smallexample @c ada
1872 pragma Import (C, C_Routine, "C_routine");
1873 @end smallexample
1874
1875 @noindent
1876 In this case, the string literal normally provides the exact casing required
1877 for the external name.  The second argument of pragma
1878 @code{External_Name_Casing} may be used to modify this behavior.
1879 If @code{Uppercase} is specified, then the name
1880 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1881 then the name will be forced to all lowercase letters.  A specification of
1882 @code{As_Is} provides the normal default behavior in which the casing is
1883 taken from the string provided.
1884 @end table
1885
1886 @noindent
1887 This pragma may appear anywhere that a pragma is valid.  In particular, it
1888 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1889 case it applies to all subsequent compilations, or it can be used as a program
1890 unit pragma, in which case it only applies to the current unit, or it can
1891 be used more locally to control individual Import/Export pragmas.
1892
1893 It is primarily intended for use with OpenVMS systems, where many
1894 compilers convert all symbols to upper case by default.  For interfacing to
1895 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1896 the pragma:
1897
1898 @smallexample @c ada
1899 pragma External_Name_Casing (Uppercase, Uppercase);
1900 @end smallexample
1901
1902 @noindent
1903 to enforce the upper casing of all external symbols.
1904
1905 @node Pragma Finalize_Storage_Only
1906 @unnumberedsec Pragma Finalize_Storage_Only
1907 @findex Finalize_Storage_Only
1908 @noindent
1909 Syntax:
1910
1911 @smallexample @c ada
1912 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1913 @end smallexample
1914
1915 @noindent
1916 This pragma allows the compiler not to emit a Finalize call for objects
1917 defined at the library level.  This is mostly useful for types where
1918 finalization is only used to deal with storage reclamation since in most
1919 environments it is not necessary to reclaim memory just before terminating
1920 execution, hence the name.
1921
1922 @node Pragma Float_Representation
1923 @unnumberedsec Pragma Float_Representation
1924 @cindex OpenVMS
1925 @findex Float_Representation
1926 @noindent
1927 Syntax:
1928
1929 @smallexample @c ada
1930 pragma Float_Representation (FLOAT_REP);
1931
1932 FLOAT_REP ::= VAX_Float | IEEE_Float
1933 @end smallexample
1934
1935 @noindent
1936 This pragma
1937 allows control over the internal representation chosen for the predefined
1938 floating point types declared in the packages @code{Standard} and
1939 @code{System}. On all systems other than OpenVMS, the argument must
1940 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1941 argument may be @code{VAX_Float} to specify the use of the VAX float
1942 format for the floating-point types in Standard. This requires that
1943 the standard runtime libraries be recompiled. See the
1944 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1945 of the GNAT Users Guide for details on the use of this command.
1946
1947 @node Pragma Ident
1948 @unnumberedsec Pragma Ident
1949 @findex Ident
1950 @noindent
1951 Syntax:
1952
1953 @smallexample @c ada
1954 pragma Ident (static_string_EXPRESSION);
1955 @end smallexample
1956
1957 @noindent
1958 This pragma provides a string identification in the generated object file,
1959 if the system supports the concept of this kind of identification string.
1960 This pragma is allowed only in the outermost declarative part or
1961 declarative items of a compilation unit. If more than one @code{Ident}
1962 pragma is given, only the last one processed is effective.
1963 @cindex OpenVMS
1964 On OpenVMS systems, the effect of the pragma is identical to the effect of
1965 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1966 maximum allowed length is 31 characters, so if it is important to
1967 maintain compatibility with this compiler, you should obey this length
1968 limit.
1969
1970 @node Pragma Import_Exception
1971 @unnumberedsec Pragma Import_Exception
1972 @cindex OpenVMS
1973 @findex Import_Exception
1974 @noindent
1975 Syntax:
1976
1977 @smallexample @c ada
1978 pragma Import_Exception (
1979      [Internal =>] LOCAL_NAME,
1980   [, [External =>] EXTERNAL_SYMBOL,]
1981   [, [Form     =>] Ada | VMS]
1982   [, [Code     =>] static_integer_EXPRESSION]);
1983
1984 EXTERNAL_SYMBOL ::=
1985   IDENTIFIER
1986 | static_string_EXPRESSION
1987 @end smallexample
1988
1989 @noindent
1990 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1991 It allows OpenVMS conditions (for example, from OpenVMS system services or
1992 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1993 The pragma specifies that the exception associated with an exception
1994 declaration in an Ada program be defined externally (in non-Ada code).
1995 For further details on this pragma, see the
1996 DEC Ada Language Reference Manual, section 13.9a.3.1.
1997
1998 @node Pragma Import_Function
1999 @unnumberedsec Pragma Import_Function
2000 @findex Import_Function
2001 @noindent
2002 Syntax:
2003
2004 @smallexample @c ada
2005 pragma Import_Function (
2006      [Internal                 =>] LOCAL_NAME,
2007   [, [External                 =>] EXTERNAL_SYMBOL]
2008   [, [Parameter_Types          =>] PARAMETER_TYPES]
2009   [, [Result_Type              =>] SUBTYPE_MARK]
2010   [, [Mechanism                =>] MECHANISM]
2011   [, [Result_Mechanism         =>] MECHANISM_NAME]
2012   [, [First_Optional_Parameter =>] IDENTIFIER]);
2013
2014 EXTERNAL_SYMBOL ::=
2015   IDENTIFIER
2016 | static_string_EXPRESSION
2017
2018 PARAMETER_TYPES ::=
2019   null
2020 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2021
2022 TYPE_DESIGNATOR ::=
2023   subtype_NAME
2024 | subtype_Name ' Access
2025
2026 MECHANISM ::=
2027   MECHANISM_NAME
2028 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2029
2030 MECHANISM_ASSOCIATION ::=
2031   [formal_parameter_NAME =>] MECHANISM_NAME
2032
2033 MECHANISM_NAME ::=
2034   Value
2035 | Reference
2036 | Descriptor [([Class =>] CLASS_NAME)]
2037
2038 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2039 @end smallexample
2040
2041 @noindent
2042 This pragma is used in conjunction with a pragma @code{Import} to
2043 specify additional information for an imported function.  The pragma
2044 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2045 @code{Import_Function} pragma and both must appear in the same
2046 declarative part as the function specification.
2047
2048 The @var{Internal} argument must uniquely designate
2049 the function to which the
2050 pragma applies.  If more than one function name exists of this name in
2051 the declarative part you must use the @code{Parameter_Types} and
2052 @var{Result_Type} parameters to achieve the required unique
2053 designation.  Subtype marks in these parameters must exactly match the
2054 subtypes in the corresponding function specification, using positional
2055 notation to match parameters with subtype marks.
2056 The form with an @code{'Access} attribute can be used to match an
2057 anonymous access parameter.
2058
2059 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2060 parameters to specify passing mechanisms for the
2061 parameters and result.  If you specify a single mechanism name, it
2062 applies to all parameters.  Otherwise you may specify a mechanism on a
2063 parameter by parameter basis using either positional or named
2064 notation.  If the mechanism is not specified, the default mechanism
2065 is used.
2066
2067 @cindex OpenVMS
2068 @cindex Passing by descriptor
2069 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2070
2071 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2072 It specifies that the designated parameter and all following parameters
2073 are optional, meaning that they are not passed at the generated code
2074 level (this is distinct from the notion of optional parameters in Ada
2075 where the parameters are passed anyway with the designated optional
2076 parameters).  All optional parameters must be of mode @code{IN} and have
2077 default parameter values that are either known at compile time
2078 expressions, or uses of the @code{'Null_Parameter} attribute.
2079
2080 @node Pragma Import_Object
2081 @unnumberedsec Pragma Import_Object
2082 @findex Import_Object
2083 @noindent
2084 Syntax:
2085
2086 @smallexample @c ada
2087 pragma Import_Object
2088      [Internal =>] LOCAL_NAME,
2089   [, [External =>] EXTERNAL_SYMBOL],
2090   [, [Size     =>] EXTERNAL_SYMBOL]);
2091
2092 EXTERNAL_SYMBOL ::=
2093   IDENTIFIER
2094 | static_string_EXPRESSION
2095 @end smallexample
2096
2097 @noindent
2098 This pragma designates an object as imported, and apart from the
2099 extended rules for external symbols, is identical in effect to the use of
2100 the normal @code{Import} pragma applied to an object.  Unlike the
2101 subprogram case, you need not use a separate @code{Import} pragma,
2102 although you may do so (and probably should do so from a portability
2103 point of view).  @var{size} is syntax checked, but otherwise ignored by
2104 GNAT@.
2105
2106 @node Pragma Import_Procedure
2107 @unnumberedsec Pragma Import_Procedure
2108 @findex Import_Procedure
2109 @noindent
2110 Syntax:
2111
2112 @smallexample @c ada
2113 pragma Import_Procedure (
2114      [Internal                 =>] LOCAL_NAME,
2115   [, [External                 =>] EXTERNAL_SYMBOL]
2116   [, [Parameter_Types          =>] PARAMETER_TYPES]
2117   [, [Mechanism                =>] MECHANISM]
2118   [, [First_Optional_Parameter =>] IDENTIFIER]);
2119
2120 EXTERNAL_SYMBOL ::=
2121   IDENTIFIER
2122 | static_string_EXPRESSION
2123
2124 PARAMETER_TYPES ::=
2125   null
2126 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2127
2128 TYPE_DESIGNATOR ::=
2129   subtype_NAME
2130 | subtype_Name ' Access
2131
2132 MECHANISM ::=
2133   MECHANISM_NAME
2134 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2135
2136 MECHANISM_ASSOCIATION ::=
2137   [formal_parameter_NAME =>] MECHANISM_NAME
2138
2139 MECHANISM_NAME ::=
2140   Value
2141 | Reference
2142 | Descriptor [([Class =>] CLASS_NAME)]
2143
2144 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2145 @end smallexample
2146
2147 @noindent
2148 This pragma is identical to @code{Import_Function} except that it
2149 applies to a procedure rather than a function and the parameters
2150 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2151
2152 @node Pragma Import_Valued_Procedure
2153 @unnumberedsec Pragma Import_Valued_Procedure
2154 @findex Import_Valued_Procedure
2155 @noindent
2156 Syntax:
2157
2158 @smallexample @c ada
2159 pragma Import_Valued_Procedure (
2160      [Internal                 =>] LOCAL_NAME,
2161   [, [External                 =>] EXTERNAL_SYMBOL]
2162   [, [Parameter_Types          =>] PARAMETER_TYPES]
2163   [, [Mechanism                =>] MECHANISM]
2164   [, [First_Optional_Parameter =>] IDENTIFIER]);
2165
2166 EXTERNAL_SYMBOL ::=
2167   IDENTIFIER
2168 | static_string_EXPRESSION
2169
2170 PARAMETER_TYPES ::=
2171   null
2172 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2173
2174 TYPE_DESIGNATOR ::=
2175   subtype_NAME
2176 | subtype_Name ' Access
2177
2178 MECHANISM ::=
2179   MECHANISM_NAME
2180 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2181
2182 MECHANISM_ASSOCIATION ::=
2183   [formal_parameter_NAME =>] MECHANISM_NAME
2184
2185 MECHANISM_NAME ::=
2186   Value
2187 | Reference
2188 | Descriptor [([Class =>] CLASS_NAME)]
2189
2190 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2191 @end smallexample
2192
2193 @noindent
2194 This pragma is identical to @code{Import_Procedure} except that the
2195 first parameter of @var{local_name}, which must be present, must be of
2196 mode @code{OUT}, and externally the subprogram is treated as a function
2197 with this parameter as the result of the function.  The purpose of this
2198 capability is to allow the use of @code{OUT} and @code{IN OUT}
2199 parameters in interfacing to external functions (which are not permitted
2200 in Ada functions).  You may optionally use the @code{Mechanism}
2201 parameters to specify passing mechanisms for the parameters.
2202 If you specify a single mechanism name, it applies to all parameters.
2203 Otherwise you may specify a mechanism on a parameter by parameter
2204 basis using either positional or named notation.  If the mechanism is not
2205 specified, the default mechanism is used.
2206
2207 Note that it is important to use this pragma in conjunction with a separate
2208 pragma Import that specifies the desired convention, since otherwise the
2209 default convention is Ada, which is almost certainly not what is required.
2210
2211 @node Pragma Initialize_Scalars
2212 @unnumberedsec Pragma Initialize_Scalars
2213 @findex Initialize_Scalars
2214 @cindex debugging with Initialize_Scalars
2215 @noindent
2216 Syntax:
2217
2218 @smallexample @c ada
2219 pragma Initialize_Scalars;
2220 @end smallexample
2221
2222 @noindent
2223 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2224 two important differences.  First, there is no requirement for the pragma
2225 to be used uniformly in all units of a partition, in particular, it is fine
2226 to use this just for some or all of the application units of a partition,
2227 without needing to recompile the run-time library.
2228
2229 In the case where some units are compiled with the pragma, and some without,
2230 then a declaration of a variable where the type is defined in package
2231 Standard or is locally declared will always be subject to initialization,
2232 as will any declaration of a scalar variable.  For composite variables,
2233 whether the variable is initialized may also depend on whether the package
2234 in which the type of the variable is declared is compiled with the pragma.
2235
2236 The other important difference is that there is control over the value used
2237 for initializing scalar objects.  At bind time, you can select whether to
2238 initialize with invalid values (like Normalize_Scalars), or with high or
2239 low values, or with a specified bit pattern.  See the users guide for binder
2240 options for specifying these cases.
2241
2242 This means that you can compile a program, and then without having to
2243 recompile the program, you can run it with different values being used
2244 for initializing otherwise uninitialized values, to test if your program
2245 behavior depends on the choice.  Of course the behavior should not change,
2246 and if it does, then most likely you have an erroneous reference to an
2247 uninitialized value.
2248
2249 Note that pragma @code{Initialize_Scalars} is particularly useful in
2250 conjunction with the enhanced validity checking that is now provided
2251 in GNAT, which checks for invalid values under more conditions.
2252 Using this feature (see description of the @code{-gnatV} flag in the
2253 users guide) in conjunction with pragma @code{Initialize_Scalars}
2254 provides a powerful new tool to assist in the detection of problems
2255 caused by uninitialized variables.
2256
2257 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2258 effect on the generated code. This may cause your code to be
2259 substantially larger. It may also cause an increase in the amount
2260 of stack required, so it is probably a good idea to turn on stack
2261 checking (see description of stack checking in the GNAT users guide)
2262 when using this pragma.
2263
2264 @node Pragma Inline_Always
2265 @unnumberedsec Pragma Inline_Always
2266 @findex Inline_Always
2267 @noindent
2268 Syntax:
2269
2270 @smallexample @c ada
2271 pragma Inline_Always (NAME [, NAME]);
2272 @end smallexample
2273
2274 @noindent
2275 Similar to pragma @code{Inline} except that inlining is not subject to
2276 the use of option @code{-gnatn} and the inlining happens regardless of
2277 whether this option is used.
2278
2279 @node Pragma Inline_Generic
2280 @unnumberedsec Pragma Inline_Generic
2281 @findex Inline_Generic
2282 @noindent
2283 Syntax:
2284
2285 @smallexample @c ada
2286 pragma Inline_Generic (generic_package_NAME);
2287 @end smallexample
2288
2289 @noindent
2290 This is implemented for compatibility with DEC Ada 83 and is recognized,
2291 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2292 by default when using GNAT@.
2293
2294 @node Pragma Interface
2295 @unnumberedsec Pragma Interface
2296 @findex Interface
2297 @noindent
2298 Syntax:
2299
2300 @smallexample @c ada
2301 pragma Interface (
2302      [Convention    =>] convention_identifier,
2303      [Entity =>] local_name
2304   [, [External_Name =>] static_string_expression],
2305   [, [Link_Name     =>] static_string_expression]);
2306 @end smallexample
2307
2308 @noindent
2309 This pragma is identical in syntax and semantics to
2310 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2311 with Ada 83.  The definition is upwards compatible both with pragma
2312 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2313 with some extended implementations of this pragma in certain Ada 83
2314 implementations.
2315
2316 @node Pragma Interface_Name
2317 @unnumberedsec Pragma Interface_Name
2318 @findex Interface_Name
2319 @noindent
2320 Syntax:
2321
2322 @smallexample @c ada
2323 pragma Interface_Name (
2324      [Entity        =>] LOCAL_NAME
2325   [, [External_Name =>] static_string_EXPRESSION]
2326   [, [Link_Name     =>] static_string_EXPRESSION]);
2327 @end smallexample
2328
2329 @noindent
2330 This pragma provides an alternative way of specifying the interface name
2331 for an interfaced subprogram, and is provided for compatibility with Ada
2332 83 compilers that use the pragma for this purpose.  You must provide at
2333 least one of @var{External_Name} or @var{Link_Name}.
2334
2335 @node Pragma Interrupt_Handler
2336 @unnumberedsec Pragma Interrupt_Handler
2337 @findex Interrupt_Handler
2338 @noindent
2339 Syntax:
2340
2341 @smallexample @c ada
2342 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2343 @end smallexample
2344
2345 @noindent
2346 This program unit pragma is supported for parameterless protected procedures
2347 as described in Annex C of the Ada Reference Manual. On the AAMP target
2348 the pragma can also be specified for nonprotected parameterless procedures
2349 that are declared at the library level (which includes procedures
2350 declared at the top level of a library package). In the case of AAMP,
2351 when this pragma is applied to a nonprotected procedure, the instruction
2352 @code{IERET} is generated for returns from the procedure, enabling
2353 maskable interrupts, in place of the normal return instruction.
2354
2355 @node Pragma Interrupt_State
2356 @unnumberedsec Pragma Interrupt_State
2357 @findex Interrupt_State
2358 @noindent
2359 Syntax:
2360
2361 @smallexample @c ada
2362 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2363 @end smallexample
2364
2365 @noindent
2366 Normally certain interrupts are reserved to the implementation.  Any attempt
2367 to attach an interrupt causes Program_Error to be raised, as described in
2368 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2369 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2370 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2371 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2372 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2373 Ada exceptions, or used to implement run-time functions such as the
2374 @code{abort} statement and stack overflow checking.
2375
2376 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2377 such uses of interrupts.  It subsumes the functionality of pragma
2378 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2379 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2380 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2381 and may be used to mark interrupts required by the board support package
2382 as reserved.
2383
2384 Interrupts can be in one of three states:
2385 @itemize @bullet
2386 @item System
2387
2388 The interrupt is reserved (no Ada handler can be installed), and the
2389 Ada run-time may not install a handler. As a result you are guaranteed
2390 standard system default action if this interrupt is raised.
2391
2392 @item Runtime
2393
2394 The interrupt is reserved (no Ada handler can be installed). The run time
2395 is allowed to install a handler for internal control purposes, but is
2396 not required to do so.
2397
2398 @item User
2399
2400 The interrupt is unreserved.  The user may install a handler to provide
2401 some other action.
2402 @end itemize
2403
2404 @noindent
2405 These states are the allowed values of the @code{State} parameter of the
2406 pragma.  The @code{Name} parameter is a value of the type
2407 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2408 @code{Ada.Interrupts.Names}.
2409
2410 This is a configuration pragma, and the binder will check that there
2411 are no inconsistencies between different units in a partition in how a
2412 given interrupt is specified. It may appear anywhere a pragma is legal.
2413
2414 The effect is to move the interrupt to the specified state.
2415
2416 By declaring interrupts to be SYSTEM, you guarantee the standard system
2417 action, such as a core dump.
2418
2419 By declaring interrupts to be USER, you guarantee that you can install
2420 a handler.
2421
2422 Note that certain signals on many operating systems cannot be caught and
2423 handled by applications.  In such cases, the pragma is ignored.  See the
2424 operating system documentation, or the value of the array @code{Reserved}
2425 declared in the specification of package @code{System.OS_Interface}.
2426
2427 Overriding the default state of signals used by the Ada runtime may interfere
2428 with an application's runtime behavior in the cases of the synchronous signals,
2429 and in the case of the signal used to implement the @code{abort} statement.
2430
2431 @node Pragma Keep_Names
2432 @unnumberedsec Pragma Keep_Names
2433 @findex Keep_Names
2434 @noindent
2435 Syntax:
2436
2437 @smallexample @c ada
2438 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2439 @end smallexample
2440
2441 @noindent
2442 The @var{LOCAL_NAME} argument
2443 must refer to an enumeration first subtype
2444 in the current declarative part. The effect is to retain the enumeration
2445 literal names for use by @code{Image} and @code{Value} even if a global
2446 @code{Discard_Names} pragma applies. This is useful when you want to
2447 generally suppress enumeration literal names and for example you therefore
2448 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2449 want to retain the names for specific enumeration types.
2450
2451 @node Pragma License
2452 @unnumberedsec Pragma License
2453 @findex License
2454 @cindex License checking
2455 @noindent
2456 Syntax:
2457
2458 @smallexample @c ada
2459 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2460 @end smallexample
2461
2462 @noindent
2463 This pragma is provided to allow automated checking for appropriate license
2464 conditions with respect to the standard and modified GPL@.  A pragma
2465 @code{License}, which is a configuration pragma that typically appears at
2466 the start of a source file or in a separate @file{gnat.adc} file, specifies
2467 the licensing conditions of a unit as follows:
2468
2469 @itemize @bullet
2470 @item Unrestricted
2471 This is used for a unit that can be freely used with no license restrictions.
2472 Examples of such units are public domain units, and units from the Ada
2473 Reference Manual.
2474
2475 @item GPL
2476 This is used for a unit that is licensed under the unmodified GPL, and which
2477 therefore cannot be @code{with}'ed by a restricted unit.
2478
2479 @item Modified_GPL
2480 This is used for a unit licensed under the GNAT modified GPL that includes
2481 a special exception paragraph that specifically permits the inclusion of
2482 the unit in programs without requiring the entire program to be released
2483 under the GPL@.  This is the license used for the GNAT run-time which ensures
2484 that the run-time can be used freely in any program without GPL concerns.
2485
2486 @item Restricted
2487 This is used for a unit that is restricted in that it is not permitted to
2488 depend on units that are licensed under the GPL@.  Typical examples are
2489 proprietary code that is to be released under more restrictive license
2490 conditions.  Note that restricted units are permitted to @code{with} units
2491 which are licensed under the modified GPL (this is the whole point of the
2492 modified GPL).
2493
2494 @end itemize
2495
2496 @noindent
2497 Normally a unit with no @code{License} pragma is considered to have an
2498 unknown license, and no checking is done.  However, standard GNAT headers
2499 are recognized, and license information is derived from them as follows.
2500
2501 @itemize @bullet
2502
2503 A GNAT license header starts with a line containing 78 hyphens.  The following
2504 comment text is searched for the appearance of any of the following strings.
2505
2506 If the string ``GNU General Public License'' is found, then the unit is assumed
2507 to have GPL license, unless the string ``As a special exception'' follows, in
2508 which case the license is assumed to be modified GPL@.
2509
2510 If one of the strings
2511 ``This specification is adapted from the Ada Semantic Interface'' or
2512 ``This specification is derived from the Ada Reference Manual'' is found
2513 then the unit is assumed to be unrestricted.
2514 @end itemize
2515
2516 @noindent
2517 These default actions means that a program with a restricted license pragma
2518 will automatically get warnings if a GPL unit is inappropriately
2519 @code{with}'ed.  For example, the program:
2520
2521 @smallexample @c ada
2522 with Sem_Ch3;
2523 with GNAT.Sockets;
2524 procedure Secret_Stuff is
2525   @dots{}
2526 end Secret_Stuff
2527 @end smallexample
2528
2529 @noindent
2530 if compiled with pragma @code{License} (@code{Restricted}) in a
2531 @file{gnat.adc} file will generate the warning:
2532
2533 @smallexample
2534 1.  with Sem_Ch3;
2535         |
2536    >>> license of withed unit "Sem_Ch3" is incompatible
2537
2538 2.  with GNAT.Sockets;
2539 3.  procedure Secret_Stuff is
2540 @end smallexample
2541
2542 @noindent
2543 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2544 compiler and is licensed under the
2545 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2546 run time, and is therefore licensed under the modified GPL@.
2547
2548 @node Pragma Link_With
2549 @unnumberedsec Pragma Link_With
2550 @findex Link_With
2551 @noindent
2552 Syntax:
2553
2554 @smallexample @c ada
2555 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2556 @end smallexample
2557
2558 @noindent
2559 This pragma is provided for compatibility with certain Ada 83 compilers.
2560 It has exactly the same effect as pragma @code{Linker_Options} except
2561 that spaces occurring within one of the string expressions are treated
2562 as separators. For example, in the following case:
2563
2564 @smallexample @c ada
2565 pragma Link_With ("-labc -ldef");
2566 @end smallexample
2567
2568 @noindent
2569 results in passing the strings @code{-labc} and @code{-ldef} as two
2570 separate arguments to the linker. In addition pragma Link_With allows
2571 multiple arguments, with the same effect as successive pragmas.
2572
2573 @node Pragma Linker_Alias
2574 @unnumberedsec Pragma Linker_Alias
2575 @findex Linker_Alias
2576 @noindent
2577 Syntax:
2578
2579 @smallexample @c ada
2580 pragma Linker_Alias (
2581   [Entity =>] LOCAL_NAME
2582   [Alias  =>] static_string_EXPRESSION);
2583 @end smallexample
2584
2585 @noindent
2586 This pragma establishes a linker alias for the given named entity.  For
2587 further details on the exact effect, consult the GCC manual.
2588
2589 @node Pragma Linker_Section
2590 @unnumberedsec Pragma Linker_Section
2591 @findex Linker_Section
2592 @noindent
2593 Syntax:
2594
2595 @smallexample @c ada
2596 pragma Linker_Section (
2597   [Entity  =>] LOCAL_NAME
2598   [Section =>] static_string_EXPRESSION);
2599 @end smallexample
2600
2601 @noindent
2602 This pragma specifies the name of the linker section for the given entity.
2603 For further details on the exact effect, consult the GCC manual.
2604
2605 @node Pragma Long_Float
2606 @unnumberedsec Pragma Long_Float
2607 @cindex OpenVMS
2608 @findex Long_Float
2609 @noindent
2610 Syntax:
2611
2612 @smallexample @c ada
2613 pragma Long_Float (FLOAT_FORMAT);
2614
2615 FLOAT_FORMAT ::= D_Float | G_Float
2616 @end smallexample
2617
2618 @noindent
2619 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2620 It allows control over the internal representation chosen for the predefined
2621 type @code{Long_Float} and for floating point type representations with
2622 @code{digits} specified in the range 7 through 15.
2623 For further details on this pragma, see the
2624 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2625 this pragma, the standard runtime libraries must be recompiled.  See the
2626 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2627 of the GNAT User's Guide for details on the use of this command.
2628
2629 @node Pragma Machine_Attribute
2630 @unnumberedsec Pragma Machine_Attribute
2631 @findex Machine_Attribute
2632 @noindent
2633 Syntax:
2634
2635 @smallexample @c ada
2636 pragma Machine_Attribute (
2637   [Attribute_Name =>] string_EXPRESSION,
2638   [Entity         =>] LOCAL_NAME);
2639 @end smallexample
2640
2641 @noindent
2642 Machine dependent attributes can be specified for types and/or
2643 declarations.  Currently only subprogram entities are supported.  This
2644 pragma is semantically equivalent to
2645 @code{__attribute__((@var{string_expression}))} in GNU C,
2646 where @code{@var{string_expression}} is
2647 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2648 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2649 configuration header file @file{tm.h} for each machine.  See the GCC
2650 manual for further information.
2651
2652 @node Pragma Main_Storage
2653 @unnumberedsec Pragma Main_Storage
2654 @cindex OpenVMS
2655 @findex Main_Storage
2656 @noindent
2657 Syntax:
2658
2659 @smallexample @c ada
2660 pragma Main_Storage
2661   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2662
2663 MAIN_STORAGE_OPTION ::=
2664   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2665 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2666
2667 @end smallexample
2668
2669 @noindent
2670 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2671 no effect in GNAT, other than being syntax checked.  Note that the pragma
2672 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2673
2674 @node Pragma No_Return
2675 @unnumberedsec Pragma No_Return
2676 @findex No_Return
2677 @noindent
2678 Syntax:
2679
2680 @smallexample @c ada
2681 pragma No_Return (procedure_LOCAL_NAME);
2682 @end smallexample
2683
2684 @noindent
2685 @var{procedure_local_NAME} must refer to one or more procedure
2686 declarations in the current declarative part.  A procedure to which this
2687 pragma is applied may not contain any explicit @code{return} statements,
2688 and also may not contain any implicit return statements from falling off
2689 the end of a statement sequence.  One use of this pragma is to identify
2690 procedures whose only purpose is to raise an exception.
2691
2692 Another use of this pragma is to suppress incorrect warnings about
2693 missing returns in functions, where the last statement of a function
2694 statement sequence is a call to such a procedure.
2695
2696 @node Pragma Normalize_Scalars
2697 @unnumberedsec Pragma Normalize_Scalars
2698 @findex Normalize_Scalars
2699 @noindent
2700 Syntax:
2701
2702 @smallexample @c ada
2703 pragma Normalize_Scalars;
2704 @end smallexample
2705
2706 @noindent
2707 This is a language defined pragma which is fully implemented in GNAT@.  The
2708 effect is to cause all scalar objects that are not otherwise initialized
2709 to be initialized.  The initial values are implementation dependent and
2710 are as follows:
2711
2712 @table @code
2713 @item Standard.Character
2714 @noindent
2715 Objects whose root type is Standard.Character are initialized to
2716 Character'Last.  This will be out of range of the subtype only if
2717 the subtype range excludes this value.
2718
2719 @item Standard.Wide_Character
2720 @noindent
2721 Objects whose root type is Standard.Wide_Character are initialized to
2722 Wide_Character'Last.  This will be out of range of the subtype only if
2723 the subtype range excludes this value.
2724
2725 @item Integer types
2726 @noindent
2727 Objects of an integer type are initialized to base_type'First, where
2728 base_type is the base type of the object type.  This will be out of range
2729 of the subtype only if the subtype range excludes this value.  For example,
2730 if you declare the subtype:
2731
2732 @smallexample @c ada
2733 subtype Ityp is integer range 1 .. 10;
2734 @end smallexample
2735
2736 @noindent
2737 then objects of type x will be initialized to Integer'First, a negative
2738 number that is certainly outside the range of subtype @code{Ityp}.
2739
2740 @item Real types
2741 Objects of all real types (fixed and floating) are initialized to
2742 base_type'First, where base_Type is the base type of the object type.
2743 This will be out of range of the subtype only if the subtype range
2744 excludes this value.
2745
2746 @item Modular types
2747 Objects of a modular type are initialized to typ'Last.  This will be out
2748 of range of the subtype only if the subtype excludes this value.
2749
2750 @item Enumeration types
2751 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2752 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2753 enumeration subtype in all cases except where the subtype contains
2754 exactly 2**8, 2**16, or 2**32 elements.
2755
2756 @end table
2757
2758 @node Pragma Obsolescent
2759 @unnumberedsec Pragma Obsolescent
2760 @findex Obsolescent
2761 @noindent
2762 Syntax:
2763
2764 @smallexample @c ada
2765 pragma Obsolescent [(static_string_EXPRESSION)];
2766 @end smallexample
2767
2768 @noindent
2769 This pragma must occur immediately following a subprogram
2770 declaration. It indicates that the associated function or procedure
2771 is considered obsolescent and should not be used. Typically this is
2772 used when an API must be modified by eventually removing or modifying
2773 existing subprograms. The pragma can be used at an intermediate stage
2774 when the subprogram is still present, but will be removed later.
2775
2776 The effect of this pragma is to output a warning message that the
2777 subprogram is obsolescent if the appropriate warning option in the
2778 compiler is activated. If a parameter is present, then a second
2779 warning message is given containing this text.
2780
2781 @node Pragma Passive
2782 @unnumberedsec Pragma Passive
2783 @findex Passive
2784 @noindent
2785 Syntax:
2786
2787 @smallexample @c ada
2788 pragma Passive ([Semaphore | No]);
2789 @end smallexample
2790
2791 @noindent
2792 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2793 compatibility with DEC Ada 83 implementations, where it is used within a
2794 task definition to request that a task be made passive.  If the argument
2795 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2796 treats the pragma as an assertion that the containing task is passive
2797 and that optimization of context switch with this task is permitted and
2798 desired.  If the argument @code{No} is present, the task must not be
2799 optimized.  GNAT does not attempt to optimize any tasks in this manner
2800 (since protected objects are available in place of passive tasks).
2801
2802 @node Pragma Polling
2803 @unnumberedsec Pragma Polling
2804 @findex Polling
2805 @noindent
2806 Syntax:
2807
2808 @smallexample @c ada
2809 pragma Polling (ON | OFF);
2810 @end smallexample
2811
2812 @noindent
2813 This pragma controls the generation of polling code.  This is normally off.
2814 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2815 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2816 runtime library, and can be found in file @file{a-excpol.adb}.
2817
2818 Pragma @code{Polling} can appear as a configuration pragma (for example it
2819 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2820 can be used in the statement or declaration sequence to control polling
2821 more locally.
2822
2823 A call to the polling routine is generated at the start of every loop and
2824 at the start of every subprogram call.  This guarantees that the @code{Poll}
2825 routine is called frequently, and places an upper bound (determined by
2826 the complexity of the code) on the period between two @code{Poll} calls.
2827
2828 The primary purpose of the polling interface is to enable asynchronous
2829 aborts on targets that cannot otherwise support it (for example Windows
2830 NT), but it may be used for any other purpose requiring periodic polling.
2831 The standard version is null, and can be replaced by a user program.  This
2832 will require re-compilation of the @code{Ada.Exceptions} package that can
2833 be found in files @file{a-except.ads} and @file{a-except.adb}.
2834
2835 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2836 distribution) is used to enable the asynchronous abort capability on
2837 targets that do not normally support the capability.  The version of
2838 @code{Poll} in this file makes a call to the appropriate runtime routine
2839 to test for an abort condition.
2840
2841 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2842 the @cite{GNAT User's Guide} for details.
2843
2844 @node Pragma Profile (Ravenscar)
2845 @unnumberedsec Pragma Profile (Ravenscar)
2846 @findex Ravenscar
2847 @noindent
2848 Syntax:
2849
2850 @smallexample @c ada
2851 pragma Profile (Ravenscar);
2852 @end smallexample
2853
2854 @noindent
2855 A configuration pragma that establishes the following set of configuration
2856 pragmas:
2857
2858 @table @code
2859 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2860 [RM D.2.2] Tasks are dispatched following a preemptive
2861 priority-ordered scheduling policy.
2862
2863 @item Locking_Policy (Ceiling_Locking)
2864 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2865 the ceiling priority of the corresponding protected object.
2866 @c
2867 @c @item Detect_Blocking
2868 @c This pragma forces the detection of potentially blocking operations within a
2869 @c protected operation, and to raise Program_Error if that happens.
2870 @end table
2871 @noindent
2872
2873 plus the following set of restrictions:
2874
2875 @table @code
2876 @item Max_Entry_Queue_Length = 1
2877 Defines the maximum number of calls that are queued on a (protected) entry.
2878 Note that this restrictions is checked at run time. Violation of this
2879 restriction results in the raising of Program_Error exception at the point of
2880 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2881 always 1 and hence no task can be queued on a protected entry.
2882
2883 @item Max_Protected_Entries = 1
2884 [RM D.7] Specifies the maximum number of entries per protected type. The
2885 bounds of every entry family of a protected unit shall be static, or shall be
2886 defined by a discriminant of a subtype whose corresponding bound is static.
2887 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
2888
2889 @item Max_Task_Entries = 0
2890 [RM D.7] Specifies the maximum number of entries
2891 per task.  The bounds of every entry family
2892 of a task unit shall be static, or shall be
2893 defined by a discriminant of a subtype whose
2894 corresponding bound is static.  A value of zero
2895 indicates that no rendezvous are possible.  For
2896 the Profile (Ravenscar), the value of Max_Task_Entries is always
2897 0 (zero).
2898
2899 @item No_Abort_Statements
2900 [RM D.7] There are no abort_statements, and there are
2901 no calls to Task_Identification.Abort_Task.
2902
2903 @item No_Asynchronous_Control
2904 [RM D.7] There are no semantic dependences on the package
2905 Asynchronous_Task_Control.
2906
2907 @item No_Calendar
2908 There are no semantic dependencies on the package Ada.Calendar.
2909
2910 @item No_Dynamic_Attachment
2911 There is no call to any of the operations defined in package Ada.Interrupts
2912 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
2913 Detach_Handler, and Reference).
2914
2915 @item No_Dynamic_Priorities
2916 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2917
2918 @item No_Implicit_Heap_Allocations
2919 [RM D.7] No constructs are allowed to cause implicit heap allocation.
2920
2921 @item No_Local_Protected_Objects
2922 Protected objects and access types that designate
2923 such objects shall be declared only at library level.
2924
2925 @item No_Protected_Type_Allocators
2926 There are no allocators for protected types or
2927 types containing protected subcomponents.
2928
2929 @item No_Relative_Delay
2930 There are no delay_relative statements.
2931
2932 @item No_Requeue_Statements
2933 Requeue statements are not allowed.
2934
2935 @item No_Select_Statements
2936 There are no select_statements.
2937
2938 @item No_Task_Allocators
2939 [RM D.7] There are no allocators for task types
2940 or types containing task subcomponents.
2941
2942 @item No_Task_Attributes_Package
2943 There are no semantic dependencies on the Ada.Task_Attributes package.
2944
2945 @item No_Task_Hierarchy
2946 [RM D.7] All (non-environment) tasks depend
2947 directly on the environment task of the partition.
2948
2949 @item No_Task_Termination
2950 Tasks which terminate are erroneous.
2951
2952 @item Simple_Barriers
2953 Entry barrier condition expressions shall be either static
2954 boolean expressions or boolean objects which are declared in
2955 the protected type which contains the entry.
2956 @end table
2957
2958 @noindent
2959 This set of configuration pragmas and restrictions correspond to the
2960 definition of the ``Ravenscar Profile'' for limited tasking, devised and
2961 published by the @cite{International Real-Time Ada Workshop}, 1997,
2962 and whose most recent description is available at
2963 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
2964
2965 The original definition of the profile was revised at subsequent IRTAW
2966 meetings. It has been included in the ISO
2967 @cite{Guide for the Use of the Ada Programming Language in High
2968 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
2969 the next revision of the standard. The formal definition given by
2970 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
2971 AI-305) available at
2972 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
2973 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
2974 respectively.
2975
2976 The above set is a superset of the restrictions provided by pragma
2977 @code{Profile (Restricted)}, it includes six additional restrictions
2978 (@code{Simple_Barriers}, @code{No_Select_Statements},
2979 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
2980 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
2981 that pragma @code{Profile (Ravenscar)}, like the pragma
2982 @code{Profile (Restricted)},
2983 automatically causes the use of a simplified,
2984 more efficient version of the tasking run-time system.
2985
2986 @node Pragma Profile (Restricted)
2987 @unnumberedsec Pragma Profile (Restricted)
2988 @findex Restricted Run Time
2989 @noindent
2990 Syntax:
2991
2992 @smallexample @c ada
2993 pragma Profile (Restricted);
2994 @end smallexample
2995
2996 @noindent
2997 A configuration pragma that establishes the following set of restrictions:
2998
2999 @itemize @bullet
3000 @item No_Abort_Statements
3001 @item No_Entry_Queue
3002 @item No_Task_Hierarchy
3003 @item No_Task_Allocators
3004 @item No_Dynamic_Priorities
3005 @item No_Terminate_Alternatives
3006 @item No_Dynamic_Attachment
3007 @item No_Protected_Type_Allocators
3008 @item No_Local_Protected_Objects
3009 @item No_Requeue_Statements
3010 @item No_Task_Attributes_Package
3011 @item Max_Asynchronous_Select_Nesting =  0
3012 @item Max_Task_Entries =  0
3013 @item Max_Protected_Entries = 1
3014 @item Max_Select_Alternatives = 0
3015 @end itemize
3016
3017 @noindent
3018 This set of restrictions causes the automatic selection of a simplified
3019 version of the run time that provides improved performance for the
3020 limited set of tasking functionality permitted by this set of restrictions.
3021
3022 @node Pragma Propagate_Exceptions
3023 @unnumberedsec Pragma Propagate_Exceptions
3024 @findex Propagate_Exceptions
3025 @cindex Zero Cost Exceptions
3026 @noindent
3027 Syntax:
3028
3029 @smallexample @c ada
3030 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
3031 @end smallexample
3032
3033 @noindent
3034 This pragma indicates that the given entity, which is the name of an
3035 imported foreign-language subprogram may receive an Ada exception,
3036 and that the exception should be propagated.  It is relevant only if
3037 zero cost exception handling is in use, and is thus never needed if
3038 the alternative @code{longjmp} / @code{setjmp} implementation of
3039 exceptions is used (although it is harmless to use it in such cases).
3040
3041 The implementation of fast exceptions always properly propagates
3042 exceptions through Ada code, as described in the Ada Reference Manual.
3043 However, this manual is silent about the propagation of exceptions
3044 through foreign code.  For example, consider the
3045 situation where @code{P1} calls
3046 @code{P2}, and @code{P2} calls @code{P3}, where
3047 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
3048 @code{P3} raises an Ada exception.  The question is whether or not
3049 it will be propagated through @code{P2} and can be handled in
3050 @code{P1}.
3051
3052 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
3053 the answer is always yes.  For some targets on which zero cost exception
3054 handling is implemented, the answer is also always yes.  However, there
3055 are some targets, notably in the current version all x86 architecture
3056 targets, in which the answer is that such propagation does not
3057 happen automatically.  If such propagation is required on these
3058 targets, it is mandatory to use @code{Propagate_Exceptions} to
3059 name all foreign language routines through which Ada exceptions
3060 may be propagated.
3061
3062 @node Pragma Psect_Object
3063 @unnumberedsec Pragma Psect_Object
3064 @findex Psect_Object
3065 @noindent
3066 Syntax:
3067
3068 @smallexample @c ada
3069 pragma Psect_Object (
3070      [Internal =>] LOCAL_NAME,
3071   [, [External =>] EXTERNAL_SYMBOL]
3072   [, [Size     =>] EXTERNAL_SYMBOL]);
3073
3074 EXTERNAL_SYMBOL ::=
3075   IDENTIFIER
3076 | static_string_EXPRESSION
3077 @end smallexample
3078
3079 @noindent
3080 This pragma is identical in effect to pragma @code{Common_Object}.
3081
3082 @node Pragma Pure_Function
3083 @unnumberedsec Pragma Pure_Function
3084 @findex Pure_Function
3085 @noindent
3086 Syntax:
3087
3088 @smallexample @c ada
3089 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3090 @end smallexample
3091
3092 @noindent
3093 This pragma appears in the same declarative part as a function
3094 declaration (or a set of function declarations if more than one
3095 overloaded declaration exists, in which case the pragma applies
3096 to all entities).  It specifies that the function @code{Entity} is
3097 to be considered pure for the purposes of code generation.  This means
3098 that the compiler can assume that there are no side effects, and
3099 in particular that two calls with identical arguments produce the
3100 same result.  It also means that the function can be used in an
3101 address clause.
3102
3103 Note that, quite deliberately, there are no static checks to try
3104 to ensure that this promise is met, so @code{Pure_Function} can be used
3105 with functions that are conceptually pure, even if they do modify
3106 global variables.  For example, a square root function that is
3107 instrumented to count the number of times it is called is still
3108 conceptually pure, and can still be optimized, even though it
3109 modifies a global variable (the count).  Memo functions are another
3110 example (where a table of previous calls is kept and consulted to
3111 avoid re-computation).
3112
3113 @findex Pure
3114 Note: Most functions in a @code{Pure} package are automatically pure, and
3115 there is no need to use pragma @code{Pure_Function} for such functions.  One
3116 exception is any function that has at least one formal of type
3117 @code{System.Address} or a type derived from it.  Such functions are not
3118 considered pure by default, since the compiler assumes that the
3119 @code{Address} parameter may be functioning as a pointer and that the
3120 referenced data may change even if the address value does not.
3121 Similarly, imported functions are not considered to be pure by default,
3122 since there is no way of checking that they are in fact pure.  The use
3123 of pragma @code{Pure_Function} for such a function will override these default
3124 assumption, and cause the compiler to treat a designated subprogram as pure
3125 in these cases.
3126
3127 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3128 applies to the underlying renamed function.  This can be used to
3129 disambiguate cases of overloading where some but not all functions
3130 in a set of overloaded functions are to be designated as pure.
3131
3132 @node Pragma Restriction_Warnings
3133 @unnumberedsec Pragma Restriction_Warnings
3134 @findex Restriction_Warnings
3135 @noindent
3136 Syntax:
3137
3138 @smallexample @c ada
3139 pragma Restriction_Warnings
3140   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3141 @end smallexample
3142
3143 @noindent
3144 This pragma allows a series of restriction identifiers to be
3145 specified (the list of allowed identifiers is the same as for
3146 pragma @code{Restrictions}). For each of these identifiers
3147 the compiler checks for violations of the restriction, but
3148 generates a warning message rather than an error message
3149 if the restriction is violated.
3150
3151 @node Pragma Source_File_Name
3152 @unnumberedsec Pragma Source_File_Name
3153 @findex Source_File_Name
3154 @noindent
3155 Syntax:
3156
3157 @smallexample @c ada
3158 pragma Source_File_Name (
3159   [Unit_Name   =>] unit_NAME,
3160   Spec_File_Name =>  STRING_LITERAL);
3161
3162 pragma Source_File_Name (
3163   [Unit_Name   =>] unit_NAME,
3164   Body_File_Name =>  STRING_LITERAL);
3165 @end smallexample
3166
3167 @noindent
3168 Use this to override the normal naming convention.  It is a configuration
3169 pragma, and so has the usual applicability of configuration pragmas
3170 (i.e.@: it applies to either an entire partition, or to all units in a
3171 compilation, or to a single unit, depending on how it is used.
3172 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3173 the second argument is required, and indicates whether this is the file
3174 name for the spec or for the body.
3175
3176 Another form of the @code{Source_File_Name} pragma allows
3177 the specification of patterns defining alternative file naming schemes
3178 to apply to all files.
3179
3180 @smallexample @c ada
3181 pragma Source_File_Name
3182   (Spec_File_Name => STRING_LITERAL
3183    [,Casing => CASING_SPEC]
3184    [,Dot_Replacement => STRING_LITERAL]);
3185
3186 pragma Source_File_Name
3187   (Body_File_Name => STRING_LITERAL
3188    [,Casing => CASING_SPEC]
3189    [,Dot_Replacement => STRING_LITERAL]);
3190
3191 pragma Source_File_Name
3192   (Subunit_File_Name => STRING_LITERAL
3193    [,Casing => CASING_SPEC]
3194    [,Dot_Replacement => STRING_LITERAL]);
3195
3196 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3197 @end smallexample
3198
3199 @noindent
3200 The first argument is a pattern that contains a single asterisk indicating
3201 the point at which the unit name is to be inserted in the pattern string
3202 to form the file name.  The second argument is optional.  If present it
3203 specifies the casing of the unit name in the resulting file name string.
3204 The default is lower case.  Finally the third argument allows for systematic
3205 replacement of any dots in the unit name by the specified string literal.
3206
3207 A pragma Source_File_Name cannot appear after a
3208 @ref{Pragma Source_File_Name_Project}.
3209
3210 For more details on the use of the @code{Source_File_Name} pragma,
3211 see the sections ``Using Other File Names'' and
3212 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3213
3214 @node Pragma Source_File_Name_Project
3215 @unnumberedsec Pragma Source_File_Name_Project
3216 @findex Source_File_Name_Project
3217 @noindent
3218
3219 This pragma has the same syntax and semantics as pragma Source_File_Name.
3220 It is only allowed as a stand alone configuration pragma.
3221 It cannot appear after a @ref{Pragma Source_File_Name}, and
3222 most importantly, once pragma Source_File_Name_Project appears,
3223 no further Source_File_Name pragmas are allowed.
3224
3225 The intention is that Source_File_Name_Project pragmas are always
3226 generated by the Project Manager in a manner consistent with the naming
3227 specified in a project file, and when naming is controlled in this manner,
3228 it is not permissible to attempt to modify this naming scheme using
3229 Source_File_Name pragmas (which would not be known to the project manager).
3230
3231 @node Pragma Source_Reference
3232 @unnumberedsec Pragma Source_Reference
3233 @findex Source_Reference
3234 @noindent
3235 Syntax:
3236
3237 @smallexample @c ada
3238 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3239 @end smallexample
3240
3241 @noindent
3242 This pragma must appear as the first line of a source file.
3243 @var{integer_literal} is the logical line number of the line following
3244 the pragma line (for use in error messages and debugging
3245 information).  @var{string_literal} is a static string constant that
3246 specifies the file name to be used in error messages and debugging
3247 information.  This is most notably used for the output of @code{gnatchop}
3248 with the @code{-r} switch, to make sure that the original unchopped
3249 source file is the one referred to.
3250
3251 The second argument must be a string literal, it cannot be a static
3252 string expression other than a string literal.  This is because its value
3253 is needed for error messages issued by all phases of the compiler.
3254
3255 @node Pragma Stream_Convert
3256 @unnumberedsec Pragma Stream_Convert
3257 @findex Stream_Convert
3258 @noindent
3259 Syntax:
3260
3261 @smallexample @c ada
3262 pragma Stream_Convert (
3263   [Entity =>] type_LOCAL_NAME,
3264   [Read   =>] function_NAME,
3265   [Write  =>] function_NAME);
3266 @end smallexample
3267
3268 @noindent
3269 This pragma provides an efficient way of providing stream functions for
3270 types defined in packages.  Not only is it simpler to use than declaring
3271 the necessary functions with attribute representation clauses, but more
3272 significantly, it allows the declaration to made in such a way that the
3273 stream packages are not loaded unless they are needed.  The use of
3274 the Stream_Convert pragma adds no overhead at all, unless the stream
3275 attributes are actually used on the designated type.
3276
3277 The first argument specifies the type for which stream functions are
3278 provided.  The second parameter provides a function used to read values
3279 of this type.  It must name a function whose argument type may be any
3280 subtype, and whose returned type must be the type given as the first
3281 argument to the pragma.
3282
3283 The meaning of the @var{Read}
3284 parameter is that if a stream attribute directly
3285 or indirectly specifies reading of the type given as the first parameter,
3286 then a value of the type given as the argument to the Read function is
3287 read from the stream, and then the Read function is used to convert this
3288 to the required target type.
3289
3290 Similarly the @var{Write} parameter specifies how to treat write attributes
3291 that directly or indirectly apply to the type given as the first parameter.
3292 It must have an input parameter of the type specified by the first parameter,
3293 and the return type must be the same as the input type of the Read function.
3294 The effect is to first call the Write function to convert to the given stream
3295 type, and then write the result type to the stream.
3296
3297 The Read and Write functions must not be overloaded subprograms.  If necessary
3298 renamings can be supplied to meet this requirement.
3299 The usage of this attribute is best illustrated by a simple example, taken
3300 from the GNAT implementation of package Ada.Strings.Unbounded:
3301
3302 @smallexample @c ada
3303 function To_Unbounded (S : String)
3304            return Unbounded_String
3305   renames To_Unbounded_String;
3306
3307 pragma Stream_Convert
3308   (Unbounded_String, To_Unbounded, To_String);
3309 @end smallexample
3310
3311 @noindent
3312 The specifications of the referenced functions, as given in the Ada 95
3313 Reference Manual are:
3314
3315 @smallexample @c ada
3316 function To_Unbounded_String (Source : String)
3317   return Unbounded_String;
3318
3319 function To_String (Source : Unbounded_String)
3320   return String;
3321 @end smallexample
3322
3323 @noindent
3324 The effect is that if the value of an unbounded string is written to a
3325 stream, then the representation of the item in the stream is in the same
3326 format used for @code{Standard.String}, and this same representation is
3327 expected when a value of this type is read from the stream.
3328
3329 @node Pragma Style_Checks
3330 @unnumberedsec Pragma Style_Checks
3331 @findex Style_Checks
3332 @noindent
3333 Syntax:
3334
3335 @smallexample @c ada
3336 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3337                      On | Off [, LOCAL_NAME]);
3338 @end smallexample
3339
3340 @noindent
3341 This pragma is used in conjunction with compiler switches to control the
3342 built in style checking provided by GNAT@.  The compiler switches, if set,
3343 provide an initial setting for the switches, and this pragma may be used
3344 to modify these settings, or the settings may be provided entirely by
3345 the use of the pragma.  This pragma can be used anywhere that a pragma
3346 is legal, including use as a configuration pragma (including use in
3347 the @file{gnat.adc} file).
3348
3349 The form with a string literal specifies which style options are to be
3350 activated.  These are additive, so they apply in addition to any previously
3351 set style check options.  The codes for the options are the same as those
3352 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3353 For example the following two methods can be used to enable
3354 layout checking:
3355
3356 @itemize @bullet
3357 @item
3358 @smallexample @c ada
3359 pragma Style_Checks ("l");
3360 @end smallexample
3361
3362 @item
3363 @smallexample
3364 gcc -c -gnatyl @dots{}
3365 @end smallexample
3366 @end itemize
3367
3368 @noindent
3369 The form ALL_CHECKS activates all standard checks (its use is equivalent
3370 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3371 Guide for details.
3372
3373 The forms with @code{Off} and @code{On}
3374 can be used to temporarily disable style checks
3375 as shown in the following example:
3376
3377 @smallexample @c ada
3378 @iftex
3379 @leftskip=0cm
3380 @end iftex
3381 pragma Style_Checks ("k"); -- requires keywords in lower case
3382 pragma Style_Checks (Off); -- turn off style checks
3383 NULL;                      -- this will not generate an error message
3384 pragma Style_Checks (On);  -- turn style checks back on
3385 NULL;                      -- this will generate an error message
3386 @end smallexample
3387
3388 @noindent
3389 Finally the two argument form is allowed only if the first argument is
3390 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3391 for the specified entity, as shown in the following example:
3392
3393 @smallexample @c ada
3394 @iftex
3395 @leftskip=0cm
3396 @end iftex
3397 pragma Style_Checks ("r"); -- require consistency of identifier casing
3398 Arg : Integer;
3399 Rf1 : Integer := ARG;      -- incorrect, wrong case
3400 pragma Style_Checks (Off, Arg);
3401 Rf2 : Integer := ARG;      -- OK, no error
3402 @end smallexample
3403
3404 @node Pragma Subtitle
3405 @unnumberedsec Pragma Subtitle
3406 @findex Subtitle
3407 @noindent
3408 Syntax:
3409
3410 @smallexample @c ada
3411 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3412 @end smallexample
3413
3414 @noindent
3415 This pragma is recognized for compatibility with other Ada compilers
3416 but is ignored by GNAT@.
3417
3418 @node Pragma Suppress_All
3419 @unnumberedsec Pragma Suppress_All
3420 @findex Suppress_All
3421 @noindent
3422 Syntax:
3423
3424 @smallexample @c ada
3425 pragma Suppress_All;
3426 @end smallexample
3427
3428 @noindent
3429 This pragma can only appear immediately following a compilation
3430 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3431 which it follows.  This pragma is implemented for compatibility with DEC
3432 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3433 configuration pragma is the preferred usage in GNAT@.
3434
3435 @node Pragma Suppress_Exception_Locations
3436 @unnumberedsec Pragma Suppress_Exception_Locations
3437 @findex Suppress_Exception_Locations
3438 @noindent
3439 Syntax:
3440
3441 @smallexample @c ada
3442 pragma Suppress_Exception_Locations;
3443 @end smallexample
3444
3445 @noindent
3446 In normal mode, a raise statement for an exception by default generates
3447 an exception message giving the file name and line number for the location
3448 of the raise. This is useful for debugging and logging purposes, but this
3449 entails extra space for the strings for the messages. The configuration
3450 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3451 generation of these strings, with the result that space is saved, but the
3452 exception message for such raises is null. This configuration pragma may
3453 appear in a global configuration pragma file, or in a specific unit as
3454 usual. It is not required that this pragma be used consistently within
3455 a partition, so it is fine to have some units within a partition compiled
3456 with this pragma and others compiled in normal mode without it.
3457
3458 @node Pragma Suppress_Initialization
3459 @unnumberedsec Pragma Suppress_Initialization
3460 @findex Suppress_Initialization
3461 @cindex Suppressing initialization
3462 @cindex Initialization, suppression of
3463 @noindent
3464 Syntax:
3465
3466 @smallexample @c ada
3467 pragma Suppress_Initialization ([Entity =>] type_Name);
3468 @end smallexample
3469
3470 @noindent
3471 This pragma suppresses any implicit or explicit initialization
3472 associated with the given type name for all variables of this type.
3473
3474 @node Pragma Task_Info
3475 @unnumberedsec Pragma Task_Info
3476 @findex Task_Info
3477 @noindent
3478 Syntax
3479
3480 @smallexample @c ada
3481 pragma Task_Info (EXPRESSION);
3482 @end smallexample
3483
3484 @noindent
3485 This pragma appears within a task definition (like pragma
3486 @code{Priority}) and applies to the task in which it appears.  The
3487 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3488 The @code{Task_Info} pragma provides system dependent control over
3489 aspects of tasking implementation, for example, the ability to map
3490 tasks to specific processors.  For details on the facilities available
3491 for the version of GNAT that you are using, see the documentation
3492 in the specification of package System.Task_Info in the runtime
3493 library.
3494
3495 @node Pragma Task_Name
3496 @unnumberedsec Pragma Task_Name
3497 @findex Task_Name
3498 @noindent
3499 Syntax
3500
3501 @smallexample @c ada
3502 pragma Task_Name (string_EXPRESSION);
3503 @end smallexample
3504
3505 @noindent
3506 This pragma appears within a task definition (like pragma
3507 @code{Priority}) and applies to the task in which it appears.  The
3508 argument must be of type String, and provides a name to be used for
3509 the task instance when the task is created.  Note that this expression
3510 is not required to be static, and in particular, it can contain
3511 references to task discriminants.  This facility can be used to
3512 provide different names for different tasks as they are created,
3513 as illustrated in the example below.
3514
3515 The task name is recorded internally in the run-time structures
3516 and is accessible to tools like the debugger.  In addition the
3517 routine @code{Ada.Task_Identification.Image} will return this
3518 string, with a unique task address appended.
3519
3520 @smallexample @c ada
3521 --  Example of the use of pragma Task_Name
3522
3523 with Ada.Task_Identification;
3524 use Ada.Task_Identification;
3525 with Text_IO; use Text_IO;
3526 procedure t3 is
3527
3528    type Astring is access String;
3529
3530    task type Task_Typ (Name : access String) is
3531       pragma Task_Name (Name.all);
3532    end Task_Typ;
3533
3534    task body Task_Typ is
3535       Nam : constant String := Image (Current_Task);
3536    begin
3537       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3538    end Task_Typ;
3539
3540    type Ptr_Task is access Task_Typ;
3541    Task_Var : Ptr_Task;
3542
3543 begin
3544    Task_Var :=
3545      new Task_Typ (new String'("This is task 1"));
3546    Task_Var :=
3547      new Task_Typ (new String'("This is task 2"));
3548 end;
3549 @end smallexample
3550
3551 @node Pragma Task_Storage
3552 @unnumberedsec Pragma Task_Storage
3553 @findex Task_Storage
3554 Syntax:
3555
3556 @smallexample @c ada
3557 pragma Task_Storage (
3558   [Task_Type =>] LOCAL_NAME,
3559   [Top_Guard =>] static_integer_EXPRESSION);
3560 @end smallexample
3561
3562 @noindent
3563 This pragma specifies the length of the guard area for tasks.  The guard
3564 area is an additional storage area allocated to a task.  A value of zero
3565 means that either no guard area is created or a minimal guard area is
3566 created, depending on the target.  This pragma can appear anywhere a
3567 @code{Storage_Size} attribute definition clause is allowed for a task
3568 type.
3569
3570 @node Pragma Thread_Body
3571 @unnumberedsec Pragma Thread_Body
3572 @findex Thread_Body
3573 Syntax:
3574
3575 @smallexample @c ada
3576 pragma Thread_Body (
3577   [Entity =>] LOCAL_NAME,
3578  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3579 @end smallexample
3580
3581 @noindent
3582 This pragma specifies that the subprogram whose name is given as the
3583 @code{Entity} argument is a thread body, which will be activated
3584 by being called via its Address from foreign code. The purpose is
3585 to allow execution and registration of the foreign thread within the
3586 Ada run-time system.
3587
3588 See the library unit @code{System.Threads} for details on the expansion of
3589 a thread body subprogram, including the calls made to subprograms
3590 within System.Threads to register the task.  This unit also lists the
3591 targets and runtime systems for which this pragma is supported.
3592
3593 A thread body subprogram may not be called directly from Ada code, and
3594 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3595 to such a subprogram. The only legitimate way of calling such a subprogram
3596 is to pass its Address to foreign code and then make the call from the
3597 foreign code.
3598
3599 A thread body subprogram may have any parameters, and it may be a function
3600 returning a result. The convention of the thread body subprogram may be
3601 set in the usual manner using @code{pragma Convention}.
3602
3603 The secondary stack size parameter, if given, is used to set the size
3604 of secondary stack for the thread. The secondary stack is allocated as
3605 a local variable of the expanded thread body subprogram, and thus is
3606 allocated out of the main thread stack size. If no secondary stack
3607 size parameter is present, the default size (from the declaration in
3608 @code{System.Secondary_Stack} is used.
3609
3610 @node Pragma Time_Slice
3611 @unnumberedsec Pragma Time_Slice
3612 @findex Time_Slice
3613 @noindent
3614 Syntax:
3615
3616 @smallexample @c ada
3617 pragma Time_Slice (static_duration_EXPRESSION);
3618 @end smallexample
3619
3620 @noindent
3621 For implementations of GNAT on operating systems where it is possible
3622 to supply a time slice value, this pragma may be used for this purpose.
3623 It is ignored if it is used in a system that does not allow this control,
3624 or if it appears in other than the main program unit.
3625 @cindex OpenVMS
3626 Note that the effect of this pragma is identical to the effect of the
3627 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3628
3629 @node Pragma Title
3630 @unnumberedsec Pragma Title
3631 @findex Title
3632 @noindent
3633 Syntax:
3634
3635 @smallexample @c ada
3636 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3637
3638 TITLING_OPTION ::=
3639   [Title    =>] STRING_LITERAL,
3640 | [Subtitle =>] STRING_LITERAL
3641 @end smallexample
3642
3643 @noindent
3644 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3645 pragma used in DEC Ada 83 implementations to provide a title and/or
3646 subtitle for the program listing.  The program listing generated by GNAT
3647 does not have titles or subtitles.
3648
3649 Unlike other pragmas, the full flexibility of named notation is allowed
3650 for this pragma, i.e.@: the parameters may be given in any order if named
3651 notation is used, and named and positional notation can be mixed
3652 following the normal rules for procedure calls in Ada.
3653
3654 @node Pragma Unchecked_Union
3655 @unnumberedsec Pragma Unchecked_Union
3656 @cindex Unions in C
3657 @findex Unchecked_Union
3658 @noindent
3659 Syntax:
3660
3661 @smallexample @c ada
3662 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3663 @end smallexample
3664
3665 @noindent
3666 This pragma is used to declare that the specified type should be represented
3667 in a manner
3668 equivalent to a C union type, and is intended only for use in
3669 interfacing with C code that uses union types.  In Ada terms, the named
3670 type must obey the following rules:
3671
3672 @itemize @bullet
3673 @item
3674 It is a non-tagged non-limited record type.
3675 @item
3676 It has a single discrete discriminant with a default value.
3677 @item
3678 The component list consists of a single variant part.
3679 @item
3680 Each variant has a component list with a single component.
3681 @item
3682 No nested variants are allowed.
3683 @item
3684 No component has an explicit default value.
3685 @item
3686 No component has a non-static constraint.
3687 @end itemize
3688
3689 @noindent
3690 In addition, given a type that meets the above requirements, the
3691 following restrictions apply to its use throughout the program:
3692
3693 @itemize @bullet
3694 @item
3695 The discriminant name can be mentioned only in an aggregate.
3696 @item
3697 No subtypes may be created of this type.
3698 @item
3699 The type may not be constrained by giving a discriminant value.
3700 @item
3701 The type cannot be passed as the actual for a generic formal with a
3702 discriminant.
3703 @end itemize
3704
3705 @noindent
3706 Equality and inequality operations on @code{unchecked_unions} are not
3707 available, since there is no discriminant to compare and the compiler
3708 does not even know how many bits to compare.  It is implementation
3709 dependent whether this is detected at compile time as an illegality or
3710 whether it is undetected and considered to be an erroneous construct.  In
3711 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3712 the composite case (where two composites are compared that contain an
3713 unchecked union component), so such comparisons are simply considered
3714 erroneous.
3715
3716 The layout of the resulting type corresponds exactly to a C union, where
3717 each branch of the union corresponds to a single variant in the Ada
3718 record.  The semantics of the Ada program is not changed in any way by
3719 the pragma, i.e.@: provided the above restrictions are followed, and no
3720 erroneous incorrect references to fields or erroneous comparisons occur,
3721 the semantics is exactly as described by the Ada reference manual.
3722 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3723 type and the default convention is C.
3724
3725 @node Pragma Unimplemented_Unit
3726 @unnumberedsec Pragma Unimplemented_Unit
3727 @findex Unimplemented_Unit
3728 @noindent
3729 Syntax:
3730
3731 @smallexample @c ada
3732 pragma Unimplemented_Unit;
3733 @end smallexample
3734
3735 @noindent
3736 If this pragma occurs in a unit that is processed by the compiler, GNAT
3737 aborts with the message @samp{@var{xxx} not implemented}, where
3738 @var{xxx} is the name of the current compilation unit.  This pragma is
3739 intended to allow the compiler to handle unimplemented library units in
3740 a clean manner.
3741
3742 The abort only happens if code is being generated.  Thus you can use
3743 specs of unimplemented packages in syntax or semantic checking mode.
3744
3745 @node Pragma Universal_Data
3746 @unnumberedsec Pragma Universal_Data
3747 @findex Universal_Data
3748 @noindent
3749 Syntax:
3750
3751 @smallexample @c ada
3752 pragma Universal_Data [(library_unit_Name)];
3753 @end smallexample
3754
3755 @noindent
3756 This pragma is supported only for the AAMP target and is ignored for
3757 other targets. The pragma specifies that all library-level objects
3758 (Counter 0 data) associated with the library unit are to be accessed
3759 and updated using universal addressing (24-bit addresses for AAMP5)
3760 rather than the default of 16-bit Data Environment (DENV) addressing.
3761 Use of this pragma will generally result in less efficient code for
3762 references to global data associated with the library unit, but
3763 allows such data to be located anywhere in memory. This pragma is
3764 a library unit pragma, but can also be used as a configuration pragma
3765 (including use in the @file{gnat.adc} file). The functionality
3766 of this pragma is also available by applying the -univ switch on the
3767 compilations of units where universal addressing of the data is desired.
3768
3769 @node Pragma Unreferenced
3770 @unnumberedsec Pragma Unreferenced
3771 @findex Unreferenced
3772 @cindex Warnings, unreferenced
3773 @noindent
3774 Syntax:
3775
3776 @smallexample @c ada
3777 pragma Unreferenced (local_Name @{, local_Name@});
3778 @end smallexample
3779
3780 @noindent
3781 This pragma signals that the entities whose names are listed are
3782 deliberately not referenced in the current source unit. This
3783 suppresses warnings about the
3784 entities being unreferenced, and in addition a warning will be
3785 generated if one of these entities is in fact referenced in the
3786 same unit as the pragma (or in the corresponding body, or one
3787 of its subunits).
3788
3789 This is particularly useful for clearly signaling that a particular
3790 parameter is not referenced in some particular subprogram implementation
3791 and that this is deliberate. It can also be useful in the case of
3792 objects declared only for their initialization or finalization side
3793 effects.
3794
3795 If @code{local_Name} identifies more than one matching homonym in the
3796 current scope, then the entity most recently declared is the one to which
3797 the pragma applies.
3798
3799 The left hand side of an assignment does not count as a reference for the
3800 purpose of this pragma. Thus it is fine to assign to an entity for which
3801 pragma Unreferenced is given.
3802
3803 @node Pragma Unreserve_All_Interrupts
3804 @unnumberedsec Pragma Unreserve_All_Interrupts
3805 @findex Unreserve_All_Interrupts
3806 @noindent
3807 Syntax:
3808
3809 @smallexample @c ada
3810 pragma Unreserve_All_Interrupts;
3811 @end smallexample
3812
3813 @noindent
3814 Normally certain interrupts are reserved to the implementation.  Any attempt
3815 to attach an interrupt causes Program_Error to be raised, as described in
3816 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3817 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3818 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3819 interrupt execution.
3820
3821 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3822 a program, then all such interrupts are unreserved.  This allows the
3823 program to handle these interrupts, but disables their standard
3824 functions.  For example, if this pragma is used, then pressing
3825 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3826 a program can then handle the @code{SIGINT} interrupt as it chooses.
3827
3828 For a full list of the interrupts handled in a specific implementation,
3829 see the source code for the specification of @code{Ada.Interrupts.Names} in
3830 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3831 list of interrupts recognized for a given target.  The documentation in
3832 this file also specifies what interrupts are affected by the use of
3833 the @code{Unreserve_All_Interrupts} pragma.
3834
3835 For a more general facility for controlling what interrupts can be
3836 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3837 of the @code{Unreserve_All_Interrupts} pragma.
3838
3839 @node Pragma Unsuppress
3840 @unnumberedsec Pragma Unsuppress
3841 @findex Unsuppress
3842 @noindent
3843 Syntax:
3844
3845 @smallexample @c ada
3846 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3847 @end smallexample
3848
3849 @noindent
3850 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3851 there is no corresponding pragma @code{Suppress} in effect, it has no
3852 effect.  The range of the effect is the same as for pragma
3853 @code{Suppress}.  The meaning of the arguments is identical to that used
3854 in pragma @code{Suppress}.
3855
3856 One important application is to ensure that checks are on in cases where
3857 code depends on the checks for its correct functioning, so that the code
3858 will compile correctly even if the compiler switches are set to suppress
3859 checks.
3860
3861 @node Pragma Use_VADS_Size
3862 @unnumberedsec Pragma Use_VADS_Size
3863 @cindex @code{Size}, VADS compatibility
3864 @findex Use_VADS_Size
3865 @noindent
3866 Syntax:
3867
3868 @smallexample @c ada
3869 pragma Use_VADS_Size;
3870 @end smallexample
3871
3872 @noindent
3873 This is a configuration pragma.  In a unit to which it applies, any use
3874 of the 'Size attribute is automatically interpreted as a use of the
3875 'VADS_Size attribute.  Note that this may result in incorrect semantic
3876 processing of valid Ada 95 programs.  This is intended to aid in the
3877 handling of legacy code which depends on the interpretation of Size
3878 as implemented in the VADS compiler.  See description of the VADS_Size
3879 attribute for further details.
3880
3881 @node Pragma Validity_Checks
3882 @unnumberedsec Pragma Validity_Checks
3883 @findex Validity_Checks
3884 @noindent
3885 Syntax:
3886
3887 @smallexample @c ada
3888 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3889 @end smallexample
3890
3891 @noindent
3892 This pragma is used in conjunction with compiler switches to control the
3893 built-in validity checking provided by GNAT@.  The compiler switches, if set
3894 provide an initial setting for the switches, and this pragma may be used
3895 to modify these settings, or the settings may be provided entirely by
3896 the use of the pragma.  This pragma can be used anywhere that a pragma
3897 is legal, including use as a configuration pragma (including use in
3898 the @file{gnat.adc} file).
3899
3900 The form with a string literal specifies which validity options are to be
3901 activated.  The validity checks are first set to include only the default
3902 reference manual settings, and then a string of letters in the string
3903 specifies the exact set of options required.  The form of this string
3904 is exactly as described for the @code{-gnatVx} compiler switch (see the
3905 GNAT users guide for details).  For example the following two methods
3906 can be used to enable validity checking for mode @code{in} and
3907 @code{in out} subprogram parameters:
3908
3909 @itemize @bullet
3910 @item
3911 @smallexample @c ada
3912 pragma Validity_Checks ("im");
3913 @end smallexample
3914
3915 @item
3916 @smallexample
3917 gcc -c -gnatVim @dots{}
3918 @end smallexample
3919 @end itemize
3920
3921 @noindent
3922 The form ALL_CHECKS activates all standard checks (its use is equivalent
3923 to the use of the @code{gnatva} switch.
3924
3925 The forms with @code{Off} and @code{On}
3926 can be used to temporarily disable validity checks
3927 as shown in the following example:
3928
3929 @smallexample @c ada
3930 @iftex
3931 @leftskip=0cm
3932 @end iftex
3933 pragma Validity_Checks ("c"); -- validity checks for copies
3934 pragma Validity_Checks (Off); -- turn off validity checks
3935 A := B;                       -- B will not be validity checked
3936 pragma Validity_Checks (On);  -- turn validity checks back on
3937 A := C;                       -- C will be validity checked
3938 @end smallexample
3939
3940 @node Pragma Volatile
3941 @unnumberedsec Pragma Volatile
3942 @findex Volatile
3943 @noindent
3944 Syntax:
3945
3946 @smallexample @c ada
3947 pragma Volatile (local_NAME);
3948 @end smallexample
3949
3950 @noindent
3951 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3952 implementation is fully conformant with this definition.  The reason it
3953 is mentioned in this section is that a pragma of the same name was supplied
3954 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3955 of pragma Volatile is upwards compatible with the implementation in
3956 Dec Ada 83.
3957
3958 @node Pragma Warnings
3959 @unnumberedsec Pragma Warnings
3960 @findex Warnings
3961 @noindent
3962 Syntax:
3963
3964 @smallexample @c ada
3965 pragma Warnings (On | Off [, LOCAL_NAME]);
3966 @end smallexample
3967
3968 @noindent
3969 Normally warnings are enabled, with the output being controlled by
3970 the command line switch.  Warnings (@code{Off}) turns off generation of
3971 warnings until a Warnings (@code{On}) is encountered or the end of the
3972 current unit.  If generation of warnings is turned off using this
3973 pragma, then no warning messages are output, regardless of the
3974 setting of the command line switches.
3975
3976 The form with a single argument is a configuration pragma.
3977
3978 If the @var{local_name} parameter is present, warnings are suppressed for
3979 the specified entity.  This suppression is effective from the point where
3980 it occurs till the end of the extended scope of the variable (similar to
3981 the scope of @code{Suppress}).
3982
3983 @node Pragma Weak_External
3984 @unnumberedsec Pragma Weak_External
3985 @findex Weak_External
3986 @noindent
3987 Syntax:
3988
3989 @smallexample @c ada
3990 pragma Weak_External ([Entity =>] LOCAL_NAME);
3991 @end smallexample
3992
3993 @noindent
3994 This pragma specifies that the given entity should be marked as a weak
3995 external (one that does not have to be resolved) for the linker.  For
3996 further details, consult the GCC manual.
3997
3998 @node Implementation Defined Attributes
3999 @chapter Implementation Defined Attributes
4000 Ada 95 defines (throughout the Ada 95 reference manual,
4001 summarized in annex K),
4002 a set of attributes that provide useful additional functionality in all
4003 areas of the language.  These language defined attributes are implemented
4004 in GNAT and work as described in the Ada 95 Reference Manual.
4005
4006 In addition, Ada 95 allows implementations to define additional
4007 attributes whose meaning is defined by the implementation.  GNAT provides
4008 a number of these implementation-dependent attributes which can be used
4009 to extend and enhance the functionality of the compiler.  This section of
4010 the GNAT reference manual describes these additional attributes.
4011
4012 Note that any program using these attributes may not be portable to
4013 other compilers (although GNAT implements this set of attributes on all
4014 platforms).  Therefore if portability to other compilers is an important
4015 consideration, you should minimize the use of these attributes.
4016
4017 @menu
4018 * Abort_Signal::
4019 * Address_Size::
4020 * Asm_Input::
4021 * Asm_Output::
4022 * AST_Entry::
4023 * Bit::
4024 * Bit_Position::
4025 * Code_Address::
4026 * Default_Bit_Order::
4027 * Elaborated::
4028 * Elab_Body::
4029 * Elab_Spec::
4030 * Emax::
4031 * Enum_Rep::
4032 * Epsilon::
4033 * Fixed_Value::
4034 * Has_Access_Values::
4035 * Has_Discriminants::
4036 * Img::
4037 * Integer_Value::
4038 * Large::
4039 * Machine_Size::
4040 * Mantissa::
4041 * Max_Interrupt_Priority::
4042 * Max_Priority::
4043 * Maximum_Alignment::
4044 * Mechanism_Code::
4045 * Null_Parameter::
4046 * Object_Size::
4047 * Passed_By_Reference::
4048 * Range_Length::
4049 * Safe_Emax::
4050 * Safe_Large::
4051 * Small::
4052 * Storage_Unit::
4053 * Target_Name::
4054 * Tick::
4055 * To_Address::
4056 * Type_Class::
4057 * UET_Address::
4058 * Unconstrained_Array::
4059 * Universal_Literal_String::
4060 * Unrestricted_Access::
4061 * VADS_Size::
4062 * Value_Size::
4063 * Wchar_T_Size::
4064 * Word_Size::
4065 @end menu
4066
4067 @node Abort_Signal
4068 @unnumberedsec Abort_Signal
4069 @findex Abort_Signal
4070 @noindent
4071 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4072 prefix) provides the entity for the special exception used to signal
4073 task abort or asynchronous transfer of control.  Normally this attribute
4074 should only be used in the tasking runtime (it is highly peculiar, and
4075 completely outside the normal semantics of Ada, for a user program to
4076 intercept the abort exception).
4077
4078 @node Address_Size
4079 @unnumberedsec Address_Size
4080 @cindex Size of @code{Address}
4081 @findex Address_Size
4082 @noindent
4083 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4084 prefix) is a static constant giving the number of bits in an
4085 @code{Address}. It is the same value as System.Address'Size,
4086 but has the advantage of being static, while a direct
4087 reference to System.Address'Size is non-static because Address
4088 is a private type.
4089
4090 @node Asm_Input
4091 @unnumberedsec Asm_Input
4092 @findex Asm_Input
4093 @noindent
4094 The @code{Asm_Input} attribute denotes a function that takes two
4095 parameters.  The first is a string, the second is an expression of the
4096 type designated by the prefix.  The first (string) argument is required
4097 to be a static expression, and is the constraint for the parameter,
4098 (e.g.@: what kind of register is required).  The second argument is the
4099 value to be used as the input argument.  The possible values for the
4100 constant are the same as those used in the RTL, and are dependent on
4101 the configuration file used to built the GCC back end.
4102 @ref{Machine Code Insertions}
4103
4104 @node Asm_Output
4105 @unnumberedsec Asm_Output
4106 @findex Asm_Output
4107 @noindent
4108 The @code{Asm_Output} attribute denotes a function that takes two
4109 parameters.  The first is a string, the second is the name of a variable
4110 of the type designated by the attribute prefix.  The first (string)
4111 argument is required to be a static expression and designates the
4112 constraint for the parameter (e.g.@: what kind of register is
4113 required).  The second argument is the variable to be updated with the
4114 result.  The possible values for constraint are the same as those used in
4115 the RTL, and are dependent on the configuration file used to build the
4116 GCC back end.  If there are no output operands, then this argument may
4117 either be omitted, or explicitly given as @code{No_Output_Operands}.
4118 @ref{Machine Code Insertions}
4119
4120 @node AST_Entry
4121 @unnumberedsec AST_Entry
4122 @cindex OpenVMS
4123 @findex AST_Entry
4124 @noindent
4125 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4126 the name of an entry, it yields a value of the predefined type AST_Handler
4127 (declared in the predefined package System, as extended by the use of
4128 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4129 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4130 Language Reference Manual}, section 9.12a.
4131
4132 @node Bit
4133 @unnumberedsec Bit
4134 @findex Bit
4135 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4136 offset within the storage unit (byte) that contains the first bit of
4137 storage allocated for the object.  The value of this attribute is of the
4138 type @code{Universal_Integer}, and is always a non-negative number not
4139 exceeding the value of @code{System.Storage_Unit}.
4140
4141 For an object that is a variable or a constant allocated in a register,
4142 the value is zero.  (The use of this attribute does not force the
4143 allocation of a variable to memory).
4144
4145 For an object that is a formal parameter, this attribute applies
4146 to either the matching actual parameter or to a copy of the
4147 matching actual parameter.
4148
4149 For an access object the value is zero.  Note that
4150 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4151 designated object.  Similarly for a record component
4152 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4153 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4154 are subject to index checks.
4155
4156 This attribute is designed to be compatible with the DEC Ada 83 definition
4157 and implementation of the @code{Bit} attribute.
4158
4159 @node Bit_Position
4160 @unnumberedsec Bit_Position
4161 @findex Bit_Position
4162 @noindent
4163 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4164 of the fields of the record type, yields the bit
4165 offset within the record contains the first bit of
4166 storage allocated for the object.  The value of this attribute is of the
4167 type @code{Universal_Integer}.  The value depends only on the field
4168 @var{C} and is independent of the alignment of
4169 the containing record @var{R}.
4170
4171 @node Code_Address
4172 @unnumberedsec Code_Address
4173 @findex Code_Address
4174 @cindex Subprogram address
4175 @cindex Address of subprogram code
4176 @noindent
4177 The @code{'Address}
4178 attribute may be applied to subprograms in Ada 95, but the
4179 intended effect from the Ada 95 reference manual seems to be to provide
4180 an address value which can be used to call the subprogram by means of
4181 an address clause as in the following example:
4182
4183 @smallexample @c ada
4184 procedure K is @dots{}
4185
4186 procedure L;
4187 for L'Address use K'Address;
4188 pragma Import (Ada, L);
4189 @end smallexample
4190
4191 @noindent
4192 A call to @code{L} is then expected to result in a call to @code{K}@.
4193 In Ada 83, where there were no access-to-subprogram values, this was
4194 a common work around for getting the effect of an indirect call.
4195 GNAT implements the above use of @code{Address} and the technique
4196 illustrated by the example code works correctly.
4197
4198 However, for some purposes, it is useful to have the address of the start
4199 of the generated code for the subprogram.  On some architectures, this is
4200 not necessarily the same as the @code{Address} value described above.
4201 For example, the @code{Address} value may reference a subprogram
4202 descriptor rather than the subprogram itself.
4203
4204 The @code{'Code_Address} attribute, which can only be applied to
4205 subprogram entities, always returns the address of the start of the
4206 generated code of the specified subprogram, which may or may not be
4207 the same value as is returned by the corresponding @code{'Address}
4208 attribute.
4209
4210 @node Default_Bit_Order
4211 @unnumberedsec Default_Bit_Order
4212 @cindex Big endian
4213 @cindex Little endian
4214 @findex Default_Bit_Order
4215 @noindent
4216 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4217 permissible prefix), provides the value @code{System.Default_Bit_Order}
4218 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4219 @code{Low_Order_First}).  This is used to construct the definition of
4220 @code{Default_Bit_Order} in package @code{System}.
4221
4222 @node Elaborated
4223 @unnumberedsec Elaborated
4224 @findex Elaborated
4225 @noindent
4226 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4227 value is a Boolean which indicates whether or not the given unit has been
4228 elaborated.  This attribute is primarily intended for internal use by the
4229 generated code for dynamic elaboration checking, but it can also be used
4230 in user programs.  The value will always be True once elaboration of all
4231 units has been completed.  An exception is for units which need no
4232 elaboration, the value is always False for such units.
4233
4234 @node Elab_Body
4235 @unnumberedsec Elab_Body
4236 @findex Elab_Body
4237 @noindent
4238 This attribute can only be applied to a program unit name.  It returns
4239 the entity for the corresponding elaboration procedure for elaborating
4240 the body of the referenced unit.  This is used in the main generated
4241 elaboration procedure by the binder and is not normally used in any
4242 other context.  However, there may be specialized situations in which it
4243 is useful to be able to call this elaboration procedure from Ada code,
4244 e.g.@: if it is necessary to do selective re-elaboration to fix some
4245 error.
4246
4247 @node Elab_Spec
4248 @unnumberedsec Elab_Spec
4249 @findex Elab_Spec
4250 @noindent
4251 This attribute can only be applied to a program unit name.  It returns
4252 the entity for the corresponding elaboration procedure for elaborating
4253 the specification of the referenced unit.  This is used in the main
4254 generated elaboration procedure by the binder and is not normally used
4255 in any other context.  However, there may be specialized situations in
4256 which it is useful to be able to call this elaboration procedure from
4257 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4258 some error.
4259
4260 @node Emax
4261 @unnumberedsec Emax
4262 @cindex Ada 83 attributes
4263 @findex Emax
4264 @noindent
4265 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4266 the Ada 83 reference manual for an exact description of the semantics of
4267 this attribute.
4268
4269 @node Enum_Rep
4270 @unnumberedsec Enum_Rep
4271 @cindex Representation of enums
4272 @findex Enum_Rep
4273 @noindent
4274 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4275 function with the following spec:
4276
4277 @smallexample @c ada
4278 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4279   return @i{Universal_Integer};
4280 @end smallexample
4281
4282 @noindent
4283 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4284 enumeration type or to a non-overloaded enumeration
4285 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4286 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4287 enumeration literal or object.
4288
4289 The function returns the representation value for the given enumeration
4290 value.  This will be equal to value of the @code{Pos} attribute in the
4291 absence of an enumeration representation clause.  This is a static
4292 attribute (i.e.@: the result is static if the argument is static).
4293
4294 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4295 in which case it simply returns the integer value.  The reason for this
4296 is to allow it to be used for @code{(<>)} discrete formal arguments in
4297 a generic unit that can be instantiated with either enumeration types
4298 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4299 type whose upper bound exceeds the upper bound of the largest signed
4300 integer type, and the argument is a variable, so that the universal
4301 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4302 may raise @code{Constraint_Error}.
4303
4304 @node Epsilon
4305 @unnumberedsec Epsilon
4306 @cindex Ada 83 attributes
4307 @findex Epsilon
4308 @noindent
4309 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4310 the Ada 83 reference manual for an exact description of the semantics of
4311 this attribute.
4312
4313 @node Fixed_Value
4314 @unnumberedsec Fixed_Value
4315 @findex Fixed_Value
4316 @noindent
4317 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4318 function with the following specification:
4319
4320 @smallexample @c ada
4321 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4322   return @var{S};
4323 @end smallexample
4324
4325 @noindent
4326 The value returned is the fixed-point value @var{V} such that
4327
4328 @smallexample @c ada
4329 @var{V} = Arg * @var{S}'Small
4330 @end smallexample
4331
4332 @noindent
4333 The effect is thus similar to first converting the argument to the
4334 integer type used to represent @var{S}, and then doing an unchecked
4335 conversion to the fixed-point type.  The difference is
4336 that there are full range checks, to ensure that the result is in range.
4337 This attribute is primarily intended for use in implementation of the
4338 input-output functions for fixed-point values.
4339
4340 @node Has_Access_Values
4341 @unnumberedsec Has_Access_Values
4342 @cindex Access values, testing for
4343 @findex Has_Access_Values
4344 @noindent
4345 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4346 is a Boolean value which is True if the is an access type, or is a composite
4347 type with a component (at any nesting depth) that is an access type, and is
4348 False otherwise.
4349 The intended use of this attribute is in conjunction with generic
4350 definitions.  If the attribute is applied to a generic private type, it
4351 indicates whether or not the corresponding actual type has access values.
4352
4353 @node Has_Discriminants
4354 @unnumberedsec Has_Discriminants
4355 @cindex Discriminants, testing for
4356 @findex Has_Discriminants
4357 @noindent
4358 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4359 is a Boolean value which is True if the type has discriminants, and False
4360 otherwise.  The intended use of this attribute is in conjunction with generic
4361 definitions.  If the attribute is applied to a generic private type, it
4362 indicates whether or not the corresponding actual type has discriminants.
4363
4364 @node Img
4365 @unnumberedsec Img
4366 @findex Img
4367 @noindent
4368 The @code{Img} attribute differs from @code{Image} in that it may be
4369 applied to objects as well as types, in which case it gives the
4370 @code{Image} for the subtype of the object.  This is convenient for
4371 debugging:
4372
4373 @smallexample @c ada
4374 Put_Line ("X = " & X'Img);
4375 @end smallexample
4376
4377 @noindent
4378 has the same meaning as the more verbose:
4379
4380 @smallexample @c ada
4381 Put_Line ("X = " & @var{T}'Image (X));
4382 @end smallexample
4383
4384 @noindent
4385 where @var{T} is the (sub)type of the object @code{X}.
4386
4387 @node Integer_Value
4388 @unnumberedsec Integer_Value
4389 @findex Integer_Value
4390 @noindent
4391 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4392 function with the following spec:
4393
4394 @smallexample @c ada
4395 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4396   return @var{S};
4397 @end smallexample
4398
4399 @noindent
4400 The value returned is the integer value @var{V}, such that
4401
4402 @smallexample @c ada
4403 Arg = @var{V} * @var{T}'Small
4404 @end smallexample
4405
4406 @noindent
4407 where @var{T} is the type of @code{Arg}.
4408 The effect is thus similar to first doing an unchecked conversion from
4409 the fixed-point type to its corresponding implementation type, and then
4410 converting the result to the target integer type.  The difference is
4411 that there are full range checks, to ensure that the result is in range.
4412 This attribute is primarily intended for use in implementation of the
4413 standard input-output functions for fixed-point values.
4414
4415 @node Large
4416 @unnumberedsec Large
4417 @cindex Ada 83 attributes
4418 @findex Large
4419 @noindent
4420 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4421 the Ada 83 reference manual for an exact description of the semantics of
4422 this attribute.
4423
4424 @node Machine_Size
4425 @unnumberedsec Machine_Size
4426 @findex Machine_Size
4427 @noindent
4428 This attribute is identical to the @code{Object_Size} attribute.  It is
4429 provided for compatibility with the DEC Ada 83 attribute of this name.
4430
4431 @node Mantissa
4432 @unnumberedsec Mantissa
4433 @cindex Ada 83 attributes
4434 @findex Mantissa
4435 @noindent
4436 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4437 the Ada 83 reference manual for an exact description of the semantics of
4438 this attribute.
4439
4440 @node Max_Interrupt_Priority
4441 @unnumberedsec Max_Interrupt_Priority
4442 @cindex Interrupt priority, maximum
4443 @findex Max_Interrupt_Priority
4444 @noindent
4445 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4446 permissible prefix), provides the same value as
4447 @code{System.Max_Interrupt_Priority}.
4448
4449 @node Max_Priority
4450 @unnumberedsec Max_Priority
4451 @cindex Priority, maximum
4452 @findex Max_Priority
4453 @noindent
4454 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4455 prefix) provides the same value as @code{System.Max_Priority}.
4456
4457 @node Maximum_Alignment
4458 @unnumberedsec Maximum_Alignment
4459 @cindex Alignment, maximum
4460 @findex Maximum_Alignment
4461 @noindent
4462 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4463 permissible prefix) provides the maximum useful alignment value for the
4464 target.  This is a static value that can be used to specify the alignment
4465 for an object, guaranteeing that it is properly aligned in all
4466 cases.
4467
4468 @node Mechanism_Code
4469 @unnumberedsec Mechanism_Code
4470 @cindex Return values, passing mechanism
4471 @cindex Parameters, passing mechanism
4472 @findex Mechanism_Code
4473 @noindent
4474 @code{@var{function}'Mechanism_Code} yields an integer code for the
4475 mechanism used for the result of function, and
4476 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4477 used for formal parameter number @var{n} (a static integer value with 1
4478 meaning the first parameter) of @var{subprogram}.  The code returned is:
4479
4480 @table @asis
4481 @item 1
4482 by copy (value)
4483 @item 2
4484 by reference
4485 @item 3
4486 by descriptor (default descriptor class)
4487 @item 4
4488 by descriptor (UBS: unaligned bit string)
4489 @item 5
4490 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4491 @item 6
4492 by descriptor (UBA: unaligned bit array)
4493 @item 7
4494 by descriptor (S: string, also scalar access type parameter)
4495 @item 8
4496 by descriptor (SB: string with arbitrary bounds)
4497 @item 9
4498 by descriptor (A: contiguous array)
4499 @item 10
4500 by descriptor (NCA: non-contiguous array)
4501 @end table
4502
4503 @noindent
4504 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4505 @cindex OpenVMS
4506
4507 @node Null_Parameter
4508 @unnumberedsec Null_Parameter
4509 @cindex Zero address, passing
4510 @findex Null_Parameter
4511 @noindent
4512 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4513 type or subtype @var{T} allocated at machine address zero.  The attribute
4514 is allowed only as the default expression of a formal parameter, or as
4515 an actual expression of a subprogram call.  In either case, the
4516 subprogram must be imported.
4517
4518 The identity of the object is represented by the address zero in the
4519 argument list, independent of the passing mechanism (explicit or
4520 default).
4521
4522 This capability is needed to specify that a zero address should be
4523 passed for a record or other composite object passed by reference.
4524 There is no way of indicating this without the @code{Null_Parameter}
4525 attribute.
4526
4527 @node Object_Size
4528 @unnumberedsec Object_Size
4529 @cindex Size, used for objects
4530 @findex Object_Size
4531 @noindent
4532 The size of an object is not necessarily the same as the size of the type
4533 of an object.  This is because by default object sizes are increased to be
4534 a multiple of the alignment of the object.  For example,
4535 @code{Natural'Size} is
4536 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4537 Similarly, a record containing an integer and a character:
4538
4539 @smallexample @c ada
4540 type Rec is record
4541    I : Integer;
4542    C : Character;
4543 end record;
4544 @end smallexample
4545
4546 @noindent
4547 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4548 alignment will be 4, because of the
4549 integer field, and so the default size of record objects for this type
4550 will be 64 (8 bytes).
4551
4552 The @code{@var{type}'Object_Size} attribute
4553 has been added to GNAT to allow the
4554 default object size of a type to be easily determined.  For example,
4555 @code{Natural'Object_Size} is 32, and
4556 @code{Rec'Object_Size} (for the record type in the above example) will be
4557 64.  Note also that, unlike the situation with the
4558 @code{Size} attribute as defined in the Ada RM, the
4559 @code{Object_Size} attribute can be specified individually
4560 for different subtypes.  For example:
4561
4562 @smallexample @c ada
4563 type R is new Integer;
4564 subtype R1 is R range 1 .. 10;
4565 subtype R2 is R range 1 .. 10;
4566 for R2'Object_Size use 8;
4567 @end smallexample
4568
4569 @noindent
4570 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4571 32 since the default object size for a subtype is the same as the object size
4572 for the parent subtype.  This means that objects of type @code{R}
4573 or @code{R1} will
4574 by default be 32 bits (four bytes).  But objects of type
4575 @code{R2} will be only
4576 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4577
4578 @node Passed_By_Reference
4579 @unnumberedsec Passed_By_Reference
4580 @cindex Parameters, when passed by reference
4581 @findex Passed_By_Reference
4582 @noindent
4583 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4584 a value of type @code{Boolean} value that is @code{True} if the type is
4585 normally passed by reference and @code{False} if the type is normally
4586 passed by copy in calls.  For scalar types, the result is always @code{False}
4587 and is static.  For non-scalar types, the result is non-static.
4588
4589 @node Range_Length
4590 @unnumberedsec Range_Length
4591 @findex Range_Length
4592 @noindent
4593 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4594 the number of values represented by the subtype (zero for a null
4595 range).  The result is static for static subtypes.  @code{Range_Length}
4596 applied to the index subtype of a one dimensional array always gives the
4597 same result as @code{Range} applied to the array itself.
4598
4599 @node Safe_Emax
4600 @unnumberedsec Safe_Emax
4601 @cindex Ada 83 attributes
4602 @findex Safe_Emax
4603 @noindent
4604 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4605 the Ada 83 reference manual for an exact description of the semantics of
4606 this attribute.
4607
4608 @node Safe_Large
4609 @unnumberedsec Safe_Large
4610 @cindex Ada 83 attributes
4611 @findex Safe_Large
4612 @noindent
4613 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4614 the Ada 83 reference manual for an exact description of the semantics of
4615 this attribute.
4616
4617 @node Small
4618 @unnumberedsec Small
4619 @cindex Ada 83 attributes
4620 @findex Small
4621 @noindent
4622 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4623 GNAT also allows this attribute to be applied to floating-point types
4624 for compatibility with Ada 83.  See
4625 the Ada 83 reference manual for an exact description of the semantics of
4626 this attribute when applied to floating-point types.
4627
4628 @node Storage_Unit
4629 @unnumberedsec Storage_Unit
4630 @findex Storage_Unit
4631 @noindent
4632 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4633 prefix) provides the same value as @code{System.Storage_Unit}.
4634
4635 @node Target_Name
4636 @unnumberedsec Target_Name
4637 @findex Target_Name
4638 @noindent
4639 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4640 prefix) provides a static string value that identifies the target
4641 for the current compilation. For GCC implementations, this is the
4642 standard gcc target name without the terminating slash (for
4643 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4644
4645 @node Tick
4646 @unnumberedsec Tick
4647 @findex Tick
4648 @noindent
4649 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4650 provides the same value as @code{System.Tick},
4651
4652 @node To_Address
4653 @unnumberedsec To_Address
4654 @findex To_Address
4655 @noindent
4656 The @code{System'To_Address}
4657 (@code{System} is the only permissible prefix)
4658 denotes a function identical to
4659 @code{System.Storage_Elements.To_Address} except that
4660 it is a static attribute.  This means that if its argument is
4661 a static expression, then the result of the attribute is a
4662 static expression.  The result is that such an expression can be
4663 used in contexts (e.g.@: preelaborable packages) which require a
4664 static expression and where the function call could not be used
4665 (since the function call is always non-static, even if its
4666 argument is static).
4667
4668 @node Type_Class
4669 @unnumberedsec Type_Class
4670 @findex Type_Class
4671 @noindent
4672 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4673 the value of the type class for the full type of @var{type}.  If
4674 @var{type} is a generic formal type, the value is the value for the
4675 corresponding actual subtype.  The value of this attribute is of type
4676 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4677
4678 @smallexample @c ada
4679   type Type_Class is
4680     (Type_Class_Enumeration,
4681      Type_Class_Integer,
4682      Type_Class_Fixed_Point,
4683      Type_Class_Floating_Point,
4684      Type_Class_Array,
4685      Type_Class_Record,
4686      Type_Class_Access,
4687      Type_Class_Task,
4688      Type_Class_Address);
4689 @end smallexample
4690
4691 @noindent
4692 Protected types yield the value @code{Type_Class_Task}, which thus
4693 applies to all concurrent types.  This attribute is designed to
4694 be compatible with the DEC Ada 83 attribute of the same name.
4695
4696 @node UET_Address
4697 @unnumberedsec UET_Address
4698 @findex UET_Address
4699 @noindent
4700 The @code{UET_Address} attribute can only be used for a prefix which
4701 denotes a library package.  It yields the address of the unit exception
4702 table when zero cost exception handling is used.  This attribute is
4703 intended only for use within the GNAT implementation.  See the unit
4704 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4705 for details on how this attribute is used in the implementation.
4706
4707 @node Unconstrained_Array
4708 @unnumberedsec Unconstrained_Array
4709 @findex Unconstrained_Array
4710 @noindent
4711 The @code{Unconstrained_Array} attribute can be used with a prefix that
4712 denotes any type or subtype. It is a static attribute that yields
4713 @code{True} if the prefix designates an unconstrained array,
4714 and @code{False} otherwise. In a generic instance, the result is
4715 still static, and yields the result of applying this test to the
4716 generic actual.
4717
4718 @node Universal_Literal_String
4719 @unnumberedsec Universal_Literal_String
4720 @cindex Named numbers, representation of
4721 @findex Universal_Literal_String
4722 @noindent
4723 The prefix of @code{Universal_Literal_String} must be a named
4724 number.  The static result is the string consisting of the characters of
4725 the number as defined in the original source.  This allows the user
4726 program to access the actual text of named numbers without intermediate
4727 conversions and without the need to enclose the strings in quotes (which
4728 would preclude their use as numbers).  This is used internally for the
4729 construction of values of the floating-point attributes from the file
4730 @file{ttypef.ads}, but may also be used by user programs.
4731
4732 @node Unrestricted_Access
4733 @unnumberedsec Unrestricted_Access
4734 @cindex @code{Access}, unrestricted
4735 @findex Unrestricted_Access
4736 @noindent
4737 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4738 except that all accessibility and aliased view checks are omitted.  This
4739 is a user-beware attribute.  It is similar to
4740 @code{Address}, for which it is a desirable replacement where the value
4741 desired is an access type.  In other words, its effect is identical to
4742 first applying the @code{Address} attribute and then doing an unchecked
4743 conversion to a desired access type.  In GNAT, but not necessarily in
4744 other implementations, the use of static chains for inner level
4745 subprograms means that @code{Unrestricted_Access} applied to a
4746 subprogram yields a value that can be called as long as the subprogram
4747 is in scope (normal Ada 95 accessibility rules restrict this usage).
4748
4749 It is possible to use @code{Unrestricted_Access} for any type, but care
4750 must be excercised if it is used to create pointers to unconstrained
4751 objects. In this case, the resulting pointer has the same scope as the
4752 context of the attribute, and may not be returned to some enclosing
4753 scope. For instance, a function cannot use @code{Unrestricted_Access}
4754 to create a unconstrained pointer and then return that value to the
4755 caller.
4756
4757 @node VADS_Size
4758 @unnumberedsec VADS_Size
4759 @cindex @code{Size}, VADS compatibility
4760 @findex VADS_Size
4761 @noindent
4762 The @code{'VADS_Size} attribute is intended to make it easier to port
4763 legacy code which relies on the semantics of @code{'Size} as implemented
4764 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4765 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4766 to a predefined or other primitive type with no Size clause yields the
4767 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4768 typical machines).  In addition @code{'VADS_Size} applied to an object
4769 gives the result that would be obtained by applying the attribute to
4770 the corresponding type.
4771
4772 @node Value_Size
4773 @unnumberedsec Value_Size
4774 @cindex @code{Size}, setting for not-first subtype
4775 @findex Value_Size
4776 @code{@var{type}'Value_Size} is the number of bits required to represent
4777 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4778 but, unlike @code{Size}, may be set for non-first subtypes.
4779
4780 @node Wchar_T_Size
4781 @unnumberedsec Wchar_T_Size
4782 @findex Wchar_T_Size
4783 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4784 prefix) provides the size in bits of the C @code{wchar_t} type
4785 primarily for constructing the definition of this type in
4786 package @code{Interfaces.C}.
4787
4788 @node Word_Size
4789 @unnumberedsec Word_Size
4790 @findex Word_Size
4791 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4792 prefix) provides the value @code{System.Word_Size}.
4793
4794 @c ------------------------
4795 @node Implementation Advice
4796 @chapter Implementation Advice
4797 @noindent
4798 The main text of the Ada 95 Reference Manual describes the required
4799 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4800 these requirements.
4801
4802 In addition, there are sections throughout the Ada 95
4803 reference manual headed
4804 by the phrase ``implementation advice''.  These sections are not normative,
4805 i.e.@: they do not specify requirements that all compilers must
4806 follow.  Rather they provide advice on generally desirable behavior.  You
4807 may wonder why they are not requirements.  The most typical answer is
4808 that they describe behavior that seems generally desirable, but cannot
4809 be provided on all systems, or which may be undesirable on some systems.
4810
4811 As far as practical, GNAT follows the implementation advice sections in
4812 the Ada 95 Reference Manual.  This chapter contains a table giving the
4813 reference manual section number, paragraph number and several keywords
4814 for each advice.  Each entry consists of the text of the advice followed
4815 by the GNAT interpretation of this advice.  Most often, this simply says
4816 ``followed'', which means that GNAT follows the advice.  However, in a
4817 number of cases, GNAT deliberately deviates from this advice, in which
4818 case the text describes what GNAT does and why.
4819
4820 @cindex Error detection
4821 @unnumberedsec 1.1.3(20): Error Detection
4822 @sp 1
4823 @cartouche
4824 If an implementation detects the use of an unsupported Specialized Needs
4825 Annex feature at run time, it should raise @code{Program_Error} if
4826 feasible.
4827 @end cartouche
4828 Not relevant.  All specialized needs annex features are either supported,
4829 or diagnosed at compile time.
4830
4831 @cindex Child Units
4832 @unnumberedsec 1.1.3(31): Child Units
4833 @sp 1
4834 @cartouche
4835 If an implementation wishes to provide implementation-defined
4836 extensions to the functionality of a language-defined library unit, it
4837 should normally do so by adding children to the library unit.
4838 @end cartouche
4839 Followed.
4840
4841 @cindex Bounded errors
4842 @unnumberedsec 1.1.5(12): Bounded Errors
4843 @sp 1
4844 @cartouche
4845 If an implementation detects a bounded error or erroneous
4846 execution, it should raise @code{Program_Error}.
4847 @end cartouche
4848 Followed in all cases in which the implementation detects a bounded
4849 error or erroneous execution.  Not all such situations are detected at
4850 runtime.
4851
4852 @cindex Pragmas
4853 @unnumberedsec 2.8(16): Pragmas
4854 @sp 1
4855 @cartouche
4856 Normally, implementation-defined pragmas should have no semantic effect
4857 for error-free programs; that is, if the implementation-defined pragmas
4858 are removed from a working program, the program should still be legal,
4859 and should still have the same semantics.
4860 @end cartouche
4861 The following implementation defined pragmas are exceptions to this
4862 rule:
4863
4864 @table @code
4865 @item Abort_Defer
4866 Affects semantics
4867 @item Ada_83
4868 Affects legality
4869 @item Assert
4870 Affects semantics
4871 @item CPP_Class
4872 Affects semantics
4873 @item CPP_Constructor
4874 Affects semantics
4875 @item CPP_Virtual
4876 Affects semantics
4877 @item CPP_Vtable
4878 Affects semantics
4879 @item Debug
4880 Affects semantics
4881 @item Interface_Name
4882 Affects semantics
4883 @item Machine_Attribute
4884 Affects semantics
4885 @item Unimplemented_Unit
4886 Affects legality
4887 @item Unchecked_Union
4888 Affects semantics
4889 @end table
4890
4891 @noindent
4892 In each of the above cases, it is essential to the purpose of the pragma
4893 that this advice not be followed.  For details see the separate section
4894 on implementation defined pragmas.
4895
4896 @unnumberedsec 2.8(17-19): Pragmas
4897 @sp 1
4898 @cartouche
4899 Normally, an implementation should not define pragmas that can
4900 make an illegal program legal, except as follows:
4901 @end cartouche
4902 @sp 1
4903 @cartouche
4904 A pragma used to complete a declaration, such as a pragma @code{Import};
4905 @end cartouche
4906 @sp 1
4907 @cartouche
4908 A pragma used to configure the environment by adding, removing, or
4909 replacing @code{library_items}.
4910 @end cartouche
4911 See response to paragraph 16 of this same section.
4912
4913 @cindex Character Sets
4914 @cindex Alternative Character Sets
4915 @unnumberedsec 3.5.2(5): Alternative Character Sets
4916 @sp 1
4917 @cartouche
4918 If an implementation supports a mode with alternative interpretations
4919 for @code{Character} and @code{Wide_Character}, the set of graphic
4920 characters of @code{Character} should nevertheless remain a proper
4921 subset of the set of graphic characters of @code{Wide_Character}.  Any
4922 character set ``localizations'' should be reflected in the results of
4923 the subprograms defined in the language-defined package
4924 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4925 an alternative interpretation of @code{Character}, the implementation should
4926 also support a corresponding change in what is a legal
4927 @code{identifier_letter}.
4928 @end cartouche
4929 Not all wide character modes follow this advice, in particular the JIS
4930 and IEC modes reflect standard usage in Japan, and in these encoding,
4931 the upper half of the Latin-1 set is not part of the wide-character
4932 subset, since the most significant bit is used for wide character
4933 encoding.  However, this only applies to the external forms.  Internally
4934 there is no such restriction.
4935
4936 @cindex Integer types
4937 @unnumberedsec 3.5.4(28): Integer Types
4938
4939 @sp 1
4940 @cartouche
4941 An implementation should support @code{Long_Integer} in addition to
4942 @code{Integer} if the target machine supports 32-bit (or longer)
4943 arithmetic.  No other named integer subtypes are recommended for package
4944 @code{Standard}.  Instead, appropriate named integer subtypes should be
4945 provided in the library package @code{Interfaces} (see B.2).
4946 @end cartouche
4947 @code{Long_Integer} is supported.  Other standard integer types are supported
4948 so this advice is not fully followed.  These types
4949 are supported for convenient interface to C, and so that all hardware
4950 types of the machine are easily available.
4951 @unnumberedsec 3.5.4(29): Integer Types
4952
4953 @sp 1
4954 @cartouche
4955 An implementation for a two's complement machine should support
4956 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4957 implementation should support a non-binary modules up to @code{Integer'Last}.
4958 @end cartouche
4959 Followed.
4960
4961 @cindex Enumeration values
4962 @unnumberedsec 3.5.5(8): Enumeration Values
4963 @sp 1
4964 @cartouche
4965 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4966 subtype, if the value of the operand does not correspond to the internal
4967 code for any enumeration literal of its type (perhaps due to an
4968 un-initialized variable), then the implementation should raise
4969 @code{Program_Error}.  This is particularly important for enumeration
4970 types with noncontiguous internal codes specified by an
4971 enumeration_representation_clause.
4972 @end cartouche
4973 Followed.
4974
4975 @cindex Float types
4976 @unnumberedsec 3.5.7(17): Float Types
4977 @sp 1
4978 @cartouche
4979 An implementation should support @code{Long_Float} in addition to
4980 @code{Float} if the target machine supports 11 or more digits of
4981 precision.  No other named floating point subtypes are recommended for
4982 package @code{Standard}.  Instead, appropriate named floating point subtypes
4983 should be provided in the library package @code{Interfaces} (see B.2).
4984 @end cartouche
4985 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4986 former provides improved compatibility with other implementations
4987 supporting this type.  The latter corresponds to the highest precision
4988 floating-point type supported by the hardware.  On most machines, this
4989 will be the same as @code{Long_Float}, but on some machines, it will
4990 correspond to the IEEE extended form.  The notable case is all ia32
4991 (x86) implementations, where @code{Long_Long_Float} corresponds to
4992 the 80-bit extended precision format supported in hardware on this
4993 processor.  Note that the 128-bit format on SPARC is not supported,
4994 since this is a software rather than a hardware format.
4995
4996 @cindex Multidimensional arrays
4997 @cindex Arrays, multidimensional
4998 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4999 @sp 1
5000 @cartouche
5001 An implementation should normally represent multidimensional arrays in
5002 row-major order, consistent with the notation used for multidimensional
5003 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5004 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5005 column-major order should be used instead (see B.5, ``Interfacing with
5006 Fortran'').
5007 @end cartouche
5008 Followed.
5009
5010 @findex Duration'Small
5011 @unnumberedsec 9.6(30-31): Duration'Small
5012 @sp 1
5013 @cartouche
5014 Whenever possible in an implementation, the value of @code{Duration'Small}
5015 should be no greater than 100 microseconds.
5016 @end cartouche
5017 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5018
5019 @sp 1
5020 @cartouche
5021 The time base for @code{delay_relative_statements} should be monotonic;
5022 it need not be the same time base as used for @code{Calendar.Clock}.
5023 @end cartouche
5024 Followed.
5025
5026 @unnumberedsec 10.2.1(12): Consistent Representation
5027 @sp 1
5028 @cartouche
5029 In an implementation, a type declared in a pre-elaborated package should
5030 have the same representation in every elaboration of a given version of
5031 the package, whether the elaborations occur in distinct executions of
5032 the same program, or in executions of distinct programs or partitions
5033 that include the given version.
5034 @end cartouche
5035 Followed, except in the case of tagged types.  Tagged types involve
5036 implicit pointers to a local copy of a dispatch table, and these pointers
5037 have representations which thus depend on a particular elaboration of the
5038 package.  It is not easy to see how it would be possible to follow this
5039 advice without severely impacting efficiency of execution.
5040
5041 @cindex Exception information
5042 @unnumberedsec 11.4.1(19): Exception Information
5043 @sp 1
5044 @cartouche
5045 @code{Exception_Message} by default and @code{Exception_Information}
5046 should produce information useful for
5047 debugging.  @code{Exception_Message} should be short, about one
5048 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5049 should not include the
5050 @code{Exception_Name}.  @code{Exception_Information} should include both
5051 the @code{Exception_Name} and the @code{Exception_Message}.
5052 @end cartouche
5053 Followed.  For each exception that doesn't have a specified
5054 @code{Exception_Message}, the compiler generates one containing the location
5055 of the raise statement.  This location has the form ``file:line'', where
5056 file is the short file name (without path information) and line is the line
5057 number in the file.  Note that in the case of the Zero Cost Exception
5058 mechanism, these messages become redundant with the Exception_Information that
5059 contains a full backtrace of the calling sequence, so they are disabled.
5060 To disable explicitly the generation of the source location message, use the
5061 Pragma @code{Discard_Names}.
5062
5063 @cindex Suppression of checks
5064 @cindex Checks, suppression of
5065 @unnumberedsec 11.5(28): Suppression of Checks
5066 @sp 1
5067 @cartouche
5068 The implementation should minimize the code executed for checks that
5069 have been suppressed.
5070 @end cartouche
5071 Followed.
5072
5073 @cindex Representation clauses
5074 @unnumberedsec 13.1 (21-24): Representation Clauses
5075 @sp 1
5076 @cartouche
5077 The recommended level of support for all representation items is
5078 qualified as follows:
5079 @end cartouche
5080 @sp 1
5081 @cartouche
5082 An implementation need not support representation items containing
5083 non-static expressions, except that an implementation should support a
5084 representation item for a given entity if each non-static expression in
5085 the representation item is a name that statically denotes a constant
5086 declared before the entity.
5087 @end cartouche
5088 Followed.  GNAT does not support non-static expressions in representation
5089 clauses unless they are constants declared before the entity.  For
5090 example:
5091
5092 @smallexample @c ada
5093 X : Some_Type;
5094 for X'Address use To_address (16#2000#);
5095 @end smallexample
5096
5097 @noindent
5098 will be rejected, since the To_Address expression is non-static.  Instead
5099 write:
5100
5101 @smallexample @c ada
5102 X_Address : constant Address : = To_Address (16#2000#);
5103 X         : Some_Type;
5104 for X'Address use X_Address;
5105 @end smallexample
5106
5107 @sp 1
5108 @cartouche
5109 An implementation need not support a specification for the @code{Size}
5110 for a given composite subtype, nor the size or storage place for an
5111 object (including a component) of a given composite subtype, unless the
5112 constraints on the subtype and its composite subcomponents (if any) are
5113 all static constraints.
5114 @end cartouche
5115 Followed.  Size Clauses are not permitted on non-static components, as
5116 described above.
5117
5118 @sp 1
5119 @cartouche
5120 An aliased component, or a component whose type is by-reference, should
5121 always be allocated at an addressable location.
5122 @end cartouche
5123 Followed.
5124
5125 @cindex Packed types
5126 @unnumberedsec 13.2(6-8): Packed Types
5127 @sp 1
5128 @cartouche
5129 If a type is packed, then the implementation should try to minimize
5130 storage allocated to objects of the type, possibly at the expense of
5131 speed of accessing components, subject to reasonable complexity in
5132 addressing calculations.
5133 @end cartouche
5134 @sp 1
5135 @cartouche
5136 The recommended level of support pragma @code{Pack} is:
5137
5138 For a packed record type, the components should be packed as tightly as
5139 possible subject to the Sizes of the component subtypes, and subject to
5140 any @code{record_representation_clause} that applies to the type; the
5141 implementation may, but need not, reorder components or cross aligned
5142 word boundaries to improve the packing.  A component whose @code{Size} is
5143 greater than the word size may be allocated an integral number of words.
5144 @end cartouche
5145 Followed.  Tight packing of arrays is supported for all component sizes
5146 up to 64-bits. If the array component size is 1 (that is to say, if
5147 the component is a boolean type or an enumeration type with two values)
5148 then values of the type are implicitly initialized to zero. This
5149 happens both for objects of the packed type, and for objects that have a
5150 subcomponent of the packed type.
5151
5152 @sp 1
5153 @cartouche
5154 An implementation should support Address clauses for imported
5155 subprograms.
5156 @end cartouche
5157 Followed.
5158 @cindex @code{Address} clauses
5159 @unnumberedsec 13.3(14-19): Address Clauses
5160
5161 @sp 1
5162 @cartouche
5163 For an array @var{X}, @code{@var{X}'Address} should point at the first
5164 component of the array, and not at the array bounds.
5165 @end cartouche
5166 Followed.
5167
5168 @sp 1
5169 @cartouche
5170 The recommended level of support for the @code{Address} attribute is:
5171
5172 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5173 object that is aliased or of a by-reference type, or is an entity whose
5174 @code{Address} has been specified.
5175 @end cartouche
5176 Followed.  A valid address will be produced even if none of those
5177 conditions have been met.  If necessary, the object is forced into
5178 memory to ensure the address is valid.
5179
5180 @sp 1
5181 @cartouche
5182 An implementation should support @code{Address} clauses for imported
5183 subprograms.
5184 @end cartouche
5185 Followed.
5186
5187 @sp 1
5188 @cartouche
5189 Objects (including subcomponents) that are aliased or of a by-reference
5190 type should be allocated on storage element boundaries.
5191 @end cartouche
5192 Followed.
5193
5194 @sp 1
5195 @cartouche
5196 If the @code{Address} of an object is specified, or it is imported or exported,
5197 then the implementation should not perform optimizations based on
5198 assumptions of no aliases.
5199 @end cartouche
5200 Followed.
5201
5202 @cindex @code{Alignment} clauses
5203 @unnumberedsec 13.3(29-35): Alignment Clauses
5204 @sp 1
5205 @cartouche
5206 The recommended level of support for the @code{Alignment} attribute for
5207 subtypes is:
5208
5209 An implementation should support specified Alignments that are factors
5210 and multiples of the number of storage elements per word, subject to the
5211 following:
5212 @end cartouche
5213 Followed.
5214
5215 @sp 1
5216 @cartouche
5217 An implementation need not support specified @code{Alignment}s for
5218 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5219 loaded and stored by available machine instructions.
5220 @end cartouche
5221 Followed.
5222
5223 @sp 1
5224 @cartouche
5225 An implementation need not support specified @code{Alignment}s that are
5226 greater than the maximum @code{Alignment} the implementation ever returns by
5227 default.
5228 @end cartouche
5229 Followed.
5230
5231 @sp 1
5232 @cartouche
5233 The recommended level of support for the @code{Alignment} attribute for
5234 objects is:
5235
5236 Same as above, for subtypes, but in addition:
5237 @end cartouche
5238 Followed.
5239
5240 @sp 1
5241 @cartouche
5242 For stand-alone library-level objects of statically constrained
5243 subtypes, the implementation should support all @code{Alignment}s
5244 supported by the target linker.  For example, page alignment is likely to
5245 be supported for such objects, but not for subtypes.
5246 @end cartouche
5247 Followed.
5248
5249 @cindex @code{Size} clauses
5250 @unnumberedsec 13.3(42-43): Size Clauses
5251 @sp 1
5252 @cartouche
5253 The recommended level of support for the @code{Size} attribute of
5254 objects is:
5255
5256 A @code{Size} clause should be supported for an object if the specified
5257 @code{Size} is at least as large as its subtype's @code{Size}, and
5258 corresponds to a size in storage elements that is a multiple of the
5259 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5260 @end cartouche
5261 Followed.
5262
5263 @unnumberedsec 13.3(50-56): Size Clauses
5264 @sp 1
5265 @cartouche
5266 If the @code{Size} of a subtype is specified, and allows for efficient
5267 independent addressability (see 9.10) on the target architecture, then
5268 the @code{Size} of the following objects of the subtype should equal the
5269 @code{Size} of the subtype:
5270
5271 Aliased objects (including components).
5272 @end cartouche
5273 Followed.
5274
5275 @sp 1
5276 @cartouche
5277 @code{Size} clause on a composite subtype should not affect the
5278 internal layout of components.
5279 @end cartouche
5280 Followed.
5281
5282 @sp 1
5283 @cartouche
5284 The recommended level of support for the @code{Size} attribute of subtypes is:
5285 @end cartouche
5286 @sp 1
5287 @cartouche
5288 The @code{Size} (if not specified) of a static discrete or fixed point
5289 subtype should be the number of bits needed to represent each value
5290 belonging to the subtype using an unbiased representation, leaving space
5291 for a sign bit only if the subtype contains negative values.  If such a
5292 subtype is a first subtype, then an implementation should support a
5293 specified @code{Size} for it that reflects this representation.
5294 @end cartouche
5295 Followed.
5296
5297 @sp 1
5298 @cartouche
5299 For a subtype implemented with levels of indirection, the @code{Size}
5300 should include the size of the pointers, but not the size of what they
5301 point at.
5302 @end cartouche
5303 Followed.
5304
5305 @cindex @code{Component_Size} clauses
5306 @unnumberedsec 13.3(71-73): Component Size Clauses
5307 @sp 1
5308 @cartouche
5309 The recommended level of support for the @code{Component_Size}
5310 attribute is:
5311 @end cartouche
5312 @sp 1
5313 @cartouche
5314 An implementation need not support specified @code{Component_Sizes} that are
5315 less than the @code{Size} of the component subtype.
5316 @end cartouche
5317 Followed.
5318
5319 @sp 1
5320 @cartouche
5321 An implementation should support specified @code{Component_Size}s that
5322 are factors and multiples of the word size.  For such
5323 @code{Component_Size}s, the array should contain no gaps between
5324 components.  For other @code{Component_Size}s (if supported), the array
5325 should contain no gaps between components when packing is also
5326 specified; the implementation should forbid this combination in cases
5327 where it cannot support a no-gaps representation.
5328 @end cartouche
5329 Followed.
5330
5331 @cindex Enumeration representation clauses
5332 @cindex Representation clauses, enumeration
5333 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5334 @sp 1
5335 @cartouche
5336 The recommended level of support for enumeration representation clauses
5337 is:
5338
5339 An implementation need not support enumeration representation clauses
5340 for boolean types, but should at minimum support the internal codes in
5341 the range @code{System.Min_Int.System.Max_Int}.
5342 @end cartouche
5343 Followed.
5344
5345 @cindex Record representation clauses
5346 @cindex Representation clauses, records
5347 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5348 @sp 1
5349 @cartouche
5350 The recommended level of support for
5351 @*@code{record_representation_clauses} is:
5352
5353 An implementation should support storage places that can be extracted
5354 with a load, mask, shift sequence of machine code, and set with a load,
5355 shift, mask, store sequence, given the available machine instructions
5356 and run-time model.
5357 @end cartouche
5358 Followed.
5359
5360 @sp 1
5361 @cartouche
5362 A storage place should be supported if its size is equal to the
5363 @code{Size} of the component subtype, and it starts and ends on a
5364 boundary that obeys the @code{Alignment} of the component subtype.
5365 @end cartouche
5366 Followed.
5367
5368 @sp 1
5369 @cartouche
5370 If the default bit ordering applies to the declaration of a given type,
5371 then for a component whose subtype's @code{Size} is less than the word
5372 size, any storage place that does not cross an aligned word boundary
5373 should be supported.
5374 @end cartouche
5375 Followed.
5376
5377 @sp 1
5378 @cartouche
5379 An implementation may reserve a storage place for the tag field of a
5380 tagged type, and disallow other components from overlapping that place.
5381 @end cartouche
5382 Followed.  The storage place for the tag field is the beginning of the tagged
5383 record, and its size is Address'Size.  GNAT will reject an explicit component
5384 clause for the tag field.
5385
5386 @sp 1
5387 @cartouche
5388 An implementation need not support a @code{component_clause} for a
5389 component of an extension part if the storage place is not after the
5390 storage places of all components of the parent type, whether or not
5391 those storage places had been specified.
5392 @end cartouche
5393 Followed.  The above advice on record representation clauses is followed,
5394 and all mentioned features are implemented.
5395
5396 @cindex Storage place attributes
5397 @unnumberedsec 13.5.2(5): Storage Place Attributes
5398 @sp 1
5399 @cartouche
5400 If a component is represented using some form of pointer (such as an
5401 offset) to the actual data of the component, and this data is contiguous
5402 with the rest of the object, then the storage place attributes should
5403 reflect the place of the actual data, not the pointer.  If a component is
5404 allocated discontinuously from the rest of the object, then a warning
5405 should be generated upon reference to one of its storage place
5406 attributes.
5407 @end cartouche
5408 Followed.  There are no such components in GNAT@.
5409
5410 @cindex Bit ordering
5411 @unnumberedsec 13.5.3(7-8): Bit Ordering
5412 @sp 1
5413 @cartouche
5414 The recommended level of support for the non-default bit ordering is:
5415 @end cartouche
5416 @sp 1
5417 @cartouche
5418 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5419 should support the non-default bit ordering in addition to the default
5420 bit ordering.
5421 @end cartouche
5422 Followed.  Word size does not equal storage size in this implementation.
5423 Thus non-default bit ordering is not supported.
5424
5425 @cindex @code{Address}, as private type
5426 @unnumberedsec 13.7(37): Address as Private
5427 @sp 1
5428 @cartouche
5429 @code{Address} should be of a private type.
5430 @end cartouche
5431 Followed.
5432
5433 @cindex Operations, on @code{Address}
5434 @cindex @code{Address}, operations of
5435 @unnumberedsec 13.7.1(16): Address Operations
5436 @sp 1
5437 @cartouche
5438 Operations in @code{System} and its children should reflect the target
5439 environment semantics as closely as is reasonable.  For example, on most
5440 machines, it makes sense for address arithmetic to ``wrap around''.
5441 Operations that do not make sense should raise @code{Program_Error}.
5442 @end cartouche
5443 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5444 operation raises @code{Program_Error}, since all operations make sense.
5445
5446 @cindex Unchecked conversion
5447 @unnumberedsec 13.9(14-17): Unchecked Conversion
5448 @sp 1
5449 @cartouche
5450 The @code{Size} of an array object should not include its bounds; hence,
5451 the bounds should not be part of the converted data.
5452 @end cartouche
5453 Followed.
5454
5455 @sp 1
5456 @cartouche
5457 The implementation should not generate unnecessary run-time checks to
5458 ensure that the representation of @var{S} is a representation of the
5459 target type.  It should take advantage of the permission to return by
5460 reference when possible.  Restrictions on unchecked conversions should be
5461 avoided unless required by the target environment.
5462 @end cartouche
5463 Followed.  There are no restrictions on unchecked conversion.  A warning is
5464 generated if the source and target types do not have the same size since
5465 the semantics in this case may be target dependent.
5466
5467 @sp 1
5468 @cartouche
5469 The recommended level of support for unchecked conversions is:
5470 @end cartouche
5471 @sp 1
5472 @cartouche
5473 Unchecked conversions should be supported and should be reversible in
5474 the cases where this clause defines the result.  To enable meaningful use
5475 of unchecked conversion, a contiguous representation should be used for
5476 elementary subtypes, for statically constrained array subtypes whose
5477 component subtype is one of the subtypes described in this paragraph,
5478 and for record subtypes without discriminants whose component subtypes
5479 are described in this paragraph.
5480 @end cartouche
5481 Followed.
5482
5483 @cindex Heap usage, implicit
5484 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5485 @sp 1
5486 @cartouche
5487 An implementation should document any cases in which it dynamically
5488 allocates heap storage for a purpose other than the evaluation of an
5489 allocator.
5490 @end cartouche
5491 Followed, the only other points at which heap storage is dynamically
5492 allocated are as follows:
5493
5494 @itemize @bullet
5495 @item
5496 At initial elaboration time, to allocate dynamically sized global
5497 objects.
5498
5499 @item
5500 To allocate space for a task when a task is created.
5501
5502 @item
5503 To extend the secondary stack dynamically when needed.  The secondary
5504 stack is used for returning variable length results.
5505 @end itemize
5506
5507 @sp 1
5508 @cartouche
5509 A default (implementation-provided) storage pool for an
5510 access-to-constant type should not have overhead to support deallocation of
5511 individual objects.
5512 @end cartouche
5513 Followed.
5514
5515 @sp 1
5516 @cartouche
5517 A storage pool for an anonymous access type should be created at the
5518 point of an allocator for the type, and be reclaimed when the designated
5519 object becomes inaccessible.
5520 @end cartouche
5521 Followed.
5522
5523 @cindex Unchecked deallocation
5524 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5525 @sp 1
5526 @cartouche
5527 For a standard storage pool, @code{Free} should actually reclaim the
5528 storage.
5529 @end cartouche
5530 Followed.
5531
5532 @cindex Stream oriented attributes
5533 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5534 @sp 1
5535 @cartouche
5536 If a stream element is the same size as a storage element, then the
5537 normal in-memory representation should be used by @code{Read} and
5538 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5539 should use the smallest number of stream elements needed to represent
5540 all values in the base range of the scalar type.
5541 @end cartouche
5542
5543 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5544 which specifies using the size of the first subtype.
5545 However, such an implementation is based on direct binary
5546 representations and is therefore target- and endianness-dependent.
5547 To address this issue, GNAT also supplies an alternate implementation
5548 of the stream attributes @code{Read} and @code{Write},
5549 which uses the target-independent XDR standard representation
5550 for scalar types.
5551 @cindex XDR representation
5552 @cindex @code{Read} attribute
5553 @cindex @code{Write} attribute
5554 @cindex Stream oriented attributes
5555 The XDR implementation is provided as an alternative body of the
5556 @code{System.Stream_Attributes} package, in the file
5557 @file{s-strxdr.adb} in the GNAT library.
5558 There is no @file{s-strxdr.ads} file.
5559 In order to install the XDR implementation, do the following:
5560 @enumerate
5561 @item Replace the default implementation of the
5562 @code{System.Stream_Attributes} package with the XDR implementation.
5563 For example on a Unix platform issue the commands:
5564 @smallexample
5565 $ mv s-stratt.adb s-strold.adb
5566 $ mv s-strxdr.adb s-stratt.adb
5567 @end smallexample
5568
5569 @item
5570 Rebuild the GNAT run-time library as documented in the
5571 @cite{GNAT User's Guide}
5572 @end enumerate
5573
5574 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5575 @sp 1
5576 @cartouche
5577 If an implementation provides additional named predefined integer types,
5578 then the names should end with @samp{Integer} as in
5579 @samp{Long_Integer}.  If an implementation provides additional named
5580 predefined floating point types, then the names should end with
5581 @samp{Float} as in @samp{Long_Float}.
5582 @end cartouche
5583 Followed.
5584
5585 @findex Ada.Characters.Handling
5586 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5587 @sp 1
5588 @cartouche
5589 If an implementation provides a localized definition of @code{Character}
5590 or @code{Wide_Character}, then the effects of the subprograms in
5591 @code{Characters.Handling} should reflect the localizations.  See also
5592 3.5.2.
5593 @end cartouche
5594 Followed.  GNAT provides no such localized definitions.
5595
5596 @cindex Bounded-length strings
5597 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5598 @sp 1
5599 @cartouche
5600 Bounded string objects should not be implemented by implicit pointers
5601 and dynamic allocation.
5602 @end cartouche
5603 Followed.  No implicit pointers or dynamic allocation are used.
5604
5605 @cindex Random number generation
5606 @unnumberedsec A.5.2(46-47): Random Number Generation
5607 @sp 1
5608 @cartouche
5609 Any storage associated with an object of type @code{Generator} should be
5610 reclaimed on exit from the scope of the object.
5611 @end cartouche
5612 Followed.
5613
5614 @sp 1
5615 @cartouche
5616 If the generator period is sufficiently long in relation to the number
5617 of distinct initiator values, then each possible value of
5618 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5619 random numbers that does not, in a practical sense, overlap the sequence
5620 initiated by any other value.  If this is not possible, then the mapping
5621 between initiator values and generator states should be a rapidly
5622 varying function of the initiator value.
5623 @end cartouche
5624 Followed.  The generator period is sufficiently long for the first
5625 condition here to hold true.
5626
5627 @findex Get_Immediate
5628 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5629 @sp 1
5630 @cartouche
5631 The @code{Get_Immediate} procedures should be implemented with
5632 unbuffered input.  For a device such as a keyboard, input should be
5633 @dfn{available} if a key has already been typed, whereas for a disk
5634 file, input should always be available except at end of file.  For a file
5635 associated with a keyboard-like device, any line-editing features of the
5636 underlying operating system should be disabled during the execution of
5637 @code{Get_Immediate}.
5638 @end cartouche
5639 Followed on all targets except VxWorks. For VxWorks, there is no way to
5640 provide this functionality that does not result in the input buffer being
5641 flushed before the @code{Get_Immediate} call. A special unit
5642 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5643 this functionality.
5644
5645 @findex Export
5646 @unnumberedsec B.1(39-41): Pragma @code{Export}
5647 @sp 1
5648 @cartouche
5649 If an implementation supports pragma @code{Export} to a given language,
5650 then it should also allow the main subprogram to be written in that
5651 language.  It should support some mechanism for invoking the elaboration
5652 of the Ada library units included in the system, and for invoking the
5653 finalization of the environment task.  On typical systems, the
5654 recommended mechanism is to provide two subprograms whose link names are
5655 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5656 elaboration code for library units.  @code{adafinal} should contain the
5657 finalization code.  These subprograms should have no effect the second
5658 and subsequent time they are called.
5659 @end cartouche
5660 Followed.
5661
5662 @sp 1
5663 @cartouche
5664 Automatic elaboration of pre-elaborated packages should be
5665 provided when pragma @code{Export} is supported.
5666 @end cartouche
5667 Followed when the main program is in Ada.  If the main program is in a
5668 foreign language, then
5669 @code{adainit} must be called to elaborate pre-elaborated
5670 packages.
5671
5672 @sp 1
5673 @cartouche
5674 For each supported convention @var{L} other than @code{Intrinsic}, an
5675 implementation should support @code{Import} and @code{Export} pragmas
5676 for objects of @var{L}-compatible types and for subprograms, and pragma
5677 @code{Convention} for @var{L}-eligible types and for subprograms,
5678 presuming the other language has corresponding features.  Pragma
5679 @code{Convention} need not be supported for scalar types.
5680 @end cartouche
5681 Followed.
5682
5683 @cindex Package @code{Interfaces}
5684 @findex Interfaces
5685 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5686 @sp 1
5687 @cartouche
5688 For each implementation-defined convention identifier, there should be a
5689 child package of package Interfaces with the corresponding name.  This
5690 package should contain any declarations that would be useful for
5691 interfacing to the language (implementation) represented by the
5692 convention.  Any declarations useful for interfacing to any language on
5693 the given hardware architecture should be provided directly in
5694 @code{Interfaces}.
5695 @end cartouche
5696 Followed.  An additional package not defined
5697 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5698 for interfacing to C++.
5699
5700 @sp 1
5701 @cartouche
5702 An implementation supporting an interface to C, COBOL, or Fortran should
5703 provide the corresponding package or packages described in the following
5704 clauses.
5705 @end cartouche
5706 Followed.  GNAT provides all the packages described in this section.
5707
5708 @cindex C, interfacing with
5709 @unnumberedsec B.3(63-71): Interfacing with C
5710 @sp 1
5711 @cartouche
5712 An implementation should support the following interface correspondences
5713 between Ada and C@.
5714 @end cartouche
5715 Followed.
5716
5717 @sp 1
5718 @cartouche
5719 An Ada procedure corresponds to a void-returning C function.
5720 @end cartouche
5721 Followed.
5722
5723 @sp 1
5724 @cartouche
5725 An Ada function corresponds to a non-void C function.
5726 @end cartouche
5727 Followed.
5728
5729 @sp 1
5730 @cartouche
5731 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5732 function.
5733 @end cartouche
5734 Followed.
5735
5736 @sp 1
5737 @cartouche
5738 An Ada @code{in} parameter of an access-to-object type with designated
5739 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5740 where @var{t} is the C type corresponding to the Ada type @var{T}.
5741 @end cartouche
5742 Followed.
5743
5744 @sp 1
5745 @cartouche
5746 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5747 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5748 argument to a C function, where @var{t} is the C type corresponding to
5749 the Ada type @var{T}.  In the case of an elementary @code{out} or
5750 @code{in out} parameter, a pointer to a temporary copy is used to
5751 preserve by-copy semantics.
5752 @end cartouche
5753 Followed.
5754
5755 @sp 1
5756 @cartouche
5757 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5758 @code{@var{t}*} argument to a C function, where @var{t} is the C
5759 structure corresponding to the Ada type @var{T}.
5760 @end cartouche
5761 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5762 pragma, or Convention, or by explicitly specifying the mechanism for a given
5763 call using an extended import or export pragma.
5764
5765 @sp 1
5766 @cartouche
5767 An Ada parameter of an array type with component type @var{T}, of any
5768 mode, is passed as a @code{@var{t}*} argument to a C function, where
5769 @var{t} is the C type corresponding to the Ada type @var{T}.
5770 @end cartouche
5771 Followed.
5772
5773 @sp 1
5774 @cartouche
5775 An Ada parameter of an access-to-subprogram type is passed as a pointer
5776 to a C function whose prototype corresponds to the designated
5777 subprogram's specification.
5778 @end cartouche
5779 Followed.
5780
5781 @cindex COBOL, interfacing with
5782 @unnumberedsec B.4(95-98): Interfacing with COBOL
5783 @sp 1
5784 @cartouche
5785 An Ada implementation should support the following interface
5786 correspondences between Ada and COBOL@.
5787 @end cartouche
5788 Followed.
5789
5790 @sp 1
5791 @cartouche
5792 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5793 the COBOL type corresponding to @var{T}.
5794 @end cartouche
5795 Followed.
5796
5797 @sp 1
5798 @cartouche
5799 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5800 the corresponding COBOL type.
5801 @end cartouche
5802 Followed.
5803
5804 @sp 1
5805 @cartouche
5806 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5807 COBOL type corresponding to the Ada parameter type; for scalars, a local
5808 copy is used if necessary to ensure by-copy semantics.
5809 @end cartouche
5810 Followed.
5811
5812 @cindex Fortran, interfacing with
5813 @unnumberedsec B.5(22-26): Interfacing with Fortran
5814 @sp 1
5815 @cartouche
5816 An Ada implementation should support the following interface
5817 correspondences between Ada and Fortran:
5818 @end cartouche
5819 Followed.
5820
5821 @sp 1
5822 @cartouche
5823 An Ada procedure corresponds to a Fortran subroutine.
5824 @end cartouche
5825 Followed.
5826
5827 @sp 1
5828 @cartouche
5829 An Ada function corresponds to a Fortran function.
5830 @end cartouche
5831 Followed.
5832
5833 @sp 1
5834 @cartouche
5835 An Ada parameter of an elementary, array, or record type @var{T} is
5836 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5837 the Fortran type corresponding to the Ada type @var{T}, and where the
5838 INTENT attribute of the corresponding dummy argument matches the Ada
5839 formal parameter mode; the Fortran implementation's parameter passing
5840 conventions are used.  For elementary types, a local copy is used if
5841 necessary to ensure by-copy semantics.
5842 @end cartouche
5843 Followed.
5844
5845 @sp 1
5846 @cartouche
5847 An Ada parameter of an access-to-subprogram type is passed as a
5848 reference to a Fortran procedure whose interface corresponds to the
5849 designated subprogram's specification.
5850 @end cartouche
5851 Followed.
5852
5853 @cindex Machine operations
5854 @unnumberedsec C.1(3-5): Access to Machine Operations
5855 @sp 1
5856 @cartouche
5857 The machine code or intrinsic support should allow access to all
5858 operations normally available to assembly language programmers for the
5859 target environment, including privileged instructions, if any.
5860 @end cartouche
5861 Followed.
5862
5863 @sp 1
5864 @cartouche
5865 The interfacing pragmas (see Annex B) should support interface to
5866 assembler; the default assembler should be associated with the
5867 convention identifier @code{Assembler}.
5868 @end cartouche
5869 Followed.
5870
5871 @sp 1
5872 @cartouche
5873 If an entity is exported to assembly language, then the implementation
5874 should allocate it at an addressable location, and should ensure that it
5875 is retained by the linking process, even if not otherwise referenced
5876 from the Ada code.  The implementation should assume that any call to a
5877 machine code or assembler subprogram is allowed to read or update every
5878 object that is specified as exported.
5879 @end cartouche
5880 Followed.
5881
5882 @unnumberedsec C.1(10-16): Access to Machine Operations
5883 @sp 1
5884 @cartouche
5885 The implementation should ensure that little or no overhead is
5886 associated with calling intrinsic and machine-code subprograms.
5887 @end cartouche
5888 Followed for both intrinsics and machine-code subprograms.
5889
5890 @sp 1
5891 @cartouche
5892 It is recommended that intrinsic subprograms be provided for convenient
5893 access to any machine operations that provide special capabilities or
5894 efficiency and that are not otherwise available through the language
5895 constructs.
5896 @end cartouche
5897 Followed.  A full set of machine operation intrinsic subprograms is provided.
5898
5899 @sp 1
5900 @cartouche
5901 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5902 swap, decrement and test, enqueue/dequeue.
5903 @end cartouche
5904 Followed on any target supporting such operations.
5905
5906 @sp 1
5907 @cartouche
5908 Standard numeric functions---e.g.@:, sin, log.
5909 @end cartouche
5910 Followed on any target supporting such operations.
5911
5912 @sp 1
5913 @cartouche
5914 String manipulation operations---e.g.@:, translate and test.
5915 @end cartouche
5916 Followed on any target supporting such operations.
5917
5918 @sp 1
5919 @cartouche
5920 Vector operations---e.g.@:, compare vector against thresholds.
5921 @end cartouche
5922 Followed on any target supporting such operations.
5923
5924 @sp 1
5925 @cartouche
5926 Direct operations on I/O ports.
5927 @end cartouche
5928 Followed on any target supporting such operations.
5929
5930 @cindex Interrupt support
5931 @unnumberedsec C.3(28): Interrupt Support
5932 @sp 1
5933 @cartouche
5934 If the @code{Ceiling_Locking} policy is not in effect, the
5935 implementation should provide means for the application to specify which
5936 interrupts are to be blocked during protected actions, if the underlying
5937 system allows for a finer-grain control of interrupt blocking.
5938 @end cartouche
5939 Followed.  The underlying system does not allow for finer-grain control
5940 of interrupt blocking.
5941
5942 @cindex Protected procedure handlers
5943 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5944 @sp 1
5945 @cartouche
5946 Whenever possible, the implementation should allow interrupt handlers to
5947 be called directly by the hardware.
5948 @end cartouche
5949 @c SGI info:
5950 @ignore
5951 This is never possible under IRIX, so this is followed by default.
5952 @end ignore
5953 Followed on any target where the underlying operating system permits
5954 such direct calls.
5955
5956 @sp 1
5957 @cartouche
5958 Whenever practical, violations of any
5959 implementation-defined restrictions should be detected before run time.
5960 @end cartouche
5961 Followed.  Compile time warnings are given when possible.
5962
5963 @cindex Package @code{Interrupts}
5964 @findex Interrupts
5965 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5966
5967 @sp 1
5968 @cartouche
5969 If implementation-defined forms of interrupt handler procedures are
5970 supported, such as protected procedures with parameters, then for each
5971 such form of a handler, a type analogous to @code{Parameterless_Handler}
5972 should be specified in a child package of @code{Interrupts}, with the
5973 same operations as in the predefined package Interrupts.
5974 @end cartouche
5975 Followed.
5976
5977 @cindex Pre-elaboration requirements
5978 @unnumberedsec C.4(14): Pre-elaboration Requirements
5979 @sp 1
5980 @cartouche
5981 It is recommended that pre-elaborated packages be implemented in such a
5982 way that there should be little or no code executed at run time for the
5983 elaboration of entities not already covered by the Implementation
5984 Requirements.
5985 @end cartouche
5986 Followed.  Executable code is generated in some cases, e.g.@: loops
5987 to initialize large arrays.
5988
5989 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5990
5991 @sp 1
5992 @cartouche
5993 If the pragma applies to an entity, then the implementation should
5994 reduce the amount of storage used for storing names associated with that
5995 entity.
5996 @end cartouche
5997 Followed.
5998
5999 @cindex Package @code{Task_Attributes}
6000 @findex Task_Attributes
6001 @unnumberedsec C.7.2(30): The Package Task_Attributes
6002 @sp 1
6003 @cartouche
6004 Some implementations are targeted to domains in which memory use at run
6005 time must be completely deterministic.  For such implementations, it is
6006 recommended that the storage for task attributes will be pre-allocated
6007 statically and not from the heap.  This can be accomplished by either
6008 placing restrictions on the number and the size of the task's
6009 attributes, or by using the pre-allocated storage for the first @var{N}
6010 attribute objects, and the heap for the others.  In the latter case,
6011 @var{N} should be documented.
6012 @end cartouche
6013 Not followed.  This implementation is not targeted to such a domain.
6014
6015 @cindex Locking Policies
6016 @unnumberedsec D.3(17): Locking Policies
6017
6018 @sp 1
6019 @cartouche
6020 The implementation should use names that end with @samp{_Locking} for
6021 locking policies defined by the implementation.
6022 @end cartouche
6023 Followed.  A single implementation-defined locking policy is defined,
6024 whose name (@code{Inheritance_Locking}) follows this suggestion.
6025
6026 @cindex Entry queuing policies
6027 @unnumberedsec D.4(16): Entry Queuing Policies
6028 @sp 1
6029 @cartouche
6030 Names that end with @samp{_Queuing} should be used
6031 for all implementation-defined queuing policies.
6032 @end cartouche
6033 Followed.  No such implementation-defined queuing policies exist.
6034
6035 @cindex Preemptive abort
6036 @unnumberedsec D.6(9-10): Preemptive Abort
6037 @sp 1
6038 @cartouche
6039 Even though the @code{abort_statement} is included in the list of
6040 potentially blocking operations (see 9.5.1), it is recommended that this
6041 statement be implemented in a way that never requires the task executing
6042 the @code{abort_statement} to block.
6043 @end cartouche
6044 Followed.
6045
6046 @sp 1
6047 @cartouche
6048 On a multi-processor, the delay associated with aborting a task on
6049 another processor should be bounded; the implementation should use
6050 periodic polling, if necessary, to achieve this.
6051 @end cartouche
6052 Followed.
6053
6054 @cindex Tasking restrictions
6055 @unnumberedsec D.7(21): Tasking Restrictions
6056 @sp 1
6057 @cartouche
6058 When feasible, the implementation should take advantage of the specified
6059 restrictions to produce a more efficient implementation.
6060 @end cartouche
6061 GNAT currently takes advantage of these restrictions by providing an optimized
6062 run time when the Ravenscar profile and the GNAT restricted run time set
6063 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6064 pragma @code{Profile (Restricted)} for more details.
6065
6066 @cindex Time, monotonic
6067 @unnumberedsec D.8(47-49): Monotonic Time
6068 @sp 1
6069 @cartouche
6070 When appropriate, implementations should provide configuration
6071 mechanisms to change the value of @code{Tick}.
6072 @end cartouche
6073 Such configuration mechanisms are not appropriate to this implementation
6074 and are thus not supported.
6075
6076 @sp 1
6077 @cartouche
6078 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6079 be implemented as transformations of the same time base.
6080 @end cartouche
6081 Followed.
6082
6083 @sp 1
6084 @cartouche
6085 It is recommended that the @dfn{best} time base which exists in
6086 the underlying system be available to the application through
6087 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6088 @end cartouche
6089 Followed.
6090
6091 @cindex Partition communication subsystem
6092 @cindex PCS
6093 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6094 @sp 1
6095 @cartouche
6096 Whenever possible, the PCS on the called partition should allow for
6097 multiple tasks to call the RPC-receiver with different messages and
6098 should allow them to block until the corresponding subprogram body
6099 returns.
6100 @end cartouche
6101 Followed by GLADE, a separately supplied PCS that can be used with
6102 GNAT.
6103
6104 @sp 1
6105 @cartouche
6106 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6107 should raise @code{Storage_Error} if it runs out of space trying to
6108 write the @code{Item} into the stream.
6109 @end cartouche
6110 Followed by GLADE, a separately supplied PCS that can be used with
6111 GNAT@.
6112
6113 @cindex COBOL support
6114 @unnumberedsec F(7): COBOL Support
6115 @sp 1
6116 @cartouche
6117 If COBOL (respectively, C) is widely supported in the target
6118 environment, implementations supporting the Information Systems Annex
6119 should provide the child package @code{Interfaces.COBOL} (respectively,
6120 @code{Interfaces.C}) specified in Annex B and should support a
6121 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6122 pragmas (see Annex B), thus allowing Ada programs to interface with
6123 programs written in that language.
6124 @end cartouche
6125 Followed.
6126
6127 @cindex Decimal radix support
6128 @unnumberedsec F.1(2): Decimal Radix Support
6129 @sp 1
6130 @cartouche
6131 Packed decimal should be used as the internal representation for objects
6132 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6133 @end cartouche
6134 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6135 representations.
6136
6137 @cindex Numerics
6138 @unnumberedsec G: Numerics
6139 @sp 2
6140 @cartouche
6141 If Fortran (respectively, C) is widely supported in the target
6142 environment, implementations supporting the Numerics Annex
6143 should provide the child package @code{Interfaces.Fortran} (respectively,
6144 @code{Interfaces.C}) specified in Annex B and should support a
6145 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6146 pragmas (see Annex B), thus allowing Ada programs to interface with
6147 programs written in that language.
6148 @end cartouche
6149 Followed.
6150
6151 @cindex Complex types
6152 @unnumberedsec G.1.1(56-58): Complex Types
6153 @sp 2
6154 @cartouche
6155 Because the usual mathematical meaning of multiplication of a complex
6156 operand and a real operand is that of the scaling of both components of
6157 the former by the latter, an implementation should not perform this
6158 operation by first promoting the real operand to complex type and then
6159 performing a full complex multiplication.  In systems that, in the
6160 future, support an Ada binding to IEC 559:1989, the latter technique
6161 will not generate the required result when one of the components of the
6162 complex operand is infinite.  (Explicit multiplication of the infinite
6163 component by the zero component obtained during promotion yields a NaN
6164 that propagates into the final result.) Analogous advice applies in the
6165 case of multiplication of a complex operand and a pure-imaginary
6166 operand, and in the case of division of a complex operand by a real or
6167 pure-imaginary operand.
6168 @end cartouche
6169 Not followed.
6170
6171 @sp 1
6172 @cartouche
6173 Similarly, because the usual mathematical meaning of addition of a
6174 complex operand and a real operand is that the imaginary operand remains
6175 unchanged, an implementation should not perform this operation by first
6176 promoting the real operand to complex type and then performing a full
6177 complex addition.  In implementations in which the @code{Signed_Zeros}
6178 attribute of the component type is @code{True} (and which therefore
6179 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6180 predefined arithmetic operations), the latter technique will not
6181 generate the required result when the imaginary component of the complex
6182 operand is a negatively signed zero.  (Explicit addition of the negative
6183 zero to the zero obtained during promotion yields a positive zero.)
6184 Analogous advice applies in the case of addition of a complex operand
6185 and a pure-imaginary operand, and in the case of subtraction of a
6186 complex operand and a real or pure-imaginary operand.
6187 @end cartouche
6188 Not followed.
6189
6190 @sp 1
6191 @cartouche
6192 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6193 attempt to provide a rational treatment of the signs of zero results and
6194 result components.  As one example, the result of the @code{Argument}
6195 function should have the sign of the imaginary component of the
6196 parameter @code{X} when the point represented by that parameter lies on
6197 the positive real axis; as another, the sign of the imaginary component
6198 of the @code{Compose_From_Polar} function should be the same as
6199 (respectively, the opposite of) that of the @code{Argument} parameter when that
6200 parameter has a value of zero and the @code{Modulus} parameter has a
6201 nonnegative (respectively, negative) value.
6202 @end cartouche
6203 Followed.
6204
6205 @cindex Complex elementary functions
6206 @unnumberedsec G.1.2(49): Complex Elementary Functions
6207 @sp 1
6208 @cartouche
6209 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6210 @code{True} should attempt to provide a rational treatment of the signs
6211 of zero results and result components.  For example, many of the complex
6212 elementary functions have components that are odd functions of one of
6213 the parameter components; in these cases, the result component should
6214 have the sign of the parameter component at the origin.  Other complex
6215 elementary functions have zero components whose sign is opposite that of
6216 a parameter component at the origin, or is always positive or always
6217 negative.
6218 @end cartouche
6219 Followed.
6220
6221 @cindex Accuracy requirements
6222 @unnumberedsec G.2.4(19): Accuracy Requirements
6223 @sp 1
6224 @cartouche
6225 The versions of the forward trigonometric functions without a
6226 @code{Cycle} parameter should not be implemented by calling the
6227 corresponding version with a @code{Cycle} parameter of
6228 @code{2.0*Numerics.Pi}, since this will not provide the required
6229 accuracy in some portions of the domain.  For the same reason, the
6230 version of @code{Log} without a @code{Base} parameter should not be
6231 implemented by calling the corresponding version with a @code{Base}
6232 parameter of @code{Numerics.e}.
6233 @end cartouche
6234 Followed.
6235
6236 @cindex Complex arithmetic accuracy
6237 @cindex Accuracy, complex arithmetic
6238 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6239
6240 @sp 1
6241 @cartouche
6242 The version of the @code{Compose_From_Polar} function without a
6243 @code{Cycle} parameter should not be implemented by calling the
6244 corresponding version with a @code{Cycle} parameter of
6245 @code{2.0*Numerics.Pi}, since this will not provide the required
6246 accuracy in some portions of the domain.
6247 @end cartouche
6248 Followed.
6249
6250 @c -----------------------------------------
6251 @node Implementation Defined Characteristics
6252 @chapter Implementation Defined Characteristics
6253
6254 @noindent
6255 In addition to the implementation dependent pragmas and attributes, and
6256 the implementation advice, there are a number of other features of Ada
6257 95 that are potentially implementation dependent.  These are mentioned
6258 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6259
6260 A requirement for conforming Ada compilers is that they provide
6261 documentation describing how the implementation deals with each of these
6262 issues.  In this chapter, you will find each point in annex M listed
6263 followed by a description in italic font of how GNAT
6264 @c SGI info:
6265 @ignore
6266 in the ProDev Ada
6267 implementation on IRIX 5.3 operating system or greater
6268 @end ignore
6269 handles the implementation dependence.
6270
6271 You can use this chapter as a guide to minimizing implementation
6272 dependent features in your programs if portability to other compilers
6273 and other operating systems is an important consideration.  The numbers
6274 in each section below correspond to the paragraph number in the Ada 95
6275 Reference Manual.
6276
6277 @sp 1
6278 @cartouche
6279 @noindent
6280 @strong{2}.  Whether or not each recommendation given in Implementation
6281 Advice is followed.  See 1.1.2(37).
6282 @end cartouche
6283 @noindent
6284 @xref{Implementation Advice}.
6285
6286 @sp 1
6287 @cartouche
6288 @noindent
6289 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6290 @end cartouche
6291 @noindent
6292 The complexity of programs that can be processed is limited only by the
6293 total amount of available virtual memory, and disk space for the
6294 generated object files.
6295
6296 @sp 1
6297 @cartouche
6298 @noindent
6299 @strong{4}.  Variations from the standard that are impractical to avoid
6300 given the implementation's execution environment.  See 1.1.3(6).
6301 @end cartouche
6302 @noindent
6303 There are no variations from the standard.
6304
6305 @sp 1
6306 @cartouche
6307 @noindent
6308 @strong{5}.  Which @code{code_statement}s cause external
6309 interactions.  See 1.1.3(10).
6310 @end cartouche
6311 @noindent
6312 Any @code{code_statement} can potentially cause external interactions.
6313
6314 @sp 1
6315 @cartouche
6316 @noindent
6317 @strong{6}.  The coded representation for the text of an Ada
6318 program.  See 2.1(4).
6319 @end cartouche
6320 @noindent
6321 See separate section on source representation.
6322
6323 @sp 1
6324 @cartouche
6325 @noindent
6326 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6327 @end cartouche
6328 @noindent
6329 See separate section on source representation.
6330
6331 @sp 1
6332 @cartouche
6333 @noindent
6334 @strong{8}.  The representation for an end of line.  See 2.2(2).
6335 @end cartouche
6336 @noindent
6337 See separate section on source representation.
6338
6339 @sp 1
6340 @cartouche
6341 @noindent
6342 @strong{9}.  Maximum supported line length and lexical element
6343 length.  See 2.2(15).
6344 @end cartouche
6345 @noindent
6346 The maximum line length is 255 characters an the maximum length of a
6347 lexical element is also 255 characters.
6348
6349 @sp 1
6350 @cartouche
6351 @noindent
6352 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6353 @end cartouche
6354 @noindent
6355
6356 @xref{Implementation Defined Pragmas}.
6357
6358 @sp 1
6359 @cartouche
6360 @noindent
6361 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6362 @end cartouche
6363 @noindent
6364 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6365 parameter, checks that the optimization flag is set, and aborts if it is
6366 not.
6367
6368 @sp 1
6369 @cartouche
6370 @noindent
6371 @strong{12}.  The sequence of characters of the value returned by
6372 @code{@var{S}'Image} when some of the graphic characters of
6373 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6374 3.5(37).
6375 @end cartouche
6376 @noindent
6377 The sequence of characters is as defined by the wide character encoding
6378 method used for the source.  See section on source representation for
6379 further details.
6380
6381 @sp 1
6382 @cartouche
6383 @noindent
6384 @strong{13}.  The predefined integer types declared in
6385 @code{Standard}.  See 3.5.4(25).
6386 @end cartouche
6387 @noindent
6388 @table @code
6389 @item Short_Short_Integer
6390 8 bit signed
6391 @item Short_Integer
6392 (Short) 16 bit signed
6393 @item Integer
6394 32 bit signed
6395 @item Long_Integer
6396 64 bit signed (Alpha OpenVMS only)
6397 32 bit signed (all other targets)
6398 @item Long_Long_Integer
6399 64 bit signed
6400 @end table
6401
6402 @sp 1
6403 @cartouche
6404 @noindent
6405 @strong{14}.  Any nonstandard integer types and the operators defined
6406 for them.  See 3.5.4(26).
6407 @end cartouche
6408 @noindent
6409 There are no nonstandard integer types.
6410
6411 @sp 1
6412 @cartouche
6413 @noindent
6414 @strong{15}.  Any nonstandard real types and the operators defined for
6415 them.  See 3.5.6(8).
6416 @end cartouche
6417 @noindent
6418 There are no nonstandard real types.
6419
6420 @sp 1
6421 @cartouche
6422 @noindent
6423 @strong{16}.  What combinations of requested decimal precision and range
6424 are supported for floating point types.  See 3.5.7(7).
6425 @end cartouche
6426 @noindent
6427 The precision and range is as defined by the IEEE standard.
6428
6429 @sp 1
6430 @cartouche
6431 @noindent
6432 @strong{17}.  The predefined floating point types declared in
6433 @code{Standard}.  See 3.5.7(16).
6434 @end cartouche
6435 @noindent
6436 @table @code
6437 @item Short_Float
6438 32 bit IEEE short
6439 @item Float
6440 (Short) 32 bit IEEE short
6441 @item Long_Float
6442 64 bit IEEE long
6443 @item Long_Long_Float
6444 64 bit IEEE long (80 bit IEEE long on x86 processors)
6445 @end table
6446
6447 @sp 1
6448 @cartouche
6449 @noindent
6450 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6451 @end cartouche
6452 @noindent
6453 @code{Fine_Delta} is 2**(@minus{}63)
6454
6455 @sp 1
6456 @cartouche
6457 @noindent
6458 @strong{19}.  What combinations of small, range, and digits are
6459 supported for fixed point types.  See 3.5.9(10).
6460 @end cartouche
6461 @noindent
6462 Any combinations are permitted that do not result in a small less than
6463 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6464 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6465 is 64 bits (true of all architectures except ia32), then the output from
6466 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6467 is because floating-point conversions are used to convert fixed point.
6468
6469 @sp 1
6470 @cartouche
6471 @noindent
6472 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6473 within an unnamed @code{block_statement}.  See 3.9(10).
6474 @end cartouche
6475 @noindent
6476 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6477 decimal integer are allocated.
6478
6479 @sp 1
6480 @cartouche
6481 @noindent
6482 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6483 @end cartouche
6484 @noindent
6485 @xref{Implementation Defined Attributes}.
6486
6487 @sp 1
6488 @cartouche
6489 @noindent
6490 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6491 @end cartouche
6492 @noindent
6493 There are no implementation-defined time types.
6494
6495 @sp 1
6496 @cartouche
6497 @noindent
6498 @strong{23}.  The time base associated with relative delays.
6499 @end cartouche
6500 @noindent
6501 See 9.6(20).  The time base used is that provided by the C library
6502 function @code{gettimeofday}.
6503
6504 @sp 1
6505 @cartouche
6506 @noindent
6507 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6508 9.6(23).
6509 @end cartouche
6510 @noindent
6511 The time base used is that provided by the C library function
6512 @code{gettimeofday}.
6513
6514 @sp 1
6515 @cartouche
6516 @noindent
6517 @strong{25}.  The time zone used for package @code{Calendar}
6518 operations.  See 9.6(24).
6519 @end cartouche
6520 @noindent
6521 The time zone used by package @code{Calendar} is the current system time zone
6522 setting for local time, as accessed by the C library function
6523 @code{localtime}.
6524
6525 @sp 1
6526 @cartouche
6527 @noindent
6528 @strong{26}.  Any limit on @code{delay_until_statements} of
6529 @code{select_statements}.  See 9.6(29).
6530 @end cartouche
6531 @noindent
6532 There are no such limits.
6533
6534 @sp 1
6535 @cartouche
6536 @noindent
6537 @strong{27}.  Whether or not two non overlapping parts of a composite
6538 object are independently addressable, in the case where packing, record
6539 layout, or @code{Component_Size} is specified for the object.  See
6540 9.10(1).
6541 @end cartouche
6542 @noindent
6543 Separate components are independently addressable if they do not share
6544 overlapping storage units.
6545
6546 @sp 1
6547 @cartouche
6548 @noindent
6549 @strong{28}.  The representation for a compilation.  See 10.1(2).
6550 @end cartouche
6551 @noindent
6552 A compilation is represented by a sequence of files presented to the
6553 compiler in a single invocation of the @code{gcc} command.
6554
6555 @sp 1
6556 @cartouche
6557 @noindent
6558 @strong{29}.  Any restrictions on compilations that contain multiple
6559 compilation_units.  See 10.1(4).
6560 @end cartouche
6561 @noindent
6562 No single file can contain more than one compilation unit, but any
6563 sequence of files can be presented to the compiler as a single
6564 compilation.
6565
6566 @sp 1
6567 @cartouche
6568 @noindent
6569 @strong{30}.  The mechanisms for creating an environment and for adding
6570 and replacing compilation units.  See 10.1.4(3).
6571 @end cartouche
6572 @noindent
6573 See separate section on compilation model.
6574
6575 @sp 1
6576 @cartouche
6577 @noindent
6578 @strong{31}.  The manner of explicitly assigning library units to a
6579 partition.  See 10.2(2).
6580 @end cartouche
6581 @noindent
6582 If a unit contains an Ada main program, then the Ada units for the partition
6583 are determined by recursive application of the rules in the Ada Reference
6584 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6585 are needed by the main program, and then this definition of need is applied
6586 recursively to those units, and the partition contains the transitive
6587 closure determined by this relationship.  In short, all the necessary units
6588 are included, with no need to explicitly specify the list.  If additional
6589 units are required, e.g.@: by foreign language units, then all units must be
6590 mentioned in the context clause of one of the needed Ada units.
6591
6592 If the partition contains no main program, or if the main program is in
6593 a language other than Ada, then GNAT
6594 provides the binder options @code{-z} and @code{-n} respectively, and in
6595 this case a list of units can be explicitly supplied to the binder for
6596 inclusion in the partition (all units needed by these units will also
6597 be included automatically).  For full details on the use of these
6598 options, refer to the @cite{GNAT User's Guide} sections on Binding
6599 and Linking.
6600
6601 @sp 1
6602 @cartouche
6603 @noindent
6604 @strong{32}.  The implementation-defined means, if any, of specifying
6605 which compilation units are needed by a given compilation unit.  See
6606 10.2(2).
6607 @end cartouche
6608 @noindent
6609 The units needed by a given compilation unit are as defined in
6610 the Ada Reference Manual section 10.2(2-6).  There are no
6611 implementation-defined pragmas or other implementation-defined
6612 means for specifying needed units.
6613
6614 @sp 1
6615 @cartouche
6616 @noindent
6617 @strong{33}.  The manner of designating the main subprogram of a
6618 partition.  See 10.2(7).
6619 @end cartouche
6620 @noindent
6621 The main program is designated by providing the name of the
6622 corresponding @file{ALI} file as the input parameter to the binder.
6623
6624 @sp 1
6625 @cartouche
6626 @noindent
6627 @strong{34}.  The order of elaboration of @code{library_items}.  See
6628 10.2(18).
6629 @end cartouche
6630 @noindent
6631 The first constraint on ordering is that it meets the requirements of
6632 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6633 implementation dependent choices, which are resolved by first
6634 elaborating bodies as early as possible (i.e.@: in preference to specs
6635 where there is a choice), and second by evaluating the immediate with
6636 clauses of a unit to determine the probably best choice, and
6637 third by elaborating in alphabetical order of unit names
6638 where a choice still remains.
6639
6640 @sp 1
6641 @cartouche
6642 @noindent
6643 @strong{35}.  Parameter passing and function return for the main
6644 subprogram.  See 10.2(21).
6645 @end cartouche
6646 @noindent
6647 The main program has no parameters.  It may be a procedure, or a function
6648 returning an integer type.  In the latter case, the returned integer
6649 value is the return code of the program (overriding any value that
6650 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6651
6652 @sp 1
6653 @cartouche
6654 @noindent
6655 @strong{36}.  The mechanisms for building and running partitions.  See
6656 10.2(24).
6657 @end cartouche
6658 @noindent
6659 GNAT itself supports programs with only a single partition.  The GNATDIST
6660 tool provided with the GLADE package (which also includes an implementation
6661 of the PCS) provides a completely flexible method for building and running
6662 programs consisting of multiple partitions.  See the separate GLADE manual
6663 for details.
6664
6665 @sp 1
6666 @cartouche
6667 @noindent
6668 @strong{37}.  The details of program execution, including program
6669 termination.  See 10.2(25).
6670 @end cartouche
6671 @noindent
6672 See separate section on compilation model.
6673
6674 @sp 1
6675 @cartouche
6676 @noindent
6677 @strong{38}.  The semantics of any non-active partitions supported by the
6678 implementation.  See 10.2(28).
6679 @end cartouche
6680 @noindent
6681 Passive partitions are supported on targets where shared memory is
6682 provided by the operating system.  See the GLADE reference manual for
6683 further details.
6684
6685 @sp 1
6686 @cartouche
6687 @noindent
6688 @strong{39}.  The information returned by @code{Exception_Message}.  See
6689 11.4.1(10).
6690 @end cartouche
6691 @noindent
6692 Exception message returns the null string unless a specific message has
6693 been passed by the program.
6694
6695 @sp 1
6696 @cartouche
6697 @noindent
6698 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6699 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6700 @end cartouche
6701 @noindent
6702 Blocks have implementation defined names of the form @code{B@var{nnn}}
6703 where @var{nnn} is an integer.
6704
6705 @sp 1
6706 @cartouche
6707 @noindent
6708 @strong{41}.  The information returned by
6709 @code{Exception_Information}.  See 11.4.1(13).
6710 @end cartouche
6711 @noindent
6712 @code{Exception_Information} returns a string in the following format:
6713
6714 @smallexample
6715 @emph{Exception_Name:} nnnnn
6716 @emph{Message:} mmmmm
6717 @emph{PID:} ppp
6718 @emph{Call stack traceback locations:}
6719 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6720 @end smallexample
6721
6722 @noindent
6723 where
6724
6725 @itemize @bullet
6726 @item
6727 @code{nnnn} is the fully qualified name of the exception in all upper
6728 case letters. This line is always present.
6729
6730 @item
6731 @code{mmmm} is the message (this line present only if message is non-null)
6732
6733 @item
6734 @code{ppp} is the Process Id value as a decimal integer (this line is
6735 present only if the Process Id is non-zero). Currently we are
6736 not making use of this field.
6737
6738 @item
6739 The Call stack traceback locations line and the following values
6740 are present only if at least one traceback location was recorded.
6741 The values are given in C style format, with lower case letters
6742 for a-f, and only as many digits present as are necessary.
6743 @end itemize
6744
6745 @noindent
6746 The line terminator sequence at the end of each line, including
6747 the last line is a single @code{LF} character (@code{16#0A#}).
6748
6749 @sp 1
6750 @cartouche
6751 @noindent
6752 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6753 @end cartouche
6754 @noindent
6755 No implementation-defined check names are supported.
6756
6757 @sp 1
6758 @cartouche
6759 @noindent
6760 @strong{43}.  The interpretation of each aspect of representation.  See
6761 13.1(20).
6762 @end cartouche
6763 @noindent
6764 See separate section on data representations.
6765
6766 @sp 1
6767 @cartouche
6768 @noindent
6769 @strong{44}.  Any restrictions placed upon representation items.  See
6770 13.1(20).
6771 @end cartouche
6772 @noindent
6773 See separate section on data representations.
6774
6775 @sp 1
6776 @cartouche
6777 @noindent
6778 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6779 13.3(48).
6780 @end cartouche
6781 @noindent
6782 Size for an indefinite subtype is the maximum possible size, except that
6783 for the case of a subprogram parameter, the size of the parameter object
6784 is the actual size.
6785
6786 @sp 1
6787 @cartouche
6788 @noindent
6789 @strong{46}.  The default external representation for a type tag.  See
6790 13.3(75).
6791 @end cartouche
6792 @noindent
6793 The default external representation for a type tag is the fully expanded
6794 name of the type in upper case letters.
6795
6796 @sp 1
6797 @cartouche
6798 @noindent
6799 @strong{47}.  What determines whether a compilation unit is the same in
6800 two different partitions.  See 13.3(76).
6801 @end cartouche
6802 @noindent
6803 A compilation unit is the same in two different partitions if and only
6804 if it derives from the same source file.
6805
6806 @sp 1
6807 @cartouche
6808 @noindent
6809 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6810 @end cartouche
6811 @noindent
6812 The only implementation defined component is the tag for a tagged type,
6813 which contains a pointer to the dispatching table.
6814
6815 @sp 1
6816 @cartouche
6817 @noindent
6818 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6819 ordering.  See 13.5.3(5).
6820 @end cartouche
6821 @noindent
6822 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6823 implementation, so no non-default bit ordering is supported.  The default
6824 bit ordering corresponds to the natural endianness of the target architecture.
6825
6826 @sp 1
6827 @cartouche
6828 @noindent
6829 @strong{50}.  The contents of the visible part of package @code{System}
6830 and its language-defined children.  See 13.7(2).
6831 @end cartouche
6832 @noindent
6833 See the definition of these packages in files @file{system.ads} and
6834 @file{s-stoele.ads}.
6835
6836 @sp 1
6837 @cartouche
6838 @noindent
6839 @strong{51}.  The contents of the visible part of package
6840 @code{System.Machine_Code}, and the meaning of
6841 @code{code_statements}.  See 13.8(7).
6842 @end cartouche
6843 @noindent
6844 See the definition and documentation in file @file{s-maccod.ads}.
6845
6846 @sp 1
6847 @cartouche
6848 @noindent
6849 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6850 @end cartouche
6851 @noindent
6852 Unchecked conversion between types of the same size
6853 and results in an uninterpreted transmission of the bits from one type
6854 to the other.  If the types are of unequal sizes, then in the case of
6855 discrete types, a shorter source is first zero or sign extended as
6856 necessary, and a shorter target is simply truncated on the left.
6857 For all non-discrete types, the source is first copied if necessary
6858 to ensure that the alignment requirements of the target are met, then
6859 a pointer is constructed to the source value, and the result is obtained
6860 by dereferencing this pointer after converting it to be a pointer to the
6861 target type.
6862
6863 @sp 1
6864 @cartouche
6865 @noindent
6866 @strong{53}.  The manner of choosing a storage pool for an access type
6867 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6868 @end cartouche
6869 @noindent
6870 There are 3 different standard pools used by the compiler when
6871 @code{Storage_Pool} is not specified depending whether the type is local
6872 to a subprogram or defined at the library level and whether
6873 @code{Storage_Size}is specified or not.  See documentation in the runtime
6874 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6875 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6876 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6877 default pools used.
6878
6879 @sp 1
6880 @cartouche
6881 @noindent
6882 @strong{54}.  Whether or not the implementation provides user-accessible
6883 names for the standard pool type(s).  See 13.11(17).
6884 @end cartouche
6885 @noindent
6886
6887 See documentation in the sources of the run time mentioned in paragraph
6888 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6889 these units.
6890
6891 @sp 1
6892 @cartouche
6893 @noindent
6894 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6895 @end cartouche
6896 @noindent
6897 @code{Storage_Size} is measured in storage units, and refers to the
6898 total space available for an access type collection, or to the primary
6899 stack space for a task.
6900
6901 @sp 1
6902 @cartouche
6903 @noindent
6904 @strong{56}.  Implementation-defined aspects of storage pools.  See
6905 13.11(22).
6906 @end cartouche
6907 @noindent
6908 See documentation in the sources of the run time mentioned in paragraph
6909 @strong{53} for details on GNAT-defined aspects of storage pools.
6910
6911 @sp 1
6912 @cartouche
6913 @noindent
6914 @strong{57}.  The set of restrictions allowed in a pragma
6915 @code{Restrictions}.  See 13.12(7).
6916 @end cartouche
6917 @noindent
6918 All RM defined Restriction identifiers are implemented.  The following
6919 additional restriction identifiers are provided.  There are two separate
6920 lists of implementation dependent restriction identifiers.  The first
6921 set requires consistency throughout a partition (in other words, if the
6922 restriction identifier is used for any compilation unit in the partition,
6923 then all compilation units in the partition must obey the restriction.
6924
6925 @table @code
6926
6927 @item Simple_Barriers
6928 @findex Simple_Barriers
6929 This restriction ensures at compile time that barriers in entry declarations
6930 for protected types are restricted to either static boolean expressions or
6931 references to simple boolean variables defined in the private part of the
6932 protected type.  No other form of entry barriers is permitted.  This is one
6933 of the restrictions of the Ravenscar profile for limited tasking (see also
6934 pragma @code{Profile (Ravenscar)}).
6935
6936 @item Max_Entry_Queue_Length => Expr
6937 @findex Max_Entry_Queue_Length
6938 This restriction is a declaration that any protected entry compiled in
6939 the scope of the restriction has at most the specified number of
6940 tasks waiting on the entry
6941 at any one time, and so no queue is required.  This restriction is not
6942 checked at compile time.  A program execution is erroneous if an attempt
6943 is made to queue more than the specified number of tasks on such an entry.
6944
6945 @item No_Calendar
6946 @findex No_Calendar
6947 This restriction ensures at compile time that there is no implicit or
6948 explicit dependence on the package @code{Ada.Calendar}.
6949
6950 @item No_Direct_Boolean_Operators
6951 @findex No_Direct_Boolean_Operators
6952 This restriction ensures that no logical (and/or/xor) or comparison
6953 operators are used on operands of type Boolean (or any type derived
6954 from Boolean). This is intended for use in safety critical programs
6955 where the certification protocol requires the use of short-circuit
6956 (and then, or else) forms for all composite boolean operations.
6957
6958 @item No_Dynamic_Attachment
6959 @findex No_Dynamic_Attachment
6960 This restriction ensures that there is no call to any of the operations
6961 defined in package Ada.Interrupts.
6962
6963 @item No_Enumeration_Maps
6964 @findex No_Enumeration_Maps
6965 This restriction ensures at compile time that no operations requiring
6966 enumeration maps are used (that is Image and Value attributes applied
6967 to enumeration types).
6968
6969 @item No_Entry_Calls_In_Elaboration_Code
6970 @findex No_Entry_Calls_In_Elaboration_Code
6971 This restriction ensures at compile time that no task or protected entry
6972 calls are made during elaboration code.  As a result of the use of this
6973 restriction, the compiler can assume that no code past an accept statement
6974 in a task can be executed at elaboration time.
6975
6976 @item No_Exception_Handlers
6977 @findex No_Exception_Handlers
6978 This restriction ensures at compile time that there are no explicit
6979 exception handlers. It also indicates that no exception propagation will
6980 be provided. In this mode, exceptions may be raised but will result in
6981 an immediate call to the last chance handler, a routine that the user
6982 must define with the following profile:
6983
6984    procedure Last_Chance_Handler
6985      (Source_Location : System.Address; Line : Integer);
6986    pragma Export (C, Last_Chance_Handler,
6987                   "__gnat_last_chance_handler");
6988
6989    The parameter is a C null-terminated string representing a message to be
6990    associated with the exception (typically the source location of the raise
6991    statement generated by the compiler). The Line parameter when non-zero
6992    represents the line number in the source program where the raise occurs.
6993
6994 @item No_Exception_Streams
6995 @findex No_Exception_Streams
6996 This restriction ensures at compile time that no stream operations for
6997 types Exception_Id or Exception_Occurrence are used. This also makes it
6998 impossible to pass exceptions to or from a partition with this restriction
6999 in a distributed environment. If this exception is active, then the generated
7000 code is simplified by omitting the otherwise-required global registration
7001 of exceptions when they are declared.
7002
7003 @item No_Implicit_Conditionals
7004 @findex No_Implicit_Conditionals
7005 This restriction ensures that the generated code does not contain any
7006 implicit conditionals, either by modifying the generated code where possible,
7007 or by rejecting any construct that would otherwise generate an implicit
7008 conditional. Note that this check does not include run time constraint
7009 checks, which on some targets may generate implicit conditionals as
7010 well. To control the latter, constraint checks can be suppressed in the
7011 normal manner.
7012
7013 @item No_Implicit_Dynamic_Code
7014 @findex No_Implicit_Dynamic_Code
7015 This restriction prevents the compiler from building ``trampolines''.
7016 This is a structure that is built on the stack and contains dynamic
7017 code to be executed at run time. A trampoline is needed to indirectly
7018 address a nested subprogram (that is a subprogram that is not at the
7019 library level). The restriction prevents the use of any of the
7020 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7021 being applied to a subprogram that is not at the library level.
7022
7023 @item No_Implicit_Loops
7024 @findex No_Implicit_Loops
7025 This restriction ensures that the generated code does not contain any
7026 implicit @code{for} loops, either by modifying
7027 the generated code where possible,
7028 or by rejecting any construct that would otherwise generate an implicit
7029 @code{for} loop.
7030
7031 @item No_Initialize_Scalars
7032 @findex No_Initialize_Scalars
7033 This restriction ensures that no unit in the partition is compiled with
7034 pragma Initialize_Scalars. This allows the generation of more efficient
7035 code, and in particular eliminates dummy null initialization routines that
7036 are otherwise generated for some record and array types.
7037
7038 @item No_Local_Protected_Objects
7039 @findex No_Local_Protected_Objects
7040 This restriction ensures at compile time that protected objects are
7041 only declared at the library level.
7042
7043 @item No_Protected_Type_Allocators
7044 @findex No_Protected_Type_Allocators
7045 This restriction ensures at compile time that there are no allocator
7046 expressions that attempt to allocate protected objects.
7047
7048 @item No_Secondary_Stack
7049 @findex No_Secondary_Stack
7050 This restriction ensures at compile time that the generated code does not
7051 contain any reference to the secondary stack.  The secondary stack is used
7052 to implement functions returning unconstrained objects (arrays or records)
7053 on some targets.
7054
7055 @item No_Select_Statements
7056 @findex No_Select_Statements
7057 This restriction ensures at compile time no select statements of any kind
7058 are permitted, that is the keyword @code{select} may not appear.
7059 This is one of the restrictions of the Ravenscar
7060 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7061
7062 @item No_Standard_Storage_Pools
7063 @findex No_Standard_Storage_Pools
7064 This restriction ensures at compile time that no access types
7065 use the standard default storage pool.  Any access type declared must
7066 have an explicit Storage_Pool attribute defined specifying a
7067 user-defined storage pool.
7068
7069 @item No_Streams
7070 @findex No_Streams
7071 This restriction ensures at compile time that there are no implicit or
7072 explicit dependencies on the package @code{Ada.Streams}.
7073
7074 @item No_Task_Attributes_Package
7075 @findex No_Task_Attributes_Package
7076 This restriction ensures at compile time that there are no implicit or
7077 explicit dependencies on the package @code{Ada.Task_Attributes}.
7078
7079 @item No_Task_Termination
7080 @findex No_Task_Termination
7081 This restriction ensures at compile time that no terminate alternatives
7082 appear in any task body.
7083
7084 @item No_Tasking
7085 @findex No_Tasking
7086 This restriction prevents the declaration of tasks or task types throughout
7087 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7088 except that violations are caught at compile time and cause an error message
7089 to be output either by the compiler or binder.
7090
7091 @item No_Wide_Characters
7092 @findex No_Wide_Characters
7093 This restriction ensures at compile time that no uses of the types
7094 @code{Wide_Character} or @code{Wide_String}
7095 appear, and that no wide character literals
7096 appear in the program (that is literals representing characters not in
7097 type @code{Character}.
7098
7099 @item Static_Priorities
7100 @findex Static_Priorities
7101 This restriction ensures at compile time that all priority expressions
7102 are static, and that there are no dependencies on the package
7103 @code{Ada.Dynamic_Priorities}.
7104
7105 @item Static_Storage_Size
7106 @findex Static_Storage_Size
7107 This restriction ensures at compile time that any expression appearing
7108 in a Storage_Size pragma or attribute definition clause is static.
7109
7110 @end table
7111
7112 @noindent
7113 The second set of implementation dependent restriction identifiers
7114 does not require partition-wide consistency.
7115 The restriction may be enforced for a single
7116 compilation unit without any effect on any of the
7117 other compilation units in the partition.
7118
7119 @table @code
7120
7121 @item No_Elaboration_Code
7122 @findex No_Elaboration_Code
7123 This restriction ensures at compile time that no elaboration code is
7124 generated.  Note that this is not the same condition as is enforced
7125 by pragma @code{Preelaborate}.  There are cases in which pragma
7126 @code{Preelaborate} still permits code to be generated (e.g.@: code
7127 to initialize a large array to all zeroes), and there are cases of units
7128 which do not meet the requirements for pragma @code{Preelaborate},
7129 but for which no elaboration code is generated.  Generally, it is
7130 the case that preelaborable units will meet the restrictions, with
7131 the exception of large aggregates initialized with an others_clause,
7132 and exception declarations (which generate calls to a run-time
7133 registry procedure).  Note that this restriction is enforced on
7134 a unit by unit basis, it need not be obeyed consistently
7135 throughout a partition.
7136
7137 @item No_Entry_Queue
7138 @findex No_Entry_Queue
7139 This restriction is a declaration that any protected entry compiled in
7140 the scope of the restriction has at most one task waiting on the entry
7141 at any one time, and so no queue is required.  This restriction is not
7142 checked at compile time.  A program execution is erroneous if an attempt
7143 is made to queue a second task on such an entry.
7144
7145 @item No_Implementation_Attributes
7146 @findex No_Implementation_Attributes
7147 This restriction checks at compile time that no GNAT-defined attributes
7148 are present.  With this restriction, the only attributes that can be used
7149 are those defined in the Ada 95 Reference Manual.
7150
7151 @item No_Implementation_Pragmas
7152 @findex No_Implementation_Pragmas
7153 This restriction checks at compile time that no GNAT-defined pragmas
7154 are present.  With this restriction, the only pragmas that can be used
7155 are those defined in the Ada 95 Reference Manual.
7156
7157 @item No_Implementation_Restrictions
7158 @findex No_Implementation_Restrictions
7159 This restriction checks at compile time that no GNAT-defined restriction
7160 identifiers (other than @code{No_Implementation_Restrictions} itself)
7161 are present.  With this restriction, the only other restriction identifiers
7162 that can be used are those defined in the Ada 95 Reference Manual.
7163
7164 @end table
7165
7166 @sp 1
7167 @cartouche
7168 @noindent
7169 @strong{58}.  The consequences of violating limitations on
7170 @code{Restrictions} pragmas.  See 13.12(9).
7171 @end cartouche
7172 @noindent
7173 Restrictions that can be checked at compile time result in illegalities
7174 if violated.  Currently there are no other consequences of violating
7175 restrictions.
7176
7177 @sp 1
7178 @cartouche
7179 @noindent
7180 @strong{59}.  The representation used by the @code{Read} and
7181 @code{Write} attributes of elementary types in terms of stream
7182 elements.  See 13.13.2(9).
7183 @end cartouche
7184 @noindent
7185 The representation is the in-memory representation of the base type of
7186 the type, using the number of bits corresponding to the
7187 @code{@var{type}'Size} value, and the natural ordering of the machine.
7188
7189 @sp 1
7190 @cartouche
7191 @noindent
7192 @strong{60}.  The names and characteristics of the numeric subtypes
7193 declared in the visible part of package @code{Standard}.  See A.1(3).
7194 @end cartouche
7195 @noindent
7196 See items describing the integer and floating-point types supported.
7197
7198 @sp 1
7199 @cartouche
7200 @noindent
7201 @strong{61}.  The accuracy actually achieved by the elementary
7202 functions.  See A.5.1(1).
7203 @end cartouche
7204 @noindent
7205 The elementary functions correspond to the functions available in the C
7206 library.  Only fast math mode is implemented.
7207
7208 @sp 1
7209 @cartouche
7210 @noindent
7211 @strong{62}.  The sign of a zero result from some of the operators or
7212 functions in @code{Numerics.Generic_Elementary_Functions}, when
7213 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7214 @end cartouche
7215 @noindent
7216 The sign of zeroes follows the requirements of the IEEE 754 standard on
7217 floating-point.
7218
7219 @sp 1
7220 @cartouche
7221 @noindent
7222 @strong{63}.  The value of
7223 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7224 @end cartouche
7225 @noindent
7226 Maximum image width is 649, see library file @file{a-numran.ads}.
7227
7228 @sp 1
7229 @cartouche
7230 @noindent
7231 @strong{64}.  The value of
7232 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7233 @end cartouche
7234 @noindent
7235 Maximum image width is 80, see library file @file{a-nudira.ads}.
7236
7237 @sp 1
7238 @cartouche
7239 @noindent
7240 @strong{65}.  The algorithms for random number generation.  See
7241 A.5.2(32).
7242 @end cartouche
7243 @noindent
7244 The algorithm is documented in the source files @file{a-numran.ads} and
7245 @file{a-numran.adb}.
7246
7247 @sp 1
7248 @cartouche
7249 @noindent
7250 @strong{66}.  The string representation of a random number generator's
7251 state.  See A.5.2(38).
7252 @end cartouche
7253 @noindent
7254 See the documentation contained in the file @file{a-numran.adb}.
7255
7256 @sp 1
7257 @cartouche
7258 @noindent
7259 @strong{67}.  The minimum time interval between calls to the
7260 time-dependent Reset procedure that are guaranteed to initiate different
7261 random number sequences.  See A.5.2(45).
7262 @end cartouche
7263 @noindent
7264 The minimum period between reset calls to guarantee distinct series of
7265 random numbers is one microsecond.
7266
7267 @sp 1
7268 @cartouche
7269 @noindent
7270 @strong{68}.  The values of the @code{Model_Mantissa},
7271 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7272 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7273 Annex is not supported.  See A.5.3(72).
7274 @end cartouche
7275 @noindent
7276 See the source file @file{ttypef.ads} for the values of all numeric
7277 attributes.
7278
7279 @sp 1
7280 @cartouche
7281 @noindent
7282 @strong{69}.  Any implementation-defined characteristics of the
7283 input-output packages.  See A.7(14).
7284 @end cartouche
7285 @noindent
7286 There are no special implementation defined characteristics for these
7287 packages.
7288
7289 @sp 1
7290 @cartouche
7291 @noindent
7292 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7293 A.9(10).
7294 @end cartouche
7295 @noindent
7296 All type representations are contiguous, and the @code{Buffer_Size} is
7297 the value of @code{@var{type}'Size} rounded up to the next storage unit
7298 boundary.
7299
7300 @sp 1
7301 @cartouche
7302 @noindent
7303 @strong{71}.  External files for standard input, standard output, and
7304 standard error See A.10(5).
7305 @end cartouche
7306 @noindent
7307 These files are mapped onto the files provided by the C streams
7308 libraries.  See source file @file{i-cstrea.ads} for further details.
7309
7310 @sp 1
7311 @cartouche
7312 @noindent
7313 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7314 A.10.9(36).
7315 @end cartouche
7316 @noindent
7317 If more digits are requested in the output than are represented by the
7318 precision of the value, zeroes are output in the corresponding least
7319 significant digit positions.
7320
7321 @sp 1
7322 @cartouche
7323 @noindent
7324 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7325 @code{Command_Name}.  See A.15(1).
7326 @end cartouche
7327 @noindent
7328 These are mapped onto the @code{argv} and @code{argc} parameters of the
7329 main program in the natural manner.
7330
7331 @sp 1
7332 @cartouche
7333 @noindent
7334 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7335 @end cartouche
7336 @noindent
7337 The following convention names are supported
7338
7339 @table @code
7340 @item  Ada
7341 Ada
7342 @item Assembler
7343 Assembly language
7344 @item Asm
7345 Synonym for Assembler
7346 @item Assembly
7347 Synonym for Assembler
7348 @item C
7349 C
7350 @item C_Pass_By_Copy
7351 Allowed only for record types, like C, but also notes that record
7352 is to be passed by copy rather than reference.
7353 @item COBOL
7354 COBOL
7355 @item CPP
7356 C++
7357 @item Default
7358 Treated the same as C
7359 @item External
7360 Treated the same as C
7361 @item Fortran
7362 Fortran
7363 @item Intrinsic
7364 For support of pragma @code{Import} with convention Intrinsic, see
7365 separate section on Intrinsic Subprograms.
7366 @item Stdcall
7367 Stdcall (used for Windows implementations only).  This convention correspond
7368 to the WINAPI (previously called Pascal convention) C/C++ convention under
7369 Windows.  A function with this convention cleans the stack before exit.
7370 @item DLL
7371 Synonym for Stdcall
7372 @item Win32
7373 Synonym for Stdcall
7374 @item Stubbed
7375 Stubbed is a special convention used to indicate that the body of the
7376 subprogram will be entirely ignored.  Any call to the subprogram
7377 is converted into a raise of the @code{Program_Error} exception.  If a
7378 pragma @code{Import} specifies convention @code{stubbed} then no body need
7379 be present at all.  This convention is useful during development for the
7380 inclusion of subprograms whose body has not yet been written.
7381
7382 @end table
7383 @noindent
7384 In addition, all otherwise unrecognized convention names are also
7385 treated as being synonymous with convention C@.  In all implementations
7386 except for VMS, use of such other names results in a warning.  In VMS
7387 implementations, these names are accepted silently.
7388
7389 @sp 1
7390 @cartouche
7391 @noindent
7392 @strong{75}.  The meaning of link names.  See B.1(36).
7393 @end cartouche
7394 @noindent
7395 Link names are the actual names used by the linker.
7396
7397 @sp 1
7398 @cartouche
7399 @noindent
7400 @strong{76}.  The manner of choosing link names when neither the link
7401 name nor the address of an imported or exported entity is specified.  See
7402 B.1(36).
7403 @end cartouche
7404 @noindent
7405 The default linker name is that which would be assigned by the relevant
7406 external language, interpreting the Ada name as being in all lower case
7407 letters.
7408
7409 @sp 1
7410 @cartouche
7411 @noindent
7412 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7413 @end cartouche
7414 @noindent
7415 The string passed to @code{Linker_Options} is presented uninterpreted as
7416 an argument to the link command, unless it contains Ascii.NUL characters.
7417 NUL characters if they appear act as argument separators, so for example
7418
7419 @smallexample @c ada
7420 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7421 @end smallexample
7422
7423 @noindent
7424 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7425 linker. The order of linker options is preserved for a given unit. The final
7426 list of options passed to the linker is in reverse order of the elaboration
7427 order. For example, linker options fo a body always appear before the options
7428 from the corresponding package spec.
7429
7430 @sp 1
7431 @cartouche
7432 @noindent
7433 @strong{78}.  The contents of the visible part of package
7434 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7435 @end cartouche
7436 @noindent
7437 See files with prefix @file{i-} in the distributed library.
7438
7439 @sp 1
7440 @cartouche
7441 @noindent
7442 @strong{79}.  Implementation-defined children of package
7443 @code{Interfaces}.  The contents of the visible part of package
7444 @code{Interfaces}.  See B.2(11).
7445 @end cartouche
7446 @noindent
7447 See files with prefix @file{i-} in the distributed library.
7448
7449 @sp 1
7450 @cartouche
7451 @noindent
7452 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7453 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7454 @code{COBOL_Character}; and the initialization of the variables
7455 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7456 @code{Interfaces.COBOL}.  See B.4(50).
7457 @end cartouche
7458 @noindent
7459 @table @code
7460 @item Floating
7461 Float
7462 @item Long_Floating
7463 (Floating) Long_Float
7464 @item Binary
7465 Integer
7466 @item Long_Binary
7467 Long_Long_Integer
7468 @item Decimal_Element
7469 Character
7470 @item COBOL_Character
7471 Character
7472 @end table
7473
7474 @noindent
7475 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7476
7477 @sp 1
7478 @cartouche
7479 @noindent
7480 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7481 @end cartouche
7482 @noindent
7483 See documentation in file @file{s-maccod.ads} in the distributed library.
7484
7485 @sp 1
7486 @cartouche
7487 @noindent
7488 @strong{82}.  Implementation-defined aspects of access to machine
7489 operations.  See C.1(9).
7490 @end cartouche
7491 @noindent
7492 See documentation in file @file{s-maccod.ads} in the distributed library.
7493
7494 @sp 1
7495 @cartouche
7496 @noindent
7497 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7498 @end cartouche
7499 @noindent
7500 Interrupts are mapped to signals or conditions as appropriate.  See
7501 definition of unit
7502 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7503 on the interrupts supported on a particular target.
7504
7505 @sp 1
7506 @cartouche
7507 @noindent
7508 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7509 C.4(13).
7510 @end cartouche
7511 @noindent
7512 GNAT does not permit a partition to be restarted without reloading,
7513 except under control of the debugger.
7514
7515 @sp 1
7516 @cartouche
7517 @noindent
7518 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7519 @end cartouche
7520 @noindent
7521 Pragma @code{Discard_Names} causes names of enumeration literals to
7522 be suppressed.  In the presence of this pragma, the Image attribute
7523 provides the image of the Pos of the literal, and Value accepts
7524 Pos values.
7525
7526 @sp 1
7527 @cartouche
7528 @noindent
7529 @strong{86}.  The result of the @code{Task_Identification.Image}
7530 attribute.  See C.7.1(7).
7531 @end cartouche
7532 @noindent
7533 The result of this attribute is an 8-digit hexadecimal string
7534 representing the virtual address of the task control block.
7535
7536 @sp 1
7537 @cartouche
7538 @noindent
7539 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7540 or interrupt handler.  See C.7.1(17).
7541 @end cartouche
7542 @noindent
7543 Protected entries or interrupt handlers can be executed by any
7544 convenient thread, so the value of @code{Current_Task} is undefined.
7545
7546 @sp 1
7547 @cartouche
7548 @noindent
7549 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7550 body or interrupt handler.  See C.7.1(19).
7551 @end cartouche
7552 @noindent
7553 The effect of calling @code{Current_Task} from an entry body or
7554 interrupt handler is to return the identification of the task currently
7555 executing the code.
7556
7557 @sp 1
7558 @cartouche
7559 @noindent
7560 @strong{89}.  Implementation-defined aspects of
7561 @code{Task_Attributes}.  See C.7.2(19).
7562 @end cartouche
7563 @noindent
7564 There are no implementation-defined aspects of @code{Task_Attributes}.
7565
7566 @sp 1
7567 @cartouche
7568 @noindent
7569 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7570 @end cartouche
7571 @noindent
7572 The metrics information for GNAT depends on the performance of the
7573 underlying operating system.  The sources of the run-time for tasking
7574 implementation, together with the output from @code{-gnatG} can be
7575 used to determine the exact sequence of operating systems calls made
7576 to implement various tasking constructs.  Together with appropriate
7577 information on the performance of the underlying operating system,
7578 on the exact target in use, this information can be used to determine
7579 the required metrics.
7580
7581 @sp 1
7582 @cartouche
7583 @noindent
7584 @strong{91}.  The declarations of @code{Any_Priority} and
7585 @code{Priority}.  See D.1(11).
7586 @end cartouche
7587 @noindent
7588 See declarations in file @file{system.ads}.
7589
7590 @sp 1
7591 @cartouche
7592 @noindent
7593 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7594 @end cartouche
7595 @noindent
7596 There are no implementation-defined execution resources.
7597
7598 @sp 1
7599 @cartouche
7600 @noindent
7601 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7602 access to a protected object keeps its processor busy.  See D.2.1(3).
7603 @end cartouche
7604 @noindent
7605 On a multi-processor, a task that is waiting for access to a protected
7606 object does not keep its processor busy.
7607
7608 @sp 1
7609 @cartouche
7610 @noindent
7611 @strong{94}.  The affect of implementation defined execution resources
7612 on task dispatching.  See D.2.1(9).
7613 @end cartouche
7614 @noindent
7615 @c SGI info
7616 @ignore
7617 Tasks map to IRIX threads, and the dispatching policy is as defined by
7618 the IRIX implementation of threads.
7619 @end ignore
7620 Tasks map to threads in the threads package used by GNAT@.  Where possible
7621 and appropriate, these threads correspond to native threads of the
7622 underlying operating system.
7623
7624 @sp 1
7625 @cartouche
7626 @noindent
7627 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7628 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7629 @end cartouche
7630 @noindent
7631 There are no implementation-defined policy-identifiers allowed in this
7632 pragma.
7633
7634 @sp 1
7635 @cartouche
7636 @noindent
7637 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7638 D.2.2(16).
7639 @end cartouche
7640 @noindent
7641 Execution of a task cannot be preempted by the implementation processing
7642 of delay expirations for lower priority tasks.
7643
7644 @sp 1
7645 @cartouche
7646 @noindent
7647 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7648 @end cartouche
7649 @noindent
7650 @c SGI info:
7651 @ignore
7652 Tasks map to IRIX threads, and the dispatching policy is as defied by
7653 the IRIX implementation of threads.
7654 @end ignore
7655 The policy is the same as that of the underlying threads implementation.
7656
7657 @sp 1
7658 @cartouche
7659 @noindent
7660 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7661 in a pragma @code{Locking_Policy}.  See D.3(4).
7662 @end cartouche
7663 @noindent
7664 The only implementation defined policy permitted in GNAT is
7665 @code{Inheritance_Locking}.  On targets that support this policy, locking
7666 is implemented by inheritance, i.e.@: the task owning the lock operates
7667 at a priority equal to the highest priority of any task currently
7668 requesting the lock.
7669
7670 @sp 1
7671 @cartouche
7672 @noindent
7673 @strong{99}.  Default ceiling priorities.  See D.3(10).
7674 @end cartouche
7675 @noindent
7676 The ceiling priority of protected objects of the type
7677 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7678 Reference Manual D.3(10),
7679
7680 @sp 1
7681 @cartouche
7682 @noindent
7683 @strong{100}.  The ceiling of any protected object used internally by
7684 the implementation.  See D.3(16).
7685 @end cartouche
7686 @noindent
7687 The ceiling priority of internal protected objects is
7688 @code{System.Priority'Last}.
7689
7690 @sp 1
7691 @cartouche
7692 @noindent
7693 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7694 @end cartouche
7695 @noindent
7696 There are no implementation-defined queueing policies.
7697
7698 @sp 1
7699 @cartouche
7700 @noindent
7701 @strong{102}.  On a multiprocessor, any conditions that cause the
7702 completion of an aborted construct to be delayed later than what is
7703 specified for a single processor.  See D.6(3).
7704 @end cartouche
7705 @noindent
7706 The semantics for abort on a multi-processor is the same as on a single
7707 processor, there are no further delays.
7708
7709 @sp 1
7710 @cartouche
7711 @noindent
7712 @strong{103}.  Any operations that implicitly require heap storage
7713 allocation.  See D.7(8).
7714 @end cartouche
7715 @noindent
7716 The only operation that implicitly requires heap storage allocation is
7717 task creation.
7718
7719 @sp 1
7720 @cartouche
7721 @noindent
7722 @strong{104}.  Implementation-defined aspects of pragma
7723 @code{Restrictions}.  See D.7(20).
7724 @end cartouche
7725 @noindent
7726 There are no such implementation-defined aspects.
7727
7728 @sp 1
7729 @cartouche
7730 @noindent
7731 @strong{105}.  Implementation-defined aspects of package
7732 @code{Real_Time}.  See D.8(17).
7733 @end cartouche
7734 @noindent
7735 There are no implementation defined aspects of package @code{Real_Time}.
7736
7737 @sp 1
7738 @cartouche
7739 @noindent
7740 @strong{106}.  Implementation-defined aspects of
7741 @code{delay_statements}.  See D.9(8).
7742 @end cartouche
7743 @noindent
7744 Any difference greater than one microsecond will cause the task to be
7745 delayed (see D.9(7)).
7746
7747 @sp 1
7748 @cartouche
7749 @noindent
7750 @strong{107}.  The upper bound on the duration of interrupt blocking
7751 caused by the implementation.  See D.12(5).
7752 @end cartouche
7753 @noindent
7754 The upper bound is determined by the underlying operating system.  In
7755 no cases is it more than 10 milliseconds.
7756
7757 @sp 1
7758 @cartouche
7759 @noindent
7760 @strong{108}.  The means for creating and executing distributed
7761 programs.  See E(5).
7762 @end cartouche
7763 @noindent
7764 The GLADE package provides a utility GNATDIST for creating and executing
7765 distributed programs.  See the GLADE reference manual for further details.
7766
7767 @sp 1
7768 @cartouche
7769 @noindent
7770 @strong{109}.  Any events that can result in a partition becoming
7771 inaccessible.  See E.1(7).
7772 @end cartouche
7773 @noindent
7774 See the GLADE reference manual for full details on such events.
7775
7776 @sp 1
7777 @cartouche
7778 @noindent
7779 @strong{110}.  The scheduling policies, treatment of priorities, and
7780 management of shared resources between partitions in certain cases.  See
7781 E.1(11).
7782 @end cartouche
7783 @noindent
7784 See the GLADE reference manual for full details on these aspects of
7785 multi-partition execution.
7786
7787 @sp 1
7788 @cartouche
7789 @noindent
7790 @strong{111}.  Events that cause the version of a compilation unit to
7791 change.  See E.3(5).
7792 @end cartouche
7793 @noindent
7794 Editing the source file of a compilation unit, or the source files of
7795 any units on which it is dependent in a significant way cause the version
7796 to change.  No other actions cause the version number to change.  All changes
7797 are significant except those which affect only layout, capitalization or
7798 comments.
7799
7800 @sp 1
7801 @cartouche
7802 @noindent
7803 @strong{112}.  Whether the execution of the remote subprogram is
7804 immediately aborted as a result of cancellation.  See E.4(13).
7805 @end cartouche
7806 @noindent
7807 See the GLADE reference manual for details on the effect of abort in
7808 a distributed application.
7809
7810 @sp 1
7811 @cartouche
7812 @noindent
7813 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7814 @end cartouche
7815 @noindent
7816 See the GLADE reference manual for a full description of all implementation
7817 defined aspects of the PCS@.
7818
7819 @sp 1
7820 @cartouche
7821 @noindent
7822 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7823 E.5(26).
7824 @end cartouche
7825 @noindent
7826 See the GLADE reference manual for a full description of all
7827 implementation defined interfaces.
7828
7829 @sp 1
7830 @cartouche
7831 @noindent
7832 @strong{115}.  The values of named numbers in the package
7833 @code{Decimal}.  See F.2(7).
7834 @end cartouche
7835 @noindent
7836 @table @code
7837 @item Max_Scale
7838 +18
7839 @item Min_Scale
7840 -18
7841 @item Min_Delta
7842 1.0E-18
7843 @item Max_Delta
7844 1.0E+18
7845 @item Max_Decimal_Digits
7846 18
7847 @end table
7848
7849 @sp 1
7850 @cartouche
7851 @noindent
7852 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7853 @code{Text_IO.Editing}.  See F.3.3(16).
7854 @end cartouche
7855 @noindent
7856 64
7857
7858 @sp 1
7859 @cartouche
7860 @noindent
7861 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7862 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7863 @end cartouche
7864 @noindent
7865 64
7866
7867 @sp 1
7868 @cartouche
7869 @noindent
7870 @strong{118}.  The accuracy actually achieved by the complex elementary
7871 functions and by other complex arithmetic operations.  See G.1(1).
7872 @end cartouche
7873 @noindent
7874 Standard library functions are used for the complex arithmetic
7875 operations.  Only fast math mode is currently supported.
7876
7877 @sp 1
7878 @cartouche
7879 @noindent
7880 @strong{119}.  The sign of a zero result (or a component thereof) from
7881 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7882 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7883 @end cartouche
7884 @noindent
7885 The signs of zero values are as recommended by the relevant
7886 implementation advice.
7887
7888 @sp 1
7889 @cartouche
7890 @noindent
7891 @strong{120}.  The sign of a zero result (or a component thereof) from
7892 any operator or function in
7893 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7894 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7895 @end cartouche
7896 @noindent
7897 The signs of zero values are as recommended by the relevant
7898 implementation advice.
7899
7900 @sp 1
7901 @cartouche
7902 @noindent
7903 @strong{121}.  Whether the strict mode or the relaxed mode is the
7904 default.  See G.2(2).
7905 @end cartouche
7906 @noindent
7907 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7908 provides a highly efficient implementation of strict mode.
7909
7910 @sp 1
7911 @cartouche
7912 @noindent
7913 @strong{122}.  The result interval in certain cases of fixed-to-float
7914 conversion.  See G.2.1(10).
7915 @end cartouche
7916 @noindent
7917 For cases where the result interval is implementation dependent, the
7918 accuracy is that provided by performing all operations in 64-bit IEEE
7919 floating-point format.
7920
7921 @sp 1
7922 @cartouche
7923 @noindent
7924 @strong{123}.  The result of a floating point arithmetic operation in
7925 overflow situations, when the @code{Machine_Overflows} attribute of the
7926 result type is @code{False}.  See G.2.1(13).
7927 @end cartouche
7928 @noindent
7929 Infinite and Nan values are produced as dictated by the IEEE
7930 floating-point standard.
7931
7932 @sp 1
7933 @cartouche
7934 @noindent
7935 @strong{124}.  The result interval for division (or exponentiation by a
7936 negative exponent), when the floating point hardware implements division
7937 as multiplication by a reciprocal.  See G.2.1(16).
7938 @end cartouche
7939 @noindent
7940 Not relevant, division is IEEE exact.
7941
7942 @sp 1
7943 @cartouche
7944 @noindent
7945 @strong{125}.  The definition of close result set, which determines the
7946 accuracy of certain fixed point multiplications and divisions.  See
7947 G.2.3(5).
7948 @end cartouche
7949 @noindent
7950 Operations in the close result set are performed using IEEE long format
7951 floating-point arithmetic.  The input operands are converted to
7952 floating-point, the operation is done in floating-point, and the result
7953 is converted to the target type.
7954
7955 @sp 1
7956 @cartouche
7957 @noindent
7958 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7959 point multiplication or division for which the result shall be in the
7960 perfect result set.  See G.2.3(22).
7961 @end cartouche
7962 @noindent
7963 The result is only defined to be in the perfect result set if the result
7964 can be computed by a single scaling operation involving a scale factor
7965 representable in 64-bits.
7966
7967 @sp 1
7968 @cartouche
7969 @noindent
7970 @strong{127}.  The result of a fixed point arithmetic operation in
7971 overflow situations, when the @code{Machine_Overflows} attribute of the
7972 result type is @code{False}.  See G.2.3(27).
7973 @end cartouche
7974 @noindent
7975 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7976 types.
7977
7978 @sp 1
7979 @cartouche
7980 @noindent
7981 @strong{128}.  The result of an elementary function reference in
7982 overflow situations, when the @code{Machine_Overflows} attribute of the
7983 result type is @code{False}.  See G.2.4(4).
7984 @end cartouche
7985 @noindent
7986 IEEE infinite and Nan values are produced as appropriate.
7987
7988 @sp 1
7989 @cartouche
7990 @noindent
7991 @strong{129}.  The value of the angle threshold, within which certain
7992 elementary functions, complex arithmetic operations, and complex
7993 elementary functions yield results conforming to a maximum relative
7994 error bound.  See G.2.4(10).
7995 @end cartouche
7996 @noindent
7997 Information on this subject is not yet available.
7998
7999 @sp 1
8000 @cartouche
8001 @noindent
8002 @strong{130}.  The accuracy of certain elementary functions for
8003 parameters beyond the angle threshold.  See G.2.4(10).
8004 @end cartouche
8005 @noindent
8006 Information on this subject is not yet available.
8007
8008 @sp 1
8009 @cartouche
8010 @noindent
8011 @strong{131}.  The result of a complex arithmetic operation or complex
8012 elementary function reference in overflow situations, when the
8013 @code{Machine_Overflows} attribute of the corresponding real type is
8014 @code{False}.  See G.2.6(5).
8015 @end cartouche
8016 @noindent
8017 IEEE infinite and Nan values are produced as appropriate.
8018
8019 @sp 1
8020 @cartouche
8021 @noindent
8022 @strong{132}.  The accuracy of certain complex arithmetic operations and
8023 certain complex elementary functions for parameters (or components
8024 thereof) beyond the angle threshold.  See G.2.6(8).
8025 @end cartouche
8026 @noindent
8027 Information on those subjects is not yet available.
8028
8029 @sp 1
8030 @cartouche
8031 @noindent
8032 @strong{133}.  Information regarding bounded errors and erroneous
8033 execution.  See H.2(1).
8034 @end cartouche
8035 @noindent
8036 Information on this subject is not yet available.
8037
8038 @sp 1
8039 @cartouche
8040 @noindent
8041 @strong{134}.  Implementation-defined aspects of pragma
8042 @code{Inspection_Point}.  See H.3.2(8).
8043 @end cartouche
8044 @noindent
8045 Pragma @code{Inspection_Point} ensures that the variable is live and can
8046 be examined by the debugger at the inspection point.
8047
8048 @sp 1
8049 @cartouche
8050 @noindent
8051 @strong{135}.  Implementation-defined aspects of pragma
8052 @code{Restrictions}.  See H.4(25).
8053 @end cartouche
8054 @noindent
8055 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8056 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8057 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8058
8059 @sp 1
8060 @cartouche
8061 @noindent
8062 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8063 H.4(27).
8064 @end cartouche
8065 @noindent
8066 There are no restrictions on pragma @code{Restrictions}.
8067
8068 @node Intrinsic Subprograms
8069 @chapter Intrinsic Subprograms
8070 @cindex Intrinsic Subprograms
8071
8072 @menu
8073 * Intrinsic Operators::
8074 * Enclosing_Entity::
8075 * Exception_Information::
8076 * Exception_Message::
8077 * Exception_Name::
8078 * File::
8079 * Line::
8080 * Rotate_Left::
8081 * Rotate_Right::
8082 * Shift_Left::
8083 * Shift_Right::
8084 * Shift_Right_Arithmetic::
8085 * Source_Location::
8086 @end menu
8087
8088 @noindent
8089 GNAT allows a user application program to write the declaration:
8090
8091 @smallexample @c ada
8092    pragma Import (Intrinsic, name);
8093 @end smallexample
8094
8095 @noindent
8096 providing that the name corresponds to one of the implemented intrinsic
8097 subprograms in GNAT, and that the parameter profile of the referenced
8098 subprogram meets the requirements.  This chapter describes the set of
8099 implemented intrinsic subprograms, and the requirements on parameter profiles.
8100 Note that no body is supplied; as with other uses of pragma Import, the
8101 body is supplied elsewhere (in this case by the compiler itself).  Note
8102 that any use of this feature is potentially non-portable, since the
8103 Ada standard does not require Ada compilers to implement this feature.
8104
8105 @node Intrinsic Operators
8106 @section Intrinsic Operators
8107 @cindex Intrinsic operator
8108
8109 @noindent
8110 All the predefined numeric operators in package Standard
8111 in @code{pragma Import (Intrinsic,..)}
8112 declarations.  In the binary operator case, the operands must have the same
8113 size.  The operand or operands must also be appropriate for
8114 the operator.  For example, for addition, the operands must
8115 both be floating-point or both be fixed-point, and the
8116 right operand for @code{"**"} must have a root type of
8117 @code{Standard.Integer'Base}.
8118 You can use an intrinsic operator declaration as in the following example:
8119
8120 @smallexample @c ada
8121    type Int1 is new Integer;
8122    type Int2 is new Integer;
8123
8124    function "+" (X1 : Int1; X2 : Int2) return Int1;
8125    function "+" (X1 : Int1; X2 : Int2) return Int2;
8126    pragma Import (Intrinsic, "+");
8127 @end smallexample
8128
8129 @noindent
8130 This declaration would permit ``mixed mode'' arithmetic on items
8131 of the differing types @code{Int1} and @code{Int2}.
8132 It is also possible to specify such operators for private types, if the
8133 full views are appropriate arithmetic types.
8134
8135 @node Enclosing_Entity
8136 @section Enclosing_Entity
8137 @cindex Enclosing_Entity
8138 @noindent
8139 This intrinsic subprogram is used in the implementation of the
8140 library routine @code{GNAT.Source_Info}.  The only useful use of the
8141 intrinsic import in this case is the one in this unit, so an
8142 application program should simply call the function
8143 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8144 the current subprogram, package, task, entry, or protected subprogram.
8145
8146 @node Exception_Information
8147 @section Exception_Information
8148 @cindex Exception_Information'
8149 @noindent
8150 This intrinsic subprogram is used in the implementation of the
8151 library routine @code{GNAT.Current_Exception}.  The only useful
8152 use of the intrinsic import in this case is the one in this unit,
8153 so an application program should simply call the function
8154 @code{GNAT.Current_Exception.Exception_Information} to obtain
8155 the exception information associated with the current exception.
8156
8157 @node Exception_Message
8158 @section Exception_Message
8159 @cindex Exception_Message
8160 @noindent
8161 This intrinsic subprogram is used in the implementation of the
8162 library routine @code{GNAT.Current_Exception}.  The only useful
8163 use of the intrinsic import in this case is the one in this unit,
8164 so an application program should simply call the function
8165 @code{GNAT.Current_Exception.Exception_Message} to obtain
8166 the message associated with the current exception.
8167
8168 @node Exception_Name
8169 @section Exception_Name
8170 @cindex Exception_Name
8171 @noindent
8172 This intrinsic subprogram is used in the implementation of the
8173 library routine @code{GNAT.Current_Exception}.  The only useful
8174 use of the intrinsic import in this case is the one in this unit,
8175 so an application program should simply call the function
8176 @code{GNAT.Current_Exception.Exception_Name} to obtain
8177 the name of the current exception.
8178
8179 @node File
8180 @section File
8181 @cindex File
8182 @noindent
8183 This intrinsic subprogram is used in the implementation of the
8184 library routine @code{GNAT.Source_Info}.  The only useful use of the
8185 intrinsic import in this case is the one in this unit, so an
8186 application program should simply call the function
8187 @code{GNAT.Source_Info.File} to obtain the name of the current
8188 file.
8189
8190 @node Line
8191 @section Line
8192 @cindex Line
8193 @noindent
8194 This intrinsic subprogram is used in the implementation of the
8195 library routine @code{GNAT.Source_Info}.  The only useful use of the
8196 intrinsic import in this case is the one in this unit, so an
8197 application program should simply call the function
8198 @code{GNAT.Source_Info.Line} to obtain the number of the current
8199 source line.
8200
8201 @node Rotate_Left
8202 @section Rotate_Left
8203 @cindex Rotate_Left
8204 @noindent
8205 In standard Ada 95, the @code{Rotate_Left} function is available only
8206 for the predefined modular types in package @code{Interfaces}.  However, in
8207 GNAT it is possible to define a Rotate_Left function for a user
8208 defined modular type or any signed integer type as in this example:
8209
8210 @smallexample @c ada
8211    function Shift_Left
8212      (Value  : My_Modular_Type;
8213       Amount : Natural)
8214       return   My_Modular_Type;
8215 @end smallexample
8216
8217 @noindent
8218 The requirements are that the profile be exactly as in the example
8219 above.  The only modifications allowed are in the formal parameter
8220 names, and in the type of @code{Value} and the return type, which
8221 must be the same, and must be either a signed integer type, or
8222 a modular integer type with a binary modulus, and the size must
8223 be 8.  16, 32 or 64 bits.
8224
8225 @node Rotate_Right
8226 @section Rotate_Right
8227 @cindex Rotate_Right
8228 @noindent
8229 A @code{Rotate_Right} function can be defined for any user defined
8230 binary modular integer type, or signed integer type, as described
8231 above for @code{Rotate_Left}.
8232
8233 @node Shift_Left
8234 @section Shift_Left
8235 @cindex Shift_Left
8236 @noindent
8237 A @code{Shift_Left} function can be defined for any user defined
8238 binary modular integer type, or signed integer type, as described
8239 above for @code{Rotate_Left}.
8240
8241 @node Shift_Right
8242 @section Shift_Right
8243 @cindex Shift_Right
8244 @noindent
8245 A @code{Shift_Right} function can be defined for any user defined
8246 binary modular integer type, or signed integer type, as described
8247 above for @code{Rotate_Left}.
8248
8249 @node Shift_Right_Arithmetic
8250 @section Shift_Right_Arithmetic
8251 @cindex Shift_Right_Arithmetic
8252 @noindent
8253 A @code{Shift_Right_Arithmetic} function can be defined for any user
8254 defined binary modular integer type, or signed integer type, as described
8255 above for @code{Rotate_Left}.
8256
8257 @node Source_Location
8258 @section Source_Location
8259 @cindex Source_Location
8260 @noindent
8261 This intrinsic subprogram is used in the implementation of the
8262 library routine @code{GNAT.Source_Info}.  The only useful use of the
8263 intrinsic import in this case is the one in this unit, so an
8264 application program should simply call the function
8265 @code{GNAT.Source_Info.Source_Location} to obtain the current
8266 source file location.
8267
8268 @node Representation Clauses and Pragmas
8269 @chapter Representation Clauses and Pragmas
8270 @cindex Representation Clauses
8271
8272 @menu
8273 * Alignment Clauses::
8274 * Size Clauses::
8275 * Storage_Size Clauses::
8276 * Size of Variant Record Objects::
8277 * Biased Representation ::
8278 * Value_Size and Object_Size Clauses::
8279 * Component_Size Clauses::
8280 * Bit_Order Clauses::
8281 * Effect of Bit_Order on Byte Ordering::
8282 * Pragma Pack for Arrays::
8283 * Pragma Pack for Records::
8284 * Record Representation Clauses::
8285 * Enumeration Clauses::
8286 * Address Clauses::
8287 * Effect of Convention on Representation::
8288 * Determining the Representations chosen by GNAT::
8289 @end menu
8290
8291 @noindent
8292 @cindex Representation Clause
8293 @cindex Representation Pragma
8294 @cindex Pragma, representation
8295 This section describes the representation clauses accepted by GNAT, and
8296 their effect on the representation of corresponding data objects.
8297
8298 GNAT fully implements Annex C (Systems Programming).  This means that all
8299 the implementation advice sections in chapter 13 are fully implemented.
8300 However, these sections only require a minimal level of support for
8301 representation clauses.  GNAT provides much more extensive capabilities,
8302 and this section describes the additional capabilities provided.
8303
8304 @node Alignment Clauses
8305 @section Alignment Clauses
8306 @cindex Alignment Clause
8307
8308 @noindent
8309 GNAT requires that all alignment clauses specify a power of 2, and all
8310 default alignments are always a power of 2.  The default alignment
8311 values are as follows:
8312
8313 @itemize @bullet
8314 @item @emph{Primitive Types}.
8315 For primitive types, the alignment is the minimum of the actual size of
8316 objects of the type divided by @code{Storage_Unit},
8317 and the maximum alignment supported by the target.
8318 (This maximum alignment is given by the GNAT-specific attribute
8319 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8320 @cindex @code{Maximum_Alignment} attribute
8321 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8322 default alignment will be 8 on any target that supports alignments
8323 this large, but on some targets, the maximum alignment may be smaller
8324 than 8, in which case objects of type @code{Long_Float} will be maximally
8325 aligned.
8326
8327 @item @emph{Arrays}.
8328 For arrays, the alignment is equal to the alignment of the component type
8329 for the normal case where no packing or component size is given.  If the
8330 array is packed, and the packing is effective (see separate section on
8331 packed arrays), then the alignment will be one for long packed arrays,
8332 or arrays whose length is not known at compile time.  For short packed
8333 arrays, which are handled internally as modular types, the alignment
8334 will be as described for primitive types, e.g.@: a packed array of length
8335 31 bits will have an object size of four bytes, and an alignment of 4.
8336
8337 @item @emph{Records}.
8338 For the normal non-packed case, the alignment of a record is equal to
8339 the maximum alignment of any of its components.  For tagged records, this
8340 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8341 used and all fields are packable (see separate section on pragma @code{Pack}),
8342 then the resulting alignment is 1.
8343
8344 A special case is when:
8345 @itemize @bullet
8346 @item
8347 the size of the record is given explicitly, or a
8348 full record representation clause is given, and
8349 @item
8350 the size of the record is 2, 4, or 8 bytes.
8351 @end itemize
8352 @noindent
8353 In this case, an alignment is chosen to match the
8354 size of the record. For example, if we have:
8355
8356 @smallexample @c ada
8357    type Small is record
8358       A, B : Character;
8359    end record;
8360    for Small'Size use 16;
8361 @end smallexample
8362
8363 @noindent
8364 then the default alignment of the record type @code{Small} is 2, not 1. This
8365 leads to more efficient code when the record is treated as a unit, and also
8366 allows the type to specified as @code{Atomic} on architectures requiring
8367 strict alignment.
8368
8369 @end itemize
8370
8371 @noindent
8372 An alignment clause may
8373 always specify a larger alignment than the default value, up to some
8374 maximum value dependent on the target (obtainable by using the
8375 attribute reference @code{Standard'Maximum_Alignment}).
8376 The only case where
8377 it is permissible to specify a smaller alignment than the default value
8378 is for a record with a record representation clause.
8379 In this case, packable fields for which a component clause is
8380 given still result in a default alignment corresponding to the original
8381 type, but this may be overridden, since these components in fact only
8382 require an alignment of one byte.  For example, given
8383
8384 @smallexample @c ada
8385   type V is record
8386      A : Integer;
8387   end record;
8388
8389   for V use record
8390      A at 0  range 0 .. 31;
8391   end record;
8392
8393   for V'alignment use 1;
8394 @end smallexample
8395
8396 @noindent
8397 @cindex Alignment, default
8398 The default alignment for the type @code{V} is 4, as a result of the
8399 Integer field in the record, but since this field is placed with a
8400 component clause, it is permissible, as shown, to override the default
8401 alignment of the record with a smaller value.
8402
8403 @node Size Clauses
8404 @section Size Clauses
8405 @cindex Size Clause
8406
8407 @noindent
8408 The default size for a type @code{T} is obtainable through the
8409 language-defined attribute @code{T'Size} and also through the
8410 equivalent GNAT-defined attribute @code{T'Value_Size}.
8411 For objects of type @code{T}, GNAT will generally increase the type size
8412 so that the object size (obtainable through the GNAT-defined attribute
8413 @code{T'Object_Size})
8414 is a multiple of @code{T'Alignment * Storage_Unit}.
8415 For example
8416
8417 @smallexample @c ada
8418    type Smallint is range 1 .. 6;
8419
8420    type Rec is record
8421       Y1 : integer;
8422       Y2 : boolean;
8423    end record;
8424 @end smallexample
8425
8426 @noindent
8427 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8428 as specified by the RM rules,
8429 but objects of this type will have a size of 8
8430 (@code{Smallint'Object_Size} = 8),
8431 since objects by default occupy an integral number
8432 of storage units.  On some targets, notably older
8433 versions of the Digital Alpha, the size of stand
8434 alone objects of this type may be 32, reflecting
8435 the inability of the hardware to do byte load/stores.
8436
8437 Similarly, the size of type @code{Rec} is 40 bits
8438 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8439 the alignment is 4, so objects of this type will have
8440 their size increased to 64 bits so that it is a multiple
8441 of the alignment (in bits).  This decision is
8442 in accordance with the specific Implementation Advice in RM 13.3(43):
8443
8444 @quotation
8445 A @code{Size} clause should be supported for an object if the specified
8446 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8447 to a size in storage elements that is a multiple of the object's
8448 @code{Alignment} (if the @code{Alignment} is nonzero).
8449 @end quotation
8450
8451 @noindent
8452 An explicit size clause may be used to override the default size by
8453 increasing it.  For example, if we have:
8454
8455 @smallexample @c ada
8456    type My_Boolean is new Boolean;
8457    for My_Boolean'Size use 32;
8458 @end smallexample
8459
8460 @noindent
8461 then values of this type will always be 32 bits long.  In the case of
8462 discrete types, the size can be increased up to 64 bits, with the effect
8463 that the entire specified field is used to hold the value, sign- or
8464 zero-extended as appropriate.  If more than 64 bits is specified, then
8465 padding space is allocated after the value, and a warning is issued that
8466 there are unused bits.
8467
8468 Similarly the size of records and arrays may be increased, and the effect
8469 is to add padding bits after the value.  This also causes a warning message
8470 to be generated.
8471
8472 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8473 Size in bits, this corresponds to an object of size 256 megabytes (minus
8474 one).  This limitation is true on all targets.  The reason for this
8475 limitation is that it improves the quality of the code in many cases
8476 if it is known that a Size value can be accommodated in an object of
8477 type Integer.
8478
8479 @node Storage_Size Clauses
8480 @section Storage_Size Clauses
8481 @cindex Storage_Size Clause
8482
8483 @noindent
8484 For tasks, the @code{Storage_Size} clause specifies the amount of space
8485 to be allocated for the task stack.  This cannot be extended, and if the
8486 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8487 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8488 or a @code{Storage_Size} pragma in the task definition to set the
8489 appropriate required size.  A useful technique is to include in every
8490 task definition a pragma of the form:
8491
8492 @smallexample @c ada
8493    pragma Storage_Size (Default_Stack_Size);
8494 @end smallexample
8495
8496 @noindent
8497 Then @code{Default_Stack_Size} can be defined in a global package, and
8498 modified as required.  Any tasks requiring stack sizes different from the
8499 default can have an appropriate alternative reference in the pragma.
8500
8501 For access types, the @code{Storage_Size} clause specifies the maximum
8502 space available for allocation of objects of the type.  If this space is
8503 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8504 In the case where the access type is declared local to a subprogram, the
8505 use of a @code{Storage_Size} clause triggers automatic use of a special
8506 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8507 space for the pool is automatically reclaimed on exit from the scope in
8508 which the type is declared.
8509
8510 A special case recognized by the compiler is the specification of a
8511 @code{Storage_Size} of zero for an access type.  This means that no
8512 items can be allocated from the pool, and this is recognized at compile
8513 time, and all the overhead normally associated with maintaining a fixed
8514 size storage pool is eliminated.  Consider the following example:
8515
8516 @smallexample @c ada
8517    procedure p is
8518       type R is array (Natural) of Character;
8519       type P is access all R;
8520       for P'Storage_Size use 0;
8521       --  Above access type intended only for interfacing purposes
8522
8523       y : P;
8524
8525       procedure g (m : P);
8526       pragma Import (C, g);
8527
8528       --  @dots{}
8529
8530    begin
8531       --  @dots{}
8532       y := new R;
8533    end;
8534 @end smallexample
8535
8536 @noindent
8537 As indicated in this example, these dummy storage pools are often useful in
8538 connection with interfacing where no object will ever be allocated.  If you
8539 compile the above example, you get the warning:
8540
8541 @smallexample
8542    p.adb:16:09: warning: allocation from empty storage pool
8543    p.adb:16:09: warning: Storage_Error will be raised at run time
8544 @end smallexample
8545
8546 @noindent
8547 Of course in practice, there will not be any explicit allocators in the
8548 case of such an access declaration.
8549
8550 @node Size of Variant Record Objects
8551 @section Size of Variant Record Objects
8552 @cindex Size, variant record objects
8553 @cindex Variant record objects, size
8554
8555 @noindent
8556 In the case of variant record objects, there is a question whether Size gives
8557 information about a particular variant, or the maximum size required
8558 for any variant.  Consider the following program
8559
8560 @smallexample @c ada
8561 with Text_IO; use Text_IO;
8562 procedure q is
8563    type R1 (A : Boolean := False) is record
8564      case A is
8565        when True  => X : Character;
8566        when False => null;
8567      end case;
8568    end record;
8569
8570    V1 : R1 (False);
8571    V2 : R1;
8572
8573 begin
8574    Put_Line (Integer'Image (V1'Size));
8575    Put_Line (Integer'Image (V2'Size));
8576 end q;
8577 @end smallexample
8578
8579 @noindent
8580 Here we are dealing with a variant record, where the True variant
8581 requires 16 bits, and the False variant requires 8 bits.
8582 In the above example, both V1 and V2 contain the False variant,
8583 which is only 8 bits long.  However, the result of running the
8584 program is:
8585
8586 @smallexample
8587 8
8588 16
8589 @end smallexample
8590
8591 @noindent
8592 The reason for the difference here is that the discriminant value of
8593 V1 is fixed, and will always be False.  It is not possible to assign
8594 a True variant value to V1, therefore 8 bits is sufficient.  On the
8595 other hand, in the case of V2, the initial discriminant value is
8596 False (from the default), but it is possible to assign a True
8597 variant value to V2, therefore 16 bits must be allocated for V2
8598 in the general case, even fewer bits may be needed at any particular
8599 point during the program execution.
8600
8601 As can be seen from the output of this program, the @code{'Size}
8602 attribute applied to such an object in GNAT gives the actual allocated
8603 size of the variable, which is the largest size of any of the variants.
8604 The Ada Reference Manual is not completely clear on what choice should
8605 be made here, but the GNAT behavior seems most consistent with the
8606 language in the RM@.
8607
8608 In some cases, it may be desirable to obtain the size of the current
8609 variant, rather than the size of the largest variant.  This can be
8610 achieved in GNAT by making use of the fact that in the case of a
8611 subprogram parameter, GNAT does indeed return the size of the current
8612 variant (because a subprogram has no way of knowing how much space
8613 is actually allocated for the actual).
8614
8615 Consider the following modified version of the above program:
8616
8617 @smallexample @c ada
8618 with Text_IO; use Text_IO;
8619 procedure q is
8620    type R1 (A : Boolean := False) is record
8621      case A is
8622        when True  => X : Character;
8623        when False => null;
8624      end case;
8625    end record;
8626
8627    V2 : R1;
8628
8629    function Size (V : R1) return Integer is
8630    begin
8631       return V'Size;
8632    end Size;
8633
8634 begin
8635    Put_Line (Integer'Image (V2'Size));
8636    Put_Line (Integer'IMage (Size (V2)));
8637    V2 := (True, 'x');
8638    Put_Line (Integer'Image (V2'Size));
8639    Put_Line (Integer'IMage (Size (V2)));
8640 end q;
8641 @end smallexample
8642
8643 @noindent
8644 The output from this program is
8645
8646 @smallexample
8647 16
8648 8
8649 16
8650 16
8651 @end smallexample
8652
8653 @noindent
8654 Here we see that while the @code{'Size} attribute always returns
8655 the maximum size, regardless of the current variant value, the
8656 @code{Size} function does indeed return the size of the current
8657 variant value.
8658
8659 @node Biased Representation
8660 @section Biased Representation
8661 @cindex Size for biased representation
8662 @cindex Biased representation
8663
8664 @noindent
8665 In the case of scalars with a range starting at other than zero, it is
8666 possible in some cases to specify a size smaller than the default minimum
8667 value, and in such cases, GNAT uses an unsigned biased representation,
8668 in which zero is used to represent the lower bound, and successive values
8669 represent successive values of the type.
8670
8671 For example, suppose we have the declaration:
8672
8673 @smallexample @c ada
8674    type Small is range -7 .. -4;
8675    for Small'Size use 2;
8676 @end smallexample
8677
8678 @noindent
8679 Although the default size of type @code{Small} is 4, the @code{Size}
8680 clause is accepted by GNAT and results in the following representation
8681 scheme:
8682
8683 @smallexample
8684   -7 is represented as 2#00#
8685   -6 is represented as 2#01#
8686   -5 is represented as 2#10#
8687   -4 is represented as 2#11#
8688 @end smallexample
8689
8690 @noindent
8691 Biased representation is only used if the specified @code{Size} clause
8692 cannot be accepted in any other manner.  These reduced sizes that force
8693 biased representation can be used for all discrete types except for
8694 enumeration types for which a representation clause is given.
8695
8696 @node Value_Size and Object_Size Clauses
8697 @section Value_Size and Object_Size Clauses
8698 @findex Value_Size
8699 @findex Object_Size
8700 @cindex Size, of objects
8701
8702 @noindent
8703 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8704 required to hold values of type @code{T}.  Although this interpretation was
8705 allowed in Ada 83, it was not required, and this requirement in practice
8706 can cause some significant difficulties.  For example, in most Ada 83
8707 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8708 @code{Natural'Size} is
8709 typically 31.  This means that code may change in behavior when moving
8710 from Ada 83 to Ada 95.  For example, consider:
8711
8712 @smallexample @c ada
8713    type Rec is record;
8714       A : Natural;
8715       B : Natural;
8716    end record;
8717
8718    for Rec use record
8719       at 0  range 0 .. Natural'Size - 1;
8720       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8721    end record;
8722 @end smallexample
8723
8724 @noindent
8725 In the above code, since the typical size of @code{Natural} objects
8726 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8727 unexpected inefficient packing in Ada 95, and in general there are
8728 cases where the fact that the object size can exceed the
8729 size of the type causes surprises.
8730
8731 To help get around this problem GNAT provides two implementation
8732 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8733 applied to a type, these attributes yield the size of the type
8734 (corresponding to the RM defined size attribute), and the size of
8735 objects of the type respectively.
8736
8737 The @code{Object_Size} is used for determining the default size of
8738 objects and components.  This size value can be referred to using the
8739 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8740 the basis of the determination of the size.  The backend is free to
8741 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8742 character might be stored in 32 bits on a machine with no efficient
8743 byte access instructions such as the Alpha.
8744
8745 The default rules for the value of @code{Object_Size} for
8746 discrete types are as follows:
8747
8748 @itemize @bullet
8749 @item
8750 The @code{Object_Size} for base subtypes reflect the natural hardware
8751 size in bits (run the compiler with @option{-gnatS} to find those values
8752 for numeric types). Enumeration types and fixed-point base subtypes have
8753 8, 16, 32 or 64 bits for this size, depending on the range of values
8754 to be stored.
8755
8756 @item
8757 The @code{Object_Size} of a subtype is the same as the
8758 @code{Object_Size} of
8759 the type from which it is obtained.
8760
8761 @item
8762 The @code{Object_Size} of a derived base type is copied from the parent
8763 base type, and the @code{Object_Size} of a derived first subtype is copied
8764 from the parent first subtype.
8765 @end itemize
8766
8767 @noindent
8768 The @code{Value_Size} attribute
8769 is the (minimum) number of bits required to store a value
8770 of the type.
8771 This value is used to determine how tightly to pack
8772 records or arrays with components of this type, and also affects
8773 the semantics of unchecked conversion (unchecked conversions where
8774 the @code{Value_Size} values differ generate a warning, and are potentially
8775 target dependent).
8776
8777 The default rules for the value of @code{Value_Size} are as follows:
8778
8779 @itemize @bullet
8780 @item
8781 The @code{Value_Size} for a base subtype is the minimum number of bits
8782 required to store all values of the type (including the sign bit
8783 only if negative values are possible).
8784
8785 @item
8786 If a subtype statically matches the first subtype of a given type, then it has
8787 by default the same @code{Value_Size} as the first subtype.  This is a
8788 consequence of RM 13.1(14) (``if two subtypes statically match,
8789 then their subtype-specific aspects are the same''.)
8790
8791 @item
8792 All other subtypes have a @code{Value_Size} corresponding to the minimum
8793 number of bits required to store all values of the subtype.  For
8794 dynamic bounds, it is assumed that the value can range down or up
8795 to the corresponding bound of the ancestor
8796 @end itemize
8797
8798 @noindent
8799 The RM defined attribute @code{Size} corresponds to the
8800 @code{Value_Size} attribute.
8801
8802 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8803 the @code{Value_Size} of
8804 the first-named subtype to the given value, and the
8805 @code{Object_Size} of this first-named subtype to the given value padded up
8806 to an appropriate boundary.  It is a consequence of the default rules
8807 above that this @code{Object_Size} will apply to all further subtypes.  On the
8808 other hand, @code{Value_Size} is affected only for the first subtype, any
8809 dynamic subtypes obtained from it directly, and any statically matching
8810 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8811
8812 @code{Value_Size} and
8813 @code{Object_Size} may be explicitly set for any subtype using
8814 an attribute definition clause.  Note that the use of these attributes
8815 can cause the RM 13.1(14) rule to be violated.  If two access types
8816 reference aliased objects whose subtypes have differing @code{Object_Size}
8817 values as a result of explicit attribute definition clauses, then it
8818 is erroneous to convert from one access subtype to the other.
8819
8820 At the implementation level, Esize stores the Object_Size and the
8821 RM_Size field stores the @code{Value_Size} (and hence the value of the
8822 @code{Size} attribute,
8823 which, as noted above, is equivalent to @code{Value_Size}).
8824
8825 To get a feel for the difference, consider the following examples (note
8826 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8827
8828 @smallexample
8829                                        Object_Size     Value_Size
8830
8831 type x1 is range 0 .. 5;                    8               3
8832
8833 type x2 is range 0 .. 5;
8834 for x2'size use 12;                        16              12
8835
8836 subtype x3 is x2 range 0 .. 3;             16               2
8837
8838 subtype x4 is x2'base range 0 .. 10;        8               4
8839
8840 subtype x5 is x2 range 0 .. dynamic;       16               3*
8841
8842 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8843
8844 @end smallexample
8845
8846 @noindent
8847 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8848 but it seems in the spirit of the RM rules to allocate the minimum number
8849 of bits (here 3, given the range for @code{x2})
8850 known to be large enough to hold the given range of values.
8851
8852 So far, so good, but GNAT has to obey the RM rules, so the question is
8853 under what conditions must the RM @code{Size} be used.
8854 The following is a list
8855 of the occasions on which the RM @code{Size} must be used:
8856
8857 @itemize @bullet
8858 @item
8859 Component size for packed arrays or records
8860
8861 @item
8862 Value of the attribute @code{Size} for a type
8863
8864 @item
8865 Warning about sizes not matching for unchecked conversion
8866 @end itemize
8867
8868 @noindent
8869 For record types, the @code{Object_Size} is always a multiple of the
8870 alignment of the type (this is true for all types). In some cases the
8871 @code{Value_Size} can be smaller. Consider:
8872
8873 @smallexample
8874    type R is record
8875      X : Integer;
8876      Y : Character;
8877    end record;
8878 @end smallexample
8879
8880 @noindent
8881 On a typical 32-bit architecture, the X component will be four bytes, and
8882 require four-byte alignment, and the Y component will be one byte. In this
8883 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8884 required to store a value of this type, and for example, it is permissible
8885 to have a component of type R in an outer record whose component size is
8886 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8887 since it must be rounded up so that this value is a multiple of the
8888 alignment (4 bytes = 32 bits).
8889
8890 @noindent
8891 For all other types, the @code{Object_Size}
8892 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8893 Only @code{Size} may be specified for such types.
8894
8895 @node Component_Size Clauses
8896 @section Component_Size Clauses
8897 @cindex Component_Size Clause
8898
8899 @noindent
8900 Normally, the value specified in a component clause must be consistent
8901 with the subtype of the array component with regard to size and alignment.
8902 In other words, the value specified must be at least equal to the size
8903 of this subtype, and must be a multiple of the alignment value.
8904
8905 In addition, component size clauses are allowed which cause the array
8906 to be packed, by specifying a smaller value.  The cases in which this
8907 is allowed are for component size values in the range 1 through 63.  The value
8908 specified must not be smaller than the Size of the subtype.  GNAT will
8909 accurately honor all packing requests in this range.  For example, if
8910 we have:
8911
8912 @smallexample @c ada
8913 type r is array (1 .. 8) of Natural;
8914 for r'Component_Size use 31;
8915 @end smallexample
8916
8917 @noindent
8918 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8919 Of course access to the components of such an array is considerably
8920 less efficient than if the natural component size of 32 is used.
8921
8922 @node Bit_Order Clauses
8923 @section Bit_Order Clauses
8924 @cindex Bit_Order Clause
8925 @cindex bit ordering
8926 @cindex ordering, of bits
8927
8928 @noindent
8929 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8930 attribute.  The specification may either correspond to the default bit
8931 order for the target, in which case the specification has no effect and
8932 places no additional restrictions, or it may be for the non-standard
8933 setting (that is the opposite of the default).
8934
8935 In the case where the non-standard value is specified, the effect is
8936 to renumber bits within each byte, but the ordering of bytes is not
8937 affected.  There are certain
8938 restrictions placed on component clauses as follows:
8939
8940 @itemize @bullet
8941
8942 @item Components fitting within a single storage unit.
8943 @noindent
8944 These are unrestricted, and the effect is merely to renumber bits.  For
8945 example if we are on a little-endian machine with @code{Low_Order_First}
8946 being the default, then the following two declarations have exactly
8947 the same effect:
8948
8949 @smallexample @c ada
8950    type R1 is record
8951       A : Boolean;
8952       B : Integer range 1 .. 120;
8953    end record;
8954
8955    for R1 use record
8956       A at 0 range 0 .. 0;
8957       B at 0 range 1 .. 7;
8958    end record;
8959
8960    type R2 is record
8961       A : Boolean;
8962       B : Integer range 1 .. 120;
8963    end record;
8964
8965    for R2'Bit_Order use High_Order_First;
8966
8967    for R2 use record
8968       A at 0 range 7 .. 7;
8969       B at 0 range 0 .. 6;
8970    end record;
8971 @end smallexample
8972
8973 @noindent
8974 The useful application here is to write the second declaration with the
8975 @code{Bit_Order} attribute definition clause, and know that it will be treated
8976 the same, regardless of whether the target is little-endian or big-endian.
8977
8978 @item Components occupying an integral number of bytes.
8979 @noindent
8980 These are components that exactly fit in two or more bytes.  Such component
8981 declarations are allowed, but have no effect, since it is important to realize
8982 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8983 In particular, the following attempt at getting an endian-independent integer
8984 does not work:
8985
8986 @smallexample @c ada
8987    type R2 is record
8988       A : Integer;
8989    end record;
8990
8991    for R2'Bit_Order use High_Order_First;
8992
8993    for R2 use record
8994       A at 0 range 0 .. 31;
8995    end record;
8996 @end smallexample
8997
8998 @noindent
8999 This declaration will result in a little-endian integer on a
9000 little-endian machine, and a big-endian integer on a big-endian machine.
9001 If byte flipping is required for interoperability between big- and
9002 little-endian machines, this must be explicitly programmed.  This capability
9003 is not provided by @code{Bit_Order}.
9004
9005 @item Components that are positioned across byte boundaries
9006 @noindent
9007 but do not occupy an integral number of bytes.  Given that bytes are not
9008 reordered, such fields would occupy a non-contiguous sequence of bits
9009 in memory, requiring non-trivial code to reassemble.  They are for this
9010 reason not permitted, and any component clause specifying such a layout
9011 will be flagged as illegal by GNAT@.
9012
9013 @end itemize
9014
9015 @noindent
9016 Since the misconception that Bit_Order automatically deals with all
9017 endian-related incompatibilities is a common one, the specification of
9018 a component field that is an integral number of bytes will always
9019 generate a warning.  This warning may be suppressed using
9020 @code{pragma Suppress} if desired.  The following section contains additional
9021 details regarding the issue of byte ordering.
9022
9023 @node Effect of Bit_Order on Byte Ordering
9024 @section Effect of Bit_Order on Byte Ordering
9025 @cindex byte ordering
9026 @cindex ordering, of bytes
9027
9028 @noindent
9029 In this section we will review the effect of the @code{Bit_Order} attribute
9030 definition clause on byte ordering.  Briefly, it has no effect at all, but
9031 a detailed example will be helpful.  Before giving this
9032 example, let us review the precise
9033 definition of the effect of defining @code{Bit_Order}.  The effect of a
9034 non-standard bit order is described in section 15.5.3 of the Ada
9035 Reference Manual:
9036
9037 @quotation
9038 2   A bit ordering is a method of interpreting the meaning of
9039 the storage place attributes.
9040 @end quotation
9041
9042 @noindent
9043 To understand the precise definition of storage place attributes in
9044 this context, we visit section 13.5.1 of the manual:
9045
9046 @quotation
9047 13   A record_representation_clause (without the mod_clause)
9048 specifies the layout.  The storage place attributes (see 13.5.2)
9049 are taken from the values of the position, first_bit, and last_bit
9050 expressions after normalizing those values so that first_bit is
9051 less than Storage_Unit.
9052 @end quotation
9053
9054 @noindent
9055 The critical point here is that storage places are taken from
9056 the values after normalization, not before.  So the @code{Bit_Order}
9057 interpretation applies to normalized values.  The interpretation
9058 is described in the later part of the 15.5.3 paragraph:
9059
9060 @quotation
9061 2   A bit ordering is a method of interpreting the meaning of
9062 the storage place attributes.  High_Order_First (known in the
9063 vernacular as ``big endian'') means that the first bit of a
9064 storage element (bit 0) is the most significant bit (interpreting
9065 the sequence of bits that represent a component as an unsigned
9066 integer value).  Low_Order_First (known in the vernacular as
9067 ``little endian'') means the opposite: the first bit is the
9068 least significant.
9069 @end quotation
9070
9071 @noindent
9072 Note that the numbering is with respect to the bits of a storage
9073 unit.  In other words, the specification affects only the numbering
9074 of bits within a single storage unit.
9075
9076 We can make the effect clearer by giving an example.
9077
9078 Suppose that we have an external device which presents two bytes, the first
9079 byte presented, which is the first (low addressed byte) of the two byte
9080 record is called Master, and the second byte is called Slave.
9081
9082 The left most (most significant bit is called Control for each byte, and
9083 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9084 (least significant) bit.
9085
9086 On a big-endian machine, we can write the following representation clause
9087
9088 @smallexample @c ada
9089    type Data is record
9090       Master_Control : Bit;
9091       Master_V1      : Bit;
9092       Master_V2      : Bit;
9093       Master_V3      : Bit;
9094       Master_V4      : Bit;
9095       Master_V5      : Bit;
9096       Master_V6      : Bit;
9097       Master_V7      : Bit;
9098       Slave_Control  : Bit;
9099       Slave_V1       : Bit;
9100       Slave_V2       : Bit;
9101       Slave_V3       : Bit;
9102       Slave_V4       : Bit;
9103       Slave_V5       : Bit;
9104       Slave_V6       : Bit;
9105       Slave_V7       : Bit;
9106    end record;
9107
9108    for Data use record
9109       Master_Control at 0 range 0 .. 0;
9110       Master_V1      at 0 range 1 .. 1;
9111       Master_V2      at 0 range 2 .. 2;
9112       Master_V3      at 0 range 3 .. 3;
9113       Master_V4      at 0 range 4 .. 4;
9114       Master_V5      at 0 range 5 .. 5;
9115       Master_V6      at 0 range 6 .. 6;
9116       Master_V7      at 0 range 7 .. 7;
9117       Slave_Control  at 1 range 0 .. 0;
9118       Slave_V1       at 1 range 1 .. 1;
9119       Slave_V2       at 1 range 2 .. 2;
9120       Slave_V3       at 1 range 3 .. 3;
9121       Slave_V4       at 1 range 4 .. 4;
9122       Slave_V5       at 1 range 5 .. 5;
9123       Slave_V6       at 1 range 6 .. 6;
9124       Slave_V7       at 1 range 7 .. 7;
9125    end record;
9126 @end smallexample
9127
9128 @noindent
9129 Now if we move this to a little endian machine, then the bit ordering within
9130 the byte is backwards, so we have to rewrite the record rep clause as:
9131
9132 @smallexample @c ada
9133    for Data use record
9134       Master_Control at 0 range 7 .. 7;
9135       Master_V1      at 0 range 6 .. 6;
9136       Master_V2      at 0 range 5 .. 5;
9137       Master_V3      at 0 range 4 .. 4;
9138       Master_V4      at 0 range 3 .. 3;
9139       Master_V5      at 0 range 2 .. 2;
9140       Master_V6      at 0 range 1 .. 1;
9141       Master_V7      at 0 range 0 .. 0;
9142       Slave_Control  at 1 range 7 .. 7;
9143       Slave_V1       at 1 range 6 .. 6;
9144       Slave_V2       at 1 range 5 .. 5;
9145       Slave_V3       at 1 range 4 .. 4;
9146       Slave_V4       at 1 range 3 .. 3;
9147       Slave_V5       at 1 range 2 .. 2;
9148       Slave_V6       at 1 range 1 .. 1;
9149       Slave_V7       at 1 range 0 .. 0;
9150    end record;
9151 @end smallexample
9152
9153 @noindent
9154 It is a nuisance to have to rewrite the clause, especially if
9155 the code has to be maintained on both machines.  However,
9156 this is a case that we can handle with the
9157 @code{Bit_Order} attribute if it is implemented.
9158 Note that the implementation is not required on byte addressed
9159 machines, but it is indeed implemented in GNAT.
9160 This means that we can simply use the
9161 first record clause, together with the declaration
9162
9163 @smallexample @c ada
9164    for Data'Bit_Order use High_Order_First;
9165 @end smallexample
9166
9167 @noindent
9168 and the effect is what is desired, namely the layout is exactly the same,
9169 independent of whether the code is compiled on a big-endian or little-endian
9170 machine.
9171
9172 The important point to understand is that byte ordering is not affected.
9173 A @code{Bit_Order} attribute definition never affects which byte a field
9174 ends up in, only where it ends up in that byte.
9175 To make this clear, let us rewrite the record rep clause of the previous
9176 example as:
9177
9178 @smallexample @c ada
9179    for Data'Bit_Order use High_Order_First;
9180    for Data use record
9181       Master_Control at 0 range  0 .. 0;
9182       Master_V1      at 0 range  1 .. 1;
9183       Master_V2      at 0 range  2 .. 2;
9184       Master_V3      at 0 range  3 .. 3;
9185       Master_V4      at 0 range  4 .. 4;
9186       Master_V5      at 0 range  5 .. 5;
9187       Master_V6      at 0 range  6 .. 6;
9188       Master_V7      at 0 range  7 .. 7;
9189       Slave_Control  at 0 range  8 .. 8;
9190       Slave_V1       at 0 range  9 .. 9;
9191       Slave_V2       at 0 range 10 .. 10;
9192       Slave_V3       at 0 range 11 .. 11;
9193       Slave_V4       at 0 range 12 .. 12;
9194       Slave_V5       at 0 range 13 .. 13;
9195       Slave_V6       at 0 range 14 .. 14;
9196       Slave_V7       at 0 range 15 .. 15;
9197    end record;
9198 @end smallexample
9199
9200 @noindent
9201 This is exactly equivalent to saying (a repeat of the first example):
9202
9203 @smallexample @c ada
9204    for Data'Bit_Order use High_Order_First;
9205    for Data use record
9206       Master_Control at 0 range 0 .. 0;
9207       Master_V1      at 0 range 1 .. 1;
9208       Master_V2      at 0 range 2 .. 2;
9209       Master_V3      at 0 range 3 .. 3;
9210       Master_V4      at 0 range 4 .. 4;
9211       Master_V5      at 0 range 5 .. 5;
9212       Master_V6      at 0 range 6 .. 6;
9213       Master_V7      at 0 range 7 .. 7;
9214       Slave_Control  at 1 range 0 .. 0;
9215       Slave_V1       at 1 range 1 .. 1;
9216       Slave_V2       at 1 range 2 .. 2;
9217       Slave_V3       at 1 range 3 .. 3;
9218       Slave_V4       at 1 range 4 .. 4;
9219       Slave_V5       at 1 range 5 .. 5;
9220       Slave_V6       at 1 range 6 .. 6;
9221       Slave_V7       at 1 range 7 .. 7;
9222    end record;
9223 @end smallexample
9224
9225 @noindent
9226 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9227 field.  The storage place attributes are obtained by normalizing the
9228 values given so that the @code{First_Bit} value is less than 8.  After
9229 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9230 we specified in the other case.
9231
9232 Now one might expect that the @code{Bit_Order} attribute might affect
9233 bit numbering within the entire record component (two bytes in this
9234 case, thus affecting which byte fields end up in), but that is not
9235 the way this feature is defined, it only affects numbering of bits,
9236 not which byte they end up in.
9237
9238 Consequently it never makes sense to specify a starting bit number
9239 greater than 7 (for a byte addressable field) if an attribute
9240 definition for @code{Bit_Order} has been given, and indeed it
9241 may be actively confusing to specify such a value, so the compiler
9242 generates a warning for such usage.
9243
9244 If you do need to control byte ordering then appropriate conditional
9245 values must be used.  If in our example, the slave byte came first on
9246 some machines we might write:
9247
9248 @smallexample @c ada
9249    Master_Byte_First constant Boolean := @dots{};
9250
9251    Master_Byte : constant Natural :=
9252                    1 - Boolean'Pos (Master_Byte_First);
9253    Slave_Byte  : constant Natural :=
9254                    Boolean'Pos (Master_Byte_First);
9255
9256    for Data'Bit_Order use High_Order_First;
9257    for Data use record
9258       Master_Control at Master_Byte range 0 .. 0;
9259       Master_V1      at Master_Byte range 1 .. 1;
9260       Master_V2      at Master_Byte range 2 .. 2;
9261       Master_V3      at Master_Byte range 3 .. 3;
9262       Master_V4      at Master_Byte range 4 .. 4;
9263       Master_V5      at Master_Byte range 5 .. 5;
9264       Master_V6      at Master_Byte range 6 .. 6;
9265       Master_V7      at Master_Byte range 7 .. 7;
9266       Slave_Control  at Slave_Byte  range 0 .. 0;
9267       Slave_V1       at Slave_Byte  range 1 .. 1;
9268       Slave_V2       at Slave_Byte  range 2 .. 2;
9269       Slave_V3       at Slave_Byte  range 3 .. 3;
9270       Slave_V4       at Slave_Byte  range 4 .. 4;
9271       Slave_V5       at Slave_Byte  range 5 .. 5;
9272       Slave_V6       at Slave_Byte  range 6 .. 6;
9273       Slave_V7       at Slave_Byte  range 7 .. 7;
9274    end record;
9275 @end smallexample
9276
9277 @noindent
9278 Now to switch between machines, all that is necessary is
9279 to set the boolean constant @code{Master_Byte_First} in
9280 an appropriate manner.
9281
9282 @node Pragma Pack for Arrays
9283 @section Pragma Pack for Arrays
9284 @cindex Pragma Pack (for arrays)
9285
9286 @noindent
9287 Pragma @code{Pack} applied to an array has no effect unless the component type
9288 is packable.  For a component type to be packable, it must be one of the
9289 following cases:
9290
9291 @itemize @bullet
9292 @item
9293 Any scalar type
9294 @item
9295 Any type whose size is specified with a size clause
9296 @item
9297 Any packed array type with a static size
9298 @end itemize
9299
9300 @noindent
9301 For all these cases, if the component subtype size is in the range
9302 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9303 component size were specified giving the component subtype size.
9304 For example if we have:
9305
9306 @smallexample @c ada
9307    type r is range 0 .. 17;
9308
9309    type ar is array (1 .. 8) of r;
9310    pragma Pack (ar);
9311 @end smallexample
9312
9313 @noindent
9314 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9315 and the size of the array @code{ar} will be exactly 40 bits.
9316
9317 Note that in some cases this rather fierce approach to packing can produce
9318 unexpected effects.  For example, in Ada 95, type Natural typically has a
9319 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9320 close packing, which saves a few bits, but results in far less efficient
9321 access.  Since many other Ada compilers will ignore such a packing request,
9322 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9323 might not be what is intended.  You can easily remove this warning by
9324 using an explicit @code{Component_Size} setting instead, which never generates
9325 a warning, since the intention of the programmer is clear in this case.
9326
9327 GNAT treats packed arrays in one of two ways.  If the size of the array is
9328 known at compile time and is less than 64 bits, then internally the array
9329 is represented as a single modular type, of exactly the appropriate number
9330 of bits.  If the length is greater than 63 bits, or is not known at compile
9331 time, then the packed array is represented as an array of bytes, and the
9332 length is always a multiple of 8 bits.
9333
9334 Note that to represent a packed array as a modular type, the alignment must
9335 be suitable for the modular type involved. For example, on typical machines
9336 a 32-bit packed array will be represented by a 32-bit modular integer with
9337 an alignment of four bytes. If you explicitly override the default alignment
9338 with an alignment clause that is too small, the modular representation
9339 cannot be used. For example, consider the following set of declarations:
9340
9341 @smallexample @c ada
9342    type R is range 1 .. 3;
9343    type S is array (1 .. 31) of R;
9344    for S'Component_Size use 2;
9345    for S'Size use 62;
9346    for S'Alignment use 1;
9347 @end smallexample
9348
9349 @noindent
9350 If the alignment clause were not present, then a 62-bit modular
9351 representation would be chosen (typically with an alignment of 4 or 8
9352 bytes depending on the target). But the default alignment is overridden
9353 with the explicit alignment clause. This means that the modular
9354 representation cannot be used, and instead the array of bytes
9355 representation must be used, meaning that the length must be a multiple
9356 of 8. Thus the above set of declarations will result in a diagnostic
9357 rejecting the size clause and noting that the minimum size allowed is 64.
9358
9359 @cindex Pragma Pack (for type Natural)
9360 @cindex Pragma Pack warning
9361
9362 One special case that is worth noting occurs when the base type of the
9363 component size is 8/16/32 and the subtype is one bit less. Notably this
9364 occurs with subtype @code{Natural}. Consider:
9365
9366 @smallexample @c ada
9367    type Arr is array (1 .. 32) of Natural;
9368    pragma Pack (Arr);
9369 @end smallexample
9370
9371 @noindent
9372 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9373 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9374 Ada 83 compilers did not attempt 31 bit packing.
9375
9376 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9377 does pack 31-bit subtype to 31 bits. This may result in a substantial
9378 unintended performance penalty when porting legacy Ada 83 code. To help
9379 prevent this, GNAT generates a warning in such cases. If you really want 31
9380 bit packing in a case like this, you can set the component size explicitly:
9381
9382 @smallexample @c ada
9383    type Arr is array (1 .. 32) of Natural;
9384    for Arr'Component_Size use 31;
9385 @end smallexample
9386
9387 @noindent
9388 Here 31-bit packing is achieved as required, and no warning is generated,
9389 since in this case the programmer intention is clear.
9390
9391 @node Pragma Pack for Records
9392 @section Pragma Pack for Records
9393 @cindex Pragma Pack (for records)
9394
9395 @noindent
9396 Pragma @code{Pack} applied to a record will pack the components to reduce
9397 wasted space from alignment gaps and by reducing the amount of space
9398 taken by components.  We distinguish between @emph{packable} components and
9399 @emph{non-packable} components.
9400 Components of the following types are considered packable:
9401 @itemize @bullet
9402 @item
9403 All primitive types are packable.
9404
9405 @item
9406 Small packed arrays, whose size does not exceed 64 bits, and where the
9407 size is statically known at compile time, are represented internally
9408 as modular integers, and so they are also packable.
9409
9410 @end itemize
9411
9412 @noindent
9413 All packable components occupy the exact number of bits corresponding to
9414 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9415 can start on an arbitrary bit boundary.
9416
9417 All other types are non-packable, they occupy an integral number of
9418 storage units, and
9419 are placed at a boundary corresponding to their alignment requirements.
9420
9421 For example, consider the record
9422
9423 @smallexample @c ada
9424    type Rb1 is array (1 .. 13) of Boolean;
9425    pragma Pack (rb1);
9426
9427    type Rb2 is array (1 .. 65) of Boolean;
9428    pragma Pack (rb2);
9429
9430    type x2 is record
9431       l1 : Boolean;
9432       l2 : Duration;
9433       l3 : Float;
9434       l4 : Boolean;
9435       l5 : Rb1;
9436       l6 : Rb2;
9437    end record;
9438    pragma Pack (x2);
9439 @end smallexample
9440
9441 @noindent
9442 The representation for the record x2 is as follows:
9443
9444 @smallexample @c ada
9445 for x2'Size use 224;
9446 for x2 use record
9447    l1 at  0 range  0 .. 0;
9448    l2 at  0 range  1 .. 64;
9449    l3 at 12 range  0 .. 31;
9450    l4 at 16 range  0 .. 0;
9451    l5 at 16 range  1 .. 13;
9452    l6 at 18 range  0 .. 71;
9453 end record;
9454 @end smallexample
9455
9456 @noindent
9457 Studying this example, we see that the packable fields @code{l1}
9458 and @code{l2} are
9459 of length equal to their sizes, and placed at specific bit boundaries (and
9460 not byte boundaries) to
9461 eliminate padding.  But @code{l3} is of a non-packable float type, so
9462 it is on the next appropriate alignment boundary.
9463
9464 The next two fields are fully packable, so @code{l4} and @code{l5} are
9465 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9466 array that is longer than 64 bits, so it is itself non-packable.  Thus
9467 the @code{l6} field is aligned to the next byte boundary, and takes an
9468 integral number of bytes, i.e.@: 72 bits.
9469
9470 @node Record Representation Clauses
9471 @section Record Representation Clauses
9472 @cindex Record Representation Clause
9473
9474 @noindent
9475 Record representation clauses may be given for all record types, including
9476 types obtained by record extension.  Component clauses are allowed for any
9477 static component.  The restrictions on component clauses depend on the type
9478 of the component.
9479
9480 @cindex Component Clause
9481 For all components of an elementary type, the only restriction on component
9482 clauses is that the size must be at least the 'Size value of the type
9483 (actually the Value_Size).  There are no restrictions due to alignment,
9484 and such components may freely cross storage boundaries.
9485
9486 Packed arrays with a size up to and including 64 bits are represented
9487 internally using a modular type with the appropriate number of bits, and
9488 thus the same lack of restriction applies.  For example, if you declare:
9489
9490 @smallexample @c ada
9491    type R is array (1 .. 49) of Boolean;
9492    pragma Pack (R);
9493    for R'Size use 49;
9494 @end smallexample
9495
9496 @noindent
9497 then a component clause for a component of type R may start on any
9498 specified bit boundary, and may specify a value of 49 bits or greater.
9499
9500 Packed bit arrays that are longer than 64 bits must always be placed
9501 on a storage unit (byte) boundary. Any component clause that does not
9502 meet this requirement will be rejected.
9503
9504 The rules for other types are different for GNAT 3 and GNAT 5 versions
9505 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9506 (other than packed arrays)
9507 may also be placed on arbitrary boundaries, so for example, the following
9508 is permitted:
9509
9510 @smallexample @c ada
9511    type R is array (1 .. 10) of Boolean;
9512    for R'Size use 80;
9513
9514    type Q is record
9515       G, H : Boolean;
9516       L, M : R;
9517    end record;
9518
9519    for Q use record
9520       G at 0 range  0 ..   0;
9521       H at 0 range  1 ..   1;
9522       L at 0 range  2 ..  81;
9523       R at 0 range 82 .. 161;
9524    end record;
9525 @end smallexample
9526
9527 @noindent
9528 In GNAT 3, there are more severe restrictions on larger components.
9529 For non-primitive types, including packed arrays with a size greater than
9530 64 bits, component clauses must respect the alignment requirement of the
9531 type, in particular, always starting on a byte boundary, and the length
9532 must be a multiple of the storage unit.
9533
9534 The following rules regarding tagged types are enforced in both GNAT 3 and
9535 GNAT 5:
9536
9537 The tag field of a tagged type always occupies an address sized field at
9538 the start of the record.  No component clause may attempt to overlay this
9539 tag.
9540
9541 In the case of a record extension T1, of a type T, no component clause applied
9542 to the type T1 can specify a storage location that would overlap the first
9543 T'Size bytes of the record.
9544
9545 @node Enumeration Clauses
9546 @section Enumeration Clauses
9547
9548 The only restriction on enumeration clauses is that the range of values
9549 must be representable.  For the signed case, if one or more of the
9550 representation values are negative, all values must be in the range:
9551
9552 @smallexample @c ada
9553    System.Min_Int .. System.Max_Int
9554 @end smallexample
9555
9556 @noindent
9557 For the unsigned case, where all values are non negative, the values must
9558 be in the range:
9559
9560 @smallexample @c ada
9561    0 .. System.Max_Binary_Modulus;
9562 @end smallexample
9563
9564 @noindent
9565 A @emph{confirming} representation clause is one in which the values range
9566 from 0 in sequence, i.e.@: a clause that confirms the default representation
9567 for an enumeration type.
9568 Such a confirming representation
9569 is permitted by these rules, and is specially recognized by the compiler so
9570 that no extra overhead results from the use of such a clause.
9571
9572 If an array has an index type which is an enumeration type to which an
9573 enumeration clause has been applied, then the array is stored in a compact
9574 manner.  Consider the declarations:
9575
9576 @smallexample @c ada
9577    type r is (A, B, C);
9578    for r use (A => 1, B => 5, C => 10);
9579    type t is array (r) of Character;
9580 @end smallexample
9581
9582 @noindent
9583 The array type t corresponds to a vector with exactly three elements and
9584 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9585 use of space, but means that accesses to elements of the array will incur
9586 the overhead of converting representation values to the corresponding
9587 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9588
9589 @node Address Clauses
9590 @section Address Clauses
9591 @cindex Address Clause
9592
9593 The reference manual allows a general restriction on representation clauses,
9594 as found in RM 13.1(22):
9595
9596 @quotation
9597 An implementation need not support representation
9598 items containing nonstatic expressions, except that
9599 an implementation should support a representation item
9600 for a given entity if each nonstatic expression in the
9601 representation item is a name that statically denotes
9602 a constant declared before the entity.
9603 @end quotation
9604
9605 @noindent
9606 In practice this is applicable only to address clauses, since this is the
9607 only case in which a non-static expression is permitted by the syntax.  As
9608 the AARM notes in sections 13.1 (22.a-22.h):
9609
9610 @display
9611   22.a   Reason: This is to avoid the following sort of thing:
9612
9613   22.b        X : Integer := F(@dots{});
9614               Y : Address := G(@dots{});
9615               for X'Address use Y;
9616
9617   22.c   In the above, we have to evaluate the
9618          initialization expression for X before we
9619          know where to put the result.  This seems
9620          like an unreasonable implementation burden.
9621
9622   22.d   The above code should instead be written
9623          like this:
9624
9625   22.e        Y : constant Address := G(@dots{});
9626               X : Integer := F(@dots{});
9627               for X'Address use Y;
9628
9629   22.f   This allows the expression ``Y'' to be safely
9630          evaluated before X is created.
9631
9632   22.g   The constant could be a formal parameter of mode in.
9633
9634   22.h   An implementation can support other nonstatic
9635          expressions if it wants to.  Expressions of type
9636          Address are hardly ever static, but their value
9637          might be known at compile time anyway in many
9638          cases.
9639 @end display
9640
9641 @noindent
9642 GNAT does indeed permit many additional cases of non-static expressions.  In
9643 particular, if the type involved is elementary there are no restrictions
9644 (since in this case, holding a temporary copy of the initialization value,
9645 if one is present, is inexpensive).  In addition, if there is no implicit or
9646 explicit initialization, then there are no restrictions.  GNAT will reject
9647 only the case where all three of these conditions hold:
9648
9649 @itemize @bullet
9650
9651 @item
9652 The type of the item is non-elementary (e.g.@: a record or array).
9653
9654 @item
9655 There is explicit or implicit initialization required for the object.
9656 Note that access values are always implicitly initialized, and also
9657 in GNAT, certain bit-packed arrays (those having a dynamic length or
9658 a length greater than 64) will also be implicitly initialized to zero.
9659
9660 @item
9661 The address value is non-static.  Here GNAT is more permissive than the
9662 RM, and allows the address value to be the address of a previously declared
9663 stand-alone variable, as long as it does not itself have an address clause.
9664
9665 @smallexample @c ada
9666            Anchor  : Some_Initialized_Type;
9667            Overlay : Some_Initialized_Type;
9668            for Overlay'Address use Anchor'Address;
9669 @end smallexample
9670
9671 @noindent
9672 However, the prefix of the address clause cannot be an array component, or
9673 a component of a discriminated record.
9674
9675 @end itemize
9676
9677 @noindent
9678 As noted above in section 22.h, address values are typically non-static.  In
9679 particular the To_Address function, even if applied to a literal value, is
9680 a non-static function call.  To avoid this minor annoyance, GNAT provides
9681 the implementation defined attribute 'To_Address.  The following two
9682 expressions have identical values:
9683
9684 @findex Attribute
9685 @findex To_Address
9686 @smallexample @c ada
9687    To_Address (16#1234_0000#)
9688    System'To_Address (16#1234_0000#);
9689 @end smallexample
9690
9691 @noindent
9692 except that the second form is considered to be a static expression, and
9693 thus when used as an address clause value is always permitted.
9694
9695 @noindent
9696 Additionally, GNAT treats as static an address clause that is an
9697 unchecked_conversion of a static integer value.  This simplifies the porting
9698 of legacy code, and provides a portable equivalent to the GNAT attribute
9699 @code{To_Address}.
9700
9701 Another issue with address clauses is the interaction with alignment
9702 requirements.  When an address clause is given for an object, the address
9703 value must be consistent with the alignment of the object (which is usually
9704 the same as the alignment of the type of the object).  If an address clause
9705 is given that specifies an inappropriately aligned address value, then the
9706 program execution is erroneous.
9707
9708 Since this source of erroneous behavior can have unfortunate effects, GNAT
9709 checks (at compile time if possible, generating a warning, or at execution
9710 time with a run-time check) that the alignment is appropriate.  If the
9711 run-time check fails, then @code{Program_Error} is raised.  This run-time
9712 check is suppressed if range checks are suppressed, or if
9713 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9714
9715 @findex Export
9716 An address clause cannot be given for an exported object.  More
9717 understandably the real restriction is that objects with an address
9718 clause cannot be exported.  This is because such variables are not
9719 defined by the Ada program, so there is no external object to export.
9720
9721 @findex Import
9722 It is permissible to give an address clause and a pragma Import for the
9723 same object.  In this case, the variable is not really defined by the
9724 Ada program, so there is no external symbol to be linked.  The link name
9725 and the external name are ignored in this case.  The reason that we allow this
9726 combination is that it provides a useful idiom to avoid unwanted
9727 initializations on objects with address clauses.
9728
9729 When an address clause is given for an object that has implicit or
9730 explicit initialization, then by default initialization takes place.  This
9731 means that the effect of the object declaration is to overwrite the
9732 memory at the specified address.  This is almost always not what the
9733 programmer wants, so GNAT will output a warning:
9734
9735 @smallexample
9736   with System;
9737   package G is
9738      type R is record
9739         M : Integer := 0;
9740      end record;
9741
9742      Ext : R;
9743      for Ext'Address use System'To_Address (16#1234_1234#);
9744          |
9745   >>> warning: implicit initialization of "Ext" may
9746       modify overlaid storage
9747   >>> warning: use pragma Import for "Ext" to suppress
9748       initialization (RM B(24))
9749
9750   end G;
9751 @end smallexample
9752
9753 @noindent
9754 As indicated by the warning message, the solution is to use a (dummy) pragma
9755 Import to suppress this initialization.  The pragma tell the compiler that the
9756 object is declared and initialized elsewhere.  The following package compiles
9757 without warnings (and the initialization is suppressed):
9758
9759 @smallexample @c ada
9760    with System;
9761    package G is
9762       type R is record
9763          M : Integer := 0;
9764       end record;
9765
9766       Ext : R;
9767       for Ext'Address use System'To_Address (16#1234_1234#);
9768       pragma Import (Ada, Ext);
9769    end G;
9770 @end smallexample
9771
9772 @noindent
9773 A final issue with address clauses involves their use for overlaying
9774 variables, as in the following example:
9775 @cindex Overlaying of objects
9776
9777 @smallexample @c ada
9778   A : Integer;
9779   B : Integer;
9780   for B'Address use A'Address;
9781 @end smallexample
9782
9783 @noindent
9784 or alternatively, using the form recommended by the RM:
9785
9786 @smallexample @c ada
9787   A    : Integer;
9788   Addr : constant Address := A'Address;
9789   B    : Integer;
9790   for B'Address use Addr;
9791 @end smallexample
9792
9793 @noindent
9794 In both of these cases, @code{A}
9795 and @code{B} become aliased to one another via the
9796 address clause. This use of address clauses to overlay
9797 variables, achieving an effect similar to unchecked
9798 conversion was erroneous in Ada 83, but in Ada 95
9799 the effect is implementation defined. Furthermore, the
9800 Ada 95 RM specifically recommends that in a situation
9801 like this, @code{B} should be subject to the following
9802 implementation advice (RM 13.3(19)):
9803
9804 @quotation
9805 19  If the Address of an object is specified, or it is imported
9806     or exported, then the implementation should not perform
9807     optimizations based on assumptions of no aliases.
9808 @end quotation
9809
9810 @noindent
9811 GNAT follows this recommendation, and goes further by also applying
9812 this recommendation to the overlaid variable (@code{A}
9813 in the above example) in this case. This means that the overlay
9814 works "as expected", in that a modification to one of the variables
9815 will affect the value of the other.
9816
9817 @node Effect of Convention on Representation
9818 @section Effect of Convention on Representation
9819 @cindex Convention, effect on representation
9820
9821 @noindent
9822 Normally the specification of a foreign language convention for a type or
9823 an object has no effect on the chosen representation.  In particular, the
9824 representation chosen for data in GNAT generally meets the standard system
9825 conventions, and for example records are laid out in a manner that is
9826 consistent with C@.  This means that specifying convention C (for example)
9827 has no effect.
9828
9829 There are three exceptions to this general rule:
9830
9831 @itemize @bullet
9832
9833 @item Convention Fortran and array subtypes
9834 If pragma Convention Fortran is specified for an array subtype, then in
9835 accordance with the implementation advice in section 3.6.2(11) of the
9836 Ada Reference Manual, the array will be stored in a Fortran-compatible
9837 column-major manner, instead of the normal default row-major order.
9838
9839 @item Convention C and enumeration types
9840 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9841 to accommodate all values of the type.  For example, for the enumeration
9842 type declared by:
9843
9844 @smallexample @c ada
9845    type Color is (Red, Green, Blue);
9846 @end smallexample
9847
9848 @noindent
9849 8 bits is sufficient to store all values of the type, so by default, objects
9850 of type @code{Color} will be represented using 8 bits.  However, normal C
9851 convention is to use 32 bits for all enum values in C, since enum values
9852 are essentially of type int.  If pragma @code{Convention C} is specified for an
9853 Ada enumeration type, then the size is modified as necessary (usually to
9854 32 bits) to be consistent with the C convention for enum values.
9855
9856 @item Convention C/Fortran and Boolean types
9857 In C, the usual convention for boolean values, that is values used for
9858 conditions, is that zero represents false, and nonzero values represent
9859 true.  In Ada, the normal convention is that two specific values, typically
9860 0/1, are used to represent false/true respectively.
9861
9862 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9863 value represents true).
9864
9865 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9866 C or Fortran convention for a derived Boolean, as in the following example:
9867
9868 @smallexample @c ada
9869    type C_Switch is new Boolean;
9870    pragma Convention (C, C_Switch);
9871 @end smallexample
9872
9873 @noindent
9874 then the GNAT generated code will treat any nonzero value as true.  For truth
9875 values generated by GNAT, the conventional value 1 will be used for True, but
9876 when one of these values is read, any nonzero value is treated as True.
9877
9878 @end itemize
9879
9880 @node Determining the Representations chosen by GNAT
9881 @section Determining the Representations chosen by GNAT
9882 @cindex Representation, determination of
9883 @cindex @code{-gnatR} switch
9884
9885 @noindent
9886 Although the descriptions in this section are intended to be complete, it is
9887 often easier to simply experiment to see what GNAT accepts and what the
9888 effect is on the layout of types and objects.
9889
9890 As required by the Ada RM, if a representation clause is not accepted, then
9891 it must be rejected as illegal by the compiler.  However, when a
9892 representation clause or pragma is accepted, there can still be questions
9893 of what the compiler actually does.  For example, if a partial record
9894 representation clause specifies the location of some components and not
9895 others, then where are the non-specified components placed? Or if pragma
9896 @code{Pack} is used on a record, then exactly where are the resulting
9897 fields placed? The section on pragma @code{Pack} in this chapter can be
9898 used to answer the second question, but it is often easier to just see
9899 what the compiler does.
9900
9901 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9902 with this option, then the compiler will output information on the actual
9903 representations chosen, in a format similar to source representation
9904 clauses.  For example, if we compile the package:
9905
9906 @smallexample @c ada
9907 package q is
9908    type r (x : boolean) is tagged record
9909       case x is
9910          when True => S : String (1 .. 100);
9911          when False => null;
9912       end case;
9913    end record;
9914
9915    type r2 is new r (false) with record
9916       y2 : integer;
9917    end record;
9918
9919    for r2 use record
9920       y2 at 16 range 0 .. 31;
9921    end record;
9922
9923    type x is record
9924       y : character;
9925    end record;
9926
9927    type x1 is array (1 .. 10) of x;
9928    for x1'component_size use 11;
9929
9930    type ia is access integer;
9931
9932    type Rb1 is array (1 .. 13) of Boolean;
9933    pragma Pack (rb1);
9934
9935    type Rb2 is array (1 .. 65) of Boolean;
9936    pragma Pack (rb2);
9937
9938    type x2 is record
9939       l1 : Boolean;
9940       l2 : Duration;
9941       l3 : Float;
9942       l4 : Boolean;
9943       l5 : Rb1;
9944       l6 : Rb2;
9945    end record;
9946    pragma Pack (x2);
9947 end q;
9948 @end smallexample
9949
9950 @noindent
9951 using the switch @code{-gnatR} we obtain the following output:
9952
9953 @smallexample
9954 Representation information for unit q
9955 -------------------------------------
9956
9957 for r'Size use ??;
9958 for r'Alignment use 4;
9959 for r use record
9960    x    at 4 range  0 .. 7;
9961    _tag at 0 range  0 .. 31;
9962    s    at 5 range  0 .. 799;
9963 end record;
9964
9965 for r2'Size use 160;
9966 for r2'Alignment use 4;
9967 for r2 use record
9968    x       at  4 range  0 .. 7;
9969    _tag    at  0 range  0 .. 31;
9970    _parent at  0 range  0 .. 63;
9971    y2      at 16 range  0 .. 31;
9972 end record;
9973
9974 for x'Size use 8;
9975 for x'Alignment use 1;
9976 for x use record
9977    y at 0 range  0 .. 7;
9978 end record;
9979
9980 for x1'Size use 112;
9981 for x1'Alignment use 1;
9982 for x1'Component_Size use 11;
9983
9984 for rb1'Size use 13;
9985 for rb1'Alignment use 2;
9986 for rb1'Component_Size use 1;
9987
9988 for rb2'Size use 72;
9989 for rb2'Alignment use 1;
9990 for rb2'Component_Size use 1;
9991
9992 for x2'Size use 224;
9993 for x2'Alignment use 4;
9994 for x2 use record
9995    l1 at  0 range  0 .. 0;
9996    l2 at  0 range  1 .. 64;
9997    l3 at 12 range  0 .. 31;
9998    l4 at 16 range  0 .. 0;
9999    l5 at 16 range  1 .. 13;
10000    l6 at 18 range  0 .. 71;
10001 end record;
10002 @end smallexample
10003
10004 @noindent
10005 The Size values are actually the Object_Size, i.e.@: the default size that
10006 will be allocated for objects of the type.
10007 The ?? size for type r indicates that we have a variant record, and the
10008 actual size of objects will depend on the discriminant value.
10009
10010 The Alignment values show the actual alignment chosen by the compiler
10011 for each record or array type.
10012
10013 The record representation clause for type r shows where all fields
10014 are placed, including the compiler generated tag field (whose location
10015 cannot be controlled by the programmer).
10016
10017 The record representation clause for the type extension r2 shows all the
10018 fields present, including the parent field, which is a copy of the fields
10019 of the parent type of r2, i.e.@: r1.
10020
10021 The component size and size clauses for types rb1 and rb2 show
10022 the exact effect of pragma @code{Pack} on these arrays, and the record
10023 representation clause for type x2 shows how pragma @code{Pack} affects
10024 this record type.
10025
10026 In some cases, it may be useful to cut and paste the representation clauses
10027 generated by the compiler into the original source to fix and guarantee
10028 the actual representation to be used.
10029
10030 @node Standard Library Routines
10031 @chapter Standard Library Routines
10032
10033 @noindent
10034 The Ada 95 Reference Manual contains in Annex A a full description of an
10035 extensive set of standard library routines that can be used in any Ada
10036 program, and which must be provided by all Ada compilers.  They are
10037 analogous to the standard C library used by C programs.
10038
10039 GNAT implements all of the facilities described in annex A, and for most
10040 purposes the description in the Ada 95
10041 reference manual, or appropriate Ada
10042 text book, will be sufficient for making use of these facilities.
10043
10044 In the case of the input-output facilities, @xref{The Implementation of
10045 Standard I/O}, gives details on exactly how GNAT interfaces to the
10046 file system.  For the remaining packages, the Ada 95 reference manual
10047 should be sufficient.  The following is a list of the packages included,
10048 together with a brief description of the functionality that is provided.
10049
10050 For completeness, references are included to other predefined library
10051 routines defined in other sections of the Ada 95 reference manual (these are
10052 cross-indexed from annex A).
10053
10054 @table @code
10055 @item Ada (A.2)
10056 This is a parent package for all the standard library packages.  It is
10057 usually included implicitly in your program, and itself contains no
10058 useful data or routines.
10059
10060 @item Ada.Calendar (9.6)
10061 @code{Calendar} provides time of day access, and routines for
10062 manipulating times and durations.
10063
10064 @item Ada.Characters (A.3.1)
10065 This is a dummy parent package that contains no useful entities
10066
10067 @item Ada.Characters.Handling (A.3.2)
10068 This package provides some basic character handling capabilities,
10069 including classification functions for classes of characters (e.g.@: test
10070 for letters, or digits).
10071
10072 @item Ada.Characters.Latin_1 (A.3.3)
10073 This package includes a complete set of definitions of the characters
10074 that appear in type CHARACTER@.  It is useful for writing programs that
10075 will run in international environments.  For example, if you want an
10076 upper case E with an acute accent in a string, it is often better to use
10077 the definition of @code{UC_E_Acute} in this package.  Then your program
10078 will print in an understandable manner even if your environment does not
10079 support these extended characters.
10080
10081 @item Ada.Command_Line (A.15)
10082 This package provides access to the command line parameters and the name
10083 of the current program (analogous to the use of @code{argc} and @code{argv}
10084 in C), and also allows the exit status for the program to be set in a
10085 system-independent manner.
10086
10087 @item Ada.Decimal (F.2)
10088 This package provides constants describing the range of decimal numbers
10089 implemented, and also a decimal divide routine (analogous to the COBOL
10090 verb DIVIDE .. GIVING .. REMAINDER ..)
10091
10092 @item Ada.Direct_IO (A.8.4)
10093 This package provides input-output using a model of a set of records of
10094 fixed-length, containing an arbitrary definite Ada type, indexed by an
10095 integer record number.
10096
10097 @item Ada.Dynamic_Priorities (D.5)
10098 This package allows the priorities of a task to be adjusted dynamically
10099 as the task is running.
10100
10101 @item Ada.Exceptions (11.4.1)
10102 This package provides additional information on exceptions, and also
10103 contains facilities for treating exceptions as data objects, and raising
10104 exceptions with associated messages.
10105
10106 @item Ada.Finalization (7.6)
10107 This package contains the declarations and subprograms to support the
10108 use of controlled types, providing for automatic initialization and
10109 finalization (analogous to the constructors and destructors of C++)
10110
10111 @item Ada.Interrupts (C.3.2)
10112 This package provides facilities for interfacing to interrupts, which
10113 includes the set of signals or conditions that can be raised and
10114 recognized as interrupts.
10115
10116 @item Ada.Interrupts.Names (C.3.2)
10117 This package provides the set of interrupt names (actually signal
10118 or condition names) that can be handled by GNAT@.
10119
10120 @item Ada.IO_Exceptions (A.13)
10121 This package defines the set of exceptions that can be raised by use of
10122 the standard IO packages.
10123
10124 @item Ada.Numerics
10125 This package contains some standard constants and exceptions used
10126 throughout the numerics packages.  Note that the constants pi and e are
10127 defined here, and it is better to use these definitions than rolling
10128 your own.
10129
10130 @item Ada.Numerics.Complex_Elementary_Functions
10131 Provides the implementation of standard elementary functions (such as
10132 log and trigonometric functions) operating on complex numbers using the
10133 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10134 created by the package @code{Numerics.Complex_Types}.
10135
10136 @item Ada.Numerics.Complex_Types
10137 This is a predefined instantiation of
10138 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10139 build the type @code{Complex} and @code{Imaginary}.
10140
10141 @item Ada.Numerics.Discrete_Random
10142 This package provides a random number generator suitable for generating
10143 random integer values from a specified range.
10144
10145 @item Ada.Numerics.Float_Random
10146 This package provides a random number generator suitable for generating
10147 uniformly distributed floating point values.
10148
10149 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10150 This is a generic version of the package that provides the
10151 implementation of standard elementary functions (such as log and
10152 trigonometric functions) for an arbitrary complex type.
10153
10154 The following predefined instantiations of this package are provided:
10155
10156 @table @code
10157 @item Short_Float
10158 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10159 @item Float
10160 @code{Ada.Numerics.Complex_Elementary_Functions}
10161 @item Long_Float
10162 @code{Ada.Numerics.
10163  Long_Complex_Elementary_Functions}
10164 @end table
10165
10166 @item Ada.Numerics.Generic_Complex_Types
10167 This is a generic package that allows the creation of complex types,
10168 with associated complex arithmetic operations.
10169
10170 The following predefined instantiations of this package exist
10171 @table @code
10172 @item Short_Float
10173 @code{Ada.Numerics.Short_Complex_Complex_Types}
10174 @item Float
10175 @code{Ada.Numerics.Complex_Complex_Types}
10176 @item Long_Float
10177 @code{Ada.Numerics.Long_Complex_Complex_Types}
10178 @end table
10179
10180 @item Ada.Numerics.Generic_Elementary_Functions
10181 This is a generic package that provides the implementation of standard
10182 elementary functions (such as log an trigonometric functions) for an
10183 arbitrary float type.
10184
10185 The following predefined instantiations of this package exist
10186
10187 @table @code
10188 @item Short_Float
10189 @code{Ada.Numerics.Short_Elementary_Functions}
10190 @item Float
10191 @code{Ada.Numerics.Elementary_Functions}
10192 @item Long_Float
10193 @code{Ada.Numerics.Long_Elementary_Functions}
10194 @end table
10195
10196 @item Ada.Real_Time (D.8)
10197 This package provides facilities similar to those of @code{Calendar}, but
10198 operating with a finer clock suitable for real time control. Note that
10199 annex D requires that there be no backward clock jumps, and GNAT generally
10200 guarantees this behavior, but of course if the external clock on which
10201 the GNAT runtime depends is deliberately reset by some external event,
10202 then such a backward jump may occur.
10203
10204 @item Ada.Sequential_IO (A.8.1)
10205 This package provides input-output facilities for sequential files,
10206 which can contain a sequence of values of a single type, which can be
10207 any Ada type, including indefinite (unconstrained) types.
10208
10209 @item Ada.Storage_IO (A.9)
10210 This package provides a facility for mapping arbitrary Ada types to and
10211 from a storage buffer.  It is primarily intended for the creation of new
10212 IO packages.
10213
10214 @item Ada.Streams (13.13.1)
10215 This is a generic package that provides the basic support for the
10216 concept of streams as used by the stream attributes (@code{Input},
10217 @code{Output}, @code{Read} and @code{Write}).
10218
10219 @item Ada.Streams.Stream_IO (A.12.1)
10220 This package is a specialization of the type @code{Streams} defined in
10221 package @code{Streams} together with a set of operations providing
10222 Stream_IO capability.  The Stream_IO model permits both random and
10223 sequential access to a file which can contain an arbitrary set of values
10224 of one or more Ada types.
10225
10226 @item Ada.Strings (A.4.1)
10227 This package provides some basic constants used by the string handling
10228 packages.
10229
10230 @item Ada.Strings.Bounded (A.4.4)
10231 This package provides facilities for handling variable length
10232 strings.  The bounded model requires a maximum length.  It is thus
10233 somewhat more limited than the unbounded model, but avoids the use of
10234 dynamic allocation or finalization.
10235
10236 @item Ada.Strings.Fixed (A.4.3)
10237 This package provides facilities for handling fixed length strings.
10238
10239 @item Ada.Strings.Maps (A.4.2)
10240 This package provides facilities for handling character mappings and
10241 arbitrarily defined subsets of characters.  For instance it is useful in
10242 defining specialized translation tables.
10243
10244 @item Ada.Strings.Maps.Constants (A.4.6)
10245 This package provides a standard set of predefined mappings and
10246 predefined character sets.  For example, the standard upper to lower case
10247 conversion table is found in this package.  Note that upper to lower case
10248 conversion is non-trivial if you want to take the entire set of
10249 characters, including extended characters like E with an acute accent,
10250 into account.  You should use the mappings in this package (rather than
10251 adding 32 yourself) to do case mappings.
10252
10253 @item Ada.Strings.Unbounded (A.4.5)
10254 This package provides facilities for handling variable length
10255 strings.  The unbounded model allows arbitrary length strings, but
10256 requires the use of dynamic allocation and finalization.
10257
10258 @item Ada.Strings.Wide_Bounded (A.4.7)
10259 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10260 @itemx Ada.Strings.Wide_Maps (A.4.7)
10261 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10262 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10263 These packages provide analogous capabilities to the corresponding
10264 packages without @samp{Wide_} in the name, but operate with the types
10265 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10266 and @code{Character}.
10267
10268 @item Ada.Synchronous_Task_Control (D.10)
10269 This package provides some standard facilities for controlling task
10270 communication in a synchronous manner.
10271
10272 @item Ada.Tags
10273 This package contains definitions for manipulation of the tags of tagged
10274 values.
10275
10276 @item Ada.Task_Attributes
10277 This package provides the capability of associating arbitrary
10278 task-specific data with separate tasks.
10279
10280 @item Ada.Text_IO
10281 This package provides basic text input-output capabilities for
10282 character, string and numeric data.  The subpackages of this
10283 package are listed next.
10284
10285 @item Ada.Text_IO.Decimal_IO
10286 Provides input-output facilities for decimal fixed-point types
10287
10288 @item Ada.Text_IO.Enumeration_IO
10289 Provides input-output facilities for enumeration types.
10290
10291 @item Ada.Text_IO.Fixed_IO
10292 Provides input-output facilities for ordinary fixed-point types.
10293
10294 @item Ada.Text_IO.Float_IO
10295 Provides input-output facilities for float types.  The following
10296 predefined instantiations of this generic package are available:
10297
10298 @table @code
10299 @item Short_Float
10300 @code{Short_Float_Text_IO}
10301 @item Float
10302 @code{Float_Text_IO}
10303 @item Long_Float
10304 @code{Long_Float_Text_IO}
10305 @end table
10306
10307 @item Ada.Text_IO.Integer_IO
10308 Provides input-output facilities for integer types.  The following
10309 predefined instantiations of this generic package are available:
10310
10311 @table @code
10312 @item Short_Short_Integer
10313 @code{Ada.Short_Short_Integer_Text_IO}
10314 @item Short_Integer
10315 @code{Ada.Short_Integer_Text_IO}
10316 @item Integer
10317 @code{Ada.Integer_Text_IO}
10318 @item Long_Integer
10319 @code{Ada.Long_Integer_Text_IO}
10320 @item Long_Long_Integer
10321 @code{Ada.Long_Long_Integer_Text_IO}
10322 @end table
10323
10324 @item Ada.Text_IO.Modular_IO
10325 Provides input-output facilities for modular (unsigned) types
10326
10327 @item Ada.Text_IO.Complex_IO (G.1.3)
10328 This package provides basic text input-output capabilities for complex
10329 data.
10330
10331 @item Ada.Text_IO.Editing (F.3.3)
10332 This package contains routines for edited output, analogous to the use
10333 of pictures in COBOL@.  The picture formats used by this package are a
10334 close copy of the facility in COBOL@.
10335
10336 @item Ada.Text_IO.Text_Streams (A.12.2)
10337 This package provides a facility that allows Text_IO files to be treated
10338 as streams, so that the stream attributes can be used for writing
10339 arbitrary data, including binary data, to Text_IO files.
10340
10341 @item Ada.Unchecked_Conversion (13.9)
10342 This generic package allows arbitrary conversion from one type to
10343 another of the same size, providing for breaking the type safety in
10344 special circumstances.
10345
10346 If the types have the same Size (more accurately the same Value_Size),
10347 then the effect is simply to transfer the bits from the source to the
10348 target type without any modification.  This usage is well defined, and
10349 for simple types whose representation is typically the same across
10350 all implementations, gives a portable method of performing such
10351 conversions.
10352
10353 If the types do not have the same size, then the result is implementation
10354 defined, and thus may be non-portable.  The following describes how GNAT
10355 handles such unchecked conversion cases.
10356
10357 If the types are of different sizes, and are both discrete types, then
10358 the effect is of a normal type conversion without any constraint checking.
10359 In particular if the result type has a larger size, the result will be
10360 zero or sign extended.  If the result type has a smaller size, the result
10361 will be truncated by ignoring high order bits.
10362
10363 If the types are of different sizes, and are not both discrete types,
10364 then the conversion works as though pointers were created to the source
10365 and target, and the pointer value is converted.  The effect is that bits
10366 are copied from successive low order storage units and bits of the source
10367 up to the length of the target type.
10368
10369 A warning is issued if the lengths differ, since the effect in this
10370 case is implementation dependent, and the above behavior may not match
10371 that of some other compiler.
10372
10373 A pointer to one type may be converted to a pointer to another type using
10374 unchecked conversion.  The only case in which the effect is undefined is
10375 when one or both pointers are pointers to unconstrained array types.  In
10376 this case, the bounds information may get incorrectly transferred, and in
10377 particular, GNAT uses double size pointers for such types, and it is
10378 meaningless to convert between such pointer types.  GNAT will issue a
10379 warning if the alignment of the target designated type is more strict
10380 than the alignment of the source designated type (since the result may
10381 be unaligned in this case).
10382
10383 A pointer other than a pointer to an unconstrained array type may be
10384 converted to and from System.Address.  Such usage is common in Ada 83
10385 programs, but note that Ada.Address_To_Access_Conversions is the
10386 preferred method of performing such conversions in Ada 95.  Neither
10387 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10388 used in conjunction with pointers to unconstrained objects, since
10389 the bounds information cannot be handled correctly in this case.
10390
10391 @item Ada.Unchecked_Deallocation (13.11.2)
10392 This generic package allows explicit freeing of storage previously
10393 allocated by use of an allocator.
10394
10395 @item Ada.Wide_Text_IO (A.11)
10396 This package is similar to @code{Ada.Text_IO}, except that the external
10397 file supports wide character representations, and the internal types are
10398 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10399 and @code{String}.  It contains generic subpackages listed next.
10400
10401 @item Ada.Wide_Text_IO.Decimal_IO
10402 Provides input-output facilities for decimal fixed-point types
10403
10404 @item Ada.Wide_Text_IO.Enumeration_IO
10405 Provides input-output facilities for enumeration types.
10406
10407 @item Ada.Wide_Text_IO.Fixed_IO
10408 Provides input-output facilities for ordinary fixed-point types.
10409
10410 @item Ada.Wide_Text_IO.Float_IO
10411 Provides input-output facilities for float types.  The following
10412 predefined instantiations of this generic package are available:
10413
10414 @table @code
10415 @item Short_Float
10416 @code{Short_Float_Wide_Text_IO}
10417 @item Float
10418 @code{Float_Wide_Text_IO}
10419 @item Long_Float
10420 @code{Long_Float_Wide_Text_IO}
10421 @end table
10422
10423 @item Ada.Wide_Text_IO.Integer_IO
10424 Provides input-output facilities for integer types.  The following
10425 predefined instantiations of this generic package are available:
10426
10427 @table @code
10428 @item Short_Short_Integer
10429 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10430 @item Short_Integer
10431 @code{Ada.Short_Integer_Wide_Text_IO}
10432 @item Integer
10433 @code{Ada.Integer_Wide_Text_IO}
10434 @item Long_Integer
10435 @code{Ada.Long_Integer_Wide_Text_IO}
10436 @item Long_Long_Integer
10437 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10438 @end table
10439
10440 @item Ada.Wide_Text_IO.Modular_IO
10441 Provides input-output facilities for modular (unsigned) types
10442
10443 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10444 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10445 external file supports wide character representations.
10446
10447 @item Ada.Wide_Text_IO.Editing (F.3.4)
10448 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10449 types are @code{Wide_Character} and @code{Wide_String} instead of
10450 @code{Character} and @code{String}.
10451
10452 @item Ada.Wide_Text_IO.Streams (A.12.3)
10453 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10454 types are @code{Wide_Character} and @code{Wide_String} instead of
10455 @code{Character} and @code{String}.
10456 @end table
10457
10458 @node The Implementation of Standard I/O
10459 @chapter The Implementation of Standard I/O
10460
10461 @noindent
10462 GNAT implements all the required input-output facilities described in
10463 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10464 required behavior of these packages from the Ada point of view, and if
10465 you are writing a portable Ada program that does not need to know the
10466 exact manner in which Ada maps to the outside world when it comes to
10467 reading or writing external files, then you do not need to read this
10468 chapter.  As long as your files are all regular files (not pipes or
10469 devices), and as long as you write and read the files only from Ada, the
10470 description in the Ada 95 reference manual is sufficient.
10471
10472 However, if you want to do input-output to pipes or other devices, such
10473 as the keyboard or screen, or if the files you are dealing with are
10474 either generated by some other language, or to be read by some other
10475 language, then you need to know more about the details of how the GNAT
10476 implementation of these input-output facilities behaves.
10477
10478 In this chapter we give a detailed description of exactly how GNAT
10479 interfaces to the file system.  As always, the sources of the system are
10480 available to you for answering questions at an even more detailed level,
10481 but for most purposes the information in this chapter will suffice.
10482
10483 Another reason that you may need to know more about how input-output is
10484 implemented arises when you have a program written in mixed languages
10485 where, for example, files are shared between the C and Ada sections of
10486 the same program.  GNAT provides some additional facilities, in the form
10487 of additional child library packages, that facilitate this sharing, and
10488 these additional facilities are also described in this chapter.
10489
10490 @menu
10491 * Standard I/O Packages::
10492 * FORM Strings::
10493 * Direct_IO::
10494 * Sequential_IO::
10495 * Text_IO::
10496 * Wide_Text_IO::
10497 * Stream_IO::
10498 * Shared Files::
10499 * Open Modes::
10500 * Operations on C Streams::
10501 * Interfacing to C Streams::
10502 @end menu
10503
10504 @node Standard I/O Packages
10505 @section Standard I/O Packages
10506
10507 @noindent
10508 The Standard I/O packages described in Annex A for
10509
10510 @itemize @bullet
10511 @item
10512 Ada.Text_IO
10513 @item
10514 Ada.Text_IO.Complex_IO
10515 @item
10516 Ada.Text_IO.Text_Streams,
10517 @item
10518 Ada.Wide_Text_IO
10519 @item
10520 Ada.Wide_Text_IO.Complex_IO,
10521 @item
10522 Ada.Wide_Text_IO.Text_Streams
10523 @item
10524 Ada.Stream_IO
10525 @item
10526 Ada.Sequential_IO
10527 @item
10528 Ada.Direct_IO
10529 @end itemize
10530
10531 @noindent
10532 are implemented using the C
10533 library streams facility; where
10534
10535 @itemize @bullet
10536 @item
10537 All files are opened using @code{fopen}.
10538 @item
10539 All input/output operations use @code{fread}/@code{fwrite}.
10540 @end itemize
10541
10542 @noindent
10543 There is no internal buffering of any kind at the Ada library level.  The
10544 only buffering is that provided at the system level in the
10545 implementation of the C library routines that support streams.  This
10546 facilitates shared use of these streams by mixed language programs.
10547
10548 @node FORM Strings
10549 @section FORM Strings
10550
10551 @noindent
10552 The format of a FORM string in GNAT is:
10553
10554 @smallexample
10555 "keyword=value,keyword=value,@dots{},keyword=value"
10556 @end smallexample
10557
10558 @noindent
10559 where letters may be in upper or lower case, and there are no spaces
10560 between values.  The order of the entries is not important.  Currently
10561 there are two keywords defined.
10562
10563 @smallexample
10564 SHARED=[YES|NO]
10565 WCEM=[n|h|u|s\e]
10566 @end smallexample
10567
10568 @noindent
10569 The use of these parameters is described later in this section.
10570
10571 @node Direct_IO
10572 @section Direct_IO
10573
10574 @noindent
10575 Direct_IO can only be instantiated for definite types.  This is a
10576 restriction of the Ada language, which means that the records are fixed
10577 length (the length being determined by @code{@var{type}'Size}, rounded
10578 up to the next storage unit boundary if necessary).
10579
10580 The records of a Direct_IO file are simply written to the file in index
10581 sequence, with the first record starting at offset zero, and subsequent
10582 records following.  There is no control information of any kind.  For
10583 example, if 32-bit integers are being written, each record takes
10584 4-bytes, so the record at index @var{K} starts at offset
10585 (@var{K}@minus{}1)*4.
10586
10587 There is no limit on the size of Direct_IO files, they are expanded as
10588 necessary to accommodate whatever records are written to the file.
10589
10590 @node Sequential_IO
10591 @section Sequential_IO
10592
10593 @noindent
10594 Sequential_IO may be instantiated with either a definite (constrained)
10595 or indefinite (unconstrained) type.
10596
10597 For the definite type case, the elements written to the file are simply
10598 the memory images of the data values with no control information of any
10599 kind.  The resulting file should be read using the same type, no validity
10600 checking is performed on input.
10601
10602 For the indefinite type case, the elements written consist of two
10603 parts.  First is the size of the data item, written as the memory image
10604 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10605 the data value.  The resulting file can only be read using the same
10606 (unconstrained) type.  Normal assignment checks are performed on these
10607 read operations, and if these checks fail, @code{Data_Error} is
10608 raised.  In particular, in the array case, the lengths must match, and in
10609 the variant record case, if the variable for a particular read operation
10610 is constrained, the discriminants must match.
10611
10612 Note that it is not possible to use Sequential_IO to write variable
10613 length array items, and then read the data back into different length
10614 arrays.  For example, the following will raise @code{Data_Error}:
10615
10616 @smallexample @c ada
10617  package IO is new Sequential_IO (String);
10618  F : IO.File_Type;
10619  S : String (1..4);
10620  @dots{}
10621  IO.Create (F)
10622  IO.Write (F, "hello!")
10623  IO.Reset (F, Mode=>In_File);
10624  IO.Read (F, S);
10625  Put_Line (S);
10626
10627 @end smallexample
10628
10629 @noindent
10630 On some Ada implementations, this will print @code{hell}, but the program is
10631 clearly incorrect, since there is only one element in the file, and that
10632 element is the string @code{hello!}.
10633
10634 In Ada 95, this kind of behavior can be legitimately achieved using
10635 Stream_IO, and this is the preferred mechanism.  In particular, the above
10636 program fragment rewritten to use Stream_IO will work correctly.
10637
10638 @node Text_IO
10639 @section Text_IO
10640
10641 @noindent
10642 Text_IO files consist of a stream of characters containing the following
10643 special control characters:
10644
10645 @smallexample
10646 LF (line feed, 16#0A#) Line Mark
10647 FF (form feed, 16#0C#) Page Mark
10648 @end smallexample
10649
10650 @noindent
10651 A canonical Text_IO file is defined as one in which the following
10652 conditions are met:
10653
10654 @itemize @bullet
10655 @item
10656 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10657 of the line.
10658
10659 @item
10660 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10661 end of a page and consequently can appear only immediately following a
10662 @code{LF} (line mark) character.
10663
10664 @item
10665 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10666 (line mark, page mark).  In the former case, the page mark is implicitly
10667 assumed to be present.
10668 @end itemize
10669
10670 @noindent
10671 A file written using Text_IO will be in canonical form provided that no
10672 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10673 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10674 the file unless an explicit @code{New_Page} operation was performed
10675 before closing the file.
10676
10677 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10678 pipe, can be read using any of the routines in Text_IO@.  The
10679 semantics in this case will be exactly as defined in the Ada 95 reference
10680 manual and all the routines in Text_IO are fully implemented.
10681
10682 A text file that does not meet the requirements for a canonical Text_IO
10683 file has one of the following:
10684
10685 @itemize @bullet
10686 @item
10687 The file contains @code{FF} characters not immediately following a
10688 @code{LF} character.
10689
10690 @item
10691 The file contains @code{LF} or @code{FF} characters written by
10692 @code{Put} or @code{Put_Line}, which are not logically considered to be
10693 line marks or page marks.
10694
10695 @item
10696 The file ends in a character other than @code{LF} or @code{FF},
10697 i.e.@: there is no explicit line mark or page mark at the end of the file.
10698 @end itemize
10699
10700 @noindent
10701 Text_IO can be used to read such non-standard text files but subprograms
10702 to do with line or page numbers do not have defined meanings.  In
10703 particular, a @code{FF} character that does not follow a @code{LF}
10704 character may or may not be treated as a page mark from the point of
10705 view of page and line numbering.  Every @code{LF} character is considered
10706 to end a line, and there is an implied @code{LF} character at the end of
10707 the file.
10708
10709 @menu
10710 * Text_IO Stream Pointer Positioning::
10711 * Text_IO Reading and Writing Non-Regular Files::
10712 * Get_Immediate::
10713 * Treating Text_IO Files as Streams::
10714 * Text_IO Extensions::
10715 * Text_IO Facilities for Unbounded Strings::
10716 @end menu
10717
10718 @node Text_IO Stream Pointer Positioning
10719 @subsection Stream Pointer Positioning
10720
10721 @noindent
10722 @code{Ada.Text_IO} has a definition of current position for a file that
10723 is being read.  No internal buffering occurs in Text_IO, and usually the
10724 physical position in the stream used to implement the file corresponds
10725 to this logical position defined by Text_IO@.  There are two exceptions:
10726
10727 @itemize @bullet
10728 @item
10729 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10730 is positioned past the @code{LF} (line mark) that precedes the page
10731 mark.  Text_IO maintains an internal flag so that subsequent read
10732 operations properly handle the logical position which is unchanged by
10733 the @code{End_Of_Page} call.
10734
10735 @item
10736 After a call to @code{End_Of_File} that returns @code{True}, if the
10737 Text_IO file was positioned before the line mark at the end of file
10738 before the call, then the logical position is unchanged, but the stream
10739 is physically positioned right at the end of file (past the line mark,
10740 and past a possible page mark following the line mark.  Again Text_IO
10741 maintains internal flags so that subsequent read operations properly
10742 handle the logical position.
10743 @end itemize
10744
10745 @noindent
10746 These discrepancies have no effect on the observable behavior of
10747 Text_IO, but if a single Ada stream is shared between a C program and
10748 Ada program, or shared (using @samp{shared=yes} in the form string)
10749 between two Ada files, then the difference may be observable in some
10750 situations.
10751
10752 @node Text_IO Reading and Writing Non-Regular Files
10753 @subsection Reading and Writing Non-Regular Files
10754
10755 @noindent
10756 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10757 can be used for reading and writing.  Writing is not affected and the
10758 sequence of characters output is identical to the normal file case, but
10759 for reading, the behavior of Text_IO is modified to avoid undesirable
10760 look-ahead as follows:
10761
10762 An input file that is not a regular file is considered to have no page
10763 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10764 page mark) appearing in the file are considered to be data
10765 characters.  In particular:
10766
10767 @itemize @bullet
10768 @item
10769 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10770 following a line mark.  If a page mark appears, it will be treated as a
10771 data character.
10772
10773 @item
10774 This avoids the need to wait for an extra character to be typed or
10775 entered from the pipe to complete one of these operations.
10776
10777 @item
10778 @code{End_Of_Page} always returns @code{False}
10779
10780 @item
10781 @code{End_Of_File} will return @code{False} if there is a page mark at
10782 the end of the file.
10783 @end itemize
10784
10785 @noindent
10786 Output to non-regular files is the same as for regular files.  Page marks
10787 may be written to non-regular files using @code{New_Page}, but as noted
10788 above they will not be treated as page marks on input if the output is
10789 piped to another Ada program.
10790
10791 Another important discrepancy when reading non-regular files is that the end
10792 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10793 pressing the @key{EOT} key,
10794 then end of file
10795 is signaled once (i.e.@: the test @code{End_Of_File}
10796 will yield @code{True}, or a read will
10797 raise @code{End_Error}), but then reading can resume
10798 to read data past that end of
10799 file indication, until another end of file indication is entered.
10800
10801 @node Get_Immediate
10802 @subsection Get_Immediate
10803 @cindex Get_Immediate
10804
10805 @noindent
10806 Get_Immediate returns the next character (including control characters)
10807 from the input file.  In particular, Get_Immediate will return LF or FF
10808 characters used as line marks or page marks.  Such operations leave the
10809 file positioned past the control character, and it is thus not treated
10810 as having its normal function.  This means that page, line and column
10811 counts after this kind of Get_Immediate call are set as though the mark
10812 did not occur.  In the case where a Get_Immediate leaves the file
10813 positioned between the line mark and page mark (which is not normally
10814 possible), it is undefined whether the FF character will be treated as a
10815 page mark.
10816
10817 @node Treating Text_IO Files as Streams
10818 @subsection Treating Text_IO Files as Streams
10819 @cindex Stream files
10820
10821 @noindent
10822 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10823 as a stream.  Data written to a Text_IO file in this stream mode is
10824 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10825 16#0C# (@code{FF}), the resulting file may have non-standard
10826 format.  Similarly if read operations are used to read from a Text_IO
10827 file treated as a stream, then @code{LF} and @code{FF} characters may be
10828 skipped and the effect is similar to that described above for
10829 @code{Get_Immediate}.
10830
10831 @node Text_IO Extensions
10832 @subsection Text_IO Extensions
10833 @cindex Text_IO extensions
10834
10835 @noindent
10836 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10837 to the standard @code{Text_IO} package:
10838
10839 @itemize @bullet
10840 @item function File_Exists (Name : String) return Boolean;
10841 Determines if a file of the given name exists.
10842
10843 @item function Get_Line return String;
10844 Reads a string from the standard input file.  The value returned is exactly
10845 the length of the line that was read.
10846
10847 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10848 Similar, except that the parameter File specifies the file from which
10849 the string is to be read.
10850
10851 @end itemize
10852
10853 @node Text_IO Facilities for Unbounded Strings
10854 @subsection Text_IO Facilities for Unbounded Strings
10855 @cindex Text_IO for unbounded strings
10856 @cindex Unbounded_String, Text_IO operations
10857
10858 @noindent
10859 The package @code{Ada.Strings.Unbounded.Text_IO}
10860 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10861 subprograms useful for Text_IO operations on unbounded strings:
10862
10863 @itemize @bullet
10864
10865 @item function Get_Line (File : File_Type) return Unbounded_String;
10866 Reads a line from the specified file
10867 and returns the result as an unbounded string.
10868
10869 @item procedure Put (File : File_Type; U : Unbounded_String);
10870 Writes the value of the given unbounded string to the specified file
10871 Similar to the effect of
10872 @code{Put (To_String (U))} except that an extra copy is avoided.
10873
10874 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10875 Writes the value of the given unbounded string to the specified file,
10876 followed by a @code{New_Line}.
10877 Similar to the effect of @code{Put_Line (To_String (U))} except
10878 that an extra copy is avoided.
10879 @end itemize
10880
10881 @noindent
10882 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10883 and is optional.  If the parameter is omitted, then the standard input or
10884 output file is referenced as appropriate.
10885
10886 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10887 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10888 @code{Wide_Text_IO} functionality for unbounded wide strings.
10889
10890 @node Wide_Text_IO
10891 @section Wide_Text_IO
10892
10893 @noindent
10894 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10895 both input and output files may contain special sequences that represent
10896 wide character values.  The encoding scheme for a given file may be
10897 specified using a FORM parameter:
10898
10899 @smallexample
10900 WCEM=@var{x}
10901 @end smallexample
10902
10903 @noindent
10904 as part of the FORM string (WCEM = wide character encoding method),
10905 where @var{x} is one of the following characters
10906
10907 @table @samp
10908 @item h
10909 Hex ESC encoding
10910 @item u
10911 Upper half encoding
10912 @item s
10913 Shift-JIS encoding
10914 @item e
10915 EUC Encoding
10916 @item 8
10917 UTF-8 encoding
10918 @item b
10919 Brackets encoding
10920 @end table
10921
10922 @noindent
10923 The encoding methods match those that
10924 can be used in a source
10925 program, but there is no requirement that the encoding method used for
10926 the source program be the same as the encoding method used for files,
10927 and different files may use different encoding methods.
10928
10929 The default encoding method for the standard files, and for opened files
10930 for which no WCEM parameter is given in the FORM string matches the
10931 wide character encoding specified for the main program (the default
10932 being brackets encoding if no coding method was specified with -gnatW).
10933
10934 @table @asis
10935 @item Hex Coding
10936 In this encoding, a wide character is represented by a five character
10937 sequence:
10938
10939 @smallexample
10940 ESC a b c d
10941 @end smallexample
10942
10943 @noindent
10944 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10945 characters (using upper case letters) of the wide character code.  For
10946 example, ESC A345 is used to represent the wide character with code
10947 16#A345#.  This scheme is compatible with use of the full
10948 @code{Wide_Character} set.
10949
10950 @item Upper Half Coding
10951 The wide character with encoding 16#abcd#, where the upper bit is on
10952 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10953 16#cd#.  The second byte may never be a format control character, but is
10954 not required to be in the upper half.  This method can be also used for
10955 shift-JIS or EUC where the internal coding matches the external coding.
10956
10957 @item Shift JIS Coding
10958 A wide character is represented by a two character sequence 16#ab# and
10959 16#cd#, with the restrictions described for upper half encoding as
10960 described above.  The internal character code is the corresponding JIS
10961 character according to the standard algorithm for Shift-JIS
10962 conversion.  Only characters defined in the JIS code set table can be
10963 used with this encoding method.
10964
10965 @item EUC Coding
10966 A wide character is represented by a two character sequence 16#ab# and
10967 16#cd#, with both characters being in the upper half.  The internal
10968 character code is the corresponding JIS character according to the EUC
10969 encoding algorithm.  Only characters defined in the JIS code set table
10970 can be used with this encoding method.
10971
10972 @item UTF-8 Coding
10973 A wide character is represented using
10974 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10975 10646-1/Am.2.  Depending on the character value, the representation
10976 is a one, two, or three byte sequence:
10977
10978 @smallexample
10979 16#0000#-16#007f#: 2#0xxxxxxx#
10980 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10981 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10982 @end smallexample
10983
10984 @noindent
10985 where the xxx bits correspond to the left-padded bits of the
10986 16-bit character value.  Note that all lower half ASCII characters
10987 are represented as ASCII bytes and all upper half characters and
10988 other wide characters are represented as sequences of upper-half
10989 (The full UTF-8 scheme allows for encoding 31-bit characters as
10990 6-byte sequences, but in this implementation, all UTF-8 sequences
10991 of four or more bytes length will raise a Constraint_Error, as
10992 will all invalid UTF-8 sequences.)
10993
10994 @item Brackets Coding
10995 In this encoding, a wide character is represented by the following eight
10996 character sequence:
10997
10998 @smallexample
10999 [ " a b c d " ]
11000 @end smallexample
11001
11002 @noindent
11003 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11004 characters (using uppercase letters) of the wide character code.  For
11005 example, @code{["A345"]} is used to represent the wide character with code
11006 @code{16#A345#}.
11007 This scheme is compatible with use of the full Wide_Character set.
11008 On input, brackets coding can also be used for upper half characters,
11009 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11010 is only used for wide characters with a code greater than @code{16#FF#}.
11011
11012 @end table
11013
11014 @noindent
11015 For the coding schemes other than Hex and Brackets encoding,
11016 not all wide character
11017 values can be represented.  An attempt to output a character that cannot
11018 be represented using the encoding scheme for the file causes
11019 Constraint_Error to be raised.  An invalid wide character sequence on
11020 input also causes Constraint_Error to be raised.
11021
11022 @menu
11023 * Wide_Text_IO Stream Pointer Positioning::
11024 * Wide_Text_IO Reading and Writing Non-Regular Files::
11025 @end menu
11026
11027 @node Wide_Text_IO Stream Pointer Positioning
11028 @subsection Stream Pointer Positioning
11029
11030 @noindent
11031 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11032 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11033 case:
11034
11035 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11036 normal lower ASCII set (i.e.@: a character in the range:
11037
11038 @smallexample @c ada
11039 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11040 @end smallexample
11041
11042 @noindent
11043 then although the logical position of the file pointer is unchanged by
11044 the @code{Look_Ahead} call, the stream is physically positioned past the
11045 wide character sequence.  Again this is to avoid the need for buffering
11046 or backup, and all @code{Wide_Text_IO} routines check the internal
11047 indication that this situation has occurred so that this is not visible
11048 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11049 can be observed if the wide text file shares a stream with another file.
11050
11051 @node Wide_Text_IO Reading and Writing Non-Regular Files
11052 @subsection Reading and Writing Non-Regular Files
11053
11054 @noindent
11055 As in the case of Text_IO, when a non-regular file is read, it is
11056 assumed that the file contains no page marks (any form characters are
11057 treated as data characters), and @code{End_Of_Page} always returns
11058 @code{False}.  Similarly, the end of file indication is not sticky, so
11059 it is possible to read beyond an end of file.
11060
11061 @node Stream_IO
11062 @section Stream_IO
11063
11064 @noindent
11065 A stream file is a sequence of bytes, where individual elements are
11066 written to the file as described in the Ada 95 reference manual.  The type
11067 @code{Stream_Element} is simply a byte.  There are two ways to read or
11068 write a stream file.
11069
11070 @itemize @bullet
11071 @item
11072 The operations @code{Read} and @code{Write} directly read or write a
11073 sequence of stream elements with no control information.
11074
11075 @item
11076 The stream attributes applied to a stream file transfer data in the
11077 manner described for stream attributes.
11078 @end itemize
11079
11080 @node Shared Files
11081 @section Shared Files
11082
11083 @noindent
11084 Section A.14 of the Ada 95 Reference Manual allows implementations to
11085 provide a wide variety of behavior if an attempt is made to access the
11086 same external file with two or more internal files.
11087
11088 To provide a full range of functionality, while at the same time
11089 minimizing the problems of portability caused by this implementation
11090 dependence, GNAT handles file sharing as follows:
11091
11092 @itemize @bullet
11093 @item
11094 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11095 to open two or more files with the same full name is considered an error
11096 and is not supported.  The exception @code{Use_Error} will be
11097 raised.  Note that a file that is not explicitly closed by the program
11098 remains open until the program terminates.
11099
11100 @item
11101 If the form parameter @samp{shared=no} appears in the form string, the
11102 file can be opened or created with its own separate stream identifier,
11103 regardless of whether other files sharing the same external file are
11104 opened.  The exact effect depends on how the C stream routines handle
11105 multiple accesses to the same external files using separate streams.
11106
11107 @item
11108 If the form parameter @samp{shared=yes} appears in the form string for
11109 each of two or more files opened using the same full name, the same
11110 stream is shared between these files, and the semantics are as described
11111 in Ada 95 Reference Manual, Section A.14.
11112 @end itemize
11113
11114 @noindent
11115 When a program that opens multiple files with the same name is ported
11116 from another Ada compiler to GNAT, the effect will be that
11117 @code{Use_Error} is raised.
11118
11119 The documentation of the original compiler and the documentation of the
11120 program should then be examined to determine if file sharing was
11121 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11122 and @code{Create} calls as required.
11123
11124 When a program is ported from GNAT to some other Ada compiler, no
11125 special attention is required unless the @samp{shared=@var{xxx}} form
11126 parameter is used in the program.  In this case, you must examine the
11127 documentation of the new compiler to see if it supports the required
11128 file sharing semantics, and form strings modified appropriately.  Of
11129 course it may be the case that the program cannot be ported if the
11130 target compiler does not support the required functionality.  The best
11131 approach in writing portable code is to avoid file sharing (and hence
11132 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11133 completely.
11134
11135 One common use of file sharing in Ada 83 is the use of instantiations of
11136 Sequential_IO on the same file with different types, to achieve
11137 heterogeneous input-output.  Although this approach will work in GNAT if
11138 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11139 for this purpose (using the stream attributes)
11140
11141 @node Open Modes
11142 @section Open Modes
11143
11144 @noindent
11145 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11146 using the mode shown in the following table:
11147
11148 @sp 2
11149 @center @code{Open} and @code{Create} Call Modes
11150 @smallexample
11151                                @b{OPEN }           @b{CREATE}
11152 Append_File                    "r+"             "w+"
11153 In_File                        "r"              "w+"
11154 Out_File (Direct_IO)           "r+"             "w"
11155 Out_File (all other cases)     "w"              "w"
11156 Inout_File                     "r+"             "w+"
11157 @end smallexample
11158
11159 @noindent
11160 If text file translation is required, then either @samp{b} or @samp{t}
11161 is added to the mode, depending on the setting of Text.  Text file
11162 translation refers to the mapping of CR/LF sequences in an external file
11163 to LF characters internally.  This mapping only occurs in DOS and
11164 DOS-like systems, and is not relevant to other systems.
11165
11166 A special case occurs with Stream_IO@.  As shown in the above table, the
11167 file is initially opened in @samp{r} or @samp{w} mode for the
11168 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11169 subsequently requires switching from reading to writing or vice-versa,
11170 then the file is reopened in @samp{r+} mode to permit the required operation.
11171
11172 @node Operations on C Streams
11173 @section Operations on C Streams
11174 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11175 access to the C library functions for operations on C streams:
11176
11177 @smallexample @c adanocomment
11178 package Interfaces.C_Streams is
11179   -- Note: the reason we do not use the types that are in
11180   -- Interfaces.C is that we want to avoid dragging in the
11181   -- code in this unit if possible.
11182   subtype chars is System.Address;
11183   -- Pointer to null-terminated array of characters
11184   subtype FILEs is System.Address;
11185   -- Corresponds to the C type FILE*
11186   subtype voids is System.Address;
11187   -- Corresponds to the C type void*
11188   subtype int is Integer;
11189   subtype long is Long_Integer;
11190   -- Note: the above types are subtypes deliberately, and it
11191   -- is part of this spec that the above correspondences are
11192   -- guaranteed.  This means that it is legitimate to, for
11193   -- example, use Integer instead of int.  We provide these
11194   -- synonyms for clarity, but in some cases it may be
11195   -- convenient to use the underlying types (for example to
11196   -- avoid an unnecessary dependency of a spec on the spec
11197   -- of this unit).
11198   type size_t is mod 2 ** Standard'Address_Size;
11199   NULL_Stream : constant FILEs;
11200   -- Value returned (NULL in C) to indicate an
11201   -- fdopen/fopen/tmpfile error
11202   ----------------------------------
11203   -- Constants Defined in stdio.h --
11204   ----------------------------------
11205   EOF : constant int;
11206   -- Used by a number of routines to indicate error or
11207   -- end of file
11208   IOFBF : constant int;
11209   IOLBF : constant int;
11210   IONBF : constant int;
11211   -- Used to indicate buffering mode for setvbuf call
11212   SEEK_CUR : constant int;
11213   SEEK_END : constant int;
11214   SEEK_SET : constant int;
11215   -- Used to indicate origin for fseek call
11216   function stdin return FILEs;
11217   function stdout return FILEs;
11218   function stderr return FILEs;
11219   -- Streams associated with standard files
11220   --------------------------
11221   -- Standard C functions --
11222   --------------------------
11223   -- The functions selected below are ones that are
11224   -- available in DOS, OS/2, UNIX and Xenix (but not
11225   -- necessarily in ANSI C).  These are very thin interfaces
11226   -- which copy exactly the C headers.  For more
11227   -- documentation on these functions, see the Microsoft C
11228   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11229   -- ISBN 1-55615-225-6), which includes useful information
11230   -- on system compatibility.
11231   procedure clearerr (stream : FILEs);
11232   function fclose (stream : FILEs) return int;
11233   function fdopen (handle : int; mode : chars) return FILEs;
11234   function feof (stream : FILEs) return int;
11235   function ferror (stream : FILEs) return int;
11236   function fflush (stream : FILEs) return int;
11237   function fgetc (stream : FILEs) return int;
11238   function fgets (strng : chars; n : int; stream : FILEs)
11239       return chars;
11240   function fileno (stream : FILEs) return int;
11241   function fopen (filename : chars; Mode : chars)
11242       return FILEs;
11243   -- Note: to maintain target independence, use
11244   -- text_translation_required, a boolean variable defined in
11245   -- a-sysdep.c to deal with the target dependent text
11246   -- translation requirement.  If this variable is set,
11247   -- then  b/t should be appended to the standard mode
11248   -- argument to set the text translation mode off or on
11249   -- as required.
11250   function fputc (C : int; stream : FILEs) return int;
11251   function fputs (Strng : chars; Stream : FILEs) return int;
11252   function fread
11253      (buffer : voids;
11254       size : size_t;
11255       count : size_t;
11256       stream : FILEs)
11257       return size_t;
11258   function freopen
11259      (filename : chars;
11260       mode : chars;
11261       stream : FILEs)
11262       return FILEs;
11263   function fseek
11264      (stream : FILEs;
11265       offset : long;
11266       origin : int)
11267       return int;
11268   function ftell (stream : FILEs) return long;
11269   function fwrite
11270      (buffer : voids;
11271       size : size_t;
11272       count : size_t;
11273       stream : FILEs)
11274       return size_t;
11275   function isatty (handle : int) return int;
11276   procedure mktemp (template : chars);
11277   -- The return value (which is just a pointer to template)
11278   -- is discarded
11279   procedure rewind (stream : FILEs);
11280   function rmtmp return int;
11281   function setvbuf
11282      (stream : FILEs;
11283       buffer : chars;
11284       mode : int;
11285       size : size_t)
11286       return int;
11287
11288   function tmpfile return FILEs;
11289   function ungetc (c : int; stream : FILEs) return int;
11290   function unlink (filename : chars) return int;
11291   ---------------------
11292   -- Extra functions --
11293   ---------------------
11294   -- These functions supply slightly thicker bindings than
11295   -- those above.  They are derived from functions in the
11296   -- C Run-Time Library, but may do a bit more work than
11297   -- just directly calling one of the Library functions.
11298   function is_regular_file (handle : int) return int;
11299   -- Tests if given handle is for a regular file (result 1)
11300   -- or for a non-regular file (pipe or device, result 0).
11301   ---------------------------------
11302   -- Control of Text/Binary Mode --
11303   ---------------------------------
11304   -- If text_translation_required is true, then the following
11305   -- functions may be used to dynamically switch a file from
11306   -- binary to text mode or vice versa.  These functions have
11307   -- no effect if text_translation_required is false (i.e.  in
11308   -- normal UNIX mode).  Use fileno to get a stream handle.
11309   procedure set_binary_mode (handle : int);
11310   procedure set_text_mode (handle : int);
11311   ----------------------------
11312   -- Full Path Name support --
11313   ----------------------------
11314   procedure full_name (nam : chars; buffer : chars);
11315   -- Given a NUL terminated string representing a file
11316   -- name, returns in buffer a NUL terminated string
11317   -- representing the full path name for the file name.
11318   -- On systems where it is relevant the   drive is also
11319   -- part of the full path name.  It is the responsibility
11320   -- of the caller to pass an actual parameter for buffer
11321   -- that is big enough for any full path name.  Use
11322   -- max_path_len given below as the size of buffer.
11323   max_path_len : integer;
11324   -- Maximum length of an allowable full path name on the
11325   -- system, including a terminating NUL character.
11326 end Interfaces.C_Streams;
11327 @end smallexample
11328
11329 @node Interfacing to C Streams
11330 @section Interfacing to C Streams
11331
11332 @noindent
11333 The packages in this section permit interfacing Ada files to C Stream
11334 operations.
11335
11336 @smallexample @c ada
11337  with Interfaces.C_Streams;
11338  package Ada.Sequential_IO.C_Streams is
11339     function C_Stream (F : File_Type)
11340        return Interfaces.C_Streams.FILEs;
11341     procedure Open
11342       (File : in out File_Type;
11343        Mode : in File_Mode;
11344        C_Stream : in Interfaces.C_Streams.FILEs;
11345        Form : in String := "");
11346  end Ada.Sequential_IO.C_Streams;
11347
11348   with Interfaces.C_Streams;
11349   package Ada.Direct_IO.C_Streams is
11350      function C_Stream (F : File_Type)
11351         return Interfaces.C_Streams.FILEs;
11352      procedure Open
11353        (File : in out File_Type;
11354         Mode : in File_Mode;
11355         C_Stream : in Interfaces.C_Streams.FILEs;
11356         Form : in String := "");
11357   end Ada.Direct_IO.C_Streams;
11358
11359   with Interfaces.C_Streams;
11360   package Ada.Text_IO.C_Streams is
11361      function C_Stream (F : File_Type)
11362         return Interfaces.C_Streams.FILEs;
11363      procedure Open
11364        (File : in out File_Type;
11365         Mode : in File_Mode;
11366         C_Stream : in Interfaces.C_Streams.FILEs;
11367         Form : in String := "");
11368   end Ada.Text_IO.C_Streams;
11369
11370   with Interfaces.C_Streams;
11371   package Ada.Wide_Text_IO.C_Streams is
11372      function C_Stream (F : File_Type)
11373         return Interfaces.C_Streams.FILEs;
11374      procedure Open
11375        (File : in out File_Type;
11376         Mode : in File_Mode;
11377         C_Stream : in Interfaces.C_Streams.FILEs;
11378         Form : in String := "");
11379  end Ada.Wide_Text_IO.C_Streams;
11380
11381  with Interfaces.C_Streams;
11382  package Ada.Stream_IO.C_Streams is
11383     function C_Stream (F : File_Type)
11384        return Interfaces.C_Streams.FILEs;
11385     procedure Open
11386       (File : in out File_Type;
11387        Mode : in File_Mode;
11388        C_Stream : in Interfaces.C_Streams.FILEs;
11389        Form : in String := "");
11390  end Ada.Stream_IO.C_Streams;
11391 @end smallexample
11392
11393 @noindent
11394 In each of these five packages, the @code{C_Stream} function obtains the
11395 @code{FILE} pointer from a currently opened Ada file.  It is then
11396 possible to use the @code{Interfaces.C_Streams} package to operate on
11397 this stream, or the stream can be passed to a C program which can
11398 operate on it directly.  Of course the program is responsible for
11399 ensuring that only appropriate sequences of operations are executed.
11400
11401 One particular use of relevance to an Ada program is that the
11402 @code{setvbuf} function can be used to control the buffering of the
11403 stream used by an Ada file.  In the absence of such a call the standard
11404 default buffering is used.
11405
11406 The @code{Open} procedures in these packages open a file giving an
11407 existing C Stream instead of a file name.  Typically this stream is
11408 imported from a C program, allowing an Ada file to operate on an
11409 existing C file.
11410
11411 @node The GNAT Library
11412 @chapter The GNAT Library
11413
11414 @noindent
11415 The GNAT library contains a number of general and special purpose packages.
11416 It represents functionality that the GNAT developers have found useful, and
11417 which is made available to GNAT users.  The packages described here are fully
11418 supported, and upwards compatibility will be maintained in future releases,
11419 so you can use these facilities with the confidence that the same functionality
11420 will be available in future releases.
11421
11422 The chapter here simply gives a brief summary of the facilities available.
11423 The full documentation is found in the spec file for the package.  The full
11424 sources of these library packages, including both spec and body, are provided
11425 with all GNAT releases.  For example, to find out the full specifications of
11426 the SPITBOL pattern matching capability, including a full tutorial and
11427 extensive examples, look in the @file{g-spipat.ads} file in the library.
11428
11429 For each entry here, the package name (as it would appear in a @code{with}
11430 clause) is given, followed by the name of the corresponding spec file in
11431 parentheses.  The packages are children in four hierarchies, @code{Ada},
11432 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11433 GNAT-specific hierarchy.
11434
11435 Note that an application program should only use packages in one of these
11436 four hierarchies if the package is defined in the Ada Reference Manual,
11437 or is listed in this section of the GNAT Programmers Reference Manual.
11438 All other units should be considered internal implementation units and
11439 should not be directly @code{with}'ed by application code.  The use of
11440 a @code{with} statement that references one of these internal implementation
11441 units makes an application potentially dependent on changes in versions
11442 of GNAT, and will generate a warning message.
11443
11444 @menu
11445 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11446 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11447 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11448 * Ada.Command_Line.Remove (a-colire.ads)::
11449 * Ada.Command_Line.Environment (a-colien.ads)::
11450 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11451 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11452 * Ada.Exceptions.Traceback (a-exctra.ads)::
11453 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11454 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11455 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11456 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11457 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11458 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11459 * GNAT.Array_Split (g-arrspl.ads)::
11460 * GNAT.AWK (g-awk.ads)::
11461 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11462 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11463 * GNAT.Bubble_Sort (g-bubsor.ads)::
11464 * GNAT.Bubble_Sort_A (g-busora.ads)::
11465 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11466 * GNAT.Calendar (g-calend.ads)::
11467 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11468 * GNAT.CRC32 (g-crc32.ads)::
11469 * GNAT.Case_Util (g-casuti.ads)::
11470 * GNAT.CGI (g-cgi.ads)::
11471 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11472 * GNAT.CGI.Debug (g-cgideb.ads)::
11473 * GNAT.Command_Line (g-comlin.ads)::
11474 * GNAT.Compiler_Version (g-comver.ads)::
11475 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11476 * GNAT.Current_Exception (g-curexc.ads)::
11477 * GNAT.Debug_Pools (g-debpoo.ads)::
11478 * GNAT.Debug_Utilities (g-debuti.ads)::
11479 * GNAT.Directory_Operations (g-dirope.ads)::
11480 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11481 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11482 * GNAT.Exception_Actions (g-excact.ads)::
11483 * GNAT.Exception_Traces (g-exctra.ads)::
11484 * GNAT.Exceptions (g-except.ads)::
11485 * GNAT.Expect (g-expect.ads)::
11486 * GNAT.Float_Control (g-flocon.ads)::
11487 * GNAT.Heap_Sort (g-heasor.ads)::
11488 * GNAT.Heap_Sort_A (g-hesora.ads)::
11489 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11490 * GNAT.HTable (g-htable.ads)::
11491 * GNAT.IO (g-io.ads)::
11492 * GNAT.IO_Aux (g-io_aux.ads)::
11493 * GNAT.Lock_Files (g-locfil.ads)::
11494 * GNAT.MD5 (g-md5.ads)::
11495 * GNAT.Memory_Dump (g-memdum.ads)::
11496 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11497 * GNAT.OS_Lib (g-os_lib.ads)::
11498 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11499 * GNAT.Regexp (g-regexp.ads)::
11500 * GNAT.Registry (g-regist.ads)::
11501 * GNAT.Regpat (g-regpat.ads)::
11502 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11503 * GNAT.Semaphores (g-semaph.ads)::
11504 * GNAT.Signals (g-signal.ads)::
11505 * GNAT.Sockets (g-socket.ads)::
11506 * GNAT.Source_Info (g-souinf.ads)::
11507 * GNAT.Spell_Checker (g-speche.ads)::
11508 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11509 * GNAT.Spitbol (g-spitbo.ads)::
11510 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11511 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11512 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11513 * GNAT.Strings (g-string.ads)::
11514 * GNAT.String_Split (g-strspl.ads)::
11515 * GNAT.Table (g-table.ads)::
11516 * GNAT.Task_Lock (g-tasloc.ads)::
11517 * GNAT.Threads (g-thread.ads)::
11518 * GNAT.Traceback (g-traceb.ads)::
11519 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11520 * GNAT.Wide_String_Split (g-wistsp.ads)::
11521 * Interfaces.C.Extensions (i-cexten.ads)::
11522 * Interfaces.C.Streams (i-cstrea.ads)::
11523 * Interfaces.CPP (i-cpp.ads)::
11524 * Interfaces.Os2lib (i-os2lib.ads)::
11525 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11526 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11527 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11528 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11529 * Interfaces.VxWorks (i-vxwork.ads)::
11530 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11531 * System.Address_Image (s-addima.ads)::
11532 * System.Assertions (s-assert.ads)::
11533 * System.Memory (s-memory.ads)::
11534 * System.Partition_Interface (s-parint.ads)::
11535 * System.Restrictions (s-restri.ads)::
11536 * System.Rident (s-rident.ads)::
11537 * System.Task_Info (s-tasinf.ads)::
11538 * System.Wch_Cnv (s-wchcnv.ads)::
11539 * System.Wch_Con (s-wchcon.ads)::
11540 @end menu
11541
11542 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11543 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11544 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11545 @cindex Latin_9 constants for Character
11546
11547 @noindent
11548 This child of @code{Ada.Characters}
11549 provides a set of definitions corresponding to those in the
11550 RM-defined package @code{Ada.Characters.Latin_1} but with the
11551 few modifications required for @code{Latin-9}
11552 The provision of such a package
11553 is specifically authorized by the Ada Reference Manual
11554 (RM A.3(27)).
11555
11556 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11557 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11558 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11559 @cindex Latin_1 constants for Wide_Character
11560
11561 @noindent
11562 This child of @code{Ada.Characters}
11563 provides a set of definitions corresponding to those in the
11564 RM-defined package @code{Ada.Characters.Latin_1} but with the
11565 types of the constants being @code{Wide_Character}
11566 instead of @code{Character}.  The provision of such a package
11567 is specifically authorized by the Ada Reference Manual
11568 (RM A.3(27)).
11569
11570 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11571 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11572 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11573 @cindex Latin_9 constants for Wide_Character
11574
11575 @noindent
11576 This child of @code{Ada.Characters}
11577 provides a set of definitions corresponding to those in the
11578 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11579 types of the constants being @code{Wide_Character}
11580 instead of @code{Character}.  The provision of such a package
11581 is specifically authorized by the Ada Reference Manual
11582 (RM A.3(27)).
11583
11584 @node Ada.Command_Line.Remove (a-colire.ads)
11585 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11586 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11587 @cindex Removing command line arguments
11588 @cindex Command line, argument removal
11589
11590 @noindent
11591 This child of @code{Ada.Command_Line}
11592 provides a mechanism for logically removing
11593 arguments from the argument list.  Once removed, an argument is not visible
11594 to further calls on the subprograms in @code{Ada.Command_Line} will not
11595 see the removed argument.
11596
11597 @node Ada.Command_Line.Environment (a-colien.ads)
11598 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11599 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11600 @cindex Environment entries
11601
11602 @noindent
11603 This child of @code{Ada.Command_Line}
11604 provides a mechanism for obtaining environment values on systems
11605 where this concept makes sense.
11606
11607 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11608 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11609 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11610 @cindex C Streams, Interfacing with Direct_IO
11611
11612 @noindent
11613 This package provides subprograms that allow interfacing between
11614 C streams and @code{Direct_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 Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11619 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11620 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11621 @cindex Null_Occurrence, testing for
11622
11623 @noindent
11624 This child subprogram provides a way of testing for the null
11625 exception occurrence (@code{Null_Occurrence}) without raising
11626 an exception.
11627
11628 @node Ada.Exceptions.Traceback (a-exctra.ads)
11629 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11630 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11631 @cindex Traceback for Exception Occurrence
11632
11633 @noindent
11634 This child package provides the subprogram (@code{Tracebacks}) to
11635 give a traceback array of addresses based on an exception
11636 occurrence.
11637
11638 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11639 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11640 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11641 @cindex C Streams, Interfacing with Sequential_IO
11642
11643 @noindent
11644 This package provides subprograms that allow interfacing between
11645 C streams and @code{Sequential_IO}.  The stream identifier can be
11646 extracted from a file opened on the Ada side, and an Ada file
11647 can be constructed from a stream opened on the C side.
11648
11649 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11650 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11651 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11652 @cindex C Streams, Interfacing with Stream_IO
11653
11654 @noindent
11655 This package provides subprograms that allow interfacing between
11656 C streams and @code{Stream_IO}.  The stream identifier can be
11657 extracted from a file opened on the Ada side, and an Ada file
11658 can be constructed from a stream opened on the C side.
11659
11660 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11661 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11662 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11663 @cindex @code{Unbounded_String}, IO support
11664 @cindex @code{Text_IO}, extensions for unbounded strings
11665
11666 @noindent
11667 This package provides subprograms for Text_IO for unbounded
11668 strings, avoiding the necessity for an intermediate operation
11669 with ordinary strings.
11670
11671 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11672 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11673 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11674 @cindex @code{Unbounded_Wide_String}, IO support
11675 @cindex @code{Text_IO}, extensions for unbounded wide strings
11676
11677 @noindent
11678 This package provides subprograms for Text_IO for unbounded
11679 wide strings, avoiding the necessity for an intermediate operation
11680 with ordinary wide strings.
11681
11682 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11683 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11684 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11685 @cindex C Streams, Interfacing with @code{Text_IO}
11686
11687 @noindent
11688 This package provides subprograms that allow interfacing between
11689 C streams and @code{Text_IO}.  The stream identifier can be
11690 extracted from a file opened on the Ada side, and an Ada file
11691 can be constructed from a stream opened on the C side.
11692
11693 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11694 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11695 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11696 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11697
11698 @noindent
11699 This package provides subprograms that allow interfacing between
11700 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11701 extracted from a file opened on the Ada side, and an Ada file
11702 can be constructed from a stream opened on the C side.
11703
11704 @node GNAT.Array_Split (g-arrspl.ads)
11705 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11706 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11707 @cindex Array splitter
11708
11709 @noindent
11710 Useful array-manipulation routines: given a set of separators, split
11711 an array wherever the separators appear, and provide direct access
11712 to the resulting slices.
11713
11714 @node GNAT.AWK (g-awk.ads)
11715 @section @code{GNAT.AWK} (@file{g-awk.ads})
11716 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11717 @cindex Parsing
11718 @cindex AWK
11719
11720 @noindent
11721 Provides AWK-like parsing functions, with an easy interface for parsing one
11722 or more files containing formatted data.  The file is viewed as a database
11723 where each record is a line and a field is a data element in this line.
11724
11725 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11726 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11727 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11728 @cindex Parsing
11729 @cindex Bounded Buffers
11730
11731 @noindent
11732 Provides a concurrent generic bounded buffer abstraction.  Instances are
11733 useful directly or as parts of the implementations of other abstractions,
11734 such as mailboxes.
11735
11736 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11737 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11738 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11739 @cindex Parsing
11740 @cindex Mailboxes
11741
11742 @noindent
11743 Provides a thread-safe asynchronous intertask mailbox communication facility.
11744
11745 @node GNAT.Bubble_Sort (g-bubsor.ads)
11746 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11747 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11748 @cindex Sorting
11749 @cindex Bubble sort
11750
11751 @noindent
11752 Provides a general implementation of bubble sort usable for sorting arbitrary
11753 data items.  Exchange and comparison procedures are provided by passing
11754 access-to-procedure values.
11755
11756 @node GNAT.Bubble_Sort_A (g-busora.ads)
11757 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11758 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11759 @cindex Sorting
11760 @cindex Bubble sort
11761
11762 @noindent
11763 Provides a general implementation of bubble sort usable for sorting arbitrary
11764 data items.  Move and comparison procedures are provided by passing
11765 access-to-procedure values. This is an older version, retained for
11766 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11767
11768 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11769 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11770 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11771 @cindex Sorting
11772 @cindex Bubble sort
11773
11774 @noindent
11775 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11776 are provided as generic parameters, this improves efficiency, especially
11777 if the procedures can be inlined, at the expense of duplicating code for
11778 multiple instantiations.
11779
11780 @node GNAT.Calendar (g-calend.ads)
11781 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11782 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11783 @cindex @code{Calendar}
11784
11785 @noindent
11786 Extends the facilities provided by @code{Ada.Calendar} to include handling
11787 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11788 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11789 C @code{timeval} format.
11790
11791 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11792 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11793 @cindex @code{Calendar}
11794 @cindex Time
11795 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11796
11797 @node GNAT.CRC32 (g-crc32.ads)
11798 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11799 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11800 @cindex CRC32
11801 @cindex Cyclic Redundancy Check
11802
11803 @noindent
11804 This package implements the CRC-32 algorithm.  For a full description
11805 of this algorithm see
11806 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11807 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11808 Aug.@: 1988.  Sarwate, D.V@.
11809
11810 @noindent
11811 Provides an extended capability for formatted output of time values with
11812 full user control over the format.  Modeled on the GNU Date specification.
11813
11814 @node GNAT.Case_Util (g-casuti.ads)
11815 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11816 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11817 @cindex Casing utilities
11818 @cindex Character handling (@code{GNAT.Case_Util})
11819
11820 @noindent
11821 A set of simple routines for handling upper and lower casing of strings
11822 without the overhead of the full casing tables
11823 in @code{Ada.Characters.Handling}.
11824
11825 @node GNAT.CGI (g-cgi.ads)
11826 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11827 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11828 @cindex CGI (Common Gateway Interface)
11829
11830 @noindent
11831 This is a package for interfacing a GNAT program with a Web server via the
11832 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11833 parameters, which are a set of key/value pairs sent by the Web server.  It
11834 builds a table whose index is the key and provides some services to deal
11835 with this table.
11836
11837 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11838 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11839 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11840 @cindex CGI (Common Gateway Interface) cookie support
11841 @cindex Cookie support in CGI
11842
11843 @noindent
11844 This is a package to interface a GNAT program with a Web server via the
11845 Common Gateway Interface (CGI).  It exports services to deal with Web
11846 cookies (piece of information kept in the Web client software).
11847
11848 @node GNAT.CGI.Debug (g-cgideb.ads)
11849 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11850 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11851 @cindex CGI (Common Gateway Interface) debugging
11852
11853 @noindent
11854 This is a package to help debugging CGI (Common Gateway Interface)
11855 programs written in Ada.
11856
11857 @node GNAT.Command_Line (g-comlin.ads)
11858 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11859 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11860 @cindex Command line
11861
11862 @noindent
11863 Provides a high level interface to @code{Ada.Command_Line} facilities,
11864 including the ability to scan for named switches with optional parameters
11865 and expand file names using wild card notations.
11866
11867 @node GNAT.Compiler_Version (g-comver.ads)
11868 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11869 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11870 @cindex Compiler Version
11871 @cindex Version, of compiler
11872
11873 @noindent
11874 Provides a routine for obtaining the version of the compiler used to
11875 compile the program. More accurately this is the version of the binder
11876 used to bind the program (this will normally be the same as the version
11877 of the compiler if a consistent tool set is used to compile all units
11878 of a partition).
11879
11880 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11881 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11882 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11883 @cindex Interrupt
11884
11885 @noindent
11886 Provides a simple interface to handle Ctrl-C keyboard events.
11887
11888 @node GNAT.Current_Exception (g-curexc.ads)
11889 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11890 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11891 @cindex Current exception
11892 @cindex Exception retrieval
11893
11894 @noindent
11895 Provides access to information on the current exception that has been raised
11896 without the need for using the Ada-95 exception choice parameter specification
11897 syntax.  This is particularly useful in simulating typical facilities for
11898 obtaining information about exceptions provided by Ada 83 compilers.
11899
11900 @node GNAT.Debug_Pools (g-debpoo.ads)
11901 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11902 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11903 @cindex Debugging
11904 @cindex Debug pools
11905 @cindex Memory corruption debugging
11906
11907 @noindent
11908 Provide a debugging storage pools that helps tracking memory corruption
11909 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11910 the @cite{GNAT User's Guide}.
11911
11912 @node GNAT.Debug_Utilities (g-debuti.ads)
11913 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11914 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11915 @cindex Debugging
11916
11917 @noindent
11918 Provides a few useful utilities for debugging purposes, including conversion
11919 to and from string images of address values. Supports both C and Ada formats
11920 for hexadecimal literals.
11921
11922 @node GNAT.Directory_Operations (g-dirope.ads)
11923 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11924 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11925 @cindex Directory operations
11926
11927 @noindent
11928 Provides a set of routines for manipulating directories, including changing
11929 the current directory, making new directories, and scanning the files in a
11930 directory.
11931
11932 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11933 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11934 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11935 @cindex Hash tables
11936
11937 @noindent
11938 A generic implementation of hash tables that can be used to hash arbitrary
11939 data.  Provided in two forms, a simple form with built in hash functions,
11940 and a more complex form in which the hash function is supplied.
11941
11942 @noindent
11943 This package provides a facility similar to that of @code{GNAT.HTable},
11944 except that this package declares a type that can be used to define
11945 dynamic instances of the hash table, while an instantiation of
11946 @code{GNAT.HTable} creates a single instance of the hash table.
11947
11948 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11949 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11950 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11951 @cindex Table implementation
11952 @cindex Arrays, extendable
11953
11954 @noindent
11955 A generic package providing a single dimension array abstraction where the
11956 length of the array can be dynamically modified.
11957
11958 @noindent
11959 This package provides a facility similar to that of @code{GNAT.Table},
11960 except that this package declares a type that can be used to define
11961 dynamic instances of the table, while an instantiation of
11962 @code{GNAT.Table} creates a single instance of the table type.
11963
11964 @node GNAT.Exception_Actions (g-excact.ads)
11965 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11966 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11967 @cindex Exception actions
11968
11969 @noindent
11970 Provides callbacks when an exception is raised. Callbacks can be registered
11971 for specific exceptions, or when any exception is raised. This
11972 can be used for instance to force a core dump to ease debugging.
11973
11974 @node GNAT.Exception_Traces (g-exctra.ads)
11975 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11976 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11977 @cindex Exception traces
11978 @cindex Debugging
11979
11980 @noindent
11981 Provides an interface allowing to control automatic output upon exception
11982 occurrences.
11983
11984 @node GNAT.Exceptions (g-except.ads)
11985 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11986 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11987 @cindex Exceptions, Pure
11988 @cindex Pure packages, exceptions
11989
11990 @noindent
11991 Normally it is not possible to raise an exception with
11992 a message from a subprogram in a pure package, since the
11993 necessary types and subprograms are in @code{Ada.Exceptions}
11994 which is not a pure unit. @code{GNAT.Exceptions} provides a
11995 facility for getting around this limitation for a few
11996 predefined exceptions, and for example allow raising
11997 @code{Constraint_Error} with a message from a pure subprogram.
11998
11999 @node GNAT.Expect (g-expect.ads)
12000 @section @code{GNAT.Expect} (@file{g-expect.ads})
12001 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
12002
12003 @noindent
12004 Provides a set of subprograms similar to what is available
12005 with the standard Tcl Expect tool.
12006 It allows you to easily spawn and communicate with an external process.
12007 You can send commands or inputs to the process, and compare the output
12008 with some expected regular expression. Currently @code{GNAT.Expect}
12009 is implemented on all native GNAT ports except for OpenVMS@.
12010 It is not implemented for cross ports, and in particular is not
12011 implemented for VxWorks or LynxOS@.
12012
12013 @node GNAT.Float_Control (g-flocon.ads)
12014 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
12015 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
12016 @cindex Floating-Point Processor
12017
12018 @noindent
12019 Provides an interface for resetting the floating-point processor into the
12020 mode required for correct semantic operation in Ada.  Some third party
12021 library calls may cause this mode to be modified, and the Reset procedure
12022 in this package can be used to reestablish the required mode.
12023
12024 @node GNAT.Heap_Sort (g-heasor.ads)
12025 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12026 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12027 @cindex Sorting
12028
12029 @noindent
12030 Provides a general implementation of heap sort usable for sorting arbitrary
12031 data items. Exchange and comparison procedures are provided by passing
12032 access-to-procedure values.  The algorithm used is a modified heap sort
12033 that performs approximately N*log(N) comparisons in the worst case.
12034
12035 @node GNAT.Heap_Sort_A (g-hesora.ads)
12036 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12037 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12038 @cindex Sorting
12039
12040 @noindent
12041 Provides a general implementation of heap sort usable for sorting arbitrary
12042 data items. Move and comparison procedures are provided by passing
12043 access-to-procedure values.  The algorithm used is a modified heap sort
12044 that performs approximately N*log(N) comparisons in the worst case.
12045 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12046 interface, but may be slightly more efficient.
12047
12048 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12049 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12050 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12051 @cindex Sorting
12052
12053 @noindent
12054 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12055 are provided as generic parameters, this improves efficiency, especially
12056 if the procedures can be inlined, at the expense of duplicating code for
12057 multiple instantiations.
12058
12059 @node GNAT.HTable (g-htable.ads)
12060 @section @code{GNAT.HTable} (@file{g-htable.ads})
12061 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12062 @cindex Hash tables
12063
12064 @noindent
12065 A generic implementation of hash tables that can be used to hash arbitrary
12066 data.  Provides two approaches, one a simple static approach, and the other
12067 allowing arbitrary dynamic hash tables.
12068
12069 @node GNAT.IO (g-io.ads)
12070 @section @code{GNAT.IO} (@file{g-io.ads})
12071 @cindex @code{GNAT.IO} (@file{g-io.ads})
12072 @cindex Simple I/O
12073 @cindex Input/Output facilities
12074
12075 @noindent
12076 A simple preelaborable input-output package that provides a subset of
12077 simple Text_IO functions for reading characters and strings from
12078 Standard_Input, and writing characters, strings and integers to either
12079 Standard_Output or Standard_Error.
12080
12081 @node GNAT.IO_Aux (g-io_aux.ads)
12082 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12083 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12084 @cindex Text_IO
12085 @cindex Input/Output facilities
12086
12087 Provides some auxiliary functions for use with Text_IO, including a test
12088 for whether a file exists, and functions for reading a line of text.
12089
12090 @node GNAT.Lock_Files (g-locfil.ads)
12091 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12092 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12093 @cindex File locking
12094 @cindex Locking using files
12095
12096 @noindent
12097 Provides a general interface for using files as locks.  Can be used for
12098 providing program level synchronization.
12099
12100 @node GNAT.MD5 (g-md5.ads)
12101 @section @code{GNAT.MD5} (@file{g-md5.ads})
12102 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12103 @cindex Message Digest MD5
12104
12105 @noindent
12106 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12107
12108 @node GNAT.Memory_Dump (g-memdum.ads)
12109 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12110 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12111 @cindex Dump Memory
12112
12113 @noindent
12114 Provides a convenient routine for dumping raw memory to either the
12115 standard output or standard error files. Uses GNAT.IO for actual
12116 output.
12117
12118 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12119 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12120 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12121 @cindex Exception, obtaining most recent
12122
12123 @noindent
12124 Provides access to the most recently raised exception.  Can be used for
12125 various logging purposes, including duplicating functionality of some
12126 Ada 83 implementation dependent extensions.
12127
12128 @node GNAT.OS_Lib (g-os_lib.ads)
12129 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12130 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12131 @cindex Operating System interface
12132 @cindex Spawn capability
12133
12134 @noindent
12135 Provides a range of target independent operating system interface functions,
12136 including time/date management, file operations, subprocess management,
12137 including a portable spawn procedure, and access to environment variables
12138 and error return codes.
12139
12140 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12141 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12142 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12143 @cindex Hash functions
12144
12145 @noindent
12146 Provides a generator of static minimal perfect hash functions. No
12147 collisions occur and each item can be retrieved from the table in one
12148 probe (perfect property). The hash table size corresponds to the exact
12149 size of the key set and no larger (minimal property). The key set has to
12150 be know in advance (static property). The hash functions are also order
12151 preservering. If w2 is inserted after w1 in the generator, their
12152 hashcode are in the same order. These hashing functions are very
12153 convenient for use with realtime applications.
12154
12155 @node GNAT.Regexp (g-regexp.ads)
12156 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12157 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12158 @cindex Regular expressions
12159 @cindex Pattern matching
12160
12161 @noindent
12162 A simple implementation of regular expressions, using a subset of regular
12163 expression syntax copied from familiar Unix style utilities.  This is the
12164 simples of the three pattern matching packages provided, and is particularly
12165 suitable for ``file globbing'' applications.
12166
12167 @node GNAT.Registry (g-regist.ads)
12168 @section @code{GNAT.Registry} (@file{g-regist.ads})
12169 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12170 @cindex Windows Registry
12171
12172 @noindent
12173 This is a high level binding to the Windows registry.  It is possible to
12174 do simple things like reading a key value, creating a new key.  For full
12175 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12176 package provided with the Win32Ada binding
12177
12178 @node GNAT.Regpat (g-regpat.ads)
12179 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12180 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12181 @cindex Regular expressions
12182 @cindex Pattern matching
12183
12184 @noindent
12185 A complete implementation of Unix-style regular expression matching, copied
12186 from the original V7 style regular expression library written in C by
12187 Henry Spencer (and binary compatible with this C library).
12188
12189 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12190 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12191 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12192 @cindex Secondary Stack Info
12193
12194 @noindent
12195 Provide the capability to query the high water mark of the current task's
12196 secondary stack.
12197
12198 @node GNAT.Semaphores (g-semaph.ads)
12199 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12200 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12201 @cindex Semaphores
12202
12203 @noindent
12204 Provides classic counting and binary semaphores using protected types.
12205
12206 @node GNAT.Signals (g-signal.ads)
12207 @section @code{GNAT.Signals} (@file{g-signal.ads})
12208 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12209 @cindex Signals
12210
12211 @noindent
12212 Provides the ability to manipulate the blocked status of signals on supported
12213 targets.
12214
12215 @node GNAT.Sockets (g-socket.ads)
12216 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12217 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12218 @cindex Sockets
12219
12220 @noindent
12221 A high level and portable interface to develop sockets based applications.
12222 This package is based on the sockets thin binding found in
12223 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12224 on all native GNAT ports except for OpenVMS@.  It is not implemented
12225 for the LynxOS@ cross port.
12226
12227 @node GNAT.Source_Info (g-souinf.ads)
12228 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12229 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12230 @cindex Source Information
12231
12232 @noindent
12233 Provides subprograms that give access to source code information known at
12234 compile time, such as the current file name and line number.
12235
12236 @node GNAT.Spell_Checker (g-speche.ads)
12237 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12238 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12239 @cindex Spell checking
12240
12241 @noindent
12242 Provides a function for determining whether one string is a plausible
12243 near misspelling of another string.
12244
12245 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12246 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12247 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12248 @cindex SPITBOL pattern matching
12249 @cindex Pattern matching
12250
12251 @noindent
12252 A complete implementation of SNOBOL4 style pattern matching.  This is the
12253 most elaborate of the pattern matching packages provided.  It fully duplicates
12254 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12255 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12256
12257 @node GNAT.Spitbol (g-spitbo.ads)
12258 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12259 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12260 @cindex SPITBOL interface
12261
12262 @noindent
12263 The top level package of the collection of SPITBOL-style functionality, this
12264 package provides basic SNOBOL4 string manipulation functions, such as
12265 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12266 useful for constructing arbitrary mappings from strings in the style of
12267 the SNOBOL4 TABLE function.
12268
12269 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12270 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12271 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12272 @cindex Sets of strings
12273 @cindex SPITBOL Tables
12274
12275 @noindent
12276 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12277 for type @code{Standard.Boolean}, giving an implementation of sets of
12278 string values.
12279
12280 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12281 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12282 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12283 @cindex Integer maps
12284 @cindex Maps
12285 @cindex SPITBOL Tables
12286
12287 @noindent
12288 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12289 for type @code{Standard.Integer}, giving an implementation of maps
12290 from string to integer values.
12291
12292 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12293 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12294 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12295 @cindex String maps
12296 @cindex Maps
12297 @cindex SPITBOL Tables
12298
12299 @noindent
12300 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12301 a variable length string type, giving an implementation of general
12302 maps from strings to strings.
12303
12304 @node GNAT.Strings (g-string.ads)
12305 @section @code{GNAT.Strings} (@file{g-string.ads})
12306 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12307
12308 @noindent
12309 Common String access types and related subprograms. Basically it
12310 defines a string access and an array of string access types.
12311
12312 @node GNAT.String_Split (g-strspl.ads)
12313 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12314 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12315 @cindex String splitter
12316
12317 @noindent
12318 Useful string-manipulation routines: given a set of separators, split
12319 a string wherever the separators appear, and provide direct access
12320 to the resulting slices. This package is instantiated from
12321 @code{GNAT.Array_Split}.
12322
12323 @node GNAT.Table (g-table.ads)
12324 @section @code{GNAT.Table} (@file{g-table.ads})
12325 @cindex @code{GNAT.Table} (@file{g-table.ads})
12326 @cindex Table implementation
12327 @cindex Arrays, extendable
12328
12329 @noindent
12330 A generic package providing a single dimension array abstraction where the
12331 length of the array can be dynamically modified.
12332
12333 @noindent
12334 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12335 except that this package declares a single instance of the table type,
12336 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12337 used to define dynamic instances of the table.
12338
12339 @node GNAT.Task_Lock (g-tasloc.ads)
12340 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12341 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12342 @cindex Task synchronization
12343 @cindex Task locking
12344 @cindex Locking
12345
12346 @noindent
12347 A very simple facility for locking and unlocking sections of code using a
12348 single global task lock.  Appropriate for use in situations where contention
12349 between tasks is very rarely expected.
12350
12351 @node GNAT.Threads (g-thread.ads)
12352 @section @code{GNAT.Threads} (@file{g-thread.ads})
12353 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12354 @cindex Foreign threads
12355 @cindex Threads, foreign
12356
12357 @noindent
12358 Provides facilities for creating and destroying threads with explicit calls.
12359 These threads are known to the GNAT run-time system.  These subprograms are
12360 exported C-convention procedures intended to be called from foreign code.
12361 By using these primitives rather than directly calling operating systems
12362 routines, compatibility with the Ada tasking runt-time is provided.
12363
12364 @node GNAT.Traceback (g-traceb.ads)
12365 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12366 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12367 @cindex Trace back facilities
12368
12369 @noindent
12370 Provides a facility for obtaining non-symbolic traceback information, useful
12371 in various debugging situations.
12372
12373 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12374 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12375 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12376 @cindex Trace back facilities
12377
12378 @noindent
12379 Provides symbolic traceback information that includes the subprogram
12380 name and line number information.
12381
12382 @node GNAT.Wide_String_Split (g-wistsp.ads)
12383 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12384 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12385 @cindex Wide_String splitter
12386
12387 @noindent
12388 Useful wide_string-manipulation routines: given a set of separators, split
12389 a wide_string wherever the separators appear, and provide direct access
12390 to the resulting slices. This package is instantiated from
12391 @code{GNAT.Array_Split}.
12392
12393 @node Interfaces.C.Extensions (i-cexten.ads)
12394 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12395 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12396
12397 @noindent
12398 This package contains additional C-related definitions, intended
12399 for use with either manually or automatically generated bindings
12400 to C libraries.
12401
12402 @node Interfaces.C.Streams (i-cstrea.ads)
12403 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12404 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12405 @cindex  C streams, interfacing
12406
12407 @noindent
12408 This package is a binding for the most commonly used operations
12409 on C streams.
12410
12411 @node Interfaces.CPP (i-cpp.ads)
12412 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12413 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12414 @cindex  C++ interfacing
12415 @cindex  Interfacing, to C++
12416
12417 @noindent
12418 This package provides facilities for use in interfacing to C++.  It
12419 is primarily intended to be used in connection with automated tools
12420 for the generation of C++ interfaces.
12421
12422 @node Interfaces.Os2lib (i-os2lib.ads)
12423 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12424 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12425 @cindex Interfacing, to OS/2
12426 @cindex OS/2 interfacing
12427
12428 @noindent
12429 This package provides interface definitions to the OS/2 library.
12430 It is a thin binding which is a direct translation of the
12431 various @file{<bse@.h>} files.
12432
12433 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12434 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12435 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12436 @cindex OS/2 Error codes
12437 @cindex Interfacing, to OS/2
12438 @cindex OS/2 interfacing
12439
12440 @noindent
12441 This package provides definitions of the OS/2 error codes.
12442
12443 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12444 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12445 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12446 @cindex Interfacing, to OS/2
12447 @cindex Synchronization, OS/2
12448 @cindex OS/2 synchronization primitives
12449
12450 @noindent
12451 This is a child package that provides definitions for interfacing
12452 to the @code{OS/2} synchronization primitives.
12453
12454 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12455 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12456 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12457 @cindex Interfacing, to OS/2
12458 @cindex Thread control, OS/2
12459 @cindex OS/2 thread interfacing
12460
12461 @noindent
12462 This is a child package that provides definitions for interfacing
12463 to the @code{OS/2} thread primitives.
12464
12465 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12466 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12467 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12468 @cindex  IBM Packed Format
12469 @cindex  Packed Decimal
12470
12471 @noindent
12472 This package provides a set of routines for conversions to and
12473 from a packed decimal format compatible with that used on IBM
12474 mainframes.
12475
12476 @node Interfaces.VxWorks (i-vxwork.ads)
12477 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12478 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12479 @cindex Interfacing to VxWorks
12480 @cindex VxWorks, interfacing
12481
12482 @noindent
12483 This package provides a limited binding to the VxWorks API.
12484 In particular, it interfaces with the
12485 VxWorks hardware interrupt facilities.
12486
12487 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12488 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12489 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12490 @cindex Interfacing to VxWorks' I/O
12491 @cindex VxWorks, I/O interfacing
12492 @cindex VxWorks, Get_Immediate
12493 @cindex Get_Immediate, VxWorks
12494
12495 @noindent
12496 This package provides a binding to the ioctl (IO/Control)
12497 function of VxWorks, defining a set of option values and
12498 function codes. A particular use of this package is
12499 to enable the use of Get_Immediate under VxWorks.
12500
12501 @node System.Address_Image (s-addima.ads)
12502 @section @code{System.Address_Image} (@file{s-addima.ads})
12503 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12504 @cindex Address image
12505 @cindex Image, of an address
12506
12507 @noindent
12508 This function provides a useful debugging
12509 function that gives an (implementation dependent)
12510 string which identifies an address.
12511
12512 @node System.Assertions (s-assert.ads)
12513 @section @code{System.Assertions} (@file{s-assert.ads})
12514 @cindex @code{System.Assertions} (@file{s-assert.ads})
12515 @cindex Assertions
12516 @cindex Assert_Failure, exception
12517
12518 @noindent
12519 This package provides the declaration of the exception raised
12520 by an run-time assertion failure, as well as the routine that
12521 is used internally to raise this assertion.
12522
12523 @node System.Memory (s-memory.ads)
12524 @section @code{System.Memory} (@file{s-memory.ads})
12525 @cindex @code{System.Memory} (@file{s-memory.ads})
12526 @cindex Memory allocation
12527
12528 @noindent
12529 This package provides the interface to the low level routines used
12530 by the generated code for allocation and freeing storage for the
12531 default storage pool (analogous to the C routines malloc and free.
12532 It also provides a reallocation interface analogous to the C routine
12533 realloc. The body of this unit may be modified to provide alternative
12534 allocation mechanisms for the default pool, and in addition, direct
12535 calls to this unit may be made for low level allocation uses (for
12536 example see the body of @code{GNAT.Tables}).
12537
12538 @node System.Partition_Interface (s-parint.ads)
12539 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12540 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12541 @cindex Partition intefacing functions
12542
12543 @noindent
12544 This package provides facilities for partition interfacing.  It
12545 is used primarily in a distribution context when using Annex E
12546 with @code{GLADE}.
12547
12548 @node System.Restrictions (s-restri.ads)
12549 @section @code{System.Restrictions} (@file{s-restri.ads})
12550 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12551 @cindex Run-time restrictions access
12552
12553 @noindent
12554 This package provides facilities for accessing at run-time
12555 the status of restrictions specified at compile time for
12556 the partition. Information is available both with regard
12557 to actual restrictions specified, and with regard to
12558 compiler determined information on which restrictions
12559 are violated by one or more packages in the partition.
12560
12561 @node System.Rident (s-rident.ads)
12562 @section @code{System.Rident} (@file{s-rident.ads})
12563 @cindex @code{System.Rident} (@file{s-rident.ads})
12564 @cindex Restrictions definitions
12565
12566 @noindent
12567 This package provides definitions of the restrictions
12568 identifiers supported by GNAT, and also the format of
12569 the restrictions provided in package System.Restrictions.
12570 It is not normally necessary to @code{with} this generic package
12571 since the necessary instantiation is included in
12572 package System.Restrictions.
12573
12574 @node System.Task_Info (s-tasinf.ads)
12575 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12576 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12577 @cindex Task_Info pragma
12578
12579 @noindent
12580 This package provides target dependent functionality that is used
12581 to support the @code{Task_Info} pragma
12582
12583 @node System.Wch_Cnv (s-wchcnv.ads)
12584 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12585 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12586 @cindex Wide Character, Representation
12587 @cindex Wide String, Conversion
12588 @cindex Representation of wide characters
12589
12590 @noindent
12591 This package provides routines for converting between
12592 wide characters and a representation as a value of type
12593 @code{Standard.String}, using a specified wide character
12594 encoding method.  It uses definitions in
12595 package @code{System.Wch_Con}.
12596
12597 @node System.Wch_Con (s-wchcon.ads)
12598 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12599 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12600
12601 @noindent
12602 This package provides definitions and descriptions of
12603 the various methods used for encoding wide characters
12604 in ordinary strings.  These definitions are used by
12605 the package @code{System.Wch_Cnv}.
12606
12607 @node Interfacing to Other Languages
12608 @chapter Interfacing to Other Languages
12609 @noindent
12610 The facilities in annex B of the Ada 95 Reference Manual are fully
12611 implemented in GNAT, and in addition, a full interface to C++ is
12612 provided.
12613
12614 @menu
12615 * Interfacing to C::
12616 * Interfacing to C++::
12617 * Interfacing to COBOL::
12618 * Interfacing to Fortran::
12619 * Interfacing to non-GNAT Ada code::
12620 @end menu
12621
12622 @node Interfacing to C
12623 @section Interfacing to C
12624
12625 @noindent
12626 Interfacing to C with GNAT can use one of two approaches:
12627
12628 @itemize @bullet
12629 @item
12630 The types in the package @code{Interfaces.C} may be used.
12631 @item
12632 Standard Ada types may be used directly.  This may be less portable to
12633 other compilers, but will work on all GNAT compilers, which guarantee
12634 correspondence between the C and Ada types.
12635 @end itemize
12636
12637 @noindent
12638 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12639 effect, since this is the default.  The following table shows the
12640 correspondence between Ada scalar types and the corresponding C types.
12641
12642 @table @code
12643 @item Integer
12644 @code{int}
12645 @item Short_Integer
12646 @code{short}
12647 @item Short_Short_Integer
12648 @code{signed char}
12649 @item Long_Integer
12650 @code{long}
12651 @item Long_Long_Integer
12652 @code{long long}
12653 @item Short_Float
12654 @code{float}
12655 @item Float
12656 @code{float}
12657 @item Long_Float
12658 @code{double}
12659 @item Long_Long_Float
12660 This is the longest floating-point type supported by the hardware.
12661 @end table
12662
12663 @noindent
12664 Additionally, there are the following general correspondences between Ada
12665 and C types:
12666 @itemize @bullet
12667 @item
12668 Ada enumeration types map to C enumeration types directly if pragma
12669 @code{Convention C} is specified, which causes them to have int
12670 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12671 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12672 @code{int}, respectively) depending on the number of values passed.
12673 This is the only case in which pragma @code{Convention C} affects the
12674 representation of an Ada type.
12675
12676 @item
12677 Ada access types map to C pointers, except for the case of pointers to
12678 unconstrained types in Ada, which have no direct C equivalent.
12679
12680 @item
12681 Ada arrays map directly to C arrays.
12682
12683 @item
12684 Ada records map directly to C structures.
12685
12686 @item
12687 Packed Ada records map to C structures where all members are bit fields
12688 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12689 @end itemize
12690
12691 @node Interfacing to C++
12692 @section Interfacing to C++
12693
12694 @noindent
12695 The interface to C++ makes use of the following pragmas, which are
12696 primarily intended to be constructed automatically using a binding generator
12697 tool, although it is possible to construct them by hand.  No suitable binding
12698 generator tool is supplied with GNAT though.
12699
12700 Using these pragmas it is possible to achieve complete
12701 inter-operability between Ada tagged types and C class definitions.
12702 See @ref{Implementation Defined Pragmas}, for more details.
12703
12704 @table @code
12705 @item pragma CPP_Class ([Entity =>] @var{local_name})
12706 The argument denotes an entity in the current declarative region that is
12707 declared as a tagged or untagged record type.  It indicates that the type
12708 corresponds to an externally declared C++ class type, and is to be laid
12709 out the same way that C++ would lay out the type.
12710
12711 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12712 This pragma identifies an imported function (imported in the usual way
12713 with pragma @code{Import}) as corresponding to a C++ constructor.
12714
12715 @item pragma CPP_Vtable @dots{}
12716 One @code{CPP_Vtable} pragma can be present for each component of type
12717 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12718 applies.
12719 @end table
12720
12721 @node Interfacing to COBOL
12722 @section Interfacing to COBOL
12723
12724 @noindent
12725 Interfacing to COBOL is achieved as described in section B.4 of
12726 the Ada 95 reference manual.
12727
12728 @node Interfacing to Fortran
12729 @section Interfacing to Fortran
12730
12731 @noindent
12732 Interfacing to Fortran is achieved as described in section B.5 of the
12733 reference manual.  The pragma @code{Convention Fortran}, applied to a
12734 multi-dimensional array causes the array to be stored in column-major
12735 order as required for convenient interface to Fortran.
12736
12737 @node Interfacing to non-GNAT Ada code
12738 @section Interfacing to non-GNAT Ada code
12739
12740 It is possible to specify the convention @code{Ada} in a pragma
12741 @code{Import} or pragma @code{Export}.  However this refers to
12742 the calling conventions used by GNAT, which may or may not be
12743 similar enough to those used by some other Ada 83 or Ada 95
12744 compiler to allow interoperation.
12745
12746 If arguments types are kept simple, and if the foreign compiler generally
12747 follows system calling conventions, then it may be possible to integrate
12748 files compiled by other Ada compilers, provided that the elaboration
12749 issues are adequately addressed (for example by eliminating the
12750 need for any load time elaboration).
12751
12752 In particular, GNAT running on VMS is designed to
12753 be highly compatible with the DEC Ada 83 compiler, so this is one
12754 case in which it is possible to import foreign units of this type,
12755 provided that the data items passed are restricted to simple scalar
12756 values or simple record types without variants, or simple array
12757 types with fixed bounds.
12758
12759 @node Specialized Needs Annexes
12760 @chapter Specialized Needs Annexes
12761
12762 @noindent
12763 Ada 95 defines a number of specialized needs annexes, which are not
12764 required in all implementations.  However, as described in this chapter,
12765 GNAT implements all of these special needs annexes:
12766
12767 @table @asis
12768 @item Systems Programming (Annex C)
12769 The Systems Programming Annex is fully implemented.
12770
12771 @item Real-Time Systems (Annex D)
12772 The Real-Time Systems Annex is fully implemented.
12773
12774 @item Distributed Systems (Annex E)
12775 Stub generation is fully implemented in the GNAT compiler.  In addition,
12776 a complete compatible PCS is available as part of the GLADE system,
12777 a separate product.  When the two
12778 products are used in conjunction, this annex is fully implemented.
12779
12780 @item Information Systems (Annex F)
12781 The Information Systems annex is fully implemented.
12782
12783 @item Numerics (Annex G)
12784 The Numerics Annex is fully implemented.
12785
12786 @item Safety and Security (Annex H)
12787 The Safety and Security annex is fully implemented.
12788 @end table
12789
12790 @node Implementation of Specific Ada Features
12791 @chapter Implementation of Specific Ada Features
12792
12793 @noindent
12794 This chapter describes the GNAT implementation of several Ada language
12795 facilities.
12796
12797 @menu
12798 * Machine Code Insertions::
12799 * GNAT Implementation of Tasking::
12800 * GNAT Implementation of Shared Passive Packages::
12801 * Code Generation for Array Aggregates::
12802 * The Size of Discriminated Records with Default Discriminants::
12803 @end menu
12804
12805 @node Machine Code Insertions
12806 @section Machine Code Insertions
12807
12808 @noindent
12809 Package @code{Machine_Code} provides machine code support as described
12810 in the Ada 95 Reference Manual in two separate forms:
12811 @itemize @bullet
12812 @item
12813 Machine code statements, consisting of qualified expressions that
12814 fit the requirements of RM section 13.8.
12815 @item
12816 An intrinsic callable procedure, providing an alternative mechanism of
12817 including machine instructions in a subprogram.
12818 @end itemize
12819
12820 @noindent
12821 The two features are similar, and both are closely related to the mechanism
12822 provided by the asm instruction in the GNU C compiler.  Full understanding
12823 and use of the facilities in this package requires understanding the asm
12824 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12825 by Richard Stallman. The relevant section is titled ``Extensions to the C
12826 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12827
12828 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12829 semantic restrictions and effects as described below.  Both are provided so
12830 that the procedure call can be used as a statement, and the function call
12831 can be used to form a code_statement.
12832
12833 The first example given in the GCC documentation is the C @code{asm}
12834 instruction:
12835 @smallexample
12836    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12837 @end smallexample
12838
12839 @noindent
12840 The equivalent can be written for GNAT as:
12841
12842 @smallexample @c ada
12843 Asm ("fsinx %1 %0",
12844      My_Float'Asm_Output ("=f", result),
12845      My_Float'Asm_Input  ("f",  angle));
12846 @end smallexample
12847
12848 @noindent
12849 The first argument to @code{Asm} is the assembler template, and is
12850 identical to what is used in GNU C@.  This string must be a static
12851 expression.  The second argument is the output operand list.  It is
12852 either a single @code{Asm_Output} attribute reference, or a list of such
12853 references enclosed in parentheses (technically an array aggregate of
12854 such references).
12855
12856 The @code{Asm_Output} attribute denotes a function that takes two
12857 parameters.  The first is a string, the second is the name of a variable
12858 of the type designated by the attribute prefix.  The first (string)
12859 argument is required to be a static expression and designates the
12860 constraint for the parameter (e.g.@: what kind of register is
12861 required).  The second argument is the variable to be updated with the
12862 result.  The possible values for constraint are the same as those used in
12863 the RTL, and are dependent on the configuration file used to build the
12864 GCC back end.  If there are no output operands, then this argument may
12865 either be omitted, or explicitly given as @code{No_Output_Operands}.
12866
12867 The second argument of @code{@var{my_float}'Asm_Output} functions as
12868 though it were an @code{out} parameter, which is a little curious, but
12869 all names have the form of expressions, so there is no syntactic
12870 irregularity, even though normally functions would not be permitted
12871 @code{out} parameters.  The third argument is the list of input
12872 operands.  It is either a single @code{Asm_Input} attribute reference, or
12873 a list of such references enclosed in parentheses (technically an array
12874 aggregate of such references).
12875
12876 The @code{Asm_Input} attribute denotes a function that takes two
12877 parameters.  The first is a string, the second is an expression of the
12878 type designated by the prefix.  The first (string) argument is required
12879 to be a static expression, and is the constraint for the parameter,
12880 (e.g.@: what kind of register is required).  The second argument is the
12881 value to be used as the input argument.  The possible values for the
12882 constant are the same as those used in the RTL, and are dependent on
12883 the configuration file used to built the GCC back end.
12884
12885 If there are no input operands, this argument may either be omitted, or
12886 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12887 present in the above example, is a list of register names, called the
12888 @dfn{clobber} argument.  This argument, if given, must be a static string
12889 expression, and is a space or comma separated list of names of registers
12890 that must be considered destroyed as a result of the @code{Asm} call.  If
12891 this argument is the null string (the default value), then the code
12892 generator assumes that no additional registers are destroyed.
12893
12894 The fifth argument, not present in the above example, called the
12895 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12896 the literal value @code{True} to indicate to the code generator that all
12897 optimizations with respect to the instruction specified should be
12898 suppressed, and that in particular, for an instruction that has outputs,
12899 the instruction will still be generated, even if none of the outputs are
12900 used.  See the full description in the GCC manual for further details.
12901
12902 The @code{Asm} subprograms may be used in two ways.  First the procedure
12903 forms can be used anywhere a procedure call would be valid, and
12904 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12905 be used to intersperse machine instructions with other Ada statements.
12906 Second, the function forms, which return a dummy value of the limited
12907 private type @code{Asm_Insn}, can be used in code statements, and indeed
12908 this is the only context where such calls are allowed.  Code statements
12909 appear as aggregates of the form:
12910
12911 @smallexample @c ada
12912 Asm_Insn'(Asm (@dots{}));
12913 Asm_Insn'(Asm_Volatile (@dots{}));
12914 @end smallexample
12915
12916 @noindent
12917 In accordance with RM rules, such code statements are allowed only
12918 within subprograms whose entire body consists of such statements.  It is
12919 not permissible to intermix such statements with other Ada statements.
12920
12921 Typically the form using intrinsic procedure calls is more convenient
12922 and more flexible.  The code statement form is provided to meet the RM
12923 suggestion that such a facility should be made available.  The following
12924 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12925 is used, the arguments may be given in arbitrary order, following the
12926 normal rules for use of positional and named arguments)
12927
12928 @smallexample
12929 ASM_CALL ::= Asm (
12930                  [Template =>] static_string_EXPRESSION
12931                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12932                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12933                [,[Clobber  =>] static_string_EXPRESSION ]
12934                [,[Volatile =>] static_boolean_EXPRESSION] )
12935
12936 OUTPUT_OPERAND_LIST ::=
12937   [PREFIX.]No_Output_Operands
12938 | OUTPUT_OPERAND_ATTRIBUTE
12939 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12940
12941 OUTPUT_OPERAND_ATTRIBUTE ::=
12942   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12943
12944 INPUT_OPERAND_LIST ::=
12945   [PREFIX.]No_Input_Operands
12946 | INPUT_OPERAND_ATTRIBUTE
12947 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12948
12949 INPUT_OPERAND_ATTRIBUTE ::=
12950   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12951 @end smallexample
12952
12953 @noindent
12954 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12955 are declared in the package @code{Machine_Code} and must be referenced
12956 according to normal visibility rules. In particular if there is no
12957 @code{use} clause for this package, then appropriate package name
12958 qualification is required.
12959
12960 @node GNAT Implementation of Tasking
12961 @section GNAT Implementation of Tasking
12962
12963 @noindent
12964 This chapter outlines the basic GNAT approach to tasking (in particular,
12965 a multi-layered library for portability) and discusses issues related
12966 to compliance with the Real-Time Systems Annex.
12967
12968 @menu
12969 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12970 * Ensuring Compliance with the Real-Time Annex::
12971 @end menu
12972
12973 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12974 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12975
12976 @noindent
12977 GNAT's run-time support comprises two layers:
12978
12979 @itemize @bullet
12980 @item GNARL (GNAT Run-time Layer)
12981 @item GNULL (GNAT Low-level Library)
12982 @end itemize
12983
12984 @noindent
12985 In GNAT, Ada's tasking services rely on a platform and OS independent
12986 layer known as GNARL@.  This code is responsible for implementing the
12987 correct semantics of Ada's task creation, rendezvous, protected
12988 operations etc.
12989
12990 GNARL decomposes Ada's tasking semantics into simpler lower level
12991 operations such as create a thread, set the priority of a thread,
12992 yield, create a lock, lock/unlock, etc.  The spec for these low-level
12993 operations constitutes GNULLI, the GNULL Interface.  This interface is
12994 directly inspired from the POSIX real-time API@.
12995
12996 If the underlying executive or OS implements the POSIX standard
12997 faithfully, the GNULL Interface maps as is to the services offered by
12998 the underlying kernel.  Otherwise, some target dependent glue code maps
12999 the services offered by the underlying kernel to the semantics expected
13000 by GNARL@.
13001
13002 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
13003 key point is that each Ada task is mapped on a thread in the underlying
13004 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
13005
13006 In addition Ada task priorities map onto the underlying thread priorities.
13007 Mapping Ada tasks onto the underlying kernel threads has several advantages:
13008
13009 @itemize @bullet
13010 @item
13011 The underlying scheduler is used to schedule the Ada tasks.  This
13012 makes Ada tasks as efficient as kernel threads from a scheduling
13013 standpoint.
13014
13015 @item
13016 Interaction with code written in C containing threads is eased
13017 since at the lowest level Ada tasks and C threads map onto the same
13018 underlying kernel concept.
13019
13020 @item
13021 When an Ada task is blocked during I/O the remaining Ada tasks are
13022 able to proceed.
13023
13024 @item
13025 On multiprocessor systems Ada tasks can execute in parallel.
13026 @end itemize
13027
13028 @noindent
13029 Some threads libraries offer a mechanism to fork a new process, with the
13030 child process duplicating the threads from the parent.
13031 GNAT does not
13032 support this functionality when the parent contains more than one task.
13033 @cindex Forking a new process
13034
13035 @node Ensuring Compliance with the Real-Time Annex
13036 @subsection Ensuring Compliance with the Real-Time Annex
13037 @cindex Real-Time Systems Annex compliance
13038
13039 @noindent
13040 Although mapping Ada tasks onto
13041 the underlying threads has significant advantages, it does create some
13042 complications when it comes to respecting the scheduling semantics
13043 specified in the real-time annex (Annex D).
13044
13045 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13046 scheduling policy states:
13047
13048 @quotation
13049 @emph{When the active priority of a ready task that is not running
13050 changes, or the setting of its base priority takes effect, the
13051 task is removed from the ready queue for its old active priority
13052 and is added at the tail of the ready queue for its new active
13053 priority, except in the case where the active priority is lowered
13054 due to the loss of inherited priority, in which case the task is
13055 added at the head of the ready queue for its new active priority.}
13056 @end quotation
13057
13058 @noindent
13059 While most kernels do put tasks at the end of the priority queue when
13060 a task changes its priority, (which respects the main
13061 FIFO_Within_Priorities requirement), almost none keep a thread at the
13062 beginning of its priority queue when its priority drops from the loss
13063 of inherited priority.
13064
13065 As a result most vendors have provided incomplete Annex D implementations.
13066
13067 The GNAT run-time, has a nice cooperative solution to this problem
13068 which ensures that accurate FIFO_Within_Priorities semantics are
13069 respected.
13070
13071 The principle is as follows.  When an Ada task T is about to start
13072 running, it checks whether some other Ada task R with the same
13073 priority as T has been suspended due to the loss of priority
13074 inheritance.  If this is the case, T yields and is placed at the end of
13075 its priority queue.  When R arrives at the front of the queue it
13076 executes.
13077
13078 Note that this simple scheme preserves the relative order of the tasks
13079 that were ready to execute in the priority queue where R has been
13080 placed at the end.
13081
13082 @node GNAT Implementation of Shared Passive Packages
13083 @section GNAT Implementation of Shared Passive Packages
13084 @cindex Shared passive packages
13085
13086 @noindent
13087 GNAT fully implements the pragma @code{Shared_Passive} for
13088 @cindex pragma @code{Shared_Passive}
13089 the purpose of designating shared passive packages.
13090 This allows the use of passive partitions in the
13091 context described in the Ada Reference Manual; i.e. for communication
13092 between separate partitions of a distributed application using the
13093 features in Annex E.
13094 @cindex Annex E
13095 @cindex Distribution Systems Annex
13096
13097 However, the implementation approach used by GNAT provides for more
13098 extensive usage as follows:
13099
13100 @table @emph
13101 @item Communication between separate programs
13102
13103 This allows separate programs to access the data in passive
13104 partitions, using protected objects for synchronization where
13105 needed. The only requirement is that the two programs have a
13106 common shared file system. It is even possible for programs
13107 running on different machines with different architectures
13108 (e.g. different endianness) to communicate via the data in
13109 a passive partition.
13110
13111 @item Persistence between program runs
13112
13113 The data in a passive package can persist from one run of a
13114 program to another, so that a later program sees the final
13115 values stored by a previous run of the same program.
13116
13117 @end table
13118
13119 @noindent
13120 The implementation approach used is to store the data in files. A
13121 separate stream file is created for each object in the package, and
13122 an access to an object causes the corresponding file to be read or
13123 written.
13124
13125 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13126 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13127 set to the directory to be used for these files.
13128 The files in this directory
13129 have names that correspond to their fully qualified names. For
13130 example, if we have the package
13131
13132 @smallexample @c ada
13133 package X is
13134   pragma Shared_Passive (X);
13135   Y : Integer;
13136   Z : Float;
13137 end X;
13138 @end smallexample
13139
13140 @noindent
13141 and the environment variable is set to @code{/stemp/}, then the files created
13142 will have the names:
13143
13144 @smallexample
13145 /stemp/x.y
13146 /stemp/x.z
13147 @end smallexample
13148
13149 @noindent
13150 These files are created when a value is initially written to the object, and
13151 the files are retained until manually deleted. This provides the persistence
13152 semantics. If no file exists, it means that no partition has assigned a value
13153 to the variable; in this case the initial value declared in the package
13154 will be used. This model ensures that there are no issues in synchronizing
13155 the elaboration process, since elaboration of passive packages elaborates the
13156 initial values, but does not create the files.
13157
13158 The files are written using normal @code{Stream_IO} access.
13159 If you want to be able
13160 to communicate between programs or partitions running on different
13161 architectures, then you should use the XDR versions of the stream attribute
13162 routines, since these are architecture independent.
13163
13164 If active synchronization is required for access to the variables in the
13165 shared passive package, then as described in the Ada Reference Manual, the
13166 package may contain protected objects used for this purpose. In this case
13167 a lock file (whose name is @file{___lock} (three underscores)
13168 is created in the shared memory directory.
13169 @cindex @file{___lock} file (for shared passive packages)
13170 This is used to provide the required locking
13171 semantics for proper protected object synchronization.
13172
13173 As of January 2003, GNAT supports shared passive packages on all platforms
13174 except for OpenVMS.
13175
13176 @node Code Generation for Array Aggregates
13177 @section Code Generation for Array Aggregates
13178
13179 @menu
13180 * Static constant aggregates with static bounds::
13181 * Constant aggregates with an unconstrained nominal types::
13182 * Aggregates with static bounds::
13183 * Aggregates with non-static bounds::
13184 * Aggregates in assignment statements::
13185 @end menu
13186
13187 @noindent
13188 Aggregate have a rich syntax and allow the user to specify the values of
13189 complex data structures by means of a single construct.  As a result, the
13190 code generated for aggregates can be quite complex and involve loops, case
13191 statements and multiple assignments.  In the simplest cases, however, the
13192 compiler will recognize aggregates whose components and constraints are
13193 fully static, and in those cases the compiler will generate little or no
13194 executable code.  The following is an outline of the code that GNAT generates
13195 for various aggregate constructs.  For further details, the user will find it
13196 useful to examine the output produced by the -gnatG flag to see the expanded
13197 source that is input to the code generator.  The user will also want to examine
13198 the assembly code generated at various levels of optimization.
13199
13200 The code generated for aggregates depends on the context, the component values,
13201 and the type.  In the context of an object declaration the code generated is
13202 generally simpler than in the case of an assignment.  As a general rule, static
13203 component values and static subtypes also lead to simpler code.
13204
13205 @node Static constant aggregates with static bounds
13206 @subsection Static constant aggregates with static bounds
13207
13208 @noindent
13209 For the declarations:
13210 @smallexample @c ada
13211     type One_Dim is array (1..10) of integer;
13212     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13213 @end smallexample
13214
13215 @noindent
13216 GNAT generates no executable code: the constant ar0 is placed in static memory.
13217 The same is true for constant aggregates with named associations:
13218
13219 @smallexample @c ada
13220     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13221     Cr3 : constant One_Dim := (others => 7777);
13222 @end smallexample
13223
13224 @noindent
13225 The same is true for multidimensional constant arrays such as:
13226
13227 @smallexample @c ada
13228     type two_dim is array (1..3, 1..3) of integer;
13229     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13230 @end smallexample
13231
13232 @noindent
13233 The same is true for arrays of one-dimensional arrays: the following are
13234 static:
13235
13236 @smallexample @c ada
13237 type ar1b  is array (1..3) of boolean;
13238 type ar_ar is array (1..3) of ar1b;
13239 None  : constant ar1b := (others => false);     --  fully static
13240 None2 : constant ar_ar := (1..3 => None);       --  fully static
13241 @end smallexample
13242
13243 @noindent
13244 However, for multidimensional aggregates with named associations, GNAT will
13245 generate assignments and loops, even if all associations are static.  The
13246 following two declarations generate a loop for the first dimension, and
13247 individual component assignments for the second dimension:
13248
13249 @smallexample @c ada
13250 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13251 Zero2: constant two_dim := (others => (others => 0));
13252 @end smallexample
13253
13254 @node Constant aggregates with an unconstrained nominal types
13255 @subsection Constant aggregates with an unconstrained nominal types
13256
13257 @noindent
13258 In such cases the aggregate itself establishes the subtype, so that
13259 associations with @code{others} cannot be used.  GNAT determines the
13260 bounds for the actual subtype of the aggregate, and allocates the
13261 aggregate statically as well.  No code is generated for the following:
13262
13263 @smallexample @c ada
13264     type One_Unc is array (natural range <>) of integer;
13265     Cr_Unc : constant One_Unc := (12,24,36);
13266 @end smallexample
13267
13268 @node Aggregates with static bounds
13269 @subsection Aggregates with static bounds
13270
13271 @noindent
13272 In all previous examples the aggregate was the initial (and immutable) value
13273 of a constant.  If the aggregate initializes a variable, then code is generated
13274 for it as a combination of individual assignments and loops over the target
13275 object.  The declarations
13276
13277 @smallexample @c ada
13278        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13279        Cr_Var2 : One_Dim := (others > -1);
13280 @end smallexample
13281
13282 @noindent
13283 generate the equivalent of
13284
13285 @smallexample @c ada
13286        Cr_Var1 (1) := 2;
13287        Cr_Var1 (2) := 3;
13288        Cr_Var1 (3) := 5;
13289        Cr_Var1 (4) := 11;
13290
13291        for I in Cr_Var2'range loop
13292           Cr_Var2 (I) := =-1;
13293        end loop;
13294 @end smallexample
13295
13296 @node Aggregates with non-static bounds
13297 @subsection Aggregates with non-static bounds
13298
13299 @noindent
13300 If the bounds of the aggregate are not statically compatible with the bounds
13301 of the nominal subtype  of the target, then constraint checks have to be
13302 generated on the bounds.  For a multidimensional array, constraint checks may
13303 have to be applied to sub-arrays individually, if they do not have statically
13304 compatible subtypes.
13305
13306 @node Aggregates in assignment statements
13307 @subsection Aggregates in assignment statements
13308
13309 @noindent
13310 In general, aggregate assignment requires the construction of a temporary,
13311 and a copy from the temporary to the target of the assignment.  This is because
13312 it is not always possible to convert the assignment into a series of individual
13313 component assignments.  For example, consider the simple case:
13314
13315 @smallexample @c ada
13316         A := (A(2), A(1));
13317 @end smallexample
13318
13319 @noindent
13320 This cannot be converted into:
13321
13322 @smallexample @c ada
13323         A(1) := A(2);
13324         A(2) := A(1);
13325 @end smallexample
13326
13327 @noindent
13328 So the aggregate has to be built first in a separate location, and then
13329 copied into the target.  GNAT recognizes simple cases where this intermediate
13330 step is not required, and the assignments can be performed in place, directly
13331 into the target.  The following sufficient criteria are applied:
13332
13333 @itemize @bullet
13334 @item
13335 The bounds of the aggregate are static, and the associations are static.
13336 @item
13337 The components of the aggregate are static constants, names of
13338 simple variables that are not renamings, or expressions not involving
13339 indexed components whose operands obey these rules.
13340 @end itemize
13341
13342 @noindent
13343 If any of these conditions are violated, the aggregate will be built in
13344 a temporary (created either by the front-end or the code generator) and then
13345 that temporary will be copied onto the target.
13346
13347
13348 @node The Size of Discriminated Records with Default Discriminants
13349 @section The Size of Discriminated Records with Default Discriminants
13350
13351 @noindent
13352 If a discriminated type @code{T} has discriminants with default values, it is
13353 possible to declare an object of this type without providing an explicit
13354 constraint:
13355
13356 @smallexample @c ada
13357 @group
13358 type Size is range 1..100;
13359
13360 type Rec (D : Size := 15) is record
13361    Name : String (1..D);
13362 end T;
13363
13364 Word : Rec;
13365 @end group
13366 @end smallexample
13367
13368 @noindent 
13369 Such an object is said to be @emph{unconstrained}.
13370 The discriminant of the object
13371 can be modified by a full assignment to the object, as long as it preserves the
13372 relation between the value of the discriminant, and the value of the components
13373 that depend on it:
13374
13375 @smallexample @c ada
13376 @group
13377 Word := (3, "yes");
13378
13379 Word := (5, "maybe");
13380
13381 Word := (5, "no"); -- raises Constraint_Error
13382 @end group
13383 @end smallexample
13384
13385 @noindent
13386 In order to support this behavior efficiently, an unconstrained object is
13387 given the maximum size that any value of the type requires. In the case
13388 above, @code{Word} has storage for the discriminant and for
13389 a @code{String} of length 100.
13390 It is important to note that unconstrained objects do not require dynamic
13391 allocation. It would be an improper implementation to place on the heap those
13392 components whose size depends on discriminants. (This improper implementation
13393 was used by some Ada83 compilers, where the @code{Name} component above
13394 would have
13395 been stored as a pointer to a dynamic string). Following the principle that
13396 dynamic storage management should never be introduced implicitly,
13397 an Ada95 compiler should reserve the full size for an unconstrained declared
13398 object, and place it on the stack.
13399
13400 This maximum size approach
13401 has been a source of surprise to some users, who expect the default
13402 values of the discriminants to determine the size reserved for an
13403 unconstrained object: ``If the default is 15, why should the object occupy
13404 a larger size?''
13405 The answer, of course, is that the discriminant may be later modified,
13406 and its full range of values must be taken into account. This is why the
13407 declaration:
13408
13409 @smallexample
13410 @group
13411 type Rec (D : Positive := 15) is record
13412    Name : String (1..D);
13413 end record;
13414
13415 Too_Large : Rec;
13416 @end group
13417 @end smallexample
13418
13419 @noindent
13420 is flagged by the compiler with a warning:
13421 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
13422 because the required size includes @code{Positive'Last}
13423 bytes. As the first example indicates, the proper approach is to declare an
13424 index type of ``reasonable'' range so that unconstrained objects are not too
13425 large.
13426
13427 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
13428 created in the heap by means of an allocator, then it is @emph{not}
13429 unconstrained:
13430 it is constrained by the default values of the discriminants, and those values
13431 cannot be modified by full assignment. This is because in the presence of
13432 aliasing all views of the object (which may be manipulated by different tasks,
13433 say) must be consistent, so it is imperative that the object, once created,
13434 remain invariant.
13435
13436
13437
13438
13439 @node Project File Reference
13440 @chapter Project File Reference
13441
13442 @noindent
13443 This chapter describes the syntax and semantics of project files.
13444 Project files specify the options to be used when building a system.
13445 Project files can specify global settings for all tools,
13446 as well as tool-specific settings.
13447 See the chapter on project files in the GNAT Users guide for examples of use.
13448
13449 @menu
13450 * Reserved Words::
13451 * Lexical Elements::
13452 * Declarations::
13453 * Empty declarations::
13454 * Typed string declarations::
13455 * Variables::
13456 * Expressions::
13457 * Attributes::
13458 * Project Attributes::
13459 * Attribute References::
13460 * External Values::
13461 * Case Construction::
13462 * Packages::
13463 * Package Renamings::
13464 * Projects::
13465 * Project Extensions::
13466 * Project File Elaboration::
13467 @end menu
13468
13469 @node Reserved Words
13470 @section Reserved Words
13471
13472 @noindent
13473 All Ada95 reserved words are reserved in project files, and cannot be used
13474 as variable names or project names. In addition, the following are
13475 also reserved in project files:
13476
13477 @itemize
13478 @item @code{extends}
13479
13480 @item @code{external}
13481
13482 @item @code{project}
13483
13484 @end itemize
13485
13486 @node Lexical Elements
13487 @section Lexical Elements
13488
13489 @noindent
13490 Rules for identifiers are the same as in Ada95. Identifiers
13491 are case-insensitive.  Strings are case sensitive, except where noted.
13492 Comments have the same form as in Ada95.
13493
13494 @noindent
13495 Syntax:
13496
13497 @smallexample
13498 simple_name ::=
13499   identifier
13500
13501 name ::=
13502   simple_name @{. simple_name@}
13503 @end smallexample
13504
13505 @node Declarations
13506 @section Declarations
13507
13508 @noindent
13509 Declarations introduce new entities that denote types, variables, attributes,
13510 and packages. Some declarations can only appear immediately within a project
13511 declaration. Others can appear within a project or within a package.
13512
13513 Syntax:
13514 @smallexample
13515 declarative_item ::=
13516   simple_declarative_item |
13517   typed_string_declaration |
13518   package_declaration
13519
13520 simple_declarative_item ::=
13521   variable_declaration |
13522   typed_variable_declaration |
13523   attribute_declaration |
13524   case_construction |
13525   empty_declaration
13526 @end smallexample
13527
13528 @node Empty declarations
13529 @section Empty declarations
13530
13531 @smallexample
13532 empty_declaration ::=
13533   @b{null} ;
13534 @end smallexample
13535
13536 An empty declaration is allowed anywhere a declaration is allowed.
13537 It has no effect.
13538
13539 @node Typed string declarations
13540 @section Typed string declarations
13541
13542 @noindent
13543 Typed strings are sequences of string literals. Typed strings are the only
13544 named types in project files. They are used in case constructions, where they
13545 provide support for conditional attribute definitions.
13546
13547 Syntax:
13548 @smallexample
13549 typed_string_declaration ::=
13550   @b{type} <typed_string_>_simple_name @b{is}
13551    ( string_literal @{, string_literal@} );
13552 @end smallexample
13553
13554 @noindent
13555 A typed string declaration can only appear immediately within a project
13556 declaration.
13557
13558 All the string literals in a typed string declaration must be distinct.
13559
13560 @node Variables
13561 @section Variables
13562
13563 @noindent
13564 Variables denote values, and appear as constituents of expressions.
13565
13566 @smallexample
13567 typed_variable_declaration ::=
13568   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13569
13570 variable_declaration ::=
13571   <variable_>simple_name := expression;
13572 @end smallexample
13573
13574 @noindent
13575 The elaboration of a variable declaration introduces the variable and
13576 assigns to it the value of the expression. The name of the variable is
13577 available after the assignment symbol.
13578
13579 @noindent
13580 A typed_variable can only be declare once.
13581
13582 @noindent
13583 a non typed variable can be declared multiple times.
13584
13585 @noindent
13586 Before the completion of its first declaration, the value of variable
13587 is the null string.
13588
13589 @node Expressions
13590 @section Expressions
13591
13592 @noindent
13593 An expression is a formula that defines a computation or retrieval of a value.
13594 In a project file the value of an expression is either a string or a list
13595 of strings. A string value in an expression is either a literal, the current
13596 value of a variable, an external value, an attribute reference, or a
13597 concatenation operation.
13598
13599 Syntax:
13600
13601 @smallexample
13602 expression ::=
13603   term @{& term@}
13604
13605 term ::=
13606   string_literal |
13607   string_list |
13608   <variable_>name |
13609   external_value |
13610   attribute_reference
13611
13612 string_literal ::=
13613   (same as Ada)
13614
13615 string_list ::=
13616   ( <string_>expression @{ , <string_>expression @} )
13617 @end smallexample
13618
13619 @subsection Concatenation
13620 @noindent
13621 The following concatenation functions are defined:
13622
13623 @smallexample @c ada
13624   function "&" (X : String;      Y : String)      return String;
13625   function "&" (X : String_List; Y : String)      return String_List;
13626   function "&" (X : String_List; Y : String_List) return String_List;
13627 @end smallexample
13628
13629 @node Attributes
13630 @section Attributes
13631
13632 @noindent
13633 An attribute declaration defines a property of a project or package. This
13634 property can later be queried by means of an attribute reference.
13635 Attribute values are strings or string lists.
13636
13637 Some attributes are associative arrays. These attributes are mappings whose
13638 domain is a set of strings. These attributes are declared one association
13639 at a time, by specifying a point in the domain and the corresponding image
13640 of the attribute. They may also be declared as a full associative array,
13641 getting the same associations as the corresponding attribute in an imported
13642 or extended project.
13643
13644 Attributes that are not associative arrays are called simple attributes.
13645
13646 Syntax:
13647 @smallexample
13648 attribute_declaration ::=
13649   full_associative_array_declaration |
13650   @b{for} attribute_designator @b{use} expression ;
13651
13652 full_associative_array_declaration ::=
13653   @b{for} <associative_array_attribute_>simple_name @b{use}
13654   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13655
13656 attribute_designator ::=
13657   <simple_attribute_>simple_name |
13658   <associative_array_attribute_>simple_name ( string_literal )
13659 @end smallexample
13660
13661 @noindent
13662 Some attributes are project-specific, and can only appear immediately within
13663 a project declaration. Others are package-specific, and can only appear within
13664 the proper package.
13665
13666 The expression in an attribute definition must be a string or a string_list.
13667 The string literal appearing in the attribute_designator of an associative
13668 array attribute is case-insensitive.
13669
13670 @node Project Attributes
13671 @section Project Attributes
13672
13673 @noindent
13674 The following attributes apply to a project. All of them are simple
13675 attributes.
13676
13677 @table @code
13678 @item   Object_Dir
13679 Expression must be a path name. The attribute defines the
13680 directory in which the object files created by the build are to be placed. If
13681 not specified, object files are placed in the project directory.
13682
13683 @item   Exec_Dir
13684 Expression must be a path name. The attribute defines the
13685 directory in which the executables created by the build are to be placed.
13686 If not specified, executables are placed in the object directory.
13687
13688 @item  Source_Dirs
13689 Expression must be a list of path names. The attribute
13690 defines the directories in which the source files for the project are to be
13691 found. If not specified, source files are found in the project directory.
13692
13693 @item  Source_Files
13694 Expression must be a list of file names. The attribute
13695 defines the individual files, in the project directory, which are to be used
13696 as sources for the project. File names are path_names that contain no directory
13697 information. If the project has no sources the attribute must be declared
13698 explicitly with an empty list.
13699
13700 @item  Source_List_File
13701 Expression must a single path name. The attribute
13702 defines a text file that contains a list of source file names to be used
13703 as sources for the project
13704
13705 @item  Library_Dir
13706 Expression must be a path name. The attribute defines the
13707 directory in which a  library is to be built.  The directory must exist, must
13708 be distinct from the project's object directory, and must be writable.
13709
13710 @item  Library_Name
13711 Expression must be a string that is a legal file name,
13712 without extension. The attribute defines a string that is used to generate
13713 the name of the library to be built by the project.
13714
13715 @item  Library_Kind
13716 Argument must be a string value that must be one of the
13717 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13718 string is case-insensitive. If this attribute is not specified, the library is
13719 a static library. Otherwise, the library may be dynamic or relocatable. This
13720 distinction is operating-system dependent.
13721
13722 @item  Library_Version
13723 Expression must be a string value whose interpretation
13724 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13725 libraries as the internal name of the library (the @code{"soname"}). If the
13726 library file name (built from the @code{Library_Name}) is different from the
13727 @code{Library_Version}, then the library file will be a symbolic link to the
13728 actual file whose name will be @code{Library_Version}.
13729
13730 @item Library_Interface
13731 Expression must be a string list. Each element of the string list
13732 must designate a unit of the project.
13733 If this attribute is present in a Library Project File, then the project
13734 file is a Stand-alone Library_Project_File.
13735
13736 @item Library_Auto_Init
13737 Expression must be a single string "true" or "false", case-insensitive.
13738 If this attribute is present in a Stand-alone Library Project File,
13739 it indicates if initialization is automatic when the dynamic library
13740 is loaded.
13741
13742 @item Library_Options
13743 Expression must be a string list. Indicates additional switches that
13744 are to be used when building a shared library.
13745
13746 @item Library_GCC
13747 Expression must be a single string. Designates an alternative to "gcc"
13748 for building shared libraries.
13749
13750 @item  Library_Src_Dir
13751 Expression must be a path name. The attribute defines the
13752 directory in which the sources of the interfaces of a Stand-alone Library will
13753 be copied.  The directory must exist, must be distinct from the project's
13754 object directory and source directories, and must be writable.
13755
13756 @item  Main
13757 Expression must be a list of strings that are legal file names.
13758 These file names designate existing compilation units in the source directory
13759 that are legal main subprograms.
13760
13761 When a project file is elaborated, as part of the execution of a gnatmake
13762 command, one or several executables are built and placed in the Exec_Dir.
13763 If the gnatmake command does not include explicit file names, the executables
13764 that are built correspond to the files specified by this attribute.
13765
13766 @item Main_Language
13767 This is a simple attribute. Its value is a string that specifies the
13768 language of the main program.
13769
13770 @item  Languages
13771 Expression must be a string list. Each string designates
13772 a programming language that is known to GNAT. The strings are case-insensitive.
13773
13774 @item  Locally_Removed_Files
13775 This attribute is legal only in a project file that extends another.
13776 Expression must be a list of strings that are legal file names.
13777 Each file name must designate a source that would normally be inherited
13778 by the current project file. It cannot designate an immediate source that is
13779 not inherited. Each of the source files in the list are not considered to
13780 be sources of the project file: they are not inherited.
13781 @end table
13782
13783 @node Attribute References
13784 @section Attribute References
13785
13786 @noindent
13787 Attribute references are used to retrieve the value of previously defined
13788 attribute for a package or project.
13789 Syntax:
13790 @smallexample
13791 attribute_reference ::=
13792   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13793
13794 attribute_prefix ::=
13795   @b{project} |
13796   <project_simple_name | package_identifier |
13797   <project_>simple_name . package_identifier
13798 @end smallexample
13799
13800 @noindent
13801 If an attribute has not been specified for a given package or project, its
13802 value is the null string or the empty list.
13803
13804 @node External Values
13805 @section External Values
13806
13807 @noindent
13808 An external value is an expression whose value is obtained from the command
13809 that invoked the processing of the current project file (typically a
13810 gnatmake command).
13811
13812 Syntax:
13813 @smallexample
13814 external_value ::=
13815   @b{external} ( string_literal [, string_literal] )
13816 @end smallexample
13817
13818 @noindent
13819 The first string_literal is the string to be used on the command line or
13820 in the environment to specify the external value. The second string_literal,
13821 if present, is the default to use if there is no specification for this
13822 external value either on the command line or in the environment.
13823
13824 @node Case Construction
13825 @section Case Construction
13826
13827 @noindent
13828 A case construction supports attribute declarations that depend on the value of
13829 a previously declared variable.
13830
13831 Syntax:
13832 @smallexample
13833 case_construction ::=
13834   @b{case} <typed_variable_>name @b{is}
13835     @{case_item@}
13836   @b{end case} ;
13837
13838 case_item ::=
13839   @b{when} discrete_choice_list =>
13840     @{case_construction | attribute_declaration | empty_declaration@}
13841
13842 discrete_choice_list ::=
13843   string_literal @{| string_literal@} |
13844     @b{others}
13845 @end smallexample
13846
13847 @noindent
13848 All choices in a choice list must be distinct. The choice lists of two
13849 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13850 alternatives do not need to include all values of the type. An @code{others}
13851 choice must appear last in the list of alternatives.
13852
13853 @node Packages
13854 @section Packages
13855
13856 @noindent
13857 A package provides a grouping of variable declarations and attribute
13858 declarations to be used when invoking various GNAT tools. The name of
13859 the package indicates the tool(s) to which it applies.
13860 Syntax:
13861
13862 @smallexample
13863 package_declaration ::=
13864   package_specification | package_renaming
13865
13866 package_specification ::=
13867   @b{package} package_identifier @b{is}
13868     @{simple_declarative_item@}
13869   @b{end} package_identifier ;
13870
13871 package_identifier ::=
13872   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13873   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13874   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13875 @end smallexample
13876
13877 @subsection Package Naming
13878
13879 @noindent
13880 The attributes of a @code{Naming} package specifies the naming conventions
13881 that apply to the source files in a project. When invoking other GNAT tools,
13882 they will use the sources in the source directories that satisfy these
13883 naming conventions.
13884
13885 The following attributes apply to a @code{Naming} package:
13886
13887 @table @code
13888 @item Casing
13889 This is a simple attribute whose value is a string. Legal values of this
13890 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13891 These strings are themselves case insensitive.
13892
13893 @noindent
13894 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13895
13896 @item Dot_Replacement
13897 This is a simple attribute whose string value satisfies the following
13898 requirements:
13899
13900 @itemize @bullet
13901 @item It must not be empty
13902 @item It cannot start or end with an alphanumeric character
13903 @item It cannot be a single underscore
13904 @item It cannot start with an underscore followed by an alphanumeric
13905 @item It cannot contain a dot @code{'.'} if longer than one character
13906 @end itemize
13907
13908 @noindent
13909 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13910
13911 @item Spec_Suffix
13912 This is an associative array attribute, defined on language names,
13913 whose image is a string that must satisfy the following
13914 conditions:
13915
13916 @itemize @bullet
13917 @item It must not be empty
13918 @item It cannot start with an alphanumeric character
13919 @item It cannot start with an underscore followed by an alphanumeric character
13920 @end itemize
13921
13922 @noindent
13923 For Ada, the attribute denotes the suffix used in file names that contain
13924 library unit declarations, that is to say units that are package and
13925 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13926 specified, then the default is @code{".ads"}.
13927
13928 For C and C++, the attribute denotes the suffix used in file names that
13929 contain prototypes.
13930
13931 @item Body_Suffix
13932 This is an associative array attribute defined on language names,
13933 whose image is a string that must satisfy the following
13934 conditions:
13935
13936 @itemize @bullet
13937 @item It must not be empty
13938 @item It cannot start with an alphanumeric character
13939 @item It cannot start with an underscore followed by an alphanumeric character
13940 @item It cannot be a suffix of @code{Spec_Suffix}
13941 @end itemize
13942
13943 @noindent
13944 For Ada, the attribute denotes the suffix used in file names that contain
13945 library bodies, that is to say units that are package and subprogram bodies.
13946 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13947 @code{".adb"}.
13948
13949 For C and C++, the attribute denotes the suffix used in file names that contain
13950 source code.
13951
13952 @item Separate_Suffix
13953 This is a simple attribute whose value satisfies the same conditions as
13954 @code{Body_Suffix}.
13955
13956 This attribute is specific to Ada. It denotes the suffix used in file names
13957 that contain separate bodies. If it is not specified, then it defaults to same
13958 value as @code{Body_Suffix ("Ada")}.
13959
13960 @item Spec
13961 This is an associative array attribute, specific to Ada, defined over
13962 compilation unit names. The image is a string that is the name of the file
13963 that contains that library unit. The file name is case sensitive if the
13964 conventions of the host operating system require it.
13965
13966 @item Body
13967 This is an associative array attribute, specific to Ada, defined over
13968 compilation unit names. The image is a string that is the name of the file
13969 that contains the library unit body for the named unit. The file name is case
13970 sensitive if the conventions of the host operating system require it.
13971
13972 @item Specification_Exceptions
13973 This is an associative array attribute defined on language names,
13974 whose value is a list of strings.
13975
13976 This attribute is not significant for Ada.
13977
13978 For C and C++, each string in the list denotes the name of a file that
13979 contains prototypes, but whose suffix is not necessarily the
13980 @code{Spec_Suffix} for the language.
13981
13982 @item Implementation_Exceptions
13983 This is an associative array attribute defined on language names,
13984 whose value is a list of strings.
13985
13986 This attribute is not significant for Ada.
13987
13988 For C and C++, each string in the list denotes the name of a file that
13989 contains source code, but whose suffix is not necessarily the
13990 @code{Body_Suffix} for the language.
13991 @end table
13992
13993 The following attributes of package @code{Naming} are obsolescent. They are
13994 kept as synonyms of other attributes for compatibility with previous versions
13995 of the Project Manager.
13996
13997 @table @code
13998 @item Specification_Suffix
13999 This is a synonym of @code{Spec_Suffix}.
14000
14001 @item Implementation_Suffix
14002 This is a synonym of @code{Body_Suffix}.
14003
14004 @item Specification
14005 This is a synonym of @code{Spec}.
14006
14007 @item Implementation
14008 This is a synonym of @code{Body}.
14009 @end table
14010
14011 @subsection package Compiler
14012
14013 @noindent
14014 The attributes of the @code{Compiler} package specify the compilation options
14015 to be used by the underlying compiler.
14016
14017 @table @code
14018 @item  Default_Switches
14019 This is an associative array attribute. Its
14020 domain is a set of language names. Its range is a string list that
14021 specifies the compilation options to be used when compiling a component
14022 written in that language, for which no file-specific switches have been
14023 specified..
14024
14025 @item  Switches
14026 This is an associative array attribute. Its domain is
14027 a set of file names. Its range is a string list that specifies the
14028 compilation options to be used when compiling the named file. If a file
14029 is not specified in the Switches attribute, it is compiled with the
14030 settings specified by Default_Switches.
14031
14032 @item  Local_Configuration_Pragmas.
14033 This is a simple attribute, whose
14034 value is a path name that designates a file containing configuration pragmas
14035 to be used for all invocations of the compiler for immediate sources of the
14036 project.
14037
14038 @item Executable
14039 This is an associative array attribute. Its domain is
14040 a set of main source file names. Its range is a simple string that specifies
14041 the executable file name to be used when linking the specified main source.
14042 If a main source is not specified in the Executable attribute, the executable
14043 file name is deducted from the main source file name.
14044 @end table
14045
14046 @subsection package Builder
14047
14048 @noindent
14049 The attributes of package @code{Builder} specify the compilation, binding, and
14050 linking options to be used when building an executable for a project. The
14051 following attributes apply to package @code{Builder}:
14052
14053 @table @code
14054 @item Default_Switches
14055 As above.
14056
14057 @item Switches
14058 As above.
14059
14060 @item Global_Configuration_Pragmas
14061 This is a simple attribute, whose
14062 value is a path name that designates a file that contains configuration pragmas
14063 to be used in every build of an executable. If both local and global
14064 configuration pragmas are specified, a compilation makes use of both sets.
14065
14066 @item Executable
14067 This is an associative array attribute, defined over
14068 compilation unit names. The image is a string that is the name of the
14069 executable file corresponding to the main source file index.
14070 This attribute has no effect if its value is the empty string.
14071
14072 @item Executable_Suffix
14073 This is a simple attribute whose value is a suffix to be added to
14074 the executables that don't have an attribute Executable specified.
14075 @end table
14076
14077 @subsection package Gnatls
14078
14079 @noindent
14080 The attributes of package @code{Gnatls} specify the tool options to be used
14081 when invoking the library browser @command{gnatls}.
14082 The following attributes apply to package @code{Gnatls}:
14083
14084 @table @code
14085 @item Switches
14086 As above.
14087 @end table
14088
14089 @subsection package Binder
14090
14091 @noindent
14092 The attributes of package @code{Binder} specify the options to be used
14093 when invoking the binder in the construction of an executable.
14094 The following attributes apply to package @code{Binder}:
14095
14096 @table @code
14097 @item     Default_Switches
14098 As above.
14099 @item     Switches
14100 As above.
14101 @end table
14102
14103 @subsection package Linker
14104
14105 @noindent
14106 The attributes of package @code{Linker} specify the options to be used when
14107 invoking the linker in the construction of an executable.
14108 The following attributes apply to package @code{Linker}:
14109
14110 @table @code
14111 @item     Default_Switches
14112 As above
14113 @item     Switches
14114 As above.
14115 @end table
14116
14117 @subsection package Cross_Reference
14118
14119 @noindent
14120 The attributes of package @code{Cross_Reference} specify the tool options
14121 to be used
14122 when invoking the library tool @command{gnatxref}.
14123 The following attributes apply to package @code{Cross_Reference}:
14124
14125 @table @code
14126 @item     Default_Switches
14127 As above.
14128 @item     Switches
14129 As above.
14130 @end table
14131
14132 @subsection package   Finder
14133
14134 @noindent
14135 The attributes of package @code{Finder} specify the tool options to be used
14136 when invoking the search tool @command{gnatfind}.
14137 The following attributes apply to package @code{Finder}:
14138
14139 @table @code
14140 @item     Default_Switches
14141 As above.
14142 @item     Switches
14143 As above.
14144 @end table
14145
14146 @subsection package Pretty_Printer
14147
14148 @noindent
14149 The attributes of package @code{Pretty_Printer}
14150 specify the tool options to be used
14151 when invoking the formatting tool @command{gnatpp}.
14152 The following attributes apply to package @code{Pretty_Printer}:
14153
14154 @table @code
14155 @item     Default_switches
14156 As above.
14157 @item     Switches
14158 As above.
14159 @end table
14160
14161 @subsection  package IDE
14162
14163 @noindent
14164 The attributes of package @code{IDE} specify the options to be used when using
14165 an Integrated Development Environment such as @command{GPS}.
14166
14167 @table @code
14168 @item Remote_Host
14169 This is a simple attribute. Its value is a string that designates the remote
14170 host in a cross-compilation environment, to be used for remote compilation and
14171 debugging. This field should not be specified when running on the local
14172 machine.
14173
14174 @item Program_Host
14175 This is a simple attribute. Its value is a string that specifies the
14176 name of IP address of the embedded target in a cross-compilation environment,
14177 on which the program should execute.
14178
14179 @item Communication_Protocol
14180 This is a simple string attribute. Its value is the name of the protocol
14181 to use to communicate with the target in a cross-compilation environment,
14182 e.g. @code{"wtx"} or @code{"vxworks"}.
14183
14184 @item Compiler_Command
14185 This is an associative array attribute, whose domain is a language name. Its
14186 value is  string that denotes the command to be used to invoke the compiler.
14187 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14188 gnatmake, in particular in the handling of switches.
14189
14190 @item Debugger_Command
14191 This is simple attribute, Its value is a string that specifies the name of
14192 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14193
14194 @item Default_Switches
14195 This is an associative array attribute. Its indexes are the name of the
14196 external tools that the GNAT Programming System (GPS) is supporting. Its
14197 value is a list of switches to use when invoking that tool.
14198
14199 @item  Gnatlist
14200 This is a simple attribute.  Its value is a string that specifies the name
14201 of the @command{gnatls} utility to be used to retrieve information about the
14202 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14203
14204 @item VCS_Kind
14205 This is a simple atribute. Is value is a string used to specify the
14206 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14207 ClearCase or Perforce.
14208
14209 @item VCS_File_Check
14210 This is a simple attribute. Its value is a string that specifies the
14211 command used by the VCS to check the validity of a file, either
14212 when the user explicitly asks for a check, or as a sanity check before
14213 doing the check-in.
14214
14215 @item VCS_Log_Check
14216 This is a simple attribute. Its value is a string that specifies
14217 the command used by the VCS to check the validity of a log file.
14218
14219 @end table
14220
14221 @node Package Renamings
14222 @section Package Renamings
14223
14224 @noindent
14225 A package can be defined by a renaming declaration. The new package renames
14226 a package declared in a different project file, and has the same attributes
14227 as the package it renames.
14228 Syntax:
14229 @smallexample
14230 package_renaming ::==
14231   @b{package} package_identifier @b{renames}
14232        <project_>simple_name.package_identifier ;
14233 @end smallexample
14234
14235 @noindent
14236 The package_identifier of the renamed package must be the same as the
14237 package_identifier. The project whose name is the prefix of the renamed
14238 package must contain a package declaration with this name. This project
14239 must appear in the context_clause of the enclosing project declaration,
14240 or be the parent project of the enclosing child project.
14241
14242 @node Projects
14243 @section Projects
14244
14245 @noindent
14246 A project file specifies a set of rules for constructing a software system.
14247 A project file can be self-contained, or depend on other project files.
14248 Dependencies are expressed through a context clause that names other projects.
14249
14250 Syntax:
14251
14252 @smallexample
14253 project ::=
14254   context_clause project_declaration
14255
14256 project_declaration ::=
14257   simple_project_declaration | project_extension
14258
14259 simple_project_declaration ::=
14260   @b{project} <project_>simple_name @b{is}
14261     @{declarative_item@}
14262   @b{end} <project_>simple_name;
14263
14264 context_clause ::=
14265   @{with_clause@}
14266
14267 with_clause ::=
14268   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14269
14270 path_name ::=
14271    string_literal
14272 @end smallexample
14273
14274 @noindent
14275 A path name denotes a project file. A path name can be absolute or relative.
14276 An absolute path name includes a sequence of directories, in the syntax of
14277 the host operating system, that identifies uniquely the project file in the
14278 file system. A relative path name identifies the project file, relative
14279 to the directory that contains the current project, or relative to a
14280 directory listed in the environment variable ADA_PROJECT_PATH.
14281 Path names are case sensitive if file names in the host operating system
14282 are case sensitive.
14283
14284 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14285 directory names separated by colons (semicolons on Windows).
14286
14287 A given project name can appear only once in a context_clause.
14288
14289 It is illegal for a project imported by a context clause to refer, directly
14290 or indirectly, to the project in which this context clause appears (the
14291 dependency graph cannot contain cycles), except when one of the with_clause
14292 in the cycle is a @code{limited with}.
14293
14294 @node Project Extensions
14295 @section Project Extensions
14296
14297 @noindent
14298 A project extension introduces a new project, which inherits the declarations
14299 of another project.
14300 Syntax:
14301 @smallexample
14302
14303 project_extension ::=
14304   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14305     @{declarative_item@}
14306   @b{end} <project_>simple_name;
14307 @end smallexample
14308
14309 @noindent
14310 The project extension declares a child project. The child project inherits
14311 all the declarations and all the files of the parent project, These inherited
14312 declaration can be overridden in the child project, by means of suitable
14313 declarations.
14314
14315 @node Project File Elaboration
14316 @section Project File Elaboration
14317
14318 @noindent
14319 A project file is processed as part of the invocation of a gnat tool that
14320 uses the project option. Elaboration of the process file consists in the
14321 sequential elaboration of all its declarations. The computed values of
14322 attributes and variables in the project are then used to establish the
14323 environment in which the gnat tool will execute.
14324
14325 @node Obsolescent Features
14326 @chapter Obsolescent Features
14327
14328 @noindent
14329 This chapter describes features that are provided by GNAT, but are
14330 considered obsolescent since there are preferred ways of achieving
14331 the same effect. These features are provided solely for historical
14332 compatibility purposes.
14333
14334 @menu
14335 * pragma No_Run_Time::
14336 * pragma Ravenscar::
14337 * pragma Restricted_Run_Time::
14338 @end menu
14339
14340 @node pragma No_Run_Time
14341 @section pragma No_Run_Time
14342
14343 The pragma @code{No_Run_Time} is used to achieve an affect similar
14344 to the use of the "Zero Foot Print" configurable run time, but without
14345 requiring a specially configured run time. The result of using this
14346 pragma, which must be used for all units in a partition, is to restrict
14347 the use of any language features requiring run-time support code. The
14348 preferred usage is to use an appropriately configured run-time that
14349 includes just those features that are to be made accessible.
14350
14351 @node pragma Ravenscar
14352 @section pragma Ravenscar
14353
14354 The pragma @code{Ravenscar} has exactly the same effect as pragma
14355 @code{Profile (Ravenscar)}. The latter usage is preferred since it
14356 is part of the new Ada 2005 standard.
14357
14358 @node pragma Restricted_Run_Time
14359 @section pragma Restricted_Run_Time
14360
14361 The pragma @code{Restricted_Run_Time} has exactly the same effect as
14362 pragma @code{Profile (Restricted)}. The latter usage is
14363 preferred since the Ada 2005 pragma @code{Profile} is intended for
14364 this kind of implementation dependent addition.
14365
14366 @include fdl.texi
14367 @c GNU Free Documentation License
14368
14369 @node Index,,GNU Free Documentation License, Top
14370 @unnumbered Index
14371
14372 @printindex cp
14373
14374 @contents
14375
14376 @bye