OSDN Git Service

2009-04-10 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.2 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts.  A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index::
88
89  --- The Detailed Node Listing ---
90
91 About This Guide
92
93 * What This Reference Manual Contains::
94 * Related Information::
95
96 Implementation Defined Pragmas
97
98 * Pragma Abort_Defer::
99 * Pragma Ada_83::
100 * Pragma Ada_95::
101 * Pragma Ada_05::
102 * Pragma Ada_2005::
103 * Pragma Annotate::
104 * Pragma Assert::
105 * Pragma Assume_No_Invalid_Values::
106 * Pragma Ast_Entry::
107 * Pragma C_Pass_By_Copy::
108 * Pragma Check::
109 * Pragma Check_Name::
110 * Pragma Check_Policy::
111 * Pragma Comment::
112 * Pragma Common_Object::
113 * Pragma Compile_Time_Error::
114 * Pragma Compile_Time_Warning::
115 * Pragma Complete_Representation::
116 * Pragma Complex_Representation::
117 * Pragma Component_Alignment::
118 * Pragma Convention_Identifier::
119 * Pragma CPP_Class::
120 * Pragma CPP_Constructor::
121 * Pragma CPP_Virtual::
122 * Pragma CPP_Vtable::
123 * Pragma Debug::
124 * Pragma Debug_Policy::
125 * Pragma Detect_Blocking::
126 * Pragma Elaboration_Checks::
127 * Pragma Eliminate::
128 * Pragma Export_Exception::
129 * Pragma Export_Function::
130 * Pragma Export_Object::
131 * Pragma Export_Procedure::
132 * Pragma Export_Value::
133 * Pragma Export_Valued_Procedure::
134 * Pragma Extend_System::
135 * Pragma External::
136 * Pragma External_Name_Casing::
137 * Pragma Fast_Math::
138 * Pragma Favor_Top_Level::
139 * Pragma Finalize_Storage_Only::
140 * Pragma Float_Representation::
141 * Pragma Ident::
142 * Pragma Implemented_By_Entry::
143 * Pragma Implicit_Packing::
144 * Pragma Import_Exception::
145 * Pragma Import_Function::
146 * Pragma Import_Object::
147 * Pragma Import_Procedure::
148 * Pragma Import_Valued_Procedure::
149 * Pragma Initialize_Scalars::
150 * Pragma Inline_Always::
151 * Pragma Inline_Generic::
152 * Pragma Interface::
153 * Pragma Interface_Name::
154 * Pragma Interrupt_Handler::
155 * Pragma Interrupt_State::
156 * Pragma Keep_Names::
157 * Pragma License::
158 * Pragma Link_With::
159 * Pragma Linker_Alias::
160 * Pragma Linker_Constructor::
161 * Pragma Linker_Destructor::
162 * Pragma Linker_Section::
163 * Pragma Long_Float::
164 * Pragma Machine_Attribute::
165 * Pragma Main::
166 * Pragma Main_Storage::
167 * Pragma No_Body::
168 * Pragma No_Return::
169 * Pragma No_Strict_Aliasing ::
170 * Pragma Normalize_Scalars::
171 * Pragma Obsolescent::
172 * Pragma Optimize_Alignment::
173 * Pragma Passive::
174 * Pragma Persistent_BSS::
175 * Pragma Polling::
176 * Pragma Postcondition::
177 * Pragma Precondition::
178 * Pragma Profile (Ravenscar)::
179 * Pragma Profile (Restricted)::
180 * Pragma Psect_Object::
181 * Pragma Pure_Function::
182 * Pragma Restriction_Warnings::
183 * Pragma Shared::
184 * Pragma Source_File_Name::
185 * Pragma Source_File_Name_Project::
186 * Pragma Source_Reference::
187 * Pragma Stream_Convert::
188 * Pragma Style_Checks::
189 * Pragma Subtitle::
190 * Pragma Suppress::
191 * Pragma Suppress_All::
192 * Pragma Suppress_Exception_Locations::
193 * Pragma Suppress_Initialization::
194 * Pragma Task_Info::
195 * Pragma Task_Name::
196 * Pragma Task_Storage::
197 * Pragma Thread_Local_Storage::
198 * Pragma Time_Slice::
199 * Pragma Title::
200 * Pragma Unchecked_Union::
201 * Pragma Unimplemented_Unit::
202 * Pragma Universal_Aliasing ::
203 * Pragma Universal_Data::
204 * Pragma Unmodified::
205 * Pragma Unreferenced::
206 * Pragma Unreferenced_Objects::
207 * Pragma Unreserve_All_Interrupts::
208 * Pragma Unsuppress::
209 * Pragma Use_VADS_Size::
210 * Pragma Validity_Checks::
211 * Pragma Volatile::
212 * Pragma Warnings::
213 * Pragma Weak_External::
214 * Pragma Wide_Character_Encoding::
215
216 Implementation Defined Attributes
217
218 * Abort_Signal::
219 * Address_Size::
220 * Asm_Input::
221 * Asm_Output::
222 * AST_Entry::
223 * Bit::
224 * Bit_Position::
225 * Code_Address::
226 * Default_Bit_Order::
227 * Elaborated::
228 * Elab_Body::
229 * Elab_Spec::
230 * Emax::
231 * Enabled::
232 * Enum_Rep::
233 * Enum_Val::
234 * Epsilon::
235 * Fixed_Value::
236 * Has_Access_Values::
237 * Has_Discriminants::
238 * Img::
239 * Integer_Value::
240 * Invalid_Value::
241 * Large::
242 * Machine_Size::
243 * Mantissa::
244 * Max_Interrupt_Priority::
245 * Max_Priority::
246 * Maximum_Alignment::
247 * Mechanism_Code::
248 * Null_Parameter::
249 * Object_Size::
250 * Old::
251 * Passed_By_Reference::
252 * Pool_Address::
253 * Range_Length::
254 * Safe_Emax::
255 * Safe_Large::
256 * Small::
257 * Storage_Unit::
258 * Stub_Type::
259 * Target_Name::
260 * Tick::
261 * To_Address::
262 * Type_Class::
263 * UET_Address::
264 * Unconstrained_Array::
265 * Universal_Literal_String::
266 * Unrestricted_Access::
267 * VADS_Size::
268 * Value_Size::
269 * Wchar_T_Size::
270 * Word_Size::
271
272 The Implementation of Standard I/O
273
274 * Standard I/O Packages::
275 * FORM Strings::
276 * Direct_IO::
277 * Sequential_IO::
278 * Text_IO::
279 * Wide_Text_IO::
280 * Wide_Wide_Text_IO::
281 * Stream_IO::
282 * Text Translation::
283 * Shared Files::
284 * Filenames encoding::
285 * Open Modes::
286 * Operations on C Streams::
287 * Interfacing to C Streams::
288
289 The GNAT Library
290
291 * Ada.Characters.Latin_9 (a-chlat9.ads)::
292 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
293 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
294 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
295 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
296 * Ada.Command_Line.Environment (a-colien.ads)::
297 * Ada.Command_Line.Remove (a-colire.ads)::
298 * Ada.Command_Line.Response_File (a-clrefi.ads)::
299 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
300 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
301 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
302 * Ada.Exceptions.Traceback (a-exctra.ads)::
303 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
304 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
305 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
306 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
307 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
308 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
309 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
310 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
311 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
312 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
313 * GNAT.Altivec (g-altive.ads)::
314 * GNAT.Altivec.Conversions (g-altcon.ads)::
315 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
316 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
317 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
318 * GNAT.Array_Split (g-arrspl.ads)::
319 * GNAT.AWK (g-awk.ads)::
320 * GNAT.Bounded_Buffers (g-boubuf.ads)::
321 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
322 * GNAT.Bubble_Sort (g-bubsor.ads)::
323 * GNAT.Bubble_Sort_A (g-busora.ads)::
324 * GNAT.Bubble_Sort_G (g-busorg.ads)::
325 * GNAT.Byte_Order_Mark (g-byorma.ads)::
326 * GNAT.Byte_Swapping (g-bytswa.ads)::
327 * GNAT.Calendar (g-calend.ads)::
328 * GNAT.Calendar.Time_IO (g-catiio.ads)::
329 * GNAT.Case_Util (g-casuti.ads)::
330 * GNAT.CGI (g-cgi.ads)::
331 * GNAT.CGI.Cookie (g-cgicoo.ads)::
332 * GNAT.CGI.Debug (g-cgideb.ads)::
333 * GNAT.Command_Line (g-comlin.ads)::
334 * GNAT.Compiler_Version (g-comver.ads)::
335 * GNAT.Ctrl_C (g-ctrl_c.ads)::
336 * GNAT.CRC32 (g-crc32.ads)::
337 * GNAT.Current_Exception (g-curexc.ads)::
338 * GNAT.Debug_Pools (g-debpoo.ads)::
339 * GNAT.Debug_Utilities (g-debuti.ads)::
340 * GNAT.Decode_String (g-decstr.ads)::
341 * GNAT.Decode_UTF8_String (g-deutst.ads)::
342 * GNAT.Directory_Operations (g-dirope.ads)::
343 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
344 * GNAT.Dynamic_HTables (g-dynhta.ads)::
345 * GNAT.Dynamic_Tables (g-dyntab.ads)::
346 * GNAT.Encode_String (g-encstr.ads)::
347 * GNAT.Encode_UTF8_String (g-enutst.ads)::
348 * GNAT.Exception_Actions (g-excact.ads)::
349 * GNAT.Exception_Traces (g-exctra.ads)::
350 * GNAT.Exceptions (g-except.ads)::
351 * GNAT.Expect (g-expect.ads)::
352 * GNAT.Float_Control (g-flocon.ads)::
353 * GNAT.Heap_Sort (g-heasor.ads)::
354 * GNAT.Heap_Sort_A (g-hesora.ads)::
355 * GNAT.Heap_Sort_G (g-hesorg.ads)::
356 * GNAT.HTable (g-htable.ads)::
357 * GNAT.IO (g-io.ads)::
358 * GNAT.IO_Aux (g-io_aux.ads)::
359 * GNAT.Lock_Files (g-locfil.ads)::
360 * GNAT.MD5 (g-md5.ads)::
361 * GNAT.Memory_Dump (g-memdum.ads)::
362 * GNAT.Most_Recent_Exception (g-moreex.ads)::
363 * GNAT.OS_Lib (g-os_lib.ads)::
364 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
365 * GNAT.Random_Numbers (g-rannum.ads)::
366 * GNAT.Regexp (g-regexp.ads)::
367 * GNAT.Registry (g-regist.ads)::
368 * GNAT.Regpat (g-regpat.ads)::
369 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
370 * GNAT.Semaphores (g-semaph.ads)::
371 * GNAT.Serial_Communications (g-sercom.ads)::
372 * GNAT.SHA1 (g-sha1.ads)::
373 * GNAT.Signals (g-signal.ads)::
374 * GNAT.Sockets (g-socket.ads)::
375 * GNAT.Source_Info (g-souinf.ads)::
376 * GNAT.Spelling_Checker (g-speche.ads)::
377 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
378 * GNAT.Spitbol.Patterns (g-spipat.ads)::
379 * GNAT.Spitbol (g-spitbo.ads)::
380 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
381 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
382 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
383 * GNAT.Strings (g-string.ads)::
384 * GNAT.String_Split (g-strspl.ads)::
385 * GNAT.Table (g-table.ads)::
386 * GNAT.Task_Lock (g-tasloc.ads)::
387 * GNAT.Threads (g-thread.ads)::
388 * GNAT.Time_Stamp (g-timsta.ads)::
389 * GNAT.Traceback (g-traceb.ads)::
390 * GNAT.Traceback.Symbolic (g-trasym.ads)::
391 * GNAT.UTF_32 (g-utf_32.ads)::
392 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
393 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
394 * GNAT.Wide_String_Split (g-wistsp.ads)::
395 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
396 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
397 * Interfaces.C.Extensions (i-cexten.ads)::
398 * Interfaces.C.Streams (i-cstrea.ads)::
399 * Interfaces.CPP (i-cpp.ads)::
400 * Interfaces.Packed_Decimal (i-pacdec.ads)::
401 * Interfaces.VxWorks (i-vxwork.ads)::
402 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
403 * System.Address_Image (s-addima.ads)::
404 * System.Assertions (s-assert.ads)::
405 * System.Memory (s-memory.ads)::
406 * System.Partition_Interface (s-parint.ads)::
407 * System.Pool_Global (s-pooglo.ads)::
408 * System.Pool_Local (s-pooloc.ads)::
409 * System.Restrictions (s-restri.ads)::
410 * System.Rident (s-rident.ads)::
411 * System.Task_Info (s-tasinf.ads)::
412 * System.Wch_Cnv (s-wchcnv.ads)::
413 * System.Wch_Con (s-wchcon.ads)::
414
415 Text_IO
416
417 * Text_IO Stream Pointer Positioning::
418 * Text_IO Reading and Writing Non-Regular Files::
419 * Get_Immediate::
420 * Treating Text_IO Files as Streams::
421 * Text_IO Extensions::
422 * Text_IO Facilities for Unbounded Strings::
423
424 Wide_Text_IO
425
426 * Wide_Text_IO Stream Pointer Positioning::
427 * Wide_Text_IO Reading and Writing Non-Regular Files::
428
429 Wide_Wide_Text_IO
430
431 * Wide_Wide_Text_IO Stream Pointer Positioning::
432 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
433
434 Interfacing to Other Languages
435
436 * Interfacing to C::
437 * Interfacing to C++::
438 * Interfacing to COBOL::
439 * Interfacing to Fortran::
440 * Interfacing to non-GNAT Ada code::
441
442 Specialized Needs Annexes
443
444 Implementation of Specific Ada Features
445 * Machine Code Insertions::
446 * GNAT Implementation of Tasking::
447 * GNAT Implementation of Shared Passive Packages::
448 * Code Generation for Array Aggregates::
449 * The Size of Discriminated Records with Default Discriminants::
450 * Strict Conformance to the Ada Reference Manual::
451
452 Project File Reference
453
454 Obsolescent Features
455
456 GNU Free Documentation License
457
458 Index
459 @end menu
460
461 @end ifnottex
462
463 @node About This Guide
464 @unnumbered About This Guide
465
466 @noindent
467 This manual contains useful information in writing programs using the
468 @value{EDITION} compiler.  It includes information on implementation dependent
469 characteristics of @value{EDITION}, including all the information required by
470 Annex M of the Ada language standard.
471
472 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
473 Ada 83 compatibility mode.
474 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
475 but you can override with a compiler switch
476 to explicitly specify the language version.
477 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
478 @value{EDITION} User's Guide}, for details on these switches.)
479 Throughout this manual, references to ``Ada'' without a year suffix
480 apply to both the Ada 95 and Ada 2005 versions of the language.
481
482 Ada is designed to be highly portable.
483 In general, a program will have the same effect even when compiled by
484 different compilers on different platforms.
485 However, since Ada is designed to be used in a
486 wide variety of applications, it also contains a number of system
487 dependent features to be used in interfacing to the external world.
488 @cindex Implementation-dependent features
489 @cindex Portability
490
491 Note: Any program that makes use of implementation-dependent features
492 may be non-portable.  You should follow good programming practice and
493 isolate and clearly document any sections of your program that make use
494 of these features in a non-portable manner.
495
496 @ifset PROEDITION
497 For ease of exposition, ``GNAT Pro'' will be referred to simply as
498 ``GNAT'' in the remainder of this document.
499 @end ifset
500
501 @menu
502 * What This Reference Manual Contains::
503 * Conventions::
504 * Related Information::
505 @end menu
506
507 @node What This Reference Manual Contains
508 @unnumberedsec What This Reference Manual Contains
509
510 @noindent
511 This reference manual contains the following chapters:
512
513 @itemize @bullet
514 @item
515 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
516 pragmas, which can be used to extend and enhance the functionality of the
517 compiler.
518
519 @item
520 @ref{Implementation Defined Attributes}, lists GNAT
521 implementation-dependent attributes which can be used to extend and
522 enhance the functionality of the compiler.
523
524 @item
525 @ref{Implementation Advice}, provides information on generally
526 desirable behavior which are not requirements that all compilers must
527 follow since it cannot be provided on all systems, or which may be
528 undesirable on some systems.
529
530 @item
531 @ref{Implementation Defined Characteristics}, provides a guide to
532 minimizing implementation dependent features.
533
534 @item
535 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
536 implemented by GNAT, and how they can be imported into user
537 application programs.
538
539 @item
540 @ref{Representation Clauses and Pragmas}, describes in detail the
541 way that GNAT represents data, and in particular the exact set
542 of representation clauses and pragmas that is accepted.
543
544 @item
545 @ref{Standard Library Routines}, provides a listing of packages and a
546 brief description of the functionality that is provided by Ada's
547 extensive set of standard library routines as implemented by GNAT@.
548
549 @item
550 @ref{The Implementation of Standard I/O}, details how the GNAT
551 implementation of the input-output facilities.
552
553 @item
554 @ref{The GNAT Library}, is a catalog of packages that complement
555 the Ada predefined library.
556
557 @item
558 @ref{Interfacing to Other Languages}, describes how programs
559 written in Ada using GNAT can be interfaced to other programming
560 languages.
561
562 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
563 of the specialized needs annexes.
564
565 @item
566 @ref{Implementation of Specific Ada Features}, discusses issues related
567 to GNAT's implementation of machine code insertions, tasking, and several
568 other features.
569
570 @item
571 @ref{Project File Reference}, presents the syntax and semantics
572 of project files.
573
574 @item
575 @ref{Obsolescent Features} documents implementation dependent features,
576 including pragmas and attributes, which are considered obsolescent, since
577 there are other preferred ways of achieving the same results. These
578 obsolescent forms are retained for backwards compatibility.
579
580 @end itemize
581
582 @cindex Ada 95 Language Reference Manual
583 @cindex Ada 2005 Language Reference Manual
584 @noindent
585 This reference manual assumes a basic familiarity with the Ada 95 language, as
586 described in the International Standard ANSI/ISO/IEC-8652:1995,
587 January 1995.
588 It does not require knowledge of the new features introduced by Ada 2005,
589 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
590 and Amendment 1).
591 Both reference manuals are included in the GNAT documentation
592 package.
593
594 @node Conventions
595 @unnumberedsec Conventions
596 @cindex Conventions, typographical
597 @cindex Typographical conventions
598
599 @noindent
600 Following are examples of the typographical and graphic conventions used
601 in this guide:
602
603 @itemize @bullet
604 @item
605 @code{Functions}, @code{utility program names}, @code{standard names},
606 and @code{classes}.
607
608 @item
609 @code{Option flags}
610
611 @item
612 @file{File names}, @samp{button names}, and @samp{field names}.
613
614 @item
615 @code{Variables}, @env{environment variables}, and @var{metasyntactic
616 variables}.
617
618 @item
619 @emph{Emphasis}.
620
621 @item
622 [optional information or parameters]
623
624 @item
625 Examples are described by text
626 @smallexample
627 and then shown this way.
628 @end smallexample
629 @end itemize
630
631 @noindent
632 Commands that are entered by the user are preceded in this manual by the
633 characters @samp{$ } (dollar sign followed by space).  If your system uses this
634 sequence as a prompt, then the commands will appear exactly as you see them
635 in the manual.  If your system uses some other prompt, then the command will
636 appear with the @samp{$} replaced by whatever prompt character you are using.
637
638 @node Related Information
639 @unnumberedsec Related Information
640 @noindent
641 See the following documents for further information on GNAT:
642
643 @itemize @bullet
644 @item
645 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
646 @value{EDITION} User's Guide}, which provides information on how to use the
647 GNAT compiler system.
648
649 @item
650 @cite{Ada 95 Reference Manual}, which contains all reference
651 material for the Ada 95 programming language.
652
653 @item
654 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
655 of the Ada 95 standard.  The annotations describe
656 detailed aspects of the design decision, and in particular contain useful
657 sections on Ada 83 compatibility.
658
659 @item
660 @cite{Ada 2005 Reference Manual}, which contains all reference
661 material for the Ada 2005 programming language.
662
663 @item
664 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
665 of the Ada 2005 standard.  The annotations describe
666 detailed aspects of the design decision, and in particular contain useful
667 sections on Ada 83 and Ada 95 compatibility.
668
669 @item
670 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
671 which contains specific information on compatibility between GNAT and
672 DEC Ada 83 systems.
673
674 @item
675 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
676 describes in detail the pragmas and attributes provided by the DEC Ada 83
677 compiler system.
678
679 @end itemize
680
681 @node Implementation Defined Pragmas
682 @chapter Implementation Defined Pragmas
683
684 @noindent
685 Ada defines a set of pragmas that can be used to supply additional
686 information to the compiler.  These language defined pragmas are
687 implemented in GNAT and work as described in the Ada Reference Manual.
688
689 In addition, Ada allows implementations to define additional pragmas
690 whose meaning is defined by the implementation.  GNAT provides a number
691 of these implementation-defined pragmas, which can be used to extend
692 and enhance the functionality of the compiler.  This section of the GNAT
693 Reference Manual describes these additional pragmas.
694
695 Note that any program using these pragmas might not be portable to other
696 compilers (although GNAT implements this set of pragmas on all
697 platforms).  Therefore if portability to other compilers is an important
698 consideration, the use of these pragmas should be minimized.
699
700 @menu
701 * Pragma Abort_Defer::
702 * Pragma Ada_83::
703 * Pragma Ada_95::
704 * Pragma Ada_05::
705 * Pragma Ada_2005::
706 * Pragma Annotate::
707 * Pragma Assert::
708 * Pragma Assume_No_Invalid_Values::
709 * Pragma Ast_Entry::
710 * Pragma C_Pass_By_Copy::
711 * Pragma Check::
712 * Pragma Check_Name::
713 * Pragma Check_Policy::
714 * Pragma Comment::
715 * Pragma Common_Object::
716 * Pragma Compile_Time_Error::
717 * Pragma Compile_Time_Warning::
718 * Pragma Complete_Representation::
719 * Pragma Complex_Representation::
720 * Pragma Component_Alignment::
721 * Pragma Convention_Identifier::
722 * Pragma CPP_Class::
723 * Pragma CPP_Constructor::
724 * Pragma CPP_Virtual::
725 * Pragma CPP_Vtable::
726 * Pragma Debug::
727 * Pragma Debug_Policy::
728 * Pragma Detect_Blocking::
729 * Pragma Elaboration_Checks::
730 * Pragma Eliminate::
731 * Pragma Export_Exception::
732 * Pragma Export_Function::
733 * Pragma Export_Object::
734 * Pragma Export_Procedure::
735 * Pragma Export_Value::
736 * Pragma Export_Valued_Procedure::
737 * Pragma Extend_System::
738 * Pragma External::
739 * Pragma External_Name_Casing::
740 * Pragma Fast_Math::
741 * Pragma Favor_Top_Level::
742 * Pragma Finalize_Storage_Only::
743 * Pragma Float_Representation::
744 * Pragma Ident::
745 * Pragma Implemented_By_Entry::
746 * Pragma Implicit_Packing::
747 * Pragma Import_Exception::
748 * Pragma Import_Function::
749 * Pragma Import_Object::
750 * Pragma Import_Procedure::
751 * Pragma Import_Valued_Procedure::
752 * Pragma Initialize_Scalars::
753 * Pragma Inline_Always::
754 * Pragma Inline_Generic::
755 * Pragma Interface::
756 * Pragma Interface_Name::
757 * Pragma Interrupt_Handler::
758 * Pragma Interrupt_State::
759 * Pragma Keep_Names::
760 * Pragma License::
761 * Pragma Link_With::
762 * Pragma Linker_Alias::
763 * Pragma Linker_Constructor::
764 * Pragma Linker_Destructor::
765 * Pragma Linker_Section::
766 * Pragma Long_Float::
767 * Pragma Machine_Attribute::
768 * Pragma Main::
769 * Pragma Main_Storage::
770 * Pragma No_Body::
771 * Pragma No_Return::
772 * Pragma No_Strict_Aliasing::
773 * Pragma Normalize_Scalars::
774 * Pragma Obsolescent::
775 * Pragma Optimize_Alignment::
776 * Pragma Passive::
777 * Pragma Persistent_BSS::
778 * Pragma Polling::
779 * Pragma Postcondition::
780 * Pragma Precondition::
781 * Pragma Profile (Ravenscar)::
782 * Pragma Profile (Restricted)::
783 * Pragma Psect_Object::
784 * Pragma Pure_Function::
785 * Pragma Restriction_Warnings::
786 * Pragma Shared::
787 * Pragma Source_File_Name::
788 * Pragma Source_File_Name_Project::
789 * Pragma Source_Reference::
790 * Pragma Stream_Convert::
791 * Pragma Style_Checks::
792 * Pragma Subtitle::
793 * Pragma Suppress::
794 * Pragma Suppress_All::
795 * Pragma Suppress_Exception_Locations::
796 * Pragma Suppress_Initialization::
797 * Pragma Task_Info::
798 * Pragma Task_Name::
799 * Pragma Task_Storage::
800 * Pragma Thread_Local_Storage::
801 * Pragma Time_Slice::
802 * Pragma Title::
803 * Pragma Unchecked_Union::
804 * Pragma Unimplemented_Unit::
805 * Pragma Universal_Aliasing ::
806 * Pragma Universal_Data::
807 * Pragma Unmodified::
808 * Pragma Unreferenced::
809 * Pragma Unreferenced_Objects::
810 * Pragma Unreserve_All_Interrupts::
811 * Pragma Unsuppress::
812 * Pragma Use_VADS_Size::
813 * Pragma Validity_Checks::
814 * Pragma Volatile::
815 * Pragma Warnings::
816 * Pragma Weak_External::
817 * Pragma Wide_Character_Encoding::
818 @end menu
819
820 @node Pragma Abort_Defer
821 @unnumberedsec Pragma Abort_Defer
822 @findex Abort_Defer
823 @cindex Deferring aborts
824 @noindent
825 Syntax:
826 @smallexample
827 pragma Abort_Defer;
828 @end smallexample
829
830 @noindent
831 This pragma must appear at the start of the statement sequence of a
832 handled sequence of statements (right after the @code{begin}).  It has
833 the effect of deferring aborts for the sequence of statements (but not
834 for the declarations or handlers, if any, associated with this statement
835 sequence).
836
837 @node Pragma Ada_83
838 @unnumberedsec Pragma Ada_83
839 @findex Ada_83
840 @noindent
841 Syntax:
842 @smallexample @c ada
843 pragma Ada_83;
844 @end smallexample
845
846 @noindent
847 A configuration pragma that establishes Ada 83 mode for the unit to
848 which it applies, regardless of the mode set by the command line
849 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
850 the syntax and semantics of Ada 83, as defined in the original Ada
851 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
852 and Ada 2005 are not recognized, optional package bodies are allowed,
853 and generics may name types with unknown discriminants without using
854 the @code{(<>)} notation.  In addition, some but not all of the additional
855 restrictions of Ada 83 are enforced.
856
857 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
858 Ada 83 code to be compiled and adapted to GNAT with less effort.
859 Secondly, it aids in keeping code backwards compatible with Ada 83.
860 However, there is no guarantee that code that is processed correctly
861 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
862 83 compiler, since GNAT does not enforce all the additional checks
863 required by Ada 83.
864
865 @node Pragma Ada_95
866 @unnumberedsec Pragma Ada_95
867 @findex Ada_95
868 @noindent
869 Syntax:
870 @smallexample @c ada
871 pragma Ada_95;
872 @end smallexample
873
874 @noindent
875 A configuration pragma that establishes Ada 95 mode for the unit to which
876 it applies, regardless of the mode set by the command line switches.
877 This mode is set automatically for the @code{Ada} and @code{System}
878 packages and their children, so you need not specify it in these
879 contexts.  This pragma is useful when writing a reusable component that
880 itself uses Ada 95 features, but which is intended to be usable from
881 either Ada 83 or Ada 95 programs.
882
883 @node Pragma Ada_05
884 @unnumberedsec Pragma Ada_05
885 @findex Ada_05
886 @noindent
887 Syntax:
888 @smallexample @c ada
889 pragma Ada_05;
890 @end smallexample
891
892 @noindent
893 A configuration pragma that establishes Ada 2005 mode for the unit to which
894 it applies, regardless of the mode set by the command line switches.
895 This mode is set automatically for the @code{Ada} and @code{System}
896 packages and their children, so you need not specify it in these
897 contexts.  This pragma is useful when writing a reusable component that
898 itself uses Ada 2005 features, but which is intended to be usable from
899 either Ada 83 or Ada 95 programs.
900
901 @node Pragma Ada_2005
902 @unnumberedsec Pragma Ada_2005
903 @findex Ada_2005
904 @noindent
905 Syntax:
906 @smallexample @c ada
907 pragma Ada_2005;
908 @end smallexample
909
910 @noindent
911 This configuration pragma is a synonym for pragma Ada_05 and has the
912 same syntax and effect.
913
914 @node Pragma Annotate
915 @unnumberedsec Pragma Annotate
916 @findex Annotate
917 @noindent
918 Syntax:
919 @smallexample @c ada
920 pragma Annotate (IDENTIFIER @{, ARG@});
921
922 ARG ::= NAME | EXPRESSION
923 @end smallexample
924
925 @noindent
926 This pragma is used to annotate programs.  @var{identifier} identifies
927 the type of annotation.  GNAT verifies that it is an identifier, but does
928 not otherwise analyze it.  The @var{arg} argument
929 can be either a string literal or an
930 expression.  String literals are assumed to be of type
931 @code{Standard.String}.  Names of entities are simply analyzed as entity
932 names.  All other expressions are analyzed as expressions, and must be
933 unambiguous.
934
935 The analyzed pragma is retained in the tree, but not otherwise processed
936 by any part of the GNAT compiler.  This pragma is intended for use by
937 external tools, including ASIS@.
938
939 @node Pragma Assert
940 @unnumberedsec Pragma Assert
941 @findex Assert
942 @noindent
943 Syntax:
944 @smallexample @c ada
945 pragma Assert (
946   boolean_EXPRESSION
947   [, string_EXPRESSION]);
948 @end smallexample
949
950 @noindent
951 The effect of this pragma depends on whether the corresponding command
952 line switch is set to activate assertions.  The pragma expands into code
953 equivalent to the following:
954
955 @smallexample @c ada
956 if assertions-enabled then
957    if not boolean_EXPRESSION then
958       System.Assertions.Raise_Assert_Failure
959         (string_EXPRESSION);
960    end if;
961 end if;
962 @end smallexample
963
964 @noindent
965 The string argument, if given, is the message that will be associated
966 with the exception occurrence if the exception is raised.  If no second
967 argument is given, the default message is @samp{@var{file}:@var{nnn}},
968 where @var{file} is the name of the source file containing the assert,
969 and @var{nnn} is the line number of the assert.  A pragma is not a
970 statement, so if a statement sequence contains nothing but a pragma
971 assert, then a null statement is required in addition, as in:
972
973 @smallexample @c ada
974 @dots{}
975 if J > 3 then
976    pragma Assert (K > 3, "Bad value for K");
977    null;
978 end if;
979 @end smallexample
980
981 @noindent
982 Note that, as with the @code{if} statement to which it is equivalent, the
983 type of the expression is either @code{Standard.Boolean}, or any type derived
984 from this standard type.
985
986 If assertions are disabled (switch @option{-gnata} not used), then there
987 is no run-time effect (and in particular, any side effects from the
988 expression will not occur at run time).  (The expression is still
989 analyzed at compile time, and may cause types to be frozen if they are
990 mentioned here for the first time).
991
992 If assertions are enabled, then the given expression is tested, and if
993 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
994 which results in the raising of @code{Assert_Failure} with the given message.
995
996 You should generally avoid side effects in the expression arguments of
997 this pragma, because these side effects will turn on and off with the
998 setting of the assertions mode, resulting in assertions that have an
999 effect on the program.  However, the expressions are analyzed for
1000 semantic correctness whether or not assertions are enabled, so turning
1001 assertions on and off cannot affect the legality of a program.
1002
1003 @node Pragma Assume_No_Invalid_Values
1004 @unnumberedsec Pragma Assume_No_Invalid_Values
1005 @findex Assume_No_Invalid_Values
1006 @cindex Invalid representations
1007 @cindex Invalid values
1008 @noindent
1009 Syntax:
1010 @smallexample @c ada
1011 pragma Assume_No_Invalid_Values (On | Off);
1012 @end smallexample
1013
1014 @noindent
1015 This is a configuration pragma that controls the assumptions made by the
1016 compiler about the occurrence of invalid representations (invalid values)
1017 in the code.
1018
1019 The default behavior (corresponding to an Off argument for this pragma), is
1020 to assume that values may in general be invalid unless the compiler can
1021 prove they are valid. Consider the following example:
1022
1023 @smallexample @c ada
1024 V1 : Integer range 1 .. 10;
1025 V2 : Integer range 11 .. 20;
1026 ...
1027 for J in V2 .. V1 loop
1028    ...
1029 end loop;
1030 @end smallexample
1031
1032 @noindent
1033 if V1 and V2 have valid values, then the loop is known at compile
1034 time not to execute since the lower bound must be greater than the
1035 upper bound. However in default mode, no such assumption is made,
1036 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1037 is given, the compiler will assume that any occurrence of a variable
1038 other than in an explicit @code{'Valid} test always has a valid
1039 value, and the loop above will be optimized away.
1040
1041 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1042 you know your code is free of uninitialized variables and other
1043 possible sources of invalid representations, and may result in
1044 more efficient code.
1045
1046 @node Pragma Ast_Entry
1047 @unnumberedsec Pragma Ast_Entry
1048 @cindex OpenVMS
1049 @findex Ast_Entry
1050 @noindent
1051 Syntax:
1052 @smallexample @c ada
1053 pragma AST_Entry (entry_IDENTIFIER);
1054 @end smallexample
1055
1056 @noindent
1057 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1058 argument is the simple name of a single entry; at most one @code{AST_Entry}
1059 pragma is allowed for any given entry.  This pragma must be used in
1060 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1061 the entry declaration and in the same task type specification or single task
1062 as the entry to which it applies.  This pragma specifies that the given entry
1063 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1064 resulting from an OpenVMS system service call.  The pragma does not affect
1065 normal use of the entry.  For further details on this pragma, see the
1066 DEC Ada Language Reference Manual, section 9.12a.
1067
1068 @node Pragma C_Pass_By_Copy
1069 @unnumberedsec Pragma C_Pass_By_Copy
1070 @cindex Passing by copy
1071 @findex C_Pass_By_Copy
1072 @noindent
1073 Syntax:
1074 @smallexample @c ada
1075 pragma C_Pass_By_Copy
1076   ([Max_Size =>] static_integer_EXPRESSION);
1077 @end smallexample
1078
1079 @noindent
1080 Normally the default mechanism for passing C convention records to C
1081 convention subprograms is to pass them by reference, as suggested by RM
1082 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1083 this default, by requiring that record formal parameters be passed by
1084 copy if all of the following conditions are met:
1085
1086 @itemize @bullet
1087 @item
1088 The size of the record type does not exceed the value specified for
1089 @code{Max_Size}.
1090 @item
1091 The record type has @code{Convention C}.
1092 @item
1093 The formal parameter has this record type, and the subprogram has a
1094 foreign (non-Ada) convention.
1095 @end itemize
1096
1097 @noindent
1098 If these conditions are met the argument is passed by copy, i.e.@: in a
1099 manner consistent with what C expects if the corresponding formal in the
1100 C prototype is a struct (rather than a pointer to a struct).
1101
1102 You can also pass records by copy by specifying the convention
1103 @code{C_Pass_By_Copy} for the record type, or by using the extended
1104 @code{Import} and @code{Export} pragmas, which allow specification of
1105 passing mechanisms on a parameter by parameter basis.
1106
1107 @node Pragma Check
1108 @unnumberedsec Pragma Check
1109 @cindex Assertions
1110 @cindex Named assertions
1111 @findex Check
1112 @noindent
1113 Syntax:
1114 @smallexample @c ada
1115 pragma Check (
1116      [Name    =>] Identifier,
1117      [Check   =>] Boolean_EXPRESSION
1118   [, [Message =>] string_EXPRESSION] );
1119 @end smallexample
1120
1121 @noindent
1122 This pragma is similar to the predefined pragma @code{Assert} except that an
1123 extra identifier argument is present. In conjunction with pragma
1124 @code{Check_Policy}, this can be used to define groups of assertions that can
1125 be independently controlled. The identifier @code{Assertion} is special, it
1126 refers to the normal set of pragma @code{Assert} statements. The identifiers
1127 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1128 names, so these three names would normally not be used directly in a pragma
1129 @code{Check}.
1130
1131 Checks introduced by this pragma are normally deactivated by default. They can
1132 be activated either by the command line option @option{-gnata}, which turns on
1133 all checks, or individually controlled using pragma @code{Check_Policy}.
1134
1135 @node Pragma Check_Name
1136 @unnumberedsec Pragma Check_Name
1137 @cindex Defining check names
1138 @cindex Check names, defining
1139 @findex Check_Name
1140 @noindent
1141 Syntax:
1142 @smallexample @c ada
1143 pragma Check_Name (check_name_IDENTIFIER);
1144 @end smallexample
1145
1146 @noindent
1147 This is a configuration pragma that defines a new implementation
1148 defined check name (unless IDENTIFIER matches one of the predefined
1149 check names, in which case the pragma has no effect). Check names
1150 are global to a partition, so if two or more configuration pragmas
1151 are present in a partition mentioning the same name, only one new
1152 check name is introduced.
1153
1154 An implementation defined check name introduced with this pragma may
1155 be used in only three contexts: @code{pragma Suppress},
1156 @code{pragma Unsuppress},
1157 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1158 any of these three cases, the check name must be visible. A check
1159 name is visible if it is in the configuration pragmas applying to
1160 the current unit, or if it appears at the start of any unit that
1161 is part of the dependency set of the current unit (e.g., units that
1162 are mentioned in @code{with} clauses).
1163
1164 @node Pragma Check_Policy
1165 @unnumberedsec Pragma Check_Policy
1166 @cindex Controlling assertions
1167 @cindex Assertions, control
1168 @cindex Check pragma control
1169 @cindex Named assertions
1170 @findex Check
1171 @noindent
1172 Syntax:
1173 @smallexample @c ada
1174 pragma Check_Policy
1175  ([Name   =>] Identifier,
1176   [Policy =>] POLICY_IDENTIFIER);
1177
1178 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1179 @end smallexample
1180
1181 @noindent
1182 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1183 except that it controls sets of named assertions introduced using the
1184 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1185 @code{Assertion_Policy}) can be used within a declarative part, in which case
1186 it controls the status to the end of the corresponding construct (in a manner
1187 identical to pragma @code{Suppress)}.
1188
1189 The identifier given as the first argument corresponds to a name used in
1190 associated @code{Check} pragmas. For example, if the pragma:
1191
1192 @smallexample @c ada
1193 pragma Check_Policy (Critical_Error, Off);
1194 @end smallexample
1195
1196 @noindent
1197 is given, then subsequent @code{Check} pragmas whose first argument is also
1198 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1199 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1200 @code{Check_Policy} with this identifier is similar to the normal
1201 @code{Assertion_Policy} pragma except that it can appear within a
1202 declarative part).
1203
1204 The special identifiers @code{Precondition} and @code{Postcondition} control
1205 the status of preconditions and postconditions. If a @code{Precondition} pragma
1206 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1207 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1208 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1209 are recognized.
1210
1211 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1212 to turn on corresponding checks. The default for a set of checks for which no
1213 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1214 @option{-gnata} is given, which turns on all checks by default.
1215
1216 The check policy settings @code{Check} and @code{Ignore} are also recognized
1217 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1218 compatibility with the standard @code{Assertion_Policy} pragma.
1219
1220 @node Pragma Comment
1221 @unnumberedsec Pragma Comment
1222 @findex Comment
1223 @noindent
1224 Syntax:
1225
1226 @smallexample @c ada
1227 pragma Comment (static_string_EXPRESSION);
1228 @end smallexample
1229
1230 @noindent
1231 This is almost identical in effect to pragma @code{Ident}.  It allows the
1232 placement of a comment into the object file and hence into the
1233 executable file if the operating system permits such usage.  The
1234 difference is that @code{Comment}, unlike @code{Ident}, has
1235 no limitations on placement of the pragma (it can be placed
1236 anywhere in the main source unit), and if more than one pragma
1237 is used, all comments are retained.
1238
1239 @node Pragma Common_Object
1240 @unnumberedsec Pragma Common_Object
1241 @findex Common_Object
1242 @noindent
1243 Syntax:
1244
1245 @smallexample @c ada
1246 pragma Common_Object (
1247      [Internal =>] LOCAL_NAME
1248   [, [External =>] EXTERNAL_SYMBOL]
1249   [, [Size     =>] EXTERNAL_SYMBOL] );
1250
1251 EXTERNAL_SYMBOL ::=
1252   IDENTIFIER
1253 | static_string_EXPRESSION
1254 @end smallexample
1255
1256 @noindent
1257 This pragma enables the shared use of variables stored in overlaid
1258 linker areas corresponding to the use of @code{COMMON}
1259 in Fortran.  The single
1260 object @var{LOCAL_NAME} is assigned to the area designated by
1261 the @var{External} argument.
1262 You may define a record to correspond to a series
1263 of fields.  The @var{Size} argument
1264 is syntax checked in GNAT, but otherwise ignored.
1265
1266 @code{Common_Object} is not supported on all platforms.  If no
1267 support is available, then the code generator will issue a message
1268 indicating that the necessary attribute for implementation of this
1269 pragma is not available.
1270
1271 @node Pragma Compile_Time_Error
1272 @unnumberedsec Pragma Compile_Time_Error
1273 @findex Compile_Time_Error
1274 @noindent
1275 Syntax:
1276
1277 @smallexample @c ada
1278 pragma Compile_Time_Error
1279          (boolean_EXPRESSION, static_string_EXPRESSION);
1280 @end smallexample
1281
1282 @noindent
1283 This pragma can be used to generate additional compile time
1284 error messages. It
1285 is particularly useful in generics, where errors can be issued for
1286 specific problematic instantiations. The first parameter is a boolean
1287 expression. The pragma is effective only if the value of this expression
1288 is known at compile time, and has the value True. The set of expressions
1289 whose values are known at compile time includes all static boolean
1290 expressions, and also other values which the compiler can determine
1291 at compile time (e.g., the size of a record type set by an explicit
1292 size representation clause, or the value of a variable which was
1293 initialized to a constant and is known not to have been modified).
1294 If these conditions are met, an error message is generated using
1295 the value given as the second argument. This string value may contain
1296 embedded ASCII.LF characters to break the message into multiple lines.
1297
1298 @node Pragma Compile_Time_Warning
1299 @unnumberedsec Pragma Compile_Time_Warning
1300 @findex Compile_Time_Warning
1301 @noindent
1302 Syntax:
1303
1304 @smallexample @c ada
1305 pragma Compile_Time_Warning
1306          (boolean_EXPRESSION, static_string_EXPRESSION);
1307 @end smallexample
1308
1309 @noindent
1310 Same as pragma Compile_Time_Error, except a warning is issued instead
1311 of an error message. Note that if this pragma is used in a package that
1312 is with'ed by a client, the client will get the warning even though it
1313 is issued by a with'ed package (normally warnings in with'ed units are
1314 suppressed, but this is a special exception to that rule).
1315
1316 One typical use is within a generic where compile time known characteristics
1317 of formal parameters are tested, and warnings given appropriately. Another use
1318 with a first parameter of True is to warn a client about use of a package,
1319 for example that it is not fully implemented.
1320
1321 @node Pragma Complete_Representation
1322 @unnumberedsec Pragma Complete_Representation
1323 @findex Complete_Representation
1324 @noindent
1325 Syntax:
1326
1327 @smallexample @c ada
1328 pragma Complete_Representation;
1329 @end smallexample
1330
1331 @noindent
1332 This pragma must appear immediately within a record representation
1333 clause. Typical placements are before the first component clause
1334 or after the last component clause. The effect is to give an error
1335 message if any component is missing a component clause. This pragma
1336 may be used to ensure that a record representation clause is
1337 complete, and that this invariant is maintained if fields are
1338 added to the record in the future.
1339
1340 @node Pragma Complex_Representation
1341 @unnumberedsec Pragma Complex_Representation
1342 @findex Complex_Representation
1343 @noindent
1344 Syntax:
1345
1346 @smallexample @c ada
1347 pragma Complex_Representation
1348         ([Entity =>] LOCAL_NAME);
1349 @end smallexample
1350
1351 @noindent
1352 The @var{Entity} argument must be the name of a record type which has
1353 two fields of the same floating-point type.  The effect of this pragma is
1354 to force gcc to use the special internal complex representation form for
1355 this record, which may be more efficient.  Note that this may result in
1356 the code for this type not conforming to standard ABI (application
1357 binary interface) requirements for the handling of record types.  For
1358 example, in some environments, there is a requirement for passing
1359 records by pointer, and the use of this pragma may result in passing
1360 this type in floating-point registers.
1361
1362 @node Pragma Component_Alignment
1363 @unnumberedsec Pragma Component_Alignment
1364 @cindex Alignments of components
1365 @findex Component_Alignment
1366 @noindent
1367 Syntax:
1368
1369 @smallexample @c ada
1370 pragma Component_Alignment (
1371      [Form =>] ALIGNMENT_CHOICE
1372   [, [Name =>] type_LOCAL_NAME]);
1373
1374 ALIGNMENT_CHOICE ::=
1375   Component_Size
1376 | Component_Size_4
1377 | Storage_Unit
1378 | Default
1379 @end smallexample
1380
1381 @noindent
1382 Specifies the alignment of components in array or record types.
1383 The meaning of the @var{Form} argument is as follows:
1384
1385 @table @code
1386 @findex Component_Size
1387 @item Component_Size
1388 Aligns scalar components and subcomponents of the array or record type
1389 on boundaries appropriate to their inherent size (naturally
1390 aligned).  For example, 1-byte components are aligned on byte boundaries,
1391 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1392 integer components are aligned on 4-byte boundaries and so on.  These
1393 alignment rules correspond to the normal rules for C compilers on all
1394 machines except the VAX@.
1395
1396 @findex Component_Size_4
1397 @item Component_Size_4
1398 Naturally aligns components with a size of four or fewer
1399 bytes.  Components that are larger than 4 bytes are placed on the next
1400 4-byte boundary.
1401
1402 @findex Storage_Unit
1403 @item Storage_Unit
1404 Specifies that array or record components are byte aligned, i.e.@:
1405 aligned on boundaries determined by the value of the constant
1406 @code{System.Storage_Unit}.
1407
1408 @cindex OpenVMS
1409 @item Default
1410 Specifies that array or record components are aligned on default
1411 boundaries, appropriate to the underlying hardware or operating system or
1412 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1413 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1414 the @code{Default} choice is the same as @code{Component_Size} (natural
1415 alignment).
1416 @end table
1417
1418 @noindent
1419 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1420 refer to a local record or array type, and the specified alignment
1421 choice applies to the specified type.  The use of
1422 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1423 @code{Component_Alignment} pragma to be ignored.  The use of
1424 @code{Component_Alignment} together with a record representation clause
1425 is only effective for fields not specified by the representation clause.
1426
1427 If the @code{Name} parameter is absent, the pragma can be used as either
1428 a configuration pragma, in which case it applies to one or more units in
1429 accordance with the normal rules for configuration pragmas, or it can be
1430 used within a declarative part, in which case it applies to types that
1431 are declared within this declarative part, or within any nested scope
1432 within this declarative part.  In either case it specifies the alignment
1433 to be applied to any record or array type which has otherwise standard
1434 representation.
1435
1436 If the alignment for a record or array type is not specified (using
1437 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1438 clause), the GNAT uses the default alignment as described previously.
1439
1440 @node Pragma Convention_Identifier
1441 @unnumberedsec Pragma Convention_Identifier
1442 @findex Convention_Identifier
1443 @cindex Conventions, synonyms
1444 @noindent
1445 Syntax:
1446
1447 @smallexample @c ada
1448 pragma Convention_Identifier (
1449          [Name =>]       IDENTIFIER,
1450          [Convention =>] convention_IDENTIFIER);
1451 @end smallexample
1452
1453 @noindent
1454 This pragma provides a mechanism for supplying synonyms for existing
1455 convention identifiers. The @code{Name} identifier can subsequently
1456 be used as a synonym for the given convention in other pragmas (including
1457 for example pragma @code{Import} or another @code{Convention_Identifier}
1458 pragma). As an example of the use of this, suppose you had legacy code
1459 which used Fortran77 as the identifier for Fortran. Then the pragma:
1460
1461 @smallexample @c ada
1462 pragma Convention_Identifier (Fortran77, Fortran);
1463 @end smallexample
1464
1465 @noindent
1466 would allow the use of the convention identifier @code{Fortran77} in
1467 subsequent code, avoiding the need to modify the sources. As another
1468 example, you could use this to parametrize convention requirements
1469 according to systems. Suppose you needed to use @code{Stdcall} on
1470 windows systems, and @code{C} on some other system, then you could
1471 define a convention identifier @code{Library} and use a single
1472 @code{Convention_Identifier} pragma to specify which convention
1473 would be used system-wide.
1474
1475 @node Pragma CPP_Class
1476 @unnumberedsec Pragma CPP_Class
1477 @findex CPP_Class
1478 @cindex Interfacing with C++
1479 @noindent
1480 Syntax:
1481
1482 @smallexample @c ada
1483 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1484 @end smallexample
1485
1486 @noindent
1487 The argument denotes an entity in the current declarative region that is
1488 declared as a tagged record type. It indicates that the type corresponds
1489 to an externally declared C++ class type, and is to be laid out the same
1490 way that C++ would lay out the type.
1491
1492 Types for which @code{CPP_Class} is specified do not have assignment or
1493 equality operators defined (such operations can be imported or declared
1494 as subprograms as required). Initialization is allowed only by constructor
1495 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1496 limited if not explicitly declared as limited or derived from a limited
1497 type, and a warning is issued in that case.
1498
1499 Pragma @code{CPP_Class} is intended primarily for automatic generation
1500 using an automatic binding generator tool.
1501 See @ref{Interfacing to C++} for related information.
1502
1503 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1504 for backward compatibility but its functionality is available
1505 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1506
1507 @node Pragma CPP_Constructor
1508 @unnumberedsec Pragma CPP_Constructor
1509 @cindex Interfacing with C++
1510 @findex CPP_Constructor
1511 @noindent
1512 Syntax:
1513
1514 @smallexample @c ada
1515 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1516   [, [External_Name =>] static_string_EXPRESSION ]
1517   [, [Link_Name     =>] static_string_EXPRESSION ]);
1518 @end smallexample
1519
1520 @noindent
1521 This pragma identifies an imported function (imported in the usual way
1522 with pragma @code{Import}) as corresponding to a C++ constructor. If
1523 @code{External_Name} and @code{Link_Name} are not specified then the
1524 @code{Entity} argument is a name that must have been previously mentioned
1525 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1526 must be of one of the following forms:
1527
1528 @itemize @bullet
1529 @item
1530 @code{function @var{Fname} return @var{T}'Class}
1531
1532 @item
1533 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1534 @end itemize
1535
1536 @noindent
1537 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1538
1539 The first form is the default constructor, used when an object of type
1540 @var{T} is created on the Ada side with no explicit constructor.  Other
1541 constructors (including the copy constructor, which is simply a special
1542 case of the second form in which the one and only argument is of type
1543 @var{T}), can only appear in two contexts:
1544
1545 @itemize @bullet
1546 @item
1547 On the right side of an initialization of an object of type @var{T}.
1548 @item
1549 In an extension aggregate for an object of a type derived from @var{T}.
1550 @end itemize
1551
1552 @noindent
1553 Although the constructor is described as a function that returns a value
1554 on the Ada side, it is typically a procedure with an extra implicit
1555 argument (the object being initialized) at the implementation
1556 level.  GNAT issues the appropriate call, whatever it is, to get the
1557 object properly initialized.
1558
1559 In the case of derived objects, you may use one of two possible forms
1560 for declaring and creating an object:
1561
1562 @itemize @bullet
1563 @item @code{New_Object : Derived_T}
1564 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1565 @end itemize
1566
1567 @noindent
1568 In the first case the default constructor is called and extension fields
1569 if any are initialized according to the default initialization
1570 expressions in the Ada declaration.  In the second case, the given
1571 constructor is called and the extension aggregate indicates the explicit
1572 values of the extension fields.
1573
1574 If no constructors are imported, it is impossible to create any objects
1575 on the Ada side.  If no default constructor is imported, only the
1576 initialization forms using an explicit call to a constructor are
1577 permitted.
1578
1579 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1580 using an automatic binding generator tool.
1581 See @ref{Interfacing to C++} for more related information.
1582
1583 @node Pragma CPP_Virtual
1584 @unnumberedsec Pragma CPP_Virtual
1585 @cindex Interfacing to C++
1586 @findex CPP_Virtual
1587 @noindent
1588 This pragma is now obsolete has has no effect because GNAT generates
1589 the same object layout than the G++ compiler.
1590
1591 See @ref{Interfacing to C++} for related information.
1592
1593 @node Pragma CPP_Vtable
1594 @unnumberedsec Pragma CPP_Vtable
1595 @cindex Interfacing with C++
1596 @findex CPP_Vtable
1597 @noindent
1598 This pragma is now obsolete has has no effect because GNAT generates
1599 the same object layout than the G++ compiler.
1600
1601 See @ref{Interfacing to C++} for related information.
1602
1603 @node Pragma Debug
1604 @unnumberedsec Pragma Debug
1605 @findex Debug
1606 @noindent
1607 Syntax:
1608
1609 @smallexample @c ada
1610 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1611
1612 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1613   PROCEDURE_NAME
1614 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1615 @end smallexample
1616
1617 @noindent
1618 The procedure call argument has the syntactic form of an expression, meeting
1619 the syntactic requirements for pragmas.
1620
1621 If debug pragmas are not enabled or if the condition is present and evaluates
1622 to False, this pragma has no effect. If debug pragmas are enabled, the
1623 semantics of the pragma is exactly equivalent to the procedure call statement
1624 corresponding to the argument with a terminating semicolon. Pragmas are
1625 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1626 intersperse calls to debug procedures in the middle of declarations. Debug
1627 pragmas can be enabled either by use of the command line switch @option{-gnata}
1628 or by use of the configuration pragma @code{Debug_Policy}.
1629
1630 @node Pragma Debug_Policy
1631 @unnumberedsec Pragma Debug_Policy
1632 @findex Debug_Policy
1633 @noindent
1634 Syntax:
1635
1636 @smallexample @c ada
1637 pragma Debug_Policy (CHECK | IGNORE);
1638 @end smallexample
1639
1640 @noindent
1641 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1642 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1643 This pragma overrides the effect of the @option{-gnata} switch on the
1644 command line.
1645
1646 @node Pragma Detect_Blocking
1647 @unnumberedsec Pragma Detect_Blocking
1648 @findex Detect_Blocking
1649 @noindent
1650 Syntax:
1651
1652 @smallexample @c ada
1653 pragma Detect_Blocking;
1654 @end smallexample
1655
1656 @noindent
1657 This is a configuration pragma that forces the detection of potentially
1658 blocking operations within a protected operation, and to raise Program_Error
1659 if that happens.
1660
1661 @node Pragma Elaboration_Checks
1662 @unnumberedsec Pragma Elaboration_Checks
1663 @cindex Elaboration control
1664 @findex Elaboration_Checks
1665 @noindent
1666 Syntax:
1667
1668 @smallexample @c ada
1669 pragma Elaboration_Checks (Dynamic | Static);
1670 @end smallexample
1671
1672 @noindent
1673 This is a configuration pragma that provides control over the
1674 elaboration model used by the compilation affected by the
1675 pragma.  If the parameter is @code{Dynamic},
1676 then the dynamic elaboration
1677 model described in the Ada Reference Manual is used, as though
1678 the @option{-gnatE} switch had been specified on the command
1679 line.  If the parameter is @code{Static}, then the default GNAT static
1680 model is used.  This configuration pragma overrides the setting
1681 of the command line.  For full details on the elaboration models
1682 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1683 gnat_ugn, @value{EDITION} User's Guide}.
1684
1685 @node Pragma Eliminate
1686 @unnumberedsec Pragma Eliminate
1687 @cindex Elimination of unused subprograms
1688 @findex Eliminate
1689 @noindent
1690 Syntax:
1691
1692 @smallexample @c ada
1693 pragma Eliminate (
1694     [Unit_Name =>] IDENTIFIER |
1695                    SELECTED_COMPONENT);
1696
1697 pragma Eliminate (
1698     [Unit_Name       =>]  IDENTIFIER |
1699                           SELECTED_COMPONENT,
1700     [Entity          =>]  IDENTIFIER |
1701                           SELECTED_COMPONENT |
1702                           STRING_LITERAL
1703     [,OVERLOADING_RESOLUTION]);
1704
1705 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1706                            SOURCE_LOCATION
1707
1708 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1709                                       FUNCTION_PROFILE
1710
1711 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1712
1713 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1714                       Result_Type => result_SUBTYPE_NAME]
1715
1716 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1717 SUBTYPE_NAME    ::= STRING_VALUE
1718
1719 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1720 SOURCE_TRACE    ::= STRING_VALUE
1721
1722 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1723 @end smallexample
1724
1725 @noindent
1726 This pragma indicates that the given entity is not used outside the
1727 compilation unit it is defined in. The entity must be an explicitly declared
1728 subprogram; this includes  generic subprogram instances and
1729 subprograms declared in generic package instances.
1730
1731 If the entity to be eliminated is a library level subprogram, then
1732 the first form of pragma @code{Eliminate} is used with only a single argument.
1733 In this form, the @code{Unit_Name} argument specifies the name of the
1734 library  level unit to be eliminated.
1735
1736 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1737 are required. If item is an entity of a library package, then the first
1738 argument specifies the unit name, and the second argument specifies
1739 the particular entity.  If the second argument is in string form, it must
1740 correspond to the internal manner in which GNAT stores entity names (see
1741 compilation unit Namet in the compiler sources for details).
1742
1743 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1744 to distinguish between overloaded subprograms. If a pragma does not contain
1745 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1746 subprograms denoted by the first two parameters.
1747
1748 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1749 to be eliminated in a manner similar to that used for the extended
1750 @code{Import} and @code{Export} pragmas, except that the subtype names are
1751 always given as strings. At the moment, this form of distinguishing
1752 overloaded subprograms is implemented only partially, so we do not recommend
1753 using it for practical subprogram elimination.
1754
1755 Note that in case of a parameterless procedure its profile is represented
1756 as @code{Parameter_Types => ("")}
1757
1758 Alternatively, the @code{Source_Location} parameter is used to specify
1759 which overloaded alternative is to be eliminated by pointing to the
1760 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1761 source text. The string literal (or concatenation of string literals)
1762 given as SOURCE_TRACE must have the following format:
1763
1764 @smallexample @c ada
1765 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1766
1767 LBRACKET ::= [
1768 RBRACKET ::= ]
1769
1770 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1771 FILE_NAME       ::= STRING_LITERAL
1772 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1773 @end smallexample
1774
1775 SOURCE_TRACE should be the short name of the source file (with no directory
1776 information), and LINE_NUMBER is supposed to point to the line where the
1777 defining name of the subprogram is located.
1778
1779 For the subprograms that are not a part of generic instantiations, only one
1780 SOURCE_LOCATION is used. If a subprogram is declared in a package
1781 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1782 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1783 second one denotes the declaration of the corresponding subprogram in the
1784 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1785 in case of nested instantiations.
1786
1787 The effect of the pragma is to allow the compiler to eliminate
1788 the code or data associated with the named entity.  Any reference to
1789 an eliminated entity outside the compilation unit it is defined in,
1790 causes a compile time or link time error.
1791
1792 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1793 in a system independent manner, with unused entities eliminated, without
1794 the requirement of modifying the source text.  Normally the required set
1795 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1796 tool. Elimination of unused entities local to a compilation unit is
1797 automatic, without requiring the use of pragma @code{Eliminate}.
1798
1799 Note that the reason this pragma takes string literals where names might
1800 be expected is that a pragma @code{Eliminate} can appear in a context where the
1801 relevant names are not visible.
1802
1803 Note that any change in the source files that includes removing, splitting of
1804 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1805 parameter illegal.
1806
1807 It is legal to use pragma Eliminate where the referenced entity is a
1808 dispatching operation, but it is not clear what this would mean, since
1809 in general the call does not know which entity is actually being called.
1810 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1811
1812 @node Pragma Export_Exception
1813 @unnumberedsec Pragma Export_Exception
1814 @cindex OpenVMS
1815 @findex Export_Exception
1816 @noindent
1817 Syntax:
1818
1819 @smallexample @c ada
1820 pragma Export_Exception (
1821      [Internal =>] LOCAL_NAME
1822   [, [External =>] EXTERNAL_SYMBOL]
1823   [, [Form     =>] Ada | VMS]
1824   [, [Code     =>] static_integer_EXPRESSION]);
1825
1826 EXTERNAL_SYMBOL ::=
1827   IDENTIFIER
1828 | static_string_EXPRESSION
1829 @end smallexample
1830
1831 @noindent
1832 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1833 causes the specified exception to be propagated outside of the Ada program,
1834 so that it can be handled by programs written in other OpenVMS languages.
1835 This pragma establishes an external name for an Ada exception and makes the
1836 name available to the OpenVMS Linker as a global symbol.  For further details
1837 on this pragma, see the
1838 DEC Ada Language Reference Manual, section 13.9a3.2.
1839
1840 @node Pragma Export_Function
1841 @unnumberedsec Pragma Export_Function
1842 @cindex Argument passing mechanisms
1843 @findex Export_Function
1844
1845 @noindent
1846 Syntax:
1847
1848 @smallexample @c ada
1849 pragma Export_Function (
1850      [Internal         =>] LOCAL_NAME
1851   [, [External         =>] EXTERNAL_SYMBOL]
1852   [, [Parameter_Types  =>] PARAMETER_TYPES]
1853   [, [Result_Type      =>] result_SUBTYPE_MARK]
1854   [, [Mechanism        =>] MECHANISM]
1855   [, [Result_Mechanism =>] MECHANISM_NAME]);
1856
1857 EXTERNAL_SYMBOL ::=
1858   IDENTIFIER
1859 | static_string_EXPRESSION
1860 | ""
1861
1862 PARAMETER_TYPES ::=
1863   null
1864 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1865
1866 TYPE_DESIGNATOR ::=
1867   subtype_NAME
1868 | subtype_Name ' Access
1869
1870 MECHANISM ::=
1871   MECHANISM_NAME
1872 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1873
1874 MECHANISM_ASSOCIATION ::=
1875   [formal_parameter_NAME =>] MECHANISM_NAME
1876
1877 MECHANISM_NAME ::=
1878   Value
1879 | Reference
1880 | Descriptor [([Class =>] CLASS_NAME)]
1881 | Short_Descriptor [([Class =>] CLASS_NAME)]
1882
1883 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1884 @end smallexample
1885
1886 @noindent
1887 Use this pragma to make a function externally callable and optionally
1888 provide information on mechanisms to be used for passing parameter and
1889 result values.  We recommend, for the purposes of improving portability,
1890 this pragma always be used in conjunction with a separate pragma
1891 @code{Export}, which must precede the pragma @code{Export_Function}.
1892 GNAT does not require a separate pragma @code{Export}, but if none is
1893 present, @code{Convention Ada} is assumed, which is usually
1894 not what is wanted, so it is usually appropriate to use this
1895 pragma in conjunction with a @code{Export} or @code{Convention}
1896 pragma that specifies the desired foreign convention.
1897 Pragma @code{Export_Function}
1898 (and @code{Export}, if present) must appear in the same declarative
1899 region as the function to which they apply.
1900
1901 @var{internal_name} must uniquely designate the function to which the
1902 pragma applies.  If more than one function name exists of this name in
1903 the declarative part you must use the @code{Parameter_Types} and
1904 @code{Result_Type} parameters is mandatory to achieve the required
1905 unique designation.  @var{subtype_mark}s in these parameters must
1906 exactly match the subtypes in the corresponding function specification,
1907 using positional notation to match parameters with subtype marks.
1908 The form with an @code{'Access} attribute can be used to match an
1909 anonymous access parameter.
1910
1911 @cindex OpenVMS
1912 @cindex Passing by descriptor
1913 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1914 The default behavior for Export_Function is to accept either 64bit or
1915 32bit descriptors unless short_descriptor is specified, then only 32bit
1916 descriptors are accepted.
1917
1918 @cindex Suppressing external name
1919 Special treatment is given if the EXTERNAL is an explicit null
1920 string or a static string expressions that evaluates to the null
1921 string. In this case, no external name is generated. This form
1922 still allows the specification of parameter mechanisms.
1923
1924 @node Pragma Export_Object
1925 @unnumberedsec Pragma Export_Object
1926 @findex Export_Object
1927 @noindent
1928 Syntax:
1929
1930 @smallexample @c ada
1931 pragma Export_Object
1932       [Internal =>] LOCAL_NAME
1933    [, [External =>] EXTERNAL_SYMBOL]
1934    [, [Size     =>] EXTERNAL_SYMBOL]
1935
1936 EXTERNAL_SYMBOL ::=
1937   IDENTIFIER
1938 | static_string_EXPRESSION
1939 @end smallexample
1940
1941 @noindent
1942 This pragma designates an object as exported, and apart from the
1943 extended rules for external symbols, is identical in effect to the use of
1944 the normal @code{Export} pragma applied to an object.  You may use a
1945 separate Export pragma (and you probably should from the point of view
1946 of portability), but it is not required.  @var{Size} is syntax checked,
1947 but otherwise ignored by GNAT@.
1948
1949 @node Pragma Export_Procedure
1950 @unnumberedsec Pragma Export_Procedure
1951 @findex Export_Procedure
1952 @noindent
1953 Syntax:
1954
1955 @smallexample @c ada
1956 pragma Export_Procedure (
1957      [Internal        =>] LOCAL_NAME
1958   [, [External        =>] EXTERNAL_SYMBOL]
1959   [, [Parameter_Types =>] PARAMETER_TYPES]
1960   [, [Mechanism       =>] MECHANISM]);
1961
1962 EXTERNAL_SYMBOL ::=
1963   IDENTIFIER
1964 | static_string_EXPRESSION
1965 | ""
1966
1967 PARAMETER_TYPES ::=
1968   null
1969 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1970
1971 TYPE_DESIGNATOR ::=
1972   subtype_NAME
1973 | subtype_Name ' Access
1974
1975 MECHANISM ::=
1976   MECHANISM_NAME
1977 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1978
1979 MECHANISM_ASSOCIATION ::=
1980   [formal_parameter_NAME =>] MECHANISM_NAME
1981
1982 MECHANISM_NAME ::=
1983   Value
1984 | Reference
1985 | Descriptor [([Class =>] CLASS_NAME)]
1986 | Short_Descriptor [([Class =>] CLASS_NAME)]
1987
1988 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1989 @end smallexample
1990
1991 @noindent
1992 This pragma is identical to @code{Export_Function} except that it
1993 applies to a procedure rather than a function and the parameters
1994 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1995 GNAT does not require a separate pragma @code{Export}, but if none is
1996 present, @code{Convention Ada} is assumed, which is usually
1997 not what is wanted, so it is usually appropriate to use this
1998 pragma in conjunction with a @code{Export} or @code{Convention}
1999 pragma that specifies the desired foreign convention.
2000
2001 @cindex OpenVMS
2002 @cindex Passing by descriptor
2003 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2004 The default behavior for Export_Procedure is to accept either 64bit or
2005 32bit descriptors unless short_descriptor is specified, then only 32bit
2006 descriptors are accepted.
2007
2008 @cindex Suppressing external name
2009 Special treatment is given if the EXTERNAL is an explicit null
2010 string or a static string expressions that evaluates to the null
2011 string. In this case, no external name is generated. This form
2012 still allows the specification of parameter mechanisms.
2013
2014 @node Pragma Export_Value
2015 @unnumberedsec Pragma Export_Value
2016 @findex Export_Value
2017 @noindent
2018 Syntax:
2019
2020 @smallexample @c ada
2021 pragma Export_Value (
2022   [Value     =>] static_integer_EXPRESSION,
2023   [Link_Name =>] static_string_EXPRESSION);
2024 @end smallexample
2025
2026 @noindent
2027 This pragma serves to export a static integer value for external use.
2028 The first argument specifies the value to be exported. The Link_Name
2029 argument specifies the symbolic name to be associated with the integer
2030 value. This pragma is useful for defining a named static value in Ada
2031 that can be referenced in assembly language units to be linked with
2032 the application. This pragma is currently supported only for the
2033 AAMP target and is ignored for other targets.
2034
2035 @node Pragma Export_Valued_Procedure
2036 @unnumberedsec Pragma Export_Valued_Procedure
2037 @findex Export_Valued_Procedure
2038 @noindent
2039 Syntax:
2040
2041 @smallexample @c ada
2042 pragma Export_Valued_Procedure (
2043      [Internal        =>] LOCAL_NAME
2044   [, [External        =>] EXTERNAL_SYMBOL]
2045   [, [Parameter_Types =>] PARAMETER_TYPES]
2046   [, [Mechanism       =>] MECHANISM]);
2047
2048 EXTERNAL_SYMBOL ::=
2049   IDENTIFIER
2050 | static_string_EXPRESSION
2051 | ""
2052
2053 PARAMETER_TYPES ::=
2054   null
2055 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2056
2057 TYPE_DESIGNATOR ::=
2058   subtype_NAME
2059 | subtype_Name ' Access
2060
2061 MECHANISM ::=
2062   MECHANISM_NAME
2063 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2064
2065 MECHANISM_ASSOCIATION ::=
2066   [formal_parameter_NAME =>] MECHANISM_NAME
2067
2068 MECHANISM_NAME ::=
2069   Value
2070 | Reference
2071 | Descriptor [([Class =>] CLASS_NAME)]
2072 | Short_Descriptor [([Class =>] CLASS_NAME)]
2073
2074 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2075 @end smallexample
2076
2077 @noindent
2078 This pragma is identical to @code{Export_Procedure} except that the
2079 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2080 mode @code{OUT}, and externally the subprogram is treated as a function
2081 with this parameter as the result of the function.  GNAT provides for
2082 this capability to allow the use of @code{OUT} and @code{IN OUT}
2083 parameters in interfacing to external functions (which are not permitted
2084 in Ada functions).
2085 GNAT does not require a separate pragma @code{Export}, but if none is
2086 present, @code{Convention Ada} is assumed, which is almost certainly
2087 not what is wanted since the whole point of this pragma is to interface
2088 with foreign language functions, so it is usually appropriate to use this
2089 pragma in conjunction with a @code{Export} or @code{Convention}
2090 pragma that specifies the desired foreign convention.
2091
2092 @cindex OpenVMS
2093 @cindex Passing by descriptor
2094 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2095 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2096 32bit descriptors unless short_descriptor is specified, then only 32bit
2097 descriptors are accepted.
2098
2099 @cindex Suppressing external name
2100 Special treatment is given if the EXTERNAL is an explicit null
2101 string or a static string expressions that evaluates to the null
2102 string. In this case, no external name is generated. This form
2103 still allows the specification of parameter mechanisms.
2104
2105 @node Pragma Extend_System
2106 @unnumberedsec Pragma Extend_System
2107 @cindex @code{system}, extending
2108 @cindex Dec Ada 83
2109 @findex Extend_System
2110 @noindent
2111 Syntax:
2112
2113 @smallexample @c ada
2114 pragma Extend_System ([Name =>] IDENTIFIER);
2115 @end smallexample
2116
2117 @noindent
2118 This pragma is used to provide backwards compatibility with other
2119 implementations that extend the facilities of package @code{System}.  In
2120 GNAT, @code{System} contains only the definitions that are present in
2121 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2122 implementation, provide many extensions to package @code{System}.
2123
2124 For each such implementation accommodated by this pragma, GNAT provides a
2125 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2126 implementation, which provides the required additional definitions.  You
2127 can use this package in two ways.  You can @code{with} it in the normal
2128 way and access entities either by selection or using a @code{use}
2129 clause.  In this case no special processing is required.
2130
2131 However, if existing code contains references such as
2132 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2133 definitions provided in package @code{System}, you may use this pragma
2134 to extend visibility in @code{System} in a non-standard way that
2135 provides greater compatibility with the existing code.  Pragma
2136 @code{Extend_System} is a configuration pragma whose single argument is
2137 the name of the package containing the extended definition
2138 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2139 control of this pragma will be processed using special visibility
2140 processing that looks in package @code{System.Aux_@var{xxx}} where
2141 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2142 package @code{System}, but not found in package @code{System}.
2143
2144 You can use this pragma either to access a predefined @code{System}
2145 extension supplied with the compiler, for example @code{Aux_DEC} or
2146 you can construct your own extension unit following the above
2147 definition.  Note that such a package is a child of @code{System}
2148 and thus is considered part of the implementation.  To compile
2149 it you will have to use the appropriate switch for compiling
2150 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2151 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2152
2153 @node Pragma External
2154 @unnumberedsec Pragma External
2155 @findex External
2156 @noindent
2157 Syntax:
2158
2159 @smallexample @c ada
2160 pragma External (
2161   [   Convention    =>] convention_IDENTIFIER,
2162   [   Entity        =>] LOCAL_NAME
2163   [, [External_Name =>] static_string_EXPRESSION ]
2164   [, [Link_Name     =>] static_string_EXPRESSION ]);
2165 @end smallexample
2166
2167 @noindent
2168 This pragma is identical in syntax and semantics to pragma
2169 @code{Export} as defined in the Ada Reference Manual.  It is
2170 provided for compatibility with some Ada 83 compilers that
2171 used this pragma for exactly the same purposes as pragma
2172 @code{Export} before the latter was standardized.
2173
2174 @node Pragma External_Name_Casing
2175 @unnumberedsec Pragma External_Name_Casing
2176 @cindex Dec Ada 83 casing compatibility
2177 @cindex External Names, casing
2178 @cindex Casing of External names
2179 @findex External_Name_Casing
2180 @noindent
2181 Syntax:
2182
2183 @smallexample @c ada
2184 pragma External_Name_Casing (
2185   Uppercase | Lowercase
2186   [, Uppercase | Lowercase | As_Is]);
2187 @end smallexample
2188
2189 @noindent
2190 This pragma provides control over the casing of external names associated
2191 with Import and Export pragmas.  There are two cases to consider:
2192
2193 @table @asis
2194 @item Implicit external names
2195 Implicit external names are derived from identifiers.  The most common case
2196 arises when a standard Ada Import or Export pragma is used with only two
2197 arguments, as in:
2198
2199 @smallexample @c ada
2200    pragma Import (C, C_Routine);
2201 @end smallexample
2202
2203 @noindent
2204 Since Ada is a case-insensitive language, the spelling of the identifier in
2205 the Ada source program does not provide any information on the desired
2206 casing of the external name, and so a convention is needed.  In GNAT the
2207 default treatment is that such names are converted to all lower case
2208 letters.  This corresponds to the normal C style in many environments.
2209 The first argument of pragma @code{External_Name_Casing} can be used to
2210 control this treatment.  If @code{Uppercase} is specified, then the name
2211 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2212 then the normal default of all lower case letters will be used.
2213
2214 This same implicit treatment is also used in the case of extended DEC Ada 83
2215 compatible Import and Export pragmas where an external name is explicitly
2216 specified using an identifier rather than a string.
2217
2218 @item Explicit external names
2219 Explicit external names are given as string literals.  The most common case
2220 arises when a standard Ada Import or Export pragma is used with three
2221 arguments, as in:
2222
2223 @smallexample @c ada
2224 pragma Import (C, C_Routine, "C_routine");
2225 @end smallexample
2226
2227 @noindent
2228 In this case, the string literal normally provides the exact casing required
2229 for the external name.  The second argument of pragma
2230 @code{External_Name_Casing} may be used to modify this behavior.
2231 If @code{Uppercase} is specified, then the name
2232 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2233 then the name will be forced to all lowercase letters.  A specification of
2234 @code{As_Is} provides the normal default behavior in which the casing is
2235 taken from the string provided.
2236 @end table
2237
2238 @noindent
2239 This pragma may appear anywhere that a pragma is valid.  In particular, it
2240 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2241 case it applies to all subsequent compilations, or it can be used as a program
2242 unit pragma, in which case it only applies to the current unit, or it can
2243 be used more locally to control individual Import/Export pragmas.
2244
2245 It is primarily intended for use with OpenVMS systems, where many
2246 compilers convert all symbols to upper case by default.  For interfacing to
2247 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2248 the pragma:
2249
2250 @smallexample @c ada
2251 pragma External_Name_Casing (Uppercase, Uppercase);
2252 @end smallexample
2253
2254 @noindent
2255 to enforce the upper casing of all external symbols.
2256
2257 @node Pragma Fast_Math
2258 @unnumberedsec Pragma Fast_Math
2259 @findex Fast_Math
2260 @noindent
2261 Syntax:
2262
2263 @smallexample @c ada
2264 pragma Fast_Math;
2265 @end smallexample
2266
2267 @noindent
2268 This is a configuration pragma which activates a mode in which speed is
2269 considered more important for floating-point operations than absolutely
2270 accurate adherence to the requirements of the standard. Currently the
2271 following operations are affected:
2272
2273 @table @asis
2274 @item Complex Multiplication
2275 The normal simple formula for complex multiplication can result in intermediate
2276 overflows for numbers near the end of the range. The Ada standard requires that
2277 this situation be detected and corrected by scaling, but in Fast_Math mode such
2278 cases will simply result in overflow. Note that to take advantage of this you
2279 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2280 under control of the pragma, rather than use the preinstantiated versions.
2281 @end table
2282
2283 @node Pragma Favor_Top_Level
2284 @unnumberedsec Pragma Favor_Top_Level
2285 @findex Favor_Top_Level
2286 @noindent
2287 Syntax:
2288
2289 @smallexample @c ada
2290 pragma Favor_Top_Level (type_NAME);
2291 @end smallexample
2292
2293 @noindent
2294 The named type must be an access-to-subprogram type. This pragma is an
2295 efficiency hint to the compiler, regarding the use of 'Access or
2296 'Unrestricted_Access on nested (non-library-level) subprograms. The
2297 pragma means that nested subprograms are not used with this type, or
2298 are rare, so that the generated code should be efficient in the
2299 top-level case. When this pragma is used, dynamically generated
2300 trampolines may be used on some targets for nested subprograms.
2301 See also the No_Implicit_Dynamic_Code restriction.
2302
2303 @node Pragma Finalize_Storage_Only
2304 @unnumberedsec Pragma Finalize_Storage_Only
2305 @findex Finalize_Storage_Only
2306 @noindent
2307 Syntax:
2308
2309 @smallexample @c ada
2310 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2311 @end smallexample
2312
2313 @noindent
2314 This pragma allows the compiler not to emit a Finalize call for objects
2315 defined at the library level.  This is mostly useful for types where
2316 finalization is only used to deal with storage reclamation since in most
2317 environments it is not necessary to reclaim memory just before terminating
2318 execution, hence the name.
2319
2320 @node Pragma Float_Representation
2321 @unnumberedsec Pragma Float_Representation
2322 @cindex OpenVMS
2323 @findex Float_Representation
2324 @noindent
2325 Syntax:
2326
2327 @smallexample @c ada
2328 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2329
2330 FLOAT_REP ::= VAX_Float | IEEE_Float
2331 @end smallexample
2332
2333 @noindent
2334 In the one argument form, this pragma is a configuration pragma which
2335 allows control over the internal representation chosen for the predefined
2336 floating point types declared in the packages @code{Standard} and
2337 @code{System}. On all systems other than OpenVMS, the argument must
2338 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2339 argument may be @code{VAX_Float} to specify the use of the VAX float
2340 format for the floating-point types in Standard. This requires that
2341 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2342 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2343 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2344
2345 The two argument form specifies the representation to be used for
2346 the specified floating-point type. On all systems other than OpenVMS,
2347 the argument must
2348 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2349 argument may be @code{VAX_Float} to specify the use of the VAX float
2350 format, as follows:
2351
2352 @itemize @bullet
2353 @item
2354 For digits values up to 6, F float format will be used.
2355 @item
2356 For digits values from 7 to 9, G float format will be used.
2357 @item
2358 For digits values from 10 to 15, F float format will be used.
2359 @item
2360 Digits values above 15 are not allowed.
2361 @end itemize
2362
2363 @node Pragma Ident
2364 @unnumberedsec Pragma Ident
2365 @findex Ident
2366 @noindent
2367 Syntax:
2368
2369 @smallexample @c ada
2370 pragma Ident (static_string_EXPRESSION);
2371 @end smallexample
2372
2373 @noindent
2374 This pragma provides a string identification in the generated object file,
2375 if the system supports the concept of this kind of identification string.
2376 This pragma is allowed only in the outermost declarative part or
2377 declarative items of a compilation unit. If more than one @code{Ident}
2378 pragma is given, only the last one processed is effective.
2379 @cindex OpenVMS
2380 On OpenVMS systems, the effect of the pragma is identical to the effect of
2381 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2382 maximum allowed length is 31 characters, so if it is important to
2383 maintain compatibility with this compiler, you should obey this length
2384 limit.
2385
2386 @node Pragma Implemented_By_Entry
2387 @unnumberedsec Pragma Implemented_By_Entry
2388 @findex Implemented_By_Entry
2389 @noindent
2390 Syntax:
2391
2392 @smallexample @c ada
2393 pragma Implemented_By_Entry (LOCAL_NAME);
2394 @end smallexample
2395
2396 @noindent
2397 This is a representation pragma which applies to protected, synchronized and
2398 task interface primitives. If the pragma is applied to primitive operation Op
2399 of interface Iface, it is illegal to override Op in a type that implements
2400 Iface, with anything other than an entry.
2401
2402 @smallexample @c ada
2403 type Iface is protected interface;
2404 procedure Do_Something (Object : in out Iface) is abstract;
2405 pragma Implemented_By_Entry (Do_Something);
2406
2407 protected type P is new Iface with
2408    procedure Do_Something;  --  Illegal
2409 end P;
2410
2411 task type T is new Iface with
2412    entry Do_Something;      --  Legal
2413 end T;
2414 @end smallexample
2415
2416 @noindent
2417 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2418 is intended to be used in conjunction with dispatching requeue statements as
2419 described in AI05-0030. Should the ARG decide on an official name and syntax,
2420 this pragma will become language-defined rather than GNAT-specific.
2421
2422 @node Pragma Implicit_Packing
2423 @unnumberedsec Pragma Implicit_Packing
2424 @findex Implicit_Packing
2425 @noindent
2426 Syntax:
2427
2428 @smallexample @c ada
2429 pragma Implicit_Packing;
2430 @end smallexample
2431
2432 @noindent
2433 This is a configuration pragma that requests implicit packing for packed
2434 arrays for which a size clause is given but no explicit pragma Pack or
2435 specification of Component_Size is present. Consider this example:
2436
2437 @smallexample @c ada
2438 type R is array (0 .. 7) of Boolean;
2439 for R'Size use 8;
2440 @end smallexample
2441
2442 @noindent
2443 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2444 does not change the layout of a composite object. So the Size clause in the
2445 above example is normally rejected, since the default layout of the array uses
2446 8-bit components, and thus the array requires a minimum of 64 bits.
2447
2448 If this declaration is compiled in a region of code covered by an occurrence
2449 of the configuration pragma Implicit_Packing, then the Size clause in this
2450 and similar examples will cause implicit packing and thus be accepted. For
2451 this implicit packing to occur, the type in question must be an array of small
2452 components whose size is known at compile time, and the Size clause must
2453 specify the exact size that corresponds to the length of the array multiplied
2454 by the size in bits of the component type.
2455 @cindex Array packing
2456
2457 @node Pragma Import_Exception
2458 @unnumberedsec Pragma Import_Exception
2459 @cindex OpenVMS
2460 @findex Import_Exception
2461 @noindent
2462 Syntax:
2463
2464 @smallexample @c ada
2465 pragma Import_Exception (
2466      [Internal =>] LOCAL_NAME
2467   [, [External =>] EXTERNAL_SYMBOL]
2468   [, [Form     =>] Ada | VMS]
2469   [, [Code     =>] static_integer_EXPRESSION]);
2470
2471 EXTERNAL_SYMBOL ::=
2472   IDENTIFIER
2473 | static_string_EXPRESSION
2474 @end smallexample
2475
2476 @noindent
2477 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2478 It allows OpenVMS conditions (for example, from OpenVMS system services or
2479 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2480 The pragma specifies that the exception associated with an exception
2481 declaration in an Ada program be defined externally (in non-Ada code).
2482 For further details on this pragma, see the
2483 DEC Ada Language Reference Manual, section 13.9a.3.1.
2484
2485 @node Pragma Import_Function
2486 @unnumberedsec Pragma Import_Function
2487 @findex Import_Function
2488 @noindent
2489 Syntax:
2490
2491 @smallexample @c ada
2492 pragma Import_Function (
2493      [Internal                 =>] LOCAL_NAME,
2494   [, [External                 =>] EXTERNAL_SYMBOL]
2495   [, [Parameter_Types          =>] PARAMETER_TYPES]
2496   [, [Result_Type              =>] SUBTYPE_MARK]
2497   [, [Mechanism                =>] MECHANISM]
2498   [, [Result_Mechanism         =>] MECHANISM_NAME]
2499   [, [First_Optional_Parameter =>] IDENTIFIER]);
2500
2501 EXTERNAL_SYMBOL ::=
2502   IDENTIFIER
2503 | static_string_EXPRESSION
2504
2505 PARAMETER_TYPES ::=
2506   null
2507 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2508
2509 TYPE_DESIGNATOR ::=
2510   subtype_NAME
2511 | subtype_Name ' Access
2512
2513 MECHANISM ::=
2514   MECHANISM_NAME
2515 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2516
2517 MECHANISM_ASSOCIATION ::=
2518   [formal_parameter_NAME =>] MECHANISM_NAME
2519
2520 MECHANISM_NAME ::=
2521   Value
2522 | Reference
2523 | Descriptor [([Class =>] CLASS_NAME)]
2524 | Short_Descriptor [([Class =>] CLASS_NAME)]
2525
2526 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2527 @end smallexample
2528
2529 @noindent
2530 This pragma is used in conjunction with a pragma @code{Import} to
2531 specify additional information for an imported function.  The pragma
2532 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2533 @code{Import_Function} pragma and both must appear in the same
2534 declarative part as the function specification.
2535
2536 The @var{Internal} argument must uniquely designate
2537 the function to which the
2538 pragma applies.  If more than one function name exists of this name in
2539 the declarative part you must use the @code{Parameter_Types} and
2540 @var{Result_Type} parameters to achieve the required unique
2541 designation.  Subtype marks in these parameters must exactly match the
2542 subtypes in the corresponding function specification, using positional
2543 notation to match parameters with subtype marks.
2544 The form with an @code{'Access} attribute can be used to match an
2545 anonymous access parameter.
2546
2547 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2548 parameters to specify passing mechanisms for the
2549 parameters and result.  If you specify a single mechanism name, it
2550 applies to all parameters.  Otherwise you may specify a mechanism on a
2551 parameter by parameter basis using either positional or named
2552 notation.  If the mechanism is not specified, the default mechanism
2553 is used.
2554
2555 @cindex OpenVMS
2556 @cindex Passing by descriptor
2557 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2558 The default behavior for Import_Function is to pass a 64bit descriptor
2559 unless short_descriptor is specified, then a 32bit descriptor is passed.
2560
2561 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2562 It specifies that the designated parameter and all following parameters
2563 are optional, meaning that they are not passed at the generated code
2564 level (this is distinct from the notion of optional parameters in Ada
2565 where the parameters are passed anyway with the designated optional
2566 parameters).  All optional parameters must be of mode @code{IN} and have
2567 default parameter values that are either known at compile time
2568 expressions, or uses of the @code{'Null_Parameter} attribute.
2569
2570 @node Pragma Import_Object
2571 @unnumberedsec Pragma Import_Object
2572 @findex Import_Object
2573 @noindent
2574 Syntax:
2575
2576 @smallexample @c ada
2577 pragma Import_Object
2578      [Internal =>] LOCAL_NAME
2579   [, [External =>] EXTERNAL_SYMBOL]
2580   [, [Size     =>] EXTERNAL_SYMBOL]);
2581
2582 EXTERNAL_SYMBOL ::=
2583   IDENTIFIER
2584 | static_string_EXPRESSION
2585 @end smallexample
2586
2587 @noindent
2588 This pragma designates an object as imported, and apart from the
2589 extended rules for external symbols, is identical in effect to the use of
2590 the normal @code{Import} pragma applied to an object.  Unlike the
2591 subprogram case, you need not use a separate @code{Import} pragma,
2592 although you may do so (and probably should do so from a portability
2593 point of view).  @var{size} is syntax checked, but otherwise ignored by
2594 GNAT@.
2595
2596 @node Pragma Import_Procedure
2597 @unnumberedsec Pragma Import_Procedure
2598 @findex Import_Procedure
2599 @noindent
2600 Syntax:
2601
2602 @smallexample @c ada
2603 pragma Import_Procedure (
2604      [Internal                 =>] LOCAL_NAME
2605   [, [External                 =>] EXTERNAL_SYMBOL]
2606   [, [Parameter_Types          =>] PARAMETER_TYPES]
2607   [, [Mechanism                =>] MECHANISM]
2608   [, [First_Optional_Parameter =>] IDENTIFIER]);
2609
2610 EXTERNAL_SYMBOL ::=
2611   IDENTIFIER
2612 | static_string_EXPRESSION
2613
2614 PARAMETER_TYPES ::=
2615   null
2616 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2617
2618 TYPE_DESIGNATOR ::=
2619   subtype_NAME
2620 | subtype_Name ' Access
2621
2622 MECHANISM ::=
2623   MECHANISM_NAME
2624 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2625
2626 MECHANISM_ASSOCIATION ::=
2627   [formal_parameter_NAME =>] MECHANISM_NAME
2628
2629 MECHANISM_NAME ::=
2630   Value
2631 | Reference
2632 | Descriptor [([Class =>] CLASS_NAME)]
2633 | Short_Descriptor [([Class =>] CLASS_NAME)]
2634
2635 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2636 @end smallexample
2637
2638 @noindent
2639 This pragma is identical to @code{Import_Function} except that it
2640 applies to a procedure rather than a function and the parameters
2641 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2642
2643 @node Pragma Import_Valued_Procedure
2644 @unnumberedsec Pragma Import_Valued_Procedure
2645 @findex Import_Valued_Procedure
2646 @noindent
2647 Syntax:
2648
2649 @smallexample @c ada
2650 pragma Import_Valued_Procedure (
2651      [Internal                 =>] LOCAL_NAME
2652   [, [External                 =>] EXTERNAL_SYMBOL]
2653   [, [Parameter_Types          =>] PARAMETER_TYPES]
2654   [, [Mechanism                =>] MECHANISM]
2655   [, [First_Optional_Parameter =>] IDENTIFIER]);
2656
2657 EXTERNAL_SYMBOL ::=
2658   IDENTIFIER
2659 | static_string_EXPRESSION
2660
2661 PARAMETER_TYPES ::=
2662   null
2663 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2664
2665 TYPE_DESIGNATOR ::=
2666   subtype_NAME
2667 | subtype_Name ' Access
2668
2669 MECHANISM ::=
2670   MECHANISM_NAME
2671 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2672
2673 MECHANISM_ASSOCIATION ::=
2674   [formal_parameter_NAME =>] MECHANISM_NAME
2675
2676 MECHANISM_NAME ::=
2677   Value
2678 | Reference
2679 | Descriptor [([Class =>] CLASS_NAME)]
2680 | Short_Descriptor [([Class =>] CLASS_NAME)]
2681
2682 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2683 @end smallexample
2684
2685 @noindent
2686 This pragma is identical to @code{Import_Procedure} except that the
2687 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2688 mode @code{OUT}, and externally the subprogram is treated as a function
2689 with this parameter as the result of the function.  The purpose of this
2690 capability is to allow the use of @code{OUT} and @code{IN OUT}
2691 parameters in interfacing to external functions (which are not permitted
2692 in Ada functions).  You may optionally use the @code{Mechanism}
2693 parameters to specify passing mechanisms for the parameters.
2694 If you specify a single mechanism name, it applies to all parameters.
2695 Otherwise you may specify a mechanism on a parameter by parameter
2696 basis using either positional or named notation.  If the mechanism is not
2697 specified, the default mechanism is used.
2698
2699 Note that it is important to use this pragma in conjunction with a separate
2700 pragma Import that specifies the desired convention, since otherwise the
2701 default convention is Ada, which is almost certainly not what is required.
2702
2703 @node Pragma Initialize_Scalars
2704 @unnumberedsec Pragma Initialize_Scalars
2705 @findex Initialize_Scalars
2706 @cindex debugging with Initialize_Scalars
2707 @noindent
2708 Syntax:
2709
2710 @smallexample @c ada
2711 pragma Initialize_Scalars;
2712 @end smallexample
2713
2714 @noindent
2715 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2716 two important differences.  First, there is no requirement for the pragma
2717 to be used uniformly in all units of a partition, in particular, it is fine
2718 to use this just for some or all of the application units of a partition,
2719 without needing to recompile the run-time library.
2720
2721 In the case where some units are compiled with the pragma, and some without,
2722 then a declaration of a variable where the type is defined in package
2723 Standard or is locally declared will always be subject to initialization,
2724 as will any declaration of a scalar variable.  For composite variables,
2725 whether the variable is initialized may also depend on whether the package
2726 in which the type of the variable is declared is compiled with the pragma.
2727
2728 The other important difference is that you can control the value used
2729 for initializing scalar objects.  At bind time, you can select several
2730 options for initialization. You can
2731 initialize with invalid values (similar to Normalize_Scalars, though for
2732 Initialize_Scalars it is not always possible to determine the invalid
2733 values in complex cases like signed component fields with non-standard
2734 sizes). You can also initialize with high or
2735 low values, or with a specified bit pattern.  See the users guide for binder
2736 options for specifying these cases.
2737
2738 This means that you can compile a program, and then without having to
2739 recompile the program, you can run it with different values being used
2740 for initializing otherwise uninitialized values, to test if your program
2741 behavior depends on the choice.  Of course the behavior should not change,
2742 and if it does, then most likely you have an erroneous reference to an
2743 uninitialized value.
2744
2745 It is even possible to change the value at execution time eliminating even
2746 the need to rebind with a different switch using an environment variable.
2747 See the GNAT users guide for details.
2748
2749 Note that pragma @code{Initialize_Scalars} is particularly useful in
2750 conjunction with the enhanced validity checking that is now provided
2751 in GNAT, which checks for invalid values under more conditions.
2752 Using this feature (see description of the @option{-gnatV} flag in the
2753 users guide) in conjunction with pragma @code{Initialize_Scalars}
2754 provides a powerful new tool to assist in the detection of problems
2755 caused by uninitialized variables.
2756
2757 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2758 effect on the generated code. This may cause your code to be
2759 substantially larger. It may also cause an increase in the amount
2760 of stack required, so it is probably a good idea to turn on stack
2761 checking (see description of stack checking in the GNAT users guide)
2762 when using this pragma.
2763
2764 @node Pragma Inline_Always
2765 @unnumberedsec Pragma Inline_Always
2766 @findex Inline_Always
2767 @noindent
2768 Syntax:
2769
2770 @smallexample @c ada
2771 pragma Inline_Always (NAME [, NAME]);
2772 @end smallexample
2773
2774 @noindent
2775 Similar to pragma @code{Inline} except that inlining is not subject to
2776 the use of option @option{-gnatn} and the inlining happens regardless of
2777 whether this option is used.
2778
2779 @node Pragma Inline_Generic
2780 @unnumberedsec Pragma Inline_Generic
2781 @findex Inline_Generic
2782 @noindent
2783 Syntax:
2784
2785 @smallexample @c ada
2786 pragma Inline_Generic (generic_package_NAME);
2787 @end smallexample
2788
2789 @noindent
2790 This is implemented for compatibility with DEC Ada 83 and is recognized,
2791 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2792 by default when using GNAT@.
2793
2794 @node Pragma Interface
2795 @unnumberedsec Pragma Interface
2796 @findex Interface
2797 @noindent
2798 Syntax:
2799
2800 @smallexample @c ada
2801 pragma Interface (
2802      [Convention    =>] convention_identifier,
2803      [Entity        =>] local_NAME
2804   [, [External_Name =>] static_string_expression]
2805   [, [Link_Name     =>] static_string_expression]);
2806 @end smallexample
2807
2808 @noindent
2809 This pragma is identical in syntax and semantics to
2810 the standard Ada pragma @code{Import}.  It is provided for compatibility
2811 with Ada 83.  The definition is upwards compatible both with pragma
2812 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2813 with some extended implementations of this pragma in certain Ada 83
2814 implementations.
2815
2816 @node Pragma Interface_Name
2817 @unnumberedsec Pragma Interface_Name
2818 @findex Interface_Name
2819 @noindent
2820 Syntax:
2821
2822 @smallexample @c ada
2823 pragma Interface_Name (
2824      [Entity        =>] LOCAL_NAME
2825   [, [External_Name =>] static_string_EXPRESSION]
2826   [, [Link_Name     =>] static_string_EXPRESSION]);
2827 @end smallexample
2828
2829 @noindent
2830 This pragma provides an alternative way of specifying the interface name
2831 for an interfaced subprogram, and is provided for compatibility with Ada
2832 83 compilers that use the pragma for this purpose.  You must provide at
2833 least one of @var{External_Name} or @var{Link_Name}.
2834
2835 @node Pragma Interrupt_Handler
2836 @unnumberedsec Pragma Interrupt_Handler
2837 @findex Interrupt_Handler
2838 @noindent
2839 Syntax:
2840
2841 @smallexample @c ada
2842 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2843 @end smallexample
2844
2845 @noindent
2846 This program unit pragma is supported for parameterless protected procedures
2847 as described in Annex C of the Ada Reference Manual. On the AAMP target
2848 the pragma can also be specified for nonprotected parameterless procedures
2849 that are declared at the library level (which includes procedures
2850 declared at the top level of a library package). In the case of AAMP,
2851 when this pragma is applied to a nonprotected procedure, the instruction
2852 @code{IERET} is generated for returns from the procedure, enabling
2853 maskable interrupts, in place of the normal return instruction.
2854
2855 @node Pragma Interrupt_State
2856 @unnumberedsec Pragma Interrupt_State
2857 @findex Interrupt_State
2858 @noindent
2859 Syntax:
2860
2861 @smallexample @c ada
2862 pragma Interrupt_State
2863  ([Name  =>] value,
2864   [State =>] SYSTEM | RUNTIME | USER);
2865 @end smallexample
2866
2867 @noindent
2868 Normally certain interrupts are reserved to the implementation.  Any attempt
2869 to attach an interrupt causes Program_Error to be raised, as described in
2870 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2871 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2872 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2873 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2874 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2875 Ada exceptions, or used to implement run-time functions such as the
2876 @code{abort} statement and stack overflow checking.
2877
2878 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2879 such uses of interrupts.  It subsumes the functionality of pragma
2880 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2881 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2882 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2883 and may be used to mark interrupts required by the board support package
2884 as reserved.
2885
2886 Interrupts can be in one of three states:
2887 @itemize @bullet
2888 @item System
2889
2890 The interrupt is reserved (no Ada handler can be installed), and the
2891 Ada run-time may not install a handler. As a result you are guaranteed
2892 standard system default action if this interrupt is raised.
2893
2894 @item Runtime
2895
2896 The interrupt is reserved (no Ada handler can be installed). The run time
2897 is allowed to install a handler for internal control purposes, but is
2898 not required to do so.
2899
2900 @item User
2901
2902 The interrupt is unreserved.  The user may install a handler to provide
2903 some other action.
2904 @end itemize
2905
2906 @noindent
2907 These states are the allowed values of the @code{State} parameter of the
2908 pragma.  The @code{Name} parameter is a value of the type
2909 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2910 @code{Ada.Interrupts.Names}.
2911
2912 This is a configuration pragma, and the binder will check that there
2913 are no inconsistencies between different units in a partition in how a
2914 given interrupt is specified. It may appear anywhere a pragma is legal.
2915
2916 The effect is to move the interrupt to the specified state.
2917
2918 By declaring interrupts to be SYSTEM, you guarantee the standard system
2919 action, such as a core dump.
2920
2921 By declaring interrupts to be USER, you guarantee that you can install
2922 a handler.
2923
2924 Note that certain signals on many operating systems cannot be caught and
2925 handled by applications.  In such cases, the pragma is ignored.  See the
2926 operating system documentation, or the value of the array @code{Reserved}
2927 declared in the spec of package @code{System.OS_Interface}.
2928
2929 Overriding the default state of signals used by the Ada runtime may interfere
2930 with an application's runtime behavior in the cases of the synchronous signals,
2931 and in the case of the signal used to implement the @code{abort} statement.
2932
2933 @node Pragma Keep_Names
2934 @unnumberedsec Pragma Keep_Names
2935 @findex Keep_Names
2936 @noindent
2937 Syntax:
2938
2939 @smallexample @c ada
2940 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2941 @end smallexample
2942
2943 @noindent
2944 The @var{LOCAL_NAME} argument
2945 must refer to an enumeration first subtype
2946 in the current declarative part. The effect is to retain the enumeration
2947 literal names for use by @code{Image} and @code{Value} even if a global
2948 @code{Discard_Names} pragma applies. This is useful when you want to
2949 generally suppress enumeration literal names and for example you therefore
2950 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2951 want to retain the names for specific enumeration types.
2952
2953 @node Pragma License
2954 @unnumberedsec Pragma License
2955 @findex License
2956 @cindex License checking
2957 @noindent
2958 Syntax:
2959
2960 @smallexample @c ada
2961 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2962 @end smallexample
2963
2964 @noindent
2965 This pragma is provided to allow automated checking for appropriate license
2966 conditions with respect to the standard and modified GPL@.  A pragma
2967 @code{License}, which is a configuration pragma that typically appears at
2968 the start of a source file or in a separate @file{gnat.adc} file, specifies
2969 the licensing conditions of a unit as follows:
2970
2971 @itemize @bullet
2972 @item Unrestricted
2973 This is used for a unit that can be freely used with no license restrictions.
2974 Examples of such units are public domain units, and units from the Ada
2975 Reference Manual.
2976
2977 @item GPL
2978 This is used for a unit that is licensed under the unmodified GPL, and which
2979 therefore cannot be @code{with}'ed by a restricted unit.
2980
2981 @item Modified_GPL
2982 This is used for a unit licensed under the GNAT modified GPL that includes
2983 a special exception paragraph that specifically permits the inclusion of
2984 the unit in programs without requiring the entire program to be released
2985 under the GPL@.
2986
2987 @item Restricted
2988 This is used for a unit that is restricted in that it is not permitted to
2989 depend on units that are licensed under the GPL@.  Typical examples are
2990 proprietary code that is to be released under more restrictive license
2991 conditions.  Note that restricted units are permitted to @code{with} units
2992 which are licensed under the modified GPL (this is the whole point of the
2993 modified GPL).
2994
2995 @end itemize
2996
2997 @noindent
2998 Normally a unit with no @code{License} pragma is considered to have an
2999 unknown license, and no checking is done.  However, standard GNAT headers
3000 are recognized, and license information is derived from them as follows.
3001
3002 @itemize @bullet
3003
3004 A GNAT license header starts with a line containing 78 hyphens.  The following
3005 comment text is searched for the appearance of any of the following strings.
3006
3007 If the string ``GNU General Public License'' is found, then the unit is assumed
3008 to have GPL license, unless the string ``As a special exception'' follows, in
3009 which case the license is assumed to be modified GPL@.
3010
3011 If one of the strings
3012 ``This specification is adapted from the Ada Semantic Interface'' or
3013 ``This specification is derived from the Ada Reference Manual'' is found
3014 then the unit is assumed to be unrestricted.
3015 @end itemize
3016
3017 @noindent
3018 These default actions means that a program with a restricted license pragma
3019 will automatically get warnings if a GPL unit is inappropriately
3020 @code{with}'ed.  For example, the program:
3021
3022 @smallexample @c ada
3023 with Sem_Ch3;
3024 with GNAT.Sockets;
3025 procedure Secret_Stuff is
3026   @dots{}
3027 end Secret_Stuff
3028 @end smallexample
3029
3030 @noindent
3031 if compiled with pragma @code{License} (@code{Restricted}) in a
3032 @file{gnat.adc} file will generate the warning:
3033
3034 @smallexample
3035 1.  with Sem_Ch3;
3036         |
3037    >>> license of withed unit "Sem_Ch3" is incompatible
3038
3039 2.  with GNAT.Sockets;
3040 3.  procedure Secret_Stuff is
3041 @end smallexample
3042
3043 @noindent
3044 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3045 compiler and is licensed under the
3046 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3047 run time, and is therefore licensed under the modified GPL@.
3048
3049 @node Pragma Link_With
3050 @unnumberedsec Pragma Link_With
3051 @findex Link_With
3052 @noindent
3053 Syntax:
3054
3055 @smallexample @c ada
3056 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3057 @end smallexample
3058
3059 @noindent
3060 This pragma is provided for compatibility with certain Ada 83 compilers.
3061 It has exactly the same effect as pragma @code{Linker_Options} except
3062 that spaces occurring within one of the string expressions are treated
3063 as separators. For example, in the following case:
3064
3065 @smallexample @c ada
3066 pragma Link_With ("-labc -ldef");
3067 @end smallexample
3068
3069 @noindent
3070 results in passing the strings @code{-labc} and @code{-ldef} as two
3071 separate arguments to the linker. In addition pragma Link_With allows
3072 multiple arguments, with the same effect as successive pragmas.
3073
3074 @node Pragma Linker_Alias
3075 @unnumberedsec Pragma Linker_Alias
3076 @findex Linker_Alias
3077 @noindent
3078 Syntax:
3079
3080 @smallexample @c ada
3081 pragma Linker_Alias (
3082   [Entity =>] LOCAL_NAME,
3083   [Target =>] static_string_EXPRESSION);
3084 @end smallexample
3085
3086 @noindent
3087 @var{LOCAL_NAME} must refer to an object that is declared at the library
3088 level. This pragma establishes the given entity as a linker alias for the
3089 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3090 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3091 @var{static_string_EXPRESSION} in the object file, that is to say no space
3092 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3093 to the same address as @var{static_string_EXPRESSION} by the linker.
3094
3095 The actual linker name for the target must be used (e.g.@: the fully
3096 encoded name with qualification in Ada, or the mangled name in C++),
3097 or it must be declared using the C convention with @code{pragma Import}
3098 or @code{pragma Export}.
3099
3100 Not all target machines support this pragma. On some of them it is accepted
3101 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3102
3103 @smallexample @c ada
3104 --  Example of the use of pragma Linker_Alias
3105
3106 package p is
3107   i : Integer := 1;
3108   pragma Export (C, i);
3109
3110   new_name_for_i : Integer;
3111   pragma Linker_Alias (new_name_for_i, "i");
3112 end p;
3113 @end smallexample
3114
3115 @node Pragma Linker_Constructor
3116 @unnumberedsec Pragma Linker_Constructor
3117 @findex Linker_Constructor
3118 @noindent
3119 Syntax:
3120
3121 @smallexample @c ada
3122 pragma Linker_Constructor (procedure_LOCAL_NAME);
3123 @end smallexample
3124
3125 @noindent
3126 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3127 is declared at the library level. A procedure to which this pragma is
3128 applied will be treated as an initialization routine by the linker.
3129 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3130 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3131 of the executable is called (or immediately after the shared library is
3132 loaded if the procedure is linked in a shared library), in particular
3133 before the Ada run-time environment is set up.
3134
3135 Because of these specific contexts, the set of operations such a procedure
3136 can perform is very limited and the type of objects it can manipulate is
3137 essentially restricted to the elementary types. In particular, it must only
3138 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3139
3140 This pragma is used by GNAT to implement auto-initialization of shared Stand
3141 Alone Libraries, which provides a related capability without the restrictions
3142 listed above. Where possible, the use of Stand Alone Libraries is preferable
3143 to the use of this pragma.
3144
3145 @node Pragma Linker_Destructor
3146 @unnumberedsec Pragma Linker_Destructor
3147 @findex Linker_Destructor
3148 @noindent
3149 Syntax:
3150
3151 @smallexample @c ada
3152 pragma Linker_Destructor (procedure_LOCAL_NAME);
3153 @end smallexample
3154
3155 @noindent
3156 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3157 is declared at the library level. A procedure to which this pragma is
3158 applied will be treated as a finalization routine by the linker.
3159 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3160 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3161 of the executable has exited (or immediately before the shared library
3162 is unloaded if the procedure is linked in a shared library), in particular
3163 after the Ada run-time environment is shut down.
3164
3165 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3166 because of these specific contexts.
3167
3168 @node Pragma Linker_Section
3169 @unnumberedsec Pragma Linker_Section
3170 @findex Linker_Section
3171 @noindent
3172 Syntax:
3173
3174 @smallexample @c ada
3175 pragma Linker_Section (
3176   [Entity  =>] LOCAL_NAME,
3177   [Section =>] static_string_EXPRESSION);
3178 @end smallexample
3179
3180 @noindent
3181 @var{LOCAL_NAME} must refer to an object that is declared at the library
3182 level. This pragma specifies the name of the linker section for the given
3183 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3184 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3185 section of the executable (assuming the linker doesn't rename the section).
3186
3187 The compiler normally places library-level objects in standard sections
3188 depending on their type: procedures and functions generally go in the
3189 @code{.text} section, initialized variables in the @code{.data} section
3190 and uninitialized variables in the @code{.bss} section.
3191
3192 Other, special sections may exist on given target machines to map special
3193 hardware, for example I/O ports or flash memory. This pragma is a means to
3194 defer the final layout of the executable to the linker, thus fully working
3195 at the symbolic level with the compiler.
3196
3197 Some file formats do not support arbitrary sections so not all target
3198 machines support this pragma. The use of this pragma may cause a program
3199 execution to be erroneous if it is used to place an entity into an
3200 inappropriate section (e.g.@: a modified variable into the @code{.text}
3201 section). See also @code{pragma Persistent_BSS}.
3202
3203 @smallexample @c ada
3204 --  Example of the use of pragma Linker_Section
3205
3206 package IO_Card is
3207   Port_A : Integer;
3208   pragma Volatile (Port_A);
3209   pragma Linker_Section (Port_A, ".bss.port_a");
3210
3211   Port_B : Integer;
3212   pragma Volatile (Port_B);
3213   pragma Linker_Section (Port_B, ".bss.port_b");
3214 end IO_Card;
3215 @end smallexample
3216
3217 @node Pragma Long_Float
3218 @unnumberedsec Pragma Long_Float
3219 @cindex OpenVMS
3220 @findex Long_Float
3221 @noindent
3222 Syntax:
3223
3224 @smallexample @c ada
3225 pragma Long_Float (FLOAT_FORMAT);
3226
3227 FLOAT_FORMAT ::= D_Float | G_Float
3228 @end smallexample
3229
3230 @noindent
3231 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3232 It allows control over the internal representation chosen for the predefined
3233 type @code{Long_Float} and for floating point type representations with
3234 @code{digits} specified in the range 7 through 15.
3235 For further details on this pragma, see the
3236 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3237 this pragma, the standard runtime libraries must be recompiled.
3238 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3239 @value{EDITION} User's Guide OpenVMS}, for a description of the
3240 @code{GNAT LIBRARY} command.
3241
3242 @node Pragma Machine_Attribute
3243 @unnumberedsec Pragma Machine_Attribute
3244 @findex Machine_Attribute
3245 @noindent
3246 Syntax:
3247
3248 @smallexample @c ada
3249 pragma Machine_Attribute (
3250      [Entity         =>] LOCAL_NAME,
3251      [Attribute_Name =>] static_string_EXPRESSION
3252   [, [Info           =>] static_string_EXPRESSION] );
3253 @end smallexample
3254
3255 @noindent
3256 Machine-dependent attributes can be specified for types and/or
3257 declarations.  This pragma is semantically equivalent to
3258 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3259 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3260 in GNU C, where @code{@var{attribute_name}} is recognized by the
3261 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3262 machine.  The optional parameter @var{info} is transformed into an
3263 identifier, which may make this pragma unusable for some attributes
3264 (parameter of some attributes must be a number or a string).
3265 @xref{Target Attributes,, Defining target-specific uses of
3266 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3267 further information.  It is not possible to specify
3268 attributes defined by other languages, only attributes defined by the
3269 machine the code is intended to run on.
3270
3271 @node Pragma Main
3272 @unnumberedsec Pragma Main
3273 @cindex OpenVMS
3274 @findex Main
3275 @noindent
3276 Syntax:
3277
3278 @smallexample @c ada
3279 pragma Main
3280  (MAIN_OPTION [, MAIN_OPTION]);
3281
3282 MAIN_OPTION ::=
3283   [Stack_Size              =>] static_integer_EXPRESSION
3284 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3285 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3286 @end smallexample
3287
3288 @noindent
3289 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3290 no effect in GNAT, other than being syntax checked.
3291
3292 @node Pragma Main_Storage
3293 @unnumberedsec Pragma Main_Storage
3294 @cindex OpenVMS
3295 @findex Main_Storage
3296 @noindent
3297 Syntax:
3298
3299 @smallexample @c ada
3300 pragma Main_Storage
3301   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3302
3303 MAIN_STORAGE_OPTION ::=
3304   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3305 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3306 @end smallexample
3307
3308 @noindent
3309 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3310 no effect in GNAT, other than being syntax checked.  Note that the pragma
3311 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3312
3313 @node Pragma No_Body
3314 @unnumberedsec Pragma No_Body
3315 @findex No_Body
3316 @noindent
3317 Syntax:
3318
3319 @smallexample @c ada
3320 pragma No_Body;
3321 @end smallexample
3322
3323 @noindent
3324 There are a number of cases in which a package spec does not require a body,
3325 and in fact a body is not permitted. GNAT will not permit the spec to be
3326 compiled if there is a body around. The pragma No_Body allows you to provide
3327 a body file, even in a case where no body is allowed. The body file must
3328 contain only comments and a single No_Body pragma. This is recognized by
3329 the compiler as indicating that no body is logically present.
3330
3331 This is particularly useful during maintenance when a package is modified in
3332 such a way that a body needed before is no longer needed. The provision of a
3333 dummy body with a No_Body pragma ensures that there is no interference from
3334 earlier versions of the package body.
3335
3336 @node Pragma No_Return
3337 @unnumberedsec Pragma No_Return
3338 @findex No_Return
3339 @noindent
3340 Syntax:
3341
3342 @smallexample @c ada
3343 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3344 @end smallexample
3345
3346 @noindent
3347 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3348 declarations in the current declarative part.  A procedure to which this
3349 pragma is applied may not contain any explicit @code{return} statements.
3350 In addition, if the procedure contains any implicit returns from falling
3351 off the end of a statement sequence, then execution of that implicit
3352 return will cause Program_Error to be raised.
3353
3354 One use of this pragma is to identify procedures whose only purpose is to raise
3355 an exception. Another use of this pragma is to suppress incorrect warnings
3356 about missing returns in functions, where the last statement of a function
3357 statement sequence is a call to such a procedure.
3358
3359 Note that in Ada 2005 mode, this pragma is part of the language, and is
3360 identical in effect to the pragma as implemented in Ada 95 mode.
3361
3362 @node Pragma No_Strict_Aliasing
3363 @unnumberedsec Pragma No_Strict_Aliasing
3364 @findex No_Strict_Aliasing
3365 @noindent
3366 Syntax:
3367
3368 @smallexample @c ada
3369 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3370 @end smallexample
3371
3372 @noindent
3373 @var{type_LOCAL_NAME} must refer to an access type
3374 declaration in the current declarative part.  The effect is to inhibit
3375 strict aliasing optimization for the given type.  The form with no
3376 arguments is a configuration pragma which applies to all access types
3377 declared in units to which the pragma applies. For a detailed
3378 description of the strict aliasing optimization, and the situations
3379 in which it must be suppressed, see @ref{Optimization and Strict
3380 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3381
3382 @node Pragma Normalize_Scalars
3383 @unnumberedsec Pragma Normalize_Scalars
3384 @findex Normalize_Scalars
3385 @noindent
3386 Syntax:
3387
3388 @smallexample @c ada
3389 pragma Normalize_Scalars;
3390 @end smallexample
3391
3392 @noindent
3393 This is a language defined pragma which is fully implemented in GNAT@.  The
3394 effect is to cause all scalar objects that are not otherwise initialized
3395 to be initialized.  The initial values are implementation dependent and
3396 are as follows:
3397
3398 @table @code
3399 @item Standard.Character
3400 @noindent
3401 Objects whose root type is Standard.Character are initialized to
3402 Character'Last unless the subtype range excludes NUL (in which case
3403 NUL is used). This choice will always generate an invalid value if
3404 one exists.
3405
3406 @item Standard.Wide_Character
3407 @noindent
3408 Objects whose root type is Standard.Wide_Character are initialized to
3409 Wide_Character'Last unless the subtype range excludes NUL (in which case
3410 NUL is used). This choice will always generate an invalid value if
3411 one exists.
3412
3413 @item Standard.Wide_Wide_Character
3414 @noindent
3415 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3416 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3417 which case NUL is used). This choice will always generate an invalid value if
3418 one exists.
3419
3420 @item Integer types
3421 @noindent
3422 Objects of an integer type are treated differently depending on whether
3423 negative values are present in the subtype. If no negative values are
3424 present, then all one bits is used as the initial value except in the
3425 special case where zero is excluded from the subtype, in which case
3426 all zero bits are used. This choice will always generate an invalid
3427 value if one exists.
3428
3429 For subtypes with negative values present, the largest negative number
3430 is used, except in the unusual case where this largest negative number
3431 is in the subtype, and the largest positive number is not, in which case
3432 the largest positive value is used. This choice will always generate
3433 an invalid value if one exists.
3434
3435 @item Floating-Point Types
3436 Objects of all floating-point types are initialized to all 1-bits. For
3437 standard IEEE format, this corresponds to a NaN (not a number) which is
3438 indeed an invalid value.
3439
3440 @item Fixed-Point Types
3441 Objects of all fixed-point types are treated as described above for integers,
3442 with the rules applying to the underlying integer value used to represent
3443 the fixed-point value.
3444
3445 @item Modular types
3446 Objects of a modular type are initialized to all one bits, except in
3447 the special case where zero is excluded from the subtype, in which
3448 case all zero bits are used. This choice will always generate an
3449 invalid value if one exists.
3450
3451 @item Enumeration types
3452 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3453 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3454 whose Pos value is zero, in which case a code of zero is used. This choice
3455 will always generate an invalid value if one exists.
3456
3457 @end table
3458
3459 @node Pragma Obsolescent
3460 @unnumberedsec Pragma Obsolescent
3461 @findex Obsolescent
3462 @noindent
3463 Syntax:
3464
3465 @smallexample @c ada
3466 pragma Obsolescent;
3467
3468 pragma Obsolescent (
3469   [Message =>] static_string_EXPRESSION
3470 [,[Version =>] Ada_05]]);
3471
3472 pragma Obsolescent (
3473   [Entity  =>] NAME
3474 [,[Message =>] static_string_EXPRESSION
3475 [,[Version =>] Ada_05]] );
3476 @end smallexample
3477
3478 @noindent
3479 This pragma can occur immediately following a declaration of an entity,
3480 including the case of a record component. If no Entity argument is present,
3481 then this declaration is the one to which the pragma applies. If an Entity
3482 parameter is present, it must either match the name of the entity in this
3483 declaration, or alternatively, the pragma can immediately follow an enumeration
3484 type declaration, where the Entity argument names one of the enumeration
3485 literals.
3486
3487 This pragma is used to indicate that the named entity
3488 is considered obsolescent and should not be used. Typically this is
3489 used when an API must be modified by eventually removing or modifying
3490 existing subprograms or other entities. The pragma can be used at an
3491 intermediate stage when the entity is still present, but will be
3492 removed later.
3493
3494 The effect of this pragma is to output a warning message on a reference to
3495 an entity thus marked that the subprogram is obsolescent if the appropriate
3496 warning option in the compiler is activated. If the Message parameter is
3497 present, then a second warning message is given containing this text. In
3498 addition, a reference to the eneity is considered to be a violation of pragma
3499 Restrictions (No_Obsolescent_Features).
3500
3501 This pragma can also be used as a program unit pragma for a package,
3502 in which case the entity name is the name of the package, and the
3503 pragma indicates that the entire package is considered
3504 obsolescent. In this case a client @code{with}'ing such a package
3505 violates the restriction, and the @code{with} statement is
3506 flagged with warnings if the warning option is set.
3507
3508 If the Version parameter is present (which must be exactly
3509 the identifier Ada_05, no other argument is allowed), then the
3510 indication of obsolescence applies only when compiling in Ada 2005
3511 mode. This is primarily intended for dealing with the situations
3512 in the predefined library where subprograms or packages
3513 have become defined as obsolescent in Ada 2005
3514 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3515
3516 The following examples show typical uses of this pragma:
3517
3518 @smallexample @c ada
3519 package p is
3520    pragma Obsolescent (p, Message => "use pp instead of p");
3521 end p;
3522
3523 package q is
3524    procedure q2;
3525    pragma Obsolescent ("use q2new instead");
3526
3527    type R is new integer;
3528    pragma Obsolescent
3529      (Entity  => R,
3530       Message => "use RR in Ada 2005",
3531       Version => Ada_05);
3532
3533    type M is record
3534       F1 : Integer;
3535       F2 : Integer;
3536       pragma Obsolescent;
3537       F3 : Integer;
3538    end record;
3539
3540    type E is (a, bc, 'd', quack);
3541    pragma Obsolescent (Entity => bc)
3542    pragma Obsolescent (Entity => 'd')
3543
3544    function "+"
3545      (a, b : character) return character;
3546    pragma Obsolescent (Entity => "+");
3547 end;
3548 @end smallexample
3549
3550 @noindent
3551 Note that, as for all pragmas, if you use a pragma argument identifier,
3552 then all subsequent parameters must also use a pragma argument identifier.
3553 So if you specify "Entity =>" for the Entity argument, and a Message
3554 argument is present, it must be preceded by "Message =>".
3555
3556 @node Pragma Optimize_Alignment
3557 @unnumberedsec Pragma Optimize_Alignment
3558 @findex Optimize_Alignment
3559 @cindex Alignment, default settings
3560 @noindent
3561 Syntax:
3562
3563 @smallexample @c ada
3564 pragma Optimize_Alignment (TIME | SPACE | OFF);
3565 @end smallexample
3566
3567 @noindent
3568 This is a configuration pragma which affects the choice of default alignments
3569 for types where no alignment is explicitly specified. There is a time/space
3570 trade-off in the selection of these values. Large alignments result in more
3571 efficient code, at the expense of larger data space, since sizes have to be
3572 increased to match these alignments. Smaller alignments save space, but the
3573 access code is slower. The normal choice of default alignments (which is what
3574 you get if you do not use this pragma, or if you use an argument of OFF),
3575 tries to balance these two requirements.
3576
3577 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3578 First any packed record is given an alignment of 1. Second, if a size is given
3579 for the type, then the alignment is chosen to avoid increasing this size. For
3580 example, consider:
3581
3582 @smallexample @c ada
3583    type R is record
3584       X : Integer;
3585       Y : Character;
3586    end record;
3587
3588    for R'Size use 5*8;
3589 @end smallexample
3590
3591 @noindent
3592 In the default mode, this type gets an alignment of 4, so that access to the
3593 Integer field X are efficient. But this means that objects of the type end up
3594 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3595 allowed to be bigger than the size of the type, but it can waste space if for
3596 example fields of type R appear in an enclosing record. If the above type is
3597 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3598
3599 Specifying TIME causes larger default alignments to be chosen in the case of
3600 small types with sizes that are not a power of 2. For example, consider:
3601
3602 @smallexample @c ada
3603    type R is record
3604       A : Character;
3605       B : Character;
3606       C : Boolean;
3607    end record;
3608
3609    pragma Pack (R);
3610    for R'Size use 17;
3611 @end smallexample
3612
3613 @noindent
3614 The default alignment for this record is normally 1, but if this type is
3615 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3616 to 4, which wastes space for objects of the type, since they are now 4 bytes
3617 long, but results in more efficient access when the whole record is referenced.
3618
3619 As noted above, this is a configuration pragma, and there is a requirement
3620 that all units in a partition be compiled with a consistent setting of the
3621 optimization setting. This would normally be achieved by use of a configuration
3622 pragma file containing the appropriate setting. The exception to this rule is
3623 that units with an explicit configuration pragma in the same file as the source
3624 unit are excluded from the consistency check, as are all predefined units. The
3625 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3626 pragma appears at the start of the file.
3627
3628 @node Pragma Passive
3629 @unnumberedsec Pragma Passive
3630 @findex Passive
3631 @noindent
3632 Syntax:
3633
3634 @smallexample @c ada
3635 pragma Passive [(Semaphore | No)];
3636 @end smallexample
3637
3638 @noindent
3639 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3640 compatibility with DEC Ada 83 implementations, where it is used within a
3641 task definition to request that a task be made passive.  If the argument
3642 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3643 treats the pragma as an assertion that the containing task is passive
3644 and that optimization of context switch with this task is permitted and
3645 desired.  If the argument @code{No} is present, the task must not be
3646 optimized.  GNAT does not attempt to optimize any tasks in this manner
3647 (since protected objects are available in place of passive tasks).
3648
3649 @node Pragma Persistent_BSS
3650 @unnumberedsec Pragma Persistent_BSS
3651 @findex Persistent_BSS
3652 @noindent
3653 Syntax:
3654
3655 @smallexample @c ada
3656 pragma Persistent_BSS [(LOCAL_NAME)]
3657 @end smallexample
3658
3659 @noindent
3660 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3661 section. On some targets the linker and loader provide for special
3662 treatment of this section, allowing a program to be reloaded without
3663 affecting the contents of this data (hence the name persistent).
3664
3665 There are two forms of usage. If an argument is given, it must be the
3666 local name of a library level object, with no explicit initialization
3667 and whose type is potentially persistent. If no argument is given, then
3668 the pragma is a configuration pragma, and applies to all library level
3669 objects with no explicit initialization of potentially persistent types.
3670
3671 A potentially persistent type is a scalar type, or a non-tagged,
3672 non-discriminated record, all of whose components have no explicit
3673 initialization and are themselves of a potentially persistent type,
3674 or an array, all of whose constraints are static, and whose component
3675 type is potentially persistent.
3676
3677 If this pragma is used on a target where this feature is not supported,
3678 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3679
3680 @node Pragma Polling
3681 @unnumberedsec Pragma Polling
3682 @findex Polling
3683 @noindent
3684 Syntax:
3685
3686 @smallexample @c ada
3687 pragma Polling (ON | OFF);
3688 @end smallexample
3689
3690 @noindent
3691 This pragma controls the generation of polling code.  This is normally off.
3692 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3693 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3694 runtime library, and can be found in file @file{a-excpol.adb}.
3695
3696 Pragma @code{Polling} can appear as a configuration pragma (for example it
3697 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3698 can be used in the statement or declaration sequence to control polling
3699 more locally.
3700
3701 A call to the polling routine is generated at the start of every loop and
3702 at the start of every subprogram call.  This guarantees that the @code{Poll}
3703 routine is called frequently, and places an upper bound (determined by
3704 the complexity of the code) on the period between two @code{Poll} calls.
3705
3706 The primary purpose of the polling interface is to enable asynchronous
3707 aborts on targets that cannot otherwise support it (for example Windows
3708 NT), but it may be used for any other purpose requiring periodic polling.
3709 The standard version is null, and can be replaced by a user program.  This
3710 will require re-compilation of the @code{Ada.Exceptions} package that can
3711 be found in files @file{a-except.ads} and @file{a-except.adb}.
3712
3713 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3714 distribution) is used to enable the asynchronous abort capability on
3715 targets that do not normally support the capability.  The version of
3716 @code{Poll} in this file makes a call to the appropriate runtime routine
3717 to test for an abort condition.
3718
3719 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3720 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3721 details.
3722
3723 @node Pragma Postcondition
3724 @unnumberedsec Pragma Postcondition
3725 @cindex Postconditions
3726 @cindex Checks, postconditions
3727 @findex Postconditions
3728 @noindent
3729 Syntax:
3730
3731 @smallexample @c ada
3732 pragma Postcondition (
3733    [Check   =>] Boolean_Expression
3734  [,[Message =>] String_Expression]);
3735 @end smallexample
3736
3737 @noindent
3738 The @code{Postcondition} pragma allows specification of automatic
3739 postcondition checks for subprograms. These checks are similar to
3740 assertions, but are automatically inserted just prior to the return
3741 statements of the subprogram with which they are associated (including
3742 implicit returns at the end of procedure bodies and associated
3743 exception handlers).
3744
3745 In addition, the boolean expression which is the condition which
3746 must be true may contain references to function'Result in the case
3747 of a function to refer to the returned value.
3748
3749 @code{Postcondition} pragmas may appear either immediate following the
3750 (separate) declaration of a subprogram, or at the start of the
3751 declarations of a subprogram body. Only other pragmas may intervene
3752 (that is appear between the subprogram declaration and its
3753 postconditions, or appear before the postcondition in the
3754 declaration sequence in a subprogram body). In the case of a
3755 postcondition appearing after a subprogram declaration, the
3756 formal arguments of the subprogram are visible, and can be
3757 referenced in the postcondition expressions.
3758
3759 The postconditions are collected and automatically tested just
3760 before any return (implicit or explicit) in the subprogram body.
3761 A postcondition is only recognized if postconditions are active
3762 at the time the pragma is encountered. The compiler switch @option{gnata}
3763 turns on all postconditions by default, and pragma @code{Check_Policy}
3764 with an identifier of @code{Postcondition} can also be used to
3765 control whether postconditions are active.
3766
3767 The general approach is that postconditions are placed in the spec
3768 if they represent functional aspects which make sense to the client.
3769 For example we might have:
3770
3771 @smallexample @c ada
3772    function Direction return Integer;
3773    pragma Postcondition
3774     (Direction'Result = +1
3775        or else
3776      Direction'Result = -1);
3777 @end smallexample
3778
3779 @noindent
3780 which serves to document that the result must be +1 or -1, and
3781 will test that this is the case at run time if postcondition
3782 checking is active.
3783
3784 Postconditions within the subprogram body can be used to
3785 check that some internal aspect of the implementation,
3786 not visible to the client, is operating as expected.
3787 For instance if a square root routine keeps an internal
3788 counter of the number of times it is called, then we
3789 might have the following postcondition:
3790
3791 @smallexample @c ada
3792    Sqrt_Calls : Natural := 0;
3793
3794    function Sqrt (Arg : Float) return Float is
3795      pragma Postcondition
3796        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3797      ...
3798    end Sqrt
3799 @end smallexample
3800
3801 @noindent
3802 As this example, shows, the use of the @code{Old} attribute
3803 is often useful in postconditions to refer to the state on
3804 entry to the subprogram.
3805
3806 Note that postconditions are only checked on normal returns
3807 from the subprogram. If an abnormal return results from
3808 raising an exception, then the postconditions are not checked.
3809
3810 If a postcondition fails, then the exception
3811 @code{System.Assertions.Assert_Failure} is raised. If
3812 a message argument was supplied, then the given string
3813 will be used as the exception message. If no message
3814 argument was supplied, then the default message has
3815 the form "Postcondition failed at file:line". The
3816 exception is raised in the context of the subprogram
3817 body, so it is possible to catch postcondition failures
3818 within the subprogram body itself.
3819
3820 Within a package spec, normal visibility rules
3821 in Ada would prevent forward references within a
3822 postcondition pragma to functions defined later in
3823 the same package. This would introduce undesirable
3824 ordering constraints. To avoid this problem, all
3825 postcondition pragmas are analyzed at the end of
3826 the package spec, allowing forward references.
3827
3828 The following example shows that this even allows
3829 mutually recursive postconditions as in:
3830
3831 @smallexample @c ada
3832 package Parity_Functions is
3833    function Odd  (X : Natural) return Boolean;
3834    pragma Postcondition
3835      (Odd'Result =
3836         (x = 1
3837           or else
3838         (x /= 0 and then Even (X - 1))));
3839
3840    function Even (X : Natural) return Boolean;
3841    pragma Postcondition
3842      (Even'Result =
3843         (x = 0
3844           or else
3845         (x /= 1 and then Odd (X - 1))));
3846
3847 end Parity_Functions;
3848 @end smallexample
3849
3850 @noindent
3851 There are no restrictions on the complexity or form of
3852 conditions used within @code{Postcondition} pragmas.
3853 The following example shows that it is even possible
3854 to verify performance behavior.
3855
3856 @smallexample @c ada
3857 package Sort is
3858
3859    Performance : constant Float;
3860    --  Performance constant set by implementation
3861    --  to match target architecture behavior.
3862
3863    procedure Treesort (Arg : String);
3864    --  Sorts characters of argument using N*logN sort
3865    pragma Postcondition
3866      (Float (Clock - Clock'Old) <=
3867         Float (Arg'Length) *
3868         log (Float (Arg'Length)) *
3869         Performance);
3870 end Sort;
3871 @end smallexample
3872
3873 @noindent
3874 Note: postcondition pragmas associated with subprograms that are
3875 marked as Inline_Always, or those marked as Inline with front-end
3876 inlining (-gnatN option set) are accepted and legality-checked
3877 by the compiler, but are ignored at run-time even if postcondition
3878 checking is enabled.
3879
3880 @node Pragma Precondition
3881 @unnumberedsec Pragma Precondition
3882 @cindex Preconditions
3883 @cindex Checks, preconditions
3884 @findex Preconditions
3885 @noindent
3886 Syntax:
3887
3888 @smallexample @c ada
3889 pragma Precondition (
3890    [Check   =>] Boolean_Expression
3891  [,[Message =>] String_Expression]);
3892 @end smallexample
3893
3894 @noindent
3895 The @code{Precondition} pragma is similar to @code{Postcondition}
3896 except that the corresponding checks take place immediately upon
3897 entry to the subprogram, and if a precondition fails, the exception
3898 is raised in the context of the caller, and the attribute 'Result
3899 cannot be used within the precondition expression.
3900
3901 Otherwise, the placement and visibility rules are identical to those
3902 described for postconditions. The following is an example of use
3903 within a package spec:
3904
3905 @smallexample @c ada
3906 package Math_Functions is
3907    ...
3908    function Sqrt (Arg : Float) return Float;
3909    pragma Precondition (Arg >= 0.0)
3910    ...
3911 end Math_Functions;
3912 @end smallexample
3913
3914 @noindent
3915 @code{Precondition} pragmas may appear either immediate following the
3916 (separate) declaration of a subprogram, or at the start of the
3917 declarations of a subprogram body. Only other pragmas may intervene
3918 (that is appear between the subprogram declaration and its
3919 postconditions, or appear before the postcondition in the
3920 declaration sequence in a subprogram body).
3921
3922 Note: postcondition pragmas associated with subprograms that are
3923 marked as Inline_Always, or those marked as Inline with front-end
3924 inlining (-gnatN option set) are accepted and legality-checked
3925 by the compiler, but are ignored at run-time even if postcondition
3926 checking is enabled.
3927
3928
3929
3930 @node Pragma Profile (Ravenscar)
3931 @unnumberedsec Pragma Profile (Ravenscar)
3932 @findex Ravenscar
3933 @noindent
3934 Syntax:
3935
3936 @smallexample @c ada
3937 pragma Profile (Ravenscar);
3938 @end smallexample
3939
3940 @noindent
3941 A configuration pragma that establishes the following set of configuration
3942 pragmas:
3943
3944 @table @code
3945 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3946 [RM D.2.2] Tasks are dispatched following a preemptive
3947 priority-ordered scheduling policy.
3948
3949 @item Locking_Policy (Ceiling_Locking)
3950 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3951 the ceiling priority of the corresponding protected object.
3952 @c
3953 @c @item Detect_Blocking
3954 @c This pragma forces the detection of potentially blocking operations within a
3955 @c protected operation, and to raise Program_Error if that happens.
3956 @end table
3957 @noindent
3958
3959 plus the following set of restrictions:
3960
3961 @table @code
3962 @item Max_Entry_Queue_Length = 1
3963 Defines the maximum number of calls that are queued on a (protected) entry.
3964 Note that this restrictions is checked at run time. Violation of this
3965 restriction results in the raising of Program_Error exception at the point of
3966 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3967 always 1 and hence no task can be queued on a protected entry.
3968
3969 @item Max_Protected_Entries = 1
3970 [RM D.7] Specifies the maximum number of entries per protected type. The
3971 bounds of every entry family of a protected unit shall be static, or shall be
3972 defined by a discriminant of a subtype whose corresponding bound is static.
3973 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3974
3975 @item Max_Task_Entries = 0
3976 [RM D.7] Specifies the maximum number of entries
3977 per task.  The bounds of every entry family
3978 of a task unit shall be static, or shall be
3979 defined by a discriminant of a subtype whose
3980 corresponding bound is static.  A value of zero
3981 indicates that no rendezvous are possible.  For
3982 the Profile (Ravenscar), the value of Max_Task_Entries is always
3983 0 (zero).
3984
3985 @item No_Abort_Statements
3986 [RM D.7] There are no abort_statements, and there are
3987 no calls to Task_Identification.Abort_Task.
3988
3989 @item No_Asynchronous_Control
3990 There are no semantic dependences on the package
3991 Asynchronous_Task_Control.
3992
3993 @item No_Calendar
3994 There are no semantic dependencies on the package Ada.Calendar.
3995
3996 @item No_Dynamic_Attachment
3997 There is no call to any of the operations defined in package Ada.Interrupts
3998 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3999 Detach_Handler, and Reference).
4000
4001 @item No_Dynamic_Priorities
4002 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4003
4004 @item No_Implicit_Heap_Allocations
4005 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4006
4007 @item No_Local_Protected_Objects
4008 Protected objects and access types that designate
4009 such objects shall be declared only at library level.
4010
4011 @item No_Local_Timing_Events
4012 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4013 declared at the library level.
4014
4015 @item No_Protected_Type_Allocators
4016 There are no allocators for protected types or
4017 types containing protected subcomponents.
4018
4019 @item No_Relative_Delay
4020 There are no delay_relative statements.
4021
4022 @item No_Requeue_Statements
4023 Requeue statements are not allowed.
4024
4025 @item No_Select_Statements
4026 There are no select_statements.
4027
4028 @item No_Specific_Termination_Handlers
4029 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4030 or to Ada.Task_Termination.Specific_Handler.
4031
4032 @item No_Task_Allocators
4033 [RM D.7] There are no allocators for task types
4034 or types containing task subcomponents.
4035
4036 @item No_Task_Attributes_Package
4037 There are no semantic dependencies on the Ada.Task_Attributes package.
4038
4039 @item No_Task_Hierarchy
4040 [RM D.7] All (non-environment) tasks depend
4041 directly on the environment task of the partition.
4042
4043 @item No_Task_Termination
4044 Tasks which terminate are erroneous.
4045
4046 @item No_Unchecked_Conversion
4047 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4048
4049 @item No_Unchecked_Deallocation
4050 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4051
4052 @item Simple_Barriers
4053 Entry barrier condition expressions shall be either static
4054 boolean expressions or boolean objects which are declared in
4055 the protected type which contains the entry.
4056 @end table
4057
4058 @noindent
4059 This set of configuration pragmas and restrictions correspond to the
4060 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4061 published by the @cite{International Real-Time Ada Workshop}, 1997,
4062 and whose most recent description is available at
4063 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4064
4065 The original definition of the profile was revised at subsequent IRTAW
4066 meetings. It has been included in the ISO
4067 @cite{Guide for the Use of the Ada Programming Language in High
4068 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4069 the next revision of the standard. The formal definition given by
4070 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4071 AI-305) available at
4072 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4073 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4074 respectively.
4075
4076 The above set is a superset of the restrictions provided by pragma
4077 @code{Profile (Restricted)}, it includes six additional restrictions
4078 (@code{Simple_Barriers}, @code{No_Select_Statements},
4079 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4080 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4081 that pragma @code{Profile (Ravenscar)}, like the pragma
4082 @code{Profile (Restricted)},
4083 automatically causes the use of a simplified,
4084 more efficient version of the tasking run-time system.
4085
4086 @node Pragma Profile (Restricted)
4087 @unnumberedsec Pragma Profile (Restricted)
4088 @findex Restricted Run Time
4089 @noindent
4090 Syntax:
4091
4092 @smallexample @c ada
4093 pragma Profile (Restricted);
4094 @end smallexample
4095
4096 @noindent
4097 A configuration pragma that establishes the following set of restrictions:
4098
4099 @itemize @bullet
4100 @item No_Abort_Statements
4101 @item No_Entry_Queue
4102 @item No_Task_Hierarchy
4103 @item No_Task_Allocators
4104 @item No_Dynamic_Priorities
4105 @item No_Terminate_Alternatives
4106 @item No_Dynamic_Attachment
4107 @item No_Protected_Type_Allocators
4108 @item No_Local_Protected_Objects
4109 @item No_Requeue_Statements
4110 @item No_Task_Attributes_Package
4111 @item Max_Asynchronous_Select_Nesting =  0
4112 @item Max_Task_Entries =  0
4113 @item Max_Protected_Entries = 1
4114 @item Max_Select_Alternatives = 0
4115 @end itemize
4116
4117 @noindent
4118 This set of restrictions causes the automatic selection of a simplified
4119 version of the run time that provides improved performance for the
4120 limited set of tasking functionality permitted by this set of restrictions.
4121
4122 @node Pragma Psect_Object
4123 @unnumberedsec Pragma Psect_Object
4124 @findex Psect_Object
4125 @noindent
4126 Syntax:
4127
4128 @smallexample @c ada
4129 pragma Psect_Object (
4130      [Internal =>] LOCAL_NAME,
4131   [, [External =>] EXTERNAL_SYMBOL]
4132   [, [Size     =>] EXTERNAL_SYMBOL]);
4133
4134 EXTERNAL_SYMBOL ::=
4135   IDENTIFIER
4136 | static_string_EXPRESSION
4137 @end smallexample
4138
4139 @noindent
4140 This pragma is identical in effect to pragma @code{Common_Object}.
4141
4142 @node Pragma Pure_Function
4143 @unnumberedsec Pragma Pure_Function
4144 @findex Pure_Function
4145 @noindent
4146 Syntax:
4147
4148 @smallexample @c ada
4149 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4150 @end smallexample
4151
4152 @noindent
4153 This pragma appears in the same declarative part as a function
4154 declaration (or a set of function declarations if more than one
4155 overloaded declaration exists, in which case the pragma applies
4156 to all entities).  It specifies that the function @code{Entity} is
4157 to be considered pure for the purposes of code generation.  This means
4158 that the compiler can assume that there are no side effects, and
4159 in particular that two calls with identical arguments produce the
4160 same result.  It also means that the function can be used in an
4161 address clause.
4162
4163 Note that, quite deliberately, there are no static checks to try
4164 to ensure that this promise is met, so @code{Pure_Function} can be used
4165 with functions that are conceptually pure, even if they do modify
4166 global variables.  For example, a square root function that is
4167 instrumented to count the number of times it is called is still
4168 conceptually pure, and can still be optimized, even though it
4169 modifies a global variable (the count).  Memo functions are another
4170 example (where a table of previous calls is kept and consulted to
4171 avoid re-computation).
4172
4173 @findex Pure
4174 Note: Most functions in a @code{Pure} package are automatically pure, and
4175 there is no need to use pragma @code{Pure_Function} for such functions.  One
4176 exception is any function that has at least one formal of type
4177 @code{System.Address} or a type derived from it.  Such functions are not
4178 considered pure by default, since the compiler assumes that the
4179 @code{Address} parameter may be functioning as a pointer and that the
4180 referenced data may change even if the address value does not.
4181 Similarly, imported functions are not considered to be pure by default,
4182 since there is no way of checking that they are in fact pure.  The use
4183 of pragma @code{Pure_Function} for such a function will override these default
4184 assumption, and cause the compiler to treat a designated subprogram as pure
4185 in these cases.
4186
4187 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4188 applies to the underlying renamed function.  This can be used to
4189 disambiguate cases of overloading where some but not all functions
4190 in a set of overloaded functions are to be designated as pure.
4191
4192 If pragma @code{Pure_Function} is applied to a library level function, the
4193 function is also considered pure from an optimization point of view, but the
4194 unit is not a Pure unit in the categorization sense. So for example, a function
4195 thus marked is free to @code{with} non-pure units.
4196
4197 @node Pragma Restriction_Warnings
4198 @unnumberedsec Pragma Restriction_Warnings
4199 @findex Restriction_Warnings
4200 @noindent
4201 Syntax:
4202
4203 @smallexample @c ada
4204 pragma Restriction_Warnings
4205   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4206 @end smallexample
4207
4208 @noindent
4209 This pragma allows a series of restriction identifiers to be
4210 specified (the list of allowed identifiers is the same as for
4211 pragma @code{Restrictions}). For each of these identifiers
4212 the compiler checks for violations of the restriction, but
4213 generates a warning message rather than an error message
4214 if the restriction is violated.
4215
4216 @node Pragma Shared
4217 @unnumberedsec Pragma Shared
4218 @findex Shared
4219
4220 @noindent
4221 This pragma is provided for compatibility with Ada 83. The syntax and
4222 semantics are identical to pragma Atomic.
4223
4224 @node Pragma Source_File_Name
4225 @unnumberedsec Pragma Source_File_Name
4226 @findex Source_File_Name
4227 @noindent
4228 Syntax:
4229
4230 @smallexample @c ada
4231 pragma Source_File_Name (
4232   [Unit_Name   =>] unit_NAME,
4233   Spec_File_Name =>  STRING_LITERAL);
4234
4235 pragma Source_File_Name (
4236   [Unit_Name   =>] unit_NAME,
4237   Body_File_Name =>  STRING_LITERAL);
4238 @end smallexample
4239
4240 @noindent
4241 Use this to override the normal naming convention.  It is a configuration
4242 pragma, and so has the usual applicability of configuration pragmas
4243 (i.e.@: it applies to either an entire partition, or to all units in a
4244 compilation, or to a single unit, depending on how it is used.
4245 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4246 the second argument is required, and indicates whether this is the file
4247 name for the spec or for the body.
4248
4249 Another form of the @code{Source_File_Name} pragma allows
4250 the specification of patterns defining alternative file naming schemes
4251 to apply to all files.
4252
4253 @smallexample @c ada
4254 pragma Source_File_Name
4255   (  [Spec_File_Name  =>] STRING_LITERAL
4256    [,[Casing          =>] CASING_SPEC]
4257    [,[Dot_Replacement =>] STRING_LITERAL]);
4258
4259 pragma Source_File_Name
4260   (  [Body_File_Name  =>] STRING_LITERAL
4261    [,[Casing          =>] CASING_SPEC]
4262    [,[Dot_Replacement =>] STRING_LITERAL]);
4263
4264 pragma Source_File_Name
4265   (  [Subunit_File_Name =>] STRING_LITERAL
4266    [,[Casing            =>] CASING_SPEC]
4267    [,[Dot_Replacement   =>] STRING_LITERAL]);
4268
4269 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4270 @end smallexample
4271
4272 @noindent
4273 The first argument is a pattern that contains a single asterisk indicating
4274 the point at which the unit name is to be inserted in the pattern string
4275 to form the file name.  The second argument is optional.  If present it
4276 specifies the casing of the unit name in the resulting file name string.
4277 The default is lower case.  Finally the third argument allows for systematic
4278 replacement of any dots in the unit name by the specified string literal.
4279
4280 A pragma Source_File_Name cannot appear after a
4281 @ref{Pragma Source_File_Name_Project}.
4282
4283 For more details on the use of the @code{Source_File_Name} pragma,
4284 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4285 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4286 User's Guide}.
4287
4288 @node Pragma Source_File_Name_Project
4289 @unnumberedsec Pragma Source_File_Name_Project
4290 @findex Source_File_Name_Project
4291 @noindent
4292
4293 This pragma has the same syntax and semantics as pragma Source_File_Name.
4294 It is only allowed as a stand alone configuration pragma.
4295 It cannot appear after a @ref{Pragma Source_File_Name}, and
4296 most importantly, once pragma Source_File_Name_Project appears,
4297 no further Source_File_Name pragmas are allowed.
4298
4299 The intention is that Source_File_Name_Project pragmas are always
4300 generated by the Project Manager in a manner consistent with the naming
4301 specified in a project file, and when naming is controlled in this manner,
4302 it is not permissible to attempt to modify this naming scheme using
4303 Source_File_Name pragmas (which would not be known to the project manager).
4304
4305 @node Pragma Source_Reference
4306 @unnumberedsec Pragma Source_Reference
4307 @findex Source_Reference
4308 @noindent
4309 Syntax:
4310
4311 @smallexample @c ada
4312 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4313 @end smallexample
4314
4315 @noindent
4316 This pragma must appear as the first line of a source file.
4317 @var{integer_literal} is the logical line number of the line following
4318 the pragma line (for use in error messages and debugging
4319 information).  @var{string_literal} is a static string constant that
4320 specifies the file name to be used in error messages and debugging
4321 information.  This is most notably used for the output of @code{gnatchop}
4322 with the @option{-r} switch, to make sure that the original unchopped
4323 source file is the one referred to.
4324
4325 The second argument must be a string literal, it cannot be a static
4326 string expression other than a string literal.  This is because its value
4327 is needed for error messages issued by all phases of the compiler.
4328
4329 @node Pragma Stream_Convert
4330 @unnumberedsec Pragma Stream_Convert
4331 @findex Stream_Convert
4332 @noindent
4333 Syntax:
4334
4335 @smallexample @c ada
4336 pragma Stream_Convert (
4337   [Entity =>] type_LOCAL_NAME,
4338   [Read   =>] function_NAME,
4339   [Write  =>] function_NAME);
4340 @end smallexample
4341
4342 @noindent
4343 This pragma provides an efficient way of providing stream functions for
4344 types defined in packages.  Not only is it simpler to use than declaring
4345 the necessary functions with attribute representation clauses, but more
4346 significantly, it allows the declaration to made in such a way that the
4347 stream packages are not loaded unless they are needed.  The use of
4348 the Stream_Convert pragma adds no overhead at all, unless the stream
4349 attributes are actually used on the designated type.
4350
4351 The first argument specifies the type for which stream functions are
4352 provided.  The second parameter provides a function used to read values
4353 of this type.  It must name a function whose argument type may be any
4354 subtype, and whose returned type must be the type given as the first
4355 argument to the pragma.
4356
4357 The meaning of the @var{Read}
4358 parameter is that if a stream attribute directly
4359 or indirectly specifies reading of the type given as the first parameter,
4360 then a value of the type given as the argument to the Read function is
4361 read from the stream, and then the Read function is used to convert this
4362 to the required target type.
4363
4364 Similarly the @var{Write} parameter specifies how to treat write attributes
4365 that directly or indirectly apply to the type given as the first parameter.
4366 It must have an input parameter of the type specified by the first parameter,
4367 and the return type must be the same as the input type of the Read function.
4368 The effect is to first call the Write function to convert to the given stream
4369 type, and then write the result type to the stream.
4370
4371 The Read and Write functions must not be overloaded subprograms.  If necessary
4372 renamings can be supplied to meet this requirement.
4373 The usage of this attribute is best illustrated by a simple example, taken
4374 from the GNAT implementation of package Ada.Strings.Unbounded:
4375
4376 @smallexample @c ada
4377 function To_Unbounded (S : String)
4378            return Unbounded_String
4379   renames To_Unbounded_String;
4380
4381 pragma Stream_Convert
4382   (Unbounded_String, To_Unbounded, To_String);
4383 @end smallexample
4384
4385 @noindent
4386 The specifications of the referenced functions, as given in the Ada
4387 Reference Manual are:
4388
4389 @smallexample @c ada
4390 function To_Unbounded_String (Source : String)
4391   return Unbounded_String;
4392
4393 function To_String (Source : Unbounded_String)
4394   return String;
4395 @end smallexample
4396
4397 @noindent
4398 The effect is that if the value of an unbounded string is written to a
4399 stream, then the representation of the item in the stream is in the same
4400 format used for @code{Standard.String}, and this same representation is
4401 expected when a value of this type is read from the stream.
4402
4403 @node Pragma Style_Checks
4404 @unnumberedsec Pragma Style_Checks
4405 @findex Style_Checks
4406 @noindent
4407 Syntax:
4408
4409 @smallexample @c ada
4410 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4411                      On | Off [, LOCAL_NAME]);
4412 @end smallexample
4413
4414 @noindent
4415 This pragma is used in conjunction with compiler switches to control the
4416 built in style checking provided by GNAT@.  The compiler switches, if set,
4417 provide an initial setting for the switches, and this pragma may be used
4418 to modify these settings, or the settings may be provided entirely by
4419 the use of the pragma.  This pragma can be used anywhere that a pragma
4420 is legal, including use as a configuration pragma (including use in
4421 the @file{gnat.adc} file).
4422
4423 The form with a string literal specifies which style options are to be
4424 activated.  These are additive, so they apply in addition to any previously
4425 set style check options.  The codes for the options are the same as those
4426 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4427 For example the following two methods can be used to enable
4428 layout checking:
4429
4430 @itemize @bullet
4431 @item
4432 @smallexample @c ada
4433 pragma Style_Checks ("l");
4434 @end smallexample
4435
4436 @item
4437 @smallexample
4438 gcc -c -gnatyl @dots{}
4439 @end smallexample
4440 @end itemize
4441
4442 @noindent
4443 The form ALL_CHECKS activates all standard checks (its use is equivalent
4444 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4445 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4446 @value{EDITION} User's Guide}, for details.
4447
4448 The forms with @code{Off} and @code{On}
4449 can be used to temporarily disable style checks
4450 as shown in the following example:
4451
4452 @smallexample @c ada
4453 @iftex
4454 @leftskip=0cm
4455 @end iftex
4456 pragma Style_Checks ("k"); -- requires keywords in lower case
4457 pragma Style_Checks (Off); -- turn off style checks
4458 NULL;                      -- this will not generate an error message
4459 pragma Style_Checks (On);  -- turn style checks back on
4460 NULL;                      -- this will generate an error message
4461 @end smallexample
4462
4463 @noindent
4464 Finally the two argument form is allowed only if the first argument is
4465 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4466 for the specified entity, as shown in the following example:
4467
4468 @smallexample @c ada
4469 @iftex
4470 @leftskip=0cm
4471 @end iftex
4472 pragma Style_Checks ("r"); -- require consistency of identifier casing
4473 Arg : Integer;
4474 Rf1 : Integer := ARG;      -- incorrect, wrong case
4475 pragma Style_Checks (Off, Arg);
4476 Rf2 : Integer := ARG;      -- OK, no error
4477 @end smallexample
4478
4479 @node Pragma Subtitle
4480 @unnumberedsec Pragma Subtitle
4481 @findex Subtitle
4482 @noindent
4483 Syntax:
4484
4485 @smallexample @c ada
4486 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4487 @end smallexample
4488
4489 @noindent
4490 This pragma is recognized for compatibility with other Ada compilers
4491 but is ignored by GNAT@.
4492
4493 @node Pragma Suppress
4494 @unnumberedsec Pragma Suppress
4495 @findex Suppress
4496 @noindent
4497 Syntax:
4498
4499 @smallexample @c ada
4500 pragma Suppress (Identifier [, [On =>] Name]);
4501 @end smallexample
4502
4503 @noindent
4504 This is a standard pragma, and supports all the check names required in
4505 the RM. It is included here because GNAT recognizes one additional check
4506 name: @code{Alignment_Check} which can be used to suppress alignment checks
4507 on addresses used in address clauses. Such checks can also be suppressed
4508 by suppressing range checks, but the specific use of @code{Alignment_Check}
4509 allows suppression of alignment checks without suppressing other range checks.
4510
4511 Note that pragma Suppress gives the compiler permission to omit
4512 checks, but does not require the compiler to omit checks. The compiler
4513 will generate checks if they are essentially free, even when they are
4514 suppressed. In particular, if the compiler can prove that a certain
4515 check will necessarily fail, it will generate code to do an
4516 unconditional ``raise'', even if checks are suppressed. The compiler
4517 warns in this case.
4518
4519 Of course, run-time checks are omitted whenever the compiler can prove
4520 that they will not fail, whether or not checks are suppressed.
4521
4522 @node Pragma Suppress_All
4523 @unnumberedsec Pragma Suppress_All
4524 @findex Suppress_All
4525 @noindent
4526 Syntax:
4527
4528 @smallexample @c ada
4529 pragma Suppress_All;
4530 @end smallexample
4531
4532 @noindent
4533 This pragma can only appear immediately following a compilation
4534 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4535 which it follows.  This pragma is implemented for compatibility with DEC
4536 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4537 configuration pragma is the preferred usage in GNAT@.
4538
4539 @node Pragma Suppress_Exception_Locations
4540 @unnumberedsec Pragma Suppress_Exception_Locations
4541 @findex Suppress_Exception_Locations
4542 @noindent
4543 Syntax:
4544
4545 @smallexample @c ada
4546 pragma Suppress_Exception_Locations;
4547 @end smallexample
4548
4549 @noindent
4550 In normal mode, a raise statement for an exception by default generates
4551 an exception message giving the file name and line number for the location
4552 of the raise. This is useful for debugging and logging purposes, but this
4553 entails extra space for the strings for the messages. The configuration
4554 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4555 generation of these strings, with the result that space is saved, but the
4556 exception message for such raises is null. This configuration pragma may
4557 appear in a global configuration pragma file, or in a specific unit as
4558 usual. It is not required that this pragma be used consistently within
4559 a partition, so it is fine to have some units within a partition compiled
4560 with this pragma and others compiled in normal mode without it.
4561
4562 @node Pragma Suppress_Initialization
4563 @unnumberedsec Pragma Suppress_Initialization
4564 @findex Suppress_Initialization
4565 @cindex Suppressing initialization
4566 @cindex Initialization, suppression of
4567 @noindent
4568 Syntax:
4569
4570 @smallexample @c ada
4571 pragma Suppress_Initialization ([Entity =>] type_Name);
4572 @end smallexample
4573
4574 @noindent
4575 This pragma suppresses any implicit or explicit initialization
4576 associated with the given type name for all variables of this type.
4577
4578 @node Pragma Task_Info
4579 @unnumberedsec Pragma Task_Info
4580 @findex Task_Info
4581 @noindent
4582 Syntax
4583
4584 @smallexample @c ada
4585 pragma Task_Info (EXPRESSION);
4586 @end smallexample
4587
4588 @noindent
4589 This pragma appears within a task definition (like pragma
4590 @code{Priority}) and applies to the task in which it appears.  The
4591 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4592 The @code{Task_Info} pragma provides system dependent control over
4593 aspects of tasking implementation, for example, the ability to map
4594 tasks to specific processors.  For details on the facilities available
4595 for the version of GNAT that you are using, see the documentation
4596 in the spec of package System.Task_Info in the runtime
4597 library.
4598
4599 @node Pragma Task_Name
4600 @unnumberedsec Pragma Task_Name
4601 @findex Task_Name
4602 @noindent
4603 Syntax
4604
4605 @smallexample @c ada
4606 pragma Task_Name (string_EXPRESSION);
4607 @end smallexample
4608
4609 @noindent
4610 This pragma appears within a task definition (like pragma
4611 @code{Priority}) and applies to the task in which it appears.  The
4612 argument must be of type String, and provides a name to be used for
4613 the task instance when the task is created.  Note that this expression
4614 is not required to be static, and in particular, it can contain
4615 references to task discriminants.  This facility can be used to
4616 provide different names for different tasks as they are created,
4617 as illustrated in the example below.
4618
4619 The task name is recorded internally in the run-time structures
4620 and is accessible to tools like the debugger.  In addition the
4621 routine @code{Ada.Task_Identification.Image} will return this
4622 string, with a unique task address appended.
4623
4624 @smallexample @c ada
4625 --  Example of the use of pragma Task_Name
4626
4627 with Ada.Task_Identification;
4628 use Ada.Task_Identification;
4629 with Text_IO; use Text_IO;
4630 procedure t3 is
4631
4632    type Astring is access String;
4633
4634    task type Task_Typ (Name : access String) is
4635       pragma Task_Name (Name.all);
4636    end Task_Typ;
4637
4638    task body Task_Typ is
4639       Nam : constant String := Image (Current_Task);
4640    begin
4641       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4642    end Task_Typ;
4643
4644    type Ptr_Task is access Task_Typ;
4645    Task_Var : Ptr_Task;
4646
4647 begin
4648    Task_Var :=
4649      new Task_Typ (new String'("This is task 1"));
4650    Task_Var :=
4651      new Task_Typ (new String'("This is task 2"));
4652 end;
4653 @end smallexample
4654
4655 @node Pragma Task_Storage
4656 @unnumberedsec Pragma Task_Storage
4657 @findex Task_Storage
4658 Syntax:
4659
4660 @smallexample @c ada
4661 pragma Task_Storage (
4662   [Task_Type =>] LOCAL_NAME,
4663   [Top_Guard =>] static_integer_EXPRESSION);
4664 @end smallexample
4665
4666 @noindent
4667 This pragma specifies the length of the guard area for tasks.  The guard
4668 area is an additional storage area allocated to a task.  A value of zero
4669 means that either no guard area is created or a minimal guard area is
4670 created, depending on the target.  This pragma can appear anywhere a
4671 @code{Storage_Size} attribute definition clause is allowed for a task
4672 type.
4673
4674 @node Pragma Thread_Local_Storage
4675 @unnumberedsec Pragma Thread_Local_Storage
4676 @findex Thread_Local_Storage
4677 @cindex Task specific storage
4678 @cindex TLS (Thread Local Storage)
4679 Syntax:
4680
4681 @smallexample @c ada
4682 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4683 @end smallexample
4684
4685 @noindent
4686 This pragma specifies that the specified entity, which must be
4687 a variable declared in a library level package, is to be marked as
4688 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4689 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4690 (and hence each Ada task) to see a distinct copy of the variable.
4691
4692 The variable may not have default initialization, and if there is
4693 an explicit initialization, it must be either @code{null} for an
4694 access variable, or a static expression for a scalar variable.
4695 This provides a low level mechanism similar to that provided by
4696 the @code{Ada.Task_Attributes} package, but much more efficient
4697 and is also useful in writing interface code that will interact
4698 with foreign threads.
4699
4700 If this pragma is used on a system where @code{TLS} is not supported,
4701 then an error message will be generated and the program will be rejected.
4702
4703 @node Pragma Time_Slice
4704 @unnumberedsec Pragma Time_Slice
4705 @findex Time_Slice
4706 @noindent
4707 Syntax:
4708
4709 @smallexample @c ada
4710 pragma Time_Slice (static_duration_EXPRESSION);
4711 @end smallexample
4712
4713 @noindent
4714 For implementations of GNAT on operating systems where it is possible
4715 to supply a time slice value, this pragma may be used for this purpose.
4716 It is ignored if it is used in a system that does not allow this control,
4717 or if it appears in other than the main program unit.
4718 @cindex OpenVMS
4719 Note that the effect of this pragma is identical to the effect of the
4720 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4721
4722 @node Pragma Title
4723 @unnumberedsec Pragma Title
4724 @findex Title
4725 @noindent
4726 Syntax:
4727
4728 @smallexample @c ada
4729 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4730
4731 TITLING_OPTION ::=
4732   [Title    =>] STRING_LITERAL,
4733 | [Subtitle =>] STRING_LITERAL
4734 @end smallexample
4735
4736 @noindent
4737 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4738 pragma used in DEC Ada 83 implementations to provide a title and/or
4739 subtitle for the program listing.  The program listing generated by GNAT
4740 does not have titles or subtitles.
4741
4742 Unlike other pragmas, the full flexibility of named notation is allowed
4743 for this pragma, i.e.@: the parameters may be given in any order if named
4744 notation is used, and named and positional notation can be mixed
4745 following the normal rules for procedure calls in Ada.
4746
4747 @node Pragma Unchecked_Union
4748 @unnumberedsec Pragma Unchecked_Union
4749 @cindex Unions in C
4750 @findex Unchecked_Union
4751 @noindent
4752 Syntax:
4753
4754 @smallexample @c ada
4755 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4756 @end smallexample
4757
4758 @noindent
4759 This pragma is used to specify a representation of a record type that is
4760 equivalent to a C union. It was introduced as a GNAT implementation defined
4761 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4762 pragma, making it language defined, and GNAT fully implements this extended
4763 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4764 details, consult the Ada 2005 Reference Manual, section B.3.3.
4765
4766 @node Pragma Unimplemented_Unit
4767 @unnumberedsec Pragma Unimplemented_Unit
4768 @findex Unimplemented_Unit
4769 @noindent
4770 Syntax:
4771
4772 @smallexample @c ada
4773 pragma Unimplemented_Unit;
4774 @end smallexample
4775
4776 @noindent
4777 If this pragma occurs in a unit that is processed by the compiler, GNAT
4778 aborts with the message @samp{@var{xxx} not implemented}, where
4779 @var{xxx} is the name of the current compilation unit.  This pragma is
4780 intended to allow the compiler to handle unimplemented library units in
4781 a clean manner.
4782
4783 The abort only happens if code is being generated.  Thus you can use
4784 specs of unimplemented packages in syntax or semantic checking mode.
4785
4786 @node Pragma Universal_Aliasing
4787 @unnumberedsec Pragma Universal_Aliasing
4788 @findex Universal_Aliasing
4789 @noindent
4790 Syntax:
4791
4792 @smallexample @c ada
4793 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4794 @end smallexample
4795
4796 @noindent
4797 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4798 declarative part.  The effect is to inhibit strict type-based aliasing
4799 optimization for the given type.  In other words, the effect is as though
4800 access types designating this type were subject to pragma No_Strict_Aliasing.
4801 For a detailed description of the strict aliasing optimization, and the
4802 situations in which it must be suppressed, @xref{Optimization and Strict
4803 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4804
4805 @node Pragma Universal_Data
4806 @unnumberedsec Pragma Universal_Data
4807 @findex Universal_Data
4808 @noindent
4809 Syntax:
4810
4811 @smallexample @c ada
4812 pragma Universal_Data [(library_unit_Name)];
4813 @end smallexample
4814
4815 @noindent
4816 This pragma is supported only for the AAMP target and is ignored for
4817 other targets. The pragma specifies that all library-level objects
4818 (Counter 0 data) associated with the library unit are to be accessed
4819 and updated using universal addressing (24-bit addresses for AAMP5)
4820 rather than the default of 16-bit Data Environment (DENV) addressing.
4821 Use of this pragma will generally result in less efficient code for
4822 references to global data associated with the library unit, but
4823 allows such data to be located anywhere in memory. This pragma is
4824 a library unit pragma, but can also be used as a configuration pragma
4825 (including use in the @file{gnat.adc} file). The functionality
4826 of this pragma is also available by applying the -univ switch on the
4827 compilations of units where universal addressing of the data is desired.
4828
4829 @node Pragma Unmodified
4830 @unnumberedsec Pragma Unmodified
4831 @findex Unmodified
4832 @cindex Warnings, unmodified
4833 @noindent
4834 Syntax:
4835
4836 @smallexample @c ada
4837 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4838 @end smallexample
4839
4840 @noindent
4841 This pragma signals that the assignable entities (variables,
4842 @code{out} parameters, @code{in out} parameters) whose names are listed are
4843 deliberately not assigned in the current source unit. This
4844 suppresses warnings about the
4845 entities being referenced but not assigned, and in addition a warning will be
4846 generated if one of these entities is in fact assigned in the
4847 same unit as the pragma (or in the corresponding body, or one
4848 of its subunits).
4849
4850 This is particularly useful for clearly signaling that a particular
4851 parameter is not modified, even though the spec suggests that it might
4852 be.
4853
4854 @node Pragma Unreferenced
4855 @unnumberedsec Pragma Unreferenced
4856 @findex Unreferenced
4857 @cindex Warnings, unreferenced
4858 @noindent
4859 Syntax:
4860
4861 @smallexample @c ada
4862 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4863 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4864 @end smallexample
4865
4866 @noindent
4867 This pragma signals that the entities whose names are listed are
4868 deliberately not referenced in the current source unit. This
4869 suppresses warnings about the
4870 entities being unreferenced, and in addition a warning will be
4871 generated if one of these entities is in fact referenced in the
4872 same unit as the pragma (or in the corresponding body, or one
4873 of its subunits).
4874
4875 This is particularly useful for clearly signaling that a particular
4876 parameter is not referenced in some particular subprogram implementation
4877 and that this is deliberate. It can also be useful in the case of
4878 objects declared only for their initialization or finalization side
4879 effects.
4880
4881 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4882 current scope, then the entity most recently declared is the one to which
4883 the pragma applies. Note that in the case of accept formals, the pragma
4884 Unreferenced may appear immediately after the keyword @code{do} which
4885 allows the indication of whether or not accept formals are referenced
4886 or not to be given individually for each accept statement.
4887
4888 The left hand side of an assignment does not count as a reference for the
4889 purpose of this pragma. Thus it is fine to assign to an entity for which
4890 pragma Unreferenced is given.
4891
4892 Note that if a warning is desired for all calls to a given subprogram,
4893 regardless of whether they occur in the same unit as the subprogram
4894 declaration, then this pragma should not be used (calls from another
4895 unit would not be flagged); pragma Obsolescent can be used instead
4896 for this purpose, see @xref{Pragma Obsolescent}.
4897
4898 The second form of pragma @code{Unreferenced} is used within a context
4899 clause. In this case the arguments must be unit names of units previously
4900 mentioned in @code{with} clauses (similar to the usage of pragma
4901 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4902 units and unreferenced entities within these units.
4903
4904 @node Pragma Unreferenced_Objects
4905 @unnumberedsec Pragma Unreferenced_Objects
4906 @findex Unreferenced_Objects
4907 @cindex Warnings, unreferenced
4908 @noindent
4909 Syntax:
4910
4911 @smallexample @c ada
4912 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4913 @end smallexample
4914
4915 @noindent
4916 This pragma signals that for the types or subtypes whose names are
4917 listed, objects which are declared with one of these types or subtypes may
4918 not be referenced, and if no references appear, no warnings are given.
4919
4920 This is particularly useful for objects which are declared solely for their
4921 initialization and finalization effect. Such variables are sometimes referred
4922 to as RAII variables (Resource Acquisition Is Initialization). Using this
4923 pragma on the relevant type (most typically a limited controlled type), the
4924 compiler will automatically suppress unwanted warnings about these variables
4925 not being referenced.
4926
4927 @node Pragma Unreserve_All_Interrupts
4928 @unnumberedsec Pragma Unreserve_All_Interrupts
4929 @findex Unreserve_All_Interrupts
4930 @noindent
4931 Syntax:
4932
4933 @smallexample @c ada
4934 pragma Unreserve_All_Interrupts;
4935 @end smallexample
4936
4937 @noindent
4938 Normally certain interrupts are reserved to the implementation.  Any attempt
4939 to attach an interrupt causes Program_Error to be raised, as described in
4940 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4941 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4942 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4943 interrupt execution.
4944
4945 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4946 a program, then all such interrupts are unreserved.  This allows the
4947 program to handle these interrupts, but disables their standard
4948 functions.  For example, if this pragma is used, then pressing
4949 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4950 a program can then handle the @code{SIGINT} interrupt as it chooses.
4951
4952 For a full list of the interrupts handled in a specific implementation,
4953 see the source code for the spec of @code{Ada.Interrupts.Names} in
4954 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4955 list of interrupts recognized for a given target.  The documentation in
4956 this file also specifies what interrupts are affected by the use of
4957 the @code{Unreserve_All_Interrupts} pragma.
4958
4959 For a more general facility for controlling what interrupts can be
4960 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4961 of the @code{Unreserve_All_Interrupts} pragma.
4962
4963 @node Pragma Unsuppress
4964 @unnumberedsec Pragma Unsuppress
4965 @findex Unsuppress
4966 @noindent
4967 Syntax:
4968
4969 @smallexample @c ada
4970 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4971 @end smallexample
4972
4973 @noindent
4974 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4975 there is no corresponding pragma @code{Suppress} in effect, it has no
4976 effect.  The range of the effect is the same as for pragma
4977 @code{Suppress}.  The meaning of the arguments is identical to that used
4978 in pragma @code{Suppress}.
4979
4980 One important application is to ensure that checks are on in cases where
4981 code depends on the checks for its correct functioning, so that the code
4982 will compile correctly even if the compiler switches are set to suppress
4983 checks.
4984
4985 @node Pragma Use_VADS_Size
4986 @unnumberedsec Pragma Use_VADS_Size
4987 @cindex @code{Size}, VADS compatibility
4988 @findex Use_VADS_Size
4989 @noindent
4990 Syntax:
4991
4992 @smallexample @c ada
4993 pragma Use_VADS_Size;
4994 @end smallexample
4995
4996 @noindent
4997 This is a configuration pragma.  In a unit to which it applies, any use
4998 of the 'Size attribute is automatically interpreted as a use of the
4999 'VADS_Size attribute.  Note that this may result in incorrect semantic
5000 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5001 the handling of existing code which depends on the interpretation of Size
5002 as implemented in the VADS compiler.  See description of the VADS_Size
5003 attribute for further details.
5004
5005 @node Pragma Validity_Checks
5006 @unnumberedsec Pragma Validity_Checks
5007 @findex Validity_Checks
5008 @noindent
5009 Syntax:
5010
5011 @smallexample @c ada
5012 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5013 @end smallexample
5014
5015 @noindent
5016 This pragma is used in conjunction with compiler switches to control the
5017 built-in validity checking provided by GNAT@.  The compiler switches, if set
5018 provide an initial setting for the switches, and this pragma may be used
5019 to modify these settings, or the settings may be provided entirely by
5020 the use of the pragma.  This pragma can be used anywhere that a pragma
5021 is legal, including use as a configuration pragma (including use in
5022 the @file{gnat.adc} file).
5023
5024 The form with a string literal specifies which validity options are to be
5025 activated.  The validity checks are first set to include only the default
5026 reference manual settings, and then a string of letters in the string
5027 specifies the exact set of options required.  The form of this string
5028 is exactly as described for the @option{-gnatVx} compiler switch (see the
5029 GNAT users guide for details).  For example the following two methods
5030 can be used to enable validity checking for mode @code{in} and
5031 @code{in out} subprogram parameters:
5032
5033 @itemize @bullet
5034 @item
5035 @smallexample @c ada
5036 pragma Validity_Checks ("im");
5037 @end smallexample
5038
5039 @item
5040 @smallexample
5041 gcc -c -gnatVim @dots{}
5042 @end smallexample
5043 @end itemize
5044
5045 @noindent
5046 The form ALL_CHECKS activates all standard checks (its use is equivalent
5047 to the use of the @code{gnatva} switch.
5048
5049 The forms with @code{Off} and @code{On}
5050 can be used to temporarily disable validity checks
5051 as shown in the following example:
5052
5053 @smallexample @c ada
5054 @iftex
5055 @leftskip=0cm
5056 @end iftex
5057 pragma Validity_Checks ("c"); -- validity checks for copies
5058 pragma Validity_Checks (Off); -- turn off validity checks
5059 A := B;                       -- B will not be validity checked
5060 pragma Validity_Checks (On);  -- turn validity checks back on
5061 A := C;                       -- C will be validity checked
5062 @end smallexample
5063
5064 @node Pragma Volatile
5065 @unnumberedsec Pragma Volatile
5066 @findex Volatile
5067 @noindent
5068 Syntax:
5069
5070 @smallexample @c ada
5071 pragma Volatile (LOCAL_NAME);
5072 @end smallexample
5073
5074 @noindent
5075 This pragma is defined by the Ada Reference Manual, and the GNAT
5076 implementation is fully conformant with this definition.  The reason it
5077 is mentioned in this section is that a pragma of the same name was supplied
5078 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5079 implementation of pragma Volatile is upwards compatible with the
5080 implementation in DEC Ada 83.
5081
5082 @node Pragma Warnings
5083 @unnumberedsec Pragma Warnings
5084 @findex Warnings
5085 @noindent
5086 Syntax:
5087
5088 @smallexample @c ada
5089 pragma Warnings (On | Off);
5090 pragma Warnings (On | Off, LOCAL_NAME);
5091 pragma Warnings (static_string_EXPRESSION);
5092 pragma Warnings (On | Off, static_string_EXPRESSION);
5093 @end smallexample
5094
5095 @noindent
5096 Normally warnings are enabled, with the output being controlled by
5097 the command line switch.  Warnings (@code{Off}) turns off generation of
5098 warnings until a Warnings (@code{On}) is encountered or the end of the
5099 current unit.  If generation of warnings is turned off using this
5100 pragma, then no warning messages are output, regardless of the
5101 setting of the command line switches.
5102
5103 The form with a single argument may be used as a configuration pragma.
5104
5105 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5106 the specified entity.  This suppression is effective from the point where
5107 it occurs till the end of the extended scope of the variable (similar to
5108 the scope of @code{Suppress}).
5109
5110 The form with a single static_string_EXPRESSION argument provides more precise
5111 control over which warnings are active. The string is a list of letters
5112 specifying which warnings are to be activated and which deactivated. The
5113 code for these letters is the same as the string used in the command
5114 line switch controlling warnings. The following is a brief summary. For
5115 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5116 User's Guide}.
5117
5118 @smallexample
5119 a    turn on all optional warnings (except d h l .o)
5120 A    turn off all optional warnings
5121 .a*  turn on warnings for failing assertions
5122 .A   turn off warnings for failing assertions
5123 b    turn on warnings for bad fixed value (not multiple of small)
5124 B*   turn off warnings for bad fixed value (not multiple of small)
5125 c    turn on warnings for constant conditional
5126 C*   turn off warnings for constant conditional
5127 .c   turn on warnings for unrepped components
5128 .C*  turn off warnings for unrepped components
5129 d    turn on warnings for implicit dereference
5130 D*   turn off warnings for implicit dereference
5131 e    treat all warnings as errors
5132 f    turn on warnings for unreferenced formal
5133 F*   turn off warnings for unreferenced formal
5134 g*   turn on warnings for unrecognized pragma
5135 G    turn off warnings for unrecognized pragma
5136 h    turn on warnings for hiding variable
5137 H*   turn off warnings for hiding variable
5138 i*   turn on warnings for implementation unit
5139 I    turn off warnings for implementation unit
5140 j    turn on warnings for obsolescent (annex J) feature
5141 J*   turn off warnings for obsolescent (annex J) feature
5142 k    turn on warnings on constant variable
5143 K*   turn off warnings on constant variable
5144 l    turn on warnings for missing elaboration pragma
5145 L*   turn off warnings for missing elaboration pragma
5146 m    turn on warnings for variable assigned but not read
5147 M*   turn off warnings for variable assigned but not read
5148 n*   normal warning mode (cancels -gnatws/-gnatwe)
5149 o*   turn on warnings for address clause overlay
5150 O    turn off warnings for address clause overlay
5151 .o   turn on warnings for out parameters assigned but not read
5152 .O*  turn off warnings for out parameters assigned but not read
5153 p    turn on warnings for ineffective pragma Inline in frontend
5154 P*   turn off warnings for ineffective pragma Inline in frontend
5155 q*   turn on warnings for questionable missing parentheses
5156 Q    turn off warnings for questionable missing parentheses
5157 r    turn on warnings for redundant construct
5158 R*   turn off warnings for redundant construct
5159 .r   turn on warnings for object renaming function
5160 .R*  turn off warnings for object renaming function
5161 s    suppress all warnings
5162 t    turn on warnings for tracking deleted code
5163 T*   turn off warnings for tracking deleted code
5164 u    turn on warnings for unused entity
5165 U*   turn off warnings for unused entity
5166 v*   turn on warnings for unassigned variable
5167 V    turn off warnings for unassigned variable
5168 w*   turn on warnings for wrong low bound assumption
5169 W    turn off warnings for wrong low bound assumption
5170 x*   turn on warnings for export/import
5171 X    turn off warnings for export/import
5172 .x   turn on warnings for non-local exceptions
5173 .X*  turn off warnings for non-local exceptions
5174 y*   turn on warnings for Ada 2005 incompatibility
5175 Y    turn off warnings for Ada 2005 incompatibility
5176 z*   turn on convention/size/align warnings for unchecked conversion
5177 Z    turn off convention/size/align warnings for unchecked conversion
5178 *    indicates default in above list
5179 @end smallexample
5180
5181 @noindent
5182 The specified warnings will be in effect until the end of the program
5183 or another pragma Warnings is encountered. The effect of the pragma is
5184 cumulative. Initially the set of warnings is the standard default set
5185 as possibly modified by compiler switches. Then each pragma Warning
5186 modifies this set of warnings as specified. This form of the pragma may
5187 also be used as a configuration pragma.
5188
5189 The fourth form, with an On|Off parameter and a string, is used to
5190 control individual messages, based on their text. The string argument
5191 is a pattern that is used to match against the text of individual
5192 warning messages (not including the initial "warnings: " tag).
5193
5194 The pattern may contain asterisks which match zero or more characters in
5195 the message. For example, you can use
5196 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5197 message @code{warning: 960 bits of "a" unused}. No other regular
5198 expression notations are permitted. All characters other than asterisk in
5199 these three specific cases are treated as literal characters in the match.
5200
5201 There are two ways to use this pragma. The OFF form can be used as a
5202 configuration pragma. The effect is to suppress all warnings (if any)
5203 that match the pattern string throughout the compilation.
5204
5205 The second usage is to suppress a warning locally, and in this case, two
5206 pragmas must appear in sequence:
5207
5208 @smallexample @c ada
5209 pragma Warnings (Off, Pattern);
5210 @dots{} code where given warning is to be suppressed
5211 pragma Warnings (On, Pattern);
5212 @end smallexample
5213
5214 @noindent
5215 In this usage, the pattern string must match in the Off and On pragmas,
5216 and at least one matching warning must be suppressed.
5217
5218 @node Pragma Weak_External
5219 @unnumberedsec Pragma Weak_External
5220 @findex Weak_External
5221 @noindent
5222 Syntax:
5223
5224 @smallexample @c ada
5225 pragma Weak_External ([Entity =>] LOCAL_NAME);
5226 @end smallexample
5227
5228 @noindent
5229 @var{LOCAL_NAME} must refer to an object that is declared at the library
5230 level. This pragma specifies that the given entity should be marked as a
5231 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5232 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5233 of a regular symbol, that is to say a symbol that does not have to be
5234 resolved by the linker if used in conjunction with a pragma Import.
5235
5236 When a weak symbol is not resolved by the linker, its address is set to
5237 zero. This is useful in writing interfaces to external modules that may
5238 or may not be linked in the final executable, for example depending on
5239 configuration settings.
5240
5241 If a program references at run time an entity to which this pragma has been
5242 applied, and the corresponding symbol was not resolved at link time, then
5243 the execution of the program is erroneous. It is not erroneous to take the
5244 Address of such an entity, for example to guard potential references,
5245 as shown in the example below.
5246
5247 Some file formats do not support weak symbols so not all target machines
5248 support this pragma.
5249
5250 @smallexample @c ada
5251 --  Example of the use of pragma Weak_External
5252
5253 package External_Module is
5254   key : Integer;
5255   pragma Import (C, key);
5256   pragma Weak_External (key);
5257   function Present return boolean;
5258 end External_Module;
5259
5260 with System; use System;
5261 package body External_Module is
5262   function Present return boolean is
5263   begin
5264     return key'Address /= System.Null_Address;
5265   end Present;
5266 end External_Module;
5267 @end smallexample
5268
5269 @node Pragma Wide_Character_Encoding
5270 @unnumberedsec Pragma Wide_Character_Encoding
5271 @findex Wide_Character_Encoding
5272 @noindent
5273 Syntax:
5274
5275 @smallexample @c ada
5276 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5277 @end smallexample
5278
5279 @noindent
5280 This pragma specifies the wide character encoding to be used in program
5281 source text appearing subsequently. It is a configuration pragma, but may
5282 also be used at any point that a pragma is allowed, and it is permissible
5283 to have more than one such pragma in a file, allowing multiple encodings
5284 to appear within the same file.
5285
5286 The argument can be an identifier or a character literal. In the identifier
5287 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5288 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5289 case it is correspondingly one of the characters @samp{h}, @samp{u},
5290 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5291
5292 Note that when the pragma is used within a file, it affects only the
5293 encoding within that file, and does not affect withed units, specs,
5294 or subunits.
5295
5296 @node Implementation Defined Attributes
5297 @chapter Implementation Defined Attributes
5298 Ada defines (throughout the Ada reference manual,
5299 summarized in Annex K),
5300 a set of attributes that provide useful additional functionality in all
5301 areas of the language.  These language defined attributes are implemented
5302 in GNAT and work as described in the Ada Reference Manual.
5303
5304 In addition, Ada allows implementations to define additional
5305 attributes whose meaning is defined by the implementation.  GNAT provides
5306 a number of these implementation-dependent attributes which can be used
5307 to extend and enhance the functionality of the compiler.  This section of
5308 the GNAT reference manual describes these additional attributes.
5309
5310 Note that any program using these attributes may not be portable to
5311 other compilers (although GNAT implements this set of attributes on all
5312 platforms).  Therefore if portability to other compilers is an important
5313 consideration, you should minimize the use of these attributes.
5314
5315 @menu
5316 * Abort_Signal::
5317 * Address_Size::
5318 * Asm_Input::
5319 * Asm_Output::
5320 * AST_Entry::
5321 * Bit::
5322 * Bit_Position::
5323 * Code_Address::
5324 * Default_Bit_Order::
5325 * Elaborated::
5326 * Elab_Body::
5327 * Elab_Spec::
5328 * Emax::
5329 * Enabled::
5330 * Enum_Rep::
5331 * Enum_Val::
5332 * Epsilon::
5333 * Fixed_Value::
5334 * Has_Access_Values::
5335 * Has_Discriminants::
5336 * Img::
5337 * Integer_Value::
5338 * Invalid_Value::
5339 * Large::
5340 * Machine_Size::
5341 * Mantissa::
5342 * Max_Interrupt_Priority::
5343 * Max_Priority::
5344 * Maximum_Alignment::
5345 * Mechanism_Code::
5346 * Null_Parameter::
5347 * Object_Size::
5348 * Old::
5349 * Passed_By_Reference::
5350 * Pool_Address::
5351 * Range_Length::
5352 * Safe_Emax::
5353 * Safe_Large::
5354 * Small::
5355 * Storage_Unit::
5356 * Stub_Type::
5357 * Target_Name::
5358 * Tick::
5359 * To_Address::
5360 * Type_Class::
5361 * UET_Address::
5362 * Unconstrained_Array::
5363 * Universal_Literal_String::
5364 * Unrestricted_Access::
5365 * VADS_Size::
5366 * Value_Size::
5367 * Wchar_T_Size::
5368 * Word_Size::
5369 @end menu
5370
5371 @node Abort_Signal
5372 @unnumberedsec Abort_Signal
5373 @findex Abort_Signal
5374 @noindent
5375 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5376 prefix) provides the entity for the special exception used to signal
5377 task abort or asynchronous transfer of control.  Normally this attribute
5378 should only be used in the tasking runtime (it is highly peculiar, and
5379 completely outside the normal semantics of Ada, for a user program to
5380 intercept the abort exception).
5381
5382 @node Address_Size
5383 @unnumberedsec Address_Size
5384 @cindex Size of @code{Address}
5385 @findex Address_Size
5386 @noindent
5387 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5388 prefix) is a static constant giving the number of bits in an
5389 @code{Address}. It is the same value as System.Address'Size,
5390 but has the advantage of being static, while a direct
5391 reference to System.Address'Size is non-static because Address
5392 is a private type.
5393
5394 @node Asm_Input
5395 @unnumberedsec Asm_Input
5396 @findex Asm_Input
5397 @noindent
5398 The @code{Asm_Input} attribute denotes a function that takes two
5399 parameters.  The first is a string, the second is an expression of the
5400 type designated by the prefix.  The first (string) argument is required
5401 to be a static expression, and is the constraint for the parameter,
5402 (e.g.@: what kind of register is required).  The second argument is the
5403 value to be used as the input argument.  The possible values for the
5404 constant are the same as those used in the RTL, and are dependent on
5405 the configuration file used to built the GCC back end.
5406 @ref{Machine Code Insertions}
5407
5408 @node Asm_Output
5409 @unnumberedsec Asm_Output
5410 @findex Asm_Output
5411 @noindent
5412 The @code{Asm_Output} attribute denotes a function that takes two
5413 parameters.  The first is a string, the second is the name of a variable
5414 of the type designated by the attribute prefix.  The first (string)
5415 argument is required to be a static expression and designates the
5416 constraint for the parameter (e.g.@: what kind of register is
5417 required).  The second argument is the variable to be updated with the
5418 result.  The possible values for constraint are the same as those used in
5419 the RTL, and are dependent on the configuration file used to build the
5420 GCC back end.  If there are no output operands, then this argument may
5421 either be omitted, or explicitly given as @code{No_Output_Operands}.
5422 @ref{Machine Code Insertions}
5423
5424 @node AST_Entry
5425 @unnumberedsec AST_Entry
5426 @cindex OpenVMS
5427 @findex AST_Entry
5428 @noindent
5429 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5430 the name of an entry, it yields a value of the predefined type AST_Handler
5431 (declared in the predefined package System, as extended by the use of
5432 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5433 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5434 Language Reference Manual}, section 9.12a.
5435
5436 @node Bit
5437 @unnumberedsec Bit
5438 @findex Bit
5439 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5440 offset within the storage unit (byte) that contains the first bit of
5441 storage allocated for the object.  The value of this attribute is of the
5442 type @code{Universal_Integer}, and is always a non-negative number not
5443 exceeding the value of @code{System.Storage_Unit}.
5444
5445 For an object that is a variable or a constant allocated in a register,
5446 the value is zero.  (The use of this attribute does not force the
5447 allocation of a variable to memory).
5448
5449 For an object that is a formal parameter, this attribute applies
5450 to either the matching actual parameter or to a copy of the
5451 matching actual parameter.
5452
5453 For an access object the value is zero.  Note that
5454 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5455 designated object.  Similarly for a record component
5456 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5457 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5458 are subject to index checks.
5459
5460 This attribute is designed to be compatible with the DEC Ada 83 definition
5461 and implementation of the @code{Bit} attribute.
5462
5463 @node Bit_Position
5464 @unnumberedsec Bit_Position
5465 @findex Bit_Position
5466 @noindent
5467 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5468 of the fields of the record type, yields the bit
5469 offset within the record contains the first bit of
5470 storage allocated for the object.  The value of this attribute is of the
5471 type @code{Universal_Integer}.  The value depends only on the field
5472 @var{C} and is independent of the alignment of
5473 the containing record @var{R}.
5474
5475 @node Code_Address
5476 @unnumberedsec Code_Address
5477 @findex Code_Address
5478 @cindex Subprogram address
5479 @cindex Address of subprogram code
5480 @noindent
5481 The @code{'Address}
5482 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5483 intended effect seems to be to provide
5484 an address value which can be used to call the subprogram by means of
5485 an address clause as in the following example:
5486
5487 @smallexample @c ada
5488 procedure K is @dots{}
5489
5490 procedure L;
5491 for L'Address use K'Address;
5492 pragma Import (Ada, L);
5493 @end smallexample
5494
5495 @noindent
5496 A call to @code{L} is then expected to result in a call to @code{K}@.
5497 In Ada 83, where there were no access-to-subprogram values, this was
5498 a common work-around for getting the effect of an indirect call.
5499 GNAT implements the above use of @code{Address} and the technique
5500 illustrated by the example code works correctly.
5501
5502 However, for some purposes, it is useful to have the address of the start
5503 of the generated code for the subprogram.  On some architectures, this is
5504 not necessarily the same as the @code{Address} value described above.
5505 For example, the @code{Address} value may reference a subprogram
5506 descriptor rather than the subprogram itself.
5507
5508 The @code{'Code_Address} attribute, which can only be applied to
5509 subprogram entities, always returns the address of the start of the
5510 generated code of the specified subprogram, which may or may not be
5511 the same value as is returned by the corresponding @code{'Address}
5512 attribute.
5513
5514 @node Default_Bit_Order
5515 @unnumberedsec Default_Bit_Order
5516 @cindex Big endian
5517 @cindex Little endian
5518 @findex Default_Bit_Order
5519 @noindent
5520 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5521 permissible prefix), provides the value @code{System.Default_Bit_Order}
5522 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5523 @code{Low_Order_First}).  This is used to construct the definition of
5524 @code{Default_Bit_Order} in package @code{System}.
5525
5526 @node Elaborated
5527 @unnumberedsec Elaborated
5528 @findex Elaborated
5529 @noindent
5530 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5531 value is a Boolean which indicates whether or not the given unit has been
5532 elaborated.  This attribute is primarily intended for internal use by the
5533 generated code for dynamic elaboration checking, but it can also be used
5534 in user programs.  The value will always be True once elaboration of all
5535 units has been completed.  An exception is for units which need no
5536 elaboration, the value is always False for such units.
5537
5538 @node Elab_Body
5539 @unnumberedsec Elab_Body
5540 @findex Elab_Body
5541 @noindent
5542 This attribute can only be applied to a program unit name.  It returns
5543 the entity for the corresponding elaboration procedure for elaborating
5544 the body of the referenced unit.  This is used in the main generated
5545 elaboration procedure by the binder and is not normally used in any
5546 other context.  However, there may be specialized situations in which it
5547 is useful to be able to call this elaboration procedure from Ada code,
5548 e.g.@: if it is necessary to do selective re-elaboration to fix some
5549 error.
5550
5551 @node Elab_Spec
5552 @unnumberedsec Elab_Spec
5553 @findex Elab_Spec
5554 @noindent
5555 This attribute can only be applied to a program unit name.  It returns
5556 the entity for the corresponding elaboration procedure for elaborating
5557 the spec of the referenced unit.  This is used in the main
5558 generated elaboration procedure by the binder and is not normally used
5559 in any other context.  However, there may be specialized situations in
5560 which it is useful to be able to call this elaboration procedure from
5561 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5562 some error.
5563
5564 @node Emax
5565 @unnumberedsec Emax
5566 @cindex Ada 83 attributes
5567 @findex Emax
5568 @noindent
5569 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5570 the Ada 83 reference manual for an exact description of the semantics of
5571 this attribute.
5572
5573 @node Enabled
5574 @unnumberedsec Enabled
5575 @findex Enabled
5576 @noindent
5577 The @code{Enabled} attribute allows an application program to check at compile
5578 time to see if the designated check is currently enabled. The prefix is a
5579 simple identifier, referencing any predefined check name (other than
5580 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5581 no argument is given for the attribute, the check is for the general state
5582 of the check, if an argument is given, then it is an entity name, and the
5583 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5584 given naming the entity (if not, then the argument is ignored).
5585
5586 Note that instantiations inherit the check status at the point of the
5587 instantiation, so a useful idiom is to have a library package that
5588 introduces a check name with @code{pragma Check_Name}, and then contains
5589 generic packages or subprograms which use the @code{Enabled} attribute
5590 to see if the check is enabled. A user of this package can then issue
5591 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5592 the package or subprogram, controlling whether the check will be present.
5593
5594 @node Enum_Rep
5595 @unnumberedsec Enum_Rep
5596 @cindex Representation of enums
5597 @findex Enum_Rep
5598 @noindent
5599 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5600 function with the following spec:
5601
5602 @smallexample @c ada
5603 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5604   return @i{Universal_Integer};
5605 @end smallexample
5606
5607 @noindent
5608 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5609 enumeration type or to a non-overloaded enumeration
5610 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5611 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5612 enumeration literal or object.
5613
5614 The function returns the representation value for the given enumeration
5615 value.  This will be equal to value of the @code{Pos} attribute in the
5616 absence of an enumeration representation clause.  This is a static
5617 attribute (i.e.@: the result is static if the argument is static).
5618
5619 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5620 in which case it simply returns the integer value.  The reason for this
5621 is to allow it to be used for @code{(<>)} discrete formal arguments in
5622 a generic unit that can be instantiated with either enumeration types
5623 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5624 type whose upper bound exceeds the upper bound of the largest signed
5625 integer type, and the argument is a variable, so that the universal
5626 integer calculation is done at run time, then the call to @code{Enum_Rep}
5627 may raise @code{Constraint_Error}.
5628
5629 @node Enum_Val
5630 @unnumberedsec Enum_Val
5631 @cindex Representation of enums
5632 @findex Enum_Val
5633 @noindent
5634 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5635 function with the following spec:
5636
5637 @smallexample @c ada
5638 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5639   return @var{S}'Base};
5640 @end smallexample
5641
5642 @noindent
5643 The function returns the enumeration value whose representation matches the
5644 argument, or raises Constraint_Error if no enumeration literal of the type
5645 has the matching value.
5646 This will be equal to value of the @code{Val} attribute in the
5647 absence of an enumeration representation clause.  This is a static
5648 attribute (i.e.@: the result is static if the argument is static).
5649
5650 @node Epsilon
5651 @unnumberedsec Epsilon
5652 @cindex Ada 83 attributes
5653 @findex Epsilon
5654 @noindent
5655 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5656 the Ada 83 reference manual for an exact description of the semantics of
5657 this attribute.
5658
5659 @node Fixed_Value
5660 @unnumberedsec Fixed_Value
5661 @findex Fixed_Value
5662 @noindent
5663 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5664 function with the following specification:
5665
5666 @smallexample @c ada
5667 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5668   return @var{S};
5669 @end smallexample
5670
5671 @noindent
5672 The value returned is the fixed-point value @var{V} such that
5673
5674 @smallexample @c ada
5675 @var{V} = Arg * @var{S}'Small
5676 @end smallexample
5677
5678 @noindent
5679 The effect is thus similar to first converting the argument to the
5680 integer type used to represent @var{S}, and then doing an unchecked
5681 conversion to the fixed-point type.  The difference is
5682 that there are full range checks, to ensure that the result is in range.
5683 This attribute is primarily intended for use in implementation of the
5684 input-output functions for fixed-point values.
5685
5686 @node Has_Access_Values
5687 @unnumberedsec Has_Access_Values
5688 @cindex Access values, testing for
5689 @findex Has_Access_Values
5690 @noindent
5691 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5692 is a Boolean value which is True if the is an access type, or is a composite
5693 type with a component (at any nesting depth) that is an access type, and is
5694 False otherwise.
5695 The intended use of this attribute is in conjunction with generic
5696 definitions.  If the attribute is applied to a generic private type, it
5697 indicates whether or not the corresponding actual type has access values.
5698
5699 @node Has_Discriminants
5700 @unnumberedsec Has_Discriminants
5701 @cindex Discriminants, testing for
5702 @findex Has_Discriminants
5703 @noindent
5704 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5705 is a Boolean value which is True if the type has discriminants, and False
5706 otherwise.  The intended use of this attribute is in conjunction with generic
5707 definitions.  If the attribute is applied to a generic private type, it
5708 indicates whether or not the corresponding actual type has discriminants.
5709
5710 @node Img
5711 @unnumberedsec Img
5712 @findex Img
5713 @noindent
5714 The @code{Img} attribute differs from @code{Image} in that it may be
5715 applied to objects as well as types, in which case it gives the
5716 @code{Image} for the subtype of the object.  This is convenient for
5717 debugging:
5718
5719 @smallexample @c ada
5720 Put_Line ("X = " & X'Img);
5721 @end smallexample
5722
5723 @noindent
5724 has the same meaning as the more verbose:
5725
5726 @smallexample @c ada
5727 Put_Line ("X = " & @var{T}'Image (X));
5728 @end smallexample
5729
5730 @noindent
5731 where @var{T} is the (sub)type of the object @code{X}.
5732
5733 @node Integer_Value
5734 @unnumberedsec Integer_Value
5735 @findex Integer_Value
5736 @noindent
5737 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5738 function with the following spec:
5739
5740 @smallexample @c ada
5741 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5742   return @var{S};
5743 @end smallexample
5744
5745 @noindent
5746 The value returned is the integer value @var{V}, such that
5747
5748 @smallexample @c ada
5749 Arg = @var{V} * @var{T}'Small
5750 @end smallexample
5751
5752 @noindent
5753 where @var{T} is the type of @code{Arg}.
5754 The effect is thus similar to first doing an unchecked conversion from
5755 the fixed-point type to its corresponding implementation type, and then
5756 converting the result to the target integer type.  The difference is
5757 that there are full range checks, to ensure that the result is in range.
5758 This attribute is primarily intended for use in implementation of the
5759 standard input-output functions for fixed-point values.
5760
5761 @node Invalid_Value
5762 @unnumberedsec Invalid_Value
5763 @findex Invalid_Value
5764 @noindent
5765 For every scalar type S, S'Invalid_Value returns an undefined value of the
5766 type. If possible this value is an invalid representation for the type. The
5767 value returned is identical to the value used to initialize an otherwise
5768 uninitialized value of the type if pragma Initialize_Scalars is used,
5769 including the ability to modify the value with the binder -Sxx flag and
5770 relevant environment variables at run time.
5771
5772 @node Large
5773 @unnumberedsec Large
5774 @cindex Ada 83 attributes
5775 @findex Large
5776 @noindent
5777 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5778 the Ada 83 reference manual for an exact description of the semantics of
5779 this attribute.
5780
5781 @node Machine_Size
5782 @unnumberedsec Machine_Size
5783 @findex Machine_Size
5784 @noindent
5785 This attribute is identical to the @code{Object_Size} attribute.  It is
5786 provided for compatibility with the DEC Ada 83 attribute of this name.
5787
5788 @node Mantissa
5789 @unnumberedsec Mantissa
5790 @cindex Ada 83 attributes
5791 @findex Mantissa
5792 @noindent
5793 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5794 the Ada 83 reference manual for an exact description of the semantics of
5795 this attribute.
5796
5797 @node Max_Interrupt_Priority
5798 @unnumberedsec Max_Interrupt_Priority
5799 @cindex Interrupt priority, maximum
5800 @findex Max_Interrupt_Priority
5801 @noindent
5802 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5803 permissible prefix), provides the same value as
5804 @code{System.Max_Interrupt_Priority}.
5805
5806 @node Max_Priority
5807 @unnumberedsec Max_Priority
5808 @cindex Priority, maximum
5809 @findex Max_Priority
5810 @noindent
5811 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5812 prefix) provides the same value as @code{System.Max_Priority}.
5813
5814 @node Maximum_Alignment
5815 @unnumberedsec Maximum_Alignment
5816 @cindex Alignment, maximum
5817 @findex Maximum_Alignment
5818 @noindent
5819 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5820 permissible prefix) provides the maximum useful alignment value for the
5821 target.  This is a static value that can be used to specify the alignment
5822 for an object, guaranteeing that it is properly aligned in all
5823 cases.
5824
5825 @node Mechanism_Code
5826 @unnumberedsec Mechanism_Code
5827 @cindex Return values, passing mechanism
5828 @cindex Parameters, passing mechanism
5829 @findex Mechanism_Code
5830 @noindent
5831 @code{@var{function}'Mechanism_Code} yields an integer code for the
5832 mechanism used for the result of function, and
5833 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5834 used for formal parameter number @var{n} (a static integer value with 1
5835 meaning the first parameter) of @var{subprogram}.  The code returned is:
5836
5837 @table @asis
5838 @item 1
5839 by copy (value)
5840 @item 2
5841 by reference
5842 @item 3
5843 by descriptor (default descriptor class)
5844 @item 4
5845 by descriptor (UBS: unaligned bit string)
5846 @item 5
5847 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5848 @item 6
5849 by descriptor (UBA: unaligned bit array)
5850 @item 7
5851 by descriptor (S: string, also scalar access type parameter)
5852 @item 8
5853 by descriptor (SB: string with arbitrary bounds)
5854 @item 9
5855 by descriptor (A: contiguous array)
5856 @item 10
5857 by descriptor (NCA: non-contiguous array)
5858 @end table
5859
5860 @noindent
5861 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5862 @cindex OpenVMS
5863
5864 @node Null_Parameter
5865 @unnumberedsec Null_Parameter
5866 @cindex Zero address, passing
5867 @findex Null_Parameter
5868 @noindent
5869 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5870 type or subtype @var{T} allocated at machine address zero.  The attribute
5871 is allowed only as the default expression of a formal parameter, or as
5872 an actual expression of a subprogram call.  In either case, the
5873 subprogram must be imported.
5874
5875 The identity of the object is represented by the address zero in the
5876 argument list, independent of the passing mechanism (explicit or
5877 default).
5878
5879 This capability is needed to specify that a zero address should be
5880 passed for a record or other composite object passed by reference.
5881 There is no way of indicating this without the @code{Null_Parameter}
5882 attribute.
5883
5884 @node Object_Size
5885 @unnumberedsec Object_Size
5886 @cindex Size, used for objects
5887 @findex Object_Size
5888 @noindent
5889 The size of an object is not necessarily the same as the size of the type
5890 of an object.  This is because by default object sizes are increased to be
5891 a multiple of the alignment of the object.  For example,
5892 @code{Natural'Size} is
5893 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5894 Similarly, a record containing an integer and a character:
5895
5896 @smallexample @c ada
5897 type Rec is record
5898    I : Integer;
5899    C : Character;
5900 end record;
5901 @end smallexample
5902
5903 @noindent
5904 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5905 alignment will be 4, because of the
5906 integer field, and so the default size of record objects for this type
5907 will be 64 (8 bytes).
5908
5909 @node Old
5910 @unnumberedsec Old
5911 @cindex Capturing Old values
5912 @cindex Postconditions
5913 @noindent
5914 The attribute Prefix'Old can be used within a
5915 subprogram to refer to the value of the prefix on entry. So for
5916 example if you have an argument of a record type X called Arg1,
5917 you can refer to Arg1.Field'Old which yields the value of
5918 Arg1.Field on entry. The implementation simply involves generating
5919 an object declaration which captures the value on entry. Any
5920 prefix is allowed except one of a limited type (since limited
5921 types cannot be copied to capture their values) or a local variable
5922 (since it does not exist at subprogram entry time).
5923
5924 The following example shows the use of 'Old to implement
5925 a test of a postcondition:
5926
5927 @smallexample @c ada
5928 with Old_Pkg;
5929 procedure Old is
5930 begin
5931    Old_Pkg.Incr;
5932 end Old;
5933
5934 package Old_Pkg is
5935    procedure Incr;
5936 end Old_Pkg;
5937
5938 package body Old_Pkg is
5939    Count : Natural := 0;
5940
5941    procedure Incr is
5942    begin
5943       ... code manipulating the value of Count
5944
5945       pragma Assert (Count = Count'Old + 1);
5946    end Incr;
5947 end Old_Pkg;
5948 @end smallexample
5949
5950 @noindent
5951 Note that it is allowed to apply 'Old to a constant entity, but this will
5952 result in a warning, since the old and new values will always be the same.
5953
5954 @node Passed_By_Reference
5955 @unnumberedsec Passed_By_Reference
5956 @cindex Parameters, when passed by reference
5957 @findex Passed_By_Reference
5958 @noindent
5959 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5960 a value of type @code{Boolean} value that is @code{True} if the type is
5961 normally passed by reference and @code{False} if the type is normally
5962 passed by copy in calls.  For scalar types, the result is always @code{False}
5963 and is static.  For non-scalar types, the result is non-static.
5964
5965 @node Pool_Address
5966 @unnumberedsec Pool_Address
5967 @cindex Parameters, when passed by reference
5968 @findex Pool_Address
5969 @noindent
5970 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5971 of X within its storage pool. This is the same as
5972 @code{@var{X}'Address}, except that for an unconstrained array whose
5973 bounds are allocated just before the first component,
5974 @code{@var{X}'Pool_Address} returns the address of those bounds,
5975 whereas @code{@var{X}'Address} returns the address of the first
5976 component.
5977
5978 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5979 the object is allocated'', which could be a user-defined storage pool,
5980 the global heap, on the stack, or in a static memory area. For an
5981 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5982 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5983
5984 @node Range_Length
5985 @unnumberedsec Range_Length
5986 @findex Range_Length
5987 @noindent
5988 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5989 the number of values represented by the subtype (zero for a null
5990 range).  The result is static for static subtypes.  @code{Range_Length}
5991 applied to the index subtype of a one dimensional array always gives the
5992 same result as @code{Range} applied to the array itself.
5993
5994 @node Safe_Emax
5995 @unnumberedsec Safe_Emax
5996 @cindex Ada 83 attributes
5997 @findex Safe_Emax
5998 @noindent
5999 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6000 the Ada 83 reference manual for an exact description of the semantics of
6001 this attribute.
6002
6003 @node Safe_Large
6004 @unnumberedsec Safe_Large
6005 @cindex Ada 83 attributes
6006 @findex Safe_Large
6007 @noindent
6008 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6009 the Ada 83 reference manual for an exact description of the semantics of
6010 this attribute.
6011
6012 @node Small
6013 @unnumberedsec Small
6014 @cindex Ada 83 attributes
6015 @findex Small
6016 @noindent
6017 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6018 fixed-point types.
6019 GNAT also allows this attribute to be applied to floating-point types
6020 for compatibility with Ada 83.  See
6021 the Ada 83 reference manual for an exact description of the semantics of
6022 this attribute when applied to floating-point types.
6023
6024 @node Storage_Unit
6025 @unnumberedsec Storage_Unit
6026 @findex Storage_Unit
6027 @noindent
6028 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6029 prefix) provides the same value as @code{System.Storage_Unit}.
6030
6031 @node Stub_Type
6032 @unnumberedsec Stub_Type
6033 @findex Stub_Type
6034 @noindent
6035 The GNAT implementation of remote access-to-classwide types is
6036 organized as described in AARM section E.4 (20.t): a value of an RACW type
6037 (designating a remote object) is represented as a normal access
6038 value, pointing to a "stub" object which in turn contains the
6039 necessary information to contact the designated remote object. A
6040 call on any dispatching operation of such a stub object does the
6041 remote call, if necessary, using the information in the stub object
6042 to locate the target partition, etc.
6043
6044 For a prefix @code{T} that denotes a remote access-to-classwide type,
6045 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6046
6047 By construction, the layout of @code{T'Stub_Type} is identical to that of
6048 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6049 unit @code{System.Partition_Interface}. Use of this attribute will create
6050 an implicit dependency on this unit.
6051
6052 @node Target_Name
6053 @unnumberedsec Target_Name
6054 @findex Target_Name
6055 @noindent
6056 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6057 prefix) provides a static string value that identifies the target
6058 for the current compilation. For GCC implementations, this is the
6059 standard gcc target name without the terminating slash (for
6060 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6061
6062 @node Tick
6063 @unnumberedsec Tick
6064 @findex Tick
6065 @noindent
6066 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6067 provides the same value as @code{System.Tick},
6068
6069 @node To_Address
6070 @unnumberedsec To_Address
6071 @findex To_Address
6072 @noindent
6073 The @code{System'To_Address}
6074 (@code{System} is the only permissible prefix)
6075 denotes a function identical to
6076 @code{System.Storage_Elements.To_Address} except that
6077 it is a static attribute.  This means that if its argument is
6078 a static expression, then the result of the attribute is a
6079 static expression.  The result is that such an expression can be
6080 used in contexts (e.g.@: preelaborable packages) which require a
6081 static expression and where the function call could not be used
6082 (since the function call is always non-static, even if its
6083 argument is static).
6084
6085 @node Type_Class
6086 @unnumberedsec Type_Class
6087 @findex Type_Class
6088 @noindent
6089 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6090 the value of the type class for the full type of @var{type}.  If
6091 @var{type} is a generic formal type, the value is the value for the
6092 corresponding actual subtype.  The value of this attribute is of type
6093 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6094
6095 @smallexample @c ada
6096   type Type_Class is
6097     (Type_Class_Enumeration,
6098      Type_Class_Integer,
6099      Type_Class_Fixed_Point,
6100      Type_Class_Floating_Point,
6101      Type_Class_Array,
6102      Type_Class_Record,
6103      Type_Class_Access,
6104      Type_Class_Task,
6105      Type_Class_Address);
6106 @end smallexample
6107
6108 @noindent
6109 Protected types yield the value @code{Type_Class_Task}, which thus
6110 applies to all concurrent types.  This attribute is designed to
6111 be compatible with the DEC Ada 83 attribute of the same name.
6112
6113 @node UET_Address
6114 @unnumberedsec UET_Address
6115 @findex UET_Address
6116 @noindent
6117 The @code{UET_Address} attribute can only be used for a prefix which
6118 denotes a library package.  It yields the address of the unit exception
6119 table when zero cost exception handling is used.  This attribute is
6120 intended only for use within the GNAT implementation.  See the unit
6121 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6122 for details on how this attribute is used in the implementation.
6123
6124 @node Unconstrained_Array
6125 @unnumberedsec Unconstrained_Array
6126 @findex Unconstrained_Array
6127 @noindent
6128 The @code{Unconstrained_Array} attribute can be used with a prefix that
6129 denotes any type or subtype. It is a static attribute that yields
6130 @code{True} if the prefix designates an unconstrained array,
6131 and @code{False} otherwise. In a generic instance, the result is
6132 still static, and yields the result of applying this test to the
6133 generic actual.
6134
6135 @node Universal_Literal_String
6136 @unnumberedsec Universal_Literal_String
6137 @cindex Named numbers, representation of
6138 @findex Universal_Literal_String
6139 @noindent
6140 The prefix of @code{Universal_Literal_String} must be a named
6141 number.  The static result is the string consisting of the characters of
6142 the number as defined in the original source.  This allows the user
6143 program to access the actual text of named numbers without intermediate
6144 conversions and without the need to enclose the strings in quotes (which
6145 would preclude their use as numbers).  This is used internally for the
6146 construction of values of the floating-point attributes from the file
6147 @file{ttypef.ads}, but may also be used by user programs.
6148
6149 For example, the following program prints the first 50 digits of pi:
6150
6151 @smallexample @c ada
6152 with Text_IO; use Text_IO;
6153 with Ada.Numerics;
6154 procedure Pi is
6155 begin
6156    Put (Ada.Numerics.Pi'Universal_Literal_String);
6157 end;
6158 @end smallexample
6159
6160 @node Unrestricted_Access
6161 @unnumberedsec Unrestricted_Access
6162 @cindex @code{Access}, unrestricted
6163 @findex Unrestricted_Access
6164 @noindent
6165 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6166 except that all accessibility and aliased view checks are omitted.  This
6167 is a user-beware attribute.  It is similar to
6168 @code{Address}, for which it is a desirable replacement where the value
6169 desired is an access type.  In other words, its effect is identical to
6170 first applying the @code{Address} attribute and then doing an unchecked
6171 conversion to a desired access type.  In GNAT, but not necessarily in
6172 other implementations, the use of static chains for inner level
6173 subprograms means that @code{Unrestricted_Access} applied to a
6174 subprogram yields a value that can be called as long as the subprogram
6175 is in scope (normal Ada accessibility rules restrict this usage).
6176
6177 It is possible to use @code{Unrestricted_Access} for any type, but care
6178 must be exercised if it is used to create pointers to unconstrained
6179 objects. In this case, the resulting pointer has the same scope as the
6180 context of the attribute, and may not be returned to some enclosing
6181 scope. For instance, a function cannot use @code{Unrestricted_Access}
6182 to create a unconstrained pointer and then return that value to the
6183 caller.
6184
6185 @node VADS_Size
6186 @unnumberedsec VADS_Size
6187 @cindex @code{Size}, VADS compatibility
6188 @findex VADS_Size
6189 @noindent
6190 The @code{'VADS_Size} attribute is intended to make it easier to port
6191 legacy code which relies on the semantics of @code{'Size} as implemented
6192 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6193 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6194 to a predefined or other primitive type with no Size clause yields the
6195 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6196 typical machines).  In addition @code{'VADS_Size} applied to an object
6197 gives the result that would be obtained by applying the attribute to
6198 the corresponding type.
6199
6200 @node Value_Size
6201 @unnumberedsec Value_Size
6202 @cindex @code{Size}, setting for not-first subtype
6203 @findex Value_Size
6204 @code{@var{type}'Value_Size} is the number of bits required to represent
6205 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6206 but, unlike @code{Size}, may be set for non-first subtypes.
6207
6208 @node Wchar_T_Size
6209 @unnumberedsec Wchar_T_Size
6210 @findex Wchar_T_Size
6211 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6212 prefix) provides the size in bits of the C @code{wchar_t} type
6213 primarily for constructing the definition of this type in
6214 package @code{Interfaces.C}.
6215
6216 @node Word_Size
6217 @unnumberedsec Word_Size
6218 @findex Word_Size
6219 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6220 prefix) provides the value @code{System.Word_Size}.
6221
6222 @c ------------------------
6223 @node Implementation Advice
6224 @chapter Implementation Advice
6225 @noindent
6226 The main text of the Ada Reference Manual describes the required
6227 behavior of all Ada compilers, and the GNAT compiler conforms to
6228 these requirements.
6229
6230 In addition, there are sections throughout the Ada Reference Manual headed
6231 by the phrase ``Implementation advice''.  These sections are not normative,
6232 i.e., they do not specify requirements that all compilers must
6233 follow.  Rather they provide advice on generally desirable behavior.  You
6234 may wonder why they are not requirements.  The most typical answer is
6235 that they describe behavior that seems generally desirable, but cannot
6236 be provided on all systems, or which may be undesirable on some systems.
6237
6238 As far as practical, GNAT follows the implementation advice sections in
6239 the Ada Reference Manual.  This chapter contains a table giving the
6240 reference manual section number, paragraph number and several keywords
6241 for each advice.  Each entry consists of the text of the advice followed
6242 by the GNAT interpretation of this advice.  Most often, this simply says
6243 ``followed'', which means that GNAT follows the advice.  However, in a
6244 number of cases, GNAT deliberately deviates from this advice, in which
6245 case the text describes what GNAT does and why.
6246
6247 @cindex Error detection
6248 @unnumberedsec 1.1.3(20): Error Detection
6249 @sp 1
6250 @cartouche
6251 If an implementation detects the use of an unsupported Specialized Needs
6252 Annex feature at run time, it should raise @code{Program_Error} if
6253 feasible.
6254 @end cartouche
6255 Not relevant.  All specialized needs annex features are either supported,
6256 or diagnosed at compile time.
6257
6258 @cindex Child Units
6259 @unnumberedsec 1.1.3(31): Child Units
6260 @sp 1
6261 @cartouche
6262 If an implementation wishes to provide implementation-defined
6263 extensions to the functionality of a language-defined library unit, it
6264 should normally do so by adding children to the library unit.
6265 @end cartouche
6266 Followed.
6267
6268 @cindex Bounded errors
6269 @unnumberedsec 1.1.5(12): Bounded Errors
6270 @sp 1
6271 @cartouche
6272 If an implementation detects a bounded error or erroneous
6273 execution, it should raise @code{Program_Error}.
6274 @end cartouche
6275 Followed in all cases in which the implementation detects a bounded
6276 error or erroneous execution.  Not all such situations are detected at
6277 runtime.
6278
6279 @cindex Pragmas
6280 @unnumberedsec 2.8(16): Pragmas
6281 @sp 1
6282 @cartouche
6283 Normally, implementation-defined pragmas should have no semantic effect
6284 for error-free programs; that is, if the implementation-defined pragmas
6285 are removed from a working program, the program should still be legal,
6286 and should still have the same semantics.
6287 @end cartouche
6288 The following implementation defined pragmas are exceptions to this
6289 rule:
6290
6291 @table @code
6292 @item Abort_Defer
6293 Affects semantics
6294 @item Ada_83
6295 Affects legality
6296 @item Assert
6297 Affects semantics
6298 @item CPP_Class
6299 Affects semantics
6300 @item CPP_Constructor
6301 Affects semantics
6302 @item Debug
6303 Affects semantics
6304 @item Interface_Name
6305 Affects semantics
6306 @item Machine_Attribute
6307 Affects semantics
6308 @item Unimplemented_Unit
6309 Affects legality
6310 @item Unchecked_Union
6311 Affects semantics
6312 @end table
6313
6314 @noindent
6315 In each of the above cases, it is essential to the purpose of the pragma
6316 that this advice not be followed.  For details see the separate section
6317 on implementation defined pragmas.
6318
6319 @unnumberedsec 2.8(17-19): Pragmas
6320 @sp 1
6321 @cartouche
6322 Normally, an implementation should not define pragmas that can
6323 make an illegal program legal, except as follows:
6324 @end cartouche
6325 @sp 1
6326 @cartouche
6327 A pragma used to complete a declaration, such as a pragma @code{Import};
6328 @end cartouche
6329 @sp 1
6330 @cartouche
6331 A pragma used to configure the environment by adding, removing, or
6332 replacing @code{library_items}.
6333 @end cartouche
6334 See response to paragraph 16 of this same section.
6335
6336 @cindex Character Sets
6337 @cindex Alternative Character Sets
6338 @unnumberedsec 3.5.2(5): Alternative Character Sets
6339 @sp 1
6340 @cartouche
6341 If an implementation supports a mode with alternative interpretations
6342 for @code{Character} and @code{Wide_Character}, the set of graphic
6343 characters of @code{Character} should nevertheless remain a proper
6344 subset of the set of graphic characters of @code{Wide_Character}.  Any
6345 character set ``localizations'' should be reflected in the results of
6346 the subprograms defined in the language-defined package
6347 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6348 an alternative interpretation of @code{Character}, the implementation should
6349 also support a corresponding change in what is a legal
6350 @code{identifier_letter}.
6351 @end cartouche
6352 Not all wide character modes follow this advice, in particular the JIS
6353 and IEC modes reflect standard usage in Japan, and in these encoding,
6354 the upper half of the Latin-1 set is not part of the wide-character
6355 subset, since the most significant bit is used for wide character
6356 encoding.  However, this only applies to the external forms.  Internally
6357 there is no such restriction.
6358
6359 @cindex Integer types
6360 @unnumberedsec 3.5.4(28): Integer Types
6361
6362 @sp 1
6363 @cartouche
6364 An implementation should support @code{Long_Integer} in addition to
6365 @code{Integer} if the target machine supports 32-bit (or longer)
6366 arithmetic.  No other named integer subtypes are recommended for package
6367 @code{Standard}.  Instead, appropriate named integer subtypes should be
6368 provided in the library package @code{Interfaces} (see B.2).
6369 @end cartouche
6370 @code{Long_Integer} is supported.  Other standard integer types are supported
6371 so this advice is not fully followed.  These types
6372 are supported for convenient interface to C, and so that all hardware
6373 types of the machine are easily available.
6374 @unnumberedsec 3.5.4(29): Integer Types
6375
6376 @sp 1
6377 @cartouche
6378 An implementation for a two's complement machine should support
6379 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6380 implementation should support a non-binary modules up to @code{Integer'Last}.
6381 @end cartouche
6382 Followed.
6383
6384 @cindex Enumeration values
6385 @unnumberedsec 3.5.5(8): Enumeration Values
6386 @sp 1
6387 @cartouche
6388 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6389 subtype, if the value of the operand does not correspond to the internal
6390 code for any enumeration literal of its type (perhaps due to an
6391 un-initialized variable), then the implementation should raise
6392 @code{Program_Error}.  This is particularly important for enumeration
6393 types with noncontiguous internal codes specified by an
6394 enumeration_representation_clause.
6395 @end cartouche
6396 Followed.
6397
6398 @cindex Float types
6399 @unnumberedsec 3.5.7(17): Float Types
6400 @sp 1
6401 @cartouche
6402 An implementation should support @code{Long_Float} in addition to
6403 @code{Float} if the target machine supports 11 or more digits of
6404 precision.  No other named floating point subtypes are recommended for
6405 package @code{Standard}.  Instead, appropriate named floating point subtypes
6406 should be provided in the library package @code{Interfaces} (see B.2).
6407 @end cartouche
6408 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6409 former provides improved compatibility with other implementations
6410 supporting this type.  The latter corresponds to the highest precision
6411 floating-point type supported by the hardware.  On most machines, this
6412 will be the same as @code{Long_Float}, but on some machines, it will
6413 correspond to the IEEE extended form.  The notable case is all ia32
6414 (x86) implementations, where @code{Long_Long_Float} corresponds to
6415 the 80-bit extended precision format supported in hardware on this
6416 processor.  Note that the 128-bit format on SPARC is not supported,
6417 since this is a software rather than a hardware format.
6418
6419 @cindex Multidimensional arrays
6420 @cindex Arrays, multidimensional
6421 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6422 @sp 1
6423 @cartouche
6424 An implementation should normally represent multidimensional arrays in
6425 row-major order, consistent with the notation used for multidimensional
6426 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6427 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6428 column-major order should be used instead (see B.5, ``Interfacing with
6429 Fortran'').
6430 @end cartouche
6431 Followed.
6432
6433 @findex Duration'Small
6434 @unnumberedsec 9.6(30-31): Duration'Small
6435 @sp 1
6436 @cartouche
6437 Whenever possible in an implementation, the value of @code{Duration'Small}
6438 should be no greater than 100 microseconds.
6439 @end cartouche
6440 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6441
6442 @sp 1
6443 @cartouche
6444 The time base for @code{delay_relative_statements} should be monotonic;
6445 it need not be the same time base as used for @code{Calendar.Clock}.
6446 @end cartouche
6447 Followed.
6448
6449 @unnumberedsec 10.2.1(12): Consistent Representation
6450 @sp 1
6451 @cartouche
6452 In an implementation, a type declared in a pre-elaborated package should
6453 have the same representation in every elaboration of a given version of
6454 the package, whether the elaborations occur in distinct executions of
6455 the same program, or in executions of distinct programs or partitions
6456 that include the given version.
6457 @end cartouche
6458 Followed, except in the case of tagged types.  Tagged types involve
6459 implicit pointers to a local copy of a dispatch table, and these pointers
6460 have representations which thus depend on a particular elaboration of the
6461 package.  It is not easy to see how it would be possible to follow this
6462 advice without severely impacting efficiency of execution.
6463
6464 @cindex Exception information
6465 @unnumberedsec 11.4.1(19): Exception Information
6466 @sp 1
6467 @cartouche
6468 @code{Exception_Message} by default and @code{Exception_Information}
6469 should produce information useful for
6470 debugging.  @code{Exception_Message} should be short, about one
6471 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6472 should not include the
6473 @code{Exception_Name}.  @code{Exception_Information} should include both
6474 the @code{Exception_Name} and the @code{Exception_Message}.
6475 @end cartouche
6476 Followed.  For each exception that doesn't have a specified
6477 @code{Exception_Message}, the compiler generates one containing the location
6478 of the raise statement.  This location has the form ``file:line'', where
6479 file is the short file name (without path information) and line is the line
6480 number in the file.  Note that in the case of the Zero Cost Exception
6481 mechanism, these messages become redundant with the Exception_Information that
6482 contains a full backtrace of the calling sequence, so they are disabled.
6483 To disable explicitly the generation of the source location message, use the
6484 Pragma @code{Discard_Names}.
6485
6486 @cindex Suppression of checks
6487 @cindex Checks, suppression of
6488 @unnumberedsec 11.5(28): Suppression of Checks
6489 @sp 1
6490 @cartouche
6491 The implementation should minimize the code executed for checks that
6492 have been suppressed.
6493 @end cartouche
6494 Followed.
6495
6496 @cindex Representation clauses
6497 @unnumberedsec 13.1 (21-24): Representation Clauses
6498 @sp 1
6499 @cartouche
6500 The recommended level of support for all representation items is
6501 qualified as follows:
6502 @end cartouche
6503 @sp 1
6504 @cartouche
6505 An implementation need not support representation items containing
6506 non-static expressions, except that an implementation should support a
6507 representation item for a given entity if each non-static expression in
6508 the representation item is a name that statically denotes a constant
6509 declared before the entity.
6510 @end cartouche
6511 Followed.  In fact, GNAT goes beyond the recommended level of support
6512 by allowing nonstatic expressions in some representation clauses even
6513 without the need to declare constants initialized with the values of
6514 such expressions.
6515 For example:
6516
6517 @smallexample @c ada
6518   X : Integer;
6519   Y : Float;
6520   for Y'Address use X'Address;>>
6521 @end smallexample
6522
6523
6524 @sp 1
6525 @cartouche
6526 An implementation need not support a specification for the @code{Size}
6527 for a given composite subtype, nor the size or storage place for an
6528 object (including a component) of a given composite subtype, unless the
6529 constraints on the subtype and its composite subcomponents (if any) are
6530 all static constraints.
6531 @end cartouche
6532 Followed.  Size Clauses are not permitted on non-static components, as
6533 described above.
6534
6535 @sp 1
6536 @cartouche
6537 An aliased component, or a component whose type is by-reference, should
6538 always be allocated at an addressable location.
6539 @end cartouche
6540 Followed.
6541
6542 @cindex Packed types
6543 @unnumberedsec 13.2(6-8): Packed Types
6544 @sp 1
6545 @cartouche
6546 If a type is packed, then the implementation should try to minimize
6547 storage allocated to objects of the type, possibly at the expense of
6548 speed of accessing components, subject to reasonable complexity in
6549 addressing calculations.
6550 @end cartouche
6551 @sp 1
6552 @cartouche
6553 The recommended level of support pragma @code{Pack} is:
6554
6555 For a packed record type, the components should be packed as tightly as
6556 possible subject to the Sizes of the component subtypes, and subject to
6557 any @code{record_representation_clause} that applies to the type; the
6558 implementation may, but need not, reorder components or cross aligned
6559 word boundaries to improve the packing.  A component whose @code{Size} is
6560 greater than the word size may be allocated an integral number of words.
6561 @end cartouche
6562 Followed.  Tight packing of arrays is supported for all component sizes
6563 up to 64-bits. If the array component size is 1 (that is to say, if
6564 the component is a boolean type or an enumeration type with two values)
6565 then values of the type are implicitly initialized to zero. This
6566 happens both for objects of the packed type, and for objects that have a
6567 subcomponent of the packed type.
6568
6569 @sp 1
6570 @cartouche
6571 An implementation should support Address clauses for imported
6572 subprograms.
6573 @end cartouche
6574 Followed.
6575 @cindex @code{Address} clauses
6576 @unnumberedsec 13.3(14-19): Address Clauses
6577
6578 @sp 1
6579 @cartouche
6580 For an array @var{X}, @code{@var{X}'Address} should point at the first
6581 component of the array, and not at the array bounds.
6582 @end cartouche
6583 Followed.
6584
6585 @sp 1
6586 @cartouche
6587 The recommended level of support for the @code{Address} attribute is:
6588
6589 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6590 object that is aliased or of a by-reference type, or is an entity whose
6591 @code{Address} has been specified.
6592 @end cartouche
6593 Followed.  A valid address will be produced even if none of those
6594 conditions have been met.  If necessary, the object is forced into
6595 memory to ensure the address is valid.
6596
6597 @sp 1
6598 @cartouche
6599 An implementation should support @code{Address} clauses for imported
6600 subprograms.
6601 @end cartouche
6602 Followed.
6603
6604 @sp 1
6605 @cartouche
6606 Objects (including subcomponents) that are aliased or of a by-reference
6607 type should be allocated on storage element boundaries.
6608 @end cartouche
6609 Followed.
6610
6611 @sp 1
6612 @cartouche
6613 If the @code{Address} of an object is specified, or it is imported or exported,
6614 then the implementation should not perform optimizations based on
6615 assumptions of no aliases.
6616 @end cartouche
6617 Followed.
6618
6619 @cindex @code{Alignment} clauses
6620 @unnumberedsec 13.3(29-35): Alignment Clauses
6621 @sp 1
6622 @cartouche
6623 The recommended level of support for the @code{Alignment} attribute for
6624 subtypes is:
6625
6626 An implementation should support specified Alignments that are factors
6627 and multiples of the number of storage elements per word, subject to the
6628 following:
6629 @end cartouche
6630 Followed.
6631
6632 @sp 1
6633 @cartouche
6634 An implementation need not support specified @code{Alignment}s for
6635 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6636 loaded and stored by available machine instructions.
6637 @end cartouche
6638 Followed.
6639
6640 @sp 1
6641 @cartouche
6642 An implementation need not support specified @code{Alignment}s that are
6643 greater than the maximum @code{Alignment} the implementation ever returns by
6644 default.
6645 @end cartouche
6646 Followed.
6647
6648 @sp 1
6649 @cartouche
6650 The recommended level of support for the @code{Alignment} attribute for
6651 objects is:
6652
6653 Same as above, for subtypes, but in addition:
6654 @end cartouche
6655 Followed.
6656
6657 @sp 1
6658 @cartouche
6659 For stand-alone library-level objects of statically constrained
6660 subtypes, the implementation should support all @code{Alignment}s
6661 supported by the target linker.  For example, page alignment is likely to
6662 be supported for such objects, but not for subtypes.
6663 @end cartouche
6664 Followed.
6665
6666 @cindex @code{Size} clauses
6667 @unnumberedsec 13.3(42-43): Size Clauses
6668 @sp 1
6669 @cartouche
6670 The recommended level of support for the @code{Size} attribute of
6671 objects is:
6672
6673 A @code{Size} clause should be supported for an object if the specified
6674 @code{Size} is at least as large as its subtype's @code{Size}, and
6675 corresponds to a size in storage elements that is a multiple of the
6676 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6677 @end cartouche
6678 Followed.
6679
6680 @unnumberedsec 13.3(50-56): Size Clauses
6681 @sp 1
6682 @cartouche
6683 If the @code{Size} of a subtype is specified, and allows for efficient
6684 independent addressability (see 9.10) on the target architecture, then
6685 the @code{Size} of the following objects of the subtype should equal the
6686 @code{Size} of the subtype:
6687
6688 Aliased objects (including components).
6689 @end cartouche
6690 Followed.
6691
6692 @sp 1
6693 @cartouche
6694 @code{Size} clause on a composite subtype should not affect the
6695 internal layout of components.
6696 @end cartouche
6697 Followed. But note that this can be overridden by use of the implementation
6698 pragma Implicit_Packing in the case of packed arrays.
6699
6700 @sp 1
6701 @cartouche
6702 The recommended level of support for the @code{Size} attribute of subtypes is:
6703 @end cartouche
6704 @sp 1
6705 @cartouche
6706 The @code{Size} (if not specified) of a static discrete or fixed point
6707 subtype should be the number of bits needed to represent each value
6708 belonging to the subtype using an unbiased representation, leaving space
6709 for a sign bit only if the subtype contains negative values.  If such a
6710 subtype is a first subtype, then an implementation should support a
6711 specified @code{Size} for it that reflects this representation.
6712 @end cartouche
6713 Followed.
6714
6715 @sp 1
6716 @cartouche
6717 For a subtype implemented with levels of indirection, the @code{Size}
6718 should include the size of the pointers, but not the size of what they
6719 point at.
6720 @end cartouche
6721 Followed.
6722
6723 @cindex @code{Component_Size} clauses
6724 @unnumberedsec 13.3(71-73): Component Size Clauses
6725 @sp 1
6726 @cartouche
6727 The recommended level of support for the @code{Component_Size}
6728 attribute is:
6729 @end cartouche
6730 @sp 1
6731 @cartouche
6732 An implementation need not support specified @code{Component_Sizes} that are
6733 less than the @code{Size} of the component subtype.
6734 @end cartouche
6735 Followed.
6736
6737 @sp 1
6738 @cartouche
6739 An implementation should support specified @code{Component_Size}s that
6740 are factors and multiples of the word size.  For such
6741 @code{Component_Size}s, the array should contain no gaps between
6742 components.  For other @code{Component_Size}s (if supported), the array
6743 should contain no gaps between components when packing is also
6744 specified; the implementation should forbid this combination in cases
6745 where it cannot support a no-gaps representation.
6746 @end cartouche
6747 Followed.
6748
6749 @cindex Enumeration representation clauses
6750 @cindex Representation clauses, enumeration
6751 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6752 @sp 1
6753 @cartouche
6754 The recommended level of support for enumeration representation clauses
6755 is:
6756
6757 An implementation need not support enumeration representation clauses
6758 for boolean types, but should at minimum support the internal codes in
6759 the range @code{System.Min_Int.System.Max_Int}.
6760 @end cartouche
6761 Followed.
6762
6763 @cindex Record representation clauses
6764 @cindex Representation clauses, records
6765 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6766 @sp 1
6767 @cartouche
6768 The recommended level of support for
6769 @*@code{record_representation_clauses} is:
6770
6771 An implementation should support storage places that can be extracted
6772 with a load, mask, shift sequence of machine code, and set with a load,
6773 shift, mask, store sequence, given the available machine instructions
6774 and run-time model.
6775 @end cartouche
6776 Followed.
6777
6778 @sp 1
6779 @cartouche
6780 A storage place should be supported if its size is equal to the
6781 @code{Size} of the component subtype, and it starts and ends on a
6782 boundary that obeys the @code{Alignment} of the component subtype.
6783 @end cartouche
6784 Followed.
6785
6786 @sp 1
6787 @cartouche
6788 If the default bit ordering applies to the declaration of a given type,
6789 then for a component whose subtype's @code{Size} is less than the word
6790 size, any storage place that does not cross an aligned word boundary
6791 should be supported.
6792 @end cartouche
6793 Followed.
6794
6795 @sp 1
6796 @cartouche
6797 An implementation may reserve a storage place for the tag field of a
6798 tagged type, and disallow other components from overlapping that place.
6799 @end cartouche
6800 Followed.  The storage place for the tag field is the beginning of the tagged
6801 record, and its size is Address'Size.  GNAT will reject an explicit component
6802 clause for the tag field.
6803
6804 @sp 1
6805 @cartouche
6806 An implementation need not support a @code{component_clause} for a
6807 component of an extension part if the storage place is not after the
6808 storage places of all components of the parent type, whether or not
6809 those storage places had been specified.
6810 @end cartouche
6811 Followed.  The above advice on record representation clauses is followed,
6812 and all mentioned features are implemented.
6813
6814 @cindex Storage place attributes
6815 @unnumberedsec 13.5.2(5): Storage Place Attributes
6816 @sp 1
6817 @cartouche
6818 If a component is represented using some form of pointer (such as an
6819 offset) to the actual data of the component, and this data is contiguous
6820 with the rest of the object, then the storage place attributes should
6821 reflect the place of the actual data, not the pointer.  If a component is
6822 allocated discontinuously from the rest of the object, then a warning
6823 should be generated upon reference to one of its storage place
6824 attributes.
6825 @end cartouche
6826 Followed.  There are no such components in GNAT@.
6827
6828 @cindex Bit ordering
6829 @unnumberedsec 13.5.3(7-8): Bit Ordering
6830 @sp 1
6831 @cartouche
6832 The recommended level of support for the non-default bit ordering is:
6833 @end cartouche
6834 @sp 1
6835 @cartouche
6836 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6837 should support the non-default bit ordering in addition to the default
6838 bit ordering.
6839 @end cartouche
6840 Followed.  Word size does not equal storage size in this implementation.
6841 Thus non-default bit ordering is not supported.
6842
6843 @cindex @code{Address}, as private type
6844 @unnumberedsec 13.7(37): Address as Private
6845 @sp 1
6846 @cartouche
6847 @code{Address} should be of a private type.
6848 @end cartouche
6849 Followed.
6850
6851 @cindex Operations, on @code{Address}
6852 @cindex @code{Address}, operations of
6853 @unnumberedsec 13.7.1(16): Address Operations
6854 @sp 1
6855 @cartouche
6856 Operations in @code{System} and its children should reflect the target
6857 environment semantics as closely as is reasonable.  For example, on most
6858 machines, it makes sense for address arithmetic to ``wrap around''.
6859 Operations that do not make sense should raise @code{Program_Error}.
6860 @end cartouche
6861 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6862 operation raises @code{Program_Error}, since all operations make sense.
6863
6864 @cindex Unchecked conversion
6865 @unnumberedsec 13.9(14-17): Unchecked Conversion
6866 @sp 1
6867 @cartouche
6868 The @code{Size} of an array object should not include its bounds; hence,
6869 the bounds should not be part of the converted data.
6870 @end cartouche
6871 Followed.
6872
6873 @sp 1
6874 @cartouche
6875 The implementation should not generate unnecessary run-time checks to
6876 ensure that the representation of @var{S} is a representation of the
6877 target type.  It should take advantage of the permission to return by
6878 reference when possible.  Restrictions on unchecked conversions should be
6879 avoided unless required by the target environment.
6880 @end cartouche
6881 Followed.  There are no restrictions on unchecked conversion.  A warning is
6882 generated if the source and target types do not have the same size since
6883 the semantics in this case may be target dependent.
6884
6885 @sp 1
6886 @cartouche
6887 The recommended level of support for unchecked conversions is:
6888 @end cartouche
6889 @sp 1
6890 @cartouche
6891 Unchecked conversions should be supported and should be reversible in
6892 the cases where this clause defines the result.  To enable meaningful use
6893 of unchecked conversion, a contiguous representation should be used for
6894 elementary subtypes, for statically constrained array subtypes whose
6895 component subtype is one of the subtypes described in this paragraph,
6896 and for record subtypes without discriminants whose component subtypes
6897 are described in this paragraph.
6898 @end cartouche
6899 Followed.
6900
6901 @cindex Heap usage, implicit
6902 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6903 @sp 1
6904 @cartouche
6905 An implementation should document any cases in which it dynamically
6906 allocates heap storage for a purpose other than the evaluation of an
6907 allocator.
6908 @end cartouche
6909 Followed, the only other points at which heap storage is dynamically
6910 allocated are as follows:
6911
6912 @itemize @bullet
6913 @item
6914 At initial elaboration time, to allocate dynamically sized global
6915 objects.
6916
6917 @item
6918 To allocate space for a task when a task is created.
6919
6920 @item
6921 To extend the secondary stack dynamically when needed.  The secondary
6922 stack is used for returning variable length results.
6923 @end itemize
6924
6925 @sp 1
6926 @cartouche
6927 A default (implementation-provided) storage pool for an
6928 access-to-constant type should not have overhead to support deallocation of
6929 individual objects.
6930 @end cartouche
6931 Followed.
6932
6933 @sp 1
6934 @cartouche
6935 A storage pool for an anonymous access type should be created at the
6936 point of an allocator for the type, and be reclaimed when the designated
6937 object becomes inaccessible.
6938 @end cartouche
6939 Followed.
6940
6941 @cindex Unchecked deallocation
6942 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6943 @sp 1
6944 @cartouche
6945 For a standard storage pool, @code{Free} should actually reclaim the
6946 storage.
6947 @end cartouche
6948 Followed.
6949
6950 @cindex Stream oriented attributes
6951 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6952 @sp 1
6953 @cartouche
6954 If a stream element is the same size as a storage element, then the
6955 normal in-memory representation should be used by @code{Read} and
6956 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6957 should use the smallest number of stream elements needed to represent
6958 all values in the base range of the scalar type.
6959 @end cartouche
6960
6961 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6962 which specifies using the size of the first subtype.
6963 However, such an implementation is based on direct binary
6964 representations and is therefore target- and endianness-dependent.
6965 To address this issue, GNAT also supplies an alternate implementation
6966 of the stream attributes @code{Read} and @code{Write},
6967 which uses the target-independent XDR standard representation
6968 for scalar types.
6969 @cindex XDR representation
6970 @cindex @code{Read} attribute
6971 @cindex @code{Write} attribute
6972 @cindex Stream oriented attributes
6973 The XDR implementation is provided as an alternative body of the
6974 @code{System.Stream_Attributes} package, in the file
6975 @file{s-strxdr.adb} in the GNAT library.
6976 There is no @file{s-strxdr.ads} file.
6977 In order to install the XDR implementation, do the following:
6978 @enumerate
6979 @item Replace the default implementation of the
6980 @code{System.Stream_Attributes} package with the XDR implementation.
6981 For example on a Unix platform issue the commands:
6982 @smallexample
6983 $ mv s-stratt.adb s-strold.adb
6984 $ mv s-strxdr.adb s-stratt.adb
6985 @end smallexample
6986
6987 @item
6988 Rebuild the GNAT run-time library as documented in
6989 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6990 @end enumerate
6991
6992 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6993 @sp 1
6994 @cartouche
6995 If an implementation provides additional named predefined integer types,
6996 then the names should end with @samp{Integer} as in
6997 @samp{Long_Integer}.  If an implementation provides additional named
6998 predefined floating point types, then the names should end with
6999 @samp{Float} as in @samp{Long_Float}.
7000 @end cartouche
7001 Followed.
7002
7003 @findex Ada.Characters.Handling
7004 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7005 @sp 1
7006 @cartouche
7007 If an implementation provides a localized definition of @code{Character}
7008 or @code{Wide_Character}, then the effects of the subprograms in
7009 @code{Characters.Handling} should reflect the localizations.  See also
7010 3.5.2.
7011 @end cartouche
7012 Followed.  GNAT provides no such localized definitions.
7013
7014 @cindex Bounded-length strings
7015 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7016 @sp 1
7017 @cartouche
7018 Bounded string objects should not be implemented by implicit pointers
7019 and dynamic allocation.
7020 @end cartouche
7021 Followed.  No implicit pointers or dynamic allocation are used.
7022
7023 @cindex Random number generation
7024 @unnumberedsec A.5.2(46-47): Random Number Generation
7025 @sp 1
7026 @cartouche
7027 Any storage associated with an object of type @code{Generator} should be
7028 reclaimed on exit from the scope of the object.
7029 @end cartouche
7030 Followed.
7031
7032 @sp 1
7033 @cartouche
7034 If the generator period is sufficiently long in relation to the number
7035 of distinct initiator values, then each possible value of
7036 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7037 random numbers that does not, in a practical sense, overlap the sequence
7038 initiated by any other value.  If this is not possible, then the mapping
7039 between initiator values and generator states should be a rapidly
7040 varying function of the initiator value.
7041 @end cartouche
7042 Followed.  The generator period is sufficiently long for the first
7043 condition here to hold true.
7044
7045 @findex Get_Immediate
7046 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7047 @sp 1
7048 @cartouche
7049 The @code{Get_Immediate} procedures should be implemented with
7050 unbuffered input.  For a device such as a keyboard, input should be
7051 @dfn{available} if a key has already been typed, whereas for a disk
7052 file, input should always be available except at end of file.  For a file
7053 associated with a keyboard-like device, any line-editing features of the
7054 underlying operating system should be disabled during the execution of
7055 @code{Get_Immediate}.
7056 @end cartouche
7057 Followed on all targets except VxWorks. For VxWorks, there is no way to
7058 provide this functionality that does not result in the input buffer being
7059 flushed before the @code{Get_Immediate} call. A special unit
7060 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7061 this functionality.
7062
7063 @findex Export
7064 @unnumberedsec B.1(39-41): Pragma @code{Export}
7065 @sp 1
7066 @cartouche
7067 If an implementation supports pragma @code{Export} to a given language,
7068 then it should also allow the main subprogram to be written in that
7069 language.  It should support some mechanism for invoking the elaboration
7070 of the Ada library units included in the system, and for invoking the
7071 finalization of the environment task.  On typical systems, the
7072 recommended mechanism is to provide two subprograms whose link names are
7073 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7074 elaboration code for library units.  @code{adafinal} should contain the
7075 finalization code.  These subprograms should have no effect the second
7076 and subsequent time they are called.
7077 @end cartouche
7078 Followed.
7079
7080 @sp 1
7081 @cartouche
7082 Automatic elaboration of pre-elaborated packages should be
7083 provided when pragma @code{Export} is supported.
7084 @end cartouche
7085 Followed when the main program is in Ada.  If the main program is in a
7086 foreign language, then
7087 @code{adainit} must be called to elaborate pre-elaborated
7088 packages.
7089
7090 @sp 1
7091 @cartouche
7092 For each supported convention @var{L} other than @code{Intrinsic}, an
7093 implementation should support @code{Import} and @code{Export} pragmas
7094 for objects of @var{L}-compatible types and for subprograms, and pragma
7095 @code{Convention} for @var{L}-eligible types and for subprograms,
7096 presuming the other language has corresponding features.  Pragma
7097 @code{Convention} need not be supported for scalar types.
7098 @end cartouche
7099 Followed.
7100
7101 @cindex Package @code{Interfaces}
7102 @findex Interfaces
7103 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7104 @sp 1
7105 @cartouche
7106 For each implementation-defined convention identifier, there should be a
7107 child package of package Interfaces with the corresponding name.  This
7108 package should contain any declarations that would be useful for
7109 interfacing to the language (implementation) represented by the
7110 convention.  Any declarations useful for interfacing to any language on
7111 the given hardware architecture should be provided directly in
7112 @code{Interfaces}.
7113 @end cartouche
7114 Followed. An additional package not defined
7115 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7116 for interfacing to C++.
7117
7118 @sp 1
7119 @cartouche
7120 An implementation supporting an interface to C, COBOL, or Fortran should
7121 provide the corresponding package or packages described in the following
7122 clauses.
7123 @end cartouche
7124 Followed.  GNAT provides all the packages described in this section.
7125
7126 @cindex C, interfacing with
7127 @unnumberedsec B.3(63-71): Interfacing with C
7128 @sp 1
7129 @cartouche
7130 An implementation should support the following interface correspondences
7131 between Ada and C@.
7132 @end cartouche
7133 Followed.
7134
7135 @sp 1
7136 @cartouche
7137 An Ada procedure corresponds to a void-returning C function.
7138 @end cartouche
7139 Followed.
7140
7141 @sp 1
7142 @cartouche
7143 An Ada function corresponds to a non-void C function.
7144 @end cartouche
7145 Followed.
7146
7147 @sp 1
7148 @cartouche
7149 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7150 function.
7151 @end cartouche
7152 Followed.
7153
7154 @sp 1
7155 @cartouche
7156 An Ada @code{in} parameter of an access-to-object type with designated
7157 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7158 where @var{t} is the C type corresponding to the Ada type @var{T}.
7159 @end cartouche
7160 Followed.
7161
7162 @sp 1
7163 @cartouche
7164 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7165 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7166 argument to a C function, where @var{t} is the C type corresponding to
7167 the Ada type @var{T}.  In the case of an elementary @code{out} or
7168 @code{in out} parameter, a pointer to a temporary copy is used to
7169 preserve by-copy semantics.
7170 @end cartouche
7171 Followed.
7172
7173 @sp 1
7174 @cartouche
7175 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7176 @code{@var{t}*} argument to a C function, where @var{t} is the C
7177 structure corresponding to the Ada type @var{T}.
7178 @end cartouche
7179 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7180 pragma, or Convention, or by explicitly specifying the mechanism for a given
7181 call using an extended import or export pragma.
7182
7183 @sp 1
7184 @cartouche
7185 An Ada parameter of an array type with component type @var{T}, of any
7186 mode, is passed as a @code{@var{t}*} argument to a C function, where
7187 @var{t} is the C type corresponding to the Ada type @var{T}.
7188 @end cartouche
7189 Followed.
7190
7191 @sp 1
7192 @cartouche
7193 An Ada parameter of an access-to-subprogram type is passed as a pointer
7194 to a C function whose prototype corresponds to the designated
7195 subprogram's specification.
7196 @end cartouche
7197 Followed.
7198
7199 @cindex COBOL, interfacing with
7200 @unnumberedsec B.4(95-98): Interfacing with COBOL
7201 @sp 1
7202 @cartouche
7203 An Ada implementation should support the following interface
7204 correspondences between Ada and COBOL@.
7205 @end cartouche
7206 Followed.
7207
7208 @sp 1
7209 @cartouche
7210 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7211 the COBOL type corresponding to @var{T}.
7212 @end cartouche
7213 Followed.
7214
7215 @sp 1
7216 @cartouche
7217 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7218 the corresponding COBOL type.
7219 @end cartouche
7220 Followed.
7221
7222 @sp 1
7223 @cartouche
7224 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7225 COBOL type corresponding to the Ada parameter type; for scalars, a local
7226 copy is used if necessary to ensure by-copy semantics.
7227 @end cartouche
7228 Followed.
7229
7230 @cindex Fortran, interfacing with
7231 @unnumberedsec B.5(22-26): Interfacing with Fortran
7232 @sp 1
7233 @cartouche
7234 An Ada implementation should support the following interface
7235 correspondences between Ada and Fortran:
7236 @end cartouche
7237 Followed.
7238
7239 @sp 1
7240 @cartouche
7241 An Ada procedure corresponds to a Fortran subroutine.
7242 @end cartouche
7243 Followed.
7244
7245 @sp 1
7246 @cartouche
7247 An Ada function corresponds to a Fortran function.
7248 @end cartouche
7249 Followed.
7250
7251 @sp 1
7252 @cartouche
7253 An Ada parameter of an elementary, array, or record type @var{T} is
7254 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7255 the Fortran type corresponding to the Ada type @var{T}, and where the
7256 INTENT attribute of the corresponding dummy argument matches the Ada
7257 formal parameter mode; the Fortran implementation's parameter passing
7258 conventions are used.  For elementary types, a local copy is used if
7259 necessary to ensure by-copy semantics.
7260 @end cartouche
7261 Followed.
7262
7263 @sp 1
7264 @cartouche
7265 An Ada parameter of an access-to-subprogram type is passed as a
7266 reference to a Fortran procedure whose interface corresponds to the
7267 designated subprogram's specification.
7268 @end cartouche
7269 Followed.
7270
7271 @cindex Machine operations
7272 @unnumberedsec C.1(3-5): Access to Machine Operations
7273 @sp 1
7274 @cartouche
7275 The machine code or intrinsic support should allow access to all
7276 operations normally available to assembly language programmers for the
7277 target environment, including privileged instructions, if any.
7278 @end cartouche
7279 Followed.
7280
7281 @sp 1
7282 @cartouche
7283 The interfacing pragmas (see Annex B) should support interface to
7284 assembler; the default assembler should be associated with the
7285 convention identifier @code{Assembler}.
7286 @end cartouche
7287 Followed.
7288
7289 @sp 1
7290 @cartouche
7291 If an entity is exported to assembly language, then the implementation
7292 should allocate it at an addressable location, and should ensure that it
7293 is retained by the linking process, even if not otherwise referenced
7294 from the Ada code.  The implementation should assume that any call to a
7295 machine code or assembler subprogram is allowed to read or update every
7296 object that is specified as exported.
7297 @end cartouche
7298 Followed.
7299
7300 @unnumberedsec C.1(10-16): Access to Machine Operations
7301 @sp 1
7302 @cartouche
7303 The implementation should ensure that little or no overhead is
7304 associated with calling intrinsic and machine-code subprograms.
7305 @end cartouche
7306 Followed for both intrinsics and machine-code subprograms.
7307
7308 @sp 1
7309 @cartouche
7310 It is recommended that intrinsic subprograms be provided for convenient
7311 access to any machine operations that provide special capabilities or
7312 efficiency and that are not otherwise available through the language
7313 constructs.
7314 @end cartouche
7315 Followed.  A full set of machine operation intrinsic subprograms is provided.
7316
7317 @sp 1
7318 @cartouche
7319 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7320 swap, decrement and test, enqueue/dequeue.
7321 @end cartouche
7322 Followed on any target supporting such operations.
7323
7324 @sp 1
7325 @cartouche
7326 Standard numeric functions---e.g.@:, sin, log.
7327 @end cartouche
7328 Followed on any target supporting such operations.
7329
7330 @sp 1
7331 @cartouche
7332 String manipulation operations---e.g.@:, translate and test.
7333 @end cartouche
7334 Followed on any target supporting such operations.
7335
7336 @sp 1
7337 @cartouche
7338 Vector operations---e.g.@:, compare vector against thresholds.
7339 @end cartouche
7340 Followed on any target supporting such operations.
7341
7342 @sp 1
7343 @cartouche
7344 Direct operations on I/O ports.
7345 @end cartouche
7346 Followed on any target supporting such operations.
7347
7348 @cindex Interrupt support
7349 @unnumberedsec C.3(28): Interrupt Support
7350 @sp 1
7351 @cartouche
7352 If the @code{Ceiling_Locking} policy is not in effect, the
7353 implementation should provide means for the application to specify which
7354 interrupts are to be blocked during protected actions, if the underlying
7355 system allows for a finer-grain control of interrupt blocking.
7356 @end cartouche
7357 Followed.  The underlying system does not allow for finer-grain control
7358 of interrupt blocking.
7359
7360 @cindex Protected procedure handlers
7361 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7362 @sp 1
7363 @cartouche
7364 Whenever possible, the implementation should allow interrupt handlers to
7365 be called directly by the hardware.
7366 @end cartouche
7367 @c SGI info:
7368 @ignore
7369 This is never possible under IRIX, so this is followed by default.
7370 @end ignore
7371 Followed on any target where the underlying operating system permits
7372 such direct calls.
7373
7374 @sp 1
7375 @cartouche
7376 Whenever practical, violations of any
7377 implementation-defined restrictions should be detected before run time.
7378 @end cartouche
7379 Followed.  Compile time warnings are given when possible.
7380
7381 @cindex Package @code{Interrupts}
7382 @findex Interrupts
7383 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7384
7385 @sp 1
7386 @cartouche
7387 If implementation-defined forms of interrupt handler procedures are
7388 supported, such as protected procedures with parameters, then for each
7389 such form of a handler, a type analogous to @code{Parameterless_Handler}
7390 should be specified in a child package of @code{Interrupts}, with the
7391 same operations as in the predefined package Interrupts.
7392 @end cartouche
7393 Followed.
7394
7395 @cindex Pre-elaboration requirements
7396 @unnumberedsec C.4(14): Pre-elaboration Requirements
7397 @sp 1
7398 @cartouche
7399 It is recommended that pre-elaborated packages be implemented in such a
7400 way that there should be little or no code executed at run time for the
7401 elaboration of entities not already covered by the Implementation
7402 Requirements.
7403 @end cartouche
7404 Followed.  Executable code is generated in some cases, e.g.@: loops
7405 to initialize large arrays.
7406
7407 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7408
7409 @sp 1
7410 @cartouche
7411 If the pragma applies to an entity, then the implementation should
7412 reduce the amount of storage used for storing names associated with that
7413 entity.
7414 @end cartouche
7415 Followed.
7416
7417 @cindex Package @code{Task_Attributes}
7418 @findex Task_Attributes
7419 @unnumberedsec C.7.2(30): The Package Task_Attributes
7420 @sp 1
7421 @cartouche
7422 Some implementations are targeted to domains in which memory use at run
7423 time must be completely deterministic.  For such implementations, it is
7424 recommended that the storage for task attributes will be pre-allocated
7425 statically and not from the heap.  This can be accomplished by either
7426 placing restrictions on the number and the size of the task's
7427 attributes, or by using the pre-allocated storage for the first @var{N}
7428 attribute objects, and the heap for the others.  In the latter case,
7429 @var{N} should be documented.
7430 @end cartouche
7431 Not followed.  This implementation is not targeted to such a domain.
7432
7433 @cindex Locking Policies
7434 @unnumberedsec D.3(17): Locking Policies
7435
7436 @sp 1
7437 @cartouche
7438 The implementation should use names that end with @samp{_Locking} for
7439 locking policies defined by the implementation.
7440 @end cartouche
7441 Followed.  A single implementation-defined locking policy is defined,
7442 whose name (@code{Inheritance_Locking}) follows this suggestion.
7443
7444 @cindex Entry queuing policies
7445 @unnumberedsec D.4(16): Entry Queuing Policies
7446 @sp 1
7447 @cartouche
7448 Names that end with @samp{_Queuing} should be used
7449 for all implementation-defined queuing policies.
7450 @end cartouche
7451 Followed.  No such implementation-defined queuing policies exist.
7452
7453 @cindex Preemptive abort
7454 @unnumberedsec D.6(9-10): Preemptive Abort
7455 @sp 1
7456 @cartouche
7457 Even though the @code{abort_statement} is included in the list of
7458 potentially blocking operations (see 9.5.1), it is recommended that this
7459 statement be implemented in a way that never requires the task executing
7460 the @code{abort_statement} to block.
7461 @end cartouche
7462 Followed.
7463
7464 @sp 1
7465 @cartouche
7466 On a multi-processor, the delay associated with aborting a task on
7467 another processor should be bounded; the implementation should use
7468 periodic polling, if necessary, to achieve this.
7469 @end cartouche
7470 Followed.
7471
7472 @cindex Tasking restrictions
7473 @unnumberedsec D.7(21): Tasking Restrictions
7474 @sp 1
7475 @cartouche
7476 When feasible, the implementation should take advantage of the specified
7477 restrictions to produce a more efficient implementation.
7478 @end cartouche
7479 GNAT currently takes advantage of these restrictions by providing an optimized
7480 run time when the Ravenscar profile and the GNAT restricted run time set
7481 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7482 pragma @code{Profile (Restricted)} for more details.
7483
7484 @cindex Time, monotonic
7485 @unnumberedsec D.8(47-49): Monotonic Time
7486 @sp 1
7487 @cartouche
7488 When appropriate, implementations should provide configuration
7489 mechanisms to change the value of @code{Tick}.
7490 @end cartouche
7491 Such configuration mechanisms are not appropriate to this implementation
7492 and are thus not supported.
7493
7494 @sp 1
7495 @cartouche
7496 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7497 be implemented as transformations of the same time base.
7498 @end cartouche
7499 Followed.
7500
7501 @sp 1
7502 @cartouche
7503 It is recommended that the @dfn{best} time base which exists in
7504 the underlying system be available to the application through
7505 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7506 @end cartouche
7507 Followed.
7508
7509 @cindex Partition communication subsystem
7510 @cindex PCS
7511 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7512 @sp 1
7513 @cartouche
7514 Whenever possible, the PCS on the called partition should allow for
7515 multiple tasks to call the RPC-receiver with different messages and
7516 should allow them to block until the corresponding subprogram body
7517 returns.
7518 @end cartouche
7519 Followed by GLADE, a separately supplied PCS that can be used with
7520 GNAT.
7521
7522 @sp 1
7523 @cartouche
7524 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7525 should raise @code{Storage_Error} if it runs out of space trying to
7526 write the @code{Item} into the stream.
7527 @end cartouche
7528 Followed by GLADE, a separately supplied PCS that can be used with
7529 GNAT@.
7530
7531 @cindex COBOL support
7532 @unnumberedsec F(7): COBOL Support
7533 @sp 1
7534 @cartouche
7535 If COBOL (respectively, C) is widely supported in the target
7536 environment, implementations supporting the Information Systems Annex
7537 should provide the child package @code{Interfaces.COBOL} (respectively,
7538 @code{Interfaces.C}) specified in Annex B and should support a
7539 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7540 pragmas (see Annex B), thus allowing Ada programs to interface with
7541 programs written in that language.
7542 @end cartouche
7543 Followed.
7544
7545 @cindex Decimal radix support
7546 @unnumberedsec F.1(2): Decimal Radix Support
7547 @sp 1
7548 @cartouche
7549 Packed decimal should be used as the internal representation for objects
7550 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7551 @end cartouche
7552 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7553 representations.
7554
7555 @cindex Numerics
7556 @unnumberedsec G: Numerics
7557 @sp 2
7558 @cartouche
7559 If Fortran (respectively, C) is widely supported in the target
7560 environment, implementations supporting the Numerics Annex
7561 should provide the child package @code{Interfaces.Fortran} (respectively,
7562 @code{Interfaces.C}) specified in Annex B and should support a
7563 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7564 pragmas (see Annex B), thus allowing Ada programs to interface with
7565 programs written in that language.
7566 @end cartouche
7567 Followed.
7568
7569 @cindex Complex types
7570 @unnumberedsec G.1.1(56-58): Complex Types
7571 @sp 2
7572 @cartouche
7573 Because the usual mathematical meaning of multiplication of a complex
7574 operand and a real operand is that of the scaling of both components of
7575 the former by the latter, an implementation should not perform this
7576 operation by first promoting the real operand to complex type and then
7577 performing a full complex multiplication.  In systems that, in the
7578 future, support an Ada binding to IEC 559:1989, the latter technique
7579 will not generate the required result when one of the components of the
7580 complex operand is infinite.  (Explicit multiplication of the infinite
7581 component by the zero component obtained during promotion yields a NaN
7582 that propagates into the final result.) Analogous advice applies in the
7583 case of multiplication of a complex operand and a pure-imaginary
7584 operand, and in the case of division of a complex operand by a real or
7585 pure-imaginary operand.
7586 @end cartouche
7587 Not followed.
7588
7589 @sp 1
7590 @cartouche
7591 Similarly, because the usual mathematical meaning of addition of a
7592 complex operand and a real operand is that the imaginary operand remains
7593 unchanged, an implementation should not perform this operation by first
7594 promoting the real operand to complex type and then performing a full
7595 complex addition.  In implementations in which the @code{Signed_Zeros}
7596 attribute of the component type is @code{True} (and which therefore
7597 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7598 predefined arithmetic operations), the latter technique will not
7599 generate the required result when the imaginary component of the complex
7600 operand is a negatively signed zero.  (Explicit addition of the negative
7601 zero to the zero obtained during promotion yields a positive zero.)
7602 Analogous advice applies in the case of addition of a complex operand
7603 and a pure-imaginary operand, and in the case of subtraction of a
7604 complex operand and a real or pure-imaginary operand.
7605 @end cartouche
7606 Not followed.
7607
7608 @sp 1
7609 @cartouche
7610 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7611 attempt to provide a rational treatment of the signs of zero results and
7612 result components.  As one example, the result of the @code{Argument}
7613 function should have the sign of the imaginary component of the
7614 parameter @code{X} when the point represented by that parameter lies on
7615 the positive real axis; as another, the sign of the imaginary component
7616 of the @code{Compose_From_Polar} function should be the same as
7617 (respectively, the opposite of) that of the @code{Argument} parameter when that
7618 parameter has a value of zero and the @code{Modulus} parameter has a
7619 nonnegative (respectively, negative) value.
7620 @end cartouche
7621 Followed.
7622
7623 @cindex Complex elementary functions
7624 @unnumberedsec G.1.2(49): Complex Elementary Functions
7625 @sp 1
7626 @cartouche
7627 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7628 @code{True} should attempt to provide a rational treatment of the signs
7629 of zero results and result components.  For example, many of the complex
7630 elementary functions have components that are odd functions of one of
7631 the parameter components; in these cases, the result component should
7632 have the sign of the parameter component at the origin.  Other complex
7633 elementary functions have zero components whose sign is opposite that of
7634 a parameter component at the origin, or is always positive or always
7635 negative.
7636 @end cartouche
7637 Followed.
7638
7639 @cindex Accuracy requirements
7640 @unnumberedsec G.2.4(19): Accuracy Requirements
7641 @sp 1
7642 @cartouche
7643 The versions of the forward trigonometric functions without a
7644 @code{Cycle} parameter should not be implemented by calling the
7645 corresponding version with a @code{Cycle} parameter of
7646 @code{2.0*Numerics.Pi}, since this will not provide the required
7647 accuracy in some portions of the domain.  For the same reason, the
7648 version of @code{Log} without a @code{Base} parameter should not be
7649 implemented by calling the corresponding version with a @code{Base}
7650 parameter of @code{Numerics.e}.
7651 @end cartouche
7652 Followed.
7653
7654 @cindex Complex arithmetic accuracy
7655 @cindex Accuracy, complex arithmetic
7656 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7657
7658 @sp 1
7659 @cartouche
7660 The version of the @code{Compose_From_Polar} function without a
7661 @code{Cycle} parameter should not be implemented by calling the
7662 corresponding version with a @code{Cycle} parameter of
7663 @code{2.0*Numerics.Pi}, since this will not provide the required
7664 accuracy in some portions of the domain.
7665 @end cartouche
7666 Followed.
7667
7668 @c -----------------------------------------
7669 @node Implementation Defined Characteristics
7670 @chapter Implementation Defined Characteristics
7671
7672 @noindent
7673 In addition to the implementation dependent pragmas and attributes, and
7674 the implementation advice, there are a number of other Ada features
7675 that are potentially implementation dependent.  These are mentioned
7676 throughout the Ada Reference Manual, and are summarized in annex M@.
7677
7678 A requirement for conforming Ada compilers is that they provide
7679 documentation describing how the implementation deals with each of these
7680 issues.  In this chapter, you will find each point in annex M listed
7681 followed by a description in italic font of how GNAT
7682 @c SGI info:
7683 @ignore
7684 in the ProDev Ada
7685 implementation on IRIX 5.3 operating system or greater
7686 @end ignore
7687 handles the implementation dependence.
7688
7689 You can use this chapter as a guide to minimizing implementation
7690 dependent features in your programs if portability to other compilers
7691 and other operating systems is an important consideration.  The numbers
7692 in each section below correspond to the paragraph number in the Ada
7693 Reference Manual.
7694
7695 @sp 1
7696 @cartouche
7697 @noindent
7698 @strong{2}.  Whether or not each recommendation given in Implementation
7699 Advice is followed.  See 1.1.2(37).
7700 @end cartouche
7701 @noindent
7702 @xref{Implementation Advice}.
7703
7704 @sp 1
7705 @cartouche
7706 @noindent
7707 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7708 @end cartouche
7709 @noindent
7710 The complexity of programs that can be processed is limited only by the
7711 total amount of available virtual memory, and disk space for the
7712 generated object files.
7713
7714 @sp 1
7715 @cartouche
7716 @noindent
7717 @strong{4}.  Variations from the standard that are impractical to avoid
7718 given the implementation's execution environment.  See 1.1.3(6).
7719 @end cartouche
7720 @noindent
7721 There are no variations from the standard.
7722
7723 @sp 1
7724 @cartouche
7725 @noindent
7726 @strong{5}.  Which @code{code_statement}s cause external
7727 interactions.  See 1.1.3(10).
7728 @end cartouche
7729 @noindent
7730 Any @code{code_statement} can potentially cause external interactions.
7731
7732 @sp 1
7733 @cartouche
7734 @noindent
7735 @strong{6}.  The coded representation for the text of an Ada
7736 program.  See 2.1(4).
7737 @end cartouche
7738 @noindent
7739 See separate section on source representation.
7740
7741 @sp 1
7742 @cartouche
7743 @noindent
7744 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7745 @end cartouche
7746 @noindent
7747 See separate section on source representation.
7748
7749 @sp 1
7750 @cartouche
7751 @noindent
7752 @strong{8}.  The representation for an end of line.  See 2.2(2).
7753 @end cartouche
7754 @noindent
7755 See separate section on source representation.
7756
7757 @sp 1
7758 @cartouche
7759 @noindent
7760 @strong{9}.  Maximum supported line length and lexical element
7761 length.  See 2.2(15).
7762 @end cartouche
7763 @noindent
7764 The maximum line length is 255 characters and the maximum length of a
7765 lexical element is also 255 characters.
7766
7767 @sp 1
7768 @cartouche
7769 @noindent
7770 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7771 @end cartouche
7772 @noindent
7773
7774 @xref{Implementation Defined Pragmas}.
7775
7776 @sp 1
7777 @cartouche
7778 @noindent
7779 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7780 @end cartouche
7781 @noindent
7782 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7783 parameter, checks that the optimization flag is set, and aborts if it is
7784 not.
7785
7786 @sp 1
7787 @cartouche
7788 @noindent
7789 @strong{12}.  The sequence of characters of the value returned by
7790 @code{@var{S}'Image} when some of the graphic characters of
7791 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7792 3.5(37).
7793 @end cartouche
7794 @noindent
7795 The sequence of characters is as defined by the wide character encoding
7796 method used for the source.  See section on source representation for
7797 further details.
7798
7799 @sp 1
7800 @cartouche
7801 @noindent
7802 @strong{13}.  The predefined integer types declared in
7803 @code{Standard}.  See 3.5.4(25).
7804 @end cartouche
7805 @noindent
7806 @table @code
7807 @item Short_Short_Integer
7808 8 bit signed
7809 @item Short_Integer
7810 (Short) 16 bit signed
7811 @item Integer
7812 32 bit signed
7813 @item Long_Integer
7814 64 bit signed (Alpha OpenVMS only)
7815 32 bit signed (all other targets)
7816 @item Long_Long_Integer
7817 64 bit signed
7818 @end table
7819
7820 @sp 1
7821 @cartouche
7822 @noindent
7823 @strong{14}.  Any nonstandard integer types and the operators defined
7824 for them.  See 3.5.4(26).
7825 @end cartouche
7826 @noindent
7827 There are no nonstandard integer types.
7828
7829 @sp 1
7830 @cartouche
7831 @noindent
7832 @strong{15}.  Any nonstandard real types and the operators defined for
7833 them.  See 3.5.6(8).
7834 @end cartouche
7835 @noindent
7836 There are no nonstandard real types.
7837
7838 @sp 1
7839 @cartouche
7840 @noindent
7841 @strong{16}.  What combinations of requested decimal precision and range
7842 are supported for floating point types.  See 3.5.7(7).
7843 @end cartouche
7844 @noindent
7845 The precision and range is as defined by the IEEE standard.
7846
7847 @sp 1
7848 @cartouche
7849 @noindent
7850 @strong{17}.  The predefined floating point types declared in
7851 @code{Standard}.  See 3.5.7(16).
7852 @end cartouche
7853 @noindent
7854 @table @code
7855 @item Short_Float
7856 32 bit IEEE short
7857 @item Float
7858 (Short) 32 bit IEEE short
7859 @item Long_Float
7860 64 bit IEEE long
7861 @item Long_Long_Float
7862 64 bit IEEE long (80 bit IEEE long on x86 processors)
7863 @end table
7864
7865 @sp 1
7866 @cartouche
7867 @noindent
7868 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7869 @end cartouche
7870 @noindent
7871 @code{Fine_Delta} is 2**(@minus{}63)
7872
7873 @sp 1
7874 @cartouche
7875 @noindent
7876 @strong{19}.  What combinations of small, range, and digits are
7877 supported for fixed point types.  See 3.5.9(10).
7878 @end cartouche
7879 @noindent
7880 Any combinations are permitted that do not result in a small less than
7881 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7882 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7883 is 64 bits (true of all architectures except ia32), then the output from
7884 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7885 is because floating-point conversions are used to convert fixed point.
7886
7887 @sp 1
7888 @cartouche
7889 @noindent
7890 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7891 within an unnamed @code{block_statement}.  See 3.9(10).
7892 @end cartouche
7893 @noindent
7894 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7895 decimal integer are allocated.
7896
7897 @sp 1
7898 @cartouche
7899 @noindent
7900 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7901 @end cartouche
7902 @noindent
7903 @xref{Implementation Defined Attributes}.
7904
7905 @sp 1
7906 @cartouche
7907 @noindent
7908 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7909 @end cartouche
7910 @noindent
7911 There are no implementation-defined time types.
7912
7913 @sp 1
7914 @cartouche
7915 @noindent
7916 @strong{23}.  The time base associated with relative delays.
7917 @end cartouche
7918 @noindent
7919 See 9.6(20).  The time base used is that provided by the C library
7920 function @code{gettimeofday}.
7921
7922 @sp 1
7923 @cartouche
7924 @noindent
7925 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7926 9.6(23).
7927 @end cartouche
7928 @noindent
7929 The time base used is that provided by the C library function
7930 @code{gettimeofday}.
7931
7932 @sp 1
7933 @cartouche
7934 @noindent
7935 @strong{25}.  The time zone used for package @code{Calendar}
7936 operations.  See 9.6(24).
7937 @end cartouche
7938 @noindent
7939 The time zone used by package @code{Calendar} is the current system time zone
7940 setting for local time, as accessed by the C library function
7941 @code{localtime}.
7942
7943 @sp 1
7944 @cartouche
7945 @noindent
7946 @strong{26}.  Any limit on @code{delay_until_statements} of
7947 @code{select_statements}.  See 9.6(29).
7948 @end cartouche
7949 @noindent
7950 There are no such limits.
7951
7952 @sp 1
7953 @cartouche
7954 @noindent
7955 @strong{27}.  Whether or not two non-overlapping parts of a composite
7956 object are independently addressable, in the case where packing, record
7957 layout, or @code{Component_Size} is specified for the object.  See
7958 9.10(1).
7959 @end cartouche
7960 @noindent
7961 Separate components are independently addressable if they do not share
7962 overlapping storage units.
7963
7964 @sp 1
7965 @cartouche
7966 @noindent
7967 @strong{28}.  The representation for a compilation.  See 10.1(2).
7968 @end cartouche
7969 @noindent
7970 A compilation is represented by a sequence of files presented to the
7971 compiler in a single invocation of the @command{gcc} command.
7972
7973 @sp 1
7974 @cartouche
7975 @noindent
7976 @strong{29}.  Any restrictions on compilations that contain multiple
7977 compilation_units.  See 10.1(4).
7978 @end cartouche
7979 @noindent
7980 No single file can contain more than one compilation unit, but any
7981 sequence of files can be presented to the compiler as a single
7982 compilation.
7983
7984 @sp 1
7985 @cartouche
7986 @noindent
7987 @strong{30}.  The mechanisms for creating an environment and for adding
7988 and replacing compilation units.  See 10.1.4(3).
7989 @end cartouche
7990 @noindent
7991 See separate section on compilation model.
7992
7993 @sp 1
7994 @cartouche
7995 @noindent
7996 @strong{31}.  The manner of explicitly assigning library units to a
7997 partition.  See 10.2(2).
7998 @end cartouche
7999 @noindent
8000 If a unit contains an Ada main program, then the Ada units for the partition
8001 are determined by recursive application of the rules in the Ada Reference
8002 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8003 are needed by the main program, and then this definition of need is applied
8004 recursively to those units, and the partition contains the transitive
8005 closure determined by this relationship.  In short, all the necessary units
8006 are included, with no need to explicitly specify the list.  If additional
8007 units are required, e.g.@: by foreign language units, then all units must be
8008 mentioned in the context clause of one of the needed Ada units.
8009
8010 If the partition contains no main program, or if the main program is in
8011 a language other than Ada, then GNAT
8012 provides the binder options @option{-z} and @option{-n} respectively, and in
8013 this case a list of units can be explicitly supplied to the binder for
8014 inclusion in the partition (all units needed by these units will also
8015 be included automatically).  For full details on the use of these
8016 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8017 @value{EDITION} User's Guide}.
8018
8019 @sp 1
8020 @cartouche
8021 @noindent
8022 @strong{32}.  The implementation-defined means, if any, of specifying
8023 which compilation units are needed by a given compilation unit.  See
8024 10.2(2).
8025 @end cartouche
8026 @noindent
8027 The units needed by a given compilation unit are as defined in
8028 the Ada Reference Manual section 10.2(2-6).  There are no
8029 implementation-defined pragmas or other implementation-defined
8030 means for specifying needed units.
8031
8032 @sp 1
8033 @cartouche
8034 @noindent
8035 @strong{33}.  The manner of designating the main subprogram of a
8036 partition.  See 10.2(7).
8037 @end cartouche
8038 @noindent
8039 The main program is designated by providing the name of the
8040 corresponding @file{ALI} file as the input parameter to the binder.
8041
8042 @sp 1
8043 @cartouche
8044 @noindent
8045 @strong{34}.  The order of elaboration of @code{library_items}.  See
8046 10.2(18).
8047 @end cartouche
8048 @noindent
8049 The first constraint on ordering is that it meets the requirements of
8050 Chapter 10 of the Ada Reference Manual.  This still leaves some
8051 implementation dependent choices, which are resolved by first
8052 elaborating bodies as early as possible (i.e., in preference to specs
8053 where there is a choice), and second by evaluating the immediate with
8054 clauses of a unit to determine the probably best choice, and
8055 third by elaborating in alphabetical order of unit names
8056 where a choice still remains.
8057
8058 @sp 1
8059 @cartouche
8060 @noindent
8061 @strong{35}.  Parameter passing and function return for the main
8062 subprogram.  See 10.2(21).
8063 @end cartouche
8064 @noindent
8065 The main program has no parameters.  It may be a procedure, or a function
8066 returning an integer type.  In the latter case, the returned integer
8067 value is the return code of the program (overriding any value that
8068 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8069
8070 @sp 1
8071 @cartouche
8072 @noindent
8073 @strong{36}.  The mechanisms for building and running partitions.  See
8074 10.2(24).
8075 @end cartouche
8076 @noindent
8077 GNAT itself supports programs with only a single partition.  The GNATDIST
8078 tool provided with the GLADE package (which also includes an implementation
8079 of the PCS) provides a completely flexible method for building and running
8080 programs consisting of multiple partitions.  See the separate GLADE manual
8081 for details.
8082
8083 @sp 1
8084 @cartouche
8085 @noindent
8086 @strong{37}.  The details of program execution, including program
8087 termination.  See 10.2(25).
8088 @end cartouche
8089 @noindent
8090 See separate section on compilation model.
8091
8092 @sp 1
8093 @cartouche
8094 @noindent
8095 @strong{38}.  The semantics of any non-active partitions supported by the
8096 implementation.  See 10.2(28).
8097 @end cartouche
8098 @noindent
8099 Passive partitions are supported on targets where shared memory is
8100 provided by the operating system.  See the GLADE reference manual for
8101 further details.
8102
8103 @sp 1
8104 @cartouche
8105 @noindent
8106 @strong{39}.  The information returned by @code{Exception_Message}.  See
8107 11.4.1(10).
8108 @end cartouche
8109 @noindent
8110 Exception message returns the null string unless a specific message has
8111 been passed by the program.
8112
8113 @sp 1
8114 @cartouche
8115 @noindent
8116 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8117 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8118 @end cartouche
8119 @noindent
8120 Blocks have implementation defined names of the form @code{B@var{nnn}}
8121 where @var{nnn} is an integer.
8122
8123 @sp 1
8124 @cartouche
8125 @noindent
8126 @strong{41}.  The information returned by
8127 @code{Exception_Information}.  See 11.4.1(13).
8128 @end cartouche
8129 @noindent
8130 @code{Exception_Information} returns a string in the following format:
8131
8132 @smallexample
8133 @emph{Exception_Name:} nnnnn
8134 @emph{Message:} mmmmm
8135 @emph{PID:} ppp
8136 @emph{Call stack traceback locations:}
8137 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8138 @end smallexample
8139
8140 @noindent
8141 where
8142
8143 @itemize @bullet
8144 @item
8145 @code{nnnn} is the fully qualified name of the exception in all upper
8146 case letters. This line is always present.
8147
8148 @item
8149 @code{mmmm} is the message (this line present only if message is non-null)
8150
8151 @item
8152 @code{ppp} is the Process Id value as a decimal integer (this line is
8153 present only if the Process Id is nonzero). Currently we are
8154 not making use of this field.
8155
8156 @item
8157 The Call stack traceback locations line and the following values
8158 are present only if at least one traceback location was recorded.
8159 The values are given in C style format, with lower case letters
8160 for a-f, and only as many digits present as are necessary.
8161 @end itemize
8162
8163 @noindent
8164 The line terminator sequence at the end of each line, including
8165 the last line is a single @code{LF} character (@code{16#0A#}).
8166
8167 @sp 1
8168 @cartouche
8169 @noindent
8170 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8171 @end cartouche
8172 @noindent
8173 The implementation defined check name Alignment_Check controls checking of
8174 address clause values for proper alignment (that is, the address supplied
8175 must be consistent with the alignment of the type).
8176
8177 In addition, a user program can add implementation-defined check names
8178 by means of the pragma Check_Name.
8179
8180 @sp 1
8181 @cartouche
8182 @noindent
8183 @strong{43}.  The interpretation of each aspect of representation.  See
8184 13.1(20).
8185 @end cartouche
8186 @noindent
8187 See separate section on data representations.
8188
8189 @sp 1
8190 @cartouche
8191 @noindent
8192 @strong{44}.  Any restrictions placed upon representation items.  See
8193 13.1(20).
8194 @end cartouche
8195 @noindent
8196 See separate section on data representations.
8197
8198 @sp 1
8199 @cartouche
8200 @noindent
8201 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8202 13.3(48).
8203 @end cartouche
8204 @noindent
8205 Size for an indefinite subtype is the maximum possible size, except that
8206 for the case of a subprogram parameter, the size of the parameter object
8207 is the actual size.
8208
8209 @sp 1
8210 @cartouche
8211 @noindent
8212 @strong{46}.  The default external representation for a type tag.  See
8213 13.3(75).
8214 @end cartouche
8215 @noindent
8216 The default external representation for a type tag is the fully expanded
8217 name of the type in upper case letters.
8218
8219 @sp 1
8220 @cartouche
8221 @noindent
8222 @strong{47}.  What determines whether a compilation unit is the same in
8223 two different partitions.  See 13.3(76).
8224 @end cartouche
8225 @noindent
8226 A compilation unit is the same in two different partitions if and only
8227 if it derives from the same source file.
8228
8229 @sp 1
8230 @cartouche
8231 @noindent
8232 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8233 @end cartouche
8234 @noindent
8235 The only implementation defined component is the tag for a tagged type,
8236 which contains a pointer to the dispatching table.
8237
8238 @sp 1
8239 @cartouche
8240 @noindent
8241 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8242 ordering.  See 13.5.3(5).
8243 @end cartouche
8244 @noindent
8245 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8246 implementation, so no non-default bit ordering is supported.  The default
8247 bit ordering corresponds to the natural endianness of the target architecture.
8248
8249 @sp 1
8250 @cartouche
8251 @noindent
8252 @strong{50}.  The contents of the visible part of package @code{System}
8253 and its language-defined children.  See 13.7(2).
8254 @end cartouche
8255 @noindent
8256 See the definition of these packages in files @file{system.ads} and
8257 @file{s-stoele.ads}.
8258
8259 @sp 1
8260 @cartouche
8261 @noindent
8262 @strong{51}.  The contents of the visible part of package
8263 @code{System.Machine_Code}, and the meaning of
8264 @code{code_statements}.  See 13.8(7).
8265 @end cartouche
8266 @noindent
8267 See the definition and documentation in file @file{s-maccod.ads}.
8268
8269 @sp 1
8270 @cartouche
8271 @noindent
8272 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8273 @end cartouche
8274 @noindent
8275 Unchecked conversion between types of the same size
8276 results in an uninterpreted transmission of the bits from one type
8277 to the other.  If the types are of unequal sizes, then in the case of
8278 discrete types, a shorter source is first zero or sign extended as
8279 necessary, and a shorter target is simply truncated on the left.
8280 For all non-discrete types, the source is first copied if necessary
8281 to ensure that the alignment requirements of the target are met, then
8282 a pointer is constructed to the source value, and the result is obtained
8283 by dereferencing this pointer after converting it to be a pointer to the
8284 target type. Unchecked conversions where the target subtype is an
8285 unconstrained array are not permitted. If the target alignment is
8286 greater than the source alignment, then a copy of the result is
8287 made with appropriate alignment
8288
8289 @sp 1
8290 @cartouche
8291 @noindent
8292 @strong{53}.  The manner of choosing a storage pool for an access type
8293 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8294 @end cartouche
8295 @noindent
8296 There are 3 different standard pools used by the compiler when
8297 @code{Storage_Pool} is not specified depending whether the type is local
8298 to a subprogram or defined at the library level and whether
8299 @code{Storage_Size}is specified or not.  See documentation in the runtime
8300 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8301 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8302 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8303 default pools used.
8304
8305 @sp 1
8306 @cartouche
8307 @noindent
8308 @strong{54}.  Whether or not the implementation provides user-accessible
8309 names for the standard pool type(s).  See 13.11(17).
8310 @end cartouche
8311 @noindent
8312
8313 See documentation in the sources of the run time mentioned in paragraph
8314 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8315 these units.
8316
8317 @sp 1
8318 @cartouche
8319 @noindent
8320 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8321 @end cartouche
8322 @noindent
8323 @code{Storage_Size} is measured in storage units, and refers to the
8324 total space available for an access type collection, or to the primary
8325 stack space for a task.
8326
8327 @sp 1
8328 @cartouche
8329 @noindent
8330 @strong{56}.  Implementation-defined aspects of storage pools.  See
8331 13.11(22).
8332 @end cartouche
8333 @noindent
8334 See documentation in the sources of the run time mentioned in paragraph
8335 @strong{53} for details on GNAT-defined aspects of storage pools.
8336
8337 @sp 1
8338 @cartouche
8339 @noindent
8340 @strong{57}.  The set of restrictions allowed in a pragma
8341 @code{Restrictions}.  See 13.12(7).
8342 @end cartouche
8343 @noindent
8344 All RM defined Restriction identifiers are implemented.  The following
8345 additional restriction identifiers are provided.  There are two separate
8346 lists of implementation dependent restriction identifiers.  The first
8347 set requires consistency throughout a partition (in other words, if the
8348 restriction identifier is used for any compilation unit in the partition,
8349 then all compilation units in the partition must obey the restriction.
8350
8351 @table @code
8352
8353 @item Simple_Barriers
8354 @findex Simple_Barriers
8355 This restriction ensures at compile time that barriers in entry declarations
8356 for protected types are restricted to either static boolean expressions or
8357 references to simple boolean variables defined in the private part of the
8358 protected type.  No other form of entry barriers is permitted.  This is one
8359 of the restrictions of the Ravenscar profile for limited tasking (see also
8360 pragma @code{Profile (Ravenscar)}).
8361
8362 @item Max_Entry_Queue_Length => Expr
8363 @findex Max_Entry_Queue_Length
8364 This restriction is a declaration that any protected entry compiled in
8365 the scope of the restriction has at most the specified number of
8366 tasks waiting on the entry
8367 at any one time, and so no queue is required.  This restriction is not
8368 checked at compile time.  A program execution is erroneous if an attempt
8369 is made to queue more than the specified number of tasks on such an entry.
8370
8371 @item No_Calendar
8372 @findex No_Calendar
8373 This restriction ensures at compile time that there is no implicit or
8374 explicit dependence on the package @code{Ada.Calendar}.
8375
8376 @item No_Default_Initialization
8377 @findex No_Default_Initialization
8378
8379 This restriction prohibits any instance of default initialization of variables.
8380 The binder implements a consistency rule which prevents any unit compiled
8381 without the restriction from with'ing a unit with the restriction (this allows
8382 the generation of initialization procedures to be skipped, since you can be
8383 sure that no call is ever generated to an initialization procedure in a unit
8384 with the restriction active). If used in conjunction with Initialize_Scalars or
8385 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8386 without a specific initializer (including the case of OUT scalar parameters).
8387
8388 @item No_Direct_Boolean_Operators
8389 @findex No_Direct_Boolean_Operators
8390 This restriction ensures that no logical (and/or/xor) or comparison
8391 operators are used on operands of type Boolean (or any type derived
8392 from Boolean). This is intended for use in safety critical programs
8393 where the certification protocol requires the use of short-circuit
8394 (and then, or else) forms for all composite boolean operations.
8395
8396 @item No_Dispatching_Calls
8397 @findex No_Dispatching_Calls
8398 This restriction ensures at compile time that the code generated by the
8399 compiler involves no dispatching calls. The use of this restriction allows the
8400 safe use of record extensions, classwide membership tests and other classwide
8401 features not involving implicit dispatching. This restriction ensures that
8402 the code contains no indirect calls through a dispatching mechanism. Note that
8403 this includes internally-generated calls created by the compiler, for example
8404 in the implementation of class-wide objects assignments. The
8405 membership test is allowed in the presence of this restriction, because its
8406 implementation requires no dispatching.
8407 This restriction is comparable to the official Ada restriction
8408 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8409 all classwide constructs that do not imply dispatching.
8410 The following example indicates constructs that violate this restriction.
8411
8412 @smallexample
8413 package Pkg is
8414   type T is tagged record
8415     Data : Natural;
8416   end record;
8417   procedure P (X : T);
8418
8419   type DT is new T with record
8420     More_Data : Natural;
8421   end record;
8422   procedure Q (X : DT);
8423 end Pkg;
8424
8425 with Pkg; use Pkg;
8426 procedure Example is
8427   procedure Test (O : T'Class) is
8428     N : Natural  := O'Size;--  Error: Dispatching call
8429     C : T'Class := O;      --  Error: implicit Dispatching Call
8430   begin
8431     if O in DT'Class then  --  OK   : Membership test
8432        Q (DT (O));         --  OK   : Type conversion plus direct call
8433     else
8434        P (O);              --  Error: Dispatching call
8435     end if;
8436   end Test;
8437
8438   Obj : DT;
8439 begin
8440   P (Obj);                 --  OK   : Direct call
8441   P (T (Obj));             --  OK   : Type conversion plus direct call
8442   P (T'Class (Obj));       --  Error: Dispatching call
8443
8444   Test (Obj);              --  OK   : Type conversion
8445
8446   if Obj in T'Class then   --  OK   : Membership test
8447      null;
8448   end if;
8449 end Example;
8450 @end smallexample
8451
8452 @item No_Dynamic_Attachment
8453 @findex No_Dynamic_Attachment
8454 This restriction ensures that there is no call to any of the operations
8455 defined in package Ada.Interrupts.
8456
8457 @item No_Enumeration_Maps
8458 @findex No_Enumeration_Maps
8459 This restriction ensures at compile time that no operations requiring
8460 enumeration maps are used (that is Image and Value attributes applied
8461 to enumeration types).
8462
8463 @item No_Entry_Calls_In_Elaboration_Code
8464 @findex No_Entry_Calls_In_Elaboration_Code
8465 This restriction ensures at compile time that no task or protected entry
8466 calls are made during elaboration code.  As a result of the use of this
8467 restriction, the compiler can assume that no code past an accept statement
8468 in a task can be executed at elaboration time.
8469
8470 @item No_Exception_Handlers
8471 @findex No_Exception_Handlers
8472 This restriction ensures at compile time that there are no explicit
8473 exception handlers. It also indicates that no exception propagation will
8474 be provided. In this mode, exceptions may be raised but will result in
8475 an immediate call to the last chance handler, a routine that the user
8476 must define with the following profile:
8477
8478 @smallexample @c ada
8479 procedure Last_Chance_Handler
8480   (Source_Location : System.Address; Line : Integer);
8481 pragma Export (C, Last_Chance_Handler,
8482                "__gnat_last_chance_handler");
8483 @end smallexample
8484
8485 The parameter is a C null-terminated string representing a message to be
8486 associated with the exception (typically the source location of the raise
8487 statement generated by the compiler). The Line parameter when nonzero
8488 represents the line number in the source program where the raise occurs.
8489
8490 @item No_Exception_Propagation
8491 @findex No_Exception_Propagation
8492 This restriction guarantees that exceptions are never propagated to an outer
8493 subprogram scope). The only case in which an exception may be raised is when
8494 the handler is statically in the same subprogram, so that the effect of a raise
8495 is essentially like a goto statement. Any other raise statement (implicit or
8496 explicit) will be considered unhandled. Exception handlers are allowed, but may
8497 not contain an exception occurrence identifier (exception choice). In addition
8498 use of the package GNAT.Current_Exception is not permitted, and reraise
8499 statements (raise with no operand) are not permitted.
8500
8501 @item No_Exception_Registration
8502 @findex No_Exception_Registration
8503 This restriction ensures at compile time that no stream operations for
8504 types Exception_Id or Exception_Occurrence are used. This also makes it
8505 impossible to pass exceptions to or from a partition with this restriction
8506 in a distributed environment. If this exception is active, then the generated
8507 code is simplified by omitting the otherwise-required global registration
8508 of exceptions when they are declared.
8509
8510 @item No_Implicit_Conditionals
8511 @findex No_Implicit_Conditionals
8512 This restriction ensures that the generated code does not contain any
8513 implicit conditionals, either by modifying the generated code where possible,
8514 or by rejecting any construct that would otherwise generate an implicit
8515 conditional. Note that this check does not include run time constraint
8516 checks, which on some targets may generate implicit conditionals as
8517 well. To control the latter, constraint checks can be suppressed in the
8518 normal manner. Constructs generating implicit conditionals include comparisons
8519 of composite objects and the Max/Min attributes.
8520
8521 @item No_Implicit_Dynamic_Code
8522 @findex No_Implicit_Dynamic_Code
8523 @cindex trampoline
8524 This restriction prevents the compiler from building ``trampolines''.
8525 This is a structure that is built on the stack and contains dynamic
8526 code to be executed at run time. On some targets, a trampoline is
8527 built for the following features: @code{Access},
8528 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8529 nested task bodies; primitive operations of nested tagged types.
8530 Trampolines do not work on machines that prevent execution of stack
8531 data. For example, on windows systems, enabling DEP (data execution
8532 protection) will cause trampolines to raise an exception.
8533 Trampolines are also quite slow at run time.
8534
8535 On many targets, trampolines have been largely eliminated. Look at the
8536 version of system.ads for your target --- if it has
8537 Always_Compatible_Rep equal to False, then trampolines are largely
8538 eliminated. In particular, a trampoline is built for the following
8539 features: @code{Address} of a nested subprogram;
8540 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8541 but only if pragma Favor_Top_Level applies, or the access type has a
8542 foreign-language convention; primitive operations of nested tagged
8543 types.
8544
8545 @item No_Implicit_Loops
8546 @findex No_Implicit_Loops
8547 This restriction ensures that the generated code does not contain any
8548 implicit @code{for} loops, either by modifying
8549 the generated code where possible,
8550 or by rejecting any construct that would otherwise generate an implicit
8551 @code{for} loop. If this restriction is active, it is possible to build
8552 large array aggregates with all static components without generating an
8553 intermediate temporary, and without generating a loop to initialize individual
8554 components. Otherwise, a loop is created for arrays larger than about 5000
8555 scalar components.
8556
8557 @item No_Initialize_Scalars
8558 @findex No_Initialize_Scalars
8559 This restriction ensures that no unit in the partition is compiled with
8560 pragma Initialize_Scalars. This allows the generation of more efficient
8561 code, and in particular eliminates dummy null initialization routines that
8562 are otherwise generated for some record and array types.
8563
8564 @item No_Local_Protected_Objects
8565 @findex No_Local_Protected_Objects
8566 This restriction ensures at compile time that protected objects are
8567 only declared at the library level.
8568
8569 @item No_Protected_Type_Allocators
8570 @findex No_Protected_Type_Allocators
8571 This restriction ensures at compile time that there are no allocator
8572 expressions that attempt to allocate protected objects.
8573
8574 @item No_Secondary_Stack
8575 @findex No_Secondary_Stack
8576 This restriction ensures at compile time that the generated code does not
8577 contain any reference to the secondary stack.  The secondary stack is used
8578 to implement functions returning unconstrained objects (arrays or records)
8579 on some targets.
8580
8581 @item No_Select_Statements
8582 @findex No_Select_Statements
8583 This restriction ensures at compile time no select statements of any kind
8584 are permitted, that is the keyword @code{select} may not appear.
8585 This is one of the restrictions of the Ravenscar
8586 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8587
8588 @item No_Standard_Storage_Pools
8589 @findex No_Standard_Storage_Pools
8590 This restriction ensures at compile time that no access types
8591 use the standard default storage pool.  Any access type declared must
8592 have an explicit Storage_Pool attribute defined specifying a
8593 user-defined storage pool.
8594
8595 @item No_Streams
8596 @findex No_Streams
8597 This restriction ensures at compile/bind time that there are no
8598 stream objects created and no use of stream attributes.
8599 This restriction does not forbid dependences on the package
8600 @code{Ada.Streams}. So it is permissible to with
8601 @code{Ada.Streams} (or another package that does so itself)
8602 as long as no actual stream objects are created and no
8603 stream attributes are used.
8604
8605 @item No_Task_Attributes_Package
8606 @findex No_Task_Attributes_Package
8607 This restriction ensures at compile time that there are no implicit or
8608 explicit dependencies on the package @code{Ada.Task_Attributes}.
8609
8610 @item No_Task_Termination
8611 @findex No_Task_Termination
8612 This restriction ensures at compile time that no terminate alternatives
8613 appear in any task body.
8614
8615 @item No_Tasking
8616 @findex No_Tasking
8617 This restriction prevents the declaration of tasks or task types throughout
8618 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8619 except that violations are caught at compile time and cause an error message
8620 to be output either by the compiler or binder.
8621
8622 @item Static_Priorities
8623 @findex Static_Priorities
8624 This restriction ensures at compile time that all priority expressions
8625 are static, and that there are no dependencies on the package
8626 @code{Ada.Dynamic_Priorities}.
8627
8628 @item Static_Storage_Size
8629 @findex Static_Storage_Size
8630 This restriction ensures at compile time that any expression appearing
8631 in a Storage_Size pragma or attribute definition clause is static.
8632
8633 @end table
8634
8635 @noindent
8636 The second set of implementation dependent restriction identifiers
8637 does not require partition-wide consistency.
8638 The restriction may be enforced for a single
8639 compilation unit without any effect on any of the
8640 other compilation units in the partition.
8641
8642 @table @code
8643
8644 @item No_Elaboration_Code
8645 @findex No_Elaboration_Code
8646 This restriction ensures at compile time that no elaboration code is
8647 generated.  Note that this is not the same condition as is enforced
8648 by pragma @code{Preelaborate}.  There are cases in which pragma
8649 @code{Preelaborate} still permits code to be generated (e.g.@: code
8650 to initialize a large array to all zeroes), and there are cases of units
8651 which do not meet the requirements for pragma @code{Preelaborate},
8652 but for which no elaboration code is generated.  Generally, it is
8653 the case that preelaborable units will meet the restrictions, with
8654 the exception of large aggregates initialized with an others_clause,
8655 and exception declarations (which generate calls to a run-time
8656 registry procedure).  This restriction is enforced on
8657 a unit by unit basis, it need not be obeyed consistently
8658 throughout a partition.
8659
8660 In the case of aggregates with others, if the aggregate has a dynamic
8661 size, there is no way to eliminate the elaboration code (such dynamic
8662 bounds would be incompatible with @code{Preelaborate} in any case). If
8663 the bounds are static, then use of this restriction actually modifies
8664 the code choice of the compiler to avoid generating a loop, and instead
8665 generate the aggregate statically if possible, no matter how many times
8666 the data for the others clause must be repeatedly generated.
8667
8668 It is not possible to precisely document
8669 the constructs which are compatible with this restriction, since,
8670 unlike most other restrictions, this is not a restriction on the
8671 source code, but a restriction on the generated object code. For
8672 example, if the source contains a declaration:
8673
8674 @smallexample
8675    Val : constant Integer := X;
8676 @end smallexample
8677
8678 @noindent
8679 where X is not a static constant, it may be possible, depending
8680 on complex optimization circuitry, for the compiler to figure
8681 out the value of X at compile time, in which case this initialization
8682 can be done by the loader, and requires no initialization code. It
8683 is not possible to document the precise conditions under which the
8684 optimizer can figure this out.
8685
8686 Note that this the implementation of this restriction requires full
8687 code generation. If it is used in conjunction with "semantics only"
8688 checking, then some cases of violations may be missed.
8689
8690 @item No_Entry_Queue
8691 @findex No_Entry_Queue
8692 This restriction is a declaration that any protected entry compiled in
8693 the scope of the restriction has at most one task waiting on the entry
8694 at any one time, and so no queue is required.  This restriction is not
8695 checked at compile time.  A program execution is erroneous if an attempt
8696 is made to queue a second task on such an entry.
8697
8698 @item No_Implementation_Attributes
8699 @findex No_Implementation_Attributes
8700 This restriction checks at compile time that no GNAT-defined attributes
8701 are present.  With this restriction, the only attributes that can be used
8702 are those defined in the Ada Reference Manual.
8703
8704 @item No_Implementation_Pragmas
8705 @findex No_Implementation_Pragmas
8706 This restriction checks at compile time that no GNAT-defined pragmas
8707 are present.  With this restriction, the only pragmas that can be used
8708 are those defined in the Ada Reference Manual.
8709
8710 @item No_Implementation_Restrictions
8711 @findex No_Implementation_Restrictions
8712 This restriction checks at compile time that no GNAT-defined restriction
8713 identifiers (other than @code{No_Implementation_Restrictions} itself)
8714 are present.  With this restriction, the only other restriction identifiers
8715 that can be used are those defined in the Ada Reference Manual.
8716
8717 @item No_Wide_Characters
8718 @findex No_Wide_Characters
8719 This restriction ensures at compile time that no uses of the types
8720 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8721 wide types
8722 appear, and that no wide or wide wide string or character literals
8723 appear in the program (that is literals representing characters not in
8724 type @code{Character}.
8725
8726 @end table
8727
8728 @sp 1
8729 @cartouche
8730 @noindent
8731 @strong{58}.  The consequences of violating limitations on
8732 @code{Restrictions} pragmas.  See 13.12(9).
8733 @end cartouche
8734 @noindent
8735 Restrictions that can be checked at compile time result in illegalities
8736 if violated.  Currently there are no other consequences of violating
8737 restrictions.
8738
8739 @sp 1
8740 @cartouche
8741 @noindent
8742 @strong{59}.  The representation used by the @code{Read} and
8743 @code{Write} attributes of elementary types in terms of stream
8744 elements.  See 13.13.2(9).
8745 @end cartouche
8746 @noindent
8747 The representation is the in-memory representation of the base type of
8748 the type, using the number of bits corresponding to the
8749 @code{@var{type}'Size} value, and the natural ordering of the machine.
8750
8751 @sp 1
8752 @cartouche
8753 @noindent
8754 @strong{60}.  The names and characteristics of the numeric subtypes
8755 declared in the visible part of package @code{Standard}.  See A.1(3).
8756 @end cartouche
8757 @noindent
8758 See items describing the integer and floating-point types supported.
8759
8760 @sp 1
8761 @cartouche
8762 @noindent
8763 @strong{61}.  The accuracy actually achieved by the elementary
8764 functions.  See A.5.1(1).
8765 @end cartouche
8766 @noindent
8767 The elementary functions correspond to the functions available in the C
8768 library.  Only fast math mode is implemented.
8769
8770 @sp 1
8771 @cartouche
8772 @noindent
8773 @strong{62}.  The sign of a zero result from some of the operators or
8774 functions in @code{Numerics.Generic_Elementary_Functions}, when
8775 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8776 @end cartouche
8777 @noindent
8778 The sign of zeroes follows the requirements of the IEEE 754 standard on
8779 floating-point.
8780
8781 @sp 1
8782 @cartouche
8783 @noindent
8784 @strong{63}.  The value of
8785 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8786 @end cartouche
8787 @noindent
8788 Maximum image width is 649, see library file @file{a-numran.ads}.
8789
8790 @sp 1
8791 @cartouche
8792 @noindent
8793 @strong{64}.  The value of
8794 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8795 @end cartouche
8796 @noindent
8797 Maximum image width is 80, see library file @file{a-nudira.ads}.
8798
8799 @sp 1
8800 @cartouche
8801 @noindent
8802 @strong{65}.  The algorithms for random number generation.  See
8803 A.5.2(32).
8804 @end cartouche
8805 @noindent
8806 The algorithm is documented in the source files @file{a-numran.ads} and
8807 @file{a-numran.adb}.
8808
8809 @sp 1
8810 @cartouche
8811 @noindent
8812 @strong{66}.  The string representation of a random number generator's
8813 state.  See A.5.2(38).
8814 @end cartouche
8815 @noindent
8816 See the documentation contained in the file @file{a-numran.adb}.
8817
8818 @sp 1
8819 @cartouche
8820 @noindent
8821 @strong{67}.  The minimum time interval between calls to the
8822 time-dependent Reset procedure that are guaranteed to initiate different
8823 random number sequences.  See A.5.2(45).
8824 @end cartouche
8825 @noindent
8826 The minimum period between reset calls to guarantee distinct series of
8827 random numbers is one microsecond.
8828
8829 @sp 1
8830 @cartouche
8831 @noindent
8832 @strong{68}.  The values of the @code{Model_Mantissa},
8833 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8834 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8835 Annex is not supported.  See A.5.3(72).
8836 @end cartouche
8837 @noindent
8838 See the source file @file{ttypef.ads} for the values of all numeric
8839 attributes.
8840
8841 @sp 1
8842 @cartouche
8843 @noindent
8844 @strong{69}.  Any implementation-defined characteristics of the
8845 input-output packages.  See A.7(14).
8846 @end cartouche
8847 @noindent
8848 There are no special implementation defined characteristics for these
8849 packages.
8850
8851 @sp 1
8852 @cartouche
8853 @noindent
8854 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8855 A.9(10).
8856 @end cartouche
8857 @noindent
8858 All type representations are contiguous, and the @code{Buffer_Size} is
8859 the value of @code{@var{type}'Size} rounded up to the next storage unit
8860 boundary.
8861
8862 @sp 1
8863 @cartouche
8864 @noindent
8865 @strong{71}.  External files for standard input, standard output, and
8866 standard error See A.10(5).
8867 @end cartouche
8868 @noindent
8869 These files are mapped onto the files provided by the C streams
8870 libraries.  See source file @file{i-cstrea.ads} for further details.
8871
8872 @sp 1
8873 @cartouche
8874 @noindent
8875 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8876 A.10.9(36).
8877 @end cartouche
8878 @noindent
8879 If more digits are requested in the output than are represented by the
8880 precision of the value, zeroes are output in the corresponding least
8881 significant digit positions.
8882
8883 @sp 1
8884 @cartouche
8885 @noindent
8886 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8887 @code{Command_Name}.  See A.15(1).
8888 @end cartouche
8889 @noindent
8890 These are mapped onto the @code{argv} and @code{argc} parameters of the
8891 main program in the natural manner.
8892
8893 @sp 1
8894 @cartouche
8895 @noindent
8896 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8897 @end cartouche
8898 @noindent
8899 The following convention names are supported
8900
8901 @table @code
8902 @item  Ada
8903 Ada
8904 @item Assembler
8905 Assembly language
8906 @item Asm
8907 Synonym for Assembler
8908 @item Assembly
8909 Synonym for Assembler
8910 @item C
8911 C
8912 @item C_Pass_By_Copy
8913 Allowed only for record types, like C, but also notes that record
8914 is to be passed by copy rather than reference.
8915 @item COBOL
8916 COBOL
8917 @item C_Plus_Plus (or CPP)
8918 C++
8919 @item Default
8920 Treated the same as C
8921 @item External
8922 Treated the same as C
8923 @item Fortran
8924 Fortran
8925 @item Intrinsic
8926 For support of pragma @code{Import} with convention Intrinsic, see
8927 separate section on Intrinsic Subprograms.
8928 @item Stdcall
8929 Stdcall (used for Windows implementations only).  This convention correspond
8930 to the WINAPI (previously called Pascal convention) C/C++ convention under
8931 Windows.  A function with this convention cleans the stack before exit.
8932 @item DLL
8933 Synonym for Stdcall
8934 @item Win32
8935 Synonym for Stdcall
8936 @item Stubbed
8937 Stubbed is a special convention used to indicate that the body of the
8938 subprogram will be entirely ignored.  Any call to the subprogram
8939 is converted into a raise of the @code{Program_Error} exception.  If a
8940 pragma @code{Import} specifies convention @code{stubbed} then no body need
8941 be present at all.  This convention is useful during development for the
8942 inclusion of subprograms whose body has not yet been written.
8943
8944 @end table
8945 @noindent
8946 In addition, all otherwise unrecognized convention names are also
8947 treated as being synonymous with convention C@.  In all implementations
8948 except for VMS, use of such other names results in a warning.  In VMS
8949 implementations, these names are accepted silently.
8950
8951 @sp 1
8952 @cartouche
8953 @noindent
8954 @strong{75}.  The meaning of link names.  See B.1(36).
8955 @end cartouche
8956 @noindent
8957 Link names are the actual names used by the linker.
8958
8959 @sp 1
8960 @cartouche
8961 @noindent
8962 @strong{76}.  The manner of choosing link names when neither the link
8963 name nor the address of an imported or exported entity is specified.  See
8964 B.1(36).
8965 @end cartouche
8966 @noindent
8967 The default linker name is that which would be assigned by the relevant
8968 external language, interpreting the Ada name as being in all lower case
8969 letters.
8970
8971 @sp 1
8972 @cartouche
8973 @noindent
8974 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8975 @end cartouche
8976 @noindent
8977 The string passed to @code{Linker_Options} is presented uninterpreted as
8978 an argument to the link command, unless it contains ASCII.NUL characters.
8979 NUL characters if they appear act as argument separators, so for example
8980
8981 @smallexample @c ada
8982 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8983 @end smallexample
8984
8985 @noindent
8986 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8987 linker. The order of linker options is preserved for a given unit. The final
8988 list of options passed to the linker is in reverse order of the elaboration
8989 order. For example, linker options for a body always appear before the options
8990 from the corresponding package spec.
8991
8992 @sp 1
8993 @cartouche
8994 @noindent
8995 @strong{78}.  The contents of the visible part of package
8996 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8997 @end cartouche
8998 @noindent
8999 See files with prefix @file{i-} in the distributed library.
9000
9001 @sp 1
9002 @cartouche
9003 @noindent
9004 @strong{79}.  Implementation-defined children of package
9005 @code{Interfaces}.  The contents of the visible part of package
9006 @code{Interfaces}.  See B.2(11).
9007 @end cartouche
9008 @noindent
9009 See files with prefix @file{i-} in the distributed library.
9010
9011 @sp 1
9012 @cartouche
9013 @noindent
9014 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
9015 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9016 @code{COBOL_Character}; and the initialization of the variables
9017 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9018 @code{Interfaces.COBOL}.  See B.4(50).
9019 @end cartouche
9020 @noindent
9021 @table @code
9022 @item Floating
9023 Float
9024 @item Long_Floating
9025 (Floating) Long_Float
9026 @item Binary
9027 Integer
9028 @item Long_Binary
9029 Long_Long_Integer
9030 @item Decimal_Element
9031 Character
9032 @item COBOL_Character
9033 Character
9034 @end table
9035
9036 @noindent
9037 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9038
9039 @sp 1
9040 @cartouche
9041 @noindent
9042 @strong{81}.  Support for access to machine instructions.  See C.1(1).
9043 @end cartouche
9044 @noindent
9045 See documentation in file @file{s-maccod.ads} in the distributed library.
9046
9047 @sp 1
9048 @cartouche
9049 @noindent
9050 @strong{82}.  Implementation-defined aspects of access to machine
9051 operations.  See C.1(9).
9052 @end cartouche
9053 @noindent
9054 See documentation in file @file{s-maccod.ads} in the distributed library.
9055
9056 @sp 1
9057 @cartouche
9058 @noindent
9059 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
9060 @end cartouche
9061 @noindent
9062 Interrupts are mapped to signals or conditions as appropriate.  See
9063 definition of unit
9064 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9065 on the interrupts supported on a particular target.
9066
9067 @sp 1
9068 @cartouche
9069 @noindent
9070 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
9071 C.4(13).
9072 @end cartouche
9073 @noindent
9074 GNAT does not permit a partition to be restarted without reloading,
9075 except under control of the debugger.
9076
9077 @sp 1
9078 @cartouche
9079 @noindent
9080 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9081 @end cartouche
9082 @noindent
9083 Pragma @code{Discard_Names} causes names of enumeration literals to
9084 be suppressed.  In the presence of this pragma, the Image attribute
9085 provides the image of the Pos of the literal, and Value accepts
9086 Pos values.
9087
9088 @sp 1
9089 @cartouche
9090 @noindent
9091 @strong{86}.  The result of the @code{Task_Identification.Image}
9092 attribute.  See C.7.1(7).
9093 @end cartouche
9094 @noindent
9095 The result of this attribute is a string that identifies
9096 the object or component that denotes a given task. If a variable @code{Var}
9097 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9098 where the suffix
9099 is the hexadecimal representation of the virtual address of the corresponding
9100 task control block. If the variable is an array of tasks, the image of each
9101 task will have the form of an indexed component indicating the position of a
9102 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9103 component of a record, the image of the task will have the form of a selected
9104 component. These rules are fully recursive, so that the image of a task that
9105 is a subcomponent of a composite object corresponds to the expression that
9106 designates this task.
9107 @noindent
9108 If a task is created by an allocator, its image depends on the context. If the
9109 allocator is part of an object declaration, the rules described above are used
9110 to construct its image, and this image is not affected by subsequent
9111 assignments. If the allocator appears within an expression, the image
9112 includes only the name of the task type.
9113 @noindent
9114 If the configuration pragma Discard_Names is present, or if the restriction
9115 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9116 the numeric suffix, that is to say the hexadecimal representation of the
9117 virtual address of the control block of the task.
9118 @sp 1
9119 @cartouche
9120 @noindent
9121 @strong{87}.  The value of @code{Current_Task} when in a protected entry
9122 or interrupt handler.  See C.7.1(17).
9123 @end cartouche
9124 @noindent
9125 Protected entries or interrupt handlers can be executed by any
9126 convenient thread, so the value of @code{Current_Task} is undefined.
9127
9128 @sp 1
9129 @cartouche
9130 @noindent
9131 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9132 body or interrupt handler.  See C.7.1(19).
9133 @end cartouche
9134 @noindent
9135 The effect of calling @code{Current_Task} from an entry body or
9136 interrupt handler is to return the identification of the task currently
9137 executing the code.
9138
9139 @sp 1
9140 @cartouche
9141 @noindent
9142 @strong{89}.  Implementation-defined aspects of
9143 @code{Task_Attributes}.  See C.7.2(19).
9144 @end cartouche
9145 @noindent
9146 There are no implementation-defined aspects of @code{Task_Attributes}.
9147
9148 @sp 1
9149 @cartouche
9150 @noindent
9151 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9152 @end cartouche
9153 @noindent
9154 The metrics information for GNAT depends on the performance of the
9155 underlying operating system.  The sources of the run-time for tasking
9156 implementation, together with the output from @option{-gnatG} can be
9157 used to determine the exact sequence of operating systems calls made
9158 to implement various tasking constructs.  Together with appropriate
9159 information on the performance of the underlying operating system,
9160 on the exact target in use, this information can be used to determine
9161 the required metrics.
9162
9163 @sp 1
9164 @cartouche
9165 @noindent
9166 @strong{91}.  The declarations of @code{Any_Priority} and
9167 @code{Priority}.  See D.1(11).
9168 @end cartouche
9169 @noindent
9170 See declarations in file @file{system.ads}.
9171
9172 @sp 1
9173 @cartouche
9174 @noindent
9175 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9176 @end cartouche
9177 @noindent
9178 There are no implementation-defined execution resources.
9179
9180 @sp 1
9181 @cartouche
9182 @noindent
9183 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9184 access to a protected object keeps its processor busy.  See D.2.1(3).
9185 @end cartouche
9186 @noindent
9187 On a multi-processor, a task that is waiting for access to a protected
9188 object does not keep its processor busy.
9189
9190 @sp 1
9191 @cartouche
9192 @noindent
9193 @strong{94}.  The affect of implementation defined execution resources
9194 on task dispatching.  See D.2.1(9).
9195 @end cartouche
9196 @noindent
9197 @c SGI info
9198 @ignore
9199 Tasks map to IRIX threads, and the dispatching policy is as defined by
9200 the IRIX implementation of threads.
9201 @end ignore
9202 Tasks map to threads in the threads package used by GNAT@.  Where possible
9203 and appropriate, these threads correspond to native threads of the
9204 underlying operating system.
9205
9206 @sp 1
9207 @cartouche
9208 @noindent
9209 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9210 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9211 @end cartouche
9212 @noindent
9213 There are no implementation-defined policy-identifiers allowed in this
9214 pragma.
9215
9216 @sp 1
9217 @cartouche
9218 @noindent
9219 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9220 D.2.2(16).
9221 @end cartouche
9222 @noindent
9223 Execution of a task cannot be preempted by the implementation processing
9224 of delay expirations for lower priority tasks.
9225
9226 @sp 1
9227 @cartouche
9228 @noindent
9229 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9230 @end cartouche
9231 @noindent
9232 @c SGI info:
9233 @ignore
9234 Tasks map to IRIX threads, and the dispatching policy is as defined by
9235 the IRIX implementation of threads.
9236 @end ignore
9237 The policy is the same as that of the underlying threads implementation.
9238
9239 @sp 1
9240 @cartouche
9241 @noindent
9242 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9243 in a pragma @code{Locking_Policy}.  See D.3(4).
9244 @end cartouche
9245 @noindent
9246 The only implementation defined policy permitted in GNAT is
9247 @code{Inheritance_Locking}.  On targets that support this policy, locking
9248 is implemented by inheritance, i.e.@: the task owning the lock operates
9249 at a priority equal to the highest priority of any task currently
9250 requesting the lock.
9251
9252 @sp 1
9253 @cartouche
9254 @noindent
9255 @strong{99}.  Default ceiling priorities.  See D.3(10).
9256 @end cartouche
9257 @noindent
9258 The ceiling priority of protected objects of the type
9259 @code{System.Interrupt_Priority'Last} as described in the Ada
9260 Reference Manual D.3(10),
9261
9262 @sp 1
9263 @cartouche
9264 @noindent
9265 @strong{100}.  The ceiling of any protected object used internally by
9266 the implementation.  See D.3(16).
9267 @end cartouche
9268 @noindent
9269 The ceiling priority of internal protected objects is
9270 @code{System.Priority'Last}.
9271
9272 @sp 1
9273 @cartouche
9274 @noindent
9275 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9276 @end cartouche
9277 @noindent
9278 There are no implementation-defined queuing policies.
9279
9280 @sp 1
9281 @cartouche
9282 @noindent
9283 @strong{102}.  On a multiprocessor, any conditions that cause the
9284 completion of an aborted construct to be delayed later than what is
9285 specified for a single processor.  See D.6(3).
9286 @end cartouche
9287 @noindent
9288 The semantics for abort on a multi-processor is the same as on a single
9289 processor, there are no further delays.
9290
9291 @sp 1
9292 @cartouche
9293 @noindent
9294 @strong{103}.  Any operations that implicitly require heap storage
9295 allocation.  See D.7(8).
9296 @end cartouche
9297 @noindent
9298 The only operation that implicitly requires heap storage allocation is
9299 task creation.
9300
9301 @sp 1
9302 @cartouche
9303 @noindent
9304 @strong{104}.  Implementation-defined aspects of pragma
9305 @code{Restrictions}.  See D.7(20).
9306 @end cartouche
9307 @noindent
9308 There are no such implementation-defined aspects.
9309
9310 @sp 1
9311 @cartouche
9312 @noindent
9313 @strong{105}.  Implementation-defined aspects of package
9314 @code{Real_Time}.  See D.8(17).
9315 @end cartouche
9316 @noindent
9317 There are no implementation defined aspects of package @code{Real_Time}.
9318
9319 @sp 1
9320 @cartouche
9321 @noindent
9322 @strong{106}.  Implementation-defined aspects of
9323 @code{delay_statements}.  See D.9(8).
9324 @end cartouche
9325 @noindent
9326 Any difference greater than one microsecond will cause the task to be
9327 delayed (see D.9(7)).
9328
9329 @sp 1
9330 @cartouche
9331 @noindent
9332 @strong{107}.  The upper bound on the duration of interrupt blocking
9333 caused by the implementation.  See D.12(5).
9334 @end cartouche
9335 @noindent
9336 The upper bound is determined by the underlying operating system.  In
9337 no cases is it more than 10 milliseconds.
9338
9339 @sp 1
9340 @cartouche
9341 @noindent
9342 @strong{108}.  The means for creating and executing distributed
9343 programs.  See E(5).
9344 @end cartouche
9345 @noindent
9346 The GLADE package provides a utility GNATDIST for creating and executing
9347 distributed programs.  See the GLADE reference manual for further details.
9348
9349 @sp 1
9350 @cartouche
9351 @noindent
9352 @strong{109}.  Any events that can result in a partition becoming
9353 inaccessible.  See E.1(7).
9354 @end cartouche
9355 @noindent
9356 See the GLADE reference manual for full details on such events.
9357
9358 @sp 1
9359 @cartouche
9360 @noindent
9361 @strong{110}.  The scheduling policies, treatment of priorities, and
9362 management of shared resources between partitions in certain cases.  See
9363 E.1(11).
9364 @end cartouche
9365 @noindent
9366 See the GLADE reference manual for full details on these aspects of
9367 multi-partition execution.
9368
9369 @sp 1
9370 @cartouche
9371 @noindent
9372 @strong{111}.  Events that cause the version of a compilation unit to
9373 change.  See E.3(5).
9374 @end cartouche
9375 @noindent
9376 Editing the source file of a compilation unit, or the source files of
9377 any units on which it is dependent in a significant way cause the version
9378 to change.  No other actions cause the version number to change.  All changes
9379 are significant except those which affect only layout, capitalization or
9380 comments.
9381
9382 @sp 1
9383 @cartouche
9384 @noindent
9385 @strong{112}.  Whether the execution of the remote subprogram is
9386 immediately aborted as a result of cancellation.  See E.4(13).
9387 @end cartouche
9388 @noindent
9389 See the GLADE reference manual for details on the effect of abort in
9390 a distributed application.
9391
9392 @sp 1
9393 @cartouche
9394 @noindent
9395 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9396 @end cartouche
9397 @noindent
9398 See the GLADE reference manual for a full description of all implementation
9399 defined aspects of the PCS@.
9400
9401 @sp 1
9402 @cartouche
9403 @noindent
9404 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9405 E.5(26).
9406 @end cartouche
9407 @noindent
9408 See the GLADE reference manual for a full description of all
9409 implementation defined interfaces.
9410
9411 @sp 1
9412 @cartouche
9413 @noindent
9414 @strong{115}.  The values of named numbers in the package
9415 @code{Decimal}.  See F.2(7).
9416 @end cartouche
9417 @noindent
9418 @table @code
9419 @item Max_Scale
9420 +18
9421 @item Min_Scale
9422 -18
9423 @item Min_Delta
9424 1.0E-18
9425 @item Max_Delta
9426 1.0E+18
9427 @item Max_Decimal_Digits
9428 18
9429 @end table
9430
9431 @sp 1
9432 @cartouche
9433 @noindent
9434 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9435 @code{Text_IO.Editing}.  See F.3.3(16).
9436 @end cartouche
9437 @noindent
9438 64
9439
9440 @sp 1
9441 @cartouche
9442 @noindent
9443 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9444 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9445 @end cartouche
9446 @noindent
9447 64
9448
9449 @sp 1
9450 @cartouche
9451 @noindent
9452 @strong{118}.  The accuracy actually achieved by the complex elementary
9453 functions and by other complex arithmetic operations.  See G.1(1).
9454 @end cartouche
9455 @noindent
9456 Standard library functions are used for the complex arithmetic
9457 operations.  Only fast math mode is currently supported.
9458
9459 @sp 1
9460 @cartouche
9461 @noindent
9462 @strong{119}.  The sign of a zero result (or a component thereof) from
9463 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9464 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9465 @end cartouche
9466 @noindent
9467 The signs of zero values are as recommended by the relevant
9468 implementation advice.
9469
9470 @sp 1
9471 @cartouche
9472 @noindent
9473 @strong{120}.  The sign of a zero result (or a component thereof) from
9474 any operator or function in
9475 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9476 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9477 @end cartouche
9478 @noindent
9479 The signs of zero values are as recommended by the relevant
9480 implementation advice.
9481
9482 @sp 1
9483 @cartouche
9484 @noindent
9485 @strong{121}.  Whether the strict mode or the relaxed mode is the
9486 default.  See G.2(2).
9487 @end cartouche
9488 @noindent
9489 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9490 provides a highly efficient implementation of strict mode.
9491
9492 @sp 1
9493 @cartouche
9494 @noindent
9495 @strong{122}.  The result interval in certain cases of fixed-to-float
9496 conversion.  See G.2.1(10).
9497 @end cartouche
9498 @noindent
9499 For cases where the result interval is implementation dependent, the
9500 accuracy is that provided by performing all operations in 64-bit IEEE
9501 floating-point format.
9502
9503 @sp 1
9504 @cartouche
9505 @noindent
9506 @strong{123}.  The result of a floating point arithmetic operation in
9507 overflow situations, when the @code{Machine_Overflows} attribute of the
9508 result type is @code{False}.  See G.2.1(13).
9509 @end cartouche
9510 @noindent
9511 Infinite and NaN values are produced as dictated by the IEEE
9512 floating-point standard.
9513
9514 Note that on machines that are not fully compliant with the IEEE
9515 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9516 must be used for achieving IEEE confirming behavior (although at the cost
9517 of a significant performance penalty), so infinite and NaN values are
9518 properly generated.
9519
9520 @sp 1
9521 @cartouche
9522 @noindent
9523 @strong{124}.  The result interval for division (or exponentiation by a
9524 negative exponent), when the floating point hardware implements division
9525 as multiplication by a reciprocal.  See G.2.1(16).
9526 @end cartouche
9527 @noindent
9528 Not relevant, division is IEEE exact.
9529
9530 @sp 1
9531 @cartouche
9532 @noindent
9533 @strong{125}.  The definition of close result set, which determines the
9534 accuracy of certain fixed point multiplications and divisions.  See
9535 G.2.3(5).
9536 @end cartouche
9537 @noindent
9538 Operations in the close result set are performed using IEEE long format
9539 floating-point arithmetic.  The input operands are converted to
9540 floating-point, the operation is done in floating-point, and the result
9541 is converted to the target type.
9542
9543 @sp 1
9544 @cartouche
9545 @noindent
9546 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9547 point multiplication or division for which the result shall be in the
9548 perfect result set.  See G.2.3(22).
9549 @end cartouche
9550 @noindent
9551 The result is only defined to be in the perfect result set if the result
9552 can be computed by a single scaling operation involving a scale factor
9553 representable in 64-bits.
9554
9555 @sp 1
9556 @cartouche
9557 @noindent
9558 @strong{127}.  The result of a fixed point arithmetic operation in
9559 overflow situations, when the @code{Machine_Overflows} attribute of the
9560 result type is @code{False}.  See G.2.3(27).
9561 @end cartouche
9562 @noindent
9563 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9564 types.
9565
9566 @sp 1
9567 @cartouche
9568 @noindent
9569 @strong{128}.  The result of an elementary function reference in
9570 overflow situations, when the @code{Machine_Overflows} attribute of the
9571 result type is @code{False}.  See G.2.4(4).
9572 @end cartouche
9573 @noindent
9574 IEEE infinite and Nan values are produced as appropriate.
9575
9576 @sp 1
9577 @cartouche
9578 @noindent
9579 @strong{129}.  The value of the angle threshold, within which certain
9580 elementary functions, complex arithmetic operations, and complex
9581 elementary functions yield results conforming to a maximum relative
9582 error bound.  See G.2.4(10).
9583 @end cartouche
9584 @noindent
9585 Information on this subject is not yet available.
9586
9587 @sp 1
9588 @cartouche
9589 @noindent
9590 @strong{130}.  The accuracy of certain elementary functions for
9591 parameters beyond the angle threshold.  See G.2.4(10).
9592 @end cartouche
9593 @noindent
9594 Information on this subject is not yet available.
9595
9596 @sp 1
9597 @cartouche
9598 @noindent
9599 @strong{131}.  The result of a complex arithmetic operation or complex
9600 elementary function reference in overflow situations, when the
9601 @code{Machine_Overflows} attribute of the corresponding real type is
9602 @code{False}.  See G.2.6(5).
9603 @end cartouche
9604 @noindent
9605 IEEE infinite and Nan values are produced as appropriate.
9606
9607 @sp 1
9608 @cartouche
9609 @noindent
9610 @strong{132}.  The accuracy of certain complex arithmetic operations and
9611 certain complex elementary functions for parameters (or components
9612 thereof) beyond the angle threshold.  See G.2.6(8).
9613 @end cartouche
9614 @noindent
9615 Information on those subjects is not yet available.
9616
9617 @sp 1
9618 @cartouche
9619 @noindent
9620 @strong{133}.  Information regarding bounded errors and erroneous
9621 execution.  See H.2(1).
9622 @end cartouche
9623 @noindent
9624 Information on this subject is not yet available.
9625
9626 @sp 1
9627 @cartouche
9628 @noindent
9629 @strong{134}.  Implementation-defined aspects of pragma
9630 @code{Inspection_Point}.  See H.3.2(8).
9631 @end cartouche
9632 @noindent
9633 Pragma @code{Inspection_Point} ensures that the variable is live and can
9634 be examined by the debugger at the inspection point.
9635
9636 @sp 1
9637 @cartouche
9638 @noindent
9639 @strong{135}.  Implementation-defined aspects of pragma
9640 @code{Restrictions}.  See H.4(25).
9641 @end cartouche
9642 @noindent
9643 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9644 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9645 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9646
9647 @sp 1
9648 @cartouche
9649 @noindent
9650 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9651 H.4(27).
9652 @end cartouche
9653 @noindent
9654 There are no restrictions on pragma @code{Restrictions}.
9655
9656 @node Intrinsic Subprograms
9657 @chapter Intrinsic Subprograms
9658 @cindex Intrinsic Subprograms
9659
9660 @menu
9661 * Intrinsic Operators::
9662 * Enclosing_Entity::
9663 * Exception_Information::
9664 * Exception_Message::
9665 * Exception_Name::
9666 * File::
9667 * Line::
9668 * Rotate_Left::
9669 * Rotate_Right::
9670 * Shift_Left::
9671 * Shift_Right::
9672 * Shift_Right_Arithmetic::
9673 * Source_Location::
9674 @end menu
9675
9676 @noindent
9677 GNAT allows a user application program to write the declaration:
9678
9679 @smallexample @c ada
9680    pragma Import (Intrinsic, name);
9681 @end smallexample
9682
9683 @noindent
9684 providing that the name corresponds to one of the implemented intrinsic
9685 subprograms in GNAT, and that the parameter profile of the referenced
9686 subprogram meets the requirements.  This chapter describes the set of
9687 implemented intrinsic subprograms, and the requirements on parameter profiles.
9688 Note that no body is supplied; as with other uses of pragma Import, the
9689 body is supplied elsewhere (in this case by the compiler itself).  Note
9690 that any use of this feature is potentially non-portable, since the
9691 Ada standard does not require Ada compilers to implement this feature.
9692
9693 @node Intrinsic Operators
9694 @section Intrinsic Operators
9695 @cindex Intrinsic operator
9696
9697 @noindent
9698 All the predefined numeric operators in package Standard
9699 in @code{pragma Import (Intrinsic,..)}
9700 declarations.  In the binary operator case, the operands must have the same
9701 size.  The operand or operands must also be appropriate for
9702 the operator.  For example, for addition, the operands must
9703 both be floating-point or both be fixed-point, and the
9704 right operand for @code{"**"} must have a root type of
9705 @code{Standard.Integer'Base}.
9706 You can use an intrinsic operator declaration as in the following example:
9707
9708 @smallexample @c ada
9709    type Int1 is new Integer;
9710    type Int2 is new Integer;
9711
9712    function "+" (X1 : Int1; X2 : Int2) return Int1;
9713    function "+" (X1 : Int1; X2 : Int2) return Int2;
9714    pragma Import (Intrinsic, "+");
9715 @end smallexample
9716
9717 @noindent
9718 This declaration would permit ``mixed mode'' arithmetic on items
9719 of the differing types @code{Int1} and @code{Int2}.
9720 It is also possible to specify such operators for private types, if the
9721 full views are appropriate arithmetic types.
9722
9723 @node Enclosing_Entity
9724 @section Enclosing_Entity
9725 @cindex Enclosing_Entity
9726 @noindent
9727 This intrinsic subprogram is used in the implementation of the
9728 library routine @code{GNAT.Source_Info}.  The only useful use of the
9729 intrinsic import in this case is the one in this unit, so an
9730 application program should simply call the function
9731 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9732 the current subprogram, package, task, entry, or protected subprogram.
9733
9734 @node Exception_Information
9735 @section Exception_Information
9736 @cindex Exception_Information'
9737 @noindent
9738 This intrinsic subprogram is used in the implementation of the
9739 library routine @code{GNAT.Current_Exception}.  The only useful
9740 use of the intrinsic import in this case is the one in this unit,
9741 so an application program should simply call the function
9742 @code{GNAT.Current_Exception.Exception_Information} to obtain
9743 the exception information associated with the current exception.
9744
9745 @node Exception_Message
9746 @section Exception_Message
9747 @cindex Exception_Message
9748 @noindent
9749 This intrinsic subprogram is used in the implementation of the
9750 library routine @code{GNAT.Current_Exception}.  The only useful
9751 use of the intrinsic import in this case is the one in this unit,
9752 so an application program should simply call the function
9753 @code{GNAT.Current_Exception.Exception_Message} to obtain
9754 the message associated with the current exception.
9755
9756 @node Exception_Name
9757 @section Exception_Name
9758 @cindex Exception_Name
9759 @noindent
9760 This intrinsic subprogram is used in the implementation of the
9761 library routine @code{GNAT.Current_Exception}.  The only useful
9762 use of the intrinsic import in this case is the one in this unit,
9763 so an application program should simply call the function
9764 @code{GNAT.Current_Exception.Exception_Name} to obtain
9765 the name of the current exception.
9766
9767 @node File
9768 @section File
9769 @cindex File
9770 @noindent
9771 This intrinsic subprogram is used in the implementation of the
9772 library routine @code{GNAT.Source_Info}.  The only useful use of the
9773 intrinsic import in this case is the one in this unit, so an
9774 application program should simply call the function
9775 @code{GNAT.Source_Info.File} to obtain the name of the current
9776 file.
9777
9778 @node Line
9779 @section Line
9780 @cindex Line
9781 @noindent
9782 This intrinsic subprogram is used in the implementation of the
9783 library routine @code{GNAT.Source_Info}.  The only useful use of the
9784 intrinsic import in this case is the one in this unit, so an
9785 application program should simply call the function
9786 @code{GNAT.Source_Info.Line} to obtain the number of the current
9787 source line.
9788
9789 @node Rotate_Left
9790 @section Rotate_Left
9791 @cindex Rotate_Left
9792 @noindent
9793 In standard Ada, the @code{Rotate_Left} function is available only
9794 for the predefined modular types in package @code{Interfaces}.  However, in
9795 GNAT it is possible to define a Rotate_Left function for a user
9796 defined modular type or any signed integer type as in this example:
9797
9798 @smallexample @c ada
9799    function Shift_Left
9800      (Value  : My_Modular_Type;
9801       Amount : Natural)
9802       return   My_Modular_Type;
9803 @end smallexample
9804
9805 @noindent
9806 The requirements are that the profile be exactly as in the example
9807 above.  The only modifications allowed are in the formal parameter
9808 names, and in the type of @code{Value} and the return type, which
9809 must be the same, and must be either a signed integer type, or
9810 a modular integer type with a binary modulus, and the size must
9811 be 8.  16, 32 or 64 bits.
9812
9813 @node Rotate_Right
9814 @section Rotate_Right
9815 @cindex Rotate_Right
9816 @noindent
9817 A @code{Rotate_Right} function can be defined for any user defined
9818 binary modular integer type, or signed integer type, as described
9819 above for @code{Rotate_Left}.
9820
9821 @node Shift_Left
9822 @section Shift_Left
9823 @cindex Shift_Left
9824 @noindent
9825 A @code{Shift_Left} function can be defined for any user defined
9826 binary modular integer type, or signed integer type, as described
9827 above for @code{Rotate_Left}.
9828
9829 @node Shift_Right
9830 @section Shift_Right
9831 @cindex Shift_Right
9832 @noindent
9833 A @code{Shift_Right} function can be defined for any user defined
9834 binary modular integer type, or signed integer type, as described
9835 above for @code{Rotate_Left}.
9836
9837 @node Shift_Right_Arithmetic
9838 @section Shift_Right_Arithmetic
9839 @cindex Shift_Right_Arithmetic
9840 @noindent
9841 A @code{Shift_Right_Arithmetic} function can be defined for any user
9842 defined binary modular integer type, or signed integer type, as described
9843 above for @code{Rotate_Left}.
9844
9845 @node Source_Location
9846 @section Source_Location
9847 @cindex Source_Location
9848 @noindent
9849 This intrinsic subprogram is used in the implementation of the
9850 library routine @code{GNAT.Source_Info}.  The only useful use of the
9851 intrinsic import in this case is the one in this unit, so an
9852 application program should simply call the function
9853 @code{GNAT.Source_Info.Source_Location} to obtain the current
9854 source file location.
9855
9856 @node Representation Clauses and Pragmas
9857 @chapter Representation Clauses and Pragmas
9858 @cindex Representation Clauses
9859
9860 @menu
9861 * Alignment Clauses::
9862 * Size Clauses::
9863 * Storage_Size Clauses::
9864 * Size of Variant Record Objects::
9865 * Biased Representation ::
9866 * Value_Size and Object_Size Clauses::
9867 * Component_Size Clauses::
9868 * Bit_Order Clauses::
9869 * Effect of Bit_Order on Byte Ordering::
9870 * Pragma Pack for Arrays::
9871 * Pragma Pack for Records::
9872 * Record Representation Clauses::
9873 * Enumeration Clauses::
9874 * Address Clauses::
9875 * Effect of Convention on Representation::
9876 * Determining the Representations chosen by GNAT::
9877 @end menu
9878
9879 @noindent
9880 @cindex Representation Clause
9881 @cindex Representation Pragma
9882 @cindex Pragma, representation
9883 This section describes the representation clauses accepted by GNAT, and
9884 their effect on the representation of corresponding data objects.
9885
9886 GNAT fully implements Annex C (Systems Programming).  This means that all
9887 the implementation advice sections in chapter 13 are fully implemented.
9888 However, these sections only require a minimal level of support for
9889 representation clauses.  GNAT provides much more extensive capabilities,
9890 and this section describes the additional capabilities provided.
9891
9892 @node Alignment Clauses
9893 @section Alignment Clauses
9894 @cindex Alignment Clause
9895
9896 @noindent
9897 GNAT requires that all alignment clauses specify a power of 2, and all
9898 default alignments are always a power of 2.  The default alignment
9899 values are as follows:
9900
9901 @itemize @bullet
9902 @item @emph{Primitive Types}.
9903 For primitive types, the alignment is the minimum of the actual size of
9904 objects of the type divided by @code{Storage_Unit},
9905 and the maximum alignment supported by the target.
9906 (This maximum alignment is given by the GNAT-specific attribute
9907 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9908 @cindex @code{Maximum_Alignment} attribute
9909 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9910 default alignment will be 8 on any target that supports alignments
9911 this large, but on some targets, the maximum alignment may be smaller
9912 than 8, in which case objects of type @code{Long_Float} will be maximally
9913 aligned.
9914
9915 @item @emph{Arrays}.
9916 For arrays, the alignment is equal to the alignment of the component type
9917 for the normal case where no packing or component size is given.  If the
9918 array is packed, and the packing is effective (see separate section on
9919 packed arrays), then the alignment will be one for long packed arrays,
9920 or arrays whose length is not known at compile time.  For short packed
9921 arrays, which are handled internally as modular types, the alignment
9922 will be as described for primitive types, e.g.@: a packed array of length
9923 31 bits will have an object size of four bytes, and an alignment of 4.
9924
9925 @item @emph{Records}.
9926 For the normal non-packed case, the alignment of a record is equal to
9927 the maximum alignment of any of its components.  For tagged records, this
9928 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9929 is used and all components are packable (see separate section on pragma
9930 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9931 record makes it profitable to increase it.
9932
9933 A special case is when:
9934 @itemize @bullet
9935 @item
9936 the size of the record is given explicitly, or a
9937 full record representation clause is given, and
9938 @item
9939 the size of the record is 2, 4, or 8 bytes.
9940 @end itemize
9941 @noindent
9942 In this case, an alignment is chosen to match the
9943 size of the record. For example, if we have:
9944
9945 @smallexample @c ada
9946    type Small is record
9947       A, B : Character;
9948    end record;
9949    for Small'Size use 16;
9950 @end smallexample
9951
9952 @noindent
9953 then the default alignment of the record type @code{Small} is 2, not 1. This
9954 leads to more efficient code when the record is treated as a unit, and also
9955 allows the type to specified as @code{Atomic} on architectures requiring
9956 strict alignment.
9957
9958 @end itemize
9959
9960 @noindent
9961 An alignment clause may specify a larger alignment than the default value
9962 up to some maximum value dependent on the target (obtainable by using the
9963 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9964 a smaller alignment than the default value for enumeration, integer and
9965 fixed point types, as well as for record types, for example
9966
9967 @smallexample @c ada
9968   type V is record
9969      A : Integer;
9970   end record;
9971
9972   for V'alignment use 1;
9973 @end smallexample
9974
9975 @noindent
9976 @cindex Alignment, default
9977 The default alignment for the type @code{V} is 4, as a result of the
9978 Integer field in the record, but it is permissible, as shown, to
9979 override the default alignment of the record with a smaller value.
9980
9981 @node Size Clauses
9982 @section Size Clauses
9983 @cindex Size Clause
9984
9985 @noindent
9986 The default size for a type @code{T} is obtainable through the
9987 language-defined attribute @code{T'Size} and also through the
9988 equivalent GNAT-defined attribute @code{T'Value_Size}.
9989 For objects of type @code{T}, GNAT will generally increase the type size
9990 so that the object size (obtainable through the GNAT-defined attribute
9991 @code{T'Object_Size})
9992 is a multiple of @code{T'Alignment * Storage_Unit}.
9993 For example
9994
9995 @smallexample @c ada
9996    type Smallint is range 1 .. 6;
9997
9998    type Rec is record
9999       Y1 : integer;
10000       Y2 : boolean;
10001    end record;
10002 @end smallexample
10003
10004 @noindent
10005 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10006 as specified by the RM rules,
10007 but objects of this type will have a size of 8
10008 (@code{Smallint'Object_Size} = 8),
10009 since objects by default occupy an integral number
10010 of storage units.  On some targets, notably older
10011 versions of the Digital Alpha, the size of stand
10012 alone objects of this type may be 32, reflecting
10013 the inability of the hardware to do byte load/stores.
10014
10015 Similarly, the size of type @code{Rec} is 40 bits
10016 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10017 the alignment is 4, so objects of this type will have
10018 their size increased to 64 bits so that it is a multiple
10019 of the alignment (in bits).  This decision is
10020 in accordance with the specific Implementation Advice in RM 13.3(43):
10021
10022 @quotation
10023 A @code{Size} clause should be supported for an object if the specified
10024 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10025 to a size in storage elements that is a multiple of the object's
10026 @code{Alignment} (if the @code{Alignment} is nonzero).
10027 @end quotation
10028
10029 @noindent
10030 An explicit size clause may be used to override the default size by
10031 increasing it.  For example, if we have:
10032
10033 @smallexample @c ada
10034    type My_Boolean is new Boolean;
10035    for My_Boolean'Size use 32;
10036 @end smallexample
10037
10038 @noindent
10039 then values of this type will always be 32 bits long.  In the case of
10040 discrete types, the size can be increased up to 64 bits, with the effect
10041 that the entire specified field is used to hold the value, sign- or
10042 zero-extended as appropriate.  If more than 64 bits is specified, then
10043 padding space is allocated after the value, and a warning is issued that
10044 there are unused bits.
10045
10046 Similarly the size of records and arrays may be increased, and the effect
10047 is to add padding bits after the value.  This also causes a warning message
10048 to be generated.
10049
10050 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10051 Size in bits, this corresponds to an object of size 256 megabytes (minus
10052 one).  This limitation is true on all targets.  The reason for this
10053 limitation is that it improves the quality of the code in many cases
10054 if it is known that a Size value can be accommodated in an object of
10055 type Integer.
10056
10057 @node Storage_Size Clauses
10058 @section Storage_Size Clauses
10059 @cindex Storage_Size Clause
10060
10061 @noindent
10062 For tasks, the @code{Storage_Size} clause specifies the amount of space
10063 to be allocated for the task stack.  This cannot be extended, and if the
10064 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10065 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10066 or a @code{Storage_Size} pragma in the task definition to set the
10067 appropriate required size.  A useful technique is to include in every
10068 task definition a pragma of the form:
10069
10070 @smallexample @c ada
10071    pragma Storage_Size (Default_Stack_Size);
10072 @end smallexample
10073
10074 @noindent
10075 Then @code{Default_Stack_Size} can be defined in a global package, and
10076 modified as required. Any tasks requiring stack sizes different from the
10077 default can have an appropriate alternative reference in the pragma.
10078
10079 You can also use the @option{-d} binder switch to modify the default stack
10080 size.
10081
10082 For access types, the @code{Storage_Size} clause specifies the maximum
10083 space available for allocation of objects of the type.  If this space is
10084 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10085 In the case where the access type is declared local to a subprogram, the
10086 use of a @code{Storage_Size} clause triggers automatic use of a special
10087 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10088 space for the pool is automatically reclaimed on exit from the scope in
10089 which the type is declared.
10090
10091 A special case recognized by the compiler is the specification of a
10092 @code{Storage_Size} of zero for an access type.  This means that no
10093 items can be allocated from the pool, and this is recognized at compile
10094 time, and all the overhead normally associated with maintaining a fixed
10095 size storage pool is eliminated.  Consider the following example:
10096
10097 @smallexample @c ada
10098    procedure p is
10099       type R is array (Natural) of Character;
10100       type P is access all R;
10101       for P'Storage_Size use 0;
10102       --  Above access type intended only for interfacing purposes
10103
10104       y : P;
10105
10106       procedure g (m : P);
10107       pragma Import (C, g);
10108
10109       --  @dots{}
10110
10111    begin
10112       --  @dots{}
10113       y := new R;
10114    end;
10115 @end smallexample
10116
10117 @noindent
10118 As indicated in this example, these dummy storage pools are often useful in
10119 connection with interfacing where no object will ever be allocated.  If you
10120 compile the above example, you get the warning:
10121
10122 @smallexample
10123    p.adb:16:09: warning: allocation from empty storage pool
10124    p.adb:16:09: warning: Storage_Error will be raised at run time
10125 @end smallexample
10126
10127 @noindent
10128 Of course in practice, there will not be any explicit allocators in the
10129 case of such an access declaration.
10130
10131 @node Size of Variant Record Objects
10132 @section Size of Variant Record Objects
10133 @cindex Size, variant record objects
10134 @cindex Variant record objects, size
10135
10136 @noindent
10137 In the case of variant record objects, there is a question whether Size gives
10138 information about a particular variant, or the maximum size required
10139 for any variant.  Consider the following program
10140
10141 @smallexample @c ada
10142 with Text_IO; use Text_IO;
10143 procedure q is
10144    type R1 (A : Boolean := False) is record
10145      case A is
10146        when True  => X : Character;
10147        when False => null;
10148      end case;
10149    end record;
10150
10151    V1 : R1 (False);
10152    V2 : R1;
10153
10154 begin
10155    Put_Line (Integer'Image (V1'Size));
10156    Put_Line (Integer'Image (V2'Size));
10157 end q;
10158 @end smallexample
10159
10160 @noindent
10161 Here we are dealing with a variant record, where the True variant
10162 requires 16 bits, and the False variant requires 8 bits.
10163 In the above example, both V1 and V2 contain the False variant,
10164 which is only 8 bits long.  However, the result of running the
10165 program is:
10166
10167 @smallexample
10168 8
10169 16
10170 @end smallexample
10171
10172 @noindent
10173 The reason for the difference here is that the discriminant value of
10174 V1 is fixed, and will always be False.  It is not possible to assign
10175 a True variant value to V1, therefore 8 bits is sufficient.  On the
10176 other hand, in the case of V2, the initial discriminant value is
10177 False (from the default), but it is possible to assign a True
10178 variant value to V2, therefore 16 bits must be allocated for V2
10179 in the general case, even fewer bits may be needed at any particular
10180 point during the program execution.
10181
10182 As can be seen from the output of this program, the @code{'Size}
10183 attribute applied to such an object in GNAT gives the actual allocated
10184 size of the variable, which is the largest size of any of the variants.
10185 The Ada Reference Manual is not completely clear on what choice should
10186 be made here, but the GNAT behavior seems most consistent with the
10187 language in the RM@.
10188
10189 In some cases, it may be desirable to obtain the size of the current
10190 variant, rather than the size of the largest variant.  This can be
10191 achieved in GNAT by making use of the fact that in the case of a
10192 subprogram parameter, GNAT does indeed return the size of the current
10193 variant (because a subprogram has no way of knowing how much space
10194 is actually allocated for the actual).
10195
10196 Consider the following modified version of the above program:
10197
10198 @smallexample @c ada
10199 with Text_IO; use Text_IO;
10200 procedure q is
10201    type R1 (A : Boolean := False) is record
10202      case A is
10203        when True  => X : Character;
10204        when False => null;
10205      end case;
10206    end record;
10207
10208    V2 : R1;
10209
10210    function Size (V : R1) return Integer is
10211    begin
10212       return V'Size;
10213    end Size;
10214
10215 begin
10216    Put_Line (Integer'Image (V2'Size));
10217    Put_Line (Integer'IMage (Size (V2)));
10218    V2 := (True, 'x');
10219    Put_Line (Integer'Image (V2'Size));
10220    Put_Line (Integer'IMage (Size (V2)));
10221 end q;
10222 @end smallexample
10223
10224 @noindent
10225 The output from this program is
10226
10227 @smallexample
10228 16
10229 8
10230 16
10231 16
10232 @end smallexample
10233
10234 @noindent
10235 Here we see that while the @code{'Size} attribute always returns
10236 the maximum size, regardless of the current variant value, the
10237 @code{Size} function does indeed return the size of the current
10238 variant value.
10239
10240 @node Biased Representation
10241 @section Biased Representation
10242 @cindex Size for biased representation
10243 @cindex Biased representation
10244
10245 @noindent
10246 In the case of scalars with a range starting at other than zero, it is
10247 possible in some cases to specify a size smaller than the default minimum
10248 value, and in such cases, GNAT uses an unsigned biased representation,
10249 in which zero is used to represent the lower bound, and successive values
10250 represent successive values of the type.
10251
10252 For example, suppose we have the declaration:
10253
10254 @smallexample @c ada
10255    type Small is range -7 .. -4;
10256    for Small'Size use 2;
10257 @end smallexample
10258
10259 @noindent
10260 Although the default size of type @code{Small} is 4, the @code{Size}
10261 clause is accepted by GNAT and results in the following representation
10262 scheme:
10263
10264 @smallexample
10265   -7 is represented as 2#00#
10266   -6 is represented as 2#01#
10267   -5 is represented as 2#10#
10268   -4 is represented as 2#11#
10269 @end smallexample
10270
10271 @noindent
10272 Biased representation is only used if the specified @code{Size} clause
10273 cannot be accepted in any other manner.  These reduced sizes that force
10274 biased representation can be used for all discrete types except for
10275 enumeration types for which a representation clause is given.
10276
10277 @node Value_Size and Object_Size Clauses
10278 @section Value_Size and Object_Size Clauses
10279 @findex Value_Size
10280 @findex Object_Size
10281 @cindex Size, of objects
10282
10283 @noindent
10284 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10285 number of bits required to hold values of type @code{T}.
10286 Although this interpretation was allowed in Ada 83, it was not required,
10287 and this requirement in practice can cause some significant difficulties.
10288 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10289 However, in Ada 95 and Ada 2005,
10290 @code{Natural'Size} is
10291 typically 31.  This means that code may change in behavior when moving
10292 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10293
10294 @smallexample @c ada
10295    type Rec is record;
10296       A : Natural;
10297       B : Natural;
10298    end record;
10299
10300    for Rec use record
10301       at 0  range 0 .. Natural'Size - 1;
10302       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10303    end record;
10304 @end smallexample
10305
10306 @noindent
10307 In the above code, since the typical size of @code{Natural} objects
10308 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10309 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10310 there are cases where the fact that the object size can exceed the
10311 size of the type causes surprises.
10312
10313 To help get around this problem GNAT provides two implementation
10314 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10315 applied to a type, these attributes yield the size of the type
10316 (corresponding to the RM defined size attribute), and the size of
10317 objects of the type respectively.
10318
10319 The @code{Object_Size} is used for determining the default size of
10320 objects and components.  This size value can be referred to using the
10321 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10322 the basis of the determination of the size.  The backend is free to
10323 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10324 character might be stored in 32 bits on a machine with no efficient
10325 byte access instructions such as the Alpha.
10326
10327 The default rules for the value of @code{Object_Size} for
10328 discrete types are as follows:
10329
10330 @itemize @bullet
10331 @item
10332 The @code{Object_Size} for base subtypes reflect the natural hardware
10333 size in bits (run the compiler with @option{-gnatS} to find those values
10334 for numeric types). Enumeration types and fixed-point base subtypes have
10335 8, 16, 32 or 64 bits for this size, depending on the range of values
10336 to be stored.
10337
10338 @item
10339 The @code{Object_Size} of a subtype is the same as the
10340 @code{Object_Size} of
10341 the type from which it is obtained.
10342
10343 @item
10344 The @code{Object_Size} of a derived base type is copied from the parent
10345 base type, and the @code{Object_Size} of a derived first subtype is copied
10346 from the parent first subtype.
10347 @end itemize
10348
10349 @noindent
10350 The @code{Value_Size} attribute
10351 is the (minimum) number of bits required to store a value
10352 of the type.
10353 This value is used to determine how tightly to pack
10354 records or arrays with components of this type, and also affects
10355 the semantics of unchecked conversion (unchecked conversions where
10356 the @code{Value_Size} values differ generate a warning, and are potentially
10357 target dependent).
10358
10359 The default rules for the value of @code{Value_Size} are as follows:
10360
10361 @itemize @bullet
10362 @item
10363 The @code{Value_Size} for a base subtype is the minimum number of bits
10364 required to store all values of the type (including the sign bit
10365 only if negative values are possible).
10366
10367 @item
10368 If a subtype statically matches the first subtype of a given type, then it has
10369 by default the same @code{Value_Size} as the first subtype.  This is a
10370 consequence of RM 13.1(14) (``if two subtypes statically match,
10371 then their subtype-specific aspects are the same''.)
10372
10373 @item
10374 All other subtypes have a @code{Value_Size} corresponding to the minimum
10375 number of bits required to store all values of the subtype.  For
10376 dynamic bounds, it is assumed that the value can range down or up
10377 to the corresponding bound of the ancestor
10378 @end itemize
10379
10380 @noindent
10381 The RM defined attribute @code{Size} corresponds to the
10382 @code{Value_Size} attribute.
10383
10384 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10385 the @code{Value_Size} of
10386 the first-named subtype to the given value, and the
10387 @code{Object_Size} of this first-named subtype to the given value padded up
10388 to an appropriate boundary.  It is a consequence of the default rules
10389 above that this @code{Object_Size} will apply to all further subtypes.  On the
10390 other hand, @code{Value_Size} is affected only for the first subtype, any
10391 dynamic subtypes obtained from it directly, and any statically matching
10392 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10393
10394 @code{Value_Size} and
10395 @code{Object_Size} may be explicitly set for any subtype using
10396 an attribute definition clause.  Note that the use of these attributes
10397 can cause the RM 13.1(14) rule to be violated.  If two access types
10398 reference aliased objects whose subtypes have differing @code{Object_Size}
10399 values as a result of explicit attribute definition clauses, then it
10400 is erroneous to convert from one access subtype to the other.
10401
10402 At the implementation level, Esize stores the Object_Size and the
10403 RM_Size field stores the @code{Value_Size} (and hence the value of the
10404 @code{Size} attribute,
10405 which, as noted above, is equivalent to @code{Value_Size}).
10406
10407 To get a feel for the difference, consider the following examples (note
10408 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10409
10410 @smallexample
10411                                        Object_Size     Value_Size
10412
10413 type x1 is range 0 .. 5;                    8               3
10414
10415 type x2 is range 0 .. 5;
10416 for x2'size use 12;                        16              12
10417
10418 subtype x3 is x2 range 0 .. 3;             16               2
10419
10420 subtype x4 is x2'base range 0 .. 10;        8               4
10421
10422 subtype x5 is x2 range 0 .. dynamic;       16               3*
10423
10424 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10425
10426 @end smallexample
10427
10428 @noindent
10429 Note: the entries marked ``3*'' are not actually specified by the Ada
10430 Reference Manual, but it seems in the spirit of the RM rules to allocate
10431 the minimum number of bits (here 3, given the range for @code{x2})
10432 known to be large enough to hold the given range of values.
10433
10434 So far, so good, but GNAT has to obey the RM rules, so the question is
10435 under what conditions must the RM @code{Size} be used.
10436 The following is a list
10437 of the occasions on which the RM @code{Size} must be used:
10438
10439 @itemize @bullet
10440 @item
10441 Component size for packed arrays or records
10442
10443 @item
10444 Value of the attribute @code{Size} for a type
10445
10446 @item
10447 Warning about sizes not matching for unchecked conversion
10448 @end itemize
10449
10450 @noindent
10451 For record types, the @code{Object_Size} is always a multiple of the
10452 alignment of the type (this is true for all types). In some cases the
10453 @code{Value_Size} can be smaller. Consider:
10454
10455 @smallexample
10456    type R is record
10457      X : Integer;
10458      Y : Character;
10459    end record;
10460 @end smallexample
10461
10462 @noindent
10463 On a typical 32-bit architecture, the X component will be four bytes, and
10464 require four-byte alignment, and the Y component will be one byte. In this
10465 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10466 required to store a value of this type, and for example, it is permissible
10467 to have a component of type R in an outer record whose component size is
10468 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10469 since it must be rounded up so that this value is a multiple of the
10470 alignment (4 bytes = 32 bits).
10471
10472 @noindent
10473 For all other types, the @code{Object_Size}
10474 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10475 Only @code{Size} may be specified for such types.
10476
10477 @node Component_Size Clauses
10478 @section Component_Size Clauses
10479 @cindex Component_Size Clause
10480
10481 @noindent
10482 Normally, the value specified in a component size clause must be consistent
10483 with the subtype of the array component with regard to size and alignment.
10484 In other words, the value specified must be at least equal to the size
10485 of this subtype, and must be a multiple of the alignment value.
10486
10487 In addition, component size clauses are allowed which cause the array
10488 to be packed, by specifying a smaller value.  A first case is for
10489 component size values in the range 1 through 63.  The value specified
10490 must not be smaller than the Size of the subtype.  GNAT will accurately
10491 honor all packing requests in this range.  For example, if we have:
10492
10493 @smallexample @c ada
10494 type r is array (1 .. 8) of Natural;
10495 for r'Component_Size use 31;
10496 @end smallexample
10497
10498 @noindent
10499 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10500 Of course access to the components of such an array is considerably
10501 less efficient than if the natural component size of 32 is used.
10502 A second case is when the subtype of the component is a record type
10503 padded because of its default alignment.  For example, if we have:
10504
10505 @smallexample @c ada
10506 type r is record
10507   i : Integer;
10508   j : Integer;
10509   b : Boolean;
10510 end record;
10511
10512 type a is array (1 .. 8) of r;
10513 for a'Component_Size use 72;
10514 @end smallexample
10515
10516 @noindent
10517 then the resulting array has a length of 72 bytes, instead of 96 bytes
10518 if the alignment of the record (4) was obeyed.
10519
10520 Note that there is no point in giving both a component size clause
10521 and a pragma Pack for the same array type. if such duplicate
10522 clauses are given, the pragma Pack will be ignored.
10523
10524 @node Bit_Order Clauses
10525 @section Bit_Order Clauses
10526 @cindex Bit_Order Clause
10527 @cindex bit ordering
10528 @cindex ordering, of bits
10529
10530 @noindent
10531 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10532 attribute.  The specification may either correspond to the default bit
10533 order for the target, in which case the specification has no effect and
10534 places no additional restrictions, or it may be for the non-standard
10535 setting (that is the opposite of the default).
10536
10537 In the case where the non-standard value is specified, the effect is
10538 to renumber bits within each byte, but the ordering of bytes is not
10539 affected.  There are certain
10540 restrictions placed on component clauses as follows:
10541
10542 @itemize @bullet
10543
10544 @item Components fitting within a single storage unit.
10545 @noindent
10546 These are unrestricted, and the effect is merely to renumber bits.  For
10547 example if we are on a little-endian machine with @code{Low_Order_First}
10548 being the default, then the following two declarations have exactly
10549 the same effect:
10550
10551 @smallexample @c ada
10552    type R1 is record
10553       A : Boolean;
10554       B : Integer range 1 .. 120;
10555    end record;
10556
10557    for R1 use record
10558       A at 0 range 0 .. 0;
10559       B at 0 range 1 .. 7;
10560    end record;
10561
10562    type R2 is record
10563       A : Boolean;
10564       B : Integer range 1 .. 120;
10565    end record;
10566
10567    for R2'Bit_Order use High_Order_First;
10568
10569    for R2 use record
10570       A at 0 range 7 .. 7;
10571       B at 0 range 0 .. 6;
10572    end record;
10573 @end smallexample
10574
10575 @noindent
10576 The useful application here is to write the second declaration with the
10577 @code{Bit_Order} attribute definition clause, and know that it will be treated
10578 the same, regardless of whether the target is little-endian or big-endian.
10579
10580 @item Components occupying an integral number of bytes.
10581 @noindent
10582 These are components that exactly fit in two or more bytes.  Such component
10583 declarations are allowed, but have no effect, since it is important to realize
10584 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10585 In particular, the following attempt at getting an endian-independent integer
10586 does not work:
10587
10588 @smallexample @c ada
10589    type R2 is record
10590       A : Integer;
10591    end record;
10592
10593    for R2'Bit_Order use High_Order_First;
10594
10595    for R2 use record
10596       A at 0 range 0 .. 31;
10597    end record;
10598 @end smallexample
10599
10600 @noindent
10601 This declaration will result in a little-endian integer on a
10602 little-endian machine, and a big-endian integer on a big-endian machine.
10603 If byte flipping is required for interoperability between big- and
10604 little-endian machines, this must be explicitly programmed.  This capability
10605 is not provided by @code{Bit_Order}.
10606
10607 @item Components that are positioned across byte boundaries
10608 @noindent
10609 but do not occupy an integral number of bytes.  Given that bytes are not
10610 reordered, such fields would occupy a non-contiguous sequence of bits
10611 in memory, requiring non-trivial code to reassemble.  They are for this
10612 reason not permitted, and any component clause specifying such a layout
10613 will be flagged as illegal by GNAT@.
10614
10615 @end itemize
10616
10617 @noindent
10618 Since the misconception that Bit_Order automatically deals with all
10619 endian-related incompatibilities is a common one, the specification of
10620 a component field that is an integral number of bytes will always
10621 generate a warning.  This warning may be suppressed using @code{pragma
10622 Warnings (Off)} if desired.  The following section contains additional
10623 details regarding the issue of byte ordering.
10624
10625 @node Effect of Bit_Order on Byte Ordering
10626 @section Effect of Bit_Order on Byte Ordering
10627 @cindex byte ordering
10628 @cindex ordering, of bytes
10629
10630 @noindent
10631 In this section we will review the effect of the @code{Bit_Order} attribute
10632 definition clause on byte ordering.  Briefly, it has no effect at all, but
10633 a detailed example will be helpful.  Before giving this
10634 example, let us review the precise
10635 definition of the effect of defining @code{Bit_Order}.  The effect of a
10636 non-standard bit order is described in section 15.5.3 of the Ada
10637 Reference Manual:
10638
10639 @quotation
10640 2   A bit ordering is a method of interpreting the meaning of
10641 the storage place attributes.
10642 @end quotation
10643
10644 @noindent
10645 To understand the precise definition of storage place attributes in
10646 this context, we visit section 13.5.1 of the manual:
10647
10648 @quotation
10649 13   A record_representation_clause (without the mod_clause)
10650 specifies the layout.  The storage place attributes (see 13.5.2)
10651 are taken from the values of the position, first_bit, and last_bit
10652 expressions after normalizing those values so that first_bit is
10653 less than Storage_Unit.
10654 @end quotation
10655
10656 @noindent
10657 The critical point here is that storage places are taken from
10658 the values after normalization, not before.  So the @code{Bit_Order}
10659 interpretation applies to normalized values.  The interpretation
10660 is described in the later part of the 15.5.3 paragraph:
10661
10662 @quotation
10663 2   A bit ordering is a method of interpreting the meaning of
10664 the storage place attributes.  High_Order_First (known in the
10665 vernacular as ``big endian'') means that the first bit of a
10666 storage element (bit 0) is the most significant bit (interpreting
10667 the sequence of bits that represent a component as an unsigned
10668 integer value).  Low_Order_First (known in the vernacular as
10669 ``little endian'') means the opposite: the first bit is the
10670 least significant.
10671 @end quotation
10672
10673 @noindent
10674 Note that the numbering is with respect to the bits of a storage
10675 unit.  In other words, the specification affects only the numbering
10676 of bits within a single storage unit.
10677
10678 We can make the effect clearer by giving an example.
10679
10680 Suppose that we have an external device which presents two bytes, the first
10681 byte presented, which is the first (low addressed byte) of the two byte
10682 record is called Master, and the second byte is called Slave.
10683
10684 The left most (most significant bit is called Control for each byte, and
10685 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10686 (least significant) bit.
10687
10688 On a big-endian machine, we can write the following representation clause
10689
10690 @smallexample @c ada
10691    type Data is record
10692       Master_Control : Bit;
10693       Master_V1      : Bit;
10694       Master_V2      : Bit;
10695       Master_V3      : Bit;
10696       Master_V4      : Bit;
10697       Master_V5      : Bit;
10698       Master_V6      : Bit;
10699       Master_V7      : Bit;
10700       Slave_Control  : Bit;
10701       Slave_V1       : Bit;
10702       Slave_V2       : Bit;
10703       Slave_V3       : Bit;
10704       Slave_V4       : Bit;
10705       Slave_V5       : Bit;
10706       Slave_V6       : Bit;
10707       Slave_V7       : Bit;
10708    end record;
10709
10710    for Data use record
10711       Master_Control at 0 range 0 .. 0;
10712       Master_V1      at 0 range 1 .. 1;
10713       Master_V2      at 0 range 2 .. 2;
10714       Master_V3      at 0 range 3 .. 3;
10715       Master_V4      at 0 range 4 .. 4;
10716       Master_V5      at 0 range 5 .. 5;
10717       Master_V6      at 0 range 6 .. 6;
10718       Master_V7      at 0 range 7 .. 7;
10719       Slave_Control  at 1 range 0 .. 0;
10720       Slave_V1       at 1 range 1 .. 1;
10721       Slave_V2       at 1 range 2 .. 2;
10722       Slave_V3       at 1 range 3 .. 3;
10723       Slave_V4       at 1 range 4 .. 4;
10724       Slave_V5       at 1 range 5 .. 5;
10725       Slave_V6       at 1 range 6 .. 6;
10726       Slave_V7       at 1 range 7 .. 7;
10727    end record;
10728 @end smallexample
10729
10730 @noindent
10731 Now if we move this to a little endian machine, then the bit ordering within
10732 the byte is backwards, so we have to rewrite the record rep clause as:
10733
10734 @smallexample @c ada
10735    for Data use record
10736       Master_Control at 0 range 7 .. 7;
10737       Master_V1      at 0 range 6 .. 6;
10738       Master_V2      at 0 range 5 .. 5;
10739       Master_V3      at 0 range 4 .. 4;
10740       Master_V4      at 0 range 3 .. 3;
10741       Master_V5      at 0 range 2 .. 2;
10742       Master_V6      at 0 range 1 .. 1;
10743       Master_V7      at 0 range 0 .. 0;
10744       Slave_Control  at 1 range 7 .. 7;
10745       Slave_V1       at 1 range 6 .. 6;
10746       Slave_V2       at 1 range 5 .. 5;
10747       Slave_V3       at 1 range 4 .. 4;
10748       Slave_V4       at 1 range 3 .. 3;
10749       Slave_V5       at 1 range 2 .. 2;
10750       Slave_V6       at 1 range 1 .. 1;
10751       Slave_V7       at 1 range 0 .. 0;
10752    end record;
10753 @end smallexample
10754
10755 @noindent
10756 It is a nuisance to have to rewrite the clause, especially if
10757 the code has to be maintained on both machines.  However,
10758 this is a case that we can handle with the
10759 @code{Bit_Order} attribute if it is implemented.
10760 Note that the implementation is not required on byte addressed
10761 machines, but it is indeed implemented in GNAT.
10762 This means that we can simply use the
10763 first record clause, together with the declaration
10764
10765 @smallexample @c ada
10766    for Data'Bit_Order use High_Order_First;
10767 @end smallexample
10768
10769 @noindent
10770 and the effect is what is desired, namely the layout is exactly the same,
10771 independent of whether the code is compiled on a big-endian or little-endian
10772 machine.
10773
10774 The important point to understand is that byte ordering is not affected.
10775 A @code{Bit_Order} attribute definition never affects which byte a field
10776 ends up in, only where it ends up in that byte.
10777 To make this clear, let us rewrite the record rep clause of the previous
10778 example as:
10779
10780 @smallexample @c ada
10781    for Data'Bit_Order use High_Order_First;
10782    for Data use record
10783       Master_Control at 0 range  0 .. 0;
10784       Master_V1      at 0 range  1 .. 1;
10785       Master_V2      at 0 range  2 .. 2;
10786       Master_V3      at 0 range  3 .. 3;
10787       Master_V4      at 0 range  4 .. 4;
10788       Master_V5      at 0 range  5 .. 5;
10789       Master_V6      at 0 range  6 .. 6;
10790       Master_V7      at 0 range  7 .. 7;
10791       Slave_Control  at 0 range  8 .. 8;
10792       Slave_V1       at 0 range  9 .. 9;
10793       Slave_V2       at 0 range 10 .. 10;
10794       Slave_V3       at 0 range 11 .. 11;
10795       Slave_V4       at 0 range 12 .. 12;
10796       Slave_V5       at 0 range 13 .. 13;
10797       Slave_V6       at 0 range 14 .. 14;
10798       Slave_V7       at 0 range 15 .. 15;
10799    end record;
10800 @end smallexample
10801
10802 @noindent
10803 This is exactly equivalent to saying (a repeat of the first example):
10804
10805 @smallexample @c ada
10806    for Data'Bit_Order use High_Order_First;
10807    for Data use record
10808       Master_Control at 0 range 0 .. 0;
10809       Master_V1      at 0 range 1 .. 1;
10810       Master_V2      at 0 range 2 .. 2;
10811       Master_V3      at 0 range 3 .. 3;
10812       Master_V4      at 0 range 4 .. 4;
10813       Master_V5      at 0 range 5 .. 5;
10814       Master_V6      at 0 range 6 .. 6;
10815       Master_V7      at 0 range 7 .. 7;
10816       Slave_Control  at 1 range 0 .. 0;
10817       Slave_V1       at 1 range 1 .. 1;
10818       Slave_V2       at 1 range 2 .. 2;
10819       Slave_V3       at 1 range 3 .. 3;
10820       Slave_V4       at 1 range 4 .. 4;
10821       Slave_V5       at 1 range 5 .. 5;
10822       Slave_V6       at 1 range 6 .. 6;
10823       Slave_V7       at 1 range 7 .. 7;
10824    end record;
10825 @end smallexample
10826
10827 @noindent
10828 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10829 field.  The storage place attributes are obtained by normalizing the
10830 values given so that the @code{First_Bit} value is less than 8.  After
10831 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10832 we specified in the other case.
10833
10834 Now one might expect that the @code{Bit_Order} attribute might affect
10835 bit numbering within the entire record component (two bytes in this
10836 case, thus affecting which byte fields end up in), but that is not
10837 the way this feature is defined, it only affects numbering of bits,
10838 not which byte they end up in.
10839
10840 Consequently it never makes sense to specify a starting bit number
10841 greater than 7 (for a byte addressable field) if an attribute
10842 definition for @code{Bit_Order} has been given, and indeed it
10843 may be actively confusing to specify such a value, so the compiler
10844 generates a warning for such usage.
10845
10846 If you do need to control byte ordering then appropriate conditional
10847 values must be used.  If in our example, the slave byte came first on
10848 some machines we might write:
10849
10850 @smallexample @c ada
10851    Master_Byte_First constant Boolean := @dots{};
10852
10853    Master_Byte : constant Natural :=
10854                    1 - Boolean'Pos (Master_Byte_First);
10855    Slave_Byte  : constant Natural :=
10856                    Boolean'Pos (Master_Byte_First);
10857
10858    for Data'Bit_Order use High_Order_First;
10859    for Data use record
10860       Master_Control at Master_Byte range 0 .. 0;
10861       Master_V1      at Master_Byte range 1 .. 1;
10862       Master_V2      at Master_Byte range 2 .. 2;
10863       Master_V3      at Master_Byte range 3 .. 3;
10864       Master_V4      at Master_Byte range 4 .. 4;
10865       Master_V5      at Master_Byte range 5 .. 5;
10866       Master_V6      at Master_Byte range 6 .. 6;
10867       Master_V7      at Master_Byte range 7 .. 7;
10868       Slave_Control  at Slave_Byte  range 0 .. 0;
10869       Slave_V1       at Slave_Byte  range 1 .. 1;
10870       Slave_V2       at Slave_Byte  range 2 .. 2;
10871       Slave_V3       at Slave_Byte  range 3 .. 3;
10872       Slave_V4       at Slave_Byte  range 4 .. 4;
10873       Slave_V5       at Slave_Byte  range 5 .. 5;
10874       Slave_V6       at Slave_Byte  range 6 .. 6;
10875       Slave_V7       at Slave_Byte  range 7 .. 7;
10876    end record;
10877 @end smallexample
10878
10879 @noindent
10880 Now to switch between machines, all that is necessary is
10881 to set the boolean constant @code{Master_Byte_First} in
10882 an appropriate manner.
10883
10884 @node Pragma Pack for Arrays
10885 @section Pragma Pack for Arrays
10886 @cindex Pragma Pack (for arrays)
10887
10888 @noindent
10889 Pragma @code{Pack} applied to an array has no effect unless the component type
10890 is packable.  For a component type to be packable, it must be one of the
10891 following cases:
10892
10893 @itemize @bullet
10894 @item
10895 Any scalar type
10896 @item
10897 Any type whose size is specified with a size clause
10898 @item
10899 Any packed array type with a static size
10900 @item
10901 Any record type padded because of its default alignment
10902 @end itemize
10903
10904 @noindent
10905 For all these cases, if the component subtype size is in the range
10906 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10907 component size were specified giving the component subtype size.
10908 For example if we have:
10909
10910 @smallexample @c ada
10911    type r is range 0 .. 17;
10912
10913    type ar is array (1 .. 8) of r;
10914    pragma Pack (ar);
10915 @end smallexample
10916
10917 @noindent
10918 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10919 and the size of the array @code{ar} will be exactly 40 bits.
10920
10921 Note that in some cases this rather fierce approach to packing can produce
10922 unexpected effects.  For example, in Ada 95 and Ada 2005,
10923 subtype @code{Natural} typically has a size of 31, meaning that if you
10924 pack an array of @code{Natural}, you get 31-bit
10925 close packing, which saves a few bits, but results in far less efficient
10926 access.  Since many other Ada compilers will ignore such a packing request,
10927 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10928 might not be what is intended.  You can easily remove this warning by
10929 using an explicit @code{Component_Size} setting instead, which never generates
10930 a warning, since the intention of the programmer is clear in this case.
10931
10932 GNAT treats packed arrays in one of two ways.  If the size of the array is
10933 known at compile time and is less than 64 bits, then internally the array
10934 is represented as a single modular type, of exactly the appropriate number
10935 of bits.  If the length is greater than 63 bits, or is not known at compile
10936 time, then the packed array is represented as an array of bytes, and the
10937 length is always a multiple of 8 bits.
10938
10939 Note that to represent a packed array as a modular type, the alignment must
10940 be suitable for the modular type involved. For example, on typical machines
10941 a 32-bit packed array will be represented by a 32-bit modular integer with
10942 an alignment of four bytes. If you explicitly override the default alignment
10943 with an alignment clause that is too small, the modular representation
10944 cannot be used. For example, consider the following set of declarations:
10945
10946 @smallexample @c ada
10947    type R is range 1 .. 3;
10948    type S is array (1 .. 31) of R;
10949    for S'Component_Size use 2;
10950    for S'Size use 62;
10951    for S'Alignment use 1;
10952 @end smallexample
10953
10954 @noindent
10955 If the alignment clause were not present, then a 62-bit modular
10956 representation would be chosen (typically with an alignment of 4 or 8
10957 bytes depending on the target). But the default alignment is overridden
10958 with the explicit alignment clause. This means that the modular
10959 representation cannot be used, and instead the array of bytes
10960 representation must be used, meaning that the length must be a multiple
10961 of 8. Thus the above set of declarations will result in a diagnostic
10962 rejecting the size clause and noting that the minimum size allowed is 64.
10963
10964 @cindex Pragma Pack (for type Natural)
10965 @cindex Pragma Pack warning
10966
10967 One special case that is worth noting occurs when the base type of the
10968 component size is 8/16/32 and the subtype is one bit less. Notably this
10969 occurs with subtype @code{Natural}. Consider:
10970
10971 @smallexample @c ada
10972    type Arr is array (1 .. 32) of Natural;
10973    pragma Pack (Arr);
10974 @end smallexample
10975
10976 @noindent
10977 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10978 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10979 Ada 83 compilers did not attempt 31 bit packing.
10980
10981 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10982 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10983 substantial unintended performance penalty when porting legacy Ada 83 code.
10984 To help prevent this, GNAT generates a warning in such cases. If you really
10985 want 31 bit packing in a case like this, you can set the component size
10986 explicitly:
10987
10988 @smallexample @c ada
10989    type Arr is array (1 .. 32) of Natural;
10990    for Arr'Component_Size use 31;
10991 @end smallexample
10992
10993 @noindent
10994 Here 31-bit packing is achieved as required, and no warning is generated,
10995 since in this case the programmer intention is clear.
10996
10997 @node Pragma Pack for Records
10998 @section Pragma Pack for Records
10999 @cindex Pragma Pack (for records)
11000
11001 @noindent
11002 Pragma @code{Pack} applied to a record will pack the components to reduce
11003 wasted space from alignment gaps and by reducing the amount of space
11004 taken by components.  We distinguish between @emph{packable} components and
11005 @emph{non-packable} components.
11006 Components of the following types are considered packable:
11007 @itemize @bullet
11008 @item
11009 All primitive types are packable.
11010
11011 @item
11012 Small packed arrays, whose size does not exceed 64 bits, and where the
11013 size is statically known at compile time, are represented internally
11014 as modular integers, and so they are also packable.
11015
11016 @end itemize
11017
11018 @noindent
11019 All packable components occupy the exact number of bits corresponding to
11020 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11021 can start on an arbitrary bit boundary.
11022
11023 All other types are non-packable, they occupy an integral number of
11024 storage units, and
11025 are placed at a boundary corresponding to their alignment requirements.
11026
11027 For example, consider the record
11028
11029 @smallexample @c ada
11030    type Rb1 is array (1 .. 13) of Boolean;
11031    pragma Pack (rb1);
11032
11033    type Rb2 is array (1 .. 65) of Boolean;
11034    pragma Pack (rb2);
11035
11036    type x2 is record
11037       l1 : Boolean;
11038       l2 : Duration;
11039       l3 : Float;
11040       l4 : Boolean;
11041       l5 : Rb1;
11042       l6 : Rb2;
11043    end record;
11044    pragma Pack (x2);
11045 @end smallexample
11046
11047 @noindent
11048 The representation for the record x2 is as follows:
11049
11050 @smallexample @c ada
11051 for x2'Size use 224;
11052 for x2 use record
11053    l1 at  0 range  0 .. 0;
11054    l2 at  0 range  1 .. 64;
11055    l3 at 12 range  0 .. 31;
11056    l4 at 16 range  0 .. 0;
11057    l5 at 16 range  1 .. 13;
11058    l6 at 18 range  0 .. 71;
11059 end record;
11060 @end smallexample
11061
11062 @noindent
11063 Studying this example, we see that the packable fields @code{l1}
11064 and @code{l2} are
11065 of length equal to their sizes, and placed at specific bit boundaries (and
11066 not byte boundaries) to
11067 eliminate padding.  But @code{l3} is of a non-packable float type, so
11068 it is on the next appropriate alignment boundary.
11069
11070 The next two fields are fully packable, so @code{l4} and @code{l5} are
11071 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11072 array that is longer than 64 bits, so it is itself non-packable.  Thus
11073 the @code{l6} field is aligned to the next byte boundary, and takes an
11074 integral number of bytes, i.e.@: 72 bits.
11075
11076 @node Record Representation Clauses
11077 @section Record Representation Clauses
11078 @cindex Record Representation Clause
11079
11080 @noindent
11081 Record representation clauses may be given for all record types, including
11082 types obtained by record extension.  Component clauses are allowed for any
11083 static component.  The restrictions on component clauses depend on the type
11084 of the component.
11085
11086 @cindex Component Clause
11087 For all components of an elementary type, the only restriction on component
11088 clauses is that the size must be at least the 'Size value of the type
11089 (actually the Value_Size).  There are no restrictions due to alignment,
11090 and such components may freely cross storage boundaries.
11091
11092 Packed arrays with a size up to and including 64 bits are represented
11093 internally using a modular type with the appropriate number of bits, and
11094 thus the same lack of restriction applies.  For example, if you declare:
11095
11096 @smallexample @c ada
11097    type R is array (1 .. 49) of Boolean;
11098    pragma Pack (R);
11099    for R'Size use 49;
11100 @end smallexample
11101
11102 @noindent
11103 then a component clause for a component of type R may start on any
11104 specified bit boundary, and may specify a value of 49 bits or greater.
11105
11106 For packed bit arrays that are longer than 64 bits, there are two
11107 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11108 including the important case of single bits or boolean values, then
11109 there are no limitations on placement of such components, and they
11110 may start and end at arbitrary bit boundaries.
11111
11112 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11113 an array of this type longer than 64 bits must always be placed on
11114 on a storage unit (byte) boundary and occupy an integral number
11115 of storage units (bytes). Any component clause that does not
11116 meet this requirement will be rejected.
11117
11118 Any aliased component, or component of an aliased type, must
11119 have its normal alignment and size. A component clause that
11120 does not meet this requirement will be rejected.
11121
11122 The tag field of a tagged type always occupies an address sized field at
11123 the start of the record.  No component clause may attempt to overlay this
11124 tag. When a tagged type appears as a component, the tag field must have
11125 proper alignment
11126
11127 In the case of a record extension T1, of a type T, no component clause applied
11128 to the type T1 can specify a storage location that would overlap the first
11129 T'Size bytes of the record.
11130
11131 For all other component types, including non-bit-packed arrays,
11132 the component can be placed at an arbitrary bit boundary,
11133 so for example, the following is permitted:
11134
11135 @smallexample @c ada
11136    type R is array (1 .. 10) of Boolean;
11137    for R'Size use 80;
11138
11139    type Q is record
11140       G, H : Boolean;
11141       L, M : R;
11142    end record;
11143
11144    for Q use record
11145       G at 0 range  0 ..   0;
11146       H at 0 range  1 ..   1;
11147       L at 0 range  2 ..  81;
11148       R at 0 range 82 .. 161;
11149    end record;
11150 @end smallexample
11151
11152 @noindent
11153 Note: the above rules apply to recent releases of GNAT 5.
11154 In GNAT 3, there are more severe restrictions on larger components.
11155 For non-primitive types, including packed arrays with a size greater than
11156 64 bits, component clauses must respect the alignment requirement of the
11157 type, in particular, always starting on a byte boundary, and the length
11158 must be a multiple of the storage unit.
11159
11160 @node Enumeration Clauses
11161 @section Enumeration Clauses
11162
11163 The only restriction on enumeration clauses is that the range of values
11164 must be representable.  For the signed case, if one or more of the
11165 representation values are negative, all values must be in the range:
11166
11167 @smallexample @c ada
11168    System.Min_Int .. System.Max_Int
11169 @end smallexample
11170
11171 @noindent
11172 For the unsigned case, where all values are nonnegative, the values must
11173 be in the range:
11174
11175 @smallexample @c ada
11176    0 .. System.Max_Binary_Modulus;
11177 @end smallexample
11178
11179 @noindent
11180 A @emph{confirming} representation clause is one in which the values range
11181 from 0 in sequence, i.e.@: a clause that confirms the default representation
11182 for an enumeration type.
11183 Such a confirming representation
11184 is permitted by these rules, and is specially recognized by the compiler so
11185 that no extra overhead results from the use of such a clause.
11186
11187 If an array has an index type which is an enumeration type to which an
11188 enumeration clause has been applied, then the array is stored in a compact
11189 manner.  Consider the declarations:
11190
11191 @smallexample @c ada
11192    type r is (A, B, C);
11193    for r use (A => 1, B => 5, C => 10);
11194    type t is array (r) of Character;
11195 @end smallexample
11196
11197 @noindent
11198 The array type t corresponds to a vector with exactly three elements and
11199 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11200 use of space, but means that accesses to elements of the array will incur
11201 the overhead of converting representation values to the corresponding
11202 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11203
11204 @node Address Clauses
11205 @section Address Clauses
11206 @cindex Address Clause
11207
11208 The reference manual allows a general restriction on representation clauses,
11209 as found in RM 13.1(22):
11210
11211 @quotation
11212 An implementation need not support representation
11213 items containing nonstatic expressions, except that
11214 an implementation should support a representation item
11215 for a given entity if each nonstatic expression in the
11216 representation item is a name that statically denotes
11217 a constant declared before the entity.
11218 @end quotation
11219
11220 @noindent
11221 In practice this is applicable only to address clauses, since this is the
11222 only case in which a non-static expression is permitted by the syntax.  As
11223 the AARM notes in sections 13.1 (22.a-22.h):
11224
11225 @display
11226   22.a   Reason: This is to avoid the following sort of thing:
11227
11228   22.b        X : Integer := F(@dots{});
11229               Y : Address := G(@dots{});
11230               for X'Address use Y;
11231
11232   22.c   In the above, we have to evaluate the
11233          initialization expression for X before we
11234          know where to put the result.  This seems
11235          like an unreasonable implementation burden.
11236
11237   22.d   The above code should instead be written
11238          like this:
11239
11240   22.e        Y : constant Address := G(@dots{});
11241               X : Integer := F(@dots{});
11242               for X'Address use Y;
11243
11244   22.f   This allows the expression ``Y'' to be safely
11245          evaluated before X is created.
11246
11247   22.g   The constant could be a formal parameter of mode in.
11248
11249   22.h   An implementation can support other nonstatic
11250          expressions if it wants to.  Expressions of type
11251          Address are hardly ever static, but their value
11252          might be known at compile time anyway in many
11253          cases.
11254 @end display
11255
11256 @noindent
11257 GNAT does indeed permit many additional cases of non-static expressions.  In
11258 particular, if the type involved is elementary there are no restrictions
11259 (since in this case, holding a temporary copy of the initialization value,
11260 if one is present, is inexpensive).  In addition, if there is no implicit or
11261 explicit initialization, then there are no restrictions.  GNAT will reject
11262 only the case where all three of these conditions hold:
11263
11264 @itemize @bullet
11265
11266 @item
11267 The type of the item is non-elementary (e.g.@: a record or array).
11268
11269 @item
11270 There is explicit or implicit initialization required for the object.
11271 Note that access values are always implicitly initialized, and also
11272 in GNAT, certain bit-packed arrays (those having a dynamic length or
11273 a length greater than 64) will also be implicitly initialized to zero.
11274
11275 @item
11276 The address value is non-static.  Here GNAT is more permissive than the
11277 RM, and allows the address value to be the address of a previously declared
11278 stand-alone variable, as long as it does not itself have an address clause.
11279
11280 @smallexample @c ada
11281            Anchor  : Some_Initialized_Type;
11282            Overlay : Some_Initialized_Type;
11283            for Overlay'Address use Anchor'Address;
11284 @end smallexample
11285
11286 @noindent
11287 However, the prefix of the address clause cannot be an array component, or
11288 a component of a discriminated record.
11289
11290 @end itemize
11291
11292 @noindent
11293 As noted above in section 22.h, address values are typically non-static.  In
11294 particular the To_Address function, even if applied to a literal value, is
11295 a non-static function call.  To avoid this minor annoyance, GNAT provides
11296 the implementation defined attribute 'To_Address.  The following two
11297 expressions have identical values:
11298
11299 @findex Attribute
11300 @findex To_Address
11301 @smallexample @c ada
11302    To_Address (16#1234_0000#)
11303    System'To_Address (16#1234_0000#);
11304 @end smallexample
11305
11306 @noindent
11307 except that the second form is considered to be a static expression, and
11308 thus when used as an address clause value is always permitted.
11309
11310 @noindent
11311 Additionally, GNAT treats as static an address clause that is an
11312 unchecked_conversion of a static integer value.  This simplifies the porting
11313 of legacy code, and provides a portable equivalent to the GNAT attribute
11314 @code{To_Address}.
11315
11316 Another issue with address clauses is the interaction with alignment
11317 requirements.  When an address clause is given for an object, the address
11318 value must be consistent with the alignment of the object (which is usually
11319 the same as the alignment of the type of the object).  If an address clause
11320 is given that specifies an inappropriately aligned address value, then the
11321 program execution is erroneous.
11322
11323 Since this source of erroneous behavior can have unfortunate effects, GNAT
11324 checks (at compile time if possible, generating a warning, or at execution
11325 time with a run-time check) that the alignment is appropriate.  If the
11326 run-time check fails, then @code{Program_Error} is raised.  This run-time
11327 check is suppressed if range checks are suppressed, or if the special GNAT
11328 check Alignment_Check is suppressed, or if
11329 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11330
11331 Finally, GNAT does not permit overlaying of objects of controlled types or
11332 composite types containing a controlled component. In most cases, the compiler
11333 can detect an attempt at such overlays and will generate a warning at compile
11334 time and a Program_Error exception at run time.
11335
11336 @findex Export
11337 An address clause cannot be given for an exported object.  More
11338 understandably the real restriction is that objects with an address
11339 clause cannot be exported.  This is because such variables are not
11340 defined by the Ada program, so there is no external object to export.
11341
11342 @findex Import
11343 It is permissible to give an address clause and a pragma Import for the
11344 same object.  In this case, the variable is not really defined by the
11345 Ada program, so there is no external symbol to be linked.  The link name
11346 and the external name are ignored in this case.  The reason that we allow this
11347 combination is that it provides a useful idiom to avoid unwanted
11348 initializations on objects with address clauses.
11349
11350 When an address clause is given for an object that has implicit or
11351 explicit initialization, then by default initialization takes place.  This
11352 means that the effect of the object declaration is to overwrite the
11353 memory at the specified address.  This is almost always not what the
11354 programmer wants, so GNAT will output a warning:
11355
11356 @smallexample
11357   with System;
11358   package G is
11359      type R is record
11360         M : Integer := 0;
11361      end record;
11362
11363      Ext : R;
11364      for Ext'Address use System'To_Address (16#1234_1234#);
11365          |
11366   >>> warning: implicit initialization of "Ext" may
11367       modify overlaid storage
11368   >>> warning: use pragma Import for "Ext" to suppress
11369       initialization (RM B(24))
11370
11371   end G;
11372 @end smallexample
11373
11374 @noindent
11375 As indicated by the warning message, the solution is to use a (dummy) pragma
11376 Import to suppress this initialization.  The pragma tell the compiler that the
11377 object is declared and initialized elsewhere.  The following package compiles
11378 without warnings (and the initialization is suppressed):
11379
11380 @smallexample @c ada
11381    with System;
11382    package G is
11383       type R is record
11384          M : Integer := 0;
11385       end record;
11386
11387       Ext : R;
11388       for Ext'Address use System'To_Address (16#1234_1234#);
11389       pragma Import (Ada, Ext);
11390    end G;
11391 @end smallexample
11392
11393 @noindent
11394 A final issue with address clauses involves their use for overlaying
11395 variables, as in the following example:
11396 @cindex Overlaying of objects
11397
11398 @smallexample @c ada
11399   A : Integer;
11400   B : Integer;
11401   for B'Address use A'Address;
11402 @end smallexample
11403
11404 @noindent
11405 or alternatively, using the form recommended by the RM:
11406
11407 @smallexample @c ada
11408   A    : Integer;
11409   Addr : constant Address := A'Address;
11410   B    : Integer;
11411   for B'Address use Addr;
11412 @end smallexample
11413
11414 @noindent
11415 In both of these cases, @code{A}
11416 and @code{B} become aliased to one another via the
11417 address clause. This use of address clauses to overlay
11418 variables, achieving an effect similar to unchecked
11419 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11420 the effect is implementation defined. Furthermore, the
11421 Ada RM specifically recommends that in a situation
11422 like this, @code{B} should be subject to the following
11423 implementation advice (RM 13.3(19)):
11424
11425 @quotation
11426 19  If the Address of an object is specified, or it is imported
11427     or exported, then the implementation should not perform
11428     optimizations based on assumptions of no aliases.
11429 @end quotation
11430
11431 @noindent
11432 GNAT follows this recommendation, and goes further by also applying
11433 this recommendation to the overlaid variable (@code{A}
11434 in the above example) in this case. This means that the overlay
11435 works "as expected", in that a modification to one of the variables
11436 will affect the value of the other.
11437
11438 @node Effect of Convention on Representation
11439 @section Effect of Convention on Representation
11440 @cindex Convention, effect on representation
11441
11442 @noindent
11443 Normally the specification of a foreign language convention for a type or
11444 an object has no effect on the chosen representation.  In particular, the
11445 representation chosen for data in GNAT generally meets the standard system
11446 conventions, and for example records are laid out in a manner that is
11447 consistent with C@.  This means that specifying convention C (for example)
11448 has no effect.
11449
11450 There are four exceptions to this general rule:
11451
11452 @itemize @bullet
11453
11454 @item Convention Fortran and array subtypes
11455 If pragma Convention Fortran is specified for an array subtype, then in
11456 accordance with the implementation advice in section 3.6.2(11) of the
11457 Ada Reference Manual, the array will be stored in a Fortran-compatible
11458 column-major manner, instead of the normal default row-major order.
11459
11460 @item Convention C and enumeration types
11461 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11462 to accommodate all values of the type.  For example, for the enumeration
11463 type declared by:
11464
11465 @smallexample @c ada
11466    type Color is (Red, Green, Blue);
11467 @end smallexample
11468
11469 @noindent
11470 8 bits is sufficient to store all values of the type, so by default, objects
11471 of type @code{Color} will be represented using 8 bits.  However, normal C
11472 convention is to use 32 bits for all enum values in C, since enum values
11473 are essentially of type int.  If pragma @code{Convention C} is specified for an
11474 Ada enumeration type, then the size is modified as necessary (usually to
11475 32 bits) to be consistent with the C convention for enum values.
11476
11477 Note that this treatment applies only to types. If Convention C is given for
11478 an enumeration object, where the enumeration type is not Convention C, then
11479 Object_Size bits are allocated. For example, for a normal enumeration type,
11480 with less than 256 elements, only 8 bits will be allocated for the object.
11481 Since this may be a surprise in terms of what C expects, GNAT will issue a
11482 warning in this situation. The warning can be suppressed by giving an explicit
11483 size clause specifying the desired size.
11484
11485 @item Convention C/Fortran and Boolean types
11486 In C, the usual convention for boolean values, that is values used for
11487 conditions, is that zero represents false, and nonzero values represent
11488 true.  In Ada, the normal convention is that two specific values, typically
11489 0/1, are used to represent false/true respectively.
11490
11491 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11492 value represents true).
11493
11494 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11495 C or Fortran convention for a derived Boolean, as in the following example:
11496
11497 @smallexample @c ada
11498    type C_Switch is new Boolean;
11499    pragma Convention (C, C_Switch);
11500 @end smallexample
11501
11502 @noindent
11503 then the GNAT generated code will treat any nonzero value as true.  For truth
11504 values generated by GNAT, the conventional value 1 will be used for True, but
11505 when one of these values is read, any nonzero value is treated as True.
11506
11507 @item Access types on OpenVMS
11508 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11509 arrays) are 64-bits long. An exception to this rule is for the case of
11510 C-convention access types where there is no explicit size clause present (or
11511 inherited for derived types). In this case, GNAT chooses to make these
11512 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11513 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11514
11515 @end itemize
11516
11517 @node Determining the Representations chosen by GNAT
11518 @section Determining the Representations chosen by GNAT
11519 @cindex Representation, determination of
11520 @cindex @option{-gnatR} switch
11521
11522 @noindent
11523 Although the descriptions in this section are intended to be complete, it is
11524 often easier to simply experiment to see what GNAT accepts and what the
11525 effect is on the layout of types and objects.
11526
11527 As required by the Ada RM, if a representation clause is not accepted, then
11528 it must be rejected as illegal by the compiler.  However, when a
11529 representation clause or pragma is accepted, there can still be questions
11530 of what the compiler actually does.  For example, if a partial record
11531 representation clause specifies the location of some components and not
11532 others, then where are the non-specified components placed? Or if pragma
11533 @code{Pack} is used on a record, then exactly where are the resulting
11534 fields placed? The section on pragma @code{Pack} in this chapter can be
11535 used to answer the second question, but it is often easier to just see
11536 what the compiler does.
11537
11538 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11539 with this option, then the compiler will output information on the actual
11540 representations chosen, in a format similar to source representation
11541 clauses.  For example, if we compile the package:
11542
11543 @smallexample @c ada
11544 package q is
11545    type r (x : boolean) is tagged record
11546       case x is
11547          when True => S : String (1 .. 100);
11548          when False => null;
11549       end case;
11550    end record;
11551
11552    type r2 is new r (false) with record
11553       y2 : integer;
11554    end record;
11555
11556    for r2 use record
11557       y2 at 16 range 0 .. 31;
11558    end record;
11559
11560    type x is record
11561       y : character;
11562    end record;
11563
11564    type x1 is array (1 .. 10) of x;
11565    for x1'component_size use 11;
11566
11567    type ia is access integer;
11568
11569    type Rb1 is array (1 .. 13) of Boolean;
11570    pragma Pack (rb1);
11571
11572    type Rb2 is array (1 .. 65) of Boolean;
11573    pragma Pack (rb2);
11574
11575    type x2 is record
11576       l1 : Boolean;
11577       l2 : Duration;
11578       l3 : Float;
11579       l4 : Boolean;
11580       l5 : Rb1;
11581       l6 : Rb2;
11582    end record;
11583    pragma Pack (x2);
11584 end q;
11585 @end smallexample
11586
11587 @noindent
11588 using the switch @option{-gnatR} we obtain the following output:
11589
11590 @smallexample
11591 Representation information for unit q
11592 -------------------------------------
11593
11594 for r'Size use ??;
11595 for r'Alignment use 4;
11596 for r use record
11597    x    at 4 range  0 .. 7;
11598    _tag at 0 range  0 .. 31;
11599    s    at 5 range  0 .. 799;
11600 end record;
11601
11602 for r2'Size use 160;
11603 for r2'Alignment use 4;
11604 for r2 use record
11605    x       at  4 range  0 .. 7;
11606    _tag    at  0 range  0 .. 31;
11607    _parent at  0 range  0 .. 63;
11608    y2      at 16 range  0 .. 31;
11609 end record;
11610
11611 for x'Size use 8;
11612 for x'Alignment use 1;
11613 for x use record
11614    y at 0 range  0 .. 7;
11615 end record;
11616
11617 for x1'Size use 112;
11618 for x1'Alignment use 1;
11619 for x1'Component_Size use 11;
11620
11621 for rb1'Size use 13;
11622 for rb1'Alignment use 2;
11623 for rb1'Component_Size use 1;
11624
11625 for rb2'Size use 72;
11626 for rb2'Alignment use 1;
11627 for rb2'Component_Size use 1;
11628
11629 for x2'Size use 224;
11630 for x2'Alignment use 4;
11631 for x2 use record
11632    l1 at  0 range  0 .. 0;
11633    l2 at  0 range  1 .. 64;
11634    l3 at 12 range  0 .. 31;
11635    l4 at 16 range  0 .. 0;
11636    l5 at 16 range  1 .. 13;
11637    l6 at 18 range  0 .. 71;
11638 end record;
11639 @end smallexample
11640
11641 @noindent
11642 The Size values are actually the Object_Size, i.e.@: the default size that
11643 will be allocated for objects of the type.
11644 The ?? size for type r indicates that we have a variant record, and the
11645 actual size of objects will depend on the discriminant value.
11646
11647 The Alignment values show the actual alignment chosen by the compiler
11648 for each record or array type.
11649
11650 The record representation clause for type r shows where all fields
11651 are placed, including the compiler generated tag field (whose location
11652 cannot be controlled by the programmer).
11653
11654 The record representation clause for the type extension r2 shows all the
11655 fields present, including the parent field, which is a copy of the fields
11656 of the parent type of r2, i.e.@: r1.
11657
11658 The component size and size clauses for types rb1 and rb2 show
11659 the exact effect of pragma @code{Pack} on these arrays, and the record
11660 representation clause for type x2 shows how pragma @code{Pack} affects
11661 this record type.
11662
11663 In some cases, it may be useful to cut and paste the representation clauses
11664 generated by the compiler into the original source to fix and guarantee
11665 the actual representation to be used.
11666
11667 @node Standard Library Routines
11668 @chapter Standard Library Routines
11669
11670 @noindent
11671 The Ada Reference Manual contains in Annex A a full description of an
11672 extensive set of standard library routines that can be used in any Ada
11673 program, and which must be provided by all Ada compilers.  They are
11674 analogous to the standard C library used by C programs.
11675
11676 GNAT implements all of the facilities described in annex A, and for most
11677 purposes the description in the Ada Reference Manual, or appropriate Ada
11678 text book, will be sufficient for making use of these facilities.
11679
11680 In the case of the input-output facilities,
11681 @xref{The Implementation of Standard I/O},
11682 gives details on exactly how GNAT interfaces to the
11683 file system.  For the remaining packages, the Ada Reference Manual
11684 should be sufficient.  The following is a list of the packages included,
11685 together with a brief description of the functionality that is provided.
11686
11687 For completeness, references are included to other predefined library
11688 routines defined in other sections of the Ada Reference Manual (these are
11689 cross-indexed from Annex A).
11690
11691 @table @code
11692 @item Ada (A.2)
11693 This is a parent package for all the standard library packages.  It is
11694 usually included implicitly in your program, and itself contains no
11695 useful data or routines.
11696
11697 @item Ada.Calendar (9.6)
11698 @code{Calendar} provides time of day access, and routines for
11699 manipulating times and durations.
11700
11701 @item Ada.Characters (A.3.1)
11702 This is a dummy parent package that contains no useful entities
11703
11704 @item Ada.Characters.Handling (A.3.2)
11705 This package provides some basic character handling capabilities,
11706 including classification functions for classes of characters (e.g.@: test
11707 for letters, or digits).
11708
11709 @item Ada.Characters.Latin_1 (A.3.3)
11710 This package includes a complete set of definitions of the characters
11711 that appear in type CHARACTER@.  It is useful for writing programs that
11712 will run in international environments.  For example, if you want an
11713 upper case E with an acute accent in a string, it is often better to use
11714 the definition of @code{UC_E_Acute} in this package.  Then your program
11715 will print in an understandable manner even if your environment does not
11716 support these extended characters.
11717
11718 @item Ada.Command_Line (A.15)
11719 This package provides access to the command line parameters and the name
11720 of the current program (analogous to the use of @code{argc} and @code{argv}
11721 in C), and also allows the exit status for the program to be set in a
11722 system-independent manner.
11723
11724 @item Ada.Decimal (F.2)
11725 This package provides constants describing the range of decimal numbers
11726 implemented, and also a decimal divide routine (analogous to the COBOL
11727 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11728
11729 @item Ada.Direct_IO (A.8.4)
11730 This package provides input-output using a model of a set of records of
11731 fixed-length, containing an arbitrary definite Ada type, indexed by an
11732 integer record number.
11733
11734 @item Ada.Dynamic_Priorities (D.5)
11735 This package allows the priorities of a task to be adjusted dynamically
11736 as the task is running.
11737
11738 @item Ada.Exceptions (11.4.1)
11739 This package provides additional information on exceptions, and also
11740 contains facilities for treating exceptions as data objects, and raising
11741 exceptions with associated messages.
11742
11743 @item Ada.Finalization (7.6)
11744 This package contains the declarations and subprograms to support the
11745 use of controlled types, providing for automatic initialization and
11746 finalization (analogous to the constructors and destructors of C++)
11747
11748 @item Ada.Interrupts (C.3.2)
11749 This package provides facilities for interfacing to interrupts, which
11750 includes the set of signals or conditions that can be raised and
11751 recognized as interrupts.
11752
11753 @item Ada.Interrupts.Names (C.3.2)
11754 This package provides the set of interrupt names (actually signal
11755 or condition names) that can be handled by GNAT@.
11756
11757 @item Ada.IO_Exceptions (A.13)
11758 This package defines the set of exceptions that can be raised by use of
11759 the standard IO packages.
11760
11761 @item Ada.Numerics
11762 This package contains some standard constants and exceptions used
11763 throughout the numerics packages.  Note that the constants pi and e are
11764 defined here, and it is better to use these definitions than rolling
11765 your own.
11766
11767 @item Ada.Numerics.Complex_Elementary_Functions
11768 Provides the implementation of standard elementary functions (such as
11769 log and trigonometric functions) operating on complex numbers using the
11770 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11771 created by the package @code{Numerics.Complex_Types}.
11772
11773 @item Ada.Numerics.Complex_Types
11774 This is a predefined instantiation of
11775 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11776 build the type @code{Complex} and @code{Imaginary}.
11777
11778 @item Ada.Numerics.Discrete_Random
11779 This package provides a random number generator suitable for generating
11780 random integer values from a specified range.
11781
11782 @item Ada.Numerics.Float_Random
11783 This package provides a random number generator suitable for generating
11784 uniformly distributed floating point values.
11785
11786 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11787 This is a generic version of the package that provides the
11788 implementation of standard elementary functions (such as log and
11789 trigonometric functions) for an arbitrary complex type.
11790
11791 The following predefined instantiations of this package are provided:
11792
11793 @table @code
11794 @item Short_Float
11795 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11796 @item Float
11797 @code{Ada.Numerics.Complex_Elementary_Functions}
11798 @item Long_Float
11799 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11800 @end table
11801
11802 @item Ada.Numerics.Generic_Complex_Types
11803 This is a generic package that allows the creation of complex types,
11804 with associated complex arithmetic operations.
11805
11806 The following predefined instantiations of this package exist
11807 @table @code
11808 @item Short_Float
11809 @code{Ada.Numerics.Short_Complex_Complex_Types}
11810 @item Float
11811 @code{Ada.Numerics.Complex_Complex_Types}
11812 @item Long_Float
11813 @code{Ada.Numerics.Long_Complex_Complex_Types}
11814 @end table
11815
11816 @item Ada.Numerics.Generic_Elementary_Functions
11817 This is a generic package that provides the implementation of standard
11818 elementary functions (such as log an trigonometric functions) for an
11819 arbitrary float type.
11820
11821 The following predefined instantiations of this package exist
11822
11823 @table @code
11824 @item Short_Float
11825 @code{Ada.Numerics.Short_Elementary_Functions}
11826 @item Float
11827 @code{Ada.Numerics.Elementary_Functions}
11828 @item Long_Float
11829 @code{Ada.Numerics.Long_Elementary_Functions}
11830 @end table
11831
11832 @item Ada.Real_Time (D.8)
11833 This package provides facilities similar to those of @code{Calendar}, but
11834 operating with a finer clock suitable for real time control. Note that
11835 annex D requires that there be no backward clock jumps, and GNAT generally
11836 guarantees this behavior, but of course if the external clock on which
11837 the GNAT runtime depends is deliberately reset by some external event,
11838 then such a backward jump may occur.
11839
11840 @item Ada.Sequential_IO (A.8.1)
11841 This package provides input-output facilities for sequential files,
11842 which can contain a sequence of values of a single type, which can be
11843 any Ada type, including indefinite (unconstrained) types.
11844
11845 @item Ada.Storage_IO (A.9)
11846 This package provides a facility for mapping arbitrary Ada types to and
11847 from a storage buffer.  It is primarily intended for the creation of new
11848 IO packages.
11849
11850 @item Ada.Streams (13.13.1)
11851 This is a generic package that provides the basic support for the
11852 concept of streams as used by the stream attributes (@code{Input},
11853 @code{Output}, @code{Read} and @code{Write}).
11854
11855 @item Ada.Streams.Stream_IO (A.12.1)
11856 This package is a specialization of the type @code{Streams} defined in
11857 package @code{Streams} together with a set of operations providing
11858 Stream_IO capability.  The Stream_IO model permits both random and
11859 sequential access to a file which can contain an arbitrary set of values
11860 of one or more Ada types.
11861
11862 @item Ada.Strings (A.4.1)
11863 This package provides some basic constants used by the string handling
11864 packages.
11865
11866 @item Ada.Strings.Bounded (A.4.4)
11867 This package provides facilities for handling variable length
11868 strings.  The bounded model requires a maximum length.  It is thus
11869 somewhat more limited than the unbounded model, but avoids the use of
11870 dynamic allocation or finalization.
11871
11872 @item Ada.Strings.Fixed (A.4.3)
11873 This package provides facilities for handling fixed length strings.
11874
11875 @item Ada.Strings.Maps (A.4.2)
11876 This package provides facilities for handling character mappings and
11877 arbitrarily defined subsets of characters.  For instance it is useful in
11878 defining specialized translation tables.
11879
11880 @item Ada.Strings.Maps.Constants (A.4.6)
11881 This package provides a standard set of predefined mappings and
11882 predefined character sets.  For example, the standard upper to lower case
11883 conversion table is found in this package.  Note that upper to lower case
11884 conversion is non-trivial if you want to take the entire set of
11885 characters, including extended characters like E with an acute accent,
11886 into account.  You should use the mappings in this package (rather than
11887 adding 32 yourself) to do case mappings.
11888
11889 @item Ada.Strings.Unbounded (A.4.5)
11890 This package provides facilities for handling variable length
11891 strings.  The unbounded model allows arbitrary length strings, but
11892 requires the use of dynamic allocation and finalization.
11893
11894 @item Ada.Strings.Wide_Bounded (A.4.7)
11895 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11896 @itemx Ada.Strings.Wide_Maps (A.4.7)
11897 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11898 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11899 These packages provide analogous capabilities to the corresponding
11900 packages without @samp{Wide_} in the name, but operate with the types
11901 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11902 and @code{Character}.
11903
11904 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11905 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11906 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11907 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11908 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11909 These packages provide analogous capabilities to the corresponding
11910 packages without @samp{Wide_} in the name, but operate with the types
11911 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11912 of @code{String} and @code{Character}.
11913
11914 @item Ada.Synchronous_Task_Control (D.10)
11915 This package provides some standard facilities for controlling task
11916 communication in a synchronous manner.
11917
11918 @item Ada.Tags
11919 This package contains definitions for manipulation of the tags of tagged
11920 values.
11921
11922 @item Ada.Task_Attributes
11923 This package provides the capability of associating arbitrary
11924 task-specific data with separate tasks.
11925
11926 @item Ada.Text_IO
11927 This package provides basic text input-output capabilities for
11928 character, string and numeric data.  The subpackages of this
11929 package are listed next.
11930
11931 @item Ada.Text_IO.Decimal_IO
11932 Provides input-output facilities for decimal fixed-point types
11933
11934 @item Ada.Text_IO.Enumeration_IO
11935 Provides input-output facilities for enumeration types.
11936
11937 @item Ada.Text_IO.Fixed_IO
11938 Provides input-output facilities for ordinary fixed-point types.
11939
11940 @item Ada.Text_IO.Float_IO
11941 Provides input-output facilities for float types.  The following
11942 predefined instantiations of this generic package are available:
11943
11944 @table @code
11945 @item Short_Float
11946 @code{Short_Float_Text_IO}
11947 @item Float
11948 @code{Float_Text_IO}
11949 @item Long_Float
11950 @code{Long_Float_Text_IO}
11951 @end table
11952
11953 @item Ada.Text_IO.Integer_IO
11954 Provides input-output facilities for integer types.  The following
11955 predefined instantiations of this generic package are available:
11956
11957 @table @code
11958 @item Short_Short_Integer
11959 @code{Ada.Short_Short_Integer_Text_IO}
11960 @item Short_Integer
11961 @code{Ada.Short_Integer_Text_IO}
11962 @item Integer
11963 @code{Ada.Integer_Text_IO}
11964 @item Long_Integer
11965 @code{Ada.Long_Integer_Text_IO}
11966 @item Long_Long_Integer
11967 @code{Ada.Long_Long_Integer_Text_IO}
11968 @end table
11969
11970 @item Ada.Text_IO.Modular_IO
11971 Provides input-output facilities for modular (unsigned) types
11972
11973 @item Ada.Text_IO.Complex_IO (G.1.3)
11974 This package provides basic text input-output capabilities for complex
11975 data.
11976
11977 @item Ada.Text_IO.Editing (F.3.3)
11978 This package contains routines for edited output, analogous to the use
11979 of pictures in COBOL@.  The picture formats used by this package are a
11980 close copy of the facility in COBOL@.
11981
11982 @item Ada.Text_IO.Text_Streams (A.12.2)
11983 This package provides a facility that allows Text_IO files to be treated
11984 as streams, so that the stream attributes can be used for writing
11985 arbitrary data, including binary data, to Text_IO files.
11986
11987 @item Ada.Unchecked_Conversion (13.9)
11988 This generic package allows arbitrary conversion from one type to
11989 another of the same size, providing for breaking the type safety in
11990 special circumstances.
11991
11992 If the types have the same Size (more accurately the same Value_Size),
11993 then the effect is simply to transfer the bits from the source to the
11994 target type without any modification.  This usage is well defined, and
11995 for simple types whose representation is typically the same across
11996 all implementations, gives a portable method of performing such
11997 conversions.
11998
11999 If the types do not have the same size, then the result is implementation
12000 defined, and thus may be non-portable.  The following describes how GNAT
12001 handles such unchecked conversion cases.
12002
12003 If the types are of different sizes, and are both discrete types, then
12004 the effect is of a normal type conversion without any constraint checking.
12005 In particular if the result type has a larger size, the result will be
12006 zero or sign extended.  If the result type has a smaller size, the result
12007 will be truncated by ignoring high order bits.
12008
12009 If the types are of different sizes, and are not both discrete types,
12010 then the conversion works as though pointers were created to the source
12011 and target, and the pointer value is converted.  The effect is that bits
12012 are copied from successive low order storage units and bits of the source
12013 up to the length of the target type.
12014
12015 A warning is issued if the lengths differ, since the effect in this
12016 case is implementation dependent, and the above behavior may not match
12017 that of some other compiler.
12018
12019 A pointer to one type may be converted to a pointer to another type using
12020 unchecked conversion.  The only case in which the effect is undefined is
12021 when one or both pointers are pointers to unconstrained array types.  In
12022 this case, the bounds information may get incorrectly transferred, and in
12023 particular, GNAT uses double size pointers for such types, and it is
12024 meaningless to convert between such pointer types.  GNAT will issue a
12025 warning if the alignment of the target designated type is more strict
12026 than the alignment of the source designated type (since the result may
12027 be unaligned in this case).
12028
12029 A pointer other than a pointer to an unconstrained array type may be
12030 converted to and from System.Address.  Such usage is common in Ada 83
12031 programs, but note that Ada.Address_To_Access_Conversions is the
12032 preferred method of performing such conversions in Ada 95 and Ada 2005.
12033 Neither
12034 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12035 used in conjunction with pointers to unconstrained objects, since
12036 the bounds information cannot be handled correctly in this case.
12037
12038 @item Ada.Unchecked_Deallocation (13.11.2)
12039 This generic package allows explicit freeing of storage previously
12040 allocated by use of an allocator.
12041
12042 @item Ada.Wide_Text_IO (A.11)
12043 This package is similar to @code{Ada.Text_IO}, except that the external
12044 file supports wide character representations, and the internal types are
12045 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12046 and @code{String}.  It contains generic subpackages listed next.
12047
12048 @item Ada.Wide_Text_IO.Decimal_IO
12049 Provides input-output facilities for decimal fixed-point types
12050
12051 @item Ada.Wide_Text_IO.Enumeration_IO
12052 Provides input-output facilities for enumeration types.
12053
12054 @item Ada.Wide_Text_IO.Fixed_IO
12055 Provides input-output facilities for ordinary fixed-point types.
12056
12057 @item Ada.Wide_Text_IO.Float_IO
12058 Provides input-output facilities for float types.  The following
12059 predefined instantiations of this generic package are available:
12060
12061 @table @code
12062 @item Short_Float
12063 @code{Short_Float_Wide_Text_IO}
12064 @item Float
12065 @code{Float_Wide_Text_IO}
12066 @item Long_Float
12067 @code{Long_Float_Wide_Text_IO}
12068 @end table
12069
12070 @item Ada.Wide_Text_IO.Integer_IO
12071 Provides input-output facilities for integer types.  The following
12072 predefined instantiations of this generic package are available:
12073
12074 @table @code
12075 @item Short_Short_Integer
12076 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12077 @item Short_Integer
12078 @code{Ada.Short_Integer_Wide_Text_IO}
12079 @item Integer
12080 @code{Ada.Integer_Wide_Text_IO}
12081 @item Long_Integer
12082 @code{Ada.Long_Integer_Wide_Text_IO}
12083 @item Long_Long_Integer
12084 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12085 @end table
12086
12087 @item Ada.Wide_Text_IO.Modular_IO
12088 Provides input-output facilities for modular (unsigned) types
12089
12090 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12091 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12092 external file supports wide character representations.
12093
12094 @item Ada.Wide_Text_IO.Editing (F.3.4)
12095 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12096 types are @code{Wide_Character} and @code{Wide_String} instead of
12097 @code{Character} and @code{String}.
12098
12099 @item Ada.Wide_Text_IO.Streams (A.12.3)
12100 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12101 types are @code{Wide_Character} and @code{Wide_String} instead of
12102 @code{Character} and @code{String}.
12103
12104 @item Ada.Wide_Wide_Text_IO (A.11)
12105 This package is similar to @code{Ada.Text_IO}, except that the external
12106 file supports wide character representations, and the internal types are
12107 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12108 and @code{String}.  It contains generic subpackages listed next.
12109
12110 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12111 Provides input-output facilities for decimal fixed-point types
12112
12113 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12114 Provides input-output facilities for enumeration types.
12115
12116 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12117 Provides input-output facilities for ordinary fixed-point types.
12118
12119 @item Ada.Wide_Wide_Text_IO.Float_IO
12120 Provides input-output facilities for float types.  The following
12121 predefined instantiations of this generic package are available:
12122
12123 @table @code
12124 @item Short_Float
12125 @code{Short_Float_Wide_Wide_Text_IO}
12126 @item Float
12127 @code{Float_Wide_Wide_Text_IO}
12128 @item Long_Float
12129 @code{Long_Float_Wide_Wide_Text_IO}
12130 @end table
12131
12132 @item Ada.Wide_Wide_Text_IO.Integer_IO
12133 Provides input-output facilities for integer types.  The following
12134 predefined instantiations of this generic package are available:
12135
12136 @table @code
12137 @item Short_Short_Integer
12138 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12139 @item Short_Integer
12140 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12141 @item Integer
12142 @code{Ada.Integer_Wide_Wide_Text_IO}
12143 @item Long_Integer
12144 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12145 @item Long_Long_Integer
12146 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12147 @end table
12148
12149 @item Ada.Wide_Wide_Text_IO.Modular_IO
12150 Provides input-output facilities for modular (unsigned) types
12151
12152 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12153 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12154 external file supports wide character representations.
12155
12156 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12157 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12158 types are @code{Wide_Character} and @code{Wide_String} instead of
12159 @code{Character} and @code{String}.
12160
12161 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12162 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12163 types are @code{Wide_Character} and @code{Wide_String} instead of
12164 @code{Character} and @code{String}.
12165 @end table
12166
12167
12168
12169 @node The Implementation of Standard I/O
12170 @chapter The Implementation of Standard I/O
12171
12172 @noindent
12173 GNAT implements all the required input-output facilities described in
12174 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12175 required behavior of these packages from the Ada point of view, and if
12176 you are writing a portable Ada program that does not need to know the
12177 exact manner in which Ada maps to the outside world when it comes to
12178 reading or writing external files, then you do not need to read this
12179 chapter.  As long as your files are all regular files (not pipes or
12180 devices), and as long as you write and read the files only from Ada, the
12181 description in the Ada Reference Manual is sufficient.
12182
12183 However, if you want to do input-output to pipes or other devices, such
12184 as the keyboard or screen, or if the files you are dealing with are
12185 either generated by some other language, or to be read by some other
12186 language, then you need to know more about the details of how the GNAT
12187 implementation of these input-output facilities behaves.
12188
12189 In this chapter we give a detailed description of exactly how GNAT
12190 interfaces to the file system.  As always, the sources of the system are
12191 available to you for answering questions at an even more detailed level,
12192 but for most purposes the information in this chapter will suffice.
12193
12194 Another reason that you may need to know more about how input-output is
12195 implemented arises when you have a program written in mixed languages
12196 where, for example, files are shared between the C and Ada sections of
12197 the same program.  GNAT provides some additional facilities, in the form
12198 of additional child library packages, that facilitate this sharing, and
12199 these additional facilities are also described in this chapter.
12200
12201 @menu
12202 * Standard I/O Packages::
12203 * FORM Strings::
12204 * Direct_IO::
12205 * Sequential_IO::
12206 * Text_IO::
12207 * Wide_Text_IO::
12208 * Wide_Wide_Text_IO::
12209 * Stream_IO::
12210 * Text Translation::
12211 * Shared Files::
12212 * Filenames encoding::
12213 * Open Modes::
12214 * Operations on C Streams::
12215 * Interfacing to C Streams::
12216 @end menu
12217
12218 @node Standard I/O Packages
12219 @section Standard I/O Packages
12220
12221 @noindent
12222 The Standard I/O packages described in Annex A for
12223
12224 @itemize @bullet
12225 @item
12226 Ada.Text_IO
12227 @item
12228 Ada.Text_IO.Complex_IO
12229 @item
12230 Ada.Text_IO.Text_Streams
12231 @item
12232 Ada.Wide_Text_IO
12233 @item
12234 Ada.Wide_Text_IO.Complex_IO
12235 @item
12236 Ada.Wide_Text_IO.Text_Streams
12237 @item
12238 Ada.Wide_Wide_Text_IO
12239 @item
12240 Ada.Wide_Wide_Text_IO.Complex_IO
12241 @item
12242 Ada.Wide_Wide_Text_IO.Text_Streams
12243 @item
12244 Ada.Stream_IO
12245 @item
12246 Ada.Sequential_IO
12247 @item
12248 Ada.Direct_IO
12249 @end itemize
12250
12251 @noindent
12252 are implemented using the C
12253 library streams facility; where
12254
12255 @itemize @bullet
12256 @item
12257 All files are opened using @code{fopen}.
12258 @item
12259 All input/output operations use @code{fread}/@code{fwrite}.
12260 @end itemize
12261
12262 @noindent
12263 There is no internal buffering of any kind at the Ada library level. The only
12264 buffering is that provided at the system level in the implementation of the
12265 library routines that support streams. This facilitates shared use of these
12266 streams by mixed language programs. Note though that system level buffering is
12267 explicitly enabled at elaboration of the standard I/O packages and that can
12268 have an impact on mixed language programs, in particular those using I/O before
12269 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12270 the Ada elaboration routine before performing any I/O or when impractical,
12271 flush the common I/O streams and in particular Standard_Output before
12272 elaborating the Ada code.
12273
12274 @node FORM Strings
12275 @section FORM Strings
12276
12277 @noindent
12278 The format of a FORM string in GNAT is:
12279
12280 @smallexample
12281 "keyword=value,keyword=value,@dots{},keyword=value"
12282 @end smallexample
12283
12284 @noindent
12285 where letters may be in upper or lower case, and there are no spaces
12286 between values.  The order of the entries is not important.  Currently
12287 the following keywords defined.
12288
12289 @smallexample
12290 TEXT_TRANSLATION=[YES|NO]
12291 SHARED=[YES|NO]
12292 WCEM=[n|h|u|s|e|8|b]
12293 ENCODING=[UTF8|8BITS]
12294 @end smallexample
12295
12296 @noindent
12297 The use of these parameters is described later in this section.
12298
12299 @node Direct_IO
12300 @section Direct_IO
12301
12302 @noindent
12303 Direct_IO can only be instantiated for definite types.  This is a
12304 restriction of the Ada language, which means that the records are fixed
12305 length (the length being determined by @code{@var{type}'Size}, rounded
12306 up to the next storage unit boundary if necessary).
12307
12308 The records of a Direct_IO file are simply written to the file in index
12309 sequence, with the first record starting at offset zero, and subsequent
12310 records following.  There is no control information of any kind.  For
12311 example, if 32-bit integers are being written, each record takes
12312 4-bytes, so the record at index @var{K} starts at offset
12313 (@var{K}@minus{}1)*4.
12314
12315 There is no limit on the size of Direct_IO files, they are expanded as
12316 necessary to accommodate whatever records are written to the file.
12317
12318 @node Sequential_IO
12319 @section Sequential_IO
12320
12321 @noindent
12322 Sequential_IO may be instantiated with either a definite (constrained)
12323 or indefinite (unconstrained) type.
12324
12325 For the definite type case, the elements written to the file are simply
12326 the memory images of the data values with no control information of any
12327 kind.  The resulting file should be read using the same type, no validity
12328 checking is performed on input.
12329
12330 For the indefinite type case, the elements written consist of two
12331 parts.  First is the size of the data item, written as the memory image
12332 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12333 the data value.  The resulting file can only be read using the same
12334 (unconstrained) type.  Normal assignment checks are performed on these
12335 read operations, and if these checks fail, @code{Data_Error} is
12336 raised.  In particular, in the array case, the lengths must match, and in
12337 the variant record case, if the variable for a particular read operation
12338 is constrained, the discriminants must match.
12339
12340 Note that it is not possible to use Sequential_IO to write variable
12341 length array items, and then read the data back into different length
12342 arrays.  For example, the following will raise @code{Data_Error}:
12343
12344 @smallexample @c ada
12345  package IO is new Sequential_IO (String);
12346  F : IO.File_Type;
12347  S : String (1..4);
12348  @dots{}
12349  IO.Create (F)
12350  IO.Write (F, "hello!")
12351  IO.Reset (F, Mode=>In_File);
12352  IO.Read (F, S);
12353  Put_Line (S);
12354
12355 @end smallexample
12356
12357 @noindent
12358 On some Ada implementations, this will print @code{hell}, but the program is
12359 clearly incorrect, since there is only one element in the file, and that
12360 element is the string @code{hello!}.
12361
12362 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12363 using Stream_IO, and this is the preferred mechanism.  In particular, the
12364 above program fragment rewritten to use Stream_IO will work correctly.
12365
12366 @node Text_IO
12367 @section Text_IO
12368
12369 @noindent
12370 Text_IO files consist of a stream of characters containing the following
12371 special control characters:
12372
12373 @smallexample
12374 LF (line feed, 16#0A#) Line Mark
12375 FF (form feed, 16#0C#) Page Mark
12376 @end smallexample
12377
12378 @noindent
12379 A canonical Text_IO file is defined as one in which the following
12380 conditions are met:
12381
12382 @itemize @bullet
12383 @item
12384 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12385 of the line.
12386
12387 @item
12388 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12389 end of a page and consequently can appear only immediately following a
12390 @code{LF} (line mark) character.
12391
12392 @item
12393 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12394 (line mark, page mark).  In the former case, the page mark is implicitly
12395 assumed to be present.
12396 @end itemize
12397
12398 @noindent
12399 A file written using Text_IO will be in canonical form provided that no
12400 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12401 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12402 the file unless an explicit @code{New_Page} operation was performed
12403 before closing the file.
12404
12405 A canonical Text_IO file that is a regular file (i.e., not a device or a
12406 pipe) can be read using any of the routines in Text_IO@.  The
12407 semantics in this case will be exactly as defined in the Ada Reference
12408 Manual, and all the routines in Text_IO are fully implemented.
12409
12410 A text file that does not meet the requirements for a canonical Text_IO
12411 file has one of the following:
12412
12413 @itemize @bullet
12414 @item
12415 The file contains @code{FF} characters not immediately following a
12416 @code{LF} character.
12417
12418 @item
12419 The file contains @code{LF} or @code{FF} characters written by
12420 @code{Put} or @code{Put_Line}, which are not logically considered to be
12421 line marks or page marks.
12422
12423 @item
12424 The file ends in a character other than @code{LF} or @code{FF},
12425 i.e.@: there is no explicit line mark or page mark at the end of the file.
12426 @end itemize
12427
12428 @noindent
12429 Text_IO can be used to read such non-standard text files but subprograms
12430 to do with line or page numbers do not have defined meanings.  In
12431 particular, a @code{FF} character that does not follow a @code{LF}
12432 character may or may not be treated as a page mark from the point of
12433 view of page and line numbering.  Every @code{LF} character is considered
12434 to end a line, and there is an implied @code{LF} character at the end of
12435 the file.
12436
12437 @menu
12438 * Text_IO Stream Pointer Positioning::
12439 * Text_IO Reading and Writing Non-Regular Files::
12440 * Get_Immediate::
12441 * Treating Text_IO Files as Streams::
12442 * Text_IO Extensions::
12443 * Text_IO Facilities for Unbounded Strings::
12444 @end menu
12445
12446 @node Text_IO Stream Pointer Positioning
12447 @subsection Stream Pointer Positioning
12448
12449 @noindent
12450 @code{Ada.Text_IO} has a definition of current position for a file that
12451 is being read.  No internal buffering occurs in Text_IO, and usually the
12452 physical position in the stream used to implement the file corresponds
12453 to this logical position defined by Text_IO@.  There are two exceptions:
12454
12455 @itemize @bullet
12456 @item
12457 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12458 is positioned past the @code{LF} (line mark) that precedes the page
12459 mark.  Text_IO maintains an internal flag so that subsequent read
12460 operations properly handle the logical position which is unchanged by
12461 the @code{End_Of_Page} call.
12462
12463 @item
12464 After a call to @code{End_Of_File} that returns @code{True}, if the
12465 Text_IO file was positioned before the line mark at the end of file
12466 before the call, then the logical position is unchanged, but the stream
12467 is physically positioned right at the end of file (past the line mark,
12468 and past a possible page mark following the line mark.  Again Text_IO
12469 maintains internal flags so that subsequent read operations properly
12470 handle the logical position.
12471 @end itemize
12472
12473 @noindent
12474 These discrepancies have no effect on the observable behavior of
12475 Text_IO, but if a single Ada stream is shared between a C program and
12476 Ada program, or shared (using @samp{shared=yes} in the form string)
12477 between two Ada files, then the difference may be observable in some
12478 situations.
12479
12480 @node Text_IO Reading and Writing Non-Regular Files
12481 @subsection Reading and Writing Non-Regular Files
12482
12483 @noindent
12484 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12485 can be used for reading and writing.  Writing is not affected and the
12486 sequence of characters output is identical to the normal file case, but
12487 for reading, the behavior of Text_IO is modified to avoid undesirable
12488 look-ahead as follows:
12489
12490 An input file that is not a regular file is considered to have no page
12491 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12492 page mark) appearing in the file are considered to be data
12493 characters.  In particular:
12494
12495 @itemize @bullet
12496 @item
12497 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12498 following a line mark.  If a page mark appears, it will be treated as a
12499 data character.
12500
12501 @item
12502 This avoids the need to wait for an extra character to be typed or
12503 entered from the pipe to complete one of these operations.
12504
12505 @item
12506 @code{End_Of_Page} always returns @code{False}
12507
12508 @item
12509 @code{End_Of_File} will return @code{False} if there is a page mark at
12510 the end of the file.
12511 @end itemize
12512
12513 @noindent
12514 Output to non-regular files is the same as for regular files.  Page marks
12515 may be written to non-regular files using @code{New_Page}, but as noted
12516 above they will not be treated as page marks on input if the output is
12517 piped to another Ada program.
12518
12519 Another important discrepancy when reading non-regular files is that the end
12520 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12521 pressing the @key{EOT} key,
12522 then end of file
12523 is signaled once (i.e.@: the test @code{End_Of_File}
12524 will yield @code{True}, or a read will
12525 raise @code{End_Error}), but then reading can resume
12526 to read data past that end of
12527 file indication, until another end of file indication is entered.
12528
12529 @node Get_Immediate
12530 @subsection Get_Immediate
12531 @cindex Get_Immediate
12532
12533 @noindent
12534 Get_Immediate returns the next character (including control characters)
12535 from the input file.  In particular, Get_Immediate will return LF or FF
12536 characters used as line marks or page marks.  Such operations leave the
12537 file positioned past the control character, and it is thus not treated
12538 as having its normal function.  This means that page, line and column
12539 counts after this kind of Get_Immediate call are set as though the mark
12540 did not occur.  In the case where a Get_Immediate leaves the file
12541 positioned between the line mark and page mark (which is not normally
12542 possible), it is undefined whether the FF character will be treated as a
12543 page mark.
12544
12545 @node Treating Text_IO Files as Streams
12546 @subsection Treating Text_IO Files as Streams
12547 @cindex Stream files
12548
12549 @noindent
12550 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12551 as a stream.  Data written to a Text_IO file in this stream mode is
12552 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12553 16#0C# (@code{FF}), the resulting file may have non-standard
12554 format.  Similarly if read operations are used to read from a Text_IO
12555 file treated as a stream, then @code{LF} and @code{FF} characters may be
12556 skipped and the effect is similar to that described above for
12557 @code{Get_Immediate}.
12558
12559 @node Text_IO Extensions
12560 @subsection Text_IO Extensions
12561 @cindex Text_IO extensions
12562
12563 @noindent
12564 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12565 to the standard @code{Text_IO} package:
12566
12567 @itemize @bullet
12568 @item function File_Exists (Name : String) return Boolean;
12569 Determines if a file of the given name exists.
12570
12571 @item function Get_Line return String;
12572 Reads a string from the standard input file.  The value returned is exactly
12573 the length of the line that was read.
12574
12575 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12576 Similar, except that the parameter File specifies the file from which
12577 the string is to be read.
12578
12579 @end itemize
12580
12581 @node Text_IO Facilities for Unbounded Strings
12582 @subsection Text_IO Facilities for Unbounded Strings
12583 @cindex Text_IO for unbounded strings
12584 @cindex Unbounded_String, Text_IO operations
12585
12586 @noindent
12587 The package @code{Ada.Strings.Unbounded.Text_IO}
12588 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12589 subprograms useful for Text_IO operations on unbounded strings:
12590
12591 @itemize @bullet
12592
12593 @item function Get_Line (File : File_Type) return Unbounded_String;
12594 Reads a line from the specified file
12595 and returns the result as an unbounded string.
12596
12597 @item procedure Put (File : File_Type; U : Unbounded_String);
12598 Writes the value of the given unbounded string to the specified file
12599 Similar to the effect of
12600 @code{Put (To_String (U))} except that an extra copy is avoided.
12601
12602 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12603 Writes the value of the given unbounded string to the specified file,
12604 followed by a @code{New_Line}.
12605 Similar to the effect of @code{Put_Line (To_String (U))} except
12606 that an extra copy is avoided.
12607 @end itemize
12608
12609 @noindent
12610 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12611 and is optional.  If the parameter is omitted, then the standard input or
12612 output file is referenced as appropriate.
12613
12614 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12615 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12616 @code{Wide_Text_IO} functionality for unbounded wide strings.
12617
12618 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12619 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12620 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12621
12622 @node Wide_Text_IO
12623 @section Wide_Text_IO
12624
12625 @noindent
12626 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12627 both input and output files may contain special sequences that represent
12628 wide character values.  The encoding scheme for a given file may be
12629 specified using a FORM parameter:
12630
12631 @smallexample
12632 WCEM=@var{x}
12633 @end smallexample
12634
12635 @noindent
12636 as part of the FORM string (WCEM = wide character encoding method),
12637 where @var{x} is one of the following characters
12638
12639 @table @samp
12640 @item h
12641 Hex ESC encoding
12642 @item u
12643 Upper half encoding
12644 @item s
12645 Shift-JIS encoding
12646 @item e
12647 EUC Encoding
12648 @item 8
12649 UTF-8 encoding
12650 @item b
12651 Brackets encoding
12652 @end table
12653
12654 @noindent
12655 The encoding methods match those that
12656 can be used in a source
12657 program, but there is no requirement that the encoding method used for
12658 the source program be the same as the encoding method used for files,
12659 and different files may use different encoding methods.
12660
12661 The default encoding method for the standard files, and for opened files
12662 for which no WCEM parameter is given in the FORM string matches the
12663 wide character encoding specified for the main program (the default
12664 being brackets encoding if no coding method was specified with -gnatW).
12665
12666 @table @asis
12667 @item Hex Coding
12668 In this encoding, a wide character is represented by a five character
12669 sequence:
12670
12671 @smallexample
12672 ESC a b c d
12673 @end smallexample
12674
12675 @noindent
12676 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12677 characters (using upper case letters) of the wide character code.  For
12678 example, ESC A345 is used to represent the wide character with code
12679 16#A345#.  This scheme is compatible with use of the full
12680 @code{Wide_Character} set.
12681
12682 @item Upper Half Coding
12683 The wide character with encoding 16#abcd#, where the upper bit is on
12684 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12685 16#cd#.  The second byte may never be a format control character, but is
12686 not required to be in the upper half.  This method can be also used for
12687 shift-JIS or EUC where the internal coding matches the external coding.
12688
12689 @item Shift JIS Coding
12690 A wide character is represented by a two character sequence 16#ab# and
12691 16#cd#, with the restrictions described for upper half encoding as
12692 described above.  The internal character code is the corresponding JIS
12693 character according to the standard algorithm for Shift-JIS
12694 conversion.  Only characters defined in the JIS code set table can be
12695 used with this encoding method.
12696
12697 @item EUC Coding
12698 A wide character is represented by a two character sequence 16#ab# and
12699 16#cd#, with both characters being in the upper half.  The internal
12700 character code is the corresponding JIS character according to the EUC
12701 encoding algorithm.  Only characters defined in the JIS code set table
12702 can be used with this encoding method.
12703
12704 @item UTF-8 Coding
12705 A wide character is represented using
12706 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12707 10646-1/Am.2.  Depending on the character value, the representation
12708 is a one, two, or three byte sequence:
12709
12710 @smallexample
12711 16#0000#-16#007f#: 2#0xxxxxxx#
12712 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12713 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12714 @end smallexample
12715
12716 @noindent
12717 where the @var{xxx} bits correspond to the left-padded bits of the
12718 16-bit character value.  Note that all lower half ASCII characters
12719 are represented as ASCII bytes and all upper half characters and
12720 other wide characters are represented as sequences of upper-half
12721 (The full UTF-8 scheme allows for encoding 31-bit characters as
12722 6-byte sequences, but in this implementation, all UTF-8 sequences
12723 of four or more bytes length will raise a Constraint_Error, as
12724 will all invalid UTF-8 sequences.)
12725
12726 @item Brackets Coding
12727 In this encoding, a wide character is represented by the following eight
12728 character sequence:
12729
12730 @smallexample
12731 [ " a b c d " ]
12732 @end smallexample
12733
12734 @noindent
12735 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12736 characters (using uppercase letters) of the wide character code.  For
12737 example, @code{["A345"]} is used to represent the wide character with code
12738 @code{16#A345#}.
12739 This scheme is compatible with use of the full Wide_Character set.
12740 On input, brackets coding can also be used for upper half characters,
12741 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12742 is only used for wide characters with a code greater than @code{16#FF#}.
12743
12744 Note that brackets coding is not normally used in the context of
12745 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12746 a portable way of encoding source files. In the context of Wide_Text_IO
12747 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12748 any instance of the left bracket character other than to encode wide
12749 character values using the brackets encoding method. In practice it is
12750 expected that some standard wide character encoding method such
12751 as UTF-8 will be used for text input output.
12752
12753 If brackets notation is used, then any occurrence of a left bracket
12754 in the input file which is not the start of a valid wide character
12755 sequence will cause Constraint_Error to be raised. It is possible to
12756 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12757 input will interpret this as a left bracket.
12758
12759 However, when a left bracket is output, it will be output as a left bracket
12760 and not as ["5B"]. We make this decision because for normal use of
12761 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12762 brackets. For example, if we write:
12763
12764 @smallexample
12765    Put_Line ("Start of output [first run]");
12766 @end smallexample
12767
12768 @noindent
12769 we really do not want to have the left bracket in this message clobbered so
12770 that the output reads:
12771
12772 @smallexample
12773    Start of output ["5B"]first run]
12774 @end smallexample
12775
12776 @noindent
12777 In practice brackets encoding is reasonably useful for normal Put_Line use
12778 since we won't get confused between left brackets and wide character
12779 sequences in the output. But for input, or when files are written out
12780 and read back in, it really makes better sense to use one of the standard
12781 encoding methods such as UTF-8.
12782
12783 @end table
12784
12785 @noindent
12786 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12787 not all wide character
12788 values can be represented.  An attempt to output a character that cannot
12789 be represented using the encoding scheme for the file causes
12790 Constraint_Error to be raised.  An invalid wide character sequence on
12791 input also causes Constraint_Error to be raised.
12792
12793 @menu
12794 * Wide_Text_IO Stream Pointer Positioning::
12795 * Wide_Text_IO Reading and Writing Non-Regular Files::
12796 @end menu
12797
12798 @node Wide_Text_IO Stream Pointer Positioning
12799 @subsection Stream Pointer Positioning
12800
12801 @noindent
12802 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12803 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12804 case:
12805
12806 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12807 normal lower ASCII set (i.e.@: a character in the range:
12808
12809 @smallexample @c ada
12810 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12811 @end smallexample
12812
12813 @noindent
12814 then although the logical position of the file pointer is unchanged by
12815 the @code{Look_Ahead} call, the stream is physically positioned past the
12816 wide character sequence.  Again this is to avoid the need for buffering
12817 or backup, and all @code{Wide_Text_IO} routines check the internal
12818 indication that this situation has occurred so that this is not visible
12819 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12820 can be observed if the wide text file shares a stream with another file.
12821
12822 @node Wide_Text_IO Reading and Writing Non-Regular Files
12823 @subsection Reading and Writing Non-Regular Files
12824
12825 @noindent
12826 As in the case of Text_IO, when a non-regular file is read, it is
12827 assumed that the file contains no page marks (any form characters are
12828 treated as data characters), and @code{End_Of_Page} always returns
12829 @code{False}.  Similarly, the end of file indication is not sticky, so
12830 it is possible to read beyond an end of file.
12831
12832 @node Wide_Wide_Text_IO
12833 @section Wide_Wide_Text_IO
12834
12835 @noindent
12836 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12837 both input and output files may contain special sequences that represent
12838 wide wide character values.  The encoding scheme for a given file may be
12839 specified using a FORM parameter:
12840
12841 @smallexample
12842 WCEM=@var{x}
12843 @end smallexample
12844
12845 @noindent
12846 as part of the FORM string (WCEM = wide character encoding method),
12847 where @var{x} is one of the following characters
12848
12849 @table @samp
12850 @item h
12851 Hex ESC encoding
12852 @item u
12853 Upper half encoding
12854 @item s
12855 Shift-JIS encoding
12856 @item e
12857 EUC Encoding
12858 @item 8
12859 UTF-8 encoding
12860 @item b
12861 Brackets encoding
12862 @end table
12863
12864 @noindent
12865 The encoding methods match those that
12866 can be used in a source
12867 program, but there is no requirement that the encoding method used for
12868 the source program be the same as the encoding method used for files,
12869 and different files may use different encoding methods.
12870
12871 The default encoding method for the standard files, and for opened files
12872 for which no WCEM parameter is given in the FORM string matches the
12873 wide character encoding specified for the main program (the default
12874 being brackets encoding if no coding method was specified with -gnatW).
12875
12876 @table @asis
12877
12878 @item UTF-8 Coding
12879 A wide character is represented using
12880 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12881 10646-1/Am.2.  Depending on the character value, the representation
12882 is a one, two, three, or four byte sequence:
12883
12884 @smallexample
12885 16#000000#-16#00007f#: 2#0xxxxxxx#
12886 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12887 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12888 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12889 @end smallexample
12890
12891 @noindent
12892 where the @var{xxx} bits correspond to the left-padded bits of the
12893 21-bit character value.  Note that all lower half ASCII characters
12894 are represented as ASCII bytes and all upper half characters and
12895 other wide characters are represented as sequences of upper-half
12896 characters.
12897
12898 @item Brackets Coding
12899 In this encoding, a wide wide character is represented by the following eight
12900 character sequence if is in wide character range
12901
12902 @smallexample
12903 [ " a b c d " ]
12904 @end smallexample
12905
12906 and by the following ten character sequence if not
12907
12908 @smallexample
12909 [ " a b c d e f " ]
12910 @end smallexample
12911
12912 @noindent
12913 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12914 are the four or six hexadecimal
12915 characters (using uppercase letters) of the wide wide character code.  For
12916 example, @code{["01A345"]} is used to represent the wide wide character
12917 with code @code{16#01A345#}.
12918
12919 This scheme is compatible with use of the full Wide_Wide_Character set.
12920 On input, brackets coding can also be used for upper half characters,
12921 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12922 is only used for wide characters with a code greater than @code{16#FF#}.
12923
12924 @end table
12925
12926 @noindent
12927 If is also possible to use the other Wide_Character encoding methods,
12928 such as Shift-JIS, but the other schemes cannot support the full range
12929 of wide wide characters.
12930 An attempt to output a character that cannot
12931 be represented using the encoding scheme for the file causes
12932 Constraint_Error to be raised.  An invalid wide character sequence on
12933 input also causes Constraint_Error to be raised.
12934
12935 @menu
12936 * Wide_Wide_Text_IO Stream Pointer Positioning::
12937 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12938 @end menu
12939
12940 @node Wide_Wide_Text_IO Stream Pointer Positioning
12941 @subsection Stream Pointer Positioning
12942
12943 @noindent
12944 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12945 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12946 case:
12947
12948 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12949 normal lower ASCII set (i.e.@: a character in the range:
12950
12951 @smallexample @c ada
12952 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12953 @end smallexample
12954
12955 @noindent
12956 then although the logical position of the file pointer is unchanged by
12957 the @code{Look_Ahead} call, the stream is physically positioned past the
12958 wide character sequence.  Again this is to avoid the need for buffering
12959 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12960 indication that this situation has occurred so that this is not visible
12961 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12962 can be observed if the wide text file shares a stream with another file.
12963
12964 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12965 @subsection Reading and Writing Non-Regular Files
12966
12967 @noindent
12968 As in the case of Text_IO, when a non-regular file is read, it is
12969 assumed that the file contains no page marks (any form characters are
12970 treated as data characters), and @code{End_Of_Page} always returns
12971 @code{False}.  Similarly, the end of file indication is not sticky, so
12972 it is possible to read beyond an end of file.
12973
12974 @node Stream_IO
12975 @section Stream_IO
12976
12977 @noindent
12978 A stream file is a sequence of bytes, where individual elements are
12979 written to the file as described in the Ada Reference Manual.  The type
12980 @code{Stream_Element} is simply a byte.  There are two ways to read or
12981 write a stream file.
12982
12983 @itemize @bullet
12984 @item
12985 The operations @code{Read} and @code{Write} directly read or write a
12986 sequence of stream elements with no control information.
12987
12988 @item
12989 The stream attributes applied to a stream file transfer data in the
12990 manner described for stream attributes.
12991 @end itemize
12992
12993 @node Text Translation
12994 @section Text Translation
12995
12996 @noindent
12997 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
12998 passed to Text_IO.Create and Text_IO.Open:
12999 @samp{Text_Translation=@var{Yes}} is the default, which means to
13000 translate LF to/from CR/LF on Windows systems.
13001 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13002 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13003 may be used to create Unix-style files on
13004 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13005 systems.
13006
13007 @node Shared Files
13008 @section Shared Files
13009
13010 @noindent
13011 Section A.14 of the Ada Reference Manual allows implementations to
13012 provide a wide variety of behavior if an attempt is made to access the
13013 same external file with two or more internal files.
13014
13015 To provide a full range of functionality, while at the same time
13016 minimizing the problems of portability caused by this implementation
13017 dependence, GNAT handles file sharing as follows:
13018
13019 @itemize @bullet
13020 @item
13021 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13022 to open two or more files with the same full name is considered an error
13023 and is not supported.  The exception @code{Use_Error} will be
13024 raised.  Note that a file that is not explicitly closed by the program
13025 remains open until the program terminates.
13026
13027 @item
13028 If the form parameter @samp{shared=no} appears in the form string, the
13029 file can be opened or created with its own separate stream identifier,
13030 regardless of whether other files sharing the same external file are
13031 opened.  The exact effect depends on how the C stream routines handle
13032 multiple accesses to the same external files using separate streams.
13033
13034 @item
13035 If the form parameter @samp{shared=yes} appears in the form string for
13036 each of two or more files opened using the same full name, the same
13037 stream is shared between these files, and the semantics are as described
13038 in Ada Reference Manual, Section A.14.
13039 @end itemize
13040
13041 @noindent
13042 When a program that opens multiple files with the same name is ported
13043 from another Ada compiler to GNAT, the effect will be that
13044 @code{Use_Error} is raised.
13045
13046 The documentation of the original compiler and the documentation of the
13047 program should then be examined to determine if file sharing was
13048 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13049 and @code{Create} calls as required.
13050
13051 When a program is ported from GNAT to some other Ada compiler, no
13052 special attention is required unless the @samp{shared=@var{xxx}} form
13053 parameter is used in the program.  In this case, you must examine the
13054 documentation of the new compiler to see if it supports the required
13055 file sharing semantics, and form strings modified appropriately.  Of
13056 course it may be the case that the program cannot be ported if the
13057 target compiler does not support the required functionality.  The best
13058 approach in writing portable code is to avoid file sharing (and hence
13059 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13060 completely.
13061
13062 One common use of file sharing in Ada 83 is the use of instantiations of
13063 Sequential_IO on the same file with different types, to achieve
13064 heterogeneous input-output.  Although this approach will work in GNAT if
13065 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13066 for this purpose (using the stream attributes)
13067
13068 @node Filenames encoding
13069 @section Filenames encoding
13070
13071 @noindent
13072 An encoding form parameter can be used to specify the filename
13073 encoding @samp{encoding=@var{xxx}}.
13074
13075 @itemize @bullet
13076 @item
13077 If the form parameter @samp{encoding=utf8} appears in the form string, the
13078 filename must be encoded in UTF-8.
13079
13080 @item
13081 If the form parameter @samp{encoding=8bits} appears in the form
13082 string, the filename must be a standard 8bits string.
13083 @end itemize
13084
13085 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13086 value UTF-8 is used. This encoding form parameter is only supported on
13087 the Windows platform. On the other Operating Systems the runtime is
13088 supporting UTF-8 natively.
13089
13090 @node Open Modes
13091 @section Open Modes
13092
13093 @noindent
13094 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13095 using the mode shown in the following table:
13096
13097 @sp 2
13098 @center @code{Open} and @code{Create} Call Modes
13099 @smallexample
13100                                @b{OPEN }           @b{CREATE}
13101 Append_File                    "r+"             "w+"
13102 In_File                        "r"              "w+"
13103 Out_File (Direct_IO)           "r+"             "w"
13104 Out_File (all other cases)     "w"              "w"
13105 Inout_File                     "r+"             "w+"
13106 @end smallexample
13107
13108 @noindent
13109 If text file translation is required, then either @samp{b} or @samp{t}
13110 is added to the mode, depending on the setting of Text.  Text file
13111 translation refers to the mapping of CR/LF sequences in an external file
13112 to LF characters internally.  This mapping only occurs in DOS and
13113 DOS-like systems, and is not relevant to other systems.
13114
13115 A special case occurs with Stream_IO@.  As shown in the above table, the
13116 file is initially opened in @samp{r} or @samp{w} mode for the
13117 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13118 subsequently requires switching from reading to writing or vice-versa,
13119 then the file is reopened in @samp{r+} mode to permit the required operation.
13120
13121 @node Operations on C Streams
13122 @section Operations on C Streams
13123 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13124 access to the C library functions for operations on C streams:
13125
13126 @smallexample @c adanocomment
13127 package Interfaces.C_Streams is
13128   -- Note: the reason we do not use the types that are in
13129   -- Interfaces.C is that we want to avoid dragging in the
13130   -- code in this unit if possible.
13131   subtype chars is System.Address;
13132   -- Pointer to null-terminated array of characters
13133   subtype FILEs is System.Address;
13134   -- Corresponds to the C type FILE*
13135   subtype voids is System.Address;
13136   -- Corresponds to the C type void*
13137   subtype int is Integer;
13138   subtype long is Long_Integer;
13139   -- Note: the above types are subtypes deliberately, and it
13140   -- is part of this spec that the above correspondences are
13141   -- guaranteed.  This means that it is legitimate to, for
13142   -- example, use Integer instead of int.  We provide these
13143   -- synonyms for clarity, but in some cases it may be
13144   -- convenient to use the underlying types (for example to
13145   -- avoid an unnecessary dependency of a spec on the spec
13146   -- of this unit).
13147   type size_t is mod 2 ** Standard'Address_Size;
13148   NULL_Stream : constant FILEs;
13149   -- Value returned (NULL in C) to indicate an
13150   -- fdopen/fopen/tmpfile error
13151   ----------------------------------
13152   -- Constants Defined in stdio.h --
13153   ----------------------------------
13154   EOF : constant int;
13155   -- Used by a number of routines to indicate error or
13156   -- end of file
13157   IOFBF : constant int;
13158   IOLBF : constant int;
13159   IONBF : constant int;
13160   -- Used to indicate buffering mode for setvbuf call
13161   SEEK_CUR : constant int;
13162   SEEK_END : constant int;
13163   SEEK_SET : constant int;
13164   -- Used to indicate origin for fseek call
13165   function stdin return FILEs;
13166   function stdout return FILEs;
13167   function stderr return FILEs;
13168   -- Streams associated with standard files
13169   --------------------------
13170   -- Standard C functions --
13171   --------------------------
13172   -- The functions selected below are ones that are
13173   -- available in DOS, OS/2, UNIX and Xenix (but not
13174   -- necessarily in ANSI C).  These are very thin interfaces
13175   -- which copy exactly the C headers.  For more
13176   -- documentation on these functions, see the Microsoft C
13177   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13178   -- ISBN 1-55615-225-6), which includes useful information
13179   -- on system compatibility.
13180   procedure clearerr (stream : FILEs);
13181   function fclose (stream : FILEs) return int;
13182   function fdopen (handle : int; mode : chars) return FILEs;
13183   function feof (stream : FILEs) return int;
13184   function ferror (stream : FILEs) return int;
13185   function fflush (stream : FILEs) return int;
13186   function fgetc (stream : FILEs) return int;
13187   function fgets (strng : chars; n : int; stream : FILEs)
13188       return chars;
13189   function fileno (stream : FILEs) return int;
13190   function fopen (filename : chars; Mode : chars)
13191       return FILEs;
13192   -- Note: to maintain target independence, use
13193   -- text_translation_required, a boolean variable defined in
13194   -- a-sysdep.c to deal with the target dependent text
13195   -- translation requirement.  If this variable is set,
13196   -- then  b/t should be appended to the standard mode
13197   -- argument to set the text translation mode off or on
13198   -- as required.
13199   function fputc (C : int; stream : FILEs) return int;
13200   function fputs (Strng : chars; Stream : FILEs) return int;
13201   function fread
13202      (buffer : voids;
13203       size : size_t;
13204       count : size_t;
13205       stream : FILEs)
13206       return size_t;
13207   function freopen
13208      (filename : chars;
13209       mode : chars;
13210       stream : FILEs)
13211       return FILEs;
13212   function fseek
13213      (stream : FILEs;
13214       offset : long;
13215       origin : int)
13216       return int;
13217   function ftell (stream : FILEs) return long;
13218   function fwrite
13219      (buffer : voids;
13220       size : size_t;
13221       count : size_t;
13222       stream : FILEs)
13223       return size_t;
13224   function isatty (handle : int) return int;
13225   procedure mktemp (template : chars);
13226   -- The return value (which is just a pointer to template)
13227   -- is discarded
13228   procedure rewind (stream : FILEs);
13229   function rmtmp return int;
13230   function setvbuf
13231      (stream : FILEs;
13232       buffer : chars;
13233       mode : int;
13234       size : size_t)
13235       return int;
13236
13237   function tmpfile return FILEs;
13238   function ungetc (c : int; stream : FILEs) return int;
13239   function unlink (filename : chars) return int;
13240   ---------------------
13241   -- Extra functions --
13242   ---------------------
13243   -- These functions supply slightly thicker bindings than
13244   -- those above.  They are derived from functions in the
13245   -- C Run-Time Library, but may do a bit more work than
13246   -- just directly calling one of the Library functions.
13247   function is_regular_file (handle : int) return int;
13248   -- Tests if given handle is for a regular file (result 1)
13249   -- or for a non-regular file (pipe or device, result 0).
13250   ---------------------------------
13251   -- Control of Text/Binary Mode --
13252   ---------------------------------
13253   -- If text_translation_required is true, then the following
13254   -- functions may be used to dynamically switch a file from
13255   -- binary to text mode or vice versa.  These functions have
13256   -- no effect if text_translation_required is false (i.e.@: in
13257   -- normal UNIX mode).  Use fileno to get a stream handle.
13258   procedure set_binary_mode (handle : int);
13259   procedure set_text_mode (handle : int);
13260   ----------------------------
13261   -- Full Path Name support --
13262   ----------------------------
13263   procedure full_name (nam : chars; buffer : chars);
13264   -- Given a NUL terminated string representing a file
13265   -- name, returns in buffer a NUL terminated string
13266   -- representing the full path name for the file name.
13267   -- On systems where it is relevant the   drive is also
13268   -- part of the full path name.  It is the responsibility
13269   -- of the caller to pass an actual parameter for buffer
13270   -- that is big enough for any full path name.  Use
13271   -- max_path_len given below as the size of buffer.
13272   max_path_len : integer;
13273   -- Maximum length of an allowable full path name on the
13274   -- system, including a terminating NUL character.
13275 end Interfaces.C_Streams;
13276 @end smallexample
13277
13278 @node Interfacing to C Streams
13279 @section Interfacing to C Streams
13280
13281 @noindent
13282 The packages in this section permit interfacing Ada files to C Stream
13283 operations.
13284
13285 @smallexample @c ada
13286  with Interfaces.C_Streams;
13287  package Ada.Sequential_IO.C_Streams is
13288     function C_Stream (F : File_Type)
13289        return Interfaces.C_Streams.FILEs;
13290     procedure Open
13291       (File : in out File_Type;
13292        Mode : in File_Mode;
13293        C_Stream : in Interfaces.C_Streams.FILEs;
13294        Form : in String := "");
13295  end Ada.Sequential_IO.C_Streams;
13296
13297   with Interfaces.C_Streams;
13298   package Ada.Direct_IO.C_Streams is
13299      function C_Stream (F : File_Type)
13300         return Interfaces.C_Streams.FILEs;
13301      procedure Open
13302        (File : in out File_Type;
13303         Mode : in File_Mode;
13304         C_Stream : in Interfaces.C_Streams.FILEs;
13305         Form : in String := "");
13306   end Ada.Direct_IO.C_Streams;
13307
13308   with Interfaces.C_Streams;
13309   package Ada.Text_IO.C_Streams is
13310      function C_Stream (F : File_Type)
13311         return Interfaces.C_Streams.FILEs;
13312      procedure Open
13313        (File : in out File_Type;
13314         Mode : in File_Mode;
13315         C_Stream : in Interfaces.C_Streams.FILEs;
13316         Form : in String := "");
13317   end Ada.Text_IO.C_Streams;
13318
13319   with Interfaces.C_Streams;
13320   package Ada.Wide_Text_IO.C_Streams is
13321      function C_Stream (F : File_Type)
13322         return Interfaces.C_Streams.FILEs;
13323      procedure Open
13324        (File : in out File_Type;
13325         Mode : in File_Mode;
13326         C_Stream : in Interfaces.C_Streams.FILEs;
13327         Form : in String := "");
13328  end Ada.Wide_Text_IO.C_Streams;
13329
13330   with Interfaces.C_Streams;
13331   package Ada.Wide_Wide_Text_IO.C_Streams is
13332      function C_Stream (F : File_Type)
13333         return Interfaces.C_Streams.FILEs;
13334      procedure Open
13335        (File : in out File_Type;
13336         Mode : in File_Mode;
13337         C_Stream : in Interfaces.C_Streams.FILEs;
13338         Form : in String := "");
13339  end Ada.Wide_Wide_Text_IO.C_Streams;
13340
13341  with Interfaces.C_Streams;
13342  package Ada.Stream_IO.C_Streams is
13343     function C_Stream (F : File_Type)
13344        return Interfaces.C_Streams.FILEs;
13345     procedure Open
13346       (File : in out File_Type;
13347        Mode : in File_Mode;
13348        C_Stream : in Interfaces.C_Streams.FILEs;
13349        Form : in String := "");
13350  end Ada.Stream_IO.C_Streams;
13351 @end smallexample
13352
13353 @noindent
13354 In each of these six packages, the @code{C_Stream} function obtains the
13355 @code{FILE} pointer from a currently opened Ada file.  It is then
13356 possible to use the @code{Interfaces.C_Streams} package to operate on
13357 this stream, or the stream can be passed to a C program which can
13358 operate on it directly.  Of course the program is responsible for
13359 ensuring that only appropriate sequences of operations are executed.
13360
13361 One particular use of relevance to an Ada program is that the
13362 @code{setvbuf} function can be used to control the buffering of the
13363 stream used by an Ada file.  In the absence of such a call the standard
13364 default buffering is used.
13365
13366 The @code{Open} procedures in these packages open a file giving an
13367 existing C Stream instead of a file name.  Typically this stream is
13368 imported from a C program, allowing an Ada file to operate on an
13369 existing C file.
13370
13371 @node The GNAT Library
13372 @chapter The GNAT Library
13373
13374 @noindent
13375 The GNAT library contains a number of general and special purpose packages.
13376 It represents functionality that the GNAT developers have found useful, and
13377 which is made available to GNAT users.  The packages described here are fully
13378 supported, and upwards compatibility will be maintained in future releases,
13379 so you can use these facilities with the confidence that the same functionality
13380 will be available in future releases.
13381
13382 The chapter here simply gives a brief summary of the facilities available.
13383 The full documentation is found in the spec file for the package.  The full
13384 sources of these library packages, including both spec and body, are provided
13385 with all GNAT releases.  For example, to find out the full specifications of
13386 the SPITBOL pattern matching capability, including a full tutorial and
13387 extensive examples, look in the @file{g-spipat.ads} file in the library.
13388
13389 For each entry here, the package name (as it would appear in a @code{with}
13390 clause) is given, followed by the name of the corresponding spec file in
13391 parentheses.  The packages are children in four hierarchies, @code{Ada},
13392 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13393 GNAT-specific hierarchy.
13394
13395 Note that an application program should only use packages in one of these
13396 four hierarchies if the package is defined in the Ada Reference Manual,
13397 or is listed in this section of the GNAT Programmers Reference Manual.
13398 All other units should be considered internal implementation units and
13399 should not be directly @code{with}'ed by application code.  The use of
13400 a @code{with} statement that references one of these internal implementation
13401 units makes an application potentially dependent on changes in versions
13402 of GNAT, and will generate a warning message.
13403
13404 @menu
13405 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13406 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13407 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13408 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13409 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13410 * Ada.Command_Line.Environment (a-colien.ads)::
13411 * Ada.Command_Line.Remove (a-colire.ads)::
13412 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13413 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13414 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13415 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13416 * Ada.Exceptions.Traceback (a-exctra.ads)::
13417 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13418 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13419 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13420 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13421 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13422 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13423 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13424 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13425 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13426 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13427 * GNAT.Altivec (g-altive.ads)::
13428 * GNAT.Altivec.Conversions (g-altcon.ads)::
13429 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13430 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13431 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13432 * GNAT.Array_Split (g-arrspl.ads)::
13433 * GNAT.AWK (g-awk.ads)::
13434 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13435 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13436 * GNAT.Bubble_Sort (g-bubsor.ads)::
13437 * GNAT.Bubble_Sort_A (g-busora.ads)::
13438 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13439 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13440 * GNAT.Byte_Swapping (g-bytswa.ads)::
13441 * GNAT.Calendar (g-calend.ads)::
13442 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13443 * GNAT.Case_Util (g-casuti.ads)::
13444 * GNAT.CGI (g-cgi.ads)::
13445 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13446 * GNAT.CGI.Debug (g-cgideb.ads)::
13447 * GNAT.Command_Line (g-comlin.ads)::
13448 * GNAT.Compiler_Version (g-comver.ads)::
13449 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13450 * GNAT.CRC32 (g-crc32.ads)::
13451 * GNAT.Current_Exception (g-curexc.ads)::
13452 * GNAT.Debug_Pools (g-debpoo.ads)::
13453 * GNAT.Debug_Utilities (g-debuti.ads)::
13454 * GNAT.Decode_String (g-decstr.ads)::
13455 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13456 * GNAT.Directory_Operations (g-dirope.ads)::
13457 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13458 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13459 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13460 * GNAT.Encode_String (g-encstr.ads)::
13461 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13462 * GNAT.Exception_Actions (g-excact.ads)::
13463 * GNAT.Exception_Traces (g-exctra.ads)::
13464 * GNAT.Exceptions (g-except.ads)::
13465 * GNAT.Expect (g-expect.ads)::
13466 * GNAT.Float_Control (g-flocon.ads)::
13467 * GNAT.Heap_Sort (g-heasor.ads)::
13468 * GNAT.Heap_Sort_A (g-hesora.ads)::
13469 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13470 * GNAT.HTable (g-htable.ads)::
13471 * GNAT.IO (g-io.ads)::
13472 * GNAT.IO_Aux (g-io_aux.ads)::
13473 * GNAT.Lock_Files (g-locfil.ads)::
13474 * GNAT.MD5 (g-md5.ads)::
13475 * GNAT.Memory_Dump (g-memdum.ads)::
13476 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13477 * GNAT.OS_Lib (g-os_lib.ads)::
13478 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13479 * GNAT.Random_Numbers (g-rannum.ads)::
13480 * GNAT.Regexp (g-regexp.ads)::
13481 * GNAT.Registry (g-regist.ads)::
13482 * GNAT.Regpat (g-regpat.ads)::
13483 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13484 * GNAT.Semaphores (g-semaph.ads)::
13485 * GNAT.Serial_Communications (g-sercom.ads)::
13486 * GNAT.SHA1 (g-sha1.ads)::
13487 * GNAT.Signals (g-signal.ads)::
13488 * GNAT.Sockets (g-socket.ads)::
13489 * GNAT.Source_Info (g-souinf.ads)::
13490 * GNAT.Spelling_Checker (g-speche.ads)::
13491 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13492 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13493 * GNAT.Spitbol (g-spitbo.ads)::
13494 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13495 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13496 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13497 * GNAT.Strings (g-string.ads)::
13498 * GNAT.String_Split (g-strspl.ads)::
13499 * GNAT.Table (g-table.ads)::
13500 * GNAT.Task_Lock (g-tasloc.ads)::
13501 * GNAT.Threads (g-thread.ads)::
13502 * GNAT.Time_Stamp (g-timsta.ads)::
13503 * GNAT.Traceback (g-traceb.ads)::
13504 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13505 * GNAT.UTF_32 (g-utf_32.ads)::
13506 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13507 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13508 * GNAT.Wide_String_Split (g-wistsp.ads)::
13509 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13510 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13511 * Interfaces.C.Extensions (i-cexten.ads)::
13512 * Interfaces.C.Streams (i-cstrea.ads)::
13513 * Interfaces.CPP (i-cpp.ads)::
13514 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13515 * Interfaces.VxWorks (i-vxwork.ads)::
13516 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13517 * System.Address_Image (s-addima.ads)::
13518 * System.Assertions (s-assert.ads)::
13519 * System.Memory (s-memory.ads)::
13520 * System.Partition_Interface (s-parint.ads)::
13521 * System.Pool_Global (s-pooglo.ads)::
13522 * System.Pool_Local (s-pooloc.ads)::
13523 * System.Restrictions (s-restri.ads)::
13524 * System.Rident (s-rident.ads)::
13525 * System.Task_Info (s-tasinf.ads)::
13526 * System.Wch_Cnv (s-wchcnv.ads)::
13527 * System.Wch_Con (s-wchcon.ads)::
13528 @end menu
13529
13530 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13531 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13532 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13533 @cindex Latin_9 constants for Character
13534
13535 @noindent
13536 This child of @code{Ada.Characters}
13537 provides a set of definitions corresponding to those in the
13538 RM-defined package @code{Ada.Characters.Latin_1} but with the
13539 few modifications required for @code{Latin-9}
13540 The provision of such a package
13541 is specifically authorized by the Ada Reference Manual
13542 (RM A.3.3(27)).
13543
13544 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13545 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13546 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13547 @cindex Latin_1 constants for Wide_Character
13548
13549 @noindent
13550 This child of @code{Ada.Characters}
13551 provides a set of definitions corresponding to those in the
13552 RM-defined package @code{Ada.Characters.Latin_1} but with the
13553 types of the constants being @code{Wide_Character}
13554 instead of @code{Character}.  The provision of such a package
13555 is specifically authorized by the Ada Reference Manual
13556 (RM A.3.3(27)).
13557
13558 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13559 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13560 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13561 @cindex Latin_9 constants for Wide_Character
13562
13563 @noindent
13564 This child of @code{Ada.Characters}
13565 provides a set of definitions corresponding to those in the
13566 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13567 types of the constants being @code{Wide_Character}
13568 instead of @code{Character}.  The provision of such a package
13569 is specifically authorized by the Ada Reference Manual
13570 (RM A.3.3(27)).
13571
13572 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13573 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13574 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13575 @cindex Latin_1 constants for Wide_Wide_Character
13576
13577 @noindent
13578 This child of @code{Ada.Characters}
13579 provides a set of definitions corresponding to those in the
13580 RM-defined package @code{Ada.Characters.Latin_1} but with the
13581 types of the constants being @code{Wide_Wide_Character}
13582 instead of @code{Character}.  The provision of such a package
13583 is specifically authorized by the Ada Reference Manual
13584 (RM A.3.3(27)).
13585
13586 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13587 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13588 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13589 @cindex Latin_9 constants for Wide_Wide_Character
13590
13591 @noindent
13592 This child of @code{Ada.Characters}
13593 provides a set of definitions corresponding to those in the
13594 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13595 types of the constants being @code{Wide_Wide_Character}
13596 instead of @code{Character}.  The provision of such a package
13597 is specifically authorized by the Ada Reference Manual
13598 (RM A.3.3(27)).
13599
13600 @node Ada.Command_Line.Environment (a-colien.ads)
13601 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13602 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13603 @cindex Environment entries
13604
13605 @noindent
13606 This child of @code{Ada.Command_Line}
13607 provides a mechanism for obtaining environment values on systems
13608 where this concept makes sense.
13609
13610 @node Ada.Command_Line.Remove (a-colire.ads)
13611 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13612 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13613 @cindex Removing command line arguments
13614 @cindex Command line, argument removal
13615
13616 @noindent
13617 This child of @code{Ada.Command_Line}
13618 provides a mechanism for logically removing
13619 arguments from the argument list.  Once removed, an argument is not visible
13620 to further calls on the subprograms in @code{Ada.Command_Line} will not
13621 see the removed argument.
13622
13623 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13624 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13625 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13626 @cindex Response file for command line
13627 @cindex Command line, response file
13628 @cindex Command line, handling long command lines
13629
13630 @noindent
13631 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13632 getting command line arguments from a text file, called a "response file".
13633 Using a response file allow passing a set of arguments to an executable longer
13634 than the maximum allowed by the system on the command line.
13635
13636 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13637 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13638 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13639 @cindex C Streams, Interfacing with Direct_IO
13640
13641 @noindent
13642 This package provides subprograms that allow interfacing between
13643 C streams and @code{Direct_IO}.  The stream identifier can be
13644 extracted from a file opened on the Ada side, and an Ada file
13645 can be constructed from a stream opened on the C side.
13646
13647 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13648 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13649 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13650 @cindex Null_Occurrence, testing for
13651
13652 @noindent
13653 This child subprogram provides a way of testing for the null
13654 exception occurrence (@code{Null_Occurrence}) without raising
13655 an exception.
13656
13657 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13658 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13659 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13660 @cindex Null_Occurrence, testing for
13661
13662 @noindent
13663 This child subprogram is used for handling otherwise unhandled
13664 exceptions (hence the name last chance), and perform clean ups before
13665 terminating the program. Note that this subprogram never returns.
13666
13667 @node Ada.Exceptions.Traceback (a-exctra.ads)
13668 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13669 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13670 @cindex Traceback for Exception Occurrence
13671
13672 @noindent
13673 This child package provides the subprogram (@code{Tracebacks}) to
13674 give a traceback array of addresses based on an exception
13675 occurrence.
13676
13677 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13678 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13679 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13680 @cindex C Streams, Interfacing with Sequential_IO
13681
13682 @noindent
13683 This package provides subprograms that allow interfacing between
13684 C streams and @code{Sequential_IO}.  The stream identifier can be
13685 extracted from a file opened on the Ada side, and an Ada file
13686 can be constructed from a stream opened on the C side.
13687
13688 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13689 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13690 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13691 @cindex C Streams, Interfacing with Stream_IO
13692
13693 @noindent
13694 This package provides subprograms that allow interfacing between
13695 C streams and @code{Stream_IO}.  The stream identifier can be
13696 extracted from a file opened on the Ada side, and an Ada file
13697 can be constructed from a stream opened on the C side.
13698
13699 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13700 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13701 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13702 @cindex @code{Unbounded_String}, IO support
13703 @cindex @code{Text_IO}, extensions for unbounded strings
13704
13705 @noindent
13706 This package provides subprograms for Text_IO for unbounded
13707 strings, avoiding the necessity for an intermediate operation
13708 with ordinary strings.
13709
13710 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13711 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13712 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13713 @cindex @code{Unbounded_Wide_String}, IO support
13714 @cindex @code{Text_IO}, extensions for unbounded wide strings
13715
13716 @noindent
13717 This package provides subprograms for Text_IO for unbounded
13718 wide strings, avoiding the necessity for an intermediate operation
13719 with ordinary wide strings.
13720
13721 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13722 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13723 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13724 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13725 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13726
13727 @noindent
13728 This package provides subprograms for Text_IO for unbounded
13729 wide wide strings, avoiding the necessity for an intermediate operation
13730 with ordinary wide wide strings.
13731
13732 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13733 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13734 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13735 @cindex C Streams, Interfacing with @code{Text_IO}
13736
13737 @noindent
13738 This package provides subprograms that allow interfacing between
13739 C streams and @code{Text_IO}.  The stream identifier can be
13740 extracted from a file opened on the Ada side, and an Ada file
13741 can be constructed from a stream opened on the C side.
13742
13743 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13744 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13745 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13746 @cindex Unicode categorization, Wide_Character
13747
13748 @noindent
13749 This package provides subprograms that allow categorization of
13750 Wide_Character values according to Unicode categories.
13751
13752 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13753 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13754 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13755 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13756
13757 @noindent
13758 This package provides subprograms that allow interfacing between
13759 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13760 extracted from a file opened on the Ada side, and an Ada file
13761 can be constructed from a stream opened on the C side.
13762
13763 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13764 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13765 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13766 @cindex Unicode categorization, Wide_Wide_Character
13767
13768 @noindent
13769 This package provides subprograms that allow categorization of
13770 Wide_Wide_Character values according to Unicode categories.
13771
13772 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13773 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13774 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13775 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13776
13777 @noindent
13778 This package provides subprograms that allow interfacing between
13779 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13780 extracted from a file opened on the Ada side, and an Ada file
13781 can be constructed from a stream opened on the C side.
13782
13783 @node GNAT.Altivec (g-altive.ads)
13784 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13785 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13786 @cindex AltiVec
13787
13788 @noindent
13789 This is the root package of the GNAT AltiVec binding. It provides
13790 definitions of constants and types common to all the versions of the
13791 binding.
13792
13793 @node GNAT.Altivec.Conversions (g-altcon.ads)
13794 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13795 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13796 @cindex AltiVec
13797
13798 @noindent
13799 This package provides the Vector/View conversion routines.
13800
13801 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13802 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13803 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13804 @cindex AltiVec
13805
13806 @noindent
13807 This package exposes the Ada interface to the AltiVec operations on
13808 vector objects. A soft emulation is included by default in the GNAT
13809 library. The hard binding is provided as a separate package. This unit
13810 is common to both bindings.
13811
13812 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13813 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13814 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13815 @cindex AltiVec
13816
13817 @noindent
13818 This package exposes the various vector types part of the Ada binding
13819 to AltiVec facilities.
13820
13821 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13822 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13823 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13824 @cindex AltiVec
13825
13826 @noindent
13827 This package provides public 'View' data types from/to which private
13828 vector representations can be converted via
13829 GNAT.Altivec.Conversions. This allows convenient access to individual
13830 vector elements and provides a simple way to initialize vector
13831 objects.
13832
13833 @node GNAT.Array_Split (g-arrspl.ads)
13834 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13835 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13836 @cindex Array splitter
13837
13838 @noindent
13839 Useful array-manipulation routines: given a set of separators, split
13840 an array wherever the separators appear, and provide direct access
13841 to the resulting slices.
13842
13843 @node GNAT.AWK (g-awk.ads)
13844 @section @code{GNAT.AWK} (@file{g-awk.ads})
13845 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13846 @cindex Parsing
13847 @cindex AWK
13848
13849 @noindent
13850 Provides AWK-like parsing functions, with an easy interface for parsing one
13851 or more files containing formatted data.  The file is viewed as a database
13852 where each record is a line and a field is a data element in this line.
13853
13854 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13855 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13856 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13857 @cindex Parsing
13858 @cindex Bounded Buffers
13859
13860 @noindent
13861 Provides a concurrent generic bounded buffer abstraction.  Instances are
13862 useful directly or as parts of the implementations of other abstractions,
13863 such as mailboxes.
13864
13865 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13866 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13867 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13868 @cindex Parsing
13869 @cindex Mailboxes
13870
13871 @noindent
13872 Provides a thread-safe asynchronous intertask mailbox communication facility.
13873
13874 @node GNAT.Bubble_Sort (g-bubsor.ads)
13875 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13876 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13877 @cindex Sorting
13878 @cindex Bubble sort
13879
13880 @noindent
13881 Provides a general implementation of bubble sort usable for sorting arbitrary
13882 data items.  Exchange and comparison procedures are provided by passing
13883 access-to-procedure values.
13884
13885 @node GNAT.Bubble_Sort_A (g-busora.ads)
13886 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13887 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13888 @cindex Sorting
13889 @cindex Bubble sort
13890
13891 @noindent
13892 Provides a general implementation of bubble sort usable for sorting arbitrary
13893 data items.  Move and comparison procedures are provided by passing
13894 access-to-procedure values. This is an older version, retained for
13895 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13896
13897 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13898 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13899 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13900 @cindex Sorting
13901 @cindex Bubble sort
13902
13903 @noindent
13904 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13905 are provided as generic parameters, this improves efficiency, especially
13906 if the procedures can be inlined, at the expense of duplicating code for
13907 multiple instantiations.
13908
13909 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13910 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13911 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13912 @cindex UTF-8 representation
13913 @cindex Wide characte representations
13914
13915 @noindent
13916 Provides a routine which given a string, reads the start of the string to
13917 see whether it is one of the standard byte order marks (BOM's) which signal
13918 the encoding of the string. The routine includes detection of special XML
13919 sequences for various UCS input formats.
13920
13921 @node GNAT.Byte_Swapping (g-bytswa.ads)
13922 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13923 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13924 @cindex Byte swapping
13925 @cindex Endian
13926
13927 @noindent
13928 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13929 Machine-specific implementations are available in some cases.
13930
13931 @node GNAT.Calendar (g-calend.ads)
13932 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13933 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13934 @cindex @code{Calendar}
13935
13936 @noindent
13937 Extends the facilities provided by @code{Ada.Calendar} to include handling
13938 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13939 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13940 C @code{timeval} format.
13941
13942 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13943 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13944 @cindex @code{Calendar}
13945 @cindex Time
13946 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13947
13948 @node GNAT.CRC32 (g-crc32.ads)
13949 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13950 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13951 @cindex CRC32
13952 @cindex Cyclic Redundancy Check
13953
13954 @noindent
13955 This package implements the CRC-32 algorithm.  For a full description
13956 of this algorithm see
13957 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13958 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13959 Aug.@: 1988.  Sarwate, D.V@.
13960
13961 @node GNAT.Case_Util (g-casuti.ads)
13962 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13963 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13964 @cindex Casing utilities
13965 @cindex Character handling (@code{GNAT.Case_Util})
13966
13967 @noindent
13968 A set of simple routines for handling upper and lower casing of strings
13969 without the overhead of the full casing tables
13970 in @code{Ada.Characters.Handling}.
13971
13972 @node GNAT.CGI (g-cgi.ads)
13973 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13974 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13975 @cindex CGI (Common Gateway Interface)
13976
13977 @noindent
13978 This is a package for interfacing a GNAT program with a Web server via the
13979 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13980 parameters, which are a set of key/value pairs sent by the Web server.  It
13981 builds a table whose index is the key and provides some services to deal
13982 with this table.
13983
13984 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13985 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13986 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13987 @cindex CGI (Common Gateway Interface) cookie support
13988 @cindex Cookie support in CGI
13989
13990 @noindent
13991 This is a package to interface a GNAT program with a Web server via the
13992 Common Gateway Interface (CGI).  It exports services to deal with Web
13993 cookies (piece of information kept in the Web client software).
13994
13995 @node GNAT.CGI.Debug (g-cgideb.ads)
13996 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13997 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13998 @cindex CGI (Common Gateway Interface) debugging
13999
14000 @noindent
14001 This is a package to help debugging CGI (Common Gateway Interface)
14002 programs written in Ada.
14003
14004 @node GNAT.Command_Line (g-comlin.ads)
14005 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14006 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14007 @cindex Command line
14008
14009 @noindent
14010 Provides a high level interface to @code{Ada.Command_Line} facilities,
14011 including the ability to scan for named switches with optional parameters
14012 and expand file names using wild card notations.
14013
14014 @node GNAT.Compiler_Version (g-comver.ads)
14015 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14016 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14017 @cindex Compiler Version
14018 @cindex Version, of compiler
14019
14020 @noindent
14021 Provides a routine for obtaining the version of the compiler used to
14022 compile the program. More accurately this is the version of the binder
14023 used to bind the program (this will normally be the same as the version
14024 of the compiler if a consistent tool set is used to compile all units
14025 of a partition).
14026
14027 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14028 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14029 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14030 @cindex Interrupt
14031
14032 @noindent
14033 Provides a simple interface to handle Ctrl-C keyboard events.
14034
14035 @node GNAT.Current_Exception (g-curexc.ads)
14036 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14037 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14038 @cindex Current exception
14039 @cindex Exception retrieval
14040
14041 @noindent
14042 Provides access to information on the current exception that has been raised
14043 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14044 specification syntax.
14045 This is particularly useful in simulating typical facilities for
14046 obtaining information about exceptions provided by Ada 83 compilers.
14047
14048 @node GNAT.Debug_Pools (g-debpoo.ads)
14049 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14050 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14051 @cindex Debugging
14052 @cindex Debug pools
14053 @cindex Memory corruption debugging
14054
14055 @noindent
14056 Provide a debugging storage pools that helps tracking memory corruption
14057 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14058 @value{EDITION} User's Guide}.
14059
14060 @node GNAT.Debug_Utilities (g-debuti.ads)
14061 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14062 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14063 @cindex Debugging
14064
14065 @noindent
14066 Provides a few useful utilities for debugging purposes, including conversion
14067 to and from string images of address values. Supports both C and Ada formats
14068 for hexadecimal literals.
14069
14070 @node GNAT.Decode_String (g-decstr.ads)
14071 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14072 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14073 @cindex Decoding strings
14074 @cindex String decoding
14075 @cindex Wide character encoding
14076 @cindex UTF-8
14077 @cindex Unicode
14078
14079 @noindent
14080 A generic package providing routines for decoding wide character and wide wide
14081 character strings encoded as sequences of 8-bit characters using a specified
14082 encoding method. Includes validation routines, and also routines for stepping
14083 to next or previous encoded character in an encoded string.
14084 Useful in conjunction with Unicode character coding. Note there is a
14085 preinstantiation for UTF-8. See next entry.
14086
14087 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14088 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14089 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14090 @cindex Decoding strings
14091 @cindex Decoding UTF-8 strings
14092 @cindex UTF-8 string decoding
14093 @cindex Wide character decoding
14094 @cindex UTF-8
14095 @cindex Unicode
14096
14097 @noindent
14098 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14099
14100 @node GNAT.Directory_Operations (g-dirope.ads)
14101 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14102 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14103 @cindex Directory operations
14104
14105 @noindent
14106 Provides a set of routines for manipulating directories, including changing
14107 the current directory, making new directories, and scanning the files in a
14108 directory.
14109
14110 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14111 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14112 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14113 @cindex Directory operations iteration
14114
14115 @noindent
14116 A child unit of GNAT.Directory_Operations providing additional operations
14117 for iterating through directories.
14118
14119 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14120 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14121 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14122 @cindex Hash tables
14123
14124 @noindent
14125 A generic implementation of hash tables that can be used to hash arbitrary
14126 data.  Provided in two forms, a simple form with built in hash functions,
14127 and a more complex form in which the hash function is supplied.
14128
14129 @noindent
14130 This package provides a facility similar to that of @code{GNAT.HTable},
14131 except that this package declares a type that can be used to define
14132 dynamic instances of the hash table, while an instantiation of
14133 @code{GNAT.HTable} creates a single instance of the hash table.
14134
14135 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14136 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14137 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14138 @cindex Table implementation
14139 @cindex Arrays, extendable
14140
14141 @noindent
14142 A generic package providing a single dimension array abstraction where the
14143 length of the array can be dynamically modified.
14144
14145 @noindent
14146 This package provides a facility similar to that of @code{GNAT.Table},
14147 except that this package declares a type that can be used to define
14148 dynamic instances of the table, while an instantiation of
14149 @code{GNAT.Table} creates a single instance of the table type.
14150
14151 @node GNAT.Encode_String (g-encstr.ads)
14152 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14153 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14154 @cindex Encoding strings
14155 @cindex String encoding
14156 @cindex Wide character encoding
14157 @cindex UTF-8
14158 @cindex Unicode
14159
14160 @noindent
14161 A generic package providing routines for encoding wide character and wide
14162 wide character strings as sequences of 8-bit characters using a specified
14163 encoding method. Useful in conjunction with Unicode character coding.
14164 Note there is a preinstantiation for UTF-8. See next entry.
14165
14166 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14167 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14168 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14169 @cindex Encoding strings
14170 @cindex Encoding UTF-8 strings
14171 @cindex UTF-8 string encoding
14172 @cindex Wide character encoding
14173 @cindex UTF-8
14174 @cindex Unicode
14175
14176 @noindent
14177 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14178
14179 @node GNAT.Exception_Actions (g-excact.ads)
14180 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14181 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14182 @cindex Exception actions
14183
14184 @noindent
14185 Provides callbacks when an exception is raised. Callbacks can be registered
14186 for specific exceptions, or when any exception is raised. This
14187 can be used for instance to force a core dump to ease debugging.
14188
14189 @node GNAT.Exception_Traces (g-exctra.ads)
14190 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14191 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14192 @cindex Exception traces
14193 @cindex Debugging
14194
14195 @noindent
14196 Provides an interface allowing to control automatic output upon exception
14197 occurrences.
14198
14199 @node GNAT.Exceptions (g-except.ads)
14200 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14201 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14202 @cindex Exceptions, Pure
14203 @cindex Pure packages, exceptions
14204
14205 @noindent
14206 Normally it is not possible to raise an exception with
14207 a message from a subprogram in a pure package, since the
14208 necessary types and subprograms are in @code{Ada.Exceptions}
14209 which is not a pure unit. @code{GNAT.Exceptions} provides a
14210 facility for getting around this limitation for a few
14211 predefined exceptions, and for example allow raising
14212 @code{Constraint_Error} with a message from a pure subprogram.
14213
14214 @node GNAT.Expect (g-expect.ads)
14215 @section @code{GNAT.Expect} (@file{g-expect.ads})
14216 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14217
14218 @noindent
14219 Provides a set of subprograms similar to what is available
14220 with the standard Tcl Expect tool.
14221 It allows you to easily spawn and communicate with an external process.
14222 You can send commands or inputs to the process, and compare the output
14223 with some expected regular expression. Currently @code{GNAT.Expect}
14224 is implemented on all native GNAT ports except for OpenVMS@.
14225 It is not implemented for cross ports, and in particular is not
14226 implemented for VxWorks or LynxOS@.
14227
14228 @node GNAT.Float_Control (g-flocon.ads)
14229 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14230 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14231 @cindex Floating-Point Processor
14232
14233 @noindent
14234 Provides an interface for resetting the floating-point processor into the
14235 mode required for correct semantic operation in Ada.  Some third party
14236 library calls may cause this mode to be modified, and the Reset procedure
14237 in this package can be used to reestablish the required mode.
14238
14239 @node GNAT.Heap_Sort (g-heasor.ads)
14240 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14241 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14242 @cindex Sorting
14243
14244 @noindent
14245 Provides a general implementation of heap sort usable for sorting arbitrary
14246 data items. Exchange and comparison procedures are provided by passing
14247 access-to-procedure values.  The algorithm used is a modified heap sort
14248 that performs approximately N*log(N) comparisons in the worst case.
14249
14250 @node GNAT.Heap_Sort_A (g-hesora.ads)
14251 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14252 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14253 @cindex Sorting
14254
14255 @noindent
14256 Provides a general implementation of heap sort usable for sorting arbitrary
14257 data items. Move and comparison procedures are provided by passing
14258 access-to-procedure values.  The algorithm used is a modified heap sort
14259 that performs approximately N*log(N) comparisons in the worst case.
14260 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14261 interface, but may be slightly more efficient.
14262
14263 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14264 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14265 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14266 @cindex Sorting
14267
14268 @noindent
14269 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14270 are provided as generic parameters, this improves efficiency, especially
14271 if the procedures can be inlined, at the expense of duplicating code for
14272 multiple instantiations.
14273
14274 @node GNAT.HTable (g-htable.ads)
14275 @section @code{GNAT.HTable} (@file{g-htable.ads})
14276 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14277 @cindex Hash tables
14278
14279 @noindent
14280 A generic implementation of hash tables that can be used to hash arbitrary
14281 data.  Provides two approaches, one a simple static approach, and the other
14282 allowing arbitrary dynamic hash tables.
14283
14284 @node GNAT.IO (g-io.ads)
14285 @section @code{GNAT.IO} (@file{g-io.ads})
14286 @cindex @code{GNAT.IO} (@file{g-io.ads})
14287 @cindex Simple I/O
14288 @cindex Input/Output facilities
14289
14290 @noindent
14291 A simple preelaborable input-output package that provides a subset of
14292 simple Text_IO functions for reading characters and strings from
14293 Standard_Input, and writing characters, strings and integers to either
14294 Standard_Output or Standard_Error.
14295
14296 @node GNAT.IO_Aux (g-io_aux.ads)
14297 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14298 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14299 @cindex Text_IO
14300 @cindex Input/Output facilities
14301
14302 Provides some auxiliary functions for use with Text_IO, including a test
14303 for whether a file exists, and functions for reading a line of text.
14304
14305 @node GNAT.Lock_Files (g-locfil.ads)
14306 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14307 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14308 @cindex File locking
14309 @cindex Locking using files
14310
14311 @noindent
14312 Provides a general interface for using files as locks.  Can be used for
14313 providing program level synchronization.
14314
14315 @node GNAT.MD5 (g-md5.ads)
14316 @section @code{GNAT.MD5} (@file{g-md5.ads})
14317 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14318 @cindex Message Digest MD5
14319
14320 @noindent
14321 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14322
14323 @node GNAT.Memory_Dump (g-memdum.ads)
14324 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14325 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14326 @cindex Dump Memory
14327
14328 @noindent
14329 Provides a convenient routine for dumping raw memory to either the
14330 standard output or standard error files. Uses GNAT.IO for actual
14331 output.
14332
14333 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14334 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14335 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14336 @cindex Exception, obtaining most recent
14337
14338 @noindent
14339 Provides access to the most recently raised exception.  Can be used for
14340 various logging purposes, including duplicating functionality of some
14341 Ada 83 implementation dependent extensions.
14342
14343 @node GNAT.OS_Lib (g-os_lib.ads)
14344 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14345 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14346 @cindex Operating System interface
14347 @cindex Spawn capability
14348
14349 @noindent
14350 Provides a range of target independent operating system interface functions,
14351 including time/date management, file operations, subprocess management,
14352 including a portable spawn procedure, and access to environment variables
14353 and error return codes.
14354
14355 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14356 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14357 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14358 @cindex Hash functions
14359
14360 @noindent
14361 Provides a generator of static minimal perfect hash functions. No
14362 collisions occur and each item can be retrieved from the table in one
14363 probe (perfect property). The hash table size corresponds to the exact
14364 size of the key set and no larger (minimal property). The key set has to
14365 be know in advance (static property). The hash functions are also order
14366 preserving. If w2 is inserted after w1 in the generator, their
14367 hashcode are in the same order. These hashing functions are very
14368 convenient for use with realtime applications.
14369
14370 @node GNAT.Random_Numbers (g-rannum.ads)
14371 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14372 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14373 @cindex Random number generation
14374
14375 @noindent
14376 Provides random number capabilities which extend those available in the
14377 standard Ada library and are more convenient to use.
14378
14379 @node GNAT.Regexp (g-regexp.ads)
14380 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14381 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14382 @cindex Regular expressions
14383 @cindex Pattern matching
14384
14385 @noindent
14386 A simple implementation of regular expressions, using a subset of regular
14387 expression syntax copied from familiar Unix style utilities.  This is the
14388 simples of the three pattern matching packages provided, and is particularly
14389 suitable for ``file globbing'' applications.
14390
14391 @node GNAT.Registry (g-regist.ads)
14392 @section @code{GNAT.Registry} (@file{g-regist.ads})
14393 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14394 @cindex Windows Registry
14395
14396 @noindent
14397 This is a high level binding to the Windows registry.  It is possible to
14398 do simple things like reading a key value, creating a new key.  For full
14399 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14400 package provided with the Win32Ada binding
14401
14402 @node GNAT.Regpat (g-regpat.ads)
14403 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14404 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14405 @cindex Regular expressions
14406 @cindex Pattern matching
14407
14408 @noindent
14409 A complete implementation of Unix-style regular expression matching, copied
14410 from the original V7 style regular expression library written in C by
14411 Henry Spencer (and binary compatible with this C library).
14412
14413 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14414 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14415 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14416 @cindex Secondary Stack Info
14417
14418 @noindent
14419 Provide the capability to query the high water mark of the current task's
14420 secondary stack.
14421
14422 @node GNAT.Semaphores (g-semaph.ads)
14423 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14424 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14425 @cindex Semaphores
14426
14427 @noindent
14428 Provides classic counting and binary semaphores using protected types.
14429
14430 @node GNAT.Serial_Communications (g-sercom.ads)
14431 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14432 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14433 @cindex Serial_Communications
14434
14435 @noindent
14436 Provides a simple interface to send and receive data over a serial
14437 port. This is only supported on GNU/Linux and Windows.
14438
14439 @node GNAT.SHA1 (g-sha1.ads)
14440 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14441 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14442 @cindex Secure Hash Algorithm SHA-1
14443
14444 @noindent
14445 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14446
14447 @node GNAT.Signals (g-signal.ads)
14448 @section @code{GNAT.Signals} (@file{g-signal.ads})
14449 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14450 @cindex Signals
14451
14452 @noindent
14453 Provides the ability to manipulate the blocked status of signals on supported
14454 targets.
14455
14456 @node GNAT.Sockets (g-socket.ads)
14457 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14458 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14459 @cindex Sockets
14460
14461 @noindent
14462 A high level and portable interface to develop sockets based applications.
14463 This package is based on the sockets thin binding found in
14464 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14465 on all native GNAT ports except for OpenVMS@.  It is not implemented
14466 for the LynxOS@ cross port.
14467
14468 @node GNAT.Source_Info (g-souinf.ads)
14469 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14470 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14471 @cindex Source Information
14472
14473 @noindent
14474 Provides subprograms that give access to source code information known at
14475 compile time, such as the current file name and line number.
14476
14477 @node GNAT.Spelling_Checker (g-speche.ads)
14478 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14479 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14480 @cindex Spell checking
14481
14482 @noindent
14483 Provides a function for determining whether one string is a plausible
14484 near misspelling of another string.
14485
14486 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14487 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14488 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14489 @cindex Spell checking
14490
14491 @noindent
14492 Provides a generic function that can be instantiated with a string type for
14493 determining whether one string is a plausible near misspelling of another
14494 string.
14495
14496 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14497 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14498 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14499 @cindex SPITBOL pattern matching
14500 @cindex Pattern matching
14501
14502 @noindent
14503 A complete implementation of SNOBOL4 style pattern matching.  This is the
14504 most elaborate of the pattern matching packages provided.  It fully duplicates
14505 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14506 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14507
14508 @node GNAT.Spitbol (g-spitbo.ads)
14509 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14510 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14511 @cindex SPITBOL interface
14512
14513 @noindent
14514 The top level package of the collection of SPITBOL-style functionality, this
14515 package provides basic SNOBOL4 string manipulation functions, such as
14516 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14517 useful for constructing arbitrary mappings from strings in the style of
14518 the SNOBOL4 TABLE function.
14519
14520 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14521 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14522 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14523 @cindex Sets of strings
14524 @cindex SPITBOL Tables
14525
14526 @noindent
14527 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14528 for type @code{Standard.Boolean}, giving an implementation of sets of
14529 string values.
14530
14531 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14532 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14533 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14534 @cindex Integer maps
14535 @cindex Maps
14536 @cindex SPITBOL Tables
14537
14538 @noindent
14539 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14540 for type @code{Standard.Integer}, giving an implementation of maps
14541 from string to integer values.
14542
14543 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14544 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14545 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14546 @cindex String maps
14547 @cindex Maps
14548 @cindex SPITBOL Tables
14549
14550 @noindent
14551 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14552 a variable length string type, giving an implementation of general
14553 maps from strings to strings.
14554
14555 @node GNAT.Strings (g-string.ads)
14556 @section @code{GNAT.Strings} (@file{g-string.ads})
14557 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14558
14559 @noindent
14560 Common String access types and related subprograms. Basically it
14561 defines a string access and an array of string access types.
14562
14563 @node GNAT.String_Split (g-strspl.ads)
14564 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14565 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14566 @cindex String splitter
14567
14568 @noindent
14569 Useful string manipulation routines: given a set of separators, split
14570 a string wherever the separators appear, and provide direct access
14571 to the resulting slices. This package is instantiated from
14572 @code{GNAT.Array_Split}.
14573
14574 @node GNAT.Table (g-table.ads)
14575 @section @code{GNAT.Table} (@file{g-table.ads})
14576 @cindex @code{GNAT.Table} (@file{g-table.ads})
14577 @cindex Table implementation
14578 @cindex Arrays, extendable
14579
14580 @noindent
14581 A generic package providing a single dimension array abstraction where the
14582 length of the array can be dynamically modified.
14583
14584 @noindent
14585 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14586 except that this package declares a single instance of the table type,
14587 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14588 used to define dynamic instances of the table.
14589
14590 @node GNAT.Task_Lock (g-tasloc.ads)
14591 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14592 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14593 @cindex Task synchronization
14594 @cindex Task locking
14595 @cindex Locking
14596
14597 @noindent
14598 A very simple facility for locking and unlocking sections of code using a
14599 single global task lock.  Appropriate for use in situations where contention
14600 between tasks is very rarely expected.
14601
14602 @node GNAT.Time_Stamp (g-timsta.ads)
14603 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14604 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14605 @cindex Time stamp
14606 @cindex Current time
14607
14608 @noindent
14609 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14610 represents the current date and time in ISO 8601 format. This is a very simple
14611 routine with minimal code and there are no dependencies on any other unit.
14612
14613 @node GNAT.Threads (g-thread.ads)
14614 @section @code{GNAT.Threads} (@file{g-thread.ads})
14615 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14616 @cindex Foreign threads
14617 @cindex Threads, foreign
14618
14619 @noindent
14620 Provides facilities for dealing with foreign threads which need to be known
14621 by the GNAT run-time system. Consult the documentation of this package for
14622 further details if your program has threads that are created by a non-Ada
14623 environment which then accesses Ada code.
14624
14625 @node GNAT.Traceback (g-traceb.ads)
14626 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14627 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14628 @cindex Trace back facilities
14629
14630 @noindent
14631 Provides a facility for obtaining non-symbolic traceback information, useful
14632 in various debugging situations.
14633
14634 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14635 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14636 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14637 @cindex Trace back facilities
14638
14639 @node GNAT.UTF_32 (g-utf_32.ads)
14640 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14641 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14642 @cindex Wide character codes
14643
14644 @noindent
14645 This is a package intended to be used in conjunction with the
14646 @code{Wide_Character} type in Ada 95 and the
14647 @code{Wide_Wide_Character} type in Ada 2005 (available
14648 in @code{GNAT} in Ada 2005 mode). This package contains
14649 Unicode categorization routines, as well as lexical
14650 categorization routines corresponding to the Ada 2005
14651 lexical rules for identifiers and strings, and also a
14652 lower case to upper case fold routine corresponding to
14653 the Ada 2005 rules for identifier equivalence.
14654
14655 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14656 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14657 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14658 @cindex Spell checking
14659
14660 @noindent
14661 Provides a function for determining whether one wide wide string is a plausible
14662 near misspelling of another wide wide string, where the strings are represented
14663 using the UTF_32_String type defined in System.Wch_Cnv.
14664
14665 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14666 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14667 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14668 @cindex Spell checking
14669
14670 @noindent
14671 Provides a function for determining whether one wide string is a plausible
14672 near misspelling of another wide string.
14673
14674 @node GNAT.Wide_String_Split (g-wistsp.ads)
14675 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14676 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14677 @cindex Wide_String splitter
14678
14679 @noindent
14680 Useful wide string manipulation routines: given a set of separators, split
14681 a wide string wherever the separators appear, and provide direct access
14682 to the resulting slices. This package is instantiated from
14683 @code{GNAT.Array_Split}.
14684
14685 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14686 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14687 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14688 @cindex Spell checking
14689
14690 @noindent
14691 Provides a function for determining whether one wide wide string is a plausible
14692 near misspelling of another wide wide string.
14693
14694 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14695 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14696 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14697 @cindex Wide_Wide_String splitter
14698
14699 @noindent
14700 Useful wide wide string manipulation routines: given a set of separators, split
14701 a wide wide string wherever the separators appear, and provide direct access
14702 to the resulting slices. This package is instantiated from
14703 @code{GNAT.Array_Split}.
14704
14705 @node Interfaces.C.Extensions (i-cexten.ads)
14706 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14707 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14708
14709 @noindent
14710 This package contains additional C-related definitions, intended
14711 for use with either manually or automatically generated bindings
14712 to C libraries.
14713
14714 @node Interfaces.C.Streams (i-cstrea.ads)
14715 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14716 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14717 @cindex  C streams, interfacing
14718
14719 @noindent
14720 This package is a binding for the most commonly used operations
14721 on C streams.
14722
14723 @node Interfaces.CPP (i-cpp.ads)
14724 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14725 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14726 @cindex  C++ interfacing
14727 @cindex  Interfacing, to C++
14728
14729 @noindent
14730 This package provides facilities for use in interfacing to C++.  It
14731 is primarily intended to be used in connection with automated tools
14732 for the generation of C++ interfaces.
14733
14734 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14735 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14736 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14737 @cindex  IBM Packed Format
14738 @cindex  Packed Decimal
14739
14740 @noindent
14741 This package provides a set of routines for conversions to and
14742 from a packed decimal format compatible with that used on IBM
14743 mainframes.
14744
14745 @node Interfaces.VxWorks (i-vxwork.ads)
14746 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14747 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14748 @cindex Interfacing to VxWorks
14749 @cindex VxWorks, interfacing
14750
14751 @noindent
14752 This package provides a limited binding to the VxWorks API.
14753 In particular, it interfaces with the
14754 VxWorks hardware interrupt facilities.
14755
14756 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14757 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14758 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14759 @cindex Interfacing to VxWorks' I/O
14760 @cindex VxWorks, I/O interfacing
14761 @cindex VxWorks, Get_Immediate
14762 @cindex Get_Immediate, VxWorks
14763
14764 @noindent
14765 This package provides a binding to the ioctl (IO/Control)
14766 function of VxWorks, defining a set of option values and
14767 function codes. A particular use of this package is
14768 to enable the use of Get_Immediate under VxWorks.
14769
14770 @node System.Address_Image (s-addima.ads)
14771 @section @code{System.Address_Image} (@file{s-addima.ads})
14772 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14773 @cindex Address image
14774 @cindex Image, of an address
14775
14776 @noindent
14777 This function provides a useful debugging
14778 function that gives an (implementation dependent)
14779 string which identifies an address.
14780
14781 @node System.Assertions (s-assert.ads)
14782 @section @code{System.Assertions} (@file{s-assert.ads})
14783 @cindex @code{System.Assertions} (@file{s-assert.ads})
14784 @cindex Assertions
14785 @cindex Assert_Failure, exception
14786
14787 @noindent
14788 This package provides the declaration of the exception raised
14789 by an run-time assertion failure, as well as the routine that
14790 is used internally to raise this assertion.
14791
14792 @node System.Memory (s-memory.ads)
14793 @section @code{System.Memory} (@file{s-memory.ads})
14794 @cindex @code{System.Memory} (@file{s-memory.ads})
14795 @cindex Memory allocation
14796
14797 @noindent
14798 This package provides the interface to the low level routines used
14799 by the generated code for allocation and freeing storage for the
14800 default storage pool (analogous to the C routines malloc and free.
14801 It also provides a reallocation interface analogous to the C routine
14802 realloc. The body of this unit may be modified to provide alternative
14803 allocation mechanisms for the default pool, and in addition, direct
14804 calls to this unit may be made for low level allocation uses (for
14805 example see the body of @code{GNAT.Tables}).
14806
14807 @node System.Partition_Interface (s-parint.ads)
14808 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14809 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14810 @cindex Partition interfacing functions
14811
14812 @noindent
14813 This package provides facilities for partition interfacing.  It
14814 is used primarily in a distribution context when using Annex E
14815 with @code{GLADE}.
14816
14817 @node System.Pool_Global (s-pooglo.ads)
14818 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14819 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14820 @cindex Storage pool, global
14821 @cindex Global storage pool
14822
14823 @noindent
14824 This package provides a storage pool that is equivalent to the default
14825 storage pool used for access types for which no pool is specifically
14826 declared. It uses malloc/free to allocate/free and does not attempt to
14827 do any automatic reclamation.
14828
14829 @node System.Pool_Local (s-pooloc.ads)
14830 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14831 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14832 @cindex Storage pool, local
14833 @cindex Local storage pool
14834
14835 @noindent
14836 This package provides a storage pool that is intended for use with locally
14837 defined access types. It uses malloc/free for allocate/free, and maintains
14838 a list of allocated blocks, so that all storage allocated for the pool can
14839 be freed automatically when the pool is finalized.
14840
14841 @node System.Restrictions (s-restri.ads)
14842 @section @code{System.Restrictions} (@file{s-restri.ads})
14843 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14844 @cindex Run-time restrictions access
14845
14846 @noindent
14847 This package provides facilities for accessing at run time
14848 the status of restrictions specified at compile time for
14849 the partition. Information is available both with regard
14850 to actual restrictions specified, and with regard to
14851 compiler determined information on which restrictions
14852 are violated by one or more packages in the partition.
14853
14854 @node System.Rident (s-rident.ads)
14855 @section @code{System.Rident} (@file{s-rident.ads})
14856 @cindex @code{System.Rident} (@file{s-rident.ads})
14857 @cindex Restrictions definitions
14858
14859 @noindent
14860 This package provides definitions of the restrictions
14861 identifiers supported by GNAT, and also the format of
14862 the restrictions provided in package System.Restrictions.
14863 It is not normally necessary to @code{with} this generic package
14864 since the necessary instantiation is included in
14865 package System.Restrictions.
14866
14867 @node System.Task_Info (s-tasinf.ads)
14868 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14869 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14870 @cindex Task_Info pragma
14871
14872 @noindent
14873 This package provides target dependent functionality that is used
14874 to support the @code{Task_Info} pragma
14875
14876 @node System.Wch_Cnv (s-wchcnv.ads)
14877 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14878 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14879 @cindex Wide Character, Representation
14880 @cindex Wide String, Conversion
14881 @cindex Representation of wide characters
14882
14883 @noindent
14884 This package provides routines for converting between
14885 wide and wide wide characters and a representation as a value of type
14886 @code{Standard.String}, using a specified wide character
14887 encoding method.  It uses definitions in
14888 package @code{System.Wch_Con}.
14889
14890 @node System.Wch_Con (s-wchcon.ads)
14891 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14892 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14893
14894 @noindent
14895 This package provides definitions and descriptions of
14896 the various methods used for encoding wide characters
14897 in ordinary strings.  These definitions are used by
14898 the package @code{System.Wch_Cnv}.
14899
14900 @node Interfacing to Other Languages
14901 @chapter Interfacing to Other Languages
14902 @noindent
14903 The facilities in annex B of the Ada Reference Manual are fully
14904 implemented in GNAT, and in addition, a full interface to C++ is
14905 provided.
14906
14907 @menu
14908 * Interfacing to C::
14909 * Interfacing to C++::
14910 * Interfacing to COBOL::
14911 * Interfacing to Fortran::
14912 * Interfacing to non-GNAT Ada code::
14913 @end menu
14914
14915 @node Interfacing to C
14916 @section Interfacing to C
14917
14918 @noindent
14919 Interfacing to C with GNAT can use one of two approaches:
14920
14921 @itemize @bullet
14922 @item
14923 The types in the package @code{Interfaces.C} may be used.
14924 @item
14925 Standard Ada types may be used directly.  This may be less portable to
14926 other compilers, but will work on all GNAT compilers, which guarantee
14927 correspondence between the C and Ada types.
14928 @end itemize
14929
14930 @noindent
14931 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14932 effect, since this is the default.  The following table shows the
14933 correspondence between Ada scalar types and the corresponding C types.
14934
14935 @table @code
14936 @item Integer
14937 @code{int}
14938 @item Short_Integer
14939 @code{short}
14940 @item Short_Short_Integer
14941 @code{signed char}
14942 @item Long_Integer
14943 @code{long}
14944 @item Long_Long_Integer
14945 @code{long long}
14946 @item Short_Float
14947 @code{float}
14948 @item Float
14949 @code{float}
14950 @item Long_Float
14951 @code{double}
14952 @item Long_Long_Float
14953 This is the longest floating-point type supported by the hardware.
14954 @end table
14955
14956 @noindent
14957 Additionally, there are the following general correspondences between Ada
14958 and C types:
14959 @itemize @bullet
14960 @item
14961 Ada enumeration types map to C enumeration types directly if pragma
14962 @code{Convention C} is specified, which causes them to have int
14963 length.  Without pragma @code{Convention C}, Ada enumeration types map to
14964 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14965 @code{int}, respectively) depending on the number of values passed.
14966 This is the only case in which pragma @code{Convention C} affects the
14967 representation of an Ada type.
14968
14969 @item
14970 Ada access types map to C pointers, except for the case of pointers to
14971 unconstrained types in Ada, which have no direct C equivalent.
14972
14973 @item
14974 Ada arrays map directly to C arrays.
14975
14976 @item
14977 Ada records map directly to C structures.
14978
14979 @item
14980 Packed Ada records map to C structures where all members are bit fields
14981 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14982 @end itemize
14983
14984 @node Interfacing to C++
14985 @section Interfacing to C++
14986
14987 @noindent
14988 The interface to C++ makes use of the following pragmas, which are
14989 primarily intended to be constructed automatically using a binding generator
14990 tool, although it is possible to construct them by hand.  No suitable binding
14991 generator tool is supplied with GNAT though.
14992
14993 Using these pragmas it is possible to achieve complete
14994 inter-operability between Ada tagged types and C++ class definitions.
14995 See @ref{Implementation Defined Pragmas}, for more details.
14996
14997 @table @code
14998 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14999 The argument denotes an entity in the current declarative region that is
15000 declared as a tagged or untagged record type. It indicates that the type
15001 corresponds to an externally declared C++ class type, and is to be laid
15002 out the same way that C++ would lay out the type.
15003
15004 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15005 for backward compatibility but its functionality is available
15006 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15007
15008 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15009 This pragma identifies an imported function (imported in the usual way
15010 with pragma @code{Import}) as corresponding to a C++ constructor.
15011 @end table
15012
15013 @node Interfacing to COBOL
15014 @section Interfacing to COBOL
15015
15016 @noindent
15017 Interfacing to COBOL is achieved as described in section B.4 of
15018 the Ada Reference Manual.
15019
15020 @node Interfacing to Fortran
15021 @section Interfacing to Fortran
15022
15023 @noindent
15024 Interfacing to Fortran is achieved as described in section B.5 of the
15025 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15026 multi-dimensional array causes the array to be stored in column-major
15027 order as required for convenient interface to Fortran.
15028
15029 @node Interfacing to non-GNAT Ada code
15030 @section Interfacing to non-GNAT Ada code
15031
15032 It is possible to specify the convention @code{Ada} in a pragma
15033 @code{Import} or pragma @code{Export}.  However this refers to
15034 the calling conventions used by GNAT, which may or may not be
15035 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15036 compiler to allow interoperation.
15037
15038 If arguments types are kept simple, and if the foreign compiler generally
15039 follows system calling conventions, then it may be possible to integrate
15040 files compiled by other Ada compilers, provided that the elaboration
15041 issues are adequately addressed (for example by eliminating the
15042 need for any load time elaboration).
15043
15044 In particular, GNAT running on VMS is designed to
15045 be highly compatible with the DEC Ada 83 compiler, so this is one
15046 case in which it is possible to import foreign units of this type,
15047 provided that the data items passed are restricted to simple scalar
15048 values or simple record types without variants, or simple array
15049 types with fixed bounds.
15050
15051 @node Specialized Needs Annexes
15052 @chapter Specialized Needs Annexes
15053
15054 @noindent
15055 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15056 required in all implementations.  However, as described in this chapter,
15057 GNAT implements all of these annexes:
15058
15059 @table @asis
15060 @item Systems Programming (Annex C)
15061 The Systems Programming Annex is fully implemented.
15062
15063 @item Real-Time Systems (Annex D)
15064 The Real-Time Systems Annex is fully implemented.
15065
15066 @item Distributed Systems (Annex E)
15067 Stub generation is fully implemented in the GNAT compiler.  In addition,
15068 a complete compatible PCS is available as part of the GLADE system,
15069 a separate product.  When the two
15070 products are used in conjunction, this annex is fully implemented.
15071
15072 @item Information Systems (Annex F)
15073 The Information Systems annex is fully implemented.
15074
15075 @item Numerics (Annex G)
15076 The Numerics Annex is fully implemented.
15077
15078 @item Safety and Security / High-Integrity Systems (Annex H)
15079 The Safety and Security Annex (termed the High-Integrity Systems Annex
15080 in Ada 2005) is fully implemented.
15081 @end table
15082
15083 @node Implementation of Specific Ada Features
15084 @chapter Implementation of Specific Ada Features
15085
15086 @noindent
15087 This chapter describes the GNAT implementation of several Ada language
15088 facilities.
15089
15090 @menu
15091 * Machine Code Insertions::
15092 * GNAT Implementation of Tasking::
15093 * GNAT Implementation of Shared Passive Packages::
15094 * Code Generation for Array Aggregates::
15095 * The Size of Discriminated Records with Default Discriminants::
15096 * Strict Conformance to the Ada Reference Manual::
15097 @end menu
15098
15099 @node Machine Code Insertions
15100 @section Machine Code Insertions
15101 @cindex Machine Code insertions
15102
15103 @noindent
15104 Package @code{Machine_Code} provides machine code support as described
15105 in the Ada Reference Manual in two separate forms:
15106 @itemize @bullet
15107 @item
15108 Machine code statements, consisting of qualified expressions that
15109 fit the requirements of RM section 13.8.
15110 @item
15111 An intrinsic callable procedure, providing an alternative mechanism of
15112 including machine instructions in a subprogram.
15113 @end itemize
15114
15115 @noindent
15116 The two features are similar, and both are closely related to the mechanism
15117 provided by the asm instruction in the GNU C compiler.  Full understanding
15118 and use of the facilities in this package requires understanding the asm
15119 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15120 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15121
15122 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15123 semantic restrictions and effects as described below.  Both are provided so
15124 that the procedure call can be used as a statement, and the function call
15125 can be used to form a code_statement.
15126
15127 The first example given in the GCC documentation is the C @code{asm}
15128 instruction:
15129 @smallexample
15130    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15131 @end smallexample
15132
15133 @noindent
15134 The equivalent can be written for GNAT as:
15135
15136 @smallexample @c ada
15137 Asm ("fsinx %1 %0",
15138      My_Float'Asm_Output ("=f", result),
15139      My_Float'Asm_Input  ("f",  angle));
15140 @end smallexample
15141
15142 @noindent
15143 The first argument to @code{Asm} is the assembler template, and is
15144 identical to what is used in GNU C@.  This string must be a static
15145 expression.  The second argument is the output operand list.  It is
15146 either a single @code{Asm_Output} attribute reference, or a list of such
15147 references enclosed in parentheses (technically an array aggregate of
15148 such references).
15149
15150 The @code{Asm_Output} attribute denotes a function that takes two
15151 parameters.  The first is a string, the second is the name of a variable
15152 of the type designated by the attribute prefix.  The first (string)
15153 argument is required to be a static expression and designates the
15154 constraint for the parameter (e.g.@: what kind of register is
15155 required).  The second argument is the variable to be updated with the
15156 result.  The possible values for constraint are the same as those used in
15157 the RTL, and are dependent on the configuration file used to build the
15158 GCC back end.  If there are no output operands, then this argument may
15159 either be omitted, or explicitly given as @code{No_Output_Operands}.
15160
15161 The second argument of @code{@var{my_float}'Asm_Output} functions as
15162 though it were an @code{out} parameter, which is a little curious, but
15163 all names have the form of expressions, so there is no syntactic
15164 irregularity, even though normally functions would not be permitted
15165 @code{out} parameters.  The third argument is the list of input
15166 operands.  It is either a single @code{Asm_Input} attribute reference, or
15167 a list of such references enclosed in parentheses (technically an array
15168 aggregate of such references).
15169
15170 The @code{Asm_Input} attribute denotes a function that takes two
15171 parameters.  The first is a string, the second is an expression of the
15172 type designated by the prefix.  The first (string) argument is required
15173 to be a static expression, and is the constraint for the parameter,
15174 (e.g.@: what kind of register is required).  The second argument is the
15175 value to be used as the input argument.  The possible values for the
15176 constant are the same as those used in the RTL, and are dependent on
15177 the configuration file used to built the GCC back end.
15178
15179 If there are no input operands, this argument may either be omitted, or
15180 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15181 present in the above example, is a list of register names, called the
15182 @dfn{clobber} argument.  This argument, if given, must be a static string
15183 expression, and is a space or comma separated list of names of registers
15184 that must be considered destroyed as a result of the @code{Asm} call.  If
15185 this argument is the null string (the default value), then the code
15186 generator assumes that no additional registers are destroyed.
15187
15188 The fifth argument, not present in the above example, called the
15189 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15190 the literal value @code{True} to indicate to the code generator that all
15191 optimizations with respect to the instruction specified should be
15192 suppressed, and that in particular, for an instruction that has outputs,
15193 the instruction will still be generated, even if none of the outputs are
15194 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15195 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15196 Generally it is strongly advisable to use Volatile for any ASM statement
15197 that is missing either input or output operands, or when two or more ASM
15198 statements appear in sequence, to avoid unwanted optimizations. A warning
15199 is generated if this advice is not followed.
15200
15201 The @code{Asm} subprograms may be used in two ways.  First the procedure
15202 forms can be used anywhere a procedure call would be valid, and
15203 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15204 be used to intersperse machine instructions with other Ada statements.
15205 Second, the function forms, which return a dummy value of the limited
15206 private type @code{Asm_Insn}, can be used in code statements, and indeed
15207 this is the only context where such calls are allowed.  Code statements
15208 appear as aggregates of the form:
15209
15210 @smallexample @c ada
15211 Asm_Insn'(Asm (@dots{}));
15212 Asm_Insn'(Asm_Volatile (@dots{}));
15213 @end smallexample
15214
15215 @noindent
15216 In accordance with RM rules, such code statements are allowed only
15217 within subprograms whose entire body consists of such statements.  It is
15218 not permissible to intermix such statements with other Ada statements.
15219
15220 Typically the form using intrinsic procedure calls is more convenient
15221 and more flexible.  The code statement form is provided to meet the RM
15222 suggestion that such a facility should be made available.  The following
15223 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15224 is used, the arguments may be given in arbitrary order, following the
15225 normal rules for use of positional and named arguments)
15226
15227 @smallexample
15228 ASM_CALL ::= Asm (
15229                  [Template =>] static_string_EXPRESSION
15230                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15231                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15232                [,[Clobber  =>] static_string_EXPRESSION ]
15233                [,[Volatile =>] static_boolean_EXPRESSION] )
15234
15235 OUTPUT_OPERAND_LIST ::=
15236   [PREFIX.]No_Output_Operands
15237 | OUTPUT_OPERAND_ATTRIBUTE
15238 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15239
15240 OUTPUT_OPERAND_ATTRIBUTE ::=
15241   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15242
15243 INPUT_OPERAND_LIST ::=
15244   [PREFIX.]No_Input_Operands
15245 | INPUT_OPERAND_ATTRIBUTE
15246 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15247
15248 INPUT_OPERAND_ATTRIBUTE ::=
15249   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15250 @end smallexample
15251
15252 @noindent
15253 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15254 are declared in the package @code{Machine_Code} and must be referenced
15255 according to normal visibility rules. In particular if there is no
15256 @code{use} clause for this package, then appropriate package name
15257 qualification is required.
15258
15259 @node GNAT Implementation of Tasking
15260 @section GNAT Implementation of Tasking
15261
15262 @noindent
15263 This chapter outlines the basic GNAT approach to tasking (in particular,
15264 a multi-layered library for portability) and discusses issues related
15265 to compliance with the Real-Time Systems Annex.
15266
15267 @menu
15268 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15269 * Ensuring Compliance with the Real-Time Annex::
15270 @end menu
15271
15272 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15273 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15274
15275 @noindent
15276 GNAT's run-time support comprises two layers:
15277
15278 @itemize @bullet
15279 @item GNARL (GNAT Run-time Layer)
15280 @item GNULL (GNAT Low-level Library)
15281 @end itemize
15282
15283 @noindent
15284 In GNAT, Ada's tasking services rely on a platform and OS independent
15285 layer known as GNARL@.  This code is responsible for implementing the
15286 correct semantics of Ada's task creation, rendezvous, protected
15287 operations etc.
15288
15289 GNARL decomposes Ada's tasking semantics into simpler lower level
15290 operations such as create a thread, set the priority of a thread,
15291 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15292 operations constitutes GNULLI, the GNULL Interface.  This interface is
15293 directly inspired from the POSIX real-time API@.
15294
15295 If the underlying executive or OS implements the POSIX standard
15296 faithfully, the GNULL Interface maps as is to the services offered by
15297 the underlying kernel.  Otherwise, some target dependent glue code maps
15298 the services offered by the underlying kernel to the semantics expected
15299 by GNARL@.
15300
15301 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15302 key point is that each Ada task is mapped on a thread in the underlying
15303 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15304
15305 In addition Ada task priorities map onto the underlying thread priorities.
15306 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15307
15308 @itemize @bullet
15309 @item
15310 The underlying scheduler is used to schedule the Ada tasks.  This
15311 makes Ada tasks as efficient as kernel threads from a scheduling
15312 standpoint.
15313
15314 @item
15315 Interaction with code written in C containing threads is eased
15316 since at the lowest level Ada tasks and C threads map onto the same
15317 underlying kernel concept.
15318
15319 @item
15320 When an Ada task is blocked during I/O the remaining Ada tasks are
15321 able to proceed.
15322
15323 @item
15324 On multiprocessor systems Ada tasks can execute in parallel.
15325 @end itemize
15326
15327 @noindent
15328 Some threads libraries offer a mechanism to fork a new process, with the
15329 child process duplicating the threads from the parent.
15330 GNAT does not
15331 support this functionality when the parent contains more than one task.
15332 @cindex Forking a new process
15333
15334 @node Ensuring Compliance with the Real-Time Annex
15335 @subsection Ensuring Compliance with the Real-Time Annex
15336 @cindex Real-Time Systems Annex compliance
15337
15338 @noindent
15339 Although mapping Ada tasks onto
15340 the underlying threads has significant advantages, it does create some
15341 complications when it comes to respecting the scheduling semantics
15342 specified in the real-time annex (Annex D).
15343
15344 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15345 scheduling policy states:
15346
15347 @quotation
15348 @emph{When the active priority of a ready task that is not running
15349 changes, or the setting of its base priority takes effect, the
15350 task is removed from the ready queue for its old active priority
15351 and is added at the tail of the ready queue for its new active
15352 priority, except in the case where the active priority is lowered
15353 due to the loss of inherited priority, in which case the task is
15354 added at the head of the ready queue for its new active priority.}
15355 @end quotation
15356
15357 @noindent
15358 While most kernels do put tasks at the end of the priority queue when
15359 a task changes its priority, (which respects the main
15360 FIFO_Within_Priorities requirement), almost none keep a thread at the
15361 beginning of its priority queue when its priority drops from the loss
15362 of inherited priority.
15363
15364 As a result most vendors have provided incomplete Annex D implementations.
15365
15366 The GNAT run-time, has a nice cooperative solution to this problem
15367 which ensures that accurate FIFO_Within_Priorities semantics are
15368 respected.
15369
15370 The principle is as follows.  When an Ada task T is about to start
15371 running, it checks whether some other Ada task R with the same
15372 priority as T has been suspended due to the loss of priority
15373 inheritance.  If this is the case, T yields and is placed at the end of
15374 its priority queue.  When R arrives at the front of the queue it
15375 executes.
15376
15377 Note that this simple scheme preserves the relative order of the tasks
15378 that were ready to execute in the priority queue where R has been
15379 placed at the end.
15380
15381 @node GNAT Implementation of Shared Passive Packages
15382 @section GNAT Implementation of Shared Passive Packages
15383 @cindex Shared passive packages
15384
15385 @noindent
15386 GNAT fully implements the pragma @code{Shared_Passive} for
15387 @cindex pragma @code{Shared_Passive}
15388 the purpose of designating shared passive packages.
15389 This allows the use of passive partitions in the
15390 context described in the Ada Reference Manual; i.e., for communication
15391 between separate partitions of a distributed application using the
15392 features in Annex E.
15393 @cindex Annex E
15394 @cindex Distribution Systems Annex
15395
15396 However, the implementation approach used by GNAT provides for more
15397 extensive usage as follows:
15398
15399 @table @emph
15400 @item Communication between separate programs
15401
15402 This allows separate programs to access the data in passive
15403 partitions, using protected objects for synchronization where
15404 needed. The only requirement is that the two programs have a
15405 common shared file system. It is even possible for programs
15406 running on different machines with different architectures
15407 (e.g.@: different endianness) to communicate via the data in
15408 a passive partition.
15409
15410 @item Persistence between program runs
15411
15412 The data in a passive package can persist from one run of a
15413 program to another, so that a later program sees the final
15414 values stored by a previous run of the same program.
15415
15416 @end table
15417
15418 @noindent
15419 The implementation approach used is to store the data in files. A
15420 separate stream file is created for each object in the package, and
15421 an access to an object causes the corresponding file to be read or
15422 written.
15423
15424 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15425 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15426 set to the directory to be used for these files.
15427 The files in this directory
15428 have names that correspond to their fully qualified names. For
15429 example, if we have the package
15430
15431 @smallexample @c ada
15432 package X is
15433   pragma Shared_Passive (X);
15434   Y : Integer;
15435   Z : Float;
15436 end X;
15437 @end smallexample
15438
15439 @noindent
15440 and the environment variable is set to @code{/stemp/}, then the files created
15441 will have the names:
15442
15443 @smallexample
15444 /stemp/x.y
15445 /stemp/x.z
15446 @end smallexample
15447
15448 @noindent
15449 These files are created when a value is initially written to the object, and
15450 the files are retained until manually deleted. This provides the persistence
15451 semantics. If no file exists, it means that no partition has assigned a value
15452 to the variable; in this case the initial value declared in the package
15453 will be used. This model ensures that there are no issues in synchronizing
15454 the elaboration process, since elaboration of passive packages elaborates the
15455 initial values, but does not create the files.
15456
15457 The files are written using normal @code{Stream_IO} access.
15458 If you want to be able
15459 to communicate between programs or partitions running on different
15460 architectures, then you should use the XDR versions of the stream attribute
15461 routines, since these are architecture independent.
15462
15463 If active synchronization is required for access to the variables in the
15464 shared passive package, then as described in the Ada Reference Manual, the
15465 package may contain protected objects used for this purpose. In this case
15466 a lock file (whose name is @file{___lock} (three underscores)
15467 is created in the shared memory directory.
15468 @cindex @file{___lock} file (for shared passive packages)
15469 This is used to provide the required locking
15470 semantics for proper protected object synchronization.
15471
15472 As of January 2003, GNAT supports shared passive packages on all platforms
15473 except for OpenVMS.
15474
15475 @node Code Generation for Array Aggregates
15476 @section Code Generation for Array Aggregates
15477
15478 @menu
15479 * Static constant aggregates with static bounds::
15480 * Constant aggregates with unconstrained nominal types::
15481 * Aggregates with static bounds::
15482 * Aggregates with non-static bounds::
15483 * Aggregates in assignment statements::
15484 @end menu
15485
15486 @noindent
15487 Aggregates have a rich syntax and allow the user to specify the values of
15488 complex data structures by means of a single construct.  As a result, the
15489 code generated for aggregates can be quite complex and involve loops, case
15490 statements and multiple assignments.  In the simplest cases, however, the
15491 compiler will recognize aggregates whose components and constraints are
15492 fully static, and in those cases the compiler will generate little or no
15493 executable code.  The following is an outline of the code that GNAT generates
15494 for various aggregate constructs.  For further details, you will find it
15495 useful to examine the output produced by the -gnatG flag to see the expanded
15496 source that is input to the code generator.  You may also want to examine
15497 the assembly code generated at various levels of optimization.
15498
15499 The code generated for aggregates depends on the context, the component values,
15500 and the type.  In the context of an object declaration the code generated is
15501 generally simpler than in the case of an assignment.  As a general rule, static
15502 component values and static subtypes also lead to simpler code.
15503
15504 @node Static constant aggregates with static bounds
15505 @subsection Static constant aggregates with static bounds
15506
15507 @noindent
15508 For the declarations:
15509 @smallexample @c ada
15510     type One_Dim is array (1..10) of integer;
15511     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15512 @end smallexample
15513
15514 @noindent
15515 GNAT generates no executable code: the constant ar0 is placed in static memory.
15516 The same is true for constant aggregates with named associations:
15517
15518 @smallexample @c ada
15519     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15520     Cr3 : constant One_Dim := (others => 7777);
15521 @end smallexample
15522
15523 @noindent
15524 The same is true for multidimensional constant arrays such as:
15525
15526 @smallexample @c ada
15527     type two_dim is array (1..3, 1..3) of integer;
15528     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15529 @end smallexample
15530
15531 @noindent
15532 The same is true for arrays of one-dimensional arrays: the following are
15533 static:
15534
15535 @smallexample @c ada
15536 type ar1b  is array (1..3) of boolean;
15537 type ar_ar is array (1..3) of ar1b;
15538 None  : constant ar1b := (others => false);     --  fully static
15539 None2 : constant ar_ar := (1..3 => None);       --  fully static
15540 @end smallexample
15541
15542 @noindent
15543 However, for multidimensional aggregates with named associations, GNAT will
15544 generate assignments and loops, even if all associations are static.  The
15545 following two declarations generate a loop for the first dimension, and
15546 individual component assignments for the second dimension:
15547
15548 @smallexample @c ada
15549 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15550 Zero2: constant two_dim := (others => (others => 0));
15551 @end smallexample
15552
15553 @node Constant aggregates with unconstrained nominal types
15554 @subsection Constant aggregates with unconstrained nominal types
15555
15556 @noindent
15557 In such cases the aggregate itself establishes the subtype, so that
15558 associations with @code{others} cannot be used.  GNAT determines the
15559 bounds for the actual subtype of the aggregate, and allocates the
15560 aggregate statically as well.  No code is generated for the following:
15561
15562 @smallexample @c ada
15563     type One_Unc is array (natural range <>) of integer;
15564     Cr_Unc : constant One_Unc := (12,24,36);
15565 @end smallexample
15566
15567 @node Aggregates with static bounds
15568 @subsection Aggregates with static bounds
15569
15570 @noindent
15571 In all previous examples the aggregate was the initial (and immutable) value
15572 of a constant.  If the aggregate initializes a variable, then code is generated
15573 for it as a combination of individual assignments and loops over the target
15574 object.  The declarations
15575
15576 @smallexample @c ada
15577        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15578        Cr_Var2 : One_Dim := (others > -1);
15579 @end smallexample
15580
15581 @noindent
15582 generate the equivalent of
15583
15584 @smallexample @c ada
15585        Cr_Var1 (1) := 2;
15586        Cr_Var1 (2) := 3;
15587        Cr_Var1 (3) := 5;
15588        Cr_Var1 (4) := 11;
15589
15590        for I in Cr_Var2'range loop
15591           Cr_Var2 (I) := -1;
15592        end loop;
15593 @end smallexample
15594
15595 @node Aggregates with non-static bounds
15596 @subsection Aggregates with non-static bounds
15597
15598 @noindent
15599 If the bounds of the aggregate are not statically compatible with the bounds
15600 of the nominal subtype  of the target, then constraint checks have to be
15601 generated on the bounds.  For a multidimensional array, constraint checks may
15602 have to be applied to sub-arrays individually, if they do not have statically
15603 compatible subtypes.
15604
15605 @node Aggregates in assignment statements
15606 @subsection Aggregates in assignment statements
15607
15608 @noindent
15609 In general, aggregate assignment requires the construction of a temporary,
15610 and a copy from the temporary to the target of the assignment.  This is because
15611 it is not always possible to convert the assignment into a series of individual
15612 component assignments.  For example, consider the simple case:
15613
15614 @smallexample @c ada
15615         A := (A(2), A(1));
15616 @end smallexample
15617
15618 @noindent
15619 This cannot be converted into:
15620
15621 @smallexample @c ada
15622         A(1) := A(2);
15623         A(2) := A(1);
15624 @end smallexample
15625
15626 @noindent
15627 So the aggregate has to be built first in a separate location, and then
15628 copied into the target.  GNAT recognizes simple cases where this intermediate
15629 step is not required, and the assignments can be performed in place, directly
15630 into the target.  The following sufficient criteria are applied:
15631
15632 @itemize @bullet
15633 @item
15634 The bounds of the aggregate are static, and the associations are static.
15635 @item
15636 The components of the aggregate are static constants, names of
15637 simple variables that are not renamings, or expressions not involving
15638 indexed components whose operands obey these rules.
15639 @end itemize
15640
15641 @noindent
15642 If any of these conditions are violated, the aggregate will be built in
15643 a temporary (created either by the front-end or the code generator) and then
15644 that temporary will be copied onto the target.
15645
15646
15647 @node The Size of Discriminated Records with Default Discriminants
15648 @section The Size of Discriminated Records with Default Discriminants
15649
15650 @noindent
15651 If a discriminated type @code{T} has discriminants with default values, it is
15652 possible to declare an object of this type without providing an explicit
15653 constraint:
15654
15655 @smallexample @c ada
15656 @group
15657 type Size is range 1..100;
15658
15659 type Rec (D : Size := 15) is record
15660    Name : String (1..D);
15661 end T;
15662
15663 Word : Rec;
15664 @end group
15665 @end smallexample
15666
15667 @noindent
15668 Such an object is said to be @emph{unconstrained}.
15669 The discriminant of the object
15670 can be modified by a full assignment to the object, as long as it preserves the
15671 relation between the value of the discriminant, and the value of the components
15672 that depend on it:
15673
15674 @smallexample @c ada
15675 @group
15676 Word := (3, "yes");
15677
15678 Word := (5, "maybe");
15679
15680 Word := (5, "no"); -- raises Constraint_Error
15681 @end group
15682 @end smallexample
15683
15684 @noindent
15685 In order to support this behavior efficiently, an unconstrained object is
15686 given the maximum size that any value of the type requires. In the case
15687 above, @code{Word} has storage for the discriminant and for
15688 a @code{String} of length 100.
15689 It is important to note that unconstrained objects do not require dynamic
15690 allocation. It would be an improper implementation to place on the heap those
15691 components whose size depends on discriminants. (This improper implementation
15692 was used by some Ada83 compilers, where the @code{Name} component above
15693 would have
15694 been stored as a pointer to a dynamic string). Following the principle that
15695 dynamic storage management should never be introduced implicitly,
15696 an Ada compiler should reserve the full size for an unconstrained declared
15697 object, and place it on the stack.
15698
15699 This maximum size approach
15700 has been a source of surprise to some users, who expect the default
15701 values of the discriminants to determine the size reserved for an
15702 unconstrained object: ``If the default is 15, why should the object occupy
15703 a larger size?''
15704 The answer, of course, is that the discriminant may be later modified,
15705 and its full range of values must be taken into account. This is why the
15706 declaration:
15707
15708 @smallexample
15709 @group
15710 type Rec (D : Positive := 15) is record
15711    Name : String (1..D);
15712 end record;
15713
15714 Too_Large : Rec;
15715 @end group
15716 @end smallexample
15717
15718 @noindent
15719 is flagged by the compiler with a warning:
15720 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15721 because the required size includes @code{Positive'Last}
15722 bytes. As the first example indicates, the proper approach is to declare an
15723 index type of ``reasonable'' range so that unconstrained objects are not too
15724 large.
15725
15726 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15727 created in the heap by means of an allocator, then it is @emph{not}
15728 unconstrained:
15729 it is constrained by the default values of the discriminants, and those values
15730 cannot be modified by full assignment. This is because in the presence of
15731 aliasing all views of the object (which may be manipulated by different tasks,
15732 say) must be consistent, so it is imperative that the object, once created,
15733 remain invariant.
15734
15735 @node Strict Conformance to the Ada Reference Manual
15736 @section Strict Conformance to the Ada Reference Manual
15737
15738 @noindent
15739 The dynamic semantics defined by the Ada Reference Manual impose a set of
15740 run-time checks to be generated. By default, the GNAT compiler will insert many
15741 run-time checks into the compiled code, including most of those required by the
15742 Ada Reference Manual. However, there are three checks that are not enabled
15743 in the default mode for efficiency reasons: arithmetic overflow checking for
15744 integer operations (including division by zero), checks for access before
15745 elaboration on subprogram calls, and stack overflow checking (most operating
15746 systems do not perform this check by default).
15747
15748 Strict conformance to the Ada Reference Manual can be achieved by adding
15749 three compiler options for overflow checking for integer operations
15750 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15751 calls and generic instantiations (@option{-gnatE}), and stack overflow
15752 checking (@option{-fstack-check}).
15753
15754 Note that the result of a floating point arithmetic operation in overflow and
15755 invalid situations, when the @code{Machine_Overflows} attribute of the result
15756 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15757 case for machines compliant with the IEEE floating-point standard, but on
15758 machines that are not fully compliant with this standard, such as Alpha, the
15759 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15760 behavior (although at the cost of a significant performance penalty), so
15761 infinite and and NaN values are properly generated.
15762
15763
15764 @node Project File Reference
15765 @chapter Project File Reference
15766
15767 @noindent
15768 This chapter describes the syntax and semantics of project files.
15769 Project files specify the options to be used when building a system.
15770 Project files can specify global settings for all tools,
15771 as well as tool-specific settings.
15772 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15773 for examples of use.
15774
15775 @menu
15776 * Reserved Words::
15777 * Lexical Elements::
15778 * Declarations::
15779 * Empty declarations::
15780 * Typed string declarations::
15781 * Variables::
15782 * Expressions::
15783 * Attributes::
15784 * Project Attributes::
15785 * Attribute References::
15786 * External Values::
15787 * Case Construction::
15788 * Packages::
15789 * Package Renamings::
15790 * Projects::
15791 * Project Extensions::
15792 * Project File Elaboration::
15793 @end menu
15794
15795 @node Reserved Words
15796 @section Reserved Words
15797
15798 @noindent
15799 All Ada reserved words are reserved in project files, and cannot be used
15800 as variable names or project names. In addition, the following are
15801 also reserved in project files:
15802
15803 @itemize
15804 @item @code{extends}
15805
15806 @item @code{external}
15807
15808 @item @code{project}
15809
15810 @end itemize
15811
15812 @node Lexical Elements
15813 @section Lexical Elements
15814
15815 @noindent
15816 Rules for identifiers are the same as in Ada. Identifiers
15817 are case-insensitive.  Strings are case sensitive, except where noted.
15818 Comments have the same form as in Ada.
15819
15820 @noindent
15821 Syntax:
15822
15823 @smallexample
15824 simple_name ::=
15825   identifier
15826
15827 name ::=
15828   simple_name @{. simple_name@}
15829 @end smallexample
15830
15831 @node Declarations
15832 @section Declarations
15833
15834 @noindent
15835 Declarations introduce new entities that denote types, variables, attributes,
15836 and packages. Some declarations can only appear immediately within a project
15837 declaration. Others can appear within a project or within a package.
15838
15839 Syntax:
15840 @smallexample
15841 declarative_item ::=
15842   simple_declarative_item |
15843   typed_string_declaration |
15844   package_declaration
15845
15846 simple_declarative_item ::=
15847   variable_declaration |
15848   typed_variable_declaration |
15849   attribute_declaration |
15850   case_construction |
15851   empty_declaration
15852 @end smallexample
15853
15854 @node Empty declarations
15855 @section Empty declarations
15856
15857 @smallexample
15858 empty_declaration ::=
15859   @b{null} ;
15860 @end smallexample
15861
15862 An empty declaration is allowed anywhere a declaration is allowed.
15863 It has no effect.
15864
15865 @node Typed string declarations
15866 @section Typed string declarations
15867
15868 @noindent
15869 Typed strings are sequences of string literals. Typed strings are the only
15870 named types in project files. They are used in case constructions, where they
15871 provide support for conditional attribute definitions.
15872
15873 Syntax:
15874 @smallexample
15875 typed_string_declaration ::=
15876   @b{type} <typed_string_>_simple_name @b{is}
15877    ( string_literal @{, string_literal@} );
15878 @end smallexample
15879
15880 @noindent
15881 A typed string declaration can only appear immediately within a project
15882 declaration.
15883
15884 All the string literals in a typed string declaration must be distinct.
15885
15886 @node Variables
15887 @section Variables
15888
15889 @noindent
15890 Variables denote values, and appear as constituents of expressions.
15891
15892 @smallexample
15893 typed_variable_declaration ::=
15894   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15895
15896 variable_declaration ::=
15897   <variable_>simple_name := expression;
15898 @end smallexample
15899
15900 @noindent
15901 The elaboration of a variable declaration introduces the variable and
15902 assigns to it the value of the expression. The name of the variable is
15903 available after the assignment symbol.
15904
15905 @noindent
15906 A typed_variable can only be declare once.
15907
15908 @noindent
15909 a non-typed variable can be declared multiple times.
15910
15911 @noindent
15912 Before the completion of its first declaration, the value of variable
15913 is the null string.
15914
15915 @node Expressions
15916 @section Expressions
15917
15918 @noindent
15919 An expression is a formula that defines a computation or retrieval of a value.
15920 In a project file the value of an expression is either a string or a list
15921 of strings. A string value in an expression is either a literal, the current
15922 value of a variable, an external value, an attribute reference, or a
15923 concatenation operation.
15924
15925 Syntax:
15926
15927 @smallexample
15928 expression ::=
15929   term @{& term@}
15930
15931 term ::=
15932   string_literal |
15933   string_list |
15934   <variable_>name |
15935   external_value |
15936   attribute_reference
15937
15938 string_literal ::=
15939   (same as Ada)
15940
15941 string_list ::=
15942   ( <string_>expression @{ , <string_>expression @} )
15943 @end smallexample
15944
15945 @subsection Concatenation
15946 @noindent
15947 The following concatenation functions are defined:
15948
15949 @smallexample @c ada
15950   function "&" (X : String;      Y : String)      return String;
15951   function "&" (X : String_List; Y : String)      return String_List;
15952   function "&" (X : String_List; Y : String_List) return String_List;
15953 @end smallexample
15954
15955 @node Attributes
15956 @section Attributes
15957
15958 @noindent
15959 An attribute declaration defines a property of a project or package. This
15960 property can later be queried by means of an attribute reference.
15961 Attribute values are strings or string lists.
15962
15963 Some attributes are associative arrays. These attributes are mappings whose
15964 domain is a set of strings. These attributes are declared one association
15965 at a time, by specifying a point in the domain and the corresponding image
15966 of the attribute. They may also be declared as a full associative array,
15967 getting the same associations as the corresponding attribute in an imported
15968 or extended project.
15969
15970 Attributes that are not associative arrays are called simple attributes.
15971
15972 Syntax:
15973 @smallexample
15974 attribute_declaration ::=
15975   full_associative_array_declaration |
15976   @b{for} attribute_designator @b{use} expression ;
15977
15978 full_associative_array_declaration ::=
15979   @b{for} <associative_array_attribute_>simple_name @b{use}
15980   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15981
15982 attribute_designator ::=
15983   <simple_attribute_>simple_name |
15984   <associative_array_attribute_>simple_name ( string_literal )
15985 @end smallexample
15986
15987 @noindent
15988 Some attributes are project-specific, and can only appear immediately within
15989 a project declaration. Others are package-specific, and can only appear within
15990 the proper package.
15991
15992 The expression in an attribute definition must be a string or a string_list.
15993 The string literal appearing in the attribute_designator of an associative
15994 array attribute is case-insensitive.
15995
15996 @node Project Attributes
15997 @section Project Attributes
15998
15999 @noindent
16000 The following attributes apply to a project. All of them are simple
16001 attributes.
16002
16003 @table @code
16004 @item   Object_Dir
16005 Expression must be a path name. The attribute defines the
16006 directory in which the object files created by the build are to be placed. If
16007 not specified, object files are placed in the project directory.
16008
16009 @item   Exec_Dir
16010 Expression must be a path name. The attribute defines the
16011 directory in which the executables created by the build are to be placed.
16012 If not specified, executables are placed in the object directory.
16013
16014 @item  Source_Dirs
16015 Expression must be a list of path names. The attribute
16016 defines the directories in which the source files for the project are to be
16017 found. If not specified, source files are found in the project directory.
16018 If a string in the list ends with "/**", then the directory that precedes
16019 "/**" and all of its subdirectories (recursively) are included in the list
16020 of source directories.
16021
16022 @item  Excluded_Source_Dirs
16023 Expression must be a list of strings. Each entry designates a directory that
16024 is not to be included in the list of source directories of the project.
16025 This is normally used when there are strings ending with "/**" in the value
16026 of attribute Source_Dirs.
16027
16028 @item  Source_Files
16029 Expression must be a list of file names. The attribute
16030 defines the individual files, in the project directory, which are to be used
16031 as sources for the project. File names are path_names that contain no directory
16032 information. If the project has no sources the attribute must be declared
16033 explicitly with an empty list.
16034
16035 @item  Excluded_Source_Files (Locally_Removed_Files)
16036 Expression must be a list of strings that are legal file names.
16037 Each file name must designate a source that would normally be a source file
16038 in the source directories of the project or, if the project file is an
16039 extending project file, inherited by the current project file. It cannot
16040 designate an immediate source that is not inherited. Each of the source files
16041 in the list are not considered to be sources of the project file: they are not
16042 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16043 Excluded_Source_Files is preferred.
16044
16045 @item  Source_List_File
16046 Expression must a single path name. The attribute
16047 defines a text file that contains a list of source file names to be used
16048 as sources for the project
16049
16050 @item  Library_Dir
16051 Expression must be a path name. The attribute defines the
16052 directory in which a  library is to be built.  The directory must exist, must
16053 be distinct from the project's object directory, and must be writable.
16054
16055 @item  Library_Name
16056 Expression must be a string that is a legal file name,
16057 without extension. The attribute defines a string that is used to generate
16058 the name of the library to be built by the project.
16059
16060 @item  Library_Kind
16061 Argument must be a string value that must be one of the
16062 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16063 string is case-insensitive. If this attribute is not specified, the library is
16064 a static library. Otherwise, the library may be dynamic or relocatable. This
16065 distinction is operating-system dependent.
16066
16067 @item  Library_Version
16068 Expression must be a string value whose interpretation
16069 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16070 libraries as the internal name of the library (the @code{"soname"}). If the
16071 library file name (built from the @code{Library_Name}) is different from the
16072 @code{Library_Version}, then the library file will be a symbolic link to the
16073 actual file whose name will be @code{Library_Version}.
16074
16075 @item Library_Interface
16076 Expression must be a string list. Each element of the string list
16077 must designate a unit of the project.
16078 If this attribute is present in a Library Project File, then the project
16079 file is a Stand-alone Library_Project_File.
16080
16081 @item Library_Auto_Init
16082 Expression must be a single string "true" or "false", case-insensitive.
16083 If this attribute is present in a Stand-alone Library Project File,
16084 it indicates if initialization is automatic when the dynamic library
16085 is loaded.
16086
16087 @item Library_Options
16088 Expression must be a string list. Indicates additional switches that
16089 are to be used when building a shared library.
16090
16091 @item Library_GCC
16092 Expression must be a single string. Designates an alternative to "gcc"
16093 for building shared libraries.
16094
16095 @item  Library_Src_Dir
16096 Expression must be a path name. The attribute defines the
16097 directory in which the sources of the interfaces of a Stand-alone Library will
16098 be copied.  The directory must exist, must be distinct from the project's
16099 object directory and source directories of all projects in the project tree,
16100 and must be writable.
16101
16102 @item  Library_Src_Dir
16103 Expression must be a path name. The attribute defines the
16104 directory in which the ALI files of a Library will
16105 be copied.  The directory must exist, must be distinct from the project's
16106 object directory and source directories of all projects in the project tree,
16107 and must be writable.
16108
16109 @item  Library_Symbol_File
16110 Expression must be a single string. Its value is the single file name of a
16111 symbol file to be created when building a stand-alone library when the
16112 symbol policy is either "compliant", "controlled" or "restricted",
16113 on platforms that support symbol control, such as VMS. When symbol policy
16114 is "direct", then a file with this name must exist in the object directory.
16115
16116 @item   Library_Reference_Symbol_File
16117 Expression must be a single string. Its value is the path name of a
16118 reference symbol file that is read when the symbol policy is either
16119 "compliant" or "controlled", on platforms that support symbol control,
16120 such as VMS, when building a stand-alone library. The path may be an absolute
16121 path or a path relative to the project directory.
16122
16123 @item  Library_Symbol_Policy
16124 Expression must be a single string. Its case-insensitive value can only be
16125 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16126
16127 This attribute is not taken into account on all platforms. It controls the
16128 policy for exported symbols and, on some platforms (like VMS) that have the
16129 notions of major and minor IDs built in the library files, it controls
16130 the setting of these IDs.
16131
16132 "autonomous" or "default": exported symbols are not controlled.
16133
16134 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16135 it is equivalent to policy "autonomous". If there are exported symbols in
16136 the reference symbol file that are not in the object files of the interfaces,
16137 the major ID of the library is increased. If there are symbols in the
16138 object files of the interfaces that are not in the reference symbol file,
16139 these symbols are put at the end of the list in the newly created symbol file
16140 and the minor ID is increased.
16141
16142 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16143 The library will fail to build if the exported symbols in the object files of
16144 the interfaces do not match exactly the symbol in the symbol file.
16145
16146 "restricted": The attribute Library_Symbol_File must be defined. The library
16147 will fail to build if there are symbols in the symbol file that are not in
16148 the exported symbols of the object files of the interfaces. Additional symbols
16149 in the object files are not added to the symbol file.
16150
16151 "direct": The attribute Library_Symbol_File must be defined and must designate
16152 an existing file in the object directory. This symbol file is passed directly
16153 to the underlying linker without any symbol processing.
16154
16155 @item  Main
16156 Expression must be a list of strings that are legal file names.
16157 These file names designate existing compilation units in the source directory
16158 that are legal main subprograms.
16159
16160 When a project file is elaborated, as part of the execution of a gnatmake
16161 command, one or several executables are built and placed in the Exec_Dir.
16162 If the gnatmake command does not include explicit file names, the executables
16163 that are built correspond to the files specified by this attribute.
16164
16165 @item  Externally_Built
16166 Expression must be a single string. Its value must be either "true" of "false",
16167 case-insensitive. The default is "false". When the value of this attribute is
16168 "true", no attempt is made to compile the sources or to build the library,
16169 when the project is a library project.
16170
16171 @item Main_Language
16172 This is a simple attribute. Its value is a string that specifies the
16173 language of the main program.
16174
16175 @item  Languages
16176 Expression must be a string list. Each string designates
16177 a programming language that is known to GNAT. The strings are case-insensitive.
16178
16179 @end table
16180
16181 @node Attribute References
16182 @section Attribute References
16183
16184 @noindent
16185 Attribute references are used to retrieve the value of previously defined
16186 attribute for a package or project.
16187 Syntax:
16188 @smallexample
16189 attribute_reference ::=
16190   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16191
16192 attribute_prefix ::=
16193   @b{project} |
16194   <project_simple_name | package_identifier |
16195   <project_>simple_name . package_identifier
16196 @end smallexample
16197
16198 @noindent
16199 If an attribute has not been specified for a given package or project, its
16200 value is the null string or the empty list.
16201
16202 @node External Values
16203 @section External Values
16204
16205 @noindent
16206 An external value is an expression whose value is obtained from the command
16207 that invoked the processing of the current project file (typically a
16208 gnatmake command).
16209
16210 Syntax:
16211 @smallexample
16212 external_value ::=
16213   @b{external} ( string_literal [, string_literal] )
16214 @end smallexample
16215
16216 @noindent
16217 The first string_literal is the string to be used on the command line or
16218 in the environment to specify the external value. The second string_literal,
16219 if present, is the default to use if there is no specification for this
16220 external value either on the command line or in the environment.
16221
16222 @node Case Construction
16223 @section Case Construction
16224
16225 @noindent
16226 A case construction supports attribute and variable declarations that depend
16227 on the value of a previously declared variable.
16228
16229 Syntax:
16230 @smallexample
16231 case_construction ::=
16232   @b{case} <typed_variable_>name @b{is}
16233     @{case_item@}
16234   @b{end case} ;
16235
16236 case_item ::=
16237   @b{when} discrete_choice_list =>
16238     @{case_construction |
16239       attribute_declaration |
16240       variable_declaration |
16241       empty_declaration@}
16242
16243 discrete_choice_list ::=
16244   string_literal @{| string_literal@} |
16245     @b{others}
16246 @end smallexample
16247
16248 @noindent
16249 Inside a case construction, variable declarations must be for variables that
16250 have already been declared before the case construction.
16251
16252 All choices in a choice list must be distinct. The choice lists of two
16253 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16254 alternatives do not need to include all values of the type. An @code{others}
16255 choice must appear last in the list of alternatives.
16256
16257 @node Packages
16258 @section Packages
16259
16260 @noindent
16261 A package provides a grouping of variable declarations and attribute
16262 declarations to be used when invoking various GNAT tools. The name of
16263 the package indicates the tool(s) to which it applies.
16264 Syntax:
16265
16266 @smallexample
16267 package_declaration ::=
16268   package_spec | package_renaming
16269
16270 package_spec ::=
16271   @b{package} package_identifier @b{is}
16272     @{simple_declarative_item@}
16273   @b{end} package_identifier ;
16274
16275 package_identifier ::=
16276   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16277   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16278   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16279 @end smallexample
16280
16281 @subsection Package Naming
16282
16283 @noindent
16284 The attributes of a @code{Naming} package specifies the naming conventions
16285 that apply to the source files in a project. When invoking other GNAT tools,
16286 they will use the sources in the source directories that satisfy these
16287 naming conventions.
16288
16289 The following attributes apply to a @code{Naming} package:
16290
16291 @table @code
16292 @item Casing
16293 This is a simple attribute whose value is a string. Legal values of this
16294 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16295 These strings are themselves case insensitive.
16296
16297 @noindent
16298 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16299
16300 @item Dot_Replacement
16301 This is a simple attribute whose string value satisfies the following
16302 requirements:
16303
16304 @itemize @bullet
16305 @item It must not be empty
16306 @item It cannot start or end with an alphanumeric character
16307 @item It cannot be a single underscore
16308 @item It cannot start with an underscore followed by an alphanumeric
16309 @item It cannot contain a dot @code{'.'} if longer than one character
16310 @end itemize
16311
16312 @noindent
16313 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16314
16315 @item Spec_Suffix
16316 This is an associative array attribute, defined on language names,
16317 whose image is a string that must satisfy the following
16318 conditions:
16319
16320 @itemize @bullet
16321 @item It must not be empty
16322 @item It cannot start with an alphanumeric character
16323 @item It cannot start with an underscore followed by an alphanumeric character
16324 @end itemize
16325
16326 @noindent
16327 For Ada, the attribute denotes the suffix used in file names that contain
16328 library unit declarations, that is to say units that are package and
16329 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16330 specified, then the default is @code{".ads"}.
16331
16332 For C and C++, the attribute denotes the suffix used in file names that
16333 contain prototypes.
16334
16335 @item Body_Suffix
16336 This is an associative array attribute defined on language names,
16337 whose image is a string that must satisfy the following
16338 conditions:
16339
16340 @itemize @bullet
16341 @item It must not be empty
16342 @item It cannot start with an alphanumeric character
16343 @item It cannot start with an underscore followed by an alphanumeric character
16344 @item It cannot be a suffix of @code{Spec_Suffix}
16345 @end itemize
16346
16347 @noindent
16348 For Ada, the attribute denotes the suffix used in file names that contain
16349 library bodies, that is to say units that are package and subprogram bodies.
16350 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16351 @code{".adb"}.
16352
16353 For C and C++, the attribute denotes the suffix used in file names that contain
16354 source code.
16355
16356 @item Separate_Suffix
16357 This is a simple attribute whose value satisfies the same conditions as
16358 @code{Body_Suffix}.
16359
16360 This attribute is specific to Ada. It denotes the suffix used in file names
16361 that contain separate bodies. If it is not specified, then it defaults to same
16362 value as @code{Body_Suffix ("Ada")}.
16363
16364 @item Spec
16365 This is an associative array attribute, specific to Ada, defined over
16366 compilation unit names. The image is a string that is the name of the file
16367 that contains that library unit. The file name is case sensitive if the
16368 conventions of the host operating system require it.
16369
16370 @item Body
16371 This is an associative array attribute, specific to Ada, defined over
16372 compilation unit names. The image is a string that is the name of the file
16373 that contains the library unit body for the named unit. The file name is case
16374 sensitive if the conventions of the host operating system require it.
16375
16376 @item Specification_Exceptions
16377 This is an associative array attribute defined on language names,
16378 whose value is a list of strings.
16379
16380 This attribute is not significant for Ada.
16381
16382 For C and C++, each string in the list denotes the name of a file that
16383 contains prototypes, but whose suffix is not necessarily the
16384 @code{Spec_Suffix} for the language.
16385
16386 @item Implementation_Exceptions
16387 This is an associative array attribute defined on language names,
16388 whose value is a list of strings.
16389
16390 This attribute is not significant for Ada.
16391
16392 For C and C++, each string in the list denotes the name of a file that
16393 contains source code, but whose suffix is not necessarily the
16394 @code{Body_Suffix} for the language.
16395 @end table
16396
16397 The following attributes of package @code{Naming} are obsolescent. They are
16398 kept as synonyms of other attributes for compatibility with previous versions
16399 of the Project Manager.
16400
16401 @table @code
16402 @item Specification_Suffix
16403 This is a synonym of @code{Spec_Suffix}.
16404
16405 @item Implementation_Suffix
16406 This is a synonym of @code{Body_Suffix}.
16407
16408 @item Specification
16409 This is a synonym of @code{Spec}.
16410
16411 @item Implementation
16412 This is a synonym of @code{Body}.
16413 @end table
16414
16415 @subsection package Compiler
16416
16417 @noindent
16418 The attributes of the @code{Compiler} package specify the compilation options
16419 to be used by the underlying compiler.
16420
16421 @table @code
16422 @item  Default_Switches
16423 This is an associative array attribute. Its
16424 domain is a set of language names. Its range is a string list that
16425 specifies the compilation options to be used when compiling a component
16426 written in that language, for which no file-specific switches have been
16427 specified.
16428
16429 @item  Switches
16430 This is an associative array attribute. Its domain is
16431 a set of file names. Its range is a string list that specifies the
16432 compilation options to be used when compiling the named file. If a file
16433 is not specified in the Switches attribute, it is compiled with the
16434 options specified by Default_Switches of its language, if defined.
16435
16436 @item  Local_Configuration_Pragmas.
16437 This is a simple attribute, whose
16438 value is a path name that designates a file containing configuration pragmas
16439 to be used for all invocations of the compiler for immediate sources of the
16440 project.
16441 @end table
16442
16443 @subsection package Builder
16444
16445 @noindent
16446 The attributes of package @code{Builder} specify the compilation, binding, and
16447 linking options to be used when building an executable for a project. The
16448 following attributes apply to package @code{Builder}:
16449
16450 @table @code
16451 @item Default_Switches
16452 This is an associative array attribute. Its
16453 domain is a set of language names. Its range is a string list that
16454 specifies options to be used when building a main
16455 written in that language, for which no file-specific switches have been
16456 specified.
16457
16458 @item Switches
16459 This is an associative array attribute. Its domain is
16460 a set of file names. Its range is a string list that specifies
16461 options to be used when building the named main file. If a main file
16462 is not specified in the Switches attribute, it is built with the
16463 options specified by Default_Switches of its language, if defined.
16464
16465 @item Global_Configuration_Pragmas
16466 This is a simple attribute, whose
16467 value is a path name that designates a file that contains configuration pragmas
16468 to be used in every build of an executable. If both local and global
16469 configuration pragmas are specified, a compilation makes use of both sets.
16470
16471
16472 @item Executable
16473 This is an associative array attribute. Its domain is
16474 a set of main source file names. Its range is a simple string that specifies
16475 the executable file name to be used when linking the specified main source.
16476 If a main source is not specified in the Executable attribute, the executable
16477 file name is deducted from the main source file name.
16478 This attribute has no effect if its value is the empty string.
16479
16480 @item Executable_Suffix
16481 This is a simple attribute whose value is the suffix to be added to
16482 the executables that don't have an attribute Executable specified.
16483 @end table
16484
16485 @subsection package Gnatls
16486
16487 @noindent
16488 The attributes of package @code{Gnatls} specify the tool options to be used
16489 when invoking the library browser @command{gnatls}.
16490 The following attributes apply to package @code{Gnatls}:
16491
16492 @table @code
16493 @item Switches
16494 This is a single attribute with a string list value. Each nonempty string
16495 in the list is an option when invoking @code{gnatls}.
16496 @end table
16497
16498 @subsection package Binder
16499
16500 @noindent
16501 The attributes of package @code{Binder} specify the options to be used
16502 when invoking the binder in the construction of an executable.
16503 The following attributes apply to package @code{Binder}:
16504
16505 @table @code
16506 @item     Default_Switches
16507 This is an associative array attribute. Its
16508 domain is a set of language names. Its range is a string list that
16509 specifies options to be used when binding a main
16510 written in that language, for which no file-specific switches have been
16511 specified.
16512
16513 @item Switches
16514 This is an associative array attribute. Its domain is
16515 a set of file names. Its range is a string list that specifies
16516 options to be used when binding the named main file. If a main file
16517 is not specified in the Switches attribute, it is bound with the
16518 options specified by Default_Switches of its language, if defined.
16519 @end table
16520
16521 @subsection package Linker
16522
16523 @noindent
16524 The attributes of package @code{Linker} specify the options to be used when
16525 invoking the linker in the construction of an executable.
16526 The following attributes apply to package @code{Linker}:
16527
16528 @table @code
16529 @item     Default_Switches
16530 This is an associative array attribute. Its
16531 domain is a set of language names. Its range is a string list that
16532 specifies options to be used when linking a main
16533 written in that language, for which no file-specific switches have been
16534 specified.
16535
16536 @item Switches
16537 This is an associative array attribute. Its domain is
16538 a set of file names. Its range is a string list that specifies
16539 options to be used when linking the named main file. If a main file
16540 is not specified in the Switches attribute, it is linked with the
16541 options specified by Default_Switches of its language, if defined.
16542
16543 @item  Linker_Options
16544 This is a string list attribute. Its value specifies additional options that
16545 be given to the linker when linking an executable. This attribute is not
16546 used in the main project, only in projects imported directly or indirectly.
16547
16548 @end table
16549
16550 @subsection package Cross_Reference
16551
16552 @noindent
16553 The attributes of package @code{Cross_Reference} specify the tool options
16554 to be used
16555 when invoking the library tool @command{gnatxref}.
16556 The following attributes apply to package @code{Cross_Reference}:
16557
16558 @table @code
16559 @item     Default_Switches
16560 This is an associative array attribute. Its
16561 domain is a set of language names. Its range is a string list that
16562 specifies options to be used when calling @command{gnatxref} on a source
16563 written in that language, for which no file-specific switches have been
16564 specified.
16565
16566 @item Switches
16567 This is an associative array attribute. Its domain is
16568 a set of file names. Its range is a string list that specifies
16569 options to be used when calling @command{gnatxref} on the named main source.
16570 If a source is not specified in the Switches attribute, @command{gnatxref} will
16571 be called with the options specified by Default_Switches of its language,
16572 if defined.
16573 @end table
16574
16575 @subsection package   Finder
16576
16577 @noindent
16578 The attributes of package @code{Finder} specify the tool options to be used
16579 when invoking the search tool @command{gnatfind}.
16580 The following attributes apply to package @code{Finder}:
16581
16582 @table @code
16583 @item     Default_Switches
16584 This is an associative array attribute. Its
16585 domain is a set of language names. Its range is a string list that
16586 specifies options to be used when calling @command{gnatfind} on a source
16587 written in that language, for which no file-specific switches have been
16588 specified.
16589
16590 @item Switches
16591 This is an associative array attribute. Its domain is
16592 a set of file names. Its range is a string list that specifies
16593 options to be used when calling @command{gnatfind} on the named main source.
16594 If a source is not specified in the Switches attribute, @command{gnatfind} will
16595 be called with the options specified by Default_Switches of its language,
16596 if defined.
16597 @end table
16598
16599 @subsection package Pretty_Printer
16600
16601 @noindent
16602 The attributes of package @code{Pretty_Printer}
16603 specify the tool options to be used
16604 when invoking the formatting tool @command{gnatpp}.
16605 The following attributes apply to package @code{Pretty_Printer}:
16606
16607 @table @code
16608 @item     Default_switches
16609 This is an associative array attribute. Its
16610 domain is a set of language names. Its range is a string list that
16611 specifies options to be used when calling @command{gnatpp} on a source
16612 written in that language, for which no file-specific switches have been
16613 specified.
16614
16615 @item Switches
16616 This is an associative array attribute. Its domain is
16617 a set of file names. Its range is a string list that specifies
16618 options to be used when calling @command{gnatpp} on the named main source.
16619 If a source is not specified in the Switches attribute, @command{gnatpp} will
16620 be called with the options specified by Default_Switches of its language,
16621 if defined.
16622 @end table
16623
16624 @subsection package gnatstub
16625
16626 @noindent
16627 The attributes of package @code{gnatstub}
16628 specify the tool options to be used
16629 when invoking the tool @command{gnatstub}.
16630 The following attributes apply to package @code{gnatstub}:
16631
16632 @table @code
16633 @item     Default_switches
16634 This is an associative array attribute. Its
16635 domain is a set of language names. Its range is a string list that
16636 specifies options to be used when calling @command{gnatstub} on a source
16637 written in that language, for which no file-specific switches have been
16638 specified.
16639
16640 @item Switches
16641 This is an associative array attribute. Its domain is
16642 a set of file names. Its range is a string list that specifies
16643 options to be used when calling @command{gnatstub} on the named main source.
16644 If a source is not specified in the Switches attribute, @command{gnatpp} will
16645 be called with the options specified by Default_Switches of its language,
16646 if defined.
16647 @end table
16648
16649 @subsection package Eliminate
16650
16651 @noindent
16652 The attributes of package @code{Eliminate}
16653 specify the tool options to be used
16654 when invoking the tool @command{gnatelim}.
16655 The following attributes apply to package @code{Eliminate}:
16656
16657 @table @code
16658 @item     Default_switches
16659 This is an associative array attribute. Its
16660 domain is a set of language names. Its range is a string list that
16661 specifies options to be used when calling @command{gnatelim} on a source
16662 written in that language, for which no file-specific switches have been
16663 specified.
16664
16665 @item Switches
16666 This is an associative array attribute. Its domain is
16667 a set of file names. Its range is a string list that specifies
16668 options to be used when calling @command{gnatelim} on the named main source.
16669 If a source is not specified in the Switches attribute, @command{gnatelim} will
16670 be called with the options specified by Default_Switches of its language,
16671 if defined.
16672 @end table
16673
16674 @subsection package Metrics
16675
16676 @noindent
16677 The attributes of package @code{Metrics}
16678 specify the tool options to be used
16679 when invoking the tool @command{gnatmetric}.
16680 The following attributes apply to package @code{Metrics}:
16681
16682 @table @code
16683 @item     Default_switches
16684 This is an associative array attribute. Its
16685 domain is a set of language names. Its range is a string list that
16686 specifies options to be used when calling @command{gnatmetric} on a source
16687 written in that language, for which no file-specific switches have been
16688 specified.
16689
16690 @item Switches
16691 This is an associative array attribute. Its domain is
16692 a set of file names. Its range is a string list that specifies
16693 options to be used when calling @command{gnatmetric} on the named main source.
16694 If a source is not specified in the Switches attribute, @command{gnatmetric}
16695 will be called with the options specified by Default_Switches of its language,
16696 if defined.
16697 @end table
16698
16699 @subsection  package IDE
16700
16701 @noindent
16702 The attributes of package @code{IDE} specify the options to be used when using
16703 an Integrated Development Environment such as @command{GPS}.
16704
16705 @table @code
16706 @item Remote_Host
16707 This is a simple attribute. Its value is a string that designates the remote
16708 host in a cross-compilation environment, to be used for remote compilation and
16709 debugging. This field should not be specified when running on the local
16710 machine.
16711
16712 @item Program_Host
16713 This is a simple attribute. Its value is a string that specifies the
16714 name of IP address of the embedded target in a cross-compilation environment,
16715 on which the program should execute.
16716
16717 @item Communication_Protocol
16718 This is a simple string attribute. Its value is the name of the protocol
16719 to use to communicate with the target in a cross-compilation environment,
16720 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16721
16722 @item Compiler_Command
16723 This is an associative array attribute, whose domain is a language name. Its
16724 value is  string that denotes the command to be used to invoke the compiler.
16725 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16726 gnatmake, in particular in the handling of switches.
16727
16728 @item Debugger_Command
16729 This is simple attribute, Its value is a string that specifies the name of
16730 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16731
16732 @item Default_Switches
16733 This is an associative array attribute. Its indexes are the name of the
16734 external tools that the GNAT Programming System (GPS) is supporting. Its
16735 value is a list of switches to use when invoking that tool.
16736
16737 @item  Gnatlist
16738 This is a simple attribute.  Its value is a string that specifies the name
16739 of the @command{gnatls} utility to be used to retrieve information about the
16740 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16741
16742 @item VCS_Kind
16743 This is a simple attribute. Its value is a string used to specify the
16744 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16745 ClearCase or Perforce.
16746
16747 @item VCS_File_Check
16748 This is a simple attribute. Its value is a string that specifies the
16749 command used by the VCS to check the validity of a file, either
16750 when the user explicitly asks for a check, or as a sanity check before
16751 doing the check-in.
16752
16753 @item VCS_Log_Check
16754 This is a simple attribute. Its value is a string that specifies
16755 the command used by the VCS to check the validity of a log file.
16756
16757 @item VCS_Repository_Root
16758 The VCS repository root path. This is used to create tags or branches
16759 of the repository. For subversion the value should be the @code{URL}
16760 as specified to check-out the working copy of the repository.
16761
16762 @item VCS_Patch_Root
16763 The local root directory to use for building patch file. All patch chunks
16764 will be relative to this path. The root project directory is used if
16765 this value is not defined.
16766
16767 @end table
16768
16769 @node Package Renamings
16770 @section Package Renamings
16771
16772 @noindent
16773 A package can be defined by a renaming declaration. The new package renames
16774 a package declared in a different project file, and has the same attributes
16775 as the package it renames.
16776 Syntax:
16777 @smallexample
16778 package_renaming ::==
16779   @b{package} package_identifier @b{renames}
16780        <project_>simple_name.package_identifier ;
16781 @end smallexample
16782
16783 @noindent
16784 The package_identifier of the renamed package must be the same as the
16785 package_identifier. The project whose name is the prefix of the renamed
16786 package must contain a package declaration with this name. This project
16787 must appear in the context_clause of the enclosing project declaration,
16788 or be the parent project of the enclosing child project.
16789
16790 @node Projects
16791 @section Projects
16792
16793 @noindent
16794 A project file specifies a set of rules for constructing a software system.
16795 A project file can be self-contained, or depend on other project files.
16796 Dependencies are expressed through a context clause that names other projects.
16797
16798 Syntax:
16799
16800 @smallexample
16801 project ::=
16802   context_clause project_declaration
16803
16804 project_declaration ::=
16805   simple_project_declaration | project_extension
16806
16807 simple_project_declaration ::=
16808   @b{project} <project_>simple_name @b{is}
16809     @{declarative_item@}
16810   @b{end} <project_>simple_name;
16811
16812 context_clause ::=
16813   @{with_clause@}
16814
16815 with_clause ::=
16816   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16817
16818 path_name ::=
16819    string_literal
16820 @end smallexample
16821
16822 @noindent
16823 A path name denotes a project file. A path name can be absolute or relative.
16824 An absolute path name includes a sequence of directories, in the syntax of
16825 the host operating system, that identifies uniquely the project file in the
16826 file system. A relative path name identifies the project file, relative
16827 to the directory that contains the current project, or relative to a
16828 directory listed in the environment variable ADA_PROJECT_PATH.
16829 Path names are case sensitive if file names in the host operating system
16830 are case sensitive.
16831
16832 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16833 directory names separated by colons (semicolons on Windows).
16834
16835 A given project name can appear only once in a context_clause.
16836
16837 It is illegal for a project imported by a context clause to refer, directly
16838 or indirectly, to the project in which this context clause appears (the
16839 dependency graph cannot contain cycles), except when one of the with_clause
16840 in the cycle is a @code{limited with}.
16841
16842 @node Project Extensions
16843 @section Project Extensions
16844
16845 @noindent
16846 A project extension introduces a new project, which inherits the declarations
16847 of another project.
16848 Syntax:
16849 @smallexample
16850
16851 project_extension ::=
16852   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16853     @{declarative_item@}
16854   @b{end} <project_>simple_name;
16855 @end smallexample
16856
16857 @noindent
16858 The project extension declares a child project. The child project inherits
16859 all the declarations and all the files of the parent project, These inherited
16860 declaration can be overridden in the child project, by means of suitable
16861 declarations.
16862
16863 @node Project File Elaboration
16864 @section Project File Elaboration
16865
16866 @noindent
16867 A project file is processed as part of the invocation of a gnat tool that
16868 uses the project option. Elaboration of the process file consists in the
16869 sequential elaboration of all its declarations. The computed values of
16870 attributes and variables in the project are then used to establish the
16871 environment in which the gnat tool will execute.
16872
16873 @node Obsolescent Features
16874 @chapter Obsolescent Features
16875
16876 @noindent
16877 This chapter describes features that are provided by GNAT, but are
16878 considered obsolescent since there are preferred ways of achieving
16879 the same effect. These features are provided solely for historical
16880 compatibility purposes.
16881
16882 @menu
16883 * pragma No_Run_Time::
16884 * pragma Ravenscar::
16885 * pragma Restricted_Run_Time::
16886 @end menu
16887
16888 @node pragma No_Run_Time
16889 @section pragma No_Run_Time
16890
16891 The pragma @code{No_Run_Time} is used to achieve an affect similar
16892 to the use of the "Zero Foot Print" configurable run time, but without
16893 requiring a specially configured run time. The result of using this
16894 pragma, which must be used for all units in a partition, is to restrict
16895 the use of any language features requiring run-time support code. The
16896 preferred usage is to use an appropriately configured run-time that
16897 includes just those features that are to be made accessible.
16898
16899 @node pragma Ravenscar
16900 @section pragma Ravenscar
16901
16902 The pragma @code{Ravenscar} has exactly the same effect as pragma
16903 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16904 is part of the new Ada 2005 standard.
16905
16906 @node pragma Restricted_Run_Time
16907 @section pragma Restricted_Run_Time
16908
16909 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16910 pragma @code{Profile (Restricted)}. The latter usage is
16911 preferred since the Ada 2005 pragma @code{Profile} is intended for
16912 this kind of implementation dependent addition.
16913
16914 @include fdl.texi
16915 @c GNU Free Documentation License
16916
16917 @node Index,,GNU Free Documentation License, Top
16918 @unnumbered Index
16919
16920 @printindex cp
16921
16922 @contents
16923
16924 @bye