OSDN Git Service

Relax constraints on Machine_Attribute argument types:
[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 * Compiler_Version::
226 * Code_Address::
227 * Default_Bit_Order::
228 * Elaborated::
229 * Elab_Body::
230 * Elab_Spec::
231 * Emax::
232 * Enabled::
233 * Enum_Rep::
234 * Enum_Val::
235 * Epsilon::
236 * Fixed_Value::
237 * Has_Access_Values::
238 * Has_Discriminants::
239 * Img::
240 * Integer_Value::
241 * Invalid_Value::
242 * Large::
243 * Machine_Size::
244 * Mantissa::
245 * Max_Interrupt_Priority::
246 * Max_Priority::
247 * Maximum_Alignment::
248 * Mechanism_Code::
249 * Null_Parameter::
250 * Object_Size::
251 * Old::
252 * Passed_By_Reference::
253 * Pool_Address::
254 * Range_Length::
255 * Safe_Emax::
256 * Safe_Large::
257 * Small::
258 * Storage_Unit::
259 * Stub_Type::
260 * Target_Name::
261 * Tick::
262 * To_Address::
263 * Type_Class::
264 * UET_Address::
265 * Unconstrained_Array::
266 * Universal_Literal_String::
267 * Unrestricted_Access::
268 * VADS_Size::
269 * Value_Size::
270 * Wchar_T_Size::
271 * Word_Size::
272
273 The Implementation of Standard I/O
274
275 * Standard I/O Packages::
276 * FORM Strings::
277 * Direct_IO::
278 * Sequential_IO::
279 * Text_IO::
280 * Wide_Text_IO::
281 * Wide_Wide_Text_IO::
282 * Stream_IO::
283 * Text Translation::
284 * Shared Files::
285 * Filenames encoding::
286 * Open Modes::
287 * Operations on C Streams::
288 * Interfacing to C Streams::
289
290 The GNAT Library
291
292 * Ada.Characters.Latin_9 (a-chlat9.ads)::
293 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
294 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
295 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
296 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
297 * Ada.Command_Line.Environment (a-colien.ads)::
298 * Ada.Command_Line.Remove (a-colire.ads)::
299 * Ada.Command_Line.Response_File (a-clrefi.ads)::
300 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
301 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
302 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
303 * Ada.Exceptions.Traceback (a-exctra.ads)::
304 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
305 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
306 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
307 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
308 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
309 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
310 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
311 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
312 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
313 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
314 * GNAT.Altivec (g-altive.ads)::
315 * GNAT.Altivec.Conversions (g-altcon.ads)::
316 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
317 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
318 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
319 * GNAT.Array_Split (g-arrspl.ads)::
320 * GNAT.AWK (g-awk.ads)::
321 * GNAT.Bounded_Buffers (g-boubuf.ads)::
322 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
323 * GNAT.Bubble_Sort (g-bubsor.ads)::
324 * GNAT.Bubble_Sort_A (g-busora.ads)::
325 * GNAT.Bubble_Sort_G (g-busorg.ads)::
326 * GNAT.Byte_Order_Mark (g-byorma.ads)::
327 * GNAT.Byte_Swapping (g-bytswa.ads)::
328 * GNAT.Calendar (g-calend.ads)::
329 * GNAT.Calendar.Time_IO (g-catiio.ads)::
330 * GNAT.Case_Util (g-casuti.ads)::
331 * GNAT.CGI (g-cgi.ads)::
332 * GNAT.CGI.Cookie (g-cgicoo.ads)::
333 * GNAT.CGI.Debug (g-cgideb.ads)::
334 * GNAT.Command_Line (g-comlin.ads)::
335 * GNAT.Compiler_Version (g-comver.ads)::
336 * GNAT.Ctrl_C (g-ctrl_c.ads)::
337 * GNAT.CRC32 (g-crc32.ads)::
338 * GNAT.Current_Exception (g-curexc.ads)::
339 * GNAT.Debug_Pools (g-debpoo.ads)::
340 * GNAT.Debug_Utilities (g-debuti.ads)::
341 * GNAT.Decode_String (g-decstr.ads)::
342 * GNAT.Decode_UTF8_String (g-deutst.ads)::
343 * GNAT.Directory_Operations (g-dirope.ads)::
344 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
345 * GNAT.Dynamic_HTables (g-dynhta.ads)::
346 * GNAT.Dynamic_Tables (g-dyntab.ads)::
347 * GNAT.Encode_String (g-encstr.ads)::
348 * GNAT.Encode_UTF8_String (g-enutst.ads)::
349 * GNAT.Exception_Actions (g-excact.ads)::
350 * GNAT.Exception_Traces (g-exctra.ads)::
351 * GNAT.Exceptions (g-except.ads)::
352 * GNAT.Expect (g-expect.ads)::
353 * GNAT.Float_Control (g-flocon.ads)::
354 * GNAT.Heap_Sort (g-heasor.ads)::
355 * GNAT.Heap_Sort_A (g-hesora.ads)::
356 * GNAT.Heap_Sort_G (g-hesorg.ads)::
357 * GNAT.HTable (g-htable.ads)::
358 * GNAT.IO (g-io.ads)::
359 * GNAT.IO_Aux (g-io_aux.ads)::
360 * GNAT.Lock_Files (g-locfil.ads)::
361 * GNAT.MD5 (g-md5.ads)::
362 * GNAT.Memory_Dump (g-memdum.ads)::
363 * GNAT.Most_Recent_Exception (g-moreex.ads)::
364 * GNAT.OS_Lib (g-os_lib.ads)::
365 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
366 * GNAT.Random_Numbers (g-rannum.ads)::
367 * GNAT.Regexp (g-regexp.ads)::
368 * GNAT.Registry (g-regist.ads)::
369 * GNAT.Regpat (g-regpat.ads)::
370 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
371 * GNAT.Semaphores (g-semaph.ads)::
372 * GNAT.Serial_Communications (g-sercom.ads)::
373 * GNAT.SHA1 (g-sha1.ads)::
374 * GNAT.Signals (g-signal.ads)::
375 * GNAT.Sockets (g-socket.ads)::
376 * GNAT.Source_Info (g-souinf.ads)::
377 * GNAT.Spelling_Checker (g-speche.ads)::
378 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
379 * GNAT.Spitbol.Patterns (g-spipat.ads)::
380 * GNAT.Spitbol (g-spitbo.ads)::
381 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
382 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
383 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
384 * GNAT.Strings (g-string.ads)::
385 * GNAT.String_Split (g-strspl.ads)::
386 * GNAT.Table (g-table.ads)::
387 * GNAT.Task_Lock (g-tasloc.ads)::
388 * GNAT.Threads (g-thread.ads)::
389 * GNAT.Time_Stamp (g-timsta.ads)::
390 * GNAT.Traceback (g-traceb.ads)::
391 * GNAT.Traceback.Symbolic (g-trasym.ads)::
392 * GNAT.UTF_32 (g-utf_32.ads)::
393 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
394 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
395 * GNAT.Wide_String_Split (g-wistsp.ads)::
396 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
397 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
398 * Interfaces.C.Extensions (i-cexten.ads)::
399 * Interfaces.C.Streams (i-cstrea.ads)::
400 * Interfaces.CPP (i-cpp.ads)::
401 * Interfaces.Packed_Decimal (i-pacdec.ads)::
402 * Interfaces.VxWorks (i-vxwork.ads)::
403 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
404 * System.Address_Image (s-addima.ads)::
405 * System.Assertions (s-assert.ads)::
406 * System.Memory (s-memory.ads)::
407 * System.Partition_Interface (s-parint.ads)::
408 * System.Pool_Global (s-pooglo.ads)::
409 * System.Pool_Local (s-pooloc.ads)::
410 * System.Restrictions (s-restri.ads)::
411 * System.Rident (s-rident.ads)::
412 * System.Task_Info (s-tasinf.ads)::
413 * System.Wch_Cnv (s-wchcnv.ads)::
414 * System.Wch_Con (s-wchcon.ads)::
415
416 Text_IO
417
418 * Text_IO Stream Pointer Positioning::
419 * Text_IO Reading and Writing Non-Regular Files::
420 * Get_Immediate::
421 * Treating Text_IO Files as Streams::
422 * Text_IO Extensions::
423 * Text_IO Facilities for Unbounded Strings::
424
425 Wide_Text_IO
426
427 * Wide_Text_IO Stream Pointer Positioning::
428 * Wide_Text_IO Reading and Writing Non-Regular Files::
429
430 Wide_Wide_Text_IO
431
432 * Wide_Wide_Text_IO Stream Pointer Positioning::
433 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
434
435 Interfacing to Other Languages
436
437 * Interfacing to C::
438 * Interfacing to C++::
439 * Interfacing to COBOL::
440 * Interfacing to Fortran::
441 * Interfacing to non-GNAT Ada code::
442
443 Specialized Needs Annexes
444
445 Implementation of Specific Ada Features
446 * Machine Code Insertions::
447 * GNAT Implementation of Tasking::
448 * GNAT Implementation of Shared Passive Packages::
449 * Code Generation for Array Aggregates::
450 * The Size of Discriminated Records with Default Discriminants::
451 * Strict Conformance to the Ada Reference Manual::
452
453 Project File Reference
454
455 Obsolescent Features
456
457 GNU Free Documentation License
458
459 Index
460 @end menu
461
462 @end ifnottex
463
464 @node About This Guide
465 @unnumbered About This Guide
466
467 @noindent
468 This manual contains useful information in writing programs using the
469 @value{EDITION} compiler.  It includes information on implementation dependent
470 characteristics of @value{EDITION}, including all the information required by
471 Annex M of the Ada language standard.
472
473 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
474 Ada 83 compatibility mode.
475 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
476 but you can override with a compiler switch
477 to explicitly specify the language version.
478 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
479 @value{EDITION} User's Guide}, for details on these switches.)
480 Throughout this manual, references to ``Ada'' without a year suffix
481 apply to both the Ada 95 and Ada 2005 versions of the language.
482
483 Ada is designed to be highly portable.
484 In general, a program will have the same effect even when compiled by
485 different compilers on different platforms.
486 However, since Ada is designed to be used in a
487 wide variety of applications, it also contains a number of system
488 dependent features to be used in interfacing to the external world.
489 @cindex Implementation-dependent features
490 @cindex Portability
491
492 Note: Any program that makes use of implementation-dependent features
493 may be non-portable.  You should follow good programming practice and
494 isolate and clearly document any sections of your program that make use
495 of these features in a non-portable manner.
496
497 @ifset PROEDITION
498 For ease of exposition, ``GNAT Pro'' will be referred to simply as
499 ``GNAT'' in the remainder of this document.
500 @end ifset
501
502 @menu
503 * What This Reference Manual Contains::
504 * Conventions::
505 * Related Information::
506 @end menu
507
508 @node What This Reference Manual Contains
509 @unnumberedsec What This Reference Manual Contains
510
511 @noindent
512 This reference manual contains the following chapters:
513
514 @itemize @bullet
515 @item
516 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
517 pragmas, which can be used to extend and enhance the functionality of the
518 compiler.
519
520 @item
521 @ref{Implementation Defined Attributes}, lists GNAT
522 implementation-dependent attributes which can be used to extend and
523 enhance the functionality of the compiler.
524
525 @item
526 @ref{Implementation Advice}, provides information on generally
527 desirable behavior which are not requirements that all compilers must
528 follow since it cannot be provided on all systems, or which may be
529 undesirable on some systems.
530
531 @item
532 @ref{Implementation Defined Characteristics}, provides a guide to
533 minimizing implementation dependent features.
534
535 @item
536 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
537 implemented by GNAT, and how they can be imported into user
538 application programs.
539
540 @item
541 @ref{Representation Clauses and Pragmas}, describes in detail the
542 way that GNAT represents data, and in particular the exact set
543 of representation clauses and pragmas that is accepted.
544
545 @item
546 @ref{Standard Library Routines}, provides a listing of packages and a
547 brief description of the functionality that is provided by Ada's
548 extensive set of standard library routines as implemented by GNAT@.
549
550 @item
551 @ref{The Implementation of Standard I/O}, details how the GNAT
552 implementation of the input-output facilities.
553
554 @item
555 @ref{The GNAT Library}, is a catalog of packages that complement
556 the Ada predefined library.
557
558 @item
559 @ref{Interfacing to Other Languages}, describes how programs
560 written in Ada using GNAT can be interfaced to other programming
561 languages.
562
563 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
564 of the specialized needs annexes.
565
566 @item
567 @ref{Implementation of Specific Ada Features}, discusses issues related
568 to GNAT's implementation of machine code insertions, tasking, and several
569 other features.
570
571 @item
572 @ref{Project File Reference}, presents the syntax and semantics
573 of project files.
574
575 @item
576 @ref{Obsolescent Features} documents implementation dependent features,
577 including pragmas and attributes, which are considered obsolescent, since
578 there are other preferred ways of achieving the same results. These
579 obsolescent forms are retained for backwards compatibility.
580
581 @end itemize
582
583 @cindex Ada 95 Language Reference Manual
584 @cindex Ada 2005 Language Reference Manual
585 @noindent
586 This reference manual assumes a basic familiarity with the Ada 95 language, as
587 described in the International Standard ANSI/ISO/IEC-8652:1995,
588 January 1995.
589 It does not require knowledge of the new features introduced by Ada 2005,
590 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
591 and Amendment 1).
592 Both reference manuals are included in the GNAT documentation
593 package.
594
595 @node Conventions
596 @unnumberedsec Conventions
597 @cindex Conventions, typographical
598 @cindex Typographical conventions
599
600 @noindent
601 Following are examples of the typographical and graphic conventions used
602 in this guide:
603
604 @itemize @bullet
605 @item
606 @code{Functions}, @code{utility program names}, @code{standard names},
607 and @code{classes}.
608
609 @item
610 @code{Option flags}
611
612 @item
613 @file{File names}, @samp{button names}, and @samp{field names}.
614
615 @item
616 @code{Variables}, @env{environment variables}, and @var{metasyntactic
617 variables}.
618
619 @item
620 @emph{Emphasis}.
621
622 @item
623 [optional information or parameters]
624
625 @item
626 Examples are described by text
627 @smallexample
628 and then shown this way.
629 @end smallexample
630 @end itemize
631
632 @noindent
633 Commands that are entered by the user are preceded in this manual by the
634 characters @samp{$ } (dollar sign followed by space).  If your system uses this
635 sequence as a prompt, then the commands will appear exactly as you see them
636 in the manual.  If your system uses some other prompt, then the command will
637 appear with the @samp{$} replaced by whatever prompt character you are using.
638
639 @node Related Information
640 @unnumberedsec Related Information
641 @noindent
642 See the following documents for further information on GNAT:
643
644 @itemize @bullet
645 @item
646 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
647 @value{EDITION} User's Guide}, which provides information on how to use the
648 GNAT compiler system.
649
650 @item
651 @cite{Ada 95 Reference Manual}, which contains all reference
652 material for the Ada 95 programming language.
653
654 @item
655 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
656 of the Ada 95 standard.  The annotations describe
657 detailed aspects of the design decision, and in particular contain useful
658 sections on Ada 83 compatibility.
659
660 @item
661 @cite{Ada 2005 Reference Manual}, which contains all reference
662 material for the Ada 2005 programming language.
663
664 @item
665 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
666 of the Ada 2005 standard.  The annotations describe
667 detailed aspects of the design decision, and in particular contain useful
668 sections on Ada 83 and Ada 95 compatibility.
669
670 @item
671 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
672 which contains specific information on compatibility between GNAT and
673 DEC Ada 83 systems.
674
675 @item
676 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
677 describes in detail the pragmas and attributes provided by the DEC Ada 83
678 compiler system.
679
680 @end itemize
681
682 @node Implementation Defined Pragmas
683 @chapter Implementation Defined Pragmas
684
685 @noindent
686 Ada defines a set of pragmas that can be used to supply additional
687 information to the compiler.  These language defined pragmas are
688 implemented in GNAT and work as described in the Ada Reference Manual.
689
690 In addition, Ada allows implementations to define additional pragmas
691 whose meaning is defined by the implementation.  GNAT provides a number
692 of these implementation-defined pragmas, which can be used to extend
693 and enhance the functionality of the compiler.  This section of the GNAT
694 Reference Manual describes these additional pragmas.
695
696 Note that any program using these pragmas might not be portable to other
697 compilers (although GNAT implements this set of pragmas on all
698 platforms).  Therefore if portability to other compilers is an important
699 consideration, the use of these pragmas should be minimized.
700
701 @menu
702 * Pragma Abort_Defer::
703 * Pragma Ada_83::
704 * Pragma Ada_95::
705 * Pragma Ada_05::
706 * Pragma Ada_2005::
707 * Pragma Annotate::
708 * Pragma Assert::
709 * Pragma Assume_No_Invalid_Values::
710 * Pragma Ast_Entry::
711 * Pragma C_Pass_By_Copy::
712 * Pragma Check::
713 * Pragma Check_Name::
714 * Pragma Check_Policy::
715 * Pragma Comment::
716 * Pragma Common_Object::
717 * Pragma Compile_Time_Error::
718 * Pragma Compile_Time_Warning::
719 * Pragma Complete_Representation::
720 * Pragma Complex_Representation::
721 * Pragma Component_Alignment::
722 * Pragma Convention_Identifier::
723 * Pragma CPP_Class::
724 * Pragma CPP_Constructor::
725 * Pragma CPP_Virtual::
726 * Pragma CPP_Vtable::
727 * Pragma Debug::
728 * Pragma Debug_Policy::
729 * Pragma Detect_Blocking::
730 * Pragma Elaboration_Checks::
731 * Pragma Eliminate::
732 * Pragma Export_Exception::
733 * Pragma Export_Function::
734 * Pragma Export_Object::
735 * Pragma Export_Procedure::
736 * Pragma Export_Value::
737 * Pragma Export_Valued_Procedure::
738 * Pragma Extend_System::
739 * Pragma External::
740 * Pragma External_Name_Casing::
741 * Pragma Fast_Math::
742 * Pragma Favor_Top_Level::
743 * Pragma Finalize_Storage_Only::
744 * Pragma Float_Representation::
745 * Pragma Ident::
746 * Pragma Implemented_By_Entry::
747 * Pragma Implicit_Packing::
748 * Pragma Import_Exception::
749 * Pragma Import_Function::
750 * Pragma Import_Object::
751 * Pragma Import_Procedure::
752 * Pragma Import_Valued_Procedure::
753 * Pragma Initialize_Scalars::
754 * Pragma Inline_Always::
755 * Pragma Inline_Generic::
756 * Pragma Interface::
757 * Pragma Interface_Name::
758 * Pragma Interrupt_Handler::
759 * Pragma Interrupt_State::
760 * Pragma Keep_Names::
761 * Pragma License::
762 * Pragma Link_With::
763 * Pragma Linker_Alias::
764 * Pragma Linker_Constructor::
765 * Pragma Linker_Destructor::
766 * Pragma Linker_Section::
767 * Pragma Long_Float::
768 * Pragma Machine_Attribute::
769 * Pragma Main::
770 * Pragma Main_Storage::
771 * Pragma No_Body::
772 * Pragma No_Return::
773 * Pragma No_Strict_Aliasing::
774 * Pragma Normalize_Scalars::
775 * Pragma Obsolescent::
776 * Pragma Optimize_Alignment::
777 * Pragma Passive::
778 * Pragma Persistent_BSS::
779 * Pragma Polling::
780 * Pragma Postcondition::
781 * Pragma Precondition::
782 * Pragma Profile (Ravenscar)::
783 * Pragma Profile (Restricted)::
784 * Pragma Psect_Object::
785 * Pragma Pure_Function::
786 * Pragma Restriction_Warnings::
787 * Pragma Shared::
788 * Pragma Source_File_Name::
789 * Pragma Source_File_Name_Project::
790 * Pragma Source_Reference::
791 * Pragma Stream_Convert::
792 * Pragma Style_Checks::
793 * Pragma Subtitle::
794 * Pragma Suppress::
795 * Pragma Suppress_All::
796 * Pragma Suppress_Exception_Locations::
797 * Pragma Suppress_Initialization::
798 * Pragma Task_Info::
799 * Pragma Task_Name::
800 * Pragma Task_Storage::
801 * Pragma Thread_Local_Storage::
802 * Pragma Time_Slice::
803 * Pragma Title::
804 * Pragma Unchecked_Union::
805 * Pragma Unimplemented_Unit::
806 * Pragma Universal_Aliasing ::
807 * Pragma Universal_Data::
808 * Pragma Unmodified::
809 * Pragma Unreferenced::
810 * Pragma Unreferenced_Objects::
811 * Pragma Unreserve_All_Interrupts::
812 * Pragma Unsuppress::
813 * Pragma Use_VADS_Size::
814 * Pragma Validity_Checks::
815 * Pragma Volatile::
816 * Pragma Warnings::
817 * Pragma Weak_External::
818 * Pragma Wide_Character_Encoding::
819 @end menu
820
821 @node Pragma Abort_Defer
822 @unnumberedsec Pragma Abort_Defer
823 @findex Abort_Defer
824 @cindex Deferring aborts
825 @noindent
826 Syntax:
827 @smallexample
828 pragma Abort_Defer;
829 @end smallexample
830
831 @noindent
832 This pragma must appear at the start of the statement sequence of a
833 handled sequence of statements (right after the @code{begin}).  It has
834 the effect of deferring aborts for the sequence of statements (but not
835 for the declarations or handlers, if any, associated with this statement
836 sequence).
837
838 @node Pragma Ada_83
839 @unnumberedsec Pragma Ada_83
840 @findex Ada_83
841 @noindent
842 Syntax:
843 @smallexample @c ada
844 pragma Ada_83;
845 @end smallexample
846
847 @noindent
848 A configuration pragma that establishes Ada 83 mode for the unit to
849 which it applies, regardless of the mode set by the command line
850 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
851 the syntax and semantics of Ada 83, as defined in the original Ada
852 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
853 and Ada 2005 are not recognized, optional package bodies are allowed,
854 and generics may name types with unknown discriminants without using
855 the @code{(<>)} notation.  In addition, some but not all of the additional
856 restrictions of Ada 83 are enforced.
857
858 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
859 Ada 83 code to be compiled and adapted to GNAT with less effort.
860 Secondly, it aids in keeping code backwards compatible with Ada 83.
861 However, there is no guarantee that code that is processed correctly
862 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
863 83 compiler, since GNAT does not enforce all the additional checks
864 required by Ada 83.
865
866 @node Pragma Ada_95
867 @unnumberedsec Pragma Ada_95
868 @findex Ada_95
869 @noindent
870 Syntax:
871 @smallexample @c ada
872 pragma Ada_95;
873 @end smallexample
874
875 @noindent
876 A configuration pragma that establishes Ada 95 mode for the unit to which
877 it applies, regardless of the mode set by the command line switches.
878 This mode is set automatically for the @code{Ada} and @code{System}
879 packages and their children, so you need not specify it in these
880 contexts.  This pragma is useful when writing a reusable component that
881 itself uses Ada 95 features, but which is intended to be usable from
882 either Ada 83 or Ada 95 programs.
883
884 @node Pragma Ada_05
885 @unnumberedsec Pragma Ada_05
886 @findex Ada_05
887 @noindent
888 Syntax:
889 @smallexample @c ada
890 pragma Ada_05;
891 @end smallexample
892
893 @noindent
894 A configuration pragma that establishes Ada 2005 mode for the unit to which
895 it applies, regardless of the mode set by the command line switches.
896 This mode is set automatically for the @code{Ada} and @code{System}
897 packages and their children, so you need not specify it in these
898 contexts.  This pragma is useful when writing a reusable component that
899 itself uses Ada 2005 features, but which is intended to be usable from
900 either Ada 83 or Ada 95 programs.
901
902 @node Pragma Ada_2005
903 @unnumberedsec Pragma Ada_2005
904 @findex Ada_2005
905 @noindent
906 Syntax:
907 @smallexample @c ada
908 pragma Ada_2005;
909 @end smallexample
910
911 @noindent
912 This configuration pragma is a synonym for pragma Ada_05 and has the
913 same syntax and effect.
914
915 @node Pragma Annotate
916 @unnumberedsec Pragma Annotate
917 @findex Annotate
918 @noindent
919 Syntax:
920 @smallexample @c ada
921 pragma Annotate (IDENTIFIER @{, ARG@});
922
923 ARG ::= NAME | EXPRESSION
924 @end smallexample
925
926 @noindent
927 This pragma is used to annotate programs.  @var{identifier} identifies
928 the type of annotation.  GNAT verifies that it is an identifier, but does
929 not otherwise analyze it.  The @var{arg} argument
930 can be either a string literal or an
931 expression.  String literals are assumed to be of type
932 @code{Standard.String}.  Names of entities are simply analyzed as entity
933 names.  All other expressions are analyzed as expressions, and must be
934 unambiguous.
935
936 The analyzed pragma is retained in the tree, but not otherwise processed
937 by any part of the GNAT compiler.  This pragma is intended for use by
938 external tools, including ASIS@.
939
940 @node Pragma Assert
941 @unnumberedsec Pragma Assert
942 @findex Assert
943 @noindent
944 Syntax:
945 @smallexample @c ada
946 pragma Assert (
947   boolean_EXPRESSION
948   [, string_EXPRESSION]);
949 @end smallexample
950
951 @noindent
952 The effect of this pragma depends on whether the corresponding command
953 line switch is set to activate assertions.  The pragma expands into code
954 equivalent to the following:
955
956 @smallexample @c ada
957 if assertions-enabled then
958    if not boolean_EXPRESSION then
959       System.Assertions.Raise_Assert_Failure
960         (string_EXPRESSION);
961    end if;
962 end if;
963 @end smallexample
964
965 @noindent
966 The string argument, if given, is the message that will be associated
967 with the exception occurrence if the exception is raised.  If no second
968 argument is given, the default message is @samp{@var{file}:@var{nnn}},
969 where @var{file} is the name of the source file containing the assert,
970 and @var{nnn} is the line number of the assert.  A pragma is not a
971 statement, so if a statement sequence contains nothing but a pragma
972 assert, then a null statement is required in addition, as in:
973
974 @smallexample @c ada
975 @dots{}
976 if J > 3 then
977    pragma Assert (K > 3, "Bad value for K");
978    null;
979 end if;
980 @end smallexample
981
982 @noindent
983 Note that, as with the @code{if} statement to which it is equivalent, the
984 type of the expression is either @code{Standard.Boolean}, or any type derived
985 from this standard type.
986
987 If assertions are disabled (switch @option{-gnata} not used), then there
988 is no run-time effect (and in particular, any side effects from the
989 expression will not occur at run time).  (The expression is still
990 analyzed at compile time, and may cause types to be frozen if they are
991 mentioned here for the first time).
992
993 If assertions are enabled, then the given expression is tested, and if
994 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
995 which results in the raising of @code{Assert_Failure} with the given message.
996
997 You should generally avoid side effects in the expression arguments of
998 this pragma, because these side effects will turn on and off with the
999 setting of the assertions mode, resulting in assertions that have an
1000 effect on the program.  However, the expressions are analyzed for
1001 semantic correctness whether or not assertions are enabled, so turning
1002 assertions on and off cannot affect the legality of a program.
1003
1004 @node Pragma Assume_No_Invalid_Values
1005 @unnumberedsec Pragma Assume_No_Invalid_Values
1006 @findex Assume_No_Invalid_Values
1007 @cindex Invalid representations
1008 @cindex Invalid values
1009 @noindent
1010 Syntax:
1011 @smallexample @c ada
1012 pragma Assume_No_Invalid_Values (On | Off);
1013 @end smallexample
1014
1015 @noindent
1016 This is a configuration pragma that controls the assumptions made by the
1017 compiler about the occurrence of invalid representations (invalid values)
1018 in the code.
1019
1020 The default behavior (corresponding to an Off argument for this pragma), is
1021 to assume that values may in general be invalid unless the compiler can
1022 prove they are valid. Consider the following example:
1023
1024 @smallexample @c ada
1025 V1 : Integer range 1 .. 10;
1026 V2 : Integer range 11 .. 20;
1027 ...
1028 for J in V2 .. V1 loop
1029    ...
1030 end loop;
1031 @end smallexample
1032
1033 @noindent
1034 if V1 and V2 have valid values, then the loop is known at compile
1035 time not to execute since the lower bound must be greater than the
1036 upper bound. However in default mode, no such assumption is made,
1037 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1038 is given, the compiler will assume that any occurrence of a variable
1039 other than in an explicit @code{'Valid} test always has a valid
1040 value, and the loop above will be optimized away.
1041
1042 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1043 you know your code is free of uninitialized variables and other
1044 possible sources of invalid representations, and may result in
1045 more efficient code. A program that accesses an invalid representation
1046 with this pragma in effect is erroneous, so no guarantees can be made
1047 about its behavior.
1048
1049 It is peculiar though permissible to use this pragma in conjunction
1050 with validity checking (-gnatVa). In such cases, accessing invalid
1051 values will generally give an exception, though formally the program
1052 is erroneous so there are no guarantees that this will always be the
1053 case, and it is recommended that these two options not be used together.
1054
1055 @node Pragma Ast_Entry
1056 @unnumberedsec Pragma Ast_Entry
1057 @cindex OpenVMS
1058 @findex Ast_Entry
1059 @noindent
1060 Syntax:
1061 @smallexample @c ada
1062 pragma AST_Entry (entry_IDENTIFIER);
1063 @end smallexample
1064
1065 @noindent
1066 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1067 argument is the simple name of a single entry; at most one @code{AST_Entry}
1068 pragma is allowed for any given entry.  This pragma must be used in
1069 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1070 the entry declaration and in the same task type specification or single task
1071 as the entry to which it applies.  This pragma specifies that the given entry
1072 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1073 resulting from an OpenVMS system service call.  The pragma does not affect
1074 normal use of the entry.  For further details on this pragma, see the
1075 DEC Ada Language Reference Manual, section 9.12a.
1076
1077 @node Pragma C_Pass_By_Copy
1078 @unnumberedsec Pragma C_Pass_By_Copy
1079 @cindex Passing by copy
1080 @findex C_Pass_By_Copy
1081 @noindent
1082 Syntax:
1083 @smallexample @c ada
1084 pragma C_Pass_By_Copy
1085   ([Max_Size =>] static_integer_EXPRESSION);
1086 @end smallexample
1087
1088 @noindent
1089 Normally the default mechanism for passing C convention records to C
1090 convention subprograms is to pass them by reference, as suggested by RM
1091 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1092 this default, by requiring that record formal parameters be passed by
1093 copy if all of the following conditions are met:
1094
1095 @itemize @bullet
1096 @item
1097 The size of the record type does not exceed the value specified for
1098 @code{Max_Size}.
1099 @item
1100 The record type has @code{Convention C}.
1101 @item
1102 The formal parameter has this record type, and the subprogram has a
1103 foreign (non-Ada) convention.
1104 @end itemize
1105
1106 @noindent
1107 If these conditions are met the argument is passed by copy, i.e.@: in a
1108 manner consistent with what C expects if the corresponding formal in the
1109 C prototype is a struct (rather than a pointer to a struct).
1110
1111 You can also pass records by copy by specifying the convention
1112 @code{C_Pass_By_Copy} for the record type, or by using the extended
1113 @code{Import} and @code{Export} pragmas, which allow specification of
1114 passing mechanisms on a parameter by parameter basis.
1115
1116 @node Pragma Check
1117 @unnumberedsec Pragma Check
1118 @cindex Assertions
1119 @cindex Named assertions
1120 @findex Check
1121 @noindent
1122 Syntax:
1123 @smallexample @c ada
1124 pragma Check (
1125      [Name    =>] Identifier,
1126      [Check   =>] Boolean_EXPRESSION
1127   [, [Message =>] string_EXPRESSION] );
1128 @end smallexample
1129
1130 @noindent
1131 This pragma is similar to the predefined pragma @code{Assert} except that an
1132 extra identifier argument is present. In conjunction with pragma
1133 @code{Check_Policy}, this can be used to define groups of assertions that can
1134 be independently controlled. The identifier @code{Assertion} is special, it
1135 refers to the normal set of pragma @code{Assert} statements. The identifiers
1136 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1137 names, so these three names would normally not be used directly in a pragma
1138 @code{Check}.
1139
1140 Checks introduced by this pragma are normally deactivated by default. They can
1141 be activated either by the command line option @option{-gnata}, which turns on
1142 all checks, or individually controlled using pragma @code{Check_Policy}.
1143
1144 @node Pragma Check_Name
1145 @unnumberedsec Pragma Check_Name
1146 @cindex Defining check names
1147 @cindex Check names, defining
1148 @findex Check_Name
1149 @noindent
1150 Syntax:
1151 @smallexample @c ada
1152 pragma Check_Name (check_name_IDENTIFIER);
1153 @end smallexample
1154
1155 @noindent
1156 This is a configuration pragma that defines a new implementation
1157 defined check name (unless IDENTIFIER matches one of the predefined
1158 check names, in which case the pragma has no effect). Check names
1159 are global to a partition, so if two or more configuration pragmas
1160 are present in a partition mentioning the same name, only one new
1161 check name is introduced.
1162
1163 An implementation defined check name introduced with this pragma may
1164 be used in only three contexts: @code{pragma Suppress},
1165 @code{pragma Unsuppress},
1166 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1167 any of these three cases, the check name must be visible. A check
1168 name is visible if it is in the configuration pragmas applying to
1169 the current unit, or if it appears at the start of any unit that
1170 is part of the dependency set of the current unit (e.g., units that
1171 are mentioned in @code{with} clauses).
1172
1173 @node Pragma Check_Policy
1174 @unnumberedsec Pragma Check_Policy
1175 @cindex Controlling assertions
1176 @cindex Assertions, control
1177 @cindex Check pragma control
1178 @cindex Named assertions
1179 @findex Check
1180 @noindent
1181 Syntax:
1182 @smallexample @c ada
1183 pragma Check_Policy
1184  ([Name   =>] Identifier,
1185   [Policy =>] POLICY_IDENTIFIER);
1186
1187 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1188 @end smallexample
1189
1190 @noindent
1191 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1192 except that it controls sets of named assertions introduced using the
1193 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1194 @code{Assertion_Policy}) can be used within a declarative part, in which case
1195 it controls the status to the end of the corresponding construct (in a manner
1196 identical to pragma @code{Suppress)}.
1197
1198 The identifier given as the first argument corresponds to a name used in
1199 associated @code{Check} pragmas. For example, if the pragma:
1200
1201 @smallexample @c ada
1202 pragma Check_Policy (Critical_Error, Off);
1203 @end smallexample
1204
1205 @noindent
1206 is given, then subsequent @code{Check} pragmas whose first argument is also
1207 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1208 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1209 @code{Check_Policy} with this identifier is similar to the normal
1210 @code{Assertion_Policy} pragma except that it can appear within a
1211 declarative part).
1212
1213 The special identifiers @code{Precondition} and @code{Postcondition} control
1214 the status of preconditions and postconditions. If a @code{Precondition} pragma
1215 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1216 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1217 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1218 are recognized.
1219
1220 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1221 to turn on corresponding checks. The default for a set of checks for which no
1222 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1223 @option{-gnata} is given, which turns on all checks by default.
1224
1225 The check policy settings @code{Check} and @code{Ignore} are also recognized
1226 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1227 compatibility with the standard @code{Assertion_Policy} pragma.
1228
1229 @node Pragma Comment
1230 @unnumberedsec Pragma Comment
1231 @findex Comment
1232 @noindent
1233 Syntax:
1234
1235 @smallexample @c ada
1236 pragma Comment (static_string_EXPRESSION);
1237 @end smallexample
1238
1239 @noindent
1240 This is almost identical in effect to pragma @code{Ident}.  It allows the
1241 placement of a comment into the object file and hence into the
1242 executable file if the operating system permits such usage.  The
1243 difference is that @code{Comment}, unlike @code{Ident}, has
1244 no limitations on placement of the pragma (it can be placed
1245 anywhere in the main source unit), and if more than one pragma
1246 is used, all comments are retained.
1247
1248 @node Pragma Common_Object
1249 @unnumberedsec Pragma Common_Object
1250 @findex Common_Object
1251 @noindent
1252 Syntax:
1253
1254 @smallexample @c ada
1255 pragma Common_Object (
1256      [Internal =>] LOCAL_NAME
1257   [, [External =>] EXTERNAL_SYMBOL]
1258   [, [Size     =>] EXTERNAL_SYMBOL] );
1259
1260 EXTERNAL_SYMBOL ::=
1261   IDENTIFIER
1262 | static_string_EXPRESSION
1263 @end smallexample
1264
1265 @noindent
1266 This pragma enables the shared use of variables stored in overlaid
1267 linker areas corresponding to the use of @code{COMMON}
1268 in Fortran.  The single
1269 object @var{LOCAL_NAME} is assigned to the area designated by
1270 the @var{External} argument.
1271 You may define a record to correspond to a series
1272 of fields.  The @var{Size} argument
1273 is syntax checked in GNAT, but otherwise ignored.
1274
1275 @code{Common_Object} is not supported on all platforms.  If no
1276 support is available, then the code generator will issue a message
1277 indicating that the necessary attribute for implementation of this
1278 pragma is not available.
1279
1280 @node Pragma Compile_Time_Error
1281 @unnumberedsec Pragma Compile_Time_Error
1282 @findex Compile_Time_Error
1283 @noindent
1284 Syntax:
1285
1286 @smallexample @c ada
1287 pragma Compile_Time_Error
1288          (boolean_EXPRESSION, static_string_EXPRESSION);
1289 @end smallexample
1290
1291 @noindent
1292 This pragma can be used to generate additional compile time
1293 error messages. It
1294 is particularly useful in generics, where errors can be issued for
1295 specific problematic instantiations. The first parameter is a boolean
1296 expression. The pragma is effective only if the value of this expression
1297 is known at compile time, and has the value True. The set of expressions
1298 whose values are known at compile time includes all static boolean
1299 expressions, and also other values which the compiler can determine
1300 at compile time (e.g., the size of a record type set by an explicit
1301 size representation clause, or the value of a variable which was
1302 initialized to a constant and is known not to have been modified).
1303 If these conditions are met, an error message is generated using
1304 the value given as the second argument. This string value may contain
1305 embedded ASCII.LF characters to break the message into multiple lines.
1306
1307 @node Pragma Compile_Time_Warning
1308 @unnumberedsec Pragma Compile_Time_Warning
1309 @findex Compile_Time_Warning
1310 @noindent
1311 Syntax:
1312
1313 @smallexample @c ada
1314 pragma Compile_Time_Warning
1315          (boolean_EXPRESSION, static_string_EXPRESSION);
1316 @end smallexample
1317
1318 @noindent
1319 Same as pragma Compile_Time_Error, except a warning is issued instead
1320 of an error message. Note that if this pragma is used in a package that
1321 is with'ed by a client, the client will get the warning even though it
1322 is issued by a with'ed package (normally warnings in with'ed units are
1323 suppressed, but this is a special exception to that rule).
1324
1325 One typical use is within a generic where compile time known characteristics
1326 of formal parameters are tested, and warnings given appropriately. Another use
1327 with a first parameter of True is to warn a client about use of a package,
1328 for example that it is not fully implemented.
1329
1330 @node Pragma Complete_Representation
1331 @unnumberedsec Pragma Complete_Representation
1332 @findex Complete_Representation
1333 @noindent
1334 Syntax:
1335
1336 @smallexample @c ada
1337 pragma Complete_Representation;
1338 @end smallexample
1339
1340 @noindent
1341 This pragma must appear immediately within a record representation
1342 clause. Typical placements are before the first component clause
1343 or after the last component clause. The effect is to give an error
1344 message if any component is missing a component clause. This pragma
1345 may be used to ensure that a record representation clause is
1346 complete, and that this invariant is maintained if fields are
1347 added to the record in the future.
1348
1349 @node Pragma Complex_Representation
1350 @unnumberedsec Pragma Complex_Representation
1351 @findex Complex_Representation
1352 @noindent
1353 Syntax:
1354
1355 @smallexample @c ada
1356 pragma Complex_Representation
1357         ([Entity =>] LOCAL_NAME);
1358 @end smallexample
1359
1360 @noindent
1361 The @var{Entity} argument must be the name of a record type which has
1362 two fields of the same floating-point type.  The effect of this pragma is
1363 to force gcc to use the special internal complex representation form for
1364 this record, which may be more efficient.  Note that this may result in
1365 the code for this type not conforming to standard ABI (application
1366 binary interface) requirements for the handling of record types.  For
1367 example, in some environments, there is a requirement for passing
1368 records by pointer, and the use of this pragma may result in passing
1369 this type in floating-point registers.
1370
1371 @node Pragma Component_Alignment
1372 @unnumberedsec Pragma Component_Alignment
1373 @cindex Alignments of components
1374 @findex Component_Alignment
1375 @noindent
1376 Syntax:
1377
1378 @smallexample @c ada
1379 pragma Component_Alignment (
1380      [Form =>] ALIGNMENT_CHOICE
1381   [, [Name =>] type_LOCAL_NAME]);
1382
1383 ALIGNMENT_CHOICE ::=
1384   Component_Size
1385 | Component_Size_4
1386 | Storage_Unit
1387 | Default
1388 @end smallexample
1389
1390 @noindent
1391 Specifies the alignment of components in array or record types.
1392 The meaning of the @var{Form} argument is as follows:
1393
1394 @table @code
1395 @findex Component_Size
1396 @item Component_Size
1397 Aligns scalar components and subcomponents of the array or record type
1398 on boundaries appropriate to their inherent size (naturally
1399 aligned).  For example, 1-byte components are aligned on byte boundaries,
1400 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1401 integer components are aligned on 4-byte boundaries and so on.  These
1402 alignment rules correspond to the normal rules for C compilers on all
1403 machines except the VAX@.
1404
1405 @findex Component_Size_4
1406 @item Component_Size_4
1407 Naturally aligns components with a size of four or fewer
1408 bytes.  Components that are larger than 4 bytes are placed on the next
1409 4-byte boundary.
1410
1411 @findex Storage_Unit
1412 @item Storage_Unit
1413 Specifies that array or record components are byte aligned, i.e.@:
1414 aligned on boundaries determined by the value of the constant
1415 @code{System.Storage_Unit}.
1416
1417 @cindex OpenVMS
1418 @item Default
1419 Specifies that array or record components are aligned on default
1420 boundaries, appropriate to the underlying hardware or operating system or
1421 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1422 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1423 the @code{Default} choice is the same as @code{Component_Size} (natural
1424 alignment).
1425 @end table
1426
1427 @noindent
1428 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1429 refer to a local record or array type, and the specified alignment
1430 choice applies to the specified type.  The use of
1431 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1432 @code{Component_Alignment} pragma to be ignored.  The use of
1433 @code{Component_Alignment} together with a record representation clause
1434 is only effective for fields not specified by the representation clause.
1435
1436 If the @code{Name} parameter is absent, the pragma can be used as either
1437 a configuration pragma, in which case it applies to one or more units in
1438 accordance with the normal rules for configuration pragmas, or it can be
1439 used within a declarative part, in which case it applies to types that
1440 are declared within this declarative part, or within any nested scope
1441 within this declarative part.  In either case it specifies the alignment
1442 to be applied to any record or array type which has otherwise standard
1443 representation.
1444
1445 If the alignment for a record or array type is not specified (using
1446 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1447 clause), the GNAT uses the default alignment as described previously.
1448
1449 @node Pragma Convention_Identifier
1450 @unnumberedsec Pragma Convention_Identifier
1451 @findex Convention_Identifier
1452 @cindex Conventions, synonyms
1453 @noindent
1454 Syntax:
1455
1456 @smallexample @c ada
1457 pragma Convention_Identifier (
1458          [Name =>]       IDENTIFIER,
1459          [Convention =>] convention_IDENTIFIER);
1460 @end smallexample
1461
1462 @noindent
1463 This pragma provides a mechanism for supplying synonyms for existing
1464 convention identifiers. The @code{Name} identifier can subsequently
1465 be used as a synonym for the given convention in other pragmas (including
1466 for example pragma @code{Import} or another @code{Convention_Identifier}
1467 pragma). As an example of the use of this, suppose you had legacy code
1468 which used Fortran77 as the identifier for Fortran. Then the pragma:
1469
1470 @smallexample @c ada
1471 pragma Convention_Identifier (Fortran77, Fortran);
1472 @end smallexample
1473
1474 @noindent
1475 would allow the use of the convention identifier @code{Fortran77} in
1476 subsequent code, avoiding the need to modify the sources. As another
1477 example, you could use this to parametrize convention requirements
1478 according to systems. Suppose you needed to use @code{Stdcall} on
1479 windows systems, and @code{C} on some other system, then you could
1480 define a convention identifier @code{Library} and use a single
1481 @code{Convention_Identifier} pragma to specify which convention
1482 would be used system-wide.
1483
1484 @node Pragma CPP_Class
1485 @unnumberedsec Pragma CPP_Class
1486 @findex CPP_Class
1487 @cindex Interfacing with C++
1488 @noindent
1489 Syntax:
1490
1491 @smallexample @c ada
1492 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1493 @end smallexample
1494
1495 @noindent
1496 The argument denotes an entity in the current declarative region that is
1497 declared as a tagged record type. It indicates that the type corresponds
1498 to an externally declared C++ class type, and is to be laid out the same
1499 way that C++ would lay out the type.
1500
1501 Types for which @code{CPP_Class} is specified do not have assignment or
1502 equality operators defined (such operations can be imported or declared
1503 as subprograms as required). Initialization is allowed only by constructor
1504 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1505 limited if not explicitly declared as limited or derived from a limited
1506 type, and an error is issued in that case.
1507
1508 Pragma @code{CPP_Class} is intended primarily for automatic generation
1509 using an automatic binding generator tool.
1510 See @ref{Interfacing to C++} for related information.
1511
1512 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1513 for backward compatibility but its functionality is available
1514 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1515
1516 @node Pragma CPP_Constructor
1517 @unnumberedsec Pragma CPP_Constructor
1518 @cindex Interfacing with C++
1519 @findex CPP_Constructor
1520 @noindent
1521 Syntax:
1522
1523 @smallexample @c ada
1524 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1525   [, [External_Name =>] static_string_EXPRESSION ]
1526   [, [Link_Name     =>] static_string_EXPRESSION ]);
1527 @end smallexample
1528
1529 @noindent
1530 This pragma identifies an imported function (imported in the usual way
1531 with pragma @code{Import}) as corresponding to a C++ constructor. If
1532 @code{External_Name} and @code{Link_Name} are not specified then the
1533 @code{Entity} argument is a name that must have been previously mentioned
1534 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1535 must be of one of the following forms:
1536
1537 @itemize @bullet
1538 @item
1539 @code{function @var{Fname} return @var{T}'Class}
1540
1541 @item
1542 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1543 @end itemize
1544
1545 @noindent
1546 where @var{T} is a tagged limited type imported from C++ with pragma
1547 @code{Import} and @code{Convention} = @code{CPP}.
1548
1549 The first form is the default constructor, used when an object of type
1550 @var{T} is created on the Ada side with no explicit constructor.  The
1551 second form covers all the non-default constructors of the type. See
1552 the GNAT users guide for details.
1553
1554 If no constructors are imported, it is impossible to create any objects
1555 on the Ada side and the type is implicitly declared abstract.
1556
1557 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1558 using an automatic binding generator tool.
1559 See @ref{Interfacing to C++} for more related information.
1560
1561 @node Pragma CPP_Virtual
1562 @unnumberedsec Pragma CPP_Virtual
1563 @cindex Interfacing to C++
1564 @findex CPP_Virtual
1565 @noindent
1566 This pragma is now obsolete has has no effect because GNAT generates
1567 the same object layout than the G++ compiler.
1568
1569 See @ref{Interfacing to C++} for related information.
1570
1571 @node Pragma CPP_Vtable
1572 @unnumberedsec Pragma CPP_Vtable
1573 @cindex Interfacing with C++
1574 @findex CPP_Vtable
1575 @noindent
1576 This pragma is now obsolete has has no effect because GNAT generates
1577 the same object layout than the G++ compiler.
1578
1579 See @ref{Interfacing to C++} for related information.
1580
1581 @node Pragma Debug
1582 @unnumberedsec Pragma Debug
1583 @findex Debug
1584 @noindent
1585 Syntax:
1586
1587 @smallexample @c ada
1588 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1589
1590 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1591   PROCEDURE_NAME
1592 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1593 @end smallexample
1594
1595 @noindent
1596 The procedure call argument has the syntactic form of an expression, meeting
1597 the syntactic requirements for pragmas.
1598
1599 If debug pragmas are not enabled or if the condition is present and evaluates
1600 to False, this pragma has no effect. If debug pragmas are enabled, the
1601 semantics of the pragma is exactly equivalent to the procedure call statement
1602 corresponding to the argument with a terminating semicolon. Pragmas are
1603 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1604 intersperse calls to debug procedures in the middle of declarations. Debug
1605 pragmas can be enabled either by use of the command line switch @option{-gnata}
1606 or by use of the configuration pragma @code{Debug_Policy}.
1607
1608 @node Pragma Debug_Policy
1609 @unnumberedsec Pragma Debug_Policy
1610 @findex Debug_Policy
1611 @noindent
1612 Syntax:
1613
1614 @smallexample @c ada
1615 pragma Debug_Policy (CHECK | IGNORE);
1616 @end smallexample
1617
1618 @noindent
1619 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1620 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1621 This pragma overrides the effect of the @option{-gnata} switch on the
1622 command line.
1623
1624 @node Pragma Detect_Blocking
1625 @unnumberedsec Pragma Detect_Blocking
1626 @findex Detect_Blocking
1627 @noindent
1628 Syntax:
1629
1630 @smallexample @c ada
1631 pragma Detect_Blocking;
1632 @end smallexample
1633
1634 @noindent
1635 This is a configuration pragma that forces the detection of potentially
1636 blocking operations within a protected operation, and to raise Program_Error
1637 if that happens.
1638
1639 @node Pragma Elaboration_Checks
1640 @unnumberedsec Pragma Elaboration_Checks
1641 @cindex Elaboration control
1642 @findex Elaboration_Checks
1643 @noindent
1644 Syntax:
1645
1646 @smallexample @c ada
1647 pragma Elaboration_Checks (Dynamic | Static);
1648 @end smallexample
1649
1650 @noindent
1651 This is a configuration pragma that provides control over the
1652 elaboration model used by the compilation affected by the
1653 pragma.  If the parameter is @code{Dynamic},
1654 then the dynamic elaboration
1655 model described in the Ada Reference Manual is used, as though
1656 the @option{-gnatE} switch had been specified on the command
1657 line.  If the parameter is @code{Static}, then the default GNAT static
1658 model is used.  This configuration pragma overrides the setting
1659 of the command line.  For full details on the elaboration models
1660 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1661 gnat_ugn, @value{EDITION} User's Guide}.
1662
1663 @node Pragma Eliminate
1664 @unnumberedsec Pragma Eliminate
1665 @cindex Elimination of unused subprograms
1666 @findex Eliminate
1667 @noindent
1668 Syntax:
1669
1670 @smallexample @c ada
1671 pragma Eliminate (
1672     [Unit_Name =>] IDENTIFIER |
1673                    SELECTED_COMPONENT);
1674
1675 pragma Eliminate (
1676     [Unit_Name       =>]  IDENTIFIER |
1677                           SELECTED_COMPONENT,
1678     [Entity          =>]  IDENTIFIER |
1679                           SELECTED_COMPONENT |
1680                           STRING_LITERAL
1681     [,OVERLOADING_RESOLUTION]);
1682
1683 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1684                            SOURCE_LOCATION
1685
1686 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1687                                       FUNCTION_PROFILE
1688
1689 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1690
1691 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1692                       Result_Type => result_SUBTYPE_NAME]
1693
1694 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1695 SUBTYPE_NAME    ::= STRING_VALUE
1696
1697 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1698 SOURCE_TRACE    ::= STRING_VALUE
1699
1700 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1701 @end smallexample
1702
1703 @noindent
1704 This pragma indicates that the given entity is not used outside the
1705 compilation unit it is defined in. The entity must be an explicitly declared
1706 subprogram; this includes  generic subprogram instances and
1707 subprograms declared in generic package instances.
1708
1709 If the entity to be eliminated is a library level subprogram, then
1710 the first form of pragma @code{Eliminate} is used with only a single argument.
1711 In this form, the @code{Unit_Name} argument specifies the name of the
1712 library  level unit to be eliminated.
1713
1714 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1715 are required. If item is an entity of a library package, then the first
1716 argument specifies the unit name, and the second argument specifies
1717 the particular entity.  If the second argument is in string form, it must
1718 correspond to the internal manner in which GNAT stores entity names (see
1719 compilation unit Namet in the compiler sources for details).
1720
1721 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1722 to distinguish between overloaded subprograms. If a pragma does not contain
1723 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1724 subprograms denoted by the first two parameters.
1725
1726 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1727 to be eliminated in a manner similar to that used for the extended
1728 @code{Import} and @code{Export} pragmas, except that the subtype names are
1729 always given as strings. At the moment, this form of distinguishing
1730 overloaded subprograms is implemented only partially, so we do not recommend
1731 using it for practical subprogram elimination.
1732
1733 Note that in case of a parameterless procedure its profile is represented
1734 as @code{Parameter_Types => ("")}
1735
1736 Alternatively, the @code{Source_Location} parameter is used to specify
1737 which overloaded alternative is to be eliminated by pointing to the
1738 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1739 source text. The string literal (or concatenation of string literals)
1740 given as SOURCE_TRACE must have the following format:
1741
1742 @smallexample @c ada
1743 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1744
1745 LBRACKET ::= [
1746 RBRACKET ::= ]
1747
1748 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1749 FILE_NAME       ::= STRING_LITERAL
1750 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1751 @end smallexample
1752
1753 SOURCE_TRACE should be the short name of the source file (with no directory
1754 information), and LINE_NUMBER is supposed to point to the line where the
1755 defining name of the subprogram is located.
1756
1757 For the subprograms that are not a part of generic instantiations, only one
1758 SOURCE_LOCATION is used. If a subprogram is declared in a package
1759 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1760 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1761 second one denotes the declaration of the corresponding subprogram in the
1762 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1763 in case of nested instantiations.
1764
1765 The effect of the pragma is to allow the compiler to eliminate
1766 the code or data associated with the named entity.  Any reference to
1767 an eliminated entity outside the compilation unit it is defined in,
1768 causes a compile time or link time error.
1769
1770 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1771 in a system independent manner, with unused entities eliminated, without
1772 the requirement of modifying the source text.  Normally the required set
1773 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1774 tool. Elimination of unused entities local to a compilation unit is
1775 automatic, without requiring the use of pragma @code{Eliminate}.
1776
1777 Note that the reason this pragma takes string literals where names might
1778 be expected is that a pragma @code{Eliminate} can appear in a context where the
1779 relevant names are not visible.
1780
1781 Note that any change in the source files that includes removing, splitting of
1782 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1783 parameter illegal.
1784
1785 It is legal to use pragma Eliminate where the referenced entity is a
1786 dispatching operation, but it is not clear what this would mean, since
1787 in general the call does not know which entity is actually being called.
1788 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1789
1790 @node Pragma Export_Exception
1791 @unnumberedsec Pragma Export_Exception
1792 @cindex OpenVMS
1793 @findex Export_Exception
1794 @noindent
1795 Syntax:
1796
1797 @smallexample @c ada
1798 pragma Export_Exception (
1799      [Internal =>] LOCAL_NAME
1800   [, [External =>] EXTERNAL_SYMBOL]
1801   [, [Form     =>] Ada | VMS]
1802   [, [Code     =>] static_integer_EXPRESSION]);
1803
1804 EXTERNAL_SYMBOL ::=
1805   IDENTIFIER
1806 | static_string_EXPRESSION
1807 @end smallexample
1808
1809 @noindent
1810 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1811 causes the specified exception to be propagated outside of the Ada program,
1812 so that it can be handled by programs written in other OpenVMS languages.
1813 This pragma establishes an external name for an Ada exception and makes the
1814 name available to the OpenVMS Linker as a global symbol.  For further details
1815 on this pragma, see the
1816 DEC Ada Language Reference Manual, section 13.9a3.2.
1817
1818 @node Pragma Export_Function
1819 @unnumberedsec Pragma Export_Function
1820 @cindex Argument passing mechanisms
1821 @findex Export_Function
1822
1823 @noindent
1824 Syntax:
1825
1826 @smallexample @c ada
1827 pragma Export_Function (
1828      [Internal         =>] LOCAL_NAME
1829   [, [External         =>] EXTERNAL_SYMBOL]
1830   [, [Parameter_Types  =>] PARAMETER_TYPES]
1831   [, [Result_Type      =>] result_SUBTYPE_MARK]
1832   [, [Mechanism        =>] MECHANISM]
1833   [, [Result_Mechanism =>] MECHANISM_NAME]);
1834
1835 EXTERNAL_SYMBOL ::=
1836   IDENTIFIER
1837 | static_string_EXPRESSION
1838 | ""
1839
1840 PARAMETER_TYPES ::=
1841   null
1842 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1843
1844 TYPE_DESIGNATOR ::=
1845   subtype_NAME
1846 | subtype_Name ' Access
1847
1848 MECHANISM ::=
1849   MECHANISM_NAME
1850 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1851
1852 MECHANISM_ASSOCIATION ::=
1853   [formal_parameter_NAME =>] MECHANISM_NAME
1854
1855 MECHANISM_NAME ::=
1856   Value
1857 | Reference
1858 | Descriptor [([Class =>] CLASS_NAME)]
1859 | Short_Descriptor [([Class =>] CLASS_NAME)]
1860
1861 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1862 @end smallexample
1863
1864 @noindent
1865 Use this pragma to make a function externally callable and optionally
1866 provide information on mechanisms to be used for passing parameter and
1867 result values.  We recommend, for the purposes of improving portability,
1868 this pragma always be used in conjunction with a separate pragma
1869 @code{Export}, which must precede the pragma @code{Export_Function}.
1870 GNAT does not require a separate pragma @code{Export}, but if none is
1871 present, @code{Convention Ada} is assumed, which is usually
1872 not what is wanted, so it is usually appropriate to use this
1873 pragma in conjunction with a @code{Export} or @code{Convention}
1874 pragma that specifies the desired foreign convention.
1875 Pragma @code{Export_Function}
1876 (and @code{Export}, if present) must appear in the same declarative
1877 region as the function to which they apply.
1878
1879 @var{internal_name} must uniquely designate the function to which the
1880 pragma applies.  If more than one function name exists of this name in
1881 the declarative part you must use the @code{Parameter_Types} and
1882 @code{Result_Type} parameters is mandatory to achieve the required
1883 unique designation.  @var{subtype_mark}s in these parameters must
1884 exactly match the subtypes in the corresponding function specification,
1885 using positional notation to match parameters with subtype marks.
1886 The form with an @code{'Access} attribute can be used to match an
1887 anonymous access parameter.
1888
1889 @cindex OpenVMS
1890 @cindex Passing by descriptor
1891 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1892 The default behavior for Export_Function is to accept either 64bit or
1893 32bit descriptors unless short_descriptor is specified, then only 32bit
1894 descriptors are accepted.
1895
1896 @cindex Suppressing external name
1897 Special treatment is given if the EXTERNAL is an explicit null
1898 string or a static string expressions that evaluates to the null
1899 string. In this case, no external name is generated. This form
1900 still allows the specification of parameter mechanisms.
1901
1902 @node Pragma Export_Object
1903 @unnumberedsec Pragma Export_Object
1904 @findex Export_Object
1905 @noindent
1906 Syntax:
1907
1908 @smallexample @c ada
1909 pragma Export_Object
1910       [Internal =>] LOCAL_NAME
1911    [, [External =>] EXTERNAL_SYMBOL]
1912    [, [Size     =>] EXTERNAL_SYMBOL]
1913
1914 EXTERNAL_SYMBOL ::=
1915   IDENTIFIER
1916 | static_string_EXPRESSION
1917 @end smallexample
1918
1919 @noindent
1920 This pragma designates an object as exported, and apart from the
1921 extended rules for external symbols, is identical in effect to the use of
1922 the normal @code{Export} pragma applied to an object.  You may use a
1923 separate Export pragma (and you probably should from the point of view
1924 of portability), but it is not required.  @var{Size} is syntax checked,
1925 but otherwise ignored by GNAT@.
1926
1927 @node Pragma Export_Procedure
1928 @unnumberedsec Pragma Export_Procedure
1929 @findex Export_Procedure
1930 @noindent
1931 Syntax:
1932
1933 @smallexample @c ada
1934 pragma Export_Procedure (
1935      [Internal        =>] LOCAL_NAME
1936   [, [External        =>] EXTERNAL_SYMBOL]
1937   [, [Parameter_Types =>] PARAMETER_TYPES]
1938   [, [Mechanism       =>] MECHANISM]);
1939
1940 EXTERNAL_SYMBOL ::=
1941   IDENTIFIER
1942 | static_string_EXPRESSION
1943 | ""
1944
1945 PARAMETER_TYPES ::=
1946   null
1947 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1948
1949 TYPE_DESIGNATOR ::=
1950   subtype_NAME
1951 | subtype_Name ' Access
1952
1953 MECHANISM ::=
1954   MECHANISM_NAME
1955 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1956
1957 MECHANISM_ASSOCIATION ::=
1958   [formal_parameter_NAME =>] MECHANISM_NAME
1959
1960 MECHANISM_NAME ::=
1961   Value
1962 | Reference
1963 | Descriptor [([Class =>] CLASS_NAME)]
1964 | Short_Descriptor [([Class =>] CLASS_NAME)]
1965
1966 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1967 @end smallexample
1968
1969 @noindent
1970 This pragma is identical to @code{Export_Function} except that it
1971 applies to a procedure rather than a function and the parameters
1972 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1973 GNAT does not require a separate pragma @code{Export}, but if none is
1974 present, @code{Convention Ada} is assumed, which is usually
1975 not what is wanted, so it is usually appropriate to use this
1976 pragma in conjunction with a @code{Export} or @code{Convention}
1977 pragma that specifies the desired foreign convention.
1978
1979 @cindex OpenVMS
1980 @cindex Passing by descriptor
1981 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1982 The default behavior for Export_Procedure is to accept either 64bit or
1983 32bit descriptors unless short_descriptor is specified, then only 32bit
1984 descriptors are accepted.
1985
1986 @cindex Suppressing external name
1987 Special treatment is given if the EXTERNAL is an explicit null
1988 string or a static string expressions that evaluates to the null
1989 string. In this case, no external name is generated. This form
1990 still allows the specification of parameter mechanisms.
1991
1992 @node Pragma Export_Value
1993 @unnumberedsec Pragma Export_Value
1994 @findex Export_Value
1995 @noindent
1996 Syntax:
1997
1998 @smallexample @c ada
1999 pragma Export_Value (
2000   [Value     =>] static_integer_EXPRESSION,
2001   [Link_Name =>] static_string_EXPRESSION);
2002 @end smallexample
2003
2004 @noindent
2005 This pragma serves to export a static integer value for external use.
2006 The first argument specifies the value to be exported. The Link_Name
2007 argument specifies the symbolic name to be associated with the integer
2008 value. This pragma is useful for defining a named static value in Ada
2009 that can be referenced in assembly language units to be linked with
2010 the application. This pragma is currently supported only for the
2011 AAMP target and is ignored for other targets.
2012
2013 @node Pragma Export_Valued_Procedure
2014 @unnumberedsec Pragma Export_Valued_Procedure
2015 @findex Export_Valued_Procedure
2016 @noindent
2017 Syntax:
2018
2019 @smallexample @c ada
2020 pragma Export_Valued_Procedure (
2021      [Internal        =>] LOCAL_NAME
2022   [, [External        =>] EXTERNAL_SYMBOL]
2023   [, [Parameter_Types =>] PARAMETER_TYPES]
2024   [, [Mechanism       =>] MECHANISM]);
2025
2026 EXTERNAL_SYMBOL ::=
2027   IDENTIFIER
2028 | static_string_EXPRESSION
2029 | ""
2030
2031 PARAMETER_TYPES ::=
2032   null
2033 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2034
2035 TYPE_DESIGNATOR ::=
2036   subtype_NAME
2037 | subtype_Name ' Access
2038
2039 MECHANISM ::=
2040   MECHANISM_NAME
2041 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2042
2043 MECHANISM_ASSOCIATION ::=
2044   [formal_parameter_NAME =>] MECHANISM_NAME
2045
2046 MECHANISM_NAME ::=
2047   Value
2048 | Reference
2049 | Descriptor [([Class =>] CLASS_NAME)]
2050 | Short_Descriptor [([Class =>] CLASS_NAME)]
2051
2052 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2053 @end smallexample
2054
2055 @noindent
2056 This pragma is identical to @code{Export_Procedure} except that the
2057 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2058 mode @code{OUT}, and externally the subprogram is treated as a function
2059 with this parameter as the result of the function.  GNAT provides for
2060 this capability to allow the use of @code{OUT} and @code{IN OUT}
2061 parameters in interfacing to external functions (which are not permitted
2062 in Ada functions).
2063 GNAT does not require a separate pragma @code{Export}, but if none is
2064 present, @code{Convention Ada} is assumed, which is almost certainly
2065 not what is wanted since the whole point of this pragma is to interface
2066 with foreign language functions, so it is usually appropriate to use this
2067 pragma in conjunction with a @code{Export} or @code{Convention}
2068 pragma that specifies the desired foreign convention.
2069
2070 @cindex OpenVMS
2071 @cindex Passing by descriptor
2072 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2073 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2074 32bit descriptors unless short_descriptor is specified, then only 32bit
2075 descriptors are accepted.
2076
2077 @cindex Suppressing external name
2078 Special treatment is given if the EXTERNAL is an explicit null
2079 string or a static string expressions that evaluates to the null
2080 string. In this case, no external name is generated. This form
2081 still allows the specification of parameter mechanisms.
2082
2083 @node Pragma Extend_System
2084 @unnumberedsec Pragma Extend_System
2085 @cindex @code{system}, extending
2086 @cindex Dec Ada 83
2087 @findex Extend_System
2088 @noindent
2089 Syntax:
2090
2091 @smallexample @c ada
2092 pragma Extend_System ([Name =>] IDENTIFIER);
2093 @end smallexample
2094
2095 @noindent
2096 This pragma is used to provide backwards compatibility with other
2097 implementations that extend the facilities of package @code{System}.  In
2098 GNAT, @code{System} contains only the definitions that are present in
2099 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2100 implementation, provide many extensions to package @code{System}.
2101
2102 For each such implementation accommodated by this pragma, GNAT provides a
2103 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2104 implementation, which provides the required additional definitions.  You
2105 can use this package in two ways.  You can @code{with} it in the normal
2106 way and access entities either by selection or using a @code{use}
2107 clause.  In this case no special processing is required.
2108
2109 However, if existing code contains references such as
2110 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2111 definitions provided in package @code{System}, you may use this pragma
2112 to extend visibility in @code{System} in a non-standard way that
2113 provides greater compatibility with the existing code.  Pragma
2114 @code{Extend_System} is a configuration pragma whose single argument is
2115 the name of the package containing the extended definition
2116 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2117 control of this pragma will be processed using special visibility
2118 processing that looks in package @code{System.Aux_@var{xxx}} where
2119 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2120 package @code{System}, but not found in package @code{System}.
2121
2122 You can use this pragma either to access a predefined @code{System}
2123 extension supplied with the compiler, for example @code{Aux_DEC} or
2124 you can construct your own extension unit following the above
2125 definition.  Note that such a package is a child of @code{System}
2126 and thus is considered part of the implementation.  To compile
2127 it you will have to use the appropriate switch for compiling
2128 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2129 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2130
2131 @node Pragma External
2132 @unnumberedsec Pragma External
2133 @findex External
2134 @noindent
2135 Syntax:
2136
2137 @smallexample @c ada
2138 pragma External (
2139   [   Convention    =>] convention_IDENTIFIER,
2140   [   Entity        =>] LOCAL_NAME
2141   [, [External_Name =>] static_string_EXPRESSION ]
2142   [, [Link_Name     =>] static_string_EXPRESSION ]);
2143 @end smallexample
2144
2145 @noindent
2146 This pragma is identical in syntax and semantics to pragma
2147 @code{Export} as defined in the Ada Reference Manual.  It is
2148 provided for compatibility with some Ada 83 compilers that
2149 used this pragma for exactly the same purposes as pragma
2150 @code{Export} before the latter was standardized.
2151
2152 @node Pragma External_Name_Casing
2153 @unnumberedsec Pragma External_Name_Casing
2154 @cindex Dec Ada 83 casing compatibility
2155 @cindex External Names, casing
2156 @cindex Casing of External names
2157 @findex External_Name_Casing
2158 @noindent
2159 Syntax:
2160
2161 @smallexample @c ada
2162 pragma External_Name_Casing (
2163   Uppercase | Lowercase
2164   [, Uppercase | Lowercase | As_Is]);
2165 @end smallexample
2166
2167 @noindent
2168 This pragma provides control over the casing of external names associated
2169 with Import and Export pragmas.  There are two cases to consider:
2170
2171 @table @asis
2172 @item Implicit external names
2173 Implicit external names are derived from identifiers.  The most common case
2174 arises when a standard Ada Import or Export pragma is used with only two
2175 arguments, as in:
2176
2177 @smallexample @c ada
2178    pragma Import (C, C_Routine);
2179 @end smallexample
2180
2181 @noindent
2182 Since Ada is a case-insensitive language, the spelling of the identifier in
2183 the Ada source program does not provide any information on the desired
2184 casing of the external name, and so a convention is needed.  In GNAT the
2185 default treatment is that such names are converted to all lower case
2186 letters.  This corresponds to the normal C style in many environments.
2187 The first argument of pragma @code{External_Name_Casing} can be used to
2188 control this treatment.  If @code{Uppercase} is specified, then the name
2189 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2190 then the normal default of all lower case letters will be used.
2191
2192 This same implicit treatment is also used in the case of extended DEC Ada 83
2193 compatible Import and Export pragmas where an external name is explicitly
2194 specified using an identifier rather than a string.
2195
2196 @item Explicit external names
2197 Explicit external names are given as string literals.  The most common case
2198 arises when a standard Ada Import or Export pragma is used with three
2199 arguments, as in:
2200
2201 @smallexample @c ada
2202 pragma Import (C, C_Routine, "C_routine");
2203 @end smallexample
2204
2205 @noindent
2206 In this case, the string literal normally provides the exact casing required
2207 for the external name.  The second argument of pragma
2208 @code{External_Name_Casing} may be used to modify this behavior.
2209 If @code{Uppercase} is specified, then the name
2210 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2211 then the name will be forced to all lowercase letters.  A specification of
2212 @code{As_Is} provides the normal default behavior in which the casing is
2213 taken from the string provided.
2214 @end table
2215
2216 @noindent
2217 This pragma may appear anywhere that a pragma is valid.  In particular, it
2218 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2219 case it applies to all subsequent compilations, or it can be used as a program
2220 unit pragma, in which case it only applies to the current unit, or it can
2221 be used more locally to control individual Import/Export pragmas.
2222
2223 It is primarily intended for use with OpenVMS systems, where many
2224 compilers convert all symbols to upper case by default.  For interfacing to
2225 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2226 the pragma:
2227
2228 @smallexample @c ada
2229 pragma External_Name_Casing (Uppercase, Uppercase);
2230 @end smallexample
2231
2232 @noindent
2233 to enforce the upper casing of all external symbols.
2234
2235 @node Pragma Fast_Math
2236 @unnumberedsec Pragma Fast_Math
2237 @findex Fast_Math
2238 @noindent
2239 Syntax:
2240
2241 @smallexample @c ada
2242 pragma Fast_Math;
2243 @end smallexample
2244
2245 @noindent
2246 This is a configuration pragma which activates a mode in which speed is
2247 considered more important for floating-point operations than absolutely
2248 accurate adherence to the requirements of the standard. Currently the
2249 following operations are affected:
2250
2251 @table @asis
2252 @item Complex Multiplication
2253 The normal simple formula for complex multiplication can result in intermediate
2254 overflows for numbers near the end of the range. The Ada standard requires that
2255 this situation be detected and corrected by scaling, but in Fast_Math mode such
2256 cases will simply result in overflow. Note that to take advantage of this you
2257 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2258 under control of the pragma, rather than use the preinstantiated versions.
2259 @end table
2260
2261 @node Pragma Favor_Top_Level
2262 @unnumberedsec Pragma Favor_Top_Level
2263 @findex Favor_Top_Level
2264 @noindent
2265 Syntax:
2266
2267 @smallexample @c ada
2268 pragma Favor_Top_Level (type_NAME);
2269 @end smallexample
2270
2271 @noindent
2272 The named type must be an access-to-subprogram type. This pragma is an
2273 efficiency hint to the compiler, regarding the use of 'Access or
2274 'Unrestricted_Access on nested (non-library-level) subprograms. The
2275 pragma means that nested subprograms are not used with this type, or
2276 are rare, so that the generated code should be efficient in the
2277 top-level case. When this pragma is used, dynamically generated
2278 trampolines may be used on some targets for nested subprograms.
2279 See also the No_Implicit_Dynamic_Code restriction.
2280
2281 @node Pragma Finalize_Storage_Only
2282 @unnumberedsec Pragma Finalize_Storage_Only
2283 @findex Finalize_Storage_Only
2284 @noindent
2285 Syntax:
2286
2287 @smallexample @c ada
2288 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2289 @end smallexample
2290
2291 @noindent
2292 This pragma allows the compiler not to emit a Finalize call for objects
2293 defined at the library level.  This is mostly useful for types where
2294 finalization is only used to deal with storage reclamation since in most
2295 environments it is not necessary to reclaim memory just before terminating
2296 execution, hence the name.
2297
2298 @node Pragma Float_Representation
2299 @unnumberedsec Pragma Float_Representation
2300 @cindex OpenVMS
2301 @findex Float_Representation
2302 @noindent
2303 Syntax:
2304
2305 @smallexample @c ada
2306 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2307
2308 FLOAT_REP ::= VAX_Float | IEEE_Float
2309 @end smallexample
2310
2311 @noindent
2312 In the one argument form, this pragma is a configuration pragma which
2313 allows control over the internal representation chosen for the predefined
2314 floating point types declared in the packages @code{Standard} and
2315 @code{System}. On all systems other than OpenVMS, the argument must
2316 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2317 argument may be @code{VAX_Float} to specify the use of the VAX float
2318 format for the floating-point types in Standard. This requires that
2319 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2320 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2321 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2322
2323 The two argument form specifies the representation to be used for
2324 the specified floating-point type. On all systems other than OpenVMS,
2325 the argument must
2326 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2327 argument may be @code{VAX_Float} to specify the use of the VAX float
2328 format, as follows:
2329
2330 @itemize @bullet
2331 @item
2332 For digits values up to 6, F float format will be used.
2333 @item
2334 For digits values from 7 to 9, G float format will be used.
2335 @item
2336 For digits values from 10 to 15, F float format will be used.
2337 @item
2338 Digits values above 15 are not allowed.
2339 @end itemize
2340
2341 @node Pragma Ident
2342 @unnumberedsec Pragma Ident
2343 @findex Ident
2344 @noindent
2345 Syntax:
2346
2347 @smallexample @c ada
2348 pragma Ident (static_string_EXPRESSION);
2349 @end smallexample
2350
2351 @noindent
2352 This pragma provides a string identification in the generated object file,
2353 if the system supports the concept of this kind of identification string.
2354 This pragma is allowed only in the outermost declarative part or
2355 declarative items of a compilation unit. If more than one @code{Ident}
2356 pragma is given, only the last one processed is effective.
2357 @cindex OpenVMS
2358 On OpenVMS systems, the effect of the pragma is identical to the effect of
2359 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2360 maximum allowed length is 31 characters, so if it is important to
2361 maintain compatibility with this compiler, you should obey this length
2362 limit.
2363
2364 @node Pragma Implemented_By_Entry
2365 @unnumberedsec Pragma Implemented_By_Entry
2366 @findex Implemented_By_Entry
2367 @noindent
2368 Syntax:
2369
2370 @smallexample @c ada
2371 pragma Implemented_By_Entry (LOCAL_NAME);
2372 @end smallexample
2373
2374 @noindent
2375 This is a representation pragma which applies to protected, synchronized and
2376 task interface primitives. If the pragma is applied to primitive operation Op
2377 of interface Iface, it is illegal to override Op in a type that implements
2378 Iface, with anything other than an entry.
2379
2380 @smallexample @c ada
2381 type Iface is protected interface;
2382 procedure Do_Something (Object : in out Iface) is abstract;
2383 pragma Implemented_By_Entry (Do_Something);
2384
2385 protected type P is new Iface with
2386    procedure Do_Something;  --  Illegal
2387 end P;
2388
2389 task type T is new Iface with
2390    entry Do_Something;      --  Legal
2391 end T;
2392 @end smallexample
2393
2394 @noindent
2395 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2396 is intended to be used in conjunction with dispatching requeue statements as
2397 described in AI05-0030. Should the ARG decide on an official name and syntax,
2398 this pragma will become language-defined rather than GNAT-specific.
2399
2400 @node Pragma Implicit_Packing
2401 @unnumberedsec Pragma Implicit_Packing
2402 @findex Implicit_Packing
2403 @noindent
2404 Syntax:
2405
2406 @smallexample @c ada
2407 pragma Implicit_Packing;
2408 @end smallexample
2409
2410 @noindent
2411 This is a configuration pragma that requests implicit packing for packed
2412 arrays for which a size clause is given but no explicit pragma Pack or
2413 specification of Component_Size is present. It also applies to records
2414 where no record representation clause is present. Consider this example:
2415
2416 @smallexample @c ada
2417 type R is array (0 .. 7) of Boolean;
2418 for R'Size use 8;
2419 @end smallexample
2420
2421 @noindent
2422 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2423 does not change the layout of a composite object. So the Size clause in the
2424 above example is normally rejected, since the default layout of the array uses
2425 8-bit components, and thus the array requires a minimum of 64 bits.
2426
2427 If this declaration is compiled in a region of code covered by an occurrence
2428 of the configuration pragma Implicit_Packing, then the Size clause in this
2429 and similar examples will cause implicit packing and thus be accepted. For
2430 this implicit packing to occur, the type in question must be an array of small
2431 components whose size is known at compile time, and the Size clause must
2432 specify the exact size that corresponds to the length of the array multiplied
2433 by the size in bits of the component type.
2434 @cindex Array packing
2435
2436 Similarly, the following example shows the use in the record case
2437
2438 @smallexample @c ada
2439 type r is record
2440    a, b, c, d, e, f, g, h : boolean;
2441    chr                    : character;
2442 end record;
2443 for r'size use 16;
2444 @end smallexample
2445
2446 @noindent
2447 Without a pragma Pack, each Boolean field requires 8 bits, so the
2448 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2449 sufficient. The use of pragma Implciit_Packing allows this record
2450 declaration to compile without an explicit pragma Pack.
2451 @node Pragma Import_Exception
2452 @unnumberedsec Pragma Import_Exception
2453 @cindex OpenVMS
2454 @findex Import_Exception
2455 @noindent
2456 Syntax:
2457
2458 @smallexample @c ada
2459 pragma Import_Exception (
2460      [Internal =>] LOCAL_NAME
2461   [, [External =>] EXTERNAL_SYMBOL]
2462   [, [Form     =>] Ada | VMS]
2463   [, [Code     =>] static_integer_EXPRESSION]);
2464
2465 EXTERNAL_SYMBOL ::=
2466   IDENTIFIER
2467 | static_string_EXPRESSION
2468 @end smallexample
2469
2470 @noindent
2471 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2472 It allows OpenVMS conditions (for example, from OpenVMS system services or
2473 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2474 The pragma specifies that the exception associated with an exception
2475 declaration in an Ada program be defined externally (in non-Ada code).
2476 For further details on this pragma, see the
2477 DEC Ada Language Reference Manual, section 13.9a.3.1.
2478
2479 @node Pragma Import_Function
2480 @unnumberedsec Pragma Import_Function
2481 @findex Import_Function
2482 @noindent
2483 Syntax:
2484
2485 @smallexample @c ada
2486 pragma Import_Function (
2487      [Internal                 =>] LOCAL_NAME,
2488   [, [External                 =>] EXTERNAL_SYMBOL]
2489   [, [Parameter_Types          =>] PARAMETER_TYPES]
2490   [, [Result_Type              =>] SUBTYPE_MARK]
2491   [, [Mechanism                =>] MECHANISM]
2492   [, [Result_Mechanism         =>] MECHANISM_NAME]
2493   [, [First_Optional_Parameter =>] IDENTIFIER]);
2494
2495 EXTERNAL_SYMBOL ::=
2496   IDENTIFIER
2497 | static_string_EXPRESSION
2498
2499 PARAMETER_TYPES ::=
2500   null
2501 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2502
2503 TYPE_DESIGNATOR ::=
2504   subtype_NAME
2505 | subtype_Name ' Access
2506
2507 MECHANISM ::=
2508   MECHANISM_NAME
2509 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2510
2511 MECHANISM_ASSOCIATION ::=
2512   [formal_parameter_NAME =>] MECHANISM_NAME
2513
2514 MECHANISM_NAME ::=
2515   Value
2516 | Reference
2517 | Descriptor [([Class =>] CLASS_NAME)]
2518 | Short_Descriptor [([Class =>] CLASS_NAME)]
2519
2520 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2521 @end smallexample
2522
2523 @noindent
2524 This pragma is used in conjunction with a pragma @code{Import} to
2525 specify additional information for an imported function.  The pragma
2526 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2527 @code{Import_Function} pragma and both must appear in the same
2528 declarative part as the function specification.
2529
2530 The @var{Internal} argument must uniquely designate
2531 the function to which the
2532 pragma applies.  If more than one function name exists of this name in
2533 the declarative part you must use the @code{Parameter_Types} and
2534 @var{Result_Type} parameters to achieve the required unique
2535 designation.  Subtype marks in these parameters must exactly match the
2536 subtypes in the corresponding function specification, using positional
2537 notation to match parameters with subtype marks.
2538 The form with an @code{'Access} attribute can be used to match an
2539 anonymous access parameter.
2540
2541 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2542 parameters to specify passing mechanisms for the
2543 parameters and result.  If you specify a single mechanism name, it
2544 applies to all parameters.  Otherwise you may specify a mechanism on a
2545 parameter by parameter basis using either positional or named
2546 notation.  If the mechanism is not specified, the default mechanism
2547 is used.
2548
2549 @cindex OpenVMS
2550 @cindex Passing by descriptor
2551 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2552 The default behavior for Import_Function is to pass a 64bit descriptor
2553 unless short_descriptor is specified, then a 32bit descriptor is passed.
2554
2555 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2556 It specifies that the designated parameter and all following parameters
2557 are optional, meaning that they are not passed at the generated code
2558 level (this is distinct from the notion of optional parameters in Ada
2559 where the parameters are passed anyway with the designated optional
2560 parameters).  All optional parameters must be of mode @code{IN} and have
2561 default parameter values that are either known at compile time
2562 expressions, or uses of the @code{'Null_Parameter} attribute.
2563
2564 @node Pragma Import_Object
2565 @unnumberedsec Pragma Import_Object
2566 @findex Import_Object
2567 @noindent
2568 Syntax:
2569
2570 @smallexample @c ada
2571 pragma Import_Object
2572      [Internal =>] LOCAL_NAME
2573   [, [External =>] EXTERNAL_SYMBOL]
2574   [, [Size     =>] EXTERNAL_SYMBOL]);
2575
2576 EXTERNAL_SYMBOL ::=
2577   IDENTIFIER
2578 | static_string_EXPRESSION
2579 @end smallexample
2580
2581 @noindent
2582 This pragma designates an object as imported, and apart from the
2583 extended rules for external symbols, is identical in effect to the use of
2584 the normal @code{Import} pragma applied to an object.  Unlike the
2585 subprogram case, you need not use a separate @code{Import} pragma,
2586 although you may do so (and probably should do so from a portability
2587 point of view).  @var{size} is syntax checked, but otherwise ignored by
2588 GNAT@.
2589
2590 @node Pragma Import_Procedure
2591 @unnumberedsec Pragma Import_Procedure
2592 @findex Import_Procedure
2593 @noindent
2594 Syntax:
2595
2596 @smallexample @c ada
2597 pragma Import_Procedure (
2598      [Internal                 =>] LOCAL_NAME
2599   [, [External                 =>] EXTERNAL_SYMBOL]
2600   [, [Parameter_Types          =>] PARAMETER_TYPES]
2601   [, [Mechanism                =>] MECHANISM]
2602   [, [First_Optional_Parameter =>] IDENTIFIER]);
2603
2604 EXTERNAL_SYMBOL ::=
2605   IDENTIFIER
2606 | static_string_EXPRESSION
2607
2608 PARAMETER_TYPES ::=
2609   null
2610 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2611
2612 TYPE_DESIGNATOR ::=
2613   subtype_NAME
2614 | subtype_Name ' Access
2615
2616 MECHANISM ::=
2617   MECHANISM_NAME
2618 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2619
2620 MECHANISM_ASSOCIATION ::=
2621   [formal_parameter_NAME =>] MECHANISM_NAME
2622
2623 MECHANISM_NAME ::=
2624   Value
2625 | Reference
2626 | Descriptor [([Class =>] CLASS_NAME)]
2627 | Short_Descriptor [([Class =>] CLASS_NAME)]
2628
2629 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2630 @end smallexample
2631
2632 @noindent
2633 This pragma is identical to @code{Import_Function} except that it
2634 applies to a procedure rather than a function and the parameters
2635 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2636
2637 @node Pragma Import_Valued_Procedure
2638 @unnumberedsec Pragma Import_Valued_Procedure
2639 @findex Import_Valued_Procedure
2640 @noindent
2641 Syntax:
2642
2643 @smallexample @c ada
2644 pragma Import_Valued_Procedure (
2645      [Internal                 =>] LOCAL_NAME
2646   [, [External                 =>] EXTERNAL_SYMBOL]
2647   [, [Parameter_Types          =>] PARAMETER_TYPES]
2648   [, [Mechanism                =>] MECHANISM]
2649   [, [First_Optional_Parameter =>] IDENTIFIER]);
2650
2651 EXTERNAL_SYMBOL ::=
2652   IDENTIFIER
2653 | static_string_EXPRESSION
2654
2655 PARAMETER_TYPES ::=
2656   null
2657 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2658
2659 TYPE_DESIGNATOR ::=
2660   subtype_NAME
2661 | subtype_Name ' Access
2662
2663 MECHANISM ::=
2664   MECHANISM_NAME
2665 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2666
2667 MECHANISM_ASSOCIATION ::=
2668   [formal_parameter_NAME =>] MECHANISM_NAME
2669
2670 MECHANISM_NAME ::=
2671   Value
2672 | Reference
2673 | Descriptor [([Class =>] CLASS_NAME)]
2674 | Short_Descriptor [([Class =>] CLASS_NAME)]
2675
2676 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2677 @end smallexample
2678
2679 @noindent
2680 This pragma is identical to @code{Import_Procedure} except that the
2681 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2682 mode @code{OUT}, and externally the subprogram is treated as a function
2683 with this parameter as the result of the function.  The purpose of this
2684 capability is to allow the use of @code{OUT} and @code{IN OUT}
2685 parameters in interfacing to external functions (which are not permitted
2686 in Ada functions).  You may optionally use the @code{Mechanism}
2687 parameters to specify passing mechanisms for the parameters.
2688 If you specify a single mechanism name, it applies to all parameters.
2689 Otherwise you may specify a mechanism on a parameter by parameter
2690 basis using either positional or named notation.  If the mechanism is not
2691 specified, the default mechanism is used.
2692
2693 Note that it is important to use this pragma in conjunction with a separate
2694 pragma Import that specifies the desired convention, since otherwise the
2695 default convention is Ada, which is almost certainly not what is required.
2696
2697 @node Pragma Initialize_Scalars
2698 @unnumberedsec Pragma Initialize_Scalars
2699 @findex Initialize_Scalars
2700 @cindex debugging with Initialize_Scalars
2701 @noindent
2702 Syntax:
2703
2704 @smallexample @c ada
2705 pragma Initialize_Scalars;
2706 @end smallexample
2707
2708 @noindent
2709 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2710 two important differences.  First, there is no requirement for the pragma
2711 to be used uniformly in all units of a partition, in particular, it is fine
2712 to use this just for some or all of the application units of a partition,
2713 without needing to recompile the run-time library.
2714
2715 In the case where some units are compiled with the pragma, and some without,
2716 then a declaration of a variable where the type is defined in package
2717 Standard or is locally declared will always be subject to initialization,
2718 as will any declaration of a scalar variable.  For composite variables,
2719 whether the variable is initialized may also depend on whether the package
2720 in which the type of the variable is declared is compiled with the pragma.
2721
2722 The other important difference is that you can control the value used
2723 for initializing scalar objects.  At bind time, you can select several
2724 options for initialization. You can
2725 initialize with invalid values (similar to Normalize_Scalars, though for
2726 Initialize_Scalars it is not always possible to determine the invalid
2727 values in complex cases like signed component fields with non-standard
2728 sizes). You can also initialize with high or
2729 low values, or with a specified bit pattern.  See the users guide for binder
2730 options for specifying these cases.
2731
2732 This means that you can compile a program, and then without having to
2733 recompile the program, you can run it with different values being used
2734 for initializing otherwise uninitialized values, to test if your program
2735 behavior depends on the choice.  Of course the behavior should not change,
2736 and if it does, then most likely you have an erroneous reference to an
2737 uninitialized value.
2738
2739 It is even possible to change the value at execution time eliminating even
2740 the need to rebind with a different switch using an environment variable.
2741 See the GNAT users guide for details.
2742
2743 Note that pragma @code{Initialize_Scalars} is particularly useful in
2744 conjunction with the enhanced validity checking that is now provided
2745 in GNAT, which checks for invalid values under more conditions.
2746 Using this feature (see description of the @option{-gnatV} flag in the
2747 users guide) in conjunction with pragma @code{Initialize_Scalars}
2748 provides a powerful new tool to assist in the detection of problems
2749 caused by uninitialized variables.
2750
2751 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2752 effect on the generated code. This may cause your code to be
2753 substantially larger. It may also cause an increase in the amount
2754 of stack required, so it is probably a good idea to turn on stack
2755 checking (see description of stack checking in the GNAT users guide)
2756 when using this pragma.
2757
2758 @node Pragma Inline_Always
2759 @unnumberedsec Pragma Inline_Always
2760 @findex Inline_Always
2761 @noindent
2762 Syntax:
2763
2764 @smallexample @c ada
2765 pragma Inline_Always (NAME [, NAME]);
2766 @end smallexample
2767
2768 @noindent
2769 Similar to pragma @code{Inline} except that inlining is not subject to
2770 the use of option @option{-gnatn} and the inlining happens regardless of
2771 whether this option is used.
2772
2773 @node Pragma Inline_Generic
2774 @unnumberedsec Pragma Inline_Generic
2775 @findex Inline_Generic
2776 @noindent
2777 Syntax:
2778
2779 @smallexample @c ada
2780 pragma Inline_Generic (generic_package_NAME);
2781 @end smallexample
2782
2783 @noindent
2784 This is implemented for compatibility with DEC Ada 83 and is recognized,
2785 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2786 by default when using GNAT@.
2787
2788 @node Pragma Interface
2789 @unnumberedsec Pragma Interface
2790 @findex Interface
2791 @noindent
2792 Syntax:
2793
2794 @smallexample @c ada
2795 pragma Interface (
2796      [Convention    =>] convention_identifier,
2797      [Entity        =>] local_NAME
2798   [, [External_Name =>] static_string_expression]
2799   [, [Link_Name     =>] static_string_expression]);
2800 @end smallexample
2801
2802 @noindent
2803 This pragma is identical in syntax and semantics to
2804 the standard Ada pragma @code{Import}.  It is provided for compatibility
2805 with Ada 83.  The definition is upwards compatible both with pragma
2806 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2807 with some extended implementations of this pragma in certain Ada 83
2808 implementations.
2809
2810 @node Pragma Interface_Name
2811 @unnumberedsec Pragma Interface_Name
2812 @findex Interface_Name
2813 @noindent
2814 Syntax:
2815
2816 @smallexample @c ada
2817 pragma Interface_Name (
2818      [Entity        =>] LOCAL_NAME
2819   [, [External_Name =>] static_string_EXPRESSION]
2820   [, [Link_Name     =>] static_string_EXPRESSION]);
2821 @end smallexample
2822
2823 @noindent
2824 This pragma provides an alternative way of specifying the interface name
2825 for an interfaced subprogram, and is provided for compatibility with Ada
2826 83 compilers that use the pragma for this purpose.  You must provide at
2827 least one of @var{External_Name} or @var{Link_Name}.
2828
2829 @node Pragma Interrupt_Handler
2830 @unnumberedsec Pragma Interrupt_Handler
2831 @findex Interrupt_Handler
2832 @noindent
2833 Syntax:
2834
2835 @smallexample @c ada
2836 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2837 @end smallexample
2838
2839 @noindent
2840 This program unit pragma is supported for parameterless protected procedures
2841 as described in Annex C of the Ada Reference Manual. On the AAMP target
2842 the pragma can also be specified for nonprotected parameterless procedures
2843 that are declared at the library level (which includes procedures
2844 declared at the top level of a library package). In the case of AAMP,
2845 when this pragma is applied to a nonprotected procedure, the instruction
2846 @code{IERET} is generated for returns from the procedure, enabling
2847 maskable interrupts, in place of the normal return instruction.
2848
2849 @node Pragma Interrupt_State
2850 @unnumberedsec Pragma Interrupt_State
2851 @findex Interrupt_State
2852 @noindent
2853 Syntax:
2854
2855 @smallexample @c ada
2856 pragma Interrupt_State
2857  ([Name  =>] value,
2858   [State =>] SYSTEM | RUNTIME | USER);
2859 @end smallexample
2860
2861 @noindent
2862 Normally certain interrupts are reserved to the implementation.  Any attempt
2863 to attach an interrupt causes Program_Error to be raised, as described in
2864 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2865 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2866 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2867 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2868 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2869 Ada exceptions, or used to implement run-time functions such as the
2870 @code{abort} statement and stack overflow checking.
2871
2872 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2873 such uses of interrupts.  It subsumes the functionality of pragma
2874 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2875 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2876 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2877 and may be used to mark interrupts required by the board support package
2878 as reserved.
2879
2880 Interrupts can be in one of three states:
2881 @itemize @bullet
2882 @item System
2883
2884 The interrupt is reserved (no Ada handler can be installed), and the
2885 Ada run-time may not install a handler. As a result you are guaranteed
2886 standard system default action if this interrupt is raised.
2887
2888 @item Runtime
2889
2890 The interrupt is reserved (no Ada handler can be installed). The run time
2891 is allowed to install a handler for internal control purposes, but is
2892 not required to do so.
2893
2894 @item User
2895
2896 The interrupt is unreserved.  The user may install a handler to provide
2897 some other action.
2898 @end itemize
2899
2900 @noindent
2901 These states are the allowed values of the @code{State} parameter of the
2902 pragma.  The @code{Name} parameter is a value of the type
2903 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2904 @code{Ada.Interrupts.Names}.
2905
2906 This is a configuration pragma, and the binder will check that there
2907 are no inconsistencies between different units in a partition in how a
2908 given interrupt is specified. It may appear anywhere a pragma is legal.
2909
2910 The effect is to move the interrupt to the specified state.
2911
2912 By declaring interrupts to be SYSTEM, you guarantee the standard system
2913 action, such as a core dump.
2914
2915 By declaring interrupts to be USER, you guarantee that you can install
2916 a handler.
2917
2918 Note that certain signals on many operating systems cannot be caught and
2919 handled by applications.  In such cases, the pragma is ignored.  See the
2920 operating system documentation, or the value of the array @code{Reserved}
2921 declared in the spec of package @code{System.OS_Interface}.
2922
2923 Overriding the default state of signals used by the Ada runtime may interfere
2924 with an application's runtime behavior in the cases of the synchronous signals,
2925 and in the case of the signal used to implement the @code{abort} statement.
2926
2927 @node Pragma Keep_Names
2928 @unnumberedsec Pragma Keep_Names
2929 @findex Keep_Names
2930 @noindent
2931 Syntax:
2932
2933 @smallexample @c ada
2934 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2935 @end smallexample
2936
2937 @noindent
2938 The @var{LOCAL_NAME} argument
2939 must refer to an enumeration first subtype
2940 in the current declarative part. The effect is to retain the enumeration
2941 literal names for use by @code{Image} and @code{Value} even if a global
2942 @code{Discard_Names} pragma applies. This is useful when you want to
2943 generally suppress enumeration literal names and for example you therefore
2944 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2945 want to retain the names for specific enumeration types.
2946
2947 @node Pragma License
2948 @unnumberedsec Pragma License
2949 @findex License
2950 @cindex License checking
2951 @noindent
2952 Syntax:
2953
2954 @smallexample @c ada
2955 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2956 @end smallexample
2957
2958 @noindent
2959 This pragma is provided to allow automated checking for appropriate license
2960 conditions with respect to the standard and modified GPL@.  A pragma
2961 @code{License}, which is a configuration pragma that typically appears at
2962 the start of a source file or in a separate @file{gnat.adc} file, specifies
2963 the licensing conditions of a unit as follows:
2964
2965 @itemize @bullet
2966 @item Unrestricted
2967 This is used for a unit that can be freely used with no license restrictions.
2968 Examples of such units are public domain units, and units from the Ada
2969 Reference Manual.
2970
2971 @item GPL
2972 This is used for a unit that is licensed under the unmodified GPL, and which
2973 therefore cannot be @code{with}'ed by a restricted unit.
2974
2975 @item Modified_GPL
2976 This is used for a unit licensed under the GNAT modified GPL that includes
2977 a special exception paragraph that specifically permits the inclusion of
2978 the unit in programs without requiring the entire program to be released
2979 under the GPL@.
2980
2981 @item Restricted
2982 This is used for a unit that is restricted in that it is not permitted to
2983 depend on units that are licensed under the GPL@.  Typical examples are
2984 proprietary code that is to be released under more restrictive license
2985 conditions.  Note that restricted units are permitted to @code{with} units
2986 which are licensed under the modified GPL (this is the whole point of the
2987 modified GPL).
2988
2989 @end itemize
2990
2991 @noindent
2992 Normally a unit with no @code{License} pragma is considered to have an
2993 unknown license, and no checking is done.  However, standard GNAT headers
2994 are recognized, and license information is derived from them as follows.
2995
2996 @itemize @bullet
2997
2998 A GNAT license header starts with a line containing 78 hyphens.  The following
2999 comment text is searched for the appearance of any of the following strings.
3000
3001 If the string ``GNU General Public License'' is found, then the unit is assumed
3002 to have GPL license, unless the string ``As a special exception'' follows, in
3003 which case the license is assumed to be modified GPL@.
3004
3005 If one of the strings
3006 ``This specification is adapted from the Ada Semantic Interface'' or
3007 ``This specification is derived from the Ada Reference Manual'' is found
3008 then the unit is assumed to be unrestricted.
3009 @end itemize
3010
3011 @noindent
3012 These default actions means that a program with a restricted license pragma
3013 will automatically get warnings if a GPL unit is inappropriately
3014 @code{with}'ed.  For example, the program:
3015
3016 @smallexample @c ada
3017 with Sem_Ch3;
3018 with GNAT.Sockets;
3019 procedure Secret_Stuff is
3020   @dots{}
3021 end Secret_Stuff
3022 @end smallexample
3023
3024 @noindent
3025 if compiled with pragma @code{License} (@code{Restricted}) in a
3026 @file{gnat.adc} file will generate the warning:
3027
3028 @smallexample
3029 1.  with Sem_Ch3;
3030         |
3031    >>> license of withed unit "Sem_Ch3" is incompatible
3032
3033 2.  with GNAT.Sockets;
3034 3.  procedure Secret_Stuff is
3035 @end smallexample
3036
3037 @noindent
3038 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3039 compiler and is licensed under the
3040 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3041 run time, and is therefore licensed under the modified GPL@.
3042
3043 @node Pragma Link_With
3044 @unnumberedsec Pragma Link_With
3045 @findex Link_With
3046 @noindent
3047 Syntax:
3048
3049 @smallexample @c ada
3050 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3051 @end smallexample
3052
3053 @noindent
3054 This pragma is provided for compatibility with certain Ada 83 compilers.
3055 It has exactly the same effect as pragma @code{Linker_Options} except
3056 that spaces occurring within one of the string expressions are treated
3057 as separators. For example, in the following case:
3058
3059 @smallexample @c ada
3060 pragma Link_With ("-labc -ldef");
3061 @end smallexample
3062
3063 @noindent
3064 results in passing the strings @code{-labc} and @code{-ldef} as two
3065 separate arguments to the linker. In addition pragma Link_With allows
3066 multiple arguments, with the same effect as successive pragmas.
3067
3068 @node Pragma Linker_Alias
3069 @unnumberedsec Pragma Linker_Alias
3070 @findex Linker_Alias
3071 @noindent
3072 Syntax:
3073
3074 @smallexample @c ada
3075 pragma Linker_Alias (
3076   [Entity =>] LOCAL_NAME,
3077   [Target =>] static_string_EXPRESSION);
3078 @end smallexample
3079
3080 @noindent
3081 @var{LOCAL_NAME} must refer to an object that is declared at the library
3082 level. This pragma establishes the given entity as a linker alias for the
3083 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3084 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3085 @var{static_string_EXPRESSION} in the object file, that is to say no space
3086 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3087 to the same address as @var{static_string_EXPRESSION} by the linker.
3088
3089 The actual linker name for the target must be used (e.g.@: the fully
3090 encoded name with qualification in Ada, or the mangled name in C++),
3091 or it must be declared using the C convention with @code{pragma Import}
3092 or @code{pragma Export}.
3093
3094 Not all target machines support this pragma. On some of them it is accepted
3095 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3096
3097 @smallexample @c ada
3098 --  Example of the use of pragma Linker_Alias
3099
3100 package p is
3101   i : Integer := 1;
3102   pragma Export (C, i);
3103
3104   new_name_for_i : Integer;
3105   pragma Linker_Alias (new_name_for_i, "i");
3106 end p;
3107 @end smallexample
3108
3109 @node Pragma Linker_Constructor
3110 @unnumberedsec Pragma Linker_Constructor
3111 @findex Linker_Constructor
3112 @noindent
3113 Syntax:
3114
3115 @smallexample @c ada
3116 pragma Linker_Constructor (procedure_LOCAL_NAME);
3117 @end smallexample
3118
3119 @noindent
3120 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3121 is declared at the library level. A procedure to which this pragma is
3122 applied will be treated as an initialization routine by the linker.
3123 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3124 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3125 of the executable is called (or immediately after the shared library is
3126 loaded if the procedure is linked in a shared library), in particular
3127 before the Ada run-time environment is set up.
3128
3129 Because of these specific contexts, the set of operations such a procedure
3130 can perform is very limited and the type of objects it can manipulate is
3131 essentially restricted to the elementary types. In particular, it must only
3132 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3133
3134 This pragma is used by GNAT to implement auto-initialization of shared Stand
3135 Alone Libraries, which provides a related capability without the restrictions
3136 listed above. Where possible, the use of Stand Alone Libraries is preferable
3137 to the use of this pragma.
3138
3139 @node Pragma Linker_Destructor
3140 @unnumberedsec Pragma Linker_Destructor
3141 @findex Linker_Destructor
3142 @noindent
3143 Syntax:
3144
3145 @smallexample @c ada
3146 pragma Linker_Destructor (procedure_LOCAL_NAME);
3147 @end smallexample
3148
3149 @noindent
3150 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3151 is declared at the library level. A procedure to which this pragma is
3152 applied will be treated as a finalization routine by the linker.
3153 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3154 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3155 of the executable has exited (or immediately before the shared library
3156 is unloaded if the procedure is linked in a shared library), in particular
3157 after the Ada run-time environment is shut down.
3158
3159 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3160 because of these specific contexts.
3161
3162 @node Pragma Linker_Section
3163 @unnumberedsec Pragma Linker_Section
3164 @findex Linker_Section
3165 @noindent
3166 Syntax:
3167
3168 @smallexample @c ada
3169 pragma Linker_Section (
3170   [Entity  =>] LOCAL_NAME,
3171   [Section =>] static_string_EXPRESSION);
3172 @end smallexample
3173
3174 @noindent
3175 @var{LOCAL_NAME} must refer to an object that is declared at the library
3176 level. This pragma specifies the name of the linker section for the given
3177 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3178 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3179 section of the executable (assuming the linker doesn't rename the section).
3180
3181 The compiler normally places library-level objects in standard sections
3182 depending on their type: procedures and functions generally go in the
3183 @code{.text} section, initialized variables in the @code{.data} section
3184 and uninitialized variables in the @code{.bss} section.
3185
3186 Other, special sections may exist on given target machines to map special
3187 hardware, for example I/O ports or flash memory. This pragma is a means to
3188 defer the final layout of the executable to the linker, thus fully working
3189 at the symbolic level with the compiler.
3190
3191 Some file formats do not support arbitrary sections so not all target
3192 machines support this pragma. The use of this pragma may cause a program
3193 execution to be erroneous if it is used to place an entity into an
3194 inappropriate section (e.g.@: a modified variable into the @code{.text}
3195 section). See also @code{pragma Persistent_BSS}.
3196
3197 @smallexample @c ada
3198 --  Example of the use of pragma Linker_Section
3199
3200 package IO_Card is
3201   Port_A : Integer;
3202   pragma Volatile (Port_A);
3203   pragma Linker_Section (Port_A, ".bss.port_a");
3204
3205   Port_B : Integer;
3206   pragma Volatile (Port_B);
3207   pragma Linker_Section (Port_B, ".bss.port_b");
3208 end IO_Card;
3209 @end smallexample
3210
3211 @node Pragma Long_Float
3212 @unnumberedsec Pragma Long_Float
3213 @cindex OpenVMS
3214 @findex Long_Float
3215 @noindent
3216 Syntax:
3217
3218 @smallexample @c ada
3219 pragma Long_Float (FLOAT_FORMAT);
3220
3221 FLOAT_FORMAT ::= D_Float | G_Float
3222 @end smallexample
3223
3224 @noindent
3225 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3226 It allows control over the internal representation chosen for the predefined
3227 type @code{Long_Float} and for floating point type representations with
3228 @code{digits} specified in the range 7 through 15.
3229 For further details on this pragma, see the
3230 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3231 this pragma, the standard runtime libraries must be recompiled.
3232 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3233 @value{EDITION} User's Guide OpenVMS}, for a description of the
3234 @code{GNAT LIBRARY} command.
3235
3236 @node Pragma Machine_Attribute
3237 @unnumberedsec Pragma Machine_Attribute
3238 @findex Machine_Attribute
3239 @noindent
3240 Syntax:
3241
3242 @smallexample @c ada
3243 pragma Machine_Attribute (
3244      [Entity         =>] LOCAL_NAME,
3245      [Attribute_Name =>] static_string_EXPRESSION
3246   [, [Info           =>] static_EXPRESSION] );
3247 @end smallexample
3248
3249 @noindent
3250 Machine-dependent attributes can be specified for types and/or
3251 declarations.  This pragma is semantically equivalent to
3252 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3253 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3254 in GNU C, where @code{@var{attribute_name}} is recognized by the
3255 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3256 specific macro.  A string literal for the optional parameter @var{info}
3257 is transformed into an identifier, which may make this pragma unusable
3258 for some attributes.  @xref{Target Attributes,, Defining target-specific
3259 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3260 Internals}, further information.
3261
3262 @node Pragma Main
3263 @unnumberedsec Pragma Main
3264 @cindex OpenVMS
3265 @findex Main
3266 @noindent
3267 Syntax:
3268
3269 @smallexample @c ada
3270 pragma Main
3271  (MAIN_OPTION [, MAIN_OPTION]);
3272
3273 MAIN_OPTION ::=
3274   [Stack_Size              =>] static_integer_EXPRESSION
3275 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3276 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3277 @end smallexample
3278
3279 @noindent
3280 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3281 no effect in GNAT, other than being syntax checked.
3282
3283 @node Pragma Main_Storage
3284 @unnumberedsec Pragma Main_Storage
3285 @cindex OpenVMS
3286 @findex Main_Storage
3287 @noindent
3288 Syntax:
3289
3290 @smallexample @c ada
3291 pragma Main_Storage
3292   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3293
3294 MAIN_STORAGE_OPTION ::=
3295   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3296 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3297 @end smallexample
3298
3299 @noindent
3300 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3301 no effect in GNAT, other than being syntax checked.  Note that the pragma
3302 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3303
3304 @node Pragma No_Body
3305 @unnumberedsec Pragma No_Body
3306 @findex No_Body
3307 @noindent
3308 Syntax:
3309
3310 @smallexample @c ada
3311 pragma No_Body;
3312 @end smallexample
3313
3314 @noindent
3315 There are a number of cases in which a package spec does not require a body,
3316 and in fact a body is not permitted. GNAT will not permit the spec to be
3317 compiled if there is a body around. The pragma No_Body allows you to provide
3318 a body file, even in a case where no body is allowed. The body file must
3319 contain only comments and a single No_Body pragma. This is recognized by
3320 the compiler as indicating that no body is logically present.
3321
3322 This is particularly useful during maintenance when a package is modified in
3323 such a way that a body needed before is no longer needed. The provision of a
3324 dummy body with a No_Body pragma ensures that there is no interference from
3325 earlier versions of the package body.
3326
3327 @node Pragma No_Return
3328 @unnumberedsec Pragma No_Return
3329 @findex No_Return
3330 @noindent
3331 Syntax:
3332
3333 @smallexample @c ada
3334 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3335 @end smallexample
3336
3337 @noindent
3338 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3339 declarations in the current declarative part.  A procedure to which this
3340 pragma is applied may not contain any explicit @code{return} statements.
3341 In addition, if the procedure contains any implicit returns from falling
3342 off the end of a statement sequence, then execution of that implicit
3343 return will cause Program_Error to be raised.
3344
3345 One use of this pragma is to identify procedures whose only purpose is to raise
3346 an exception. Another use of this pragma is to suppress incorrect warnings
3347 about missing returns in functions, where the last statement of a function
3348 statement sequence is a call to such a procedure.
3349
3350 Note that in Ada 2005 mode, this pragma is part of the language, and is
3351 identical in effect to the pragma as implemented in Ada 95 mode.
3352
3353 @node Pragma No_Strict_Aliasing
3354 @unnumberedsec Pragma No_Strict_Aliasing
3355 @findex No_Strict_Aliasing
3356 @noindent
3357 Syntax:
3358
3359 @smallexample @c ada
3360 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3361 @end smallexample
3362
3363 @noindent
3364 @var{type_LOCAL_NAME} must refer to an access type
3365 declaration in the current declarative part.  The effect is to inhibit
3366 strict aliasing optimization for the given type.  The form with no
3367 arguments is a configuration pragma which applies to all access types
3368 declared in units to which the pragma applies. For a detailed
3369 description of the strict aliasing optimization, and the situations
3370 in which it must be suppressed, see @ref{Optimization and Strict
3371 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3372
3373 @node Pragma Normalize_Scalars
3374 @unnumberedsec Pragma Normalize_Scalars
3375 @findex Normalize_Scalars
3376 @noindent
3377 Syntax:
3378
3379 @smallexample @c ada
3380 pragma Normalize_Scalars;
3381 @end smallexample
3382
3383 @noindent
3384 This is a language defined pragma which is fully implemented in GNAT@.  The
3385 effect is to cause all scalar objects that are not otherwise initialized
3386 to be initialized.  The initial values are implementation dependent and
3387 are as follows:
3388
3389 @table @code
3390 @item Standard.Character
3391 @noindent
3392 Objects whose root type is Standard.Character are initialized to
3393 Character'Last unless the subtype range excludes NUL (in which case
3394 NUL is used). This choice will always generate an invalid value if
3395 one exists.
3396
3397 @item Standard.Wide_Character
3398 @noindent
3399 Objects whose root type is Standard.Wide_Character are initialized to
3400 Wide_Character'Last unless the subtype range excludes NUL (in which case
3401 NUL is used). This choice will always generate an invalid value if
3402 one exists.
3403
3404 @item Standard.Wide_Wide_Character
3405 @noindent
3406 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3407 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3408 which case NUL is used). This choice will always generate an invalid value if
3409 one exists.
3410
3411 @item Integer types
3412 @noindent
3413 Objects of an integer type are treated differently depending on whether
3414 negative values are present in the subtype. If no negative values are
3415 present, then all one bits is used as the initial value except in the
3416 special case where zero is excluded from the subtype, in which case
3417 all zero bits are used. This choice will always generate an invalid
3418 value if one exists.
3419
3420 For subtypes with negative values present, the largest negative number
3421 is used, except in the unusual case where this largest negative number
3422 is in the subtype, and the largest positive number is not, in which case
3423 the largest positive value is used. This choice will always generate
3424 an invalid value if one exists.
3425
3426 @item Floating-Point Types
3427 Objects of all floating-point types are initialized to all 1-bits. For
3428 standard IEEE format, this corresponds to a NaN (not a number) which is
3429 indeed an invalid value.
3430
3431 @item Fixed-Point Types
3432 Objects of all fixed-point types are treated as described above for integers,
3433 with the rules applying to the underlying integer value used to represent
3434 the fixed-point value.
3435
3436 @item Modular types
3437 Objects of a modular type are initialized to all one bits, except in
3438 the special case where zero is excluded from the subtype, in which
3439 case all zero bits are used. This choice will always generate an
3440 invalid value if one exists.
3441
3442 @item Enumeration types
3443 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3444 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3445 whose Pos value is zero, in which case a code of zero is used. This choice
3446 will always generate an invalid value if one exists.
3447
3448 @end table
3449
3450 @node Pragma Obsolescent
3451 @unnumberedsec Pragma Obsolescent
3452 @findex Obsolescent
3453 @noindent
3454 Syntax:
3455
3456 @smallexample @c ada
3457 pragma Obsolescent;
3458
3459 pragma Obsolescent (
3460   [Message =>] static_string_EXPRESSION
3461 [,[Version =>] Ada_05]]);
3462
3463 pragma Obsolescent (
3464   [Entity  =>] NAME
3465 [,[Message =>] static_string_EXPRESSION
3466 [,[Version =>] Ada_05]] );
3467 @end smallexample
3468
3469 @noindent
3470 This pragma can occur immediately following a declaration of an entity,
3471 including the case of a record component. If no Entity argument is present,
3472 then this declaration is the one to which the pragma applies. If an Entity
3473 parameter is present, it must either match the name of the entity in this
3474 declaration, or alternatively, the pragma can immediately follow an enumeration
3475 type declaration, where the Entity argument names one of the enumeration
3476 literals.
3477
3478 This pragma is used to indicate that the named entity
3479 is considered obsolescent and should not be used. Typically this is
3480 used when an API must be modified by eventually removing or modifying
3481 existing subprograms or other entities. The pragma can be used at an
3482 intermediate stage when the entity is still present, but will be
3483 removed later.
3484
3485 The effect of this pragma is to output a warning message on a reference to
3486 an entity thus marked that the subprogram is obsolescent if the appropriate
3487 warning option in the compiler is activated. If the Message parameter is
3488 present, then a second warning message is given containing this text. In
3489 addition, a reference to the eneity is considered to be a violation of pragma
3490 Restrictions (No_Obsolescent_Features).
3491
3492 This pragma can also be used as a program unit pragma for a package,
3493 in which case the entity name is the name of the package, and the
3494 pragma indicates that the entire package is considered
3495 obsolescent. In this case a client @code{with}'ing such a package
3496 violates the restriction, and the @code{with} statement is
3497 flagged with warnings if the warning option is set.
3498
3499 If the Version parameter is present (which must be exactly
3500 the identifier Ada_05, no other argument is allowed), then the
3501 indication of obsolescence applies only when compiling in Ada 2005
3502 mode. This is primarily intended for dealing with the situations
3503 in the predefined library where subprograms or packages
3504 have become defined as obsolescent in Ada 2005
3505 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3506
3507 The following examples show typical uses of this pragma:
3508
3509 @smallexample @c ada
3510 package p is
3511    pragma Obsolescent (p, Message => "use pp instead of p");
3512 end p;
3513
3514 package q is
3515    procedure q2;
3516    pragma Obsolescent ("use q2new instead");
3517
3518    type R is new integer;
3519    pragma Obsolescent
3520      (Entity  => R,
3521       Message => "use RR in Ada 2005",
3522       Version => Ada_05);
3523
3524    type M is record
3525       F1 : Integer;
3526       F2 : Integer;
3527       pragma Obsolescent;
3528       F3 : Integer;
3529    end record;
3530
3531    type E is (a, bc, 'd', quack);
3532    pragma Obsolescent (Entity => bc)
3533    pragma Obsolescent (Entity => 'd')
3534
3535    function "+"
3536      (a, b : character) return character;
3537    pragma Obsolescent (Entity => "+");
3538 end;
3539 @end smallexample
3540
3541 @noindent
3542 Note that, as for all pragmas, if you use a pragma argument identifier,
3543 then all subsequent parameters must also use a pragma argument identifier.
3544 So if you specify "Entity =>" for the Entity argument, and a Message
3545 argument is present, it must be preceded by "Message =>".
3546
3547 @node Pragma Optimize_Alignment
3548 @unnumberedsec Pragma Optimize_Alignment
3549 @findex Optimize_Alignment
3550 @cindex Alignment, default settings
3551 @noindent
3552 Syntax:
3553
3554 @smallexample @c ada
3555 pragma Optimize_Alignment (TIME | SPACE | OFF);
3556 @end smallexample
3557
3558 @noindent
3559 This is a configuration pragma which affects the choice of default alignments
3560 for types where no alignment is explicitly specified. There is a time/space
3561 trade-off in the selection of these values. Large alignments result in more
3562 efficient code, at the expense of larger data space, since sizes have to be
3563 increased to match these alignments. Smaller alignments save space, but the
3564 access code is slower. The normal choice of default alignments (which is what
3565 you get if you do not use this pragma, or if you use an argument of OFF),
3566 tries to balance these two requirements.
3567
3568 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3569 First any packed record is given an alignment of 1. Second, if a size is given
3570 for the type, then the alignment is chosen to avoid increasing this size. For
3571 example, consider:
3572
3573 @smallexample @c ada
3574    type R is record
3575       X : Integer;
3576       Y : Character;
3577    end record;
3578
3579    for R'Size use 5*8;
3580 @end smallexample
3581
3582 @noindent
3583 In the default mode, this type gets an alignment of 4, so that access to the
3584 Integer field X are efficient. But this means that objects of the type end up
3585 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3586 allowed to be bigger than the size of the type, but it can waste space if for
3587 example fields of type R appear in an enclosing record. If the above type is
3588 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3589
3590 Specifying TIME causes larger default alignments to be chosen in the case of
3591 small types with sizes that are not a power of 2. For example, consider:
3592
3593 @smallexample @c ada
3594    type R is record
3595       A : Character;
3596       B : Character;
3597       C : Boolean;
3598    end record;
3599
3600    pragma Pack (R);
3601    for R'Size use 17;
3602 @end smallexample
3603
3604 @noindent
3605 The default alignment for this record is normally 1, but if this type is
3606 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3607 to 4, which wastes space for objects of the type, since they are now 4 bytes
3608 long, but results in more efficient access when the whole record is referenced.
3609
3610 As noted above, this is a configuration pragma, and there is a requirement
3611 that all units in a partition be compiled with a consistent setting of the
3612 optimization setting. This would normally be achieved by use of a configuration
3613 pragma file containing the appropriate setting. The exception to this rule is
3614 that units with an explicit configuration pragma in the same file as the source
3615 unit are excluded from the consistency check, as are all predefined units. The
3616 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3617 pragma appears at the start of the file.
3618
3619 @node Pragma Passive
3620 @unnumberedsec Pragma Passive
3621 @findex Passive
3622 @noindent
3623 Syntax:
3624
3625 @smallexample @c ada
3626 pragma Passive [(Semaphore | No)];
3627 @end smallexample
3628
3629 @noindent
3630 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3631 compatibility with DEC Ada 83 implementations, where it is used within a
3632 task definition to request that a task be made passive.  If the argument
3633 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3634 treats the pragma as an assertion that the containing task is passive
3635 and that optimization of context switch with this task is permitted and
3636 desired.  If the argument @code{No} is present, the task must not be
3637 optimized.  GNAT does not attempt to optimize any tasks in this manner
3638 (since protected objects are available in place of passive tasks).
3639
3640 @node Pragma Persistent_BSS
3641 @unnumberedsec Pragma Persistent_BSS
3642 @findex Persistent_BSS
3643 @noindent
3644 Syntax:
3645
3646 @smallexample @c ada
3647 pragma Persistent_BSS [(LOCAL_NAME)]
3648 @end smallexample
3649
3650 @noindent
3651 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3652 section. On some targets the linker and loader provide for special
3653 treatment of this section, allowing a program to be reloaded without
3654 affecting the contents of this data (hence the name persistent).
3655
3656 There are two forms of usage. If an argument is given, it must be the
3657 local name of a library level object, with no explicit initialization
3658 and whose type is potentially persistent. If no argument is given, then
3659 the pragma is a configuration pragma, and applies to all library level
3660 objects with no explicit initialization of potentially persistent types.
3661
3662 A potentially persistent type is a scalar type, or a non-tagged,
3663 non-discriminated record, all of whose components have no explicit
3664 initialization and are themselves of a potentially persistent type,
3665 or an array, all of whose constraints are static, and whose component
3666 type is potentially persistent.
3667
3668 If this pragma is used on a target where this feature is not supported,
3669 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3670
3671 @node Pragma Polling
3672 @unnumberedsec Pragma Polling
3673 @findex Polling
3674 @noindent
3675 Syntax:
3676
3677 @smallexample @c ada
3678 pragma Polling (ON | OFF);
3679 @end smallexample
3680
3681 @noindent
3682 This pragma controls the generation of polling code.  This is normally off.
3683 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3684 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3685 runtime library, and can be found in file @file{a-excpol.adb}.
3686
3687 Pragma @code{Polling} can appear as a configuration pragma (for example it
3688 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3689 can be used in the statement or declaration sequence to control polling
3690 more locally.
3691
3692 A call to the polling routine is generated at the start of every loop and
3693 at the start of every subprogram call.  This guarantees that the @code{Poll}
3694 routine is called frequently, and places an upper bound (determined by
3695 the complexity of the code) on the period between two @code{Poll} calls.
3696
3697 The primary purpose of the polling interface is to enable asynchronous
3698 aborts on targets that cannot otherwise support it (for example Windows
3699 NT), but it may be used for any other purpose requiring periodic polling.
3700 The standard version is null, and can be replaced by a user program.  This
3701 will require re-compilation of the @code{Ada.Exceptions} package that can
3702 be found in files @file{a-except.ads} and @file{a-except.adb}.
3703
3704 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3705 distribution) is used to enable the asynchronous abort capability on
3706 targets that do not normally support the capability.  The version of
3707 @code{Poll} in this file makes a call to the appropriate runtime routine
3708 to test for an abort condition.
3709
3710 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3711 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3712 details.
3713
3714 @node Pragma Postcondition
3715 @unnumberedsec Pragma Postcondition
3716 @cindex Postconditions
3717 @cindex Checks, postconditions
3718 @findex Postconditions
3719 @noindent
3720 Syntax:
3721
3722 @smallexample @c ada
3723 pragma Postcondition (
3724    [Check   =>] Boolean_Expression
3725  [,[Message =>] String_Expression]);
3726 @end smallexample
3727
3728 @noindent
3729 The @code{Postcondition} pragma allows specification of automatic
3730 postcondition checks for subprograms. These checks are similar to
3731 assertions, but are automatically inserted just prior to the return
3732 statements of the subprogram with which they are associated (including
3733 implicit returns at the end of procedure bodies and associated
3734 exception handlers).
3735
3736 In addition, the boolean expression which is the condition which
3737 must be true may contain references to function'Result in the case
3738 of a function to refer to the returned value.
3739
3740 @code{Postcondition} pragmas may appear either immediate following the
3741 (separate) declaration of a subprogram, or at the start of the
3742 declarations of a subprogram body. Only other pragmas may intervene
3743 (that is appear between the subprogram declaration and its
3744 postconditions, or appear before the postcondition in the
3745 declaration sequence in a subprogram body). In the case of a
3746 postcondition appearing after a subprogram declaration, the
3747 formal arguments of the subprogram are visible, and can be
3748 referenced in the postcondition expressions.
3749
3750 The postconditions are collected and automatically tested just
3751 before any return (implicit or explicit) in the subprogram body.
3752 A postcondition is only recognized if postconditions are active
3753 at the time the pragma is encountered. The compiler switch @option{gnata}
3754 turns on all postconditions by default, and pragma @code{Check_Policy}
3755 with an identifier of @code{Postcondition} can also be used to
3756 control whether postconditions are active.
3757
3758 The general approach is that postconditions are placed in the spec
3759 if they represent functional aspects which make sense to the client.
3760 For example we might have:
3761
3762 @smallexample @c ada
3763    function Direction return Integer;
3764    pragma Postcondition
3765     (Direction'Result = +1
3766        or else
3767      Direction'Result = -1);
3768 @end smallexample
3769
3770 @noindent
3771 which serves to document that the result must be +1 or -1, and
3772 will test that this is the case at run time if postcondition
3773 checking is active.
3774
3775 Postconditions within the subprogram body can be used to
3776 check that some internal aspect of the implementation,
3777 not visible to the client, is operating as expected.
3778 For instance if a square root routine keeps an internal
3779 counter of the number of times it is called, then we
3780 might have the following postcondition:
3781
3782 @smallexample @c ada
3783    Sqrt_Calls : Natural := 0;
3784
3785    function Sqrt (Arg : Float) return Float is
3786      pragma Postcondition
3787        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3788      ...
3789    end Sqrt
3790 @end smallexample
3791
3792 @noindent
3793 As this example, shows, the use of the @code{Old} attribute
3794 is often useful in postconditions to refer to the state on
3795 entry to the subprogram.
3796
3797 Note that postconditions are only checked on normal returns
3798 from the subprogram. If an abnormal return results from
3799 raising an exception, then the postconditions are not checked.
3800
3801 If a postcondition fails, then the exception
3802 @code{System.Assertions.Assert_Failure} is raised. If
3803 a message argument was supplied, then the given string
3804 will be used as the exception message. If no message
3805 argument was supplied, then the default message has
3806 the form "Postcondition failed at file:line". The
3807 exception is raised in the context of the subprogram
3808 body, so it is possible to catch postcondition failures
3809 within the subprogram body itself.
3810
3811 Within a package spec, normal visibility rules
3812 in Ada would prevent forward references within a
3813 postcondition pragma to functions defined later in
3814 the same package. This would introduce undesirable
3815 ordering constraints. To avoid this problem, all
3816 postcondition pragmas are analyzed at the end of
3817 the package spec, allowing forward references.
3818
3819 The following example shows that this even allows
3820 mutually recursive postconditions as in:
3821
3822 @smallexample @c ada
3823 package Parity_Functions is
3824    function Odd  (X : Natural) return Boolean;
3825    pragma Postcondition
3826      (Odd'Result =
3827         (x = 1
3828           or else
3829         (x /= 0 and then Even (X - 1))));
3830
3831    function Even (X : Natural) return Boolean;
3832    pragma Postcondition
3833      (Even'Result =
3834         (x = 0
3835           or else
3836         (x /= 1 and then Odd (X - 1))));
3837
3838 end Parity_Functions;
3839 @end smallexample
3840
3841 @noindent
3842 There are no restrictions on the complexity or form of
3843 conditions used within @code{Postcondition} pragmas.
3844 The following example shows that it is even possible
3845 to verify performance behavior.
3846
3847 @smallexample @c ada
3848 package Sort is
3849
3850    Performance : constant Float;
3851    --  Performance constant set by implementation
3852    --  to match target architecture behavior.
3853
3854    procedure Treesort (Arg : String);
3855    --  Sorts characters of argument using N*logN sort
3856    pragma Postcondition
3857      (Float (Clock - Clock'Old) <=
3858         Float (Arg'Length) *
3859         log (Float (Arg'Length)) *
3860         Performance);
3861 end Sort;
3862 @end smallexample
3863
3864 @noindent
3865 Note: postcondition pragmas associated with subprograms that are
3866 marked as Inline_Always, or those marked as Inline with front-end
3867 inlining (-gnatN option set) are accepted and legality-checked
3868 by the compiler, but are ignored at run-time even if postcondition
3869 checking is enabled.
3870
3871 @node Pragma Precondition
3872 @unnumberedsec Pragma Precondition
3873 @cindex Preconditions
3874 @cindex Checks, preconditions
3875 @findex Preconditions
3876 @noindent
3877 Syntax:
3878
3879 @smallexample @c ada
3880 pragma Precondition (
3881    [Check   =>] Boolean_Expression
3882  [,[Message =>] String_Expression]);
3883 @end smallexample
3884
3885 @noindent
3886 The @code{Precondition} pragma is similar to @code{Postcondition}
3887 except that the corresponding checks take place immediately upon
3888 entry to the subprogram, and if a precondition fails, the exception
3889 is raised in the context of the caller, and the attribute 'Result
3890 cannot be used within the precondition expression.
3891
3892 Otherwise, the placement and visibility rules are identical to those
3893 described for postconditions. The following is an example of use
3894 within a package spec:
3895
3896 @smallexample @c ada
3897 package Math_Functions is
3898    ...
3899    function Sqrt (Arg : Float) return Float;
3900    pragma Precondition (Arg >= 0.0)
3901    ...
3902 end Math_Functions;
3903 @end smallexample
3904
3905 @noindent
3906 @code{Precondition} pragmas may appear either immediate following the
3907 (separate) declaration of a subprogram, or at the start of the
3908 declarations of a subprogram body. Only other pragmas may intervene
3909 (that is appear between the subprogram declaration and its
3910 postconditions, or appear before the postcondition in the
3911 declaration sequence in a subprogram body).
3912
3913 Note: postcondition pragmas associated with subprograms that are
3914 marked as Inline_Always, or those marked as Inline with front-end
3915 inlining (-gnatN option set) are accepted and legality-checked
3916 by the compiler, but are ignored at run-time even if postcondition
3917 checking is enabled.
3918
3919
3920
3921 @node Pragma Profile (Ravenscar)
3922 @unnumberedsec Pragma Profile (Ravenscar)
3923 @findex Ravenscar
3924 @noindent
3925 Syntax:
3926
3927 @smallexample @c ada
3928 pragma Profile (Ravenscar);
3929 @end smallexample
3930
3931 @noindent
3932 A configuration pragma that establishes the following set of configuration
3933 pragmas:
3934
3935 @table @code
3936 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3937 [RM D.2.2] Tasks are dispatched following a preemptive
3938 priority-ordered scheduling policy.
3939
3940 @item Locking_Policy (Ceiling_Locking)
3941 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3942 the ceiling priority of the corresponding protected object.
3943 @c
3944 @c @item Detect_Blocking
3945 @c This pragma forces the detection of potentially blocking operations within a
3946 @c protected operation, and to raise Program_Error if that happens.
3947 @end table
3948 @noindent
3949
3950 plus the following set of restrictions:
3951
3952 @table @code
3953 @item Max_Entry_Queue_Length = 1
3954 Defines the maximum number of calls that are queued on a (protected) entry.
3955 Note that this restrictions is checked at run time. Violation of this
3956 restriction results in the raising of Program_Error exception at the point of
3957 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3958 always 1 and hence no task can be queued on a protected entry.
3959
3960 @item Max_Protected_Entries = 1
3961 [RM D.7] Specifies the maximum number of entries per protected type. The
3962 bounds of every entry family of a protected unit shall be static, or shall be
3963 defined by a discriminant of a subtype whose corresponding bound is static.
3964 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3965
3966 @item Max_Task_Entries = 0
3967 [RM D.7] Specifies the maximum number of entries
3968 per task.  The bounds of every entry family
3969 of a task unit shall be static, or shall be
3970 defined by a discriminant of a subtype whose
3971 corresponding bound is static.  A value of zero
3972 indicates that no rendezvous are possible.  For
3973 the Profile (Ravenscar), the value of Max_Task_Entries is always
3974 0 (zero).
3975
3976 @item No_Abort_Statements
3977 [RM D.7] There are no abort_statements, and there are
3978 no calls to Task_Identification.Abort_Task.
3979
3980 @item No_Asynchronous_Control
3981 There are no semantic dependences on the package
3982 Asynchronous_Task_Control.
3983
3984 @item No_Calendar
3985 There are no semantic dependencies on the package Ada.Calendar.
3986
3987 @item No_Dynamic_Attachment
3988 There is no call to any of the operations defined in package Ada.Interrupts
3989 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3990 Detach_Handler, and Reference).
3991
3992 @item No_Dynamic_Priorities
3993 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3994
3995 @item No_Implicit_Heap_Allocations
3996 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3997
3998 @item No_Local_Protected_Objects
3999 Protected objects and access types that designate
4000 such objects shall be declared only at library level.
4001
4002 @item No_Local_Timing_Events
4003 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4004 declared at the library level.
4005
4006 @item No_Protected_Type_Allocators
4007 There are no allocators for protected types or
4008 types containing protected subcomponents.
4009
4010 @item No_Relative_Delay
4011 There are no delay_relative statements.
4012
4013 @item No_Requeue_Statements
4014 Requeue statements are not allowed.
4015
4016 @item No_Select_Statements
4017 There are no select_statements.
4018
4019 @item No_Specific_Termination_Handlers
4020 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4021 or to Ada.Task_Termination.Specific_Handler.
4022
4023 @item No_Task_Allocators
4024 [RM D.7] There are no allocators for task types
4025 or types containing task subcomponents.
4026
4027 @item No_Task_Attributes_Package
4028 There are no semantic dependencies on the Ada.Task_Attributes package.
4029
4030 @item No_Task_Hierarchy
4031 [RM D.7] All (non-environment) tasks depend
4032 directly on the environment task of the partition.
4033
4034 @item No_Task_Termination
4035 Tasks which terminate are erroneous.
4036
4037 @item No_Unchecked_Conversion
4038 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4039
4040 @item No_Unchecked_Deallocation
4041 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4042
4043 @item Simple_Barriers
4044 Entry barrier condition expressions shall be either static
4045 boolean expressions or boolean objects which are declared in
4046 the protected type which contains the entry.
4047 @end table
4048
4049 @noindent
4050 This set of configuration pragmas and restrictions correspond to the
4051 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4052 published by the @cite{International Real-Time Ada Workshop}, 1997,
4053 and whose most recent description is available at
4054 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4055
4056 The original definition of the profile was revised at subsequent IRTAW
4057 meetings. It has been included in the ISO
4058 @cite{Guide for the Use of the Ada Programming Language in High
4059 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4060 the next revision of the standard. The formal definition given by
4061 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4062 AI-305) available at
4063 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4064 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4065 respectively.
4066
4067 The above set is a superset of the restrictions provided by pragma
4068 @code{Profile (Restricted)}, it includes six additional restrictions
4069 (@code{Simple_Barriers}, @code{No_Select_Statements},
4070 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4071 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4072 that pragma @code{Profile (Ravenscar)}, like the pragma
4073 @code{Profile (Restricted)},
4074 automatically causes the use of a simplified,
4075 more efficient version of the tasking run-time system.
4076
4077 @node Pragma Profile (Restricted)
4078 @unnumberedsec Pragma Profile (Restricted)
4079 @findex Restricted Run Time
4080 @noindent
4081 Syntax:
4082
4083 @smallexample @c ada
4084 pragma Profile (Restricted);
4085 @end smallexample
4086
4087 @noindent
4088 A configuration pragma that establishes the following set of restrictions:
4089
4090 @itemize @bullet
4091 @item No_Abort_Statements
4092 @item No_Entry_Queue
4093 @item No_Task_Hierarchy
4094 @item No_Task_Allocators
4095 @item No_Dynamic_Priorities
4096 @item No_Terminate_Alternatives
4097 @item No_Dynamic_Attachment
4098 @item No_Protected_Type_Allocators
4099 @item No_Local_Protected_Objects
4100 @item No_Requeue_Statements
4101 @item No_Task_Attributes_Package
4102 @item Max_Asynchronous_Select_Nesting =  0
4103 @item Max_Task_Entries =  0
4104 @item Max_Protected_Entries = 1
4105 @item Max_Select_Alternatives = 0
4106 @end itemize
4107
4108 @noindent
4109 This set of restrictions causes the automatic selection of a simplified
4110 version of the run time that provides improved performance for the
4111 limited set of tasking functionality permitted by this set of restrictions.
4112
4113 @node Pragma Psect_Object
4114 @unnumberedsec Pragma Psect_Object
4115 @findex Psect_Object
4116 @noindent
4117 Syntax:
4118
4119 @smallexample @c ada
4120 pragma Psect_Object (
4121      [Internal =>] LOCAL_NAME,
4122   [, [External =>] EXTERNAL_SYMBOL]
4123   [, [Size     =>] EXTERNAL_SYMBOL]);
4124
4125 EXTERNAL_SYMBOL ::=
4126   IDENTIFIER
4127 | static_string_EXPRESSION
4128 @end smallexample
4129
4130 @noindent
4131 This pragma is identical in effect to pragma @code{Common_Object}.
4132
4133 @node Pragma Pure_Function
4134 @unnumberedsec Pragma Pure_Function
4135 @findex Pure_Function
4136 @noindent
4137 Syntax:
4138
4139 @smallexample @c ada
4140 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4141 @end smallexample
4142
4143 @noindent
4144 This pragma appears in the same declarative part as a function
4145 declaration (or a set of function declarations if more than one
4146 overloaded declaration exists, in which case the pragma applies
4147 to all entities).  It specifies that the function @code{Entity} is
4148 to be considered pure for the purposes of code generation.  This means
4149 that the compiler can assume that there are no side effects, and
4150 in particular that two calls with identical arguments produce the
4151 same result.  It also means that the function can be used in an
4152 address clause.
4153
4154 Note that, quite deliberately, there are no static checks to try
4155 to ensure that this promise is met, so @code{Pure_Function} can be used
4156 with functions that are conceptually pure, even if they do modify
4157 global variables.  For example, a square root function that is
4158 instrumented to count the number of times it is called is still
4159 conceptually pure, and can still be optimized, even though it
4160 modifies a global variable (the count).  Memo functions are another
4161 example (where a table of previous calls is kept and consulted to
4162 avoid re-computation).
4163
4164 @findex Pure
4165 Note: Most functions in a @code{Pure} package are automatically pure, and
4166 there is no need to use pragma @code{Pure_Function} for such functions.  One
4167 exception is any function that has at least one formal of type
4168 @code{System.Address} or a type derived from it.  Such functions are not
4169 considered pure by default, since the compiler assumes that the
4170 @code{Address} parameter may be functioning as a pointer and that the
4171 referenced data may change even if the address value does not.
4172 Similarly, imported functions are not considered to be pure by default,
4173 since there is no way of checking that they are in fact pure.  The use
4174 of pragma @code{Pure_Function} for such a function will override these default
4175 assumption, and cause the compiler to treat a designated subprogram as pure
4176 in these cases.
4177
4178 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4179 applies to the underlying renamed function.  This can be used to
4180 disambiguate cases of overloading where some but not all functions
4181 in a set of overloaded functions are to be designated as pure.
4182
4183 If pragma @code{Pure_Function} is applied to a library level function, the
4184 function is also considered pure from an optimization point of view, but the
4185 unit is not a Pure unit in the categorization sense. So for example, a function
4186 thus marked is free to @code{with} non-pure units.
4187
4188 @node Pragma Restriction_Warnings
4189 @unnumberedsec Pragma Restriction_Warnings
4190 @findex Restriction_Warnings
4191 @noindent
4192 Syntax:
4193
4194 @smallexample @c ada
4195 pragma Restriction_Warnings
4196   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4197 @end smallexample
4198
4199 @noindent
4200 This pragma allows a series of restriction identifiers to be
4201 specified (the list of allowed identifiers is the same as for
4202 pragma @code{Restrictions}). For each of these identifiers
4203 the compiler checks for violations of the restriction, but
4204 generates a warning message rather than an error message
4205 if the restriction is violated.
4206
4207 @node Pragma Shared
4208 @unnumberedsec Pragma Shared
4209 @findex Shared
4210
4211 @noindent
4212 This pragma is provided for compatibility with Ada 83. The syntax and
4213 semantics are identical to pragma Atomic.
4214
4215 @node Pragma Source_File_Name
4216 @unnumberedsec Pragma Source_File_Name
4217 @findex Source_File_Name
4218 @noindent
4219 Syntax:
4220
4221 @smallexample @c ada
4222 pragma Source_File_Name (
4223   [Unit_Name   =>] unit_NAME,
4224   Spec_File_Name =>  STRING_LITERAL,
4225   [Index => INTEGER_LITERAL]);
4226
4227 pragma Source_File_Name (
4228   [Unit_Name   =>] unit_NAME,
4229   Body_File_Name =>  STRING_LITERAL,
4230   [Index => INTEGER_LITERAL]);
4231 @end smallexample
4232
4233 @noindent
4234 Use this to override the normal naming convention.  It is a configuration
4235 pragma, and so has the usual applicability of configuration pragmas
4236 (i.e.@: it applies to either an entire partition, or to all units in a
4237 compilation, or to a single unit, depending on how it is used.
4238 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4239 the second argument is required, and indicates whether this is the file
4240 name for the spec or for the body.
4241
4242 The optional Index argument should be used when a file contains multiple
4243 units, and when you do not want to use @code{gnatchop} to separate then
4244 into multiple files (which is the recommended procedure to limit the
4245 number of recompilation that are needed when some sources change).
4246 For instance, if the source file @file{source.ada} contains
4247
4248 @smallexample @c ada
4249 package B is
4250 ...
4251 end B;
4252
4253 with B;
4254 procedure A is
4255 begin
4256    ..
4257 end A;
4258 @end smallexample
4259
4260 you could use the following configuration pragmas:
4261
4262 @smallexample @c ada
4263 pragma Source_File_Name
4264   (B, Spec_File_Name => "source.ada", Index => 1);
4265 pragma Source_File_Name
4266   (A, Body_File_Name => "source.ada", Index => 2);
4267 @end smallexample
4268
4269 Note that the @code{gnatname} utility can also be used to generate those
4270 configuration pragmas.
4271
4272 Another form of the @code{Source_File_Name} pragma allows
4273 the specification of patterns defining alternative file naming schemes
4274 to apply to all files.
4275
4276 @smallexample @c ada
4277 pragma Source_File_Name
4278   (  [Spec_File_Name  =>] STRING_LITERAL
4279    [,[Casing          =>] CASING_SPEC]
4280    [,[Dot_Replacement =>] STRING_LITERAL]);
4281
4282 pragma Source_File_Name
4283   (  [Body_File_Name  =>] STRING_LITERAL
4284    [,[Casing          =>] CASING_SPEC]
4285    [,[Dot_Replacement =>] STRING_LITERAL]);
4286
4287 pragma Source_File_Name
4288   (  [Subunit_File_Name =>] STRING_LITERAL
4289    [,[Casing            =>] CASING_SPEC]
4290    [,[Dot_Replacement   =>] STRING_LITERAL]);
4291
4292 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4293 @end smallexample
4294
4295 @noindent
4296 The first argument is a pattern that contains a single asterisk indicating
4297 the point at which the unit name is to be inserted in the pattern string
4298 to form the file name.  The second argument is optional.  If present it
4299 specifies the casing of the unit name in the resulting file name string.
4300 The default is lower case.  Finally the third argument allows for systematic
4301 replacement of any dots in the unit name by the specified string literal.
4302
4303 A pragma Source_File_Name cannot appear after a
4304 @ref{Pragma Source_File_Name_Project}.
4305
4306 For more details on the use of the @code{Source_File_Name} pragma,
4307 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4308 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4309 User's Guide}.
4310
4311 @node Pragma Source_File_Name_Project
4312 @unnumberedsec Pragma Source_File_Name_Project
4313 @findex Source_File_Name_Project
4314 @noindent
4315
4316 This pragma has the same syntax and semantics as pragma Source_File_Name.
4317 It is only allowed as a stand alone configuration pragma.
4318 It cannot appear after a @ref{Pragma Source_File_Name}, and
4319 most importantly, once pragma Source_File_Name_Project appears,
4320 no further Source_File_Name pragmas are allowed.
4321
4322 The intention is that Source_File_Name_Project pragmas are always
4323 generated by the Project Manager in a manner consistent with the naming
4324 specified in a project file, and when naming is controlled in this manner,
4325 it is not permissible to attempt to modify this naming scheme using
4326 Source_File_Name pragmas (which would not be known to the project manager).
4327
4328 @node Pragma Source_Reference
4329 @unnumberedsec Pragma Source_Reference
4330 @findex Source_Reference
4331 @noindent
4332 Syntax:
4333
4334 @smallexample @c ada
4335 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4336 @end smallexample
4337
4338 @noindent
4339 This pragma must appear as the first line of a source file.
4340 @var{integer_literal} is the logical line number of the line following
4341 the pragma line (for use in error messages and debugging
4342 information).  @var{string_literal} is a static string constant that
4343 specifies the file name to be used in error messages and debugging
4344 information.  This is most notably used for the output of @code{gnatchop}
4345 with the @option{-r} switch, to make sure that the original unchopped
4346 source file is the one referred to.
4347
4348 The second argument must be a string literal, it cannot be a static
4349 string expression other than a string literal.  This is because its value
4350 is needed for error messages issued by all phases of the compiler.
4351
4352 @node Pragma Stream_Convert
4353 @unnumberedsec Pragma Stream_Convert
4354 @findex Stream_Convert
4355 @noindent
4356 Syntax:
4357
4358 @smallexample @c ada
4359 pragma Stream_Convert (
4360   [Entity =>] type_LOCAL_NAME,
4361   [Read   =>] function_NAME,
4362   [Write  =>] function_NAME);
4363 @end smallexample
4364
4365 @noindent
4366 This pragma provides an efficient way of providing stream functions for
4367 types defined in packages.  Not only is it simpler to use than declaring
4368 the necessary functions with attribute representation clauses, but more
4369 significantly, it allows the declaration to made in such a way that the
4370 stream packages are not loaded unless they are needed.  The use of
4371 the Stream_Convert pragma adds no overhead at all, unless the stream
4372 attributes are actually used on the designated type.
4373
4374 The first argument specifies the type for which stream functions are
4375 provided.  The second parameter provides a function used to read values
4376 of this type.  It must name a function whose argument type may be any
4377 subtype, and whose returned type must be the type given as the first
4378 argument to the pragma.
4379
4380 The meaning of the @var{Read}
4381 parameter is that if a stream attribute directly
4382 or indirectly specifies reading of the type given as the first parameter,
4383 then a value of the type given as the argument to the Read function is
4384 read from the stream, and then the Read function is used to convert this
4385 to the required target type.
4386
4387 Similarly the @var{Write} parameter specifies how to treat write attributes
4388 that directly or indirectly apply to the type given as the first parameter.
4389 It must have an input parameter of the type specified by the first parameter,
4390 and the return type must be the same as the input type of the Read function.
4391 The effect is to first call the Write function to convert to the given stream
4392 type, and then write the result type to the stream.
4393
4394 The Read and Write functions must not be overloaded subprograms.  If necessary
4395 renamings can be supplied to meet this requirement.
4396 The usage of this attribute is best illustrated by a simple example, taken
4397 from the GNAT implementation of package Ada.Strings.Unbounded:
4398
4399 @smallexample @c ada
4400 function To_Unbounded (S : String)
4401            return Unbounded_String
4402   renames To_Unbounded_String;
4403
4404 pragma Stream_Convert
4405   (Unbounded_String, To_Unbounded, To_String);
4406 @end smallexample
4407
4408 @noindent
4409 The specifications of the referenced functions, as given in the Ada
4410 Reference Manual are:
4411
4412 @smallexample @c ada
4413 function To_Unbounded_String (Source : String)
4414   return Unbounded_String;
4415
4416 function To_String (Source : Unbounded_String)
4417   return String;
4418 @end smallexample
4419
4420 @noindent
4421 The effect is that if the value of an unbounded string is written to a
4422 stream, then the representation of the item in the stream is in the same
4423 format used for @code{Standard.String}, and this same representation is
4424 expected when a value of this type is read from the stream.
4425
4426 @node Pragma Style_Checks
4427 @unnumberedsec Pragma Style_Checks
4428 @findex Style_Checks
4429 @noindent
4430 Syntax:
4431
4432 @smallexample @c ada
4433 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4434                      On | Off [, LOCAL_NAME]);
4435 @end smallexample
4436
4437 @noindent
4438 This pragma is used in conjunction with compiler switches to control the
4439 built in style checking provided by GNAT@.  The compiler switches, if set,
4440 provide an initial setting for the switches, and this pragma may be used
4441 to modify these settings, or the settings may be provided entirely by
4442 the use of the pragma.  This pragma can be used anywhere that a pragma
4443 is legal, including use as a configuration pragma (including use in
4444 the @file{gnat.adc} file).
4445
4446 The form with a string literal specifies which style options are to be
4447 activated.  These are additive, so they apply in addition to any previously
4448 set style check options.  The codes for the options are the same as those
4449 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4450 For example the following two methods can be used to enable
4451 layout checking:
4452
4453 @itemize @bullet
4454 @item
4455 @smallexample @c ada
4456 pragma Style_Checks ("l");
4457 @end smallexample
4458
4459 @item
4460 @smallexample
4461 gcc -c -gnatyl @dots{}
4462 @end smallexample
4463 @end itemize
4464
4465 @noindent
4466 The form ALL_CHECKS activates all standard checks (its use is equivalent
4467 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4468 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4469 @value{EDITION} User's Guide}, for details.
4470
4471 The forms with @code{Off} and @code{On}
4472 can be used to temporarily disable style checks
4473 as shown in the following example:
4474
4475 @smallexample @c ada
4476 @iftex
4477 @leftskip=0cm
4478 @end iftex
4479 pragma Style_Checks ("k"); -- requires keywords in lower case
4480 pragma Style_Checks (Off); -- turn off style checks
4481 NULL;                      -- this will not generate an error message
4482 pragma Style_Checks (On);  -- turn style checks back on
4483 NULL;                      -- this will generate an error message
4484 @end smallexample
4485
4486 @noindent
4487 Finally the two argument form is allowed only if the first argument is
4488 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4489 for the specified entity, as shown in the following example:
4490
4491 @smallexample @c ada
4492 @iftex
4493 @leftskip=0cm
4494 @end iftex
4495 pragma Style_Checks ("r"); -- require consistency of identifier casing
4496 Arg : Integer;
4497 Rf1 : Integer := ARG;      -- incorrect, wrong case
4498 pragma Style_Checks (Off, Arg);
4499 Rf2 : Integer := ARG;      -- OK, no error
4500 @end smallexample
4501
4502 @node Pragma Subtitle
4503 @unnumberedsec Pragma Subtitle
4504 @findex Subtitle
4505 @noindent
4506 Syntax:
4507
4508 @smallexample @c ada
4509 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4510 @end smallexample
4511
4512 @noindent
4513 This pragma is recognized for compatibility with other Ada compilers
4514 but is ignored by GNAT@.
4515
4516 @node Pragma Suppress
4517 @unnumberedsec Pragma Suppress
4518 @findex Suppress
4519 @noindent
4520 Syntax:
4521
4522 @smallexample @c ada
4523 pragma Suppress (Identifier [, [On =>] Name]);
4524 @end smallexample
4525
4526 @noindent
4527 This is a standard pragma, and supports all the check names required in
4528 the RM. It is included here because GNAT recognizes one additional check
4529 name: @code{Alignment_Check} which can be used to suppress alignment checks
4530 on addresses used in address clauses. Such checks can also be suppressed
4531 by suppressing range checks, but the specific use of @code{Alignment_Check}
4532 allows suppression of alignment checks without suppressing other range checks.
4533
4534 Note that pragma Suppress gives the compiler permission to omit
4535 checks, but does not require the compiler to omit checks. The compiler
4536 will generate checks if they are essentially free, even when they are
4537 suppressed. In particular, if the compiler can prove that a certain
4538 check will necessarily fail, it will generate code to do an
4539 unconditional ``raise'', even if checks are suppressed. The compiler
4540 warns in this case.
4541
4542 Of course, run-time checks are omitted whenever the compiler can prove
4543 that they will not fail, whether or not checks are suppressed.
4544
4545 @node Pragma Suppress_All
4546 @unnumberedsec Pragma Suppress_All
4547 @findex Suppress_All
4548 @noindent
4549 Syntax:
4550
4551 @smallexample @c ada
4552 pragma Suppress_All;
4553 @end smallexample
4554
4555 @noindent
4556 This pragma can only appear immediately following a compilation
4557 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4558 which it follows.  This pragma is implemented for compatibility with DEC
4559 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4560 configuration pragma is the preferred usage in GNAT@.
4561
4562 @node Pragma Suppress_Exception_Locations
4563 @unnumberedsec Pragma Suppress_Exception_Locations
4564 @findex Suppress_Exception_Locations
4565 @noindent
4566 Syntax:
4567
4568 @smallexample @c ada
4569 pragma Suppress_Exception_Locations;
4570 @end smallexample
4571
4572 @noindent
4573 In normal mode, a raise statement for an exception by default generates
4574 an exception message giving the file name and line number for the location
4575 of the raise. This is useful for debugging and logging purposes, but this
4576 entails extra space for the strings for the messages. The configuration
4577 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4578 generation of these strings, with the result that space is saved, but the
4579 exception message for such raises is null. This configuration pragma may
4580 appear in a global configuration pragma file, or in a specific unit as
4581 usual. It is not required that this pragma be used consistently within
4582 a partition, so it is fine to have some units within a partition compiled
4583 with this pragma and others compiled in normal mode without it.
4584
4585 @node Pragma Suppress_Initialization
4586 @unnumberedsec Pragma Suppress_Initialization
4587 @findex Suppress_Initialization
4588 @cindex Suppressing initialization
4589 @cindex Initialization, suppression of
4590 @noindent
4591 Syntax:
4592
4593 @smallexample @c ada
4594 pragma Suppress_Initialization ([Entity =>] type_Name);
4595 @end smallexample
4596
4597 @noindent
4598 This pragma suppresses any implicit or explicit initialization
4599 associated with the given type name for all variables of this type.
4600
4601 @node Pragma Task_Info
4602 @unnumberedsec Pragma Task_Info
4603 @findex Task_Info
4604 @noindent
4605 Syntax
4606
4607 @smallexample @c ada
4608 pragma Task_Info (EXPRESSION);
4609 @end smallexample
4610
4611 @noindent
4612 This pragma appears within a task definition (like pragma
4613 @code{Priority}) and applies to the task in which it appears.  The
4614 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4615 The @code{Task_Info} pragma provides system dependent control over
4616 aspects of tasking implementation, for example, the ability to map
4617 tasks to specific processors.  For details on the facilities available
4618 for the version of GNAT that you are using, see the documentation
4619 in the spec of package System.Task_Info in the runtime
4620 library.
4621
4622 @node Pragma Task_Name
4623 @unnumberedsec Pragma Task_Name
4624 @findex Task_Name
4625 @noindent
4626 Syntax
4627
4628 @smallexample @c ada
4629 pragma Task_Name (string_EXPRESSION);
4630 @end smallexample
4631
4632 @noindent
4633 This pragma appears within a task definition (like pragma
4634 @code{Priority}) and applies to the task in which it appears.  The
4635 argument must be of type String, and provides a name to be used for
4636 the task instance when the task is created.  Note that this expression
4637 is not required to be static, and in particular, it can contain
4638 references to task discriminants.  This facility can be used to
4639 provide different names for different tasks as they are created,
4640 as illustrated in the example below.
4641
4642 The task name is recorded internally in the run-time structures
4643 and is accessible to tools like the debugger.  In addition the
4644 routine @code{Ada.Task_Identification.Image} will return this
4645 string, with a unique task address appended.
4646
4647 @smallexample @c ada
4648 --  Example of the use of pragma Task_Name
4649
4650 with Ada.Task_Identification;
4651 use Ada.Task_Identification;
4652 with Text_IO; use Text_IO;
4653 procedure t3 is
4654
4655    type Astring is access String;
4656
4657    task type Task_Typ (Name : access String) is
4658       pragma Task_Name (Name.all);
4659    end Task_Typ;
4660
4661    task body Task_Typ is
4662       Nam : constant String := Image (Current_Task);
4663    begin
4664       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4665    end Task_Typ;
4666
4667    type Ptr_Task is access Task_Typ;
4668    Task_Var : Ptr_Task;
4669
4670 begin
4671    Task_Var :=
4672      new Task_Typ (new String'("This is task 1"));
4673    Task_Var :=
4674      new Task_Typ (new String'("This is task 2"));
4675 end;
4676 @end smallexample
4677
4678 @node Pragma Task_Storage
4679 @unnumberedsec Pragma Task_Storage
4680 @findex Task_Storage
4681 Syntax:
4682
4683 @smallexample @c ada
4684 pragma Task_Storage (
4685   [Task_Type =>] LOCAL_NAME,
4686   [Top_Guard =>] static_integer_EXPRESSION);
4687 @end smallexample
4688
4689 @noindent
4690 This pragma specifies the length of the guard area for tasks.  The guard
4691 area is an additional storage area allocated to a task.  A value of zero
4692 means that either no guard area is created or a minimal guard area is
4693 created, depending on the target.  This pragma can appear anywhere a
4694 @code{Storage_Size} attribute definition clause is allowed for a task
4695 type.
4696
4697 @node Pragma Thread_Local_Storage
4698 @unnumberedsec Pragma Thread_Local_Storage
4699 @findex Thread_Local_Storage
4700 @cindex Task specific storage
4701 @cindex TLS (Thread Local Storage)
4702 Syntax:
4703
4704 @smallexample @c ada
4705 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4706 @end smallexample
4707
4708 @noindent
4709 This pragma specifies that the specified entity, which must be
4710 a variable declared in a library level package, is to be marked as
4711 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4712 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4713 (and hence each Ada task) to see a distinct copy of the variable.
4714
4715 The variable may not have default initialization, and if there is
4716 an explicit initialization, it must be either @code{null} for an
4717 access variable, or a static expression for a scalar variable.
4718 This provides a low level mechanism similar to that provided by
4719 the @code{Ada.Task_Attributes} package, but much more efficient
4720 and is also useful in writing interface code that will interact
4721 with foreign threads.
4722
4723 If this pragma is used on a system where @code{TLS} is not supported,
4724 then an error message will be generated and the program will be rejected.
4725
4726 @node Pragma Time_Slice
4727 @unnumberedsec Pragma Time_Slice
4728 @findex Time_Slice
4729 @noindent
4730 Syntax:
4731
4732 @smallexample @c ada
4733 pragma Time_Slice (static_duration_EXPRESSION);
4734 @end smallexample
4735
4736 @noindent
4737 For implementations of GNAT on operating systems where it is possible
4738 to supply a time slice value, this pragma may be used for this purpose.
4739 It is ignored if it is used in a system that does not allow this control,
4740 or if it appears in other than the main program unit.
4741 @cindex OpenVMS
4742 Note that the effect of this pragma is identical to the effect of the
4743 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4744
4745 @node Pragma Title
4746 @unnumberedsec Pragma Title
4747 @findex Title
4748 @noindent
4749 Syntax:
4750
4751 @smallexample @c ada
4752 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4753
4754 TITLING_OPTION ::=
4755   [Title    =>] STRING_LITERAL,
4756 | [Subtitle =>] STRING_LITERAL
4757 @end smallexample
4758
4759 @noindent
4760 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4761 pragma used in DEC Ada 83 implementations to provide a title and/or
4762 subtitle for the program listing.  The program listing generated by GNAT
4763 does not have titles or subtitles.
4764
4765 Unlike other pragmas, the full flexibility of named notation is allowed
4766 for this pragma, i.e.@: the parameters may be given in any order if named
4767 notation is used, and named and positional notation can be mixed
4768 following the normal rules for procedure calls in Ada.
4769
4770 @node Pragma Unchecked_Union
4771 @unnumberedsec Pragma Unchecked_Union
4772 @cindex Unions in C
4773 @findex Unchecked_Union
4774 @noindent
4775 Syntax:
4776
4777 @smallexample @c ada
4778 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4779 @end smallexample
4780
4781 @noindent
4782 This pragma is used to specify a representation of a record type that is
4783 equivalent to a C union. It was introduced as a GNAT implementation defined
4784 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4785 pragma, making it language defined, and GNAT fully implements this extended
4786 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4787 details, consult the Ada 2005 Reference Manual, section B.3.3.
4788
4789 @node Pragma Unimplemented_Unit
4790 @unnumberedsec Pragma Unimplemented_Unit
4791 @findex Unimplemented_Unit
4792 @noindent
4793 Syntax:
4794
4795 @smallexample @c ada
4796 pragma Unimplemented_Unit;
4797 @end smallexample
4798
4799 @noindent
4800 If this pragma occurs in a unit that is processed by the compiler, GNAT
4801 aborts with the message @samp{@var{xxx} not implemented}, where
4802 @var{xxx} is the name of the current compilation unit.  This pragma is
4803 intended to allow the compiler to handle unimplemented library units in
4804 a clean manner.
4805
4806 The abort only happens if code is being generated.  Thus you can use
4807 specs of unimplemented packages in syntax or semantic checking mode.
4808
4809 @node Pragma Universal_Aliasing
4810 @unnumberedsec Pragma Universal_Aliasing
4811 @findex Universal_Aliasing
4812 @noindent
4813 Syntax:
4814
4815 @smallexample @c ada
4816 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4817 @end smallexample
4818
4819 @noindent
4820 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4821 declarative part.  The effect is to inhibit strict type-based aliasing
4822 optimization for the given type.  In other words, the effect is as though
4823 access types designating this type were subject to pragma No_Strict_Aliasing.
4824 For a detailed description of the strict aliasing optimization, and the
4825 situations in which it must be suppressed, @xref{Optimization and Strict
4826 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4827
4828 @node Pragma Universal_Data
4829 @unnumberedsec Pragma Universal_Data
4830 @findex Universal_Data
4831 @noindent
4832 Syntax:
4833
4834 @smallexample @c ada
4835 pragma Universal_Data [(library_unit_Name)];
4836 @end smallexample
4837
4838 @noindent
4839 This pragma is supported only for the AAMP target and is ignored for
4840 other targets. The pragma specifies that all library-level objects
4841 (Counter 0 data) associated with the library unit are to be accessed
4842 and updated using universal addressing (24-bit addresses for AAMP5)
4843 rather than the default of 16-bit Data Environment (DENV) addressing.
4844 Use of this pragma will generally result in less efficient code for
4845 references to global data associated with the library unit, but
4846 allows such data to be located anywhere in memory. This pragma is
4847 a library unit pragma, but can also be used as a configuration pragma
4848 (including use in the @file{gnat.adc} file). The functionality
4849 of this pragma is also available by applying the -univ switch on the
4850 compilations of units where universal addressing of the data is desired.
4851
4852 @node Pragma Unmodified
4853 @unnumberedsec Pragma Unmodified
4854 @findex Unmodified
4855 @cindex Warnings, unmodified
4856 @noindent
4857 Syntax:
4858
4859 @smallexample @c ada
4860 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4861 @end smallexample
4862
4863 @noindent
4864 This pragma signals that the assignable entities (variables,
4865 @code{out} parameters, @code{in out} parameters) whose names are listed are
4866 deliberately not assigned in the current source unit. This
4867 suppresses warnings about the
4868 entities being referenced but not assigned, and in addition a warning will be
4869 generated if one of these entities is in fact assigned in the
4870 same unit as the pragma (or in the corresponding body, or one
4871 of its subunits).
4872
4873 This is particularly useful for clearly signaling that a particular
4874 parameter is not modified, even though the spec suggests that it might
4875 be.
4876
4877 @node Pragma Unreferenced
4878 @unnumberedsec Pragma Unreferenced
4879 @findex Unreferenced
4880 @cindex Warnings, unreferenced
4881 @noindent
4882 Syntax:
4883
4884 @smallexample @c ada
4885 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4886 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4887 @end smallexample
4888
4889 @noindent
4890 This pragma signals that the entities whose names are listed are
4891 deliberately not referenced in the current source unit. This
4892 suppresses warnings about the
4893 entities being unreferenced, and in addition a warning will be
4894 generated if one of these entities is in fact referenced in the
4895 same unit as the pragma (or in the corresponding body, or one
4896 of its subunits).
4897
4898 This is particularly useful for clearly signaling that a particular
4899 parameter is not referenced in some particular subprogram implementation
4900 and that this is deliberate. It can also be useful in the case of
4901 objects declared only for their initialization or finalization side
4902 effects.
4903
4904 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4905 current scope, then the entity most recently declared is the one to which
4906 the pragma applies. Note that in the case of accept formals, the pragma
4907 Unreferenced may appear immediately after the keyword @code{do} which
4908 allows the indication of whether or not accept formals are referenced
4909 or not to be given individually for each accept statement.
4910
4911 The left hand side of an assignment does not count as a reference for the
4912 purpose of this pragma. Thus it is fine to assign to an entity for which
4913 pragma Unreferenced is given.
4914
4915 Note that if a warning is desired for all calls to a given subprogram,
4916 regardless of whether they occur in the same unit as the subprogram
4917 declaration, then this pragma should not be used (calls from another
4918 unit would not be flagged); pragma Obsolescent can be used instead
4919 for this purpose, see @xref{Pragma Obsolescent}.
4920
4921 The second form of pragma @code{Unreferenced} is used within a context
4922 clause. In this case the arguments must be unit names of units previously
4923 mentioned in @code{with} clauses (similar to the usage of pragma
4924 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4925 units and unreferenced entities within these units.
4926
4927 @node Pragma Unreferenced_Objects
4928 @unnumberedsec Pragma Unreferenced_Objects
4929 @findex Unreferenced_Objects
4930 @cindex Warnings, unreferenced
4931 @noindent
4932 Syntax:
4933
4934 @smallexample @c ada
4935 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4936 @end smallexample
4937
4938 @noindent
4939 This pragma signals that for the types or subtypes whose names are
4940 listed, objects which are declared with one of these types or subtypes may
4941 not be referenced, and if no references appear, no warnings are given.
4942
4943 This is particularly useful for objects which are declared solely for their
4944 initialization and finalization effect. Such variables are sometimes referred
4945 to as RAII variables (Resource Acquisition Is Initialization). Using this
4946 pragma on the relevant type (most typically a limited controlled type), the
4947 compiler will automatically suppress unwanted warnings about these variables
4948 not being referenced.
4949
4950 @node Pragma Unreserve_All_Interrupts
4951 @unnumberedsec Pragma Unreserve_All_Interrupts
4952 @findex Unreserve_All_Interrupts
4953 @noindent
4954 Syntax:
4955
4956 @smallexample @c ada
4957 pragma Unreserve_All_Interrupts;
4958 @end smallexample
4959
4960 @noindent
4961 Normally certain interrupts are reserved to the implementation.  Any attempt
4962 to attach an interrupt causes Program_Error to be raised, as described in
4963 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4964 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4965 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4966 interrupt execution.
4967
4968 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4969 a program, then all such interrupts are unreserved.  This allows the
4970 program to handle these interrupts, but disables their standard
4971 functions.  For example, if this pragma is used, then pressing
4972 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4973 a program can then handle the @code{SIGINT} interrupt as it chooses.
4974
4975 For a full list of the interrupts handled in a specific implementation,
4976 see the source code for the spec of @code{Ada.Interrupts.Names} in
4977 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4978 list of interrupts recognized for a given target.  The documentation in
4979 this file also specifies what interrupts are affected by the use of
4980 the @code{Unreserve_All_Interrupts} pragma.
4981
4982 For a more general facility for controlling what interrupts can be
4983 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4984 of the @code{Unreserve_All_Interrupts} pragma.
4985
4986 @node Pragma Unsuppress
4987 @unnumberedsec Pragma Unsuppress
4988 @findex Unsuppress
4989 @noindent
4990 Syntax:
4991
4992 @smallexample @c ada
4993 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4994 @end smallexample
4995
4996 @noindent
4997 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4998 there is no corresponding pragma @code{Suppress} in effect, it has no
4999 effect.  The range of the effect is the same as for pragma
5000 @code{Suppress}.  The meaning of the arguments is identical to that used
5001 in pragma @code{Suppress}.
5002
5003 One important application is to ensure that checks are on in cases where
5004 code depends on the checks for its correct functioning, so that the code
5005 will compile correctly even if the compiler switches are set to suppress
5006 checks.
5007
5008 @node Pragma Use_VADS_Size
5009 @unnumberedsec Pragma Use_VADS_Size
5010 @cindex @code{Size}, VADS compatibility
5011 @findex Use_VADS_Size
5012 @noindent
5013 Syntax:
5014
5015 @smallexample @c ada
5016 pragma Use_VADS_Size;
5017 @end smallexample
5018
5019 @noindent
5020 This is a configuration pragma.  In a unit to which it applies, any use
5021 of the 'Size attribute is automatically interpreted as a use of the
5022 'VADS_Size attribute.  Note that this may result in incorrect semantic
5023 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5024 the handling of existing code which depends on the interpretation of Size
5025 as implemented in the VADS compiler.  See description of the VADS_Size
5026 attribute for further details.
5027
5028 @node Pragma Validity_Checks
5029 @unnumberedsec Pragma Validity_Checks
5030 @findex Validity_Checks
5031 @noindent
5032 Syntax:
5033
5034 @smallexample @c ada
5035 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5036 @end smallexample
5037
5038 @noindent
5039 This pragma is used in conjunction with compiler switches to control the
5040 built-in validity checking provided by GNAT@.  The compiler switches, if set
5041 provide an initial setting for the switches, and this pragma may be used
5042 to modify these settings, or the settings may be provided entirely by
5043 the use of the pragma.  This pragma can be used anywhere that a pragma
5044 is legal, including use as a configuration pragma (including use in
5045 the @file{gnat.adc} file).
5046
5047 The form with a string literal specifies which validity options are to be
5048 activated.  The validity checks are first set to include only the default
5049 reference manual settings, and then a string of letters in the string
5050 specifies the exact set of options required.  The form of this string
5051 is exactly as described for the @option{-gnatVx} compiler switch (see the
5052 GNAT users guide for details).  For example the following two methods
5053 can be used to enable validity checking for mode @code{in} and
5054 @code{in out} subprogram parameters:
5055
5056 @itemize @bullet
5057 @item
5058 @smallexample @c ada
5059 pragma Validity_Checks ("im");
5060 @end smallexample
5061
5062 @item
5063 @smallexample
5064 gcc -c -gnatVim @dots{}
5065 @end smallexample
5066 @end itemize
5067
5068 @noindent
5069 The form ALL_CHECKS activates all standard checks (its use is equivalent
5070 to the use of the @code{gnatva} switch.
5071
5072 The forms with @code{Off} and @code{On}
5073 can be used to temporarily disable validity checks
5074 as shown in the following example:
5075
5076 @smallexample @c ada
5077 @iftex
5078 @leftskip=0cm
5079 @end iftex
5080 pragma Validity_Checks ("c"); -- validity checks for copies
5081 pragma Validity_Checks (Off); -- turn off validity checks
5082 A := B;                       -- B will not be validity checked
5083 pragma Validity_Checks (On);  -- turn validity checks back on
5084 A := C;                       -- C will be validity checked
5085 @end smallexample
5086
5087 @node Pragma Volatile
5088 @unnumberedsec Pragma Volatile
5089 @findex Volatile
5090 @noindent
5091 Syntax:
5092
5093 @smallexample @c ada
5094 pragma Volatile (LOCAL_NAME);
5095 @end smallexample
5096
5097 @noindent
5098 This pragma is defined by the Ada Reference Manual, and the GNAT
5099 implementation is fully conformant with this definition.  The reason it
5100 is mentioned in this section is that a pragma of the same name was supplied
5101 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5102 implementation of pragma Volatile is upwards compatible with the
5103 implementation in DEC Ada 83.
5104
5105 @node Pragma Warnings
5106 @unnumberedsec Pragma Warnings
5107 @findex Warnings
5108 @noindent
5109 Syntax:
5110
5111 @smallexample @c ada
5112 pragma Warnings (On | Off);
5113 pragma Warnings (On | Off, LOCAL_NAME);
5114 pragma Warnings (static_string_EXPRESSION);
5115 pragma Warnings (On | Off, static_string_EXPRESSION);
5116 @end smallexample
5117
5118 @noindent
5119 Normally warnings are enabled, with the output being controlled by
5120 the command line switch.  Warnings (@code{Off}) turns off generation of
5121 warnings until a Warnings (@code{On}) is encountered or the end of the
5122 current unit.  If generation of warnings is turned off using this
5123 pragma, then no warning messages are output, regardless of the
5124 setting of the command line switches.
5125
5126 The form with a single argument may be used as a configuration pragma.
5127
5128 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5129 the specified entity.  This suppression is effective from the point where
5130 it occurs till the end of the extended scope of the variable (similar to
5131 the scope of @code{Suppress}).
5132
5133 The form with a single static_string_EXPRESSION argument provides more precise
5134 control over which warnings are active. The string is a list of letters
5135 specifying which warnings are to be activated and which deactivated. The
5136 code for these letters is the same as the string used in the command
5137 line switch controlling warnings. The following is a brief summary. For
5138 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5139 User's Guide}.
5140
5141 @smallexample
5142 a    turn on all optional warnings (except d h l .o)
5143 A    turn off all optional warnings
5144 .a*  turn on warnings for failing assertions
5145 .A   turn off warnings for failing assertions
5146 b    turn on warnings for bad fixed value (not multiple of small)
5147 B*   turn off warnings for bad fixed value (not multiple of small)
5148 .b*  turn on warnings for biased representation
5149 .B   turn off warnings for biased representation
5150 c    turn on warnings for constant conditional
5151 C*   turn off warnings for constant conditional
5152 .c   turn on warnings for unrepped components
5153 .C*  turn off warnings for unrepped components
5154 d    turn on warnings for implicit dereference
5155 D*   turn off warnings for implicit dereference
5156 e    treat all warnings as errors
5157 .e   turn on every optional warning
5158 f    turn on warnings for unreferenced formal
5159 F*   turn off warnings for unreferenced formal
5160 g*   turn on warnings for unrecognized pragma
5161 G    turn off warnings for unrecognized pragma
5162 h    turn on warnings for hiding variable
5163 H*   turn off warnings for hiding variable
5164 i*   turn on warnings for implementation unit
5165 I    turn off warnings for implementation unit
5166 j    turn on warnings for obsolescent (annex J) feature
5167 J*   turn off warnings for obsolescent (annex J) feature
5168 k    turn on warnings on constant variable
5169 K*   turn off warnings on constant variable
5170 l    turn on warnings for missing elaboration pragma
5171 L*   turn off warnings for missing elaboration pragma
5172 m    turn on warnings for variable assigned but not read
5173 M*   turn off warnings for variable assigned but not read
5174 n*   normal warning mode (cancels -gnatws/-gnatwe)
5175 o*   turn on warnings for address clause overlay
5176 O    turn off warnings for address clause overlay
5177 .o   turn on warnings for out parameters assigned but not read
5178 .O*  turn off warnings for out parameters assigned but not read
5179 p    turn on warnings for ineffective pragma Inline in frontend
5180 P*   turn off warnings for ineffective pragma Inline in frontend
5181 .p   turn on warnings for parameter ordering
5182 .P*  turn off warnings for parameter ordering
5183 q*   turn on warnings for questionable missing parentheses
5184 Q    turn off warnings for questionable missing parentheses
5185 r    turn on warnings for redundant construct
5186 R*   turn off warnings for redundant construct
5187 .r   turn on warnings for object renaming function
5188 .R*  turn off warnings for object renaming function
5189 s    suppress all warnings
5190 t    turn on warnings for tracking deleted code
5191 T*   turn off warnings for tracking deleted code
5192 u    turn on warnings for unused entity
5193 U*   turn off warnings for unused entity
5194 v*   turn on warnings for unassigned variable
5195 V    turn off warnings for unassigned variable
5196 w*   turn on warnings for wrong low bound assumption
5197 W    turn off warnings for wrong low bound assumption
5198 .w   turn on warnings for unnecessary Warnings Off pragmas
5199 .W*  turn off warnings for unnecessary Warnings Off pragmas
5200 x*   turn on warnings for export/import
5201 X    turn off warnings for export/import
5202 .x   turn on warnings for non-local exceptions
5203 .X*  turn off warnings for non-local exceptions
5204 y*   turn on warnings for Ada 2005 incompatibility
5205 Y    turn off warnings for Ada 2005 incompatibility
5206 z*   turn on convention/size/align warnings for unchecked conversion
5207 Z    turn off convention/size/align warnings for unchecked conversion
5208 *    indicates default in above list
5209 @end smallexample
5210
5211 @noindent
5212 The specified warnings will be in effect until the end of the program
5213 or another pragma Warnings is encountered. The effect of the pragma is
5214 cumulative. Initially the set of warnings is the standard default set
5215 as possibly modified by compiler switches. Then each pragma Warning
5216 modifies this set of warnings as specified. This form of the pragma may
5217 also be used as a configuration pragma.
5218
5219 The fourth form, with an On|Off parameter and a string, is used to
5220 control individual messages, based on their text. The string argument
5221 is a pattern that is used to match against the text of individual
5222 warning messages (not including the initial "warning: " tag).
5223
5224 The pattern may contain asterisks, which match zero or more characters in
5225 the message. For example, you can use
5226 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5227 message @code{warning: 960 bits of "a" unused}. No other regular
5228 expression notations are permitted. All characters other than asterisk in
5229 these three specific cases are treated as literal characters in the match.
5230
5231 There are two ways to use this pragma. The OFF form can be used as a
5232 configuration pragma. The effect is to suppress all warnings (if any)
5233 that match the pattern string throughout the compilation.
5234
5235 The second usage is to suppress a warning locally, and in this case, two
5236 pragmas must appear in sequence:
5237
5238 @smallexample @c ada
5239 pragma Warnings (Off, Pattern);
5240 @dots{} code where given warning is to be suppressed
5241 pragma Warnings (On, Pattern);
5242 @end smallexample
5243
5244 @noindent
5245 In this usage, the pattern string must match in the Off and On pragmas,
5246 and at least one matching warning must be suppressed.
5247
5248 @node Pragma Weak_External
5249 @unnumberedsec Pragma Weak_External
5250 @findex Weak_External
5251 @noindent
5252 Syntax:
5253
5254 @smallexample @c ada
5255 pragma Weak_External ([Entity =>] LOCAL_NAME);
5256 @end smallexample
5257
5258 @noindent
5259 @var{LOCAL_NAME} must refer to an object that is declared at the library
5260 level. This pragma specifies that the given entity should be marked as a
5261 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5262 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5263 of a regular symbol, that is to say a symbol that does not have to be
5264 resolved by the linker if used in conjunction with a pragma Import.
5265
5266 When a weak symbol is not resolved by the linker, its address is set to
5267 zero. This is useful in writing interfaces to external modules that may
5268 or may not be linked in the final executable, for example depending on
5269 configuration settings.
5270
5271 If a program references at run time an entity to which this pragma has been
5272 applied, and the corresponding symbol was not resolved at link time, then
5273 the execution of the program is erroneous. It is not erroneous to take the
5274 Address of such an entity, for example to guard potential references,
5275 as shown in the example below.
5276
5277 Some file formats do not support weak symbols so not all target machines
5278 support this pragma.
5279
5280 @smallexample @c ada
5281 --  Example of the use of pragma Weak_External
5282
5283 package External_Module is
5284   key : Integer;
5285   pragma Import (C, key);
5286   pragma Weak_External (key);
5287   function Present return boolean;
5288 end External_Module;
5289
5290 with System; use System;
5291 package body External_Module is
5292   function Present return boolean is
5293   begin
5294     return key'Address /= System.Null_Address;
5295   end Present;
5296 end External_Module;
5297 @end smallexample
5298
5299 @node Pragma Wide_Character_Encoding
5300 @unnumberedsec Pragma Wide_Character_Encoding
5301 @findex Wide_Character_Encoding
5302 @noindent
5303 Syntax:
5304
5305 @smallexample @c ada
5306 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5307 @end smallexample
5308
5309 @noindent
5310 This pragma specifies the wide character encoding to be used in program
5311 source text appearing subsequently. It is a configuration pragma, but may
5312 also be used at any point that a pragma is allowed, and it is permissible
5313 to have more than one such pragma in a file, allowing multiple encodings
5314 to appear within the same file.
5315
5316 The argument can be an identifier or a character literal. In the identifier
5317 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5318 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5319 case it is correspondingly one of the characters @samp{h}, @samp{u},
5320 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5321
5322 Note that when the pragma is used within a file, it affects only the
5323 encoding within that file, and does not affect withed units, specs,
5324 or subunits.
5325
5326 @node Implementation Defined Attributes
5327 @chapter Implementation Defined Attributes
5328 Ada defines (throughout the Ada reference manual,
5329 summarized in Annex K),
5330 a set of attributes that provide useful additional functionality in all
5331 areas of the language.  These language defined attributes are implemented
5332 in GNAT and work as described in the Ada Reference Manual.
5333
5334 In addition, Ada allows implementations to define additional
5335 attributes whose meaning is defined by the implementation.  GNAT provides
5336 a number of these implementation-dependent attributes which can be used
5337 to extend and enhance the functionality of the compiler.  This section of
5338 the GNAT reference manual describes these additional attributes.
5339
5340 Note that any program using these attributes may not be portable to
5341 other compilers (although GNAT implements this set of attributes on all
5342 platforms).  Therefore if portability to other compilers is an important
5343 consideration, you should minimize the use of these attributes.
5344
5345 @menu
5346 * Abort_Signal::
5347 * Address_Size::
5348 * Asm_Input::
5349 * Asm_Output::
5350 * AST_Entry::
5351 * Bit::
5352 * Bit_Position::
5353 * Compiler_Version::
5354 * Code_Address::
5355 * Default_Bit_Order::
5356 * Elaborated::
5357 * Elab_Body::
5358 * Elab_Spec::
5359 * Emax::
5360 * Enabled::
5361 * Enum_Rep::
5362 * Enum_Val::
5363 * Epsilon::
5364 * Fixed_Value::
5365 * Has_Access_Values::
5366 * Has_Discriminants::
5367 * Img::
5368 * Integer_Value::
5369 * Invalid_Value::
5370 * Large::
5371 * Machine_Size::
5372 * Mantissa::
5373 * Max_Interrupt_Priority::
5374 * Max_Priority::
5375 * Maximum_Alignment::
5376 * Mechanism_Code::
5377 * Null_Parameter::
5378 * Object_Size::
5379 * Old::
5380 * Passed_By_Reference::
5381 * Pool_Address::
5382 * Range_Length::
5383 * Safe_Emax::
5384 * Safe_Large::
5385 * Small::
5386 * Storage_Unit::
5387 * Stub_Type::
5388 * Target_Name::
5389 * Tick::
5390 * To_Address::
5391 * Type_Class::
5392 * UET_Address::
5393 * Unconstrained_Array::
5394 * Universal_Literal_String::
5395 * Unrestricted_Access::
5396 * VADS_Size::
5397 * Value_Size::
5398 * Wchar_T_Size::
5399 * Word_Size::
5400 @end menu
5401
5402 @node Abort_Signal
5403 @unnumberedsec Abort_Signal
5404 @findex Abort_Signal
5405 @noindent
5406 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5407 prefix) provides the entity for the special exception used to signal
5408 task abort or asynchronous transfer of control.  Normally this attribute
5409 should only be used in the tasking runtime (it is highly peculiar, and
5410 completely outside the normal semantics of Ada, for a user program to
5411 intercept the abort exception).
5412
5413 @node Address_Size
5414 @unnumberedsec Address_Size
5415 @cindex Size of @code{Address}
5416 @findex Address_Size
5417 @noindent
5418 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5419 prefix) is a static constant giving the number of bits in an
5420 @code{Address}. It is the same value as System.Address'Size,
5421 but has the advantage of being static, while a direct
5422 reference to System.Address'Size is non-static because Address
5423 is a private type.
5424
5425 @node Asm_Input
5426 @unnumberedsec Asm_Input
5427 @findex Asm_Input
5428 @noindent
5429 The @code{Asm_Input} attribute denotes a function that takes two
5430 parameters.  The first is a string, the second is an expression of the
5431 type designated by the prefix.  The first (string) argument is required
5432 to be a static expression, and is the constraint for the parameter,
5433 (e.g.@: what kind of register is required).  The second argument is the
5434 value to be used as the input argument.  The possible values for the
5435 constant are the same as those used in the RTL, and are dependent on
5436 the configuration file used to built the GCC back end.
5437 @ref{Machine Code Insertions}
5438
5439 @node Asm_Output
5440 @unnumberedsec Asm_Output
5441 @findex Asm_Output
5442 @noindent
5443 The @code{Asm_Output} attribute denotes a function that takes two
5444 parameters.  The first is a string, the second is the name of a variable
5445 of the type designated by the attribute prefix.  The first (string)
5446 argument is required to be a static expression and designates the
5447 constraint for the parameter (e.g.@: what kind of register is
5448 required).  The second argument is the variable to be updated with the
5449 result.  The possible values for constraint are the same as those used in
5450 the RTL, and are dependent on the configuration file used to build the
5451 GCC back end.  If there are no output operands, then this argument may
5452 either be omitted, or explicitly given as @code{No_Output_Operands}.
5453 @ref{Machine Code Insertions}
5454
5455 @node AST_Entry
5456 @unnumberedsec AST_Entry
5457 @cindex OpenVMS
5458 @findex AST_Entry
5459 @noindent
5460 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5461 the name of an entry, it yields a value of the predefined type AST_Handler
5462 (declared in the predefined package System, as extended by the use of
5463 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5464 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5465 Language Reference Manual}, section 9.12a.
5466
5467 @node Bit
5468 @unnumberedsec Bit
5469 @findex Bit
5470 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5471 offset within the storage unit (byte) that contains the first bit of
5472 storage allocated for the object.  The value of this attribute is of the
5473 type @code{Universal_Integer}, and is always a non-negative number not
5474 exceeding the value of @code{System.Storage_Unit}.
5475
5476 For an object that is a variable or a constant allocated in a register,
5477 the value is zero.  (The use of this attribute does not force the
5478 allocation of a variable to memory).
5479
5480 For an object that is a formal parameter, this attribute applies
5481 to either the matching actual parameter or to a copy of the
5482 matching actual parameter.
5483
5484 For an access object the value is zero.  Note that
5485 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5486 designated object.  Similarly for a record component
5487 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5488 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5489 are subject to index checks.
5490
5491 This attribute is designed to be compatible with the DEC Ada 83 definition
5492 and implementation of the @code{Bit} attribute.
5493
5494 @node Bit_Position
5495 @unnumberedsec Bit_Position
5496 @findex Bit_Position
5497 @noindent
5498 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5499 of the fields of the record type, yields the bit
5500 offset within the record contains the first bit of
5501 storage allocated for the object.  The value of this attribute is of the
5502 type @code{Universal_Integer}.  The value depends only on the field
5503 @var{C} and is independent of the alignment of
5504 the containing record @var{R}.
5505
5506 @node Compiler_Version
5507 @unnumberedsec Compiler_Version
5508 @findex Compiler_Version
5509 @noindent
5510 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5511 prefix) yields a static string identifying the version of the compiler
5512 being used to compile the unit containing the attribute reference. A
5513 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5514
5515 @node Code_Address
5516 @unnumberedsec Code_Address
5517 @findex Code_Address
5518 @cindex Subprogram address
5519 @cindex Address of subprogram code
5520 @noindent
5521 The @code{'Address}
5522 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5523 intended effect seems to be to provide
5524 an address value which can be used to call the subprogram by means of
5525 an address clause as in the following example:
5526
5527 @smallexample @c ada
5528 procedure K is @dots{}
5529
5530 procedure L;
5531 for L'Address use K'Address;
5532 pragma Import (Ada, L);
5533 @end smallexample
5534
5535 @noindent
5536 A call to @code{L} is then expected to result in a call to @code{K}@.
5537 In Ada 83, where there were no access-to-subprogram values, this was
5538 a common work-around for getting the effect of an indirect call.
5539 GNAT implements the above use of @code{Address} and the technique
5540 illustrated by the example code works correctly.
5541
5542 However, for some purposes, it is useful to have the address of the start
5543 of the generated code for the subprogram.  On some architectures, this is
5544 not necessarily the same as the @code{Address} value described above.
5545 For example, the @code{Address} value may reference a subprogram
5546 descriptor rather than the subprogram itself.
5547
5548 The @code{'Code_Address} attribute, which can only be applied to
5549 subprogram entities, always returns the address of the start of the
5550 generated code of the specified subprogram, which may or may not be
5551 the same value as is returned by the corresponding @code{'Address}
5552 attribute.
5553
5554 @node Default_Bit_Order
5555 @unnumberedsec Default_Bit_Order
5556 @cindex Big endian
5557 @cindex Little endian
5558 @findex Default_Bit_Order
5559 @noindent
5560 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5561 permissible prefix), provides the value @code{System.Default_Bit_Order}
5562 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5563 @code{Low_Order_First}).  This is used to construct the definition of
5564 @code{Default_Bit_Order} in package @code{System}.
5565
5566 @node Elaborated
5567 @unnumberedsec Elaborated
5568 @findex Elaborated
5569 @noindent
5570 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5571 value is a Boolean which indicates whether or not the given unit has been
5572 elaborated.  This attribute is primarily intended for internal use by the
5573 generated code for dynamic elaboration checking, but it can also be used
5574 in user programs.  The value will always be True once elaboration of all
5575 units has been completed.  An exception is for units which need no
5576 elaboration, the value is always False for such units.
5577
5578 @node Elab_Body
5579 @unnumberedsec Elab_Body
5580 @findex Elab_Body
5581 @noindent
5582 This attribute can only be applied to a program unit name.  It returns
5583 the entity for the corresponding elaboration procedure for elaborating
5584 the body of the referenced unit.  This is used in the main generated
5585 elaboration procedure by the binder and is not normally used in any
5586 other context.  However, there may be specialized situations in which it
5587 is useful to be able to call this elaboration procedure from Ada code,
5588 e.g.@: if it is necessary to do selective re-elaboration to fix some
5589 error.
5590
5591 @node Elab_Spec
5592 @unnumberedsec Elab_Spec
5593 @findex Elab_Spec
5594 @noindent
5595 This attribute can only be applied to a program unit name.  It returns
5596 the entity for the corresponding elaboration procedure for elaborating
5597 the spec of the referenced unit.  This is used in the main
5598 generated elaboration procedure by the binder and is not normally used
5599 in any other context.  However, there may be specialized situations in
5600 which it is useful to be able to call this elaboration procedure from
5601 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5602 some error.
5603
5604 @node Emax
5605 @unnumberedsec Emax
5606 @cindex Ada 83 attributes
5607 @findex Emax
5608 @noindent
5609 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5610 the Ada 83 reference manual for an exact description of the semantics of
5611 this attribute.
5612
5613 @node Enabled
5614 @unnumberedsec Enabled
5615 @findex Enabled
5616 @noindent
5617 The @code{Enabled} attribute allows an application program to check at compile
5618 time to see if the designated check is currently enabled. The prefix is a
5619 simple identifier, referencing any predefined check name (other than
5620 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5621 no argument is given for the attribute, the check is for the general state
5622 of the check, if an argument is given, then it is an entity name, and the
5623 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5624 given naming the entity (if not, then the argument is ignored).
5625
5626 Note that instantiations inherit the check status at the point of the
5627 instantiation, so a useful idiom is to have a library package that
5628 introduces a check name with @code{pragma Check_Name}, and then contains
5629 generic packages or subprograms which use the @code{Enabled} attribute
5630 to see if the check is enabled. A user of this package can then issue
5631 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5632 the package or subprogram, controlling whether the check will be present.
5633
5634 @node Enum_Rep
5635 @unnumberedsec Enum_Rep
5636 @cindex Representation of enums
5637 @findex Enum_Rep
5638 @noindent
5639 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5640 function with the following spec:
5641
5642 @smallexample @c ada
5643 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5644   return @i{Universal_Integer};
5645 @end smallexample
5646
5647 @noindent
5648 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5649 enumeration type or to a non-overloaded enumeration
5650 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5651 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5652 enumeration literal or object.
5653
5654 The function returns the representation value for the given enumeration
5655 value.  This will be equal to value of the @code{Pos} attribute in the
5656 absence of an enumeration representation clause.  This is a static
5657 attribute (i.e.@: the result is static if the argument is static).
5658
5659 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5660 in which case it simply returns the integer value.  The reason for this
5661 is to allow it to be used for @code{(<>)} discrete formal arguments in
5662 a generic unit that can be instantiated with either enumeration types
5663 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5664 type whose upper bound exceeds the upper bound of the largest signed
5665 integer type, and the argument is a variable, so that the universal
5666 integer calculation is done at run time, then the call to @code{Enum_Rep}
5667 may raise @code{Constraint_Error}.
5668
5669 @node Enum_Val
5670 @unnumberedsec Enum_Val
5671 @cindex Representation of enums
5672 @findex Enum_Val
5673 @noindent
5674 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5675 function with the following spec:
5676
5677 @smallexample @c ada
5678 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5679   return @var{S}'Base};
5680 @end smallexample
5681
5682 @noindent
5683 The function returns the enumeration value whose representation matches the
5684 argument, or raises Constraint_Error if no enumeration literal of the type
5685 has the matching value.
5686 This will be equal to value of the @code{Val} attribute in the
5687 absence of an enumeration representation clause.  This is a static
5688 attribute (i.e.@: the result is static if the argument is static).
5689
5690 @node Epsilon
5691 @unnumberedsec Epsilon
5692 @cindex Ada 83 attributes
5693 @findex Epsilon
5694 @noindent
5695 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5696 the Ada 83 reference manual for an exact description of the semantics of
5697 this attribute.
5698
5699 @node Fixed_Value
5700 @unnumberedsec Fixed_Value
5701 @findex Fixed_Value
5702 @noindent
5703 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5704 function with the following specification:
5705
5706 @smallexample @c ada
5707 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5708   return @var{S};
5709 @end smallexample
5710
5711 @noindent
5712 The value returned is the fixed-point value @var{V} such that
5713
5714 @smallexample @c ada
5715 @var{V} = Arg * @var{S}'Small
5716 @end smallexample
5717
5718 @noindent
5719 The effect is thus similar to first converting the argument to the
5720 integer type used to represent @var{S}, and then doing an unchecked
5721 conversion to the fixed-point type.  The difference is
5722 that there are full range checks, to ensure that the result is in range.
5723 This attribute is primarily intended for use in implementation of the
5724 input-output functions for fixed-point values.
5725
5726 @node Has_Access_Values
5727 @unnumberedsec Has_Access_Values
5728 @cindex Access values, testing for
5729 @findex Has_Access_Values
5730 @noindent
5731 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5732 is a Boolean value which is True if the is an access type, or is a composite
5733 type with a component (at any nesting depth) that is an access type, and is
5734 False otherwise.
5735 The intended use of this attribute is in conjunction with generic
5736 definitions.  If the attribute is applied to a generic private type, it
5737 indicates whether or not the corresponding actual type has access values.
5738
5739 @node Has_Discriminants
5740 @unnumberedsec Has_Discriminants
5741 @cindex Discriminants, testing for
5742 @findex Has_Discriminants
5743 @noindent
5744 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5745 is a Boolean value which is True if the type has discriminants, and False
5746 otherwise.  The intended use of this attribute is in conjunction with generic
5747 definitions.  If the attribute is applied to a generic private type, it
5748 indicates whether or not the corresponding actual type has discriminants.
5749
5750 @node Img
5751 @unnumberedsec Img
5752 @findex Img
5753 @noindent
5754 The @code{Img} attribute differs from @code{Image} in that it may be
5755 applied to objects as well as types, in which case it gives the
5756 @code{Image} for the subtype of the object.  This is convenient for
5757 debugging:
5758
5759 @smallexample @c ada
5760 Put_Line ("X = " & X'Img);
5761 @end smallexample
5762
5763 @noindent
5764 has the same meaning as the more verbose:
5765
5766 @smallexample @c ada
5767 Put_Line ("X = " & @var{T}'Image (X));
5768 @end smallexample
5769
5770 @noindent
5771 where @var{T} is the (sub)type of the object @code{X}.
5772
5773 @node Integer_Value
5774 @unnumberedsec Integer_Value
5775 @findex Integer_Value
5776 @noindent
5777 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5778 function with the following spec:
5779
5780 @smallexample @c ada
5781 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5782   return @var{S};
5783 @end smallexample
5784
5785 @noindent
5786 The value returned is the integer value @var{V}, such that
5787
5788 @smallexample @c ada
5789 Arg = @var{V} * @var{T}'Small
5790 @end smallexample
5791
5792 @noindent
5793 where @var{T} is the type of @code{Arg}.
5794 The effect is thus similar to first doing an unchecked conversion from
5795 the fixed-point type to its corresponding implementation type, and then
5796 converting the result to the target integer type.  The difference is
5797 that there are full range checks, to ensure that the result is in range.
5798 This attribute is primarily intended for use in implementation of the
5799 standard input-output functions for fixed-point values.
5800
5801 @node Invalid_Value
5802 @unnumberedsec Invalid_Value
5803 @findex Invalid_Value
5804 @noindent
5805 For every scalar type S, S'Invalid_Value returns an undefined value of the
5806 type. If possible this value is an invalid representation for the type. The
5807 value returned is identical to the value used to initialize an otherwise
5808 uninitialized value of the type if pragma Initialize_Scalars is used,
5809 including the ability to modify the value with the binder -Sxx flag and
5810 relevant environment variables at run time.
5811
5812 @node Large
5813 @unnumberedsec Large
5814 @cindex Ada 83 attributes
5815 @findex Large
5816 @noindent
5817 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5818 the Ada 83 reference manual for an exact description of the semantics of
5819 this attribute.
5820
5821 @node Machine_Size
5822 @unnumberedsec Machine_Size
5823 @findex Machine_Size
5824 @noindent
5825 This attribute is identical to the @code{Object_Size} attribute.  It is
5826 provided for compatibility with the DEC Ada 83 attribute of this name.
5827
5828 @node Mantissa
5829 @unnumberedsec Mantissa
5830 @cindex Ada 83 attributes
5831 @findex Mantissa
5832 @noindent
5833 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5834 the Ada 83 reference manual for an exact description of the semantics of
5835 this attribute.
5836
5837 @node Max_Interrupt_Priority
5838 @unnumberedsec Max_Interrupt_Priority
5839 @cindex Interrupt priority, maximum
5840 @findex Max_Interrupt_Priority
5841 @noindent
5842 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5843 permissible prefix), provides the same value as
5844 @code{System.Max_Interrupt_Priority}.
5845
5846 @node Max_Priority
5847 @unnumberedsec Max_Priority
5848 @cindex Priority, maximum
5849 @findex Max_Priority
5850 @noindent
5851 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5852 prefix) provides the same value as @code{System.Max_Priority}.
5853
5854 @node Maximum_Alignment
5855 @unnumberedsec Maximum_Alignment
5856 @cindex Alignment, maximum
5857 @findex Maximum_Alignment
5858 @noindent
5859 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5860 permissible prefix) provides the maximum useful alignment value for the
5861 target.  This is a static value that can be used to specify the alignment
5862 for an object, guaranteeing that it is properly aligned in all
5863 cases.
5864
5865 @node Mechanism_Code
5866 @unnumberedsec Mechanism_Code
5867 @cindex Return values, passing mechanism
5868 @cindex Parameters, passing mechanism
5869 @findex Mechanism_Code
5870 @noindent
5871 @code{@var{function}'Mechanism_Code} yields an integer code for the
5872 mechanism used for the result of function, and
5873 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5874 used for formal parameter number @var{n} (a static integer value with 1
5875 meaning the first parameter) of @var{subprogram}.  The code returned is:
5876
5877 @table @asis
5878 @item 1
5879 by copy (value)
5880 @item 2
5881 by reference
5882 @item 3
5883 by descriptor (default descriptor class)
5884 @item 4
5885 by descriptor (UBS: unaligned bit string)
5886 @item 5
5887 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5888 @item 6
5889 by descriptor (UBA: unaligned bit array)
5890 @item 7
5891 by descriptor (S: string, also scalar access type parameter)
5892 @item 8
5893 by descriptor (SB: string with arbitrary bounds)
5894 @item 9
5895 by descriptor (A: contiguous array)
5896 @item 10
5897 by descriptor (NCA: non-contiguous array)
5898 @end table
5899
5900 @noindent
5901 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5902 @cindex OpenVMS
5903
5904 @node Null_Parameter
5905 @unnumberedsec Null_Parameter
5906 @cindex Zero address, passing
5907 @findex Null_Parameter
5908 @noindent
5909 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5910 type or subtype @var{T} allocated at machine address zero.  The attribute
5911 is allowed only as the default expression of a formal parameter, or as
5912 an actual expression of a subprogram call.  In either case, the
5913 subprogram must be imported.
5914
5915 The identity of the object is represented by the address zero in the
5916 argument list, independent of the passing mechanism (explicit or
5917 default).
5918
5919 This capability is needed to specify that a zero address should be
5920 passed for a record or other composite object passed by reference.
5921 There is no way of indicating this without the @code{Null_Parameter}
5922 attribute.
5923
5924 @node Object_Size
5925 @unnumberedsec Object_Size
5926 @cindex Size, used for objects
5927 @findex Object_Size
5928 @noindent
5929 The size of an object is not necessarily the same as the size of the type
5930 of an object.  This is because by default object sizes are increased to be
5931 a multiple of the alignment of the object.  For example,
5932 @code{Natural'Size} is
5933 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5934 Similarly, a record containing an integer and a character:
5935
5936 @smallexample @c ada
5937 type Rec is record
5938    I : Integer;
5939    C : Character;
5940 end record;
5941 @end smallexample
5942
5943 @noindent
5944 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5945 alignment will be 4, because of the
5946 integer field, and so the default size of record objects for this type
5947 will be 64 (8 bytes).
5948
5949 @node Old
5950 @unnumberedsec Old
5951 @cindex Capturing Old values
5952 @cindex Postconditions
5953 @noindent
5954 The attribute Prefix'Old can be used within a
5955 subprogram to refer to the value of the prefix on entry. So for
5956 example if you have an argument of a record type X called Arg1,
5957 you can refer to Arg1.Field'Old which yields the value of
5958 Arg1.Field on entry. The implementation simply involves generating
5959 an object declaration which captures the value on entry. Any
5960 prefix is allowed except one of a limited type (since limited
5961 types cannot be copied to capture their values) or a local variable
5962 (since it does not exist at subprogram entry time).
5963
5964 The following example shows the use of 'Old to implement
5965 a test of a postcondition:
5966
5967 @smallexample @c ada
5968 with Old_Pkg;
5969 procedure Old is
5970 begin
5971    Old_Pkg.Incr;
5972 end Old;
5973
5974 package Old_Pkg is
5975    procedure Incr;
5976 end Old_Pkg;
5977
5978 package body Old_Pkg is
5979    Count : Natural := 0;
5980
5981    procedure Incr is
5982    begin
5983       ... code manipulating the value of Count
5984
5985       pragma Assert (Count = Count'Old + 1);
5986    end Incr;
5987 end Old_Pkg;
5988 @end smallexample
5989
5990 @noindent
5991 Note that it is allowed to apply 'Old to a constant entity, but this will
5992 result in a warning, since the old and new values will always be the same.
5993
5994 @node Passed_By_Reference
5995 @unnumberedsec Passed_By_Reference
5996 @cindex Parameters, when passed by reference
5997 @findex Passed_By_Reference
5998 @noindent
5999 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6000 a value of type @code{Boolean} value that is @code{True} if the type is
6001 normally passed by reference and @code{False} if the type is normally
6002 passed by copy in calls.  For scalar types, the result is always @code{False}
6003 and is static.  For non-scalar types, the result is non-static.
6004
6005 @node Pool_Address
6006 @unnumberedsec Pool_Address
6007 @cindex Parameters, when passed by reference
6008 @findex Pool_Address
6009 @noindent
6010 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6011 of X within its storage pool. This is the same as
6012 @code{@var{X}'Address}, except that for an unconstrained array whose
6013 bounds are allocated just before the first component,
6014 @code{@var{X}'Pool_Address} returns the address of those bounds,
6015 whereas @code{@var{X}'Address} returns the address of the first
6016 component.
6017
6018 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6019 the object is allocated'', which could be a user-defined storage pool,
6020 the global heap, on the stack, or in a static memory area. For an
6021 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6022 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6023
6024 @node Range_Length
6025 @unnumberedsec Range_Length
6026 @findex Range_Length
6027 @noindent
6028 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6029 the number of values represented by the subtype (zero for a null
6030 range).  The result is static for static subtypes.  @code{Range_Length}
6031 applied to the index subtype of a one dimensional array always gives the
6032 same result as @code{Range} applied to the array itself.
6033
6034 @node Safe_Emax
6035 @unnumberedsec Safe_Emax
6036 @cindex Ada 83 attributes
6037 @findex Safe_Emax
6038 @noindent
6039 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6040 the Ada 83 reference manual for an exact description of the semantics of
6041 this attribute.
6042
6043 @node Safe_Large
6044 @unnumberedsec Safe_Large
6045 @cindex Ada 83 attributes
6046 @findex Safe_Large
6047 @noindent
6048 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6049 the Ada 83 reference manual for an exact description of the semantics of
6050 this attribute.
6051
6052 @node Small
6053 @unnumberedsec Small
6054 @cindex Ada 83 attributes
6055 @findex Small
6056 @noindent
6057 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6058 fixed-point types.
6059 GNAT also allows this attribute to be applied to floating-point types
6060 for compatibility with Ada 83.  See
6061 the Ada 83 reference manual for an exact description of the semantics of
6062 this attribute when applied to floating-point types.
6063
6064 @node Storage_Unit
6065 @unnumberedsec Storage_Unit
6066 @findex Storage_Unit
6067 @noindent
6068 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6069 prefix) provides the same value as @code{System.Storage_Unit}.
6070
6071 @node Stub_Type
6072 @unnumberedsec Stub_Type
6073 @findex Stub_Type
6074 @noindent
6075 The GNAT implementation of remote access-to-classwide types is
6076 organized as described in AARM section E.4 (20.t): a value of an RACW type
6077 (designating a remote object) is represented as a normal access
6078 value, pointing to a "stub" object which in turn contains the
6079 necessary information to contact the designated remote object. A
6080 call on any dispatching operation of such a stub object does the
6081 remote call, if necessary, using the information in the stub object
6082 to locate the target partition, etc.
6083
6084 For a prefix @code{T} that denotes a remote access-to-classwide type,
6085 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6086
6087 By construction, the layout of @code{T'Stub_Type} is identical to that of
6088 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6089 unit @code{System.Partition_Interface}. Use of this attribute will create
6090 an implicit dependency on this unit.
6091
6092 @node Target_Name
6093 @unnumberedsec Target_Name
6094 @findex Target_Name
6095 @noindent
6096 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6097 prefix) provides a static string value that identifies the target
6098 for the current compilation. For GCC implementations, this is the
6099 standard gcc target name without the terminating slash (for
6100 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6101
6102 @node Tick
6103 @unnumberedsec Tick
6104 @findex Tick
6105 @noindent
6106 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6107 provides the same value as @code{System.Tick},
6108
6109 @node To_Address
6110 @unnumberedsec To_Address
6111 @findex To_Address
6112 @noindent
6113 The @code{System'To_Address}
6114 (@code{System} is the only permissible prefix)
6115 denotes a function identical to
6116 @code{System.Storage_Elements.To_Address} except that
6117 it is a static attribute.  This means that if its argument is
6118 a static expression, then the result of the attribute is a
6119 static expression.  The result is that such an expression can be
6120 used in contexts (e.g.@: preelaborable packages) which require a
6121 static expression and where the function call could not be used
6122 (since the function call is always non-static, even if its
6123 argument is static).
6124
6125 @node Type_Class
6126 @unnumberedsec Type_Class
6127 @findex Type_Class
6128 @noindent
6129 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6130 the value of the type class for the full type of @var{type}.  If
6131 @var{type} is a generic formal type, the value is the value for the
6132 corresponding actual subtype.  The value of this attribute is of type
6133 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6134
6135 @smallexample @c ada
6136   type Type_Class is
6137     (Type_Class_Enumeration,
6138      Type_Class_Integer,
6139      Type_Class_Fixed_Point,
6140      Type_Class_Floating_Point,
6141      Type_Class_Array,
6142      Type_Class_Record,
6143      Type_Class_Access,
6144      Type_Class_Task,
6145      Type_Class_Address);
6146 @end smallexample
6147
6148 @noindent
6149 Protected types yield the value @code{Type_Class_Task}, which thus
6150 applies to all concurrent types.  This attribute is designed to
6151 be compatible with the DEC Ada 83 attribute of the same name.
6152
6153 @node UET_Address
6154 @unnumberedsec UET_Address
6155 @findex UET_Address
6156 @noindent
6157 The @code{UET_Address} attribute can only be used for a prefix which
6158 denotes a library package.  It yields the address of the unit exception
6159 table when zero cost exception handling is used.  This attribute is
6160 intended only for use within the GNAT implementation.  See the unit
6161 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6162 for details on how this attribute is used in the implementation.
6163
6164 @node Unconstrained_Array
6165 @unnumberedsec Unconstrained_Array
6166 @findex Unconstrained_Array
6167 @noindent
6168 The @code{Unconstrained_Array} attribute can be used with a prefix that
6169 denotes any type or subtype. It is a static attribute that yields
6170 @code{True} if the prefix designates an unconstrained array,
6171 and @code{False} otherwise. In a generic instance, the result is
6172 still static, and yields the result of applying this test to the
6173 generic actual.
6174
6175 @node Universal_Literal_String
6176 @unnumberedsec Universal_Literal_String
6177 @cindex Named numbers, representation of
6178 @findex Universal_Literal_String
6179 @noindent
6180 The prefix of @code{Universal_Literal_String} must be a named
6181 number.  The static result is the string consisting of the characters of
6182 the number as defined in the original source.  This allows the user
6183 program to access the actual text of named numbers without intermediate
6184 conversions and without the need to enclose the strings in quotes (which
6185 would preclude their use as numbers).  This is used internally for the
6186 construction of values of the floating-point attributes from the file
6187 @file{ttypef.ads}, but may also be used by user programs.
6188
6189 For example, the following program prints the first 50 digits of pi:
6190
6191 @smallexample @c ada
6192 with Text_IO; use Text_IO;
6193 with Ada.Numerics;
6194 procedure Pi is
6195 begin
6196    Put (Ada.Numerics.Pi'Universal_Literal_String);
6197 end;
6198 @end smallexample
6199
6200 @node Unrestricted_Access
6201 @unnumberedsec Unrestricted_Access
6202 @cindex @code{Access}, unrestricted
6203 @findex Unrestricted_Access
6204 @noindent
6205 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6206 except that all accessibility and aliased view checks are omitted.  This
6207 is a user-beware attribute.  It is similar to
6208 @code{Address}, for which it is a desirable replacement where the value
6209 desired is an access type.  In other words, its effect is identical to
6210 first applying the @code{Address} attribute and then doing an unchecked
6211 conversion to a desired access type.  In GNAT, but not necessarily in
6212 other implementations, the use of static chains for inner level
6213 subprograms means that @code{Unrestricted_Access} applied to a
6214 subprogram yields a value that can be called as long as the subprogram
6215 is in scope (normal Ada accessibility rules restrict this usage).
6216
6217 It is possible to use @code{Unrestricted_Access} for any type, but care
6218 must be exercised if it is used to create pointers to unconstrained
6219 objects. In this case, the resulting pointer has the same scope as the
6220 context of the attribute, and may not be returned to some enclosing
6221 scope. For instance, a function cannot use @code{Unrestricted_Access}
6222 to create a unconstrained pointer and then return that value to the
6223 caller.
6224
6225 @node VADS_Size
6226 @unnumberedsec VADS_Size
6227 @cindex @code{Size}, VADS compatibility
6228 @findex VADS_Size
6229 @noindent
6230 The @code{'VADS_Size} attribute is intended to make it easier to port
6231 legacy code which relies on the semantics of @code{'Size} as implemented
6232 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6233 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6234 to a predefined or other primitive type with no Size clause yields the
6235 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6236 typical machines).  In addition @code{'VADS_Size} applied to an object
6237 gives the result that would be obtained by applying the attribute to
6238 the corresponding type.
6239
6240 @node Value_Size
6241 @unnumberedsec Value_Size
6242 @cindex @code{Size}, setting for not-first subtype
6243 @findex Value_Size
6244 @code{@var{type}'Value_Size} is the number of bits required to represent
6245 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6246 but, unlike @code{Size}, may be set for non-first subtypes.
6247
6248 @node Wchar_T_Size
6249 @unnumberedsec Wchar_T_Size
6250 @findex Wchar_T_Size
6251 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6252 prefix) provides the size in bits of the C @code{wchar_t} type
6253 primarily for constructing the definition of this type in
6254 package @code{Interfaces.C}.
6255
6256 @node Word_Size
6257 @unnumberedsec Word_Size
6258 @findex Word_Size
6259 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6260 prefix) provides the value @code{System.Word_Size}.
6261
6262 @c ------------------------
6263 @node Implementation Advice
6264 @chapter Implementation Advice
6265 @noindent
6266 The main text of the Ada Reference Manual describes the required
6267 behavior of all Ada compilers, and the GNAT compiler conforms to
6268 these requirements.
6269
6270 In addition, there are sections throughout the Ada Reference Manual headed
6271 by the phrase ``Implementation advice''.  These sections are not normative,
6272 i.e., they do not specify requirements that all compilers must
6273 follow.  Rather they provide advice on generally desirable behavior.  You
6274 may wonder why they are not requirements.  The most typical answer is
6275 that they describe behavior that seems generally desirable, but cannot
6276 be provided on all systems, or which may be undesirable on some systems.
6277
6278 As far as practical, GNAT follows the implementation advice sections in
6279 the Ada Reference Manual.  This chapter contains a table giving the
6280 reference manual section number, paragraph number and several keywords
6281 for each advice.  Each entry consists of the text of the advice followed
6282 by the GNAT interpretation of this advice.  Most often, this simply says
6283 ``followed'', which means that GNAT follows the advice.  However, in a
6284 number of cases, GNAT deliberately deviates from this advice, in which
6285 case the text describes what GNAT does and why.
6286
6287 @cindex Error detection
6288 @unnumberedsec 1.1.3(20): Error Detection
6289 @sp 1
6290 @cartouche
6291 If an implementation detects the use of an unsupported Specialized Needs
6292 Annex feature at run time, it should raise @code{Program_Error} if
6293 feasible.
6294 @end cartouche
6295 Not relevant.  All specialized needs annex features are either supported,
6296 or diagnosed at compile time.
6297
6298 @cindex Child Units
6299 @unnumberedsec 1.1.3(31): Child Units
6300 @sp 1
6301 @cartouche
6302 If an implementation wishes to provide implementation-defined
6303 extensions to the functionality of a language-defined library unit, it
6304 should normally do so by adding children to the library unit.
6305 @end cartouche
6306 Followed.
6307
6308 @cindex Bounded errors
6309 @unnumberedsec 1.1.5(12): Bounded Errors
6310 @sp 1
6311 @cartouche
6312 If an implementation detects a bounded error or erroneous
6313 execution, it should raise @code{Program_Error}.
6314 @end cartouche
6315 Followed in all cases in which the implementation detects a bounded
6316 error or erroneous execution.  Not all such situations are detected at
6317 runtime.
6318
6319 @cindex Pragmas
6320 @unnumberedsec 2.8(16): Pragmas
6321 @sp 1
6322 @cartouche
6323 Normally, implementation-defined pragmas should have no semantic effect
6324 for error-free programs; that is, if the implementation-defined pragmas
6325 are removed from a working program, the program should still be legal,
6326 and should still have the same semantics.
6327 @end cartouche
6328 The following implementation defined pragmas are exceptions to this
6329 rule:
6330
6331 @table @code
6332 @item Abort_Defer
6333 Affects semantics
6334 @item Ada_83
6335 Affects legality
6336 @item Assert
6337 Affects semantics
6338 @item CPP_Class
6339 Affects semantics
6340 @item CPP_Constructor
6341 Affects semantics
6342 @item Debug
6343 Affects semantics
6344 @item Interface_Name
6345 Affects semantics
6346 @item Machine_Attribute
6347 Affects semantics
6348 @item Unimplemented_Unit
6349 Affects legality
6350 @item Unchecked_Union
6351 Affects semantics
6352 @end table
6353
6354 @noindent
6355 In each of the above cases, it is essential to the purpose of the pragma
6356 that this advice not be followed.  For details see the separate section
6357 on implementation defined pragmas.
6358
6359 @unnumberedsec 2.8(17-19): Pragmas
6360 @sp 1
6361 @cartouche
6362 Normally, an implementation should not define pragmas that can
6363 make an illegal program legal, except as follows:
6364 @end cartouche
6365 @sp 1
6366 @cartouche
6367 A pragma used to complete a declaration, such as a pragma @code{Import};
6368 @end cartouche
6369 @sp 1
6370 @cartouche
6371 A pragma used to configure the environment by adding, removing, or
6372 replacing @code{library_items}.
6373 @end cartouche
6374 See response to paragraph 16 of this same section.
6375
6376 @cindex Character Sets
6377 @cindex Alternative Character Sets
6378 @unnumberedsec 3.5.2(5): Alternative Character Sets
6379 @sp 1
6380 @cartouche
6381 If an implementation supports a mode with alternative interpretations
6382 for @code{Character} and @code{Wide_Character}, the set of graphic
6383 characters of @code{Character} should nevertheless remain a proper
6384 subset of the set of graphic characters of @code{Wide_Character}.  Any
6385 character set ``localizations'' should be reflected in the results of
6386 the subprograms defined in the language-defined package
6387 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6388 an alternative interpretation of @code{Character}, the implementation should
6389 also support a corresponding change in what is a legal
6390 @code{identifier_letter}.
6391 @end cartouche
6392 Not all wide character modes follow this advice, in particular the JIS
6393 and IEC modes reflect standard usage in Japan, and in these encoding,
6394 the upper half of the Latin-1 set is not part of the wide-character
6395 subset, since the most significant bit is used for wide character
6396 encoding.  However, this only applies to the external forms.  Internally
6397 there is no such restriction.
6398
6399 @cindex Integer types
6400 @unnumberedsec 3.5.4(28): Integer Types
6401
6402 @sp 1
6403 @cartouche
6404 An implementation should support @code{Long_Integer} in addition to
6405 @code{Integer} if the target machine supports 32-bit (or longer)
6406 arithmetic.  No other named integer subtypes are recommended for package
6407 @code{Standard}.  Instead, appropriate named integer subtypes should be
6408 provided in the library package @code{Interfaces} (see B.2).
6409 @end cartouche
6410 @code{Long_Integer} is supported.  Other standard integer types are supported
6411 so this advice is not fully followed.  These types
6412 are supported for convenient interface to C, and so that all hardware
6413 types of the machine are easily available.
6414 @unnumberedsec 3.5.4(29): Integer Types
6415
6416 @sp 1
6417 @cartouche
6418 An implementation for a two's complement machine should support
6419 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6420 implementation should support a non-binary modules up to @code{Integer'Last}.
6421 @end cartouche
6422 Followed.
6423
6424 @cindex Enumeration values
6425 @unnumberedsec 3.5.5(8): Enumeration Values
6426 @sp 1
6427 @cartouche
6428 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6429 subtype, if the value of the operand does not correspond to the internal
6430 code for any enumeration literal of its type (perhaps due to an
6431 un-initialized variable), then the implementation should raise
6432 @code{Program_Error}.  This is particularly important for enumeration
6433 types with noncontiguous internal codes specified by an
6434 enumeration_representation_clause.
6435 @end cartouche
6436 Followed.
6437
6438 @cindex Float types
6439 @unnumberedsec 3.5.7(17): Float Types
6440 @sp 1
6441 @cartouche
6442 An implementation should support @code{Long_Float} in addition to
6443 @code{Float} if the target machine supports 11 or more digits of
6444 precision.  No other named floating point subtypes are recommended for
6445 package @code{Standard}.  Instead, appropriate named floating point subtypes
6446 should be provided in the library package @code{Interfaces} (see B.2).
6447 @end cartouche
6448 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6449 former provides improved compatibility with other implementations
6450 supporting this type.  The latter corresponds to the highest precision
6451 floating-point type supported by the hardware.  On most machines, this
6452 will be the same as @code{Long_Float}, but on some machines, it will
6453 correspond to the IEEE extended form.  The notable case is all ia32
6454 (x86) implementations, where @code{Long_Long_Float} corresponds to
6455 the 80-bit extended precision format supported in hardware on this
6456 processor.  Note that the 128-bit format on SPARC is not supported,
6457 since this is a software rather than a hardware format.
6458
6459 @cindex Multidimensional arrays
6460 @cindex Arrays, multidimensional
6461 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6462 @sp 1
6463 @cartouche
6464 An implementation should normally represent multidimensional arrays in
6465 row-major order, consistent with the notation used for multidimensional
6466 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6467 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6468 column-major order should be used instead (see B.5, ``Interfacing with
6469 Fortran'').
6470 @end cartouche
6471 Followed.
6472
6473 @findex Duration'Small
6474 @unnumberedsec 9.6(30-31): Duration'Small
6475 @sp 1
6476 @cartouche
6477 Whenever possible in an implementation, the value of @code{Duration'Small}
6478 should be no greater than 100 microseconds.
6479 @end cartouche
6480 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6481
6482 @sp 1
6483 @cartouche
6484 The time base for @code{delay_relative_statements} should be monotonic;
6485 it need not be the same time base as used for @code{Calendar.Clock}.
6486 @end cartouche
6487 Followed.
6488
6489 @unnumberedsec 10.2.1(12): Consistent Representation
6490 @sp 1
6491 @cartouche
6492 In an implementation, a type declared in a pre-elaborated package should
6493 have the same representation in every elaboration of a given version of
6494 the package, whether the elaborations occur in distinct executions of
6495 the same program, or in executions of distinct programs or partitions
6496 that include the given version.
6497 @end cartouche
6498 Followed, except in the case of tagged types.  Tagged types involve
6499 implicit pointers to a local copy of a dispatch table, and these pointers
6500 have representations which thus depend on a particular elaboration of the
6501 package.  It is not easy to see how it would be possible to follow this
6502 advice without severely impacting efficiency of execution.
6503
6504 @cindex Exception information
6505 @unnumberedsec 11.4.1(19): Exception Information
6506 @sp 1
6507 @cartouche
6508 @code{Exception_Message} by default and @code{Exception_Information}
6509 should produce information useful for
6510 debugging.  @code{Exception_Message} should be short, about one
6511 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6512 should not include the
6513 @code{Exception_Name}.  @code{Exception_Information} should include both
6514 the @code{Exception_Name} and the @code{Exception_Message}.
6515 @end cartouche
6516 Followed.  For each exception that doesn't have a specified
6517 @code{Exception_Message}, the compiler generates one containing the location
6518 of the raise statement.  This location has the form ``file:line'', where
6519 file is the short file name (without path information) and line is the line
6520 number in the file.  Note that in the case of the Zero Cost Exception
6521 mechanism, these messages become redundant with the Exception_Information that
6522 contains a full backtrace of the calling sequence, so they are disabled.
6523 To disable explicitly the generation of the source location message, use the
6524 Pragma @code{Discard_Names}.
6525
6526 @cindex Suppression of checks
6527 @cindex Checks, suppression of
6528 @unnumberedsec 11.5(28): Suppression of Checks
6529 @sp 1
6530 @cartouche
6531 The implementation should minimize the code executed for checks that
6532 have been suppressed.
6533 @end cartouche
6534 Followed.
6535
6536 @cindex Representation clauses
6537 @unnumberedsec 13.1 (21-24): Representation Clauses
6538 @sp 1
6539 @cartouche
6540 The recommended level of support for all representation items is
6541 qualified as follows:
6542 @end cartouche
6543 @sp 1
6544 @cartouche
6545 An implementation need not support representation items containing
6546 non-static expressions, except that an implementation should support a
6547 representation item for a given entity if each non-static expression in
6548 the representation item is a name that statically denotes a constant
6549 declared before the entity.
6550 @end cartouche
6551 Followed.  In fact, GNAT goes beyond the recommended level of support
6552 by allowing nonstatic expressions in some representation clauses even
6553 without the need to declare constants initialized with the values of
6554 such expressions.
6555 For example:
6556
6557 @smallexample @c ada
6558   X : Integer;
6559   Y : Float;
6560   for Y'Address use X'Address;>>
6561 @end smallexample
6562
6563
6564 @sp 1
6565 @cartouche
6566 An implementation need not support a specification for the @code{Size}
6567 for a given composite subtype, nor the size or storage place for an
6568 object (including a component) of a given composite subtype, unless the
6569 constraints on the subtype and its composite subcomponents (if any) are
6570 all static constraints.
6571 @end cartouche
6572 Followed.  Size Clauses are not permitted on non-static components, as
6573 described above.
6574
6575 @sp 1
6576 @cartouche
6577 An aliased component, or a component whose type is by-reference, should
6578 always be allocated at an addressable location.
6579 @end cartouche
6580 Followed.
6581
6582 @cindex Packed types
6583 @unnumberedsec 13.2(6-8): Packed Types
6584 @sp 1
6585 @cartouche
6586 If a type is packed, then the implementation should try to minimize
6587 storage allocated to objects of the type, possibly at the expense of
6588 speed of accessing components, subject to reasonable complexity in
6589 addressing calculations.
6590 @end cartouche
6591 @sp 1
6592 @cartouche
6593 The recommended level of support pragma @code{Pack} is:
6594
6595 For a packed record type, the components should be packed as tightly as
6596 possible subject to the Sizes of the component subtypes, and subject to
6597 any @code{record_representation_clause} that applies to the type; the
6598 implementation may, but need not, reorder components or cross aligned
6599 word boundaries to improve the packing.  A component whose @code{Size} is
6600 greater than the word size may be allocated an integral number of words.
6601 @end cartouche
6602 Followed.  Tight packing of arrays is supported for all component sizes
6603 up to 64-bits. If the array component size is 1 (that is to say, if
6604 the component is a boolean type or an enumeration type with two values)
6605 then values of the type are implicitly initialized to zero. This
6606 happens both for objects of the packed type, and for objects that have a
6607 subcomponent of the packed type.
6608
6609 @sp 1
6610 @cartouche
6611 An implementation should support Address clauses for imported
6612 subprograms.
6613 @end cartouche
6614 Followed.
6615 @cindex @code{Address} clauses
6616 @unnumberedsec 13.3(14-19): Address Clauses
6617
6618 @sp 1
6619 @cartouche
6620 For an array @var{X}, @code{@var{X}'Address} should point at the first
6621 component of the array, and not at the array bounds.
6622 @end cartouche
6623 Followed.
6624
6625 @sp 1
6626 @cartouche
6627 The recommended level of support for the @code{Address} attribute is:
6628
6629 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6630 object that is aliased or of a by-reference type, or is an entity whose
6631 @code{Address} has been specified.
6632 @end cartouche
6633 Followed.  A valid address will be produced even if none of those
6634 conditions have been met.  If necessary, the object is forced into
6635 memory to ensure the address is valid.
6636
6637 @sp 1
6638 @cartouche
6639 An implementation should support @code{Address} clauses for imported
6640 subprograms.
6641 @end cartouche
6642 Followed.
6643
6644 @sp 1
6645 @cartouche
6646 Objects (including subcomponents) that are aliased or of a by-reference
6647 type should be allocated on storage element boundaries.
6648 @end cartouche
6649 Followed.
6650
6651 @sp 1
6652 @cartouche
6653 If the @code{Address} of an object is specified, or it is imported or exported,
6654 then the implementation should not perform optimizations based on
6655 assumptions of no aliases.
6656 @end cartouche
6657 Followed.
6658
6659 @cindex @code{Alignment} clauses
6660 @unnumberedsec 13.3(29-35): Alignment Clauses
6661 @sp 1
6662 @cartouche
6663 The recommended level of support for the @code{Alignment} attribute for
6664 subtypes is:
6665
6666 An implementation should support specified Alignments that are factors
6667 and multiples of the number of storage elements per word, subject to the
6668 following:
6669 @end cartouche
6670 Followed.
6671
6672 @sp 1
6673 @cartouche
6674 An implementation need not support specified @code{Alignment}s for
6675 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6676 loaded and stored by available machine instructions.
6677 @end cartouche
6678 Followed.
6679
6680 @sp 1
6681 @cartouche
6682 An implementation need not support specified @code{Alignment}s that are
6683 greater than the maximum @code{Alignment} the implementation ever returns by
6684 default.
6685 @end cartouche
6686 Followed.
6687
6688 @sp 1
6689 @cartouche
6690 The recommended level of support for the @code{Alignment} attribute for
6691 objects is:
6692
6693 Same as above, for subtypes, but in addition:
6694 @end cartouche
6695 Followed.
6696
6697 @sp 1
6698 @cartouche
6699 For stand-alone library-level objects of statically constrained
6700 subtypes, the implementation should support all @code{Alignment}s
6701 supported by the target linker.  For example, page alignment is likely to
6702 be supported for such objects, but not for subtypes.
6703 @end cartouche
6704 Followed.
6705
6706 @cindex @code{Size} clauses
6707 @unnumberedsec 13.3(42-43): Size Clauses
6708 @sp 1
6709 @cartouche
6710 The recommended level of support for the @code{Size} attribute of
6711 objects is:
6712
6713 A @code{Size} clause should be supported for an object if the specified
6714 @code{Size} is at least as large as its subtype's @code{Size}, and
6715 corresponds to a size in storage elements that is a multiple of the
6716 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6717 @end cartouche
6718 Followed.
6719
6720 @unnumberedsec 13.3(50-56): Size Clauses
6721 @sp 1
6722 @cartouche
6723 If the @code{Size} of a subtype is specified, and allows for efficient
6724 independent addressability (see 9.10) on the target architecture, then
6725 the @code{Size} of the following objects of the subtype should equal the
6726 @code{Size} of the subtype:
6727
6728 Aliased objects (including components).
6729 @end cartouche
6730 Followed.
6731
6732 @sp 1
6733 @cartouche
6734 @code{Size} clause on a composite subtype should not affect the
6735 internal layout of components.
6736 @end cartouche
6737 Followed. But note that this can be overridden by use of the implementation
6738 pragma Implicit_Packing in the case of packed arrays.
6739
6740 @sp 1
6741 @cartouche
6742 The recommended level of support for the @code{Size} attribute of subtypes is:
6743 @end cartouche
6744 @sp 1
6745 @cartouche
6746 The @code{Size} (if not specified) of a static discrete or fixed point
6747 subtype should be the number of bits needed to represent each value
6748 belonging to the subtype using an unbiased representation, leaving space
6749 for a sign bit only if the subtype contains negative values.  If such a
6750 subtype is a first subtype, then an implementation should support a
6751 specified @code{Size} for it that reflects this representation.
6752 @end cartouche
6753 Followed.
6754
6755 @sp 1
6756 @cartouche
6757 For a subtype implemented with levels of indirection, the @code{Size}
6758 should include the size of the pointers, but not the size of what they
6759 point at.
6760 @end cartouche
6761 Followed.
6762
6763 @cindex @code{Component_Size} clauses
6764 @unnumberedsec 13.3(71-73): Component Size Clauses
6765 @sp 1
6766 @cartouche
6767 The recommended level of support for the @code{Component_Size}
6768 attribute is:
6769 @end cartouche
6770 @sp 1
6771 @cartouche
6772 An implementation need not support specified @code{Component_Sizes} that are
6773 less than the @code{Size} of the component subtype.
6774 @end cartouche
6775 Followed.
6776
6777 @sp 1
6778 @cartouche
6779 An implementation should support specified @code{Component_Size}s that
6780 are factors and multiples of the word size.  For such
6781 @code{Component_Size}s, the array should contain no gaps between
6782 components.  For other @code{Component_Size}s (if supported), the array
6783 should contain no gaps between components when packing is also
6784 specified; the implementation should forbid this combination in cases
6785 where it cannot support a no-gaps representation.
6786 @end cartouche
6787 Followed.
6788
6789 @cindex Enumeration representation clauses
6790 @cindex Representation clauses, enumeration
6791 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6792 @sp 1
6793 @cartouche
6794 The recommended level of support for enumeration representation clauses
6795 is:
6796
6797 An implementation need not support enumeration representation clauses
6798 for boolean types, but should at minimum support the internal codes in
6799 the range @code{System.Min_Int.System.Max_Int}.
6800 @end cartouche
6801 Followed.
6802
6803 @cindex Record representation clauses
6804 @cindex Representation clauses, records
6805 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6806 @sp 1
6807 @cartouche
6808 The recommended level of support for
6809 @*@code{record_representation_clauses} is:
6810
6811 An implementation should support storage places that can be extracted
6812 with a load, mask, shift sequence of machine code, and set with a load,
6813 shift, mask, store sequence, given the available machine instructions
6814 and run-time model.
6815 @end cartouche
6816 Followed.
6817
6818 @sp 1
6819 @cartouche
6820 A storage place should be supported if its size is equal to the
6821 @code{Size} of the component subtype, and it starts and ends on a
6822 boundary that obeys the @code{Alignment} of the component subtype.
6823 @end cartouche
6824 Followed.
6825
6826 @sp 1
6827 @cartouche
6828 If the default bit ordering applies to the declaration of a given type,
6829 then for a component whose subtype's @code{Size} is less than the word
6830 size, any storage place that does not cross an aligned word boundary
6831 should be supported.
6832 @end cartouche
6833 Followed.
6834
6835 @sp 1
6836 @cartouche
6837 An implementation may reserve a storage place for the tag field of a
6838 tagged type, and disallow other components from overlapping that place.
6839 @end cartouche
6840 Followed.  The storage place for the tag field is the beginning of the tagged
6841 record, and its size is Address'Size.  GNAT will reject an explicit component
6842 clause for the tag field.
6843
6844 @sp 1
6845 @cartouche
6846 An implementation need not support a @code{component_clause} for a
6847 component of an extension part if the storage place is not after the
6848 storage places of all components of the parent type, whether or not
6849 those storage places had been specified.
6850 @end cartouche
6851 Followed.  The above advice on record representation clauses is followed,
6852 and all mentioned features are implemented.
6853
6854 @cindex Storage place attributes
6855 @unnumberedsec 13.5.2(5): Storage Place Attributes
6856 @sp 1
6857 @cartouche
6858 If a component is represented using some form of pointer (such as an
6859 offset) to the actual data of the component, and this data is contiguous
6860 with the rest of the object, then the storage place attributes should
6861 reflect the place of the actual data, not the pointer.  If a component is
6862 allocated discontinuously from the rest of the object, then a warning
6863 should be generated upon reference to one of its storage place
6864 attributes.
6865 @end cartouche
6866 Followed.  There are no such components in GNAT@.
6867
6868 @cindex Bit ordering
6869 @unnumberedsec 13.5.3(7-8): Bit Ordering
6870 @sp 1
6871 @cartouche
6872 The recommended level of support for the non-default bit ordering is:
6873 @end cartouche
6874 @sp 1
6875 @cartouche
6876 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6877 should support the non-default bit ordering in addition to the default
6878 bit ordering.
6879 @end cartouche
6880 Followed.  Word size does not equal storage size in this implementation.
6881 Thus non-default bit ordering is not supported.
6882
6883 @cindex @code{Address}, as private type
6884 @unnumberedsec 13.7(37): Address as Private
6885 @sp 1
6886 @cartouche
6887 @code{Address} should be of a private type.
6888 @end cartouche
6889 Followed.
6890
6891 @cindex Operations, on @code{Address}
6892 @cindex @code{Address}, operations of
6893 @unnumberedsec 13.7.1(16): Address Operations
6894 @sp 1
6895 @cartouche
6896 Operations in @code{System} and its children should reflect the target
6897 environment semantics as closely as is reasonable.  For example, on most
6898 machines, it makes sense for address arithmetic to ``wrap around''.
6899 Operations that do not make sense should raise @code{Program_Error}.
6900 @end cartouche
6901 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6902 operation raises @code{Program_Error}, since all operations make sense.
6903
6904 @cindex Unchecked conversion
6905 @unnumberedsec 13.9(14-17): Unchecked Conversion
6906 @sp 1
6907 @cartouche
6908 The @code{Size} of an array object should not include its bounds; hence,
6909 the bounds should not be part of the converted data.
6910 @end cartouche
6911 Followed.
6912
6913 @sp 1
6914 @cartouche
6915 The implementation should not generate unnecessary run-time checks to
6916 ensure that the representation of @var{S} is a representation of the
6917 target type.  It should take advantage of the permission to return by
6918 reference when possible.  Restrictions on unchecked conversions should be
6919 avoided unless required by the target environment.
6920 @end cartouche
6921 Followed.  There are no restrictions on unchecked conversion.  A warning is
6922 generated if the source and target types do not have the same size since
6923 the semantics in this case may be target dependent.
6924
6925 @sp 1
6926 @cartouche
6927 The recommended level of support for unchecked conversions is:
6928 @end cartouche
6929 @sp 1
6930 @cartouche
6931 Unchecked conversions should be supported and should be reversible in
6932 the cases where this clause defines the result.  To enable meaningful use
6933 of unchecked conversion, a contiguous representation should be used for
6934 elementary subtypes, for statically constrained array subtypes whose
6935 component subtype is one of the subtypes described in this paragraph,
6936 and for record subtypes without discriminants whose component subtypes
6937 are described in this paragraph.
6938 @end cartouche
6939 Followed.
6940
6941 @cindex Heap usage, implicit
6942 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6943 @sp 1
6944 @cartouche
6945 An implementation should document any cases in which it dynamically
6946 allocates heap storage for a purpose other than the evaluation of an
6947 allocator.
6948 @end cartouche
6949 Followed, the only other points at which heap storage is dynamically
6950 allocated are as follows:
6951
6952 @itemize @bullet
6953 @item
6954 At initial elaboration time, to allocate dynamically sized global
6955 objects.
6956
6957 @item
6958 To allocate space for a task when a task is created.
6959
6960 @item
6961 To extend the secondary stack dynamically when needed.  The secondary
6962 stack is used for returning variable length results.
6963 @end itemize
6964
6965 @sp 1
6966 @cartouche
6967 A default (implementation-provided) storage pool for an
6968 access-to-constant type should not have overhead to support deallocation of
6969 individual objects.
6970 @end cartouche
6971 Followed.
6972
6973 @sp 1
6974 @cartouche
6975 A storage pool for an anonymous access type should be created at the
6976 point of an allocator for the type, and be reclaimed when the designated
6977 object becomes inaccessible.
6978 @end cartouche
6979 Followed.
6980
6981 @cindex Unchecked deallocation
6982 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6983 @sp 1
6984 @cartouche
6985 For a standard storage pool, @code{Free} should actually reclaim the
6986 storage.
6987 @end cartouche
6988 Followed.
6989
6990 @cindex Stream oriented attributes
6991 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6992 @sp 1
6993 @cartouche
6994 If a stream element is the same size as a storage element, then the
6995 normal in-memory representation should be used by @code{Read} and
6996 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6997 should use the smallest number of stream elements needed to represent
6998 all values in the base range of the scalar type.
6999 @end cartouche
7000
7001 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7002 which specifies using the size of the first subtype.
7003 However, such an implementation is based on direct binary
7004 representations and is therefore target- and endianness-dependent.
7005 To address this issue, GNAT also supplies an alternate implementation
7006 of the stream attributes @code{Read} and @code{Write},
7007 which uses the target-independent XDR standard representation
7008 for scalar types.
7009 @cindex XDR representation
7010 @cindex @code{Read} attribute
7011 @cindex @code{Write} attribute
7012 @cindex Stream oriented attributes
7013 The XDR implementation is provided as an alternative body of the
7014 @code{System.Stream_Attributes} package, in the file
7015 @file{s-strxdr.adb} in the GNAT library.
7016 There is no @file{s-strxdr.ads} file.
7017 In order to install the XDR implementation, do the following:
7018 @enumerate
7019 @item Replace the default implementation of the
7020 @code{System.Stream_Attributes} package with the XDR implementation.
7021 For example on a Unix platform issue the commands:
7022 @smallexample
7023 $ mv s-stratt.adb s-strold.adb
7024 $ mv s-strxdr.adb s-stratt.adb
7025 @end smallexample
7026
7027 @item
7028 Rebuild the GNAT run-time library as documented in
7029 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7030 @end enumerate
7031
7032 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7033 @sp 1
7034 @cartouche
7035 If an implementation provides additional named predefined integer types,
7036 then the names should end with @samp{Integer} as in
7037 @samp{Long_Integer}.  If an implementation provides additional named
7038 predefined floating point types, then the names should end with
7039 @samp{Float} as in @samp{Long_Float}.
7040 @end cartouche
7041 Followed.
7042
7043 @findex Ada.Characters.Handling
7044 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7045 @sp 1
7046 @cartouche
7047 If an implementation provides a localized definition of @code{Character}
7048 or @code{Wide_Character}, then the effects of the subprograms in
7049 @code{Characters.Handling} should reflect the localizations.  See also
7050 3.5.2.
7051 @end cartouche
7052 Followed.  GNAT provides no such localized definitions.
7053
7054 @cindex Bounded-length strings
7055 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7056 @sp 1
7057 @cartouche
7058 Bounded string objects should not be implemented by implicit pointers
7059 and dynamic allocation.
7060 @end cartouche
7061 Followed.  No implicit pointers or dynamic allocation are used.
7062
7063 @cindex Random number generation
7064 @unnumberedsec A.5.2(46-47): Random Number Generation
7065 @sp 1
7066 @cartouche
7067 Any storage associated with an object of type @code{Generator} should be
7068 reclaimed on exit from the scope of the object.
7069 @end cartouche
7070 Followed.
7071
7072 @sp 1
7073 @cartouche
7074 If the generator period is sufficiently long in relation to the number
7075 of distinct initiator values, then each possible value of
7076 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7077 random numbers that does not, in a practical sense, overlap the sequence
7078 initiated by any other value.  If this is not possible, then the mapping
7079 between initiator values and generator states should be a rapidly
7080 varying function of the initiator value.
7081 @end cartouche
7082 Followed.  The generator period is sufficiently long for the first
7083 condition here to hold true.
7084
7085 @findex Get_Immediate
7086 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7087 @sp 1
7088 @cartouche
7089 The @code{Get_Immediate} procedures should be implemented with
7090 unbuffered input.  For a device such as a keyboard, input should be
7091 @dfn{available} if a key has already been typed, whereas for a disk
7092 file, input should always be available except at end of file.  For a file
7093 associated with a keyboard-like device, any line-editing features of the
7094 underlying operating system should be disabled during the execution of
7095 @code{Get_Immediate}.
7096 @end cartouche
7097 Followed on all targets except VxWorks. For VxWorks, there is no way to
7098 provide this functionality that does not result in the input buffer being
7099 flushed before the @code{Get_Immediate} call. A special unit
7100 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7101 this functionality.
7102
7103 @findex Export
7104 @unnumberedsec B.1(39-41): Pragma @code{Export}
7105 @sp 1
7106 @cartouche
7107 If an implementation supports pragma @code{Export} to a given language,
7108 then it should also allow the main subprogram to be written in that
7109 language.  It should support some mechanism for invoking the elaboration
7110 of the Ada library units included in the system, and for invoking the
7111 finalization of the environment task.  On typical systems, the
7112 recommended mechanism is to provide two subprograms whose link names are
7113 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7114 elaboration code for library units.  @code{adafinal} should contain the
7115 finalization code.  These subprograms should have no effect the second
7116 and subsequent time they are called.
7117 @end cartouche
7118 Followed.
7119
7120 @sp 1
7121 @cartouche
7122 Automatic elaboration of pre-elaborated packages should be
7123 provided when pragma @code{Export} is supported.
7124 @end cartouche
7125 Followed when the main program is in Ada.  If the main program is in a
7126 foreign language, then
7127 @code{adainit} must be called to elaborate pre-elaborated
7128 packages.
7129
7130 @sp 1
7131 @cartouche
7132 For each supported convention @var{L} other than @code{Intrinsic}, an
7133 implementation should support @code{Import} and @code{Export} pragmas
7134 for objects of @var{L}-compatible types and for subprograms, and pragma
7135 @code{Convention} for @var{L}-eligible types and for subprograms,
7136 presuming the other language has corresponding features.  Pragma
7137 @code{Convention} need not be supported for scalar types.
7138 @end cartouche
7139 Followed.
7140
7141 @cindex Package @code{Interfaces}
7142 @findex Interfaces
7143 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7144 @sp 1
7145 @cartouche
7146 For each implementation-defined convention identifier, there should be a
7147 child package of package Interfaces with the corresponding name.  This
7148 package should contain any declarations that would be useful for
7149 interfacing to the language (implementation) represented by the
7150 convention.  Any declarations useful for interfacing to any language on
7151 the given hardware architecture should be provided directly in
7152 @code{Interfaces}.
7153 @end cartouche
7154 Followed. An additional package not defined
7155 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7156 for interfacing to C++.
7157
7158 @sp 1
7159 @cartouche
7160 An implementation supporting an interface to C, COBOL, or Fortran should
7161 provide the corresponding package or packages described in the following
7162 clauses.
7163 @end cartouche
7164 Followed.  GNAT provides all the packages described in this section.
7165
7166 @cindex C, interfacing with
7167 @unnumberedsec B.3(63-71): Interfacing with C
7168 @sp 1
7169 @cartouche
7170 An implementation should support the following interface correspondences
7171 between Ada and C@.
7172 @end cartouche
7173 Followed.
7174
7175 @sp 1
7176 @cartouche
7177 An Ada procedure corresponds to a void-returning C function.
7178 @end cartouche
7179 Followed.
7180
7181 @sp 1
7182 @cartouche
7183 An Ada function corresponds to a non-void C function.
7184 @end cartouche
7185 Followed.
7186
7187 @sp 1
7188 @cartouche
7189 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7190 function.
7191 @end cartouche
7192 Followed.
7193
7194 @sp 1
7195 @cartouche
7196 An Ada @code{in} parameter of an access-to-object type with designated
7197 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7198 where @var{t} is the C type corresponding to the Ada type @var{T}.
7199 @end cartouche
7200 Followed.
7201
7202 @sp 1
7203 @cartouche
7204 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7205 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7206 argument to a C function, where @var{t} is the C type corresponding to
7207 the Ada type @var{T}.  In the case of an elementary @code{out} or
7208 @code{in out} parameter, a pointer to a temporary copy is used to
7209 preserve by-copy semantics.
7210 @end cartouche
7211 Followed.
7212
7213 @sp 1
7214 @cartouche
7215 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7216 @code{@var{t}*} argument to a C function, where @var{t} is the C
7217 structure corresponding to the Ada type @var{T}.
7218 @end cartouche
7219 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7220 pragma, or Convention, or by explicitly specifying the mechanism for a given
7221 call using an extended import or export pragma.
7222
7223 @sp 1
7224 @cartouche
7225 An Ada parameter of an array type with component type @var{T}, of any
7226 mode, is passed as a @code{@var{t}*} argument to a C function, where
7227 @var{t} is the C type corresponding to the Ada type @var{T}.
7228 @end cartouche
7229 Followed.
7230
7231 @sp 1
7232 @cartouche
7233 An Ada parameter of an access-to-subprogram type is passed as a pointer
7234 to a C function whose prototype corresponds to the designated
7235 subprogram's specification.
7236 @end cartouche
7237 Followed.
7238
7239 @cindex COBOL, interfacing with
7240 @unnumberedsec B.4(95-98): Interfacing with COBOL
7241 @sp 1
7242 @cartouche
7243 An Ada implementation should support the following interface
7244 correspondences between Ada and COBOL@.
7245 @end cartouche
7246 Followed.
7247
7248 @sp 1
7249 @cartouche
7250 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7251 the COBOL type corresponding to @var{T}.
7252 @end cartouche
7253 Followed.
7254
7255 @sp 1
7256 @cartouche
7257 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7258 the corresponding COBOL type.
7259 @end cartouche
7260 Followed.
7261
7262 @sp 1
7263 @cartouche
7264 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7265 COBOL type corresponding to the Ada parameter type; for scalars, a local
7266 copy is used if necessary to ensure by-copy semantics.
7267 @end cartouche
7268 Followed.
7269
7270 @cindex Fortran, interfacing with
7271 @unnumberedsec B.5(22-26): Interfacing with Fortran
7272 @sp 1
7273 @cartouche
7274 An Ada implementation should support the following interface
7275 correspondences between Ada and Fortran:
7276 @end cartouche
7277 Followed.
7278
7279 @sp 1
7280 @cartouche
7281 An Ada procedure corresponds to a Fortran subroutine.
7282 @end cartouche
7283 Followed.
7284
7285 @sp 1
7286 @cartouche
7287 An Ada function corresponds to a Fortran function.
7288 @end cartouche
7289 Followed.
7290
7291 @sp 1
7292 @cartouche
7293 An Ada parameter of an elementary, array, or record type @var{T} is
7294 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7295 the Fortran type corresponding to the Ada type @var{T}, and where the
7296 INTENT attribute of the corresponding dummy argument matches the Ada
7297 formal parameter mode; the Fortran implementation's parameter passing
7298 conventions are used.  For elementary types, a local copy is used if
7299 necessary to ensure by-copy semantics.
7300 @end cartouche
7301 Followed.
7302
7303 @sp 1
7304 @cartouche
7305 An Ada parameter of an access-to-subprogram type is passed as a
7306 reference to a Fortran procedure whose interface corresponds to the
7307 designated subprogram's specification.
7308 @end cartouche
7309 Followed.
7310
7311 @cindex Machine operations
7312 @unnumberedsec C.1(3-5): Access to Machine Operations
7313 @sp 1
7314 @cartouche
7315 The machine code or intrinsic support should allow access to all
7316 operations normally available to assembly language programmers for the
7317 target environment, including privileged instructions, if any.
7318 @end cartouche
7319 Followed.
7320
7321 @sp 1
7322 @cartouche
7323 The interfacing pragmas (see Annex B) should support interface to
7324 assembler; the default assembler should be associated with the
7325 convention identifier @code{Assembler}.
7326 @end cartouche
7327 Followed.
7328
7329 @sp 1
7330 @cartouche
7331 If an entity is exported to assembly language, then the implementation
7332 should allocate it at an addressable location, and should ensure that it
7333 is retained by the linking process, even if not otherwise referenced
7334 from the Ada code.  The implementation should assume that any call to a
7335 machine code or assembler subprogram is allowed to read or update every
7336 object that is specified as exported.
7337 @end cartouche
7338 Followed.
7339
7340 @unnumberedsec C.1(10-16): Access to Machine Operations
7341 @sp 1
7342 @cartouche
7343 The implementation should ensure that little or no overhead is
7344 associated with calling intrinsic and machine-code subprograms.
7345 @end cartouche
7346 Followed for both intrinsics and machine-code subprograms.
7347
7348 @sp 1
7349 @cartouche
7350 It is recommended that intrinsic subprograms be provided for convenient
7351 access to any machine operations that provide special capabilities or
7352 efficiency and that are not otherwise available through the language
7353 constructs.
7354 @end cartouche
7355 Followed.  A full set of machine operation intrinsic subprograms is provided.
7356
7357 @sp 1
7358 @cartouche
7359 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7360 swap, decrement and test, enqueue/dequeue.
7361 @end cartouche
7362 Followed on any target supporting such operations.
7363
7364 @sp 1
7365 @cartouche
7366 Standard numeric functions---e.g.@:, sin, log.
7367 @end cartouche
7368 Followed on any target supporting such operations.
7369
7370 @sp 1
7371 @cartouche
7372 String manipulation operations---e.g.@:, translate and test.
7373 @end cartouche
7374 Followed on any target supporting such operations.
7375
7376 @sp 1
7377 @cartouche
7378 Vector operations---e.g.@:, compare vector against thresholds.
7379 @end cartouche
7380 Followed on any target supporting such operations.
7381
7382 @sp 1
7383 @cartouche
7384 Direct operations on I/O ports.
7385 @end cartouche
7386 Followed on any target supporting such operations.
7387
7388 @cindex Interrupt support
7389 @unnumberedsec C.3(28): Interrupt Support
7390 @sp 1
7391 @cartouche
7392 If the @code{Ceiling_Locking} policy is not in effect, the
7393 implementation should provide means for the application to specify which
7394 interrupts are to be blocked during protected actions, if the underlying
7395 system allows for a finer-grain control of interrupt blocking.
7396 @end cartouche
7397 Followed.  The underlying system does not allow for finer-grain control
7398 of interrupt blocking.
7399
7400 @cindex Protected procedure handlers
7401 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7402 @sp 1
7403 @cartouche
7404 Whenever possible, the implementation should allow interrupt handlers to
7405 be called directly by the hardware.
7406 @end cartouche
7407 @c SGI info:
7408 @ignore
7409 This is never possible under IRIX, so this is followed by default.
7410 @end ignore
7411 Followed on any target where the underlying operating system permits
7412 such direct calls.
7413
7414 @sp 1
7415 @cartouche
7416 Whenever practical, violations of any
7417 implementation-defined restrictions should be detected before run time.
7418 @end cartouche
7419 Followed.  Compile time warnings are given when possible.
7420
7421 @cindex Package @code{Interrupts}
7422 @findex Interrupts
7423 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7424
7425 @sp 1
7426 @cartouche
7427 If implementation-defined forms of interrupt handler procedures are
7428 supported, such as protected procedures with parameters, then for each
7429 such form of a handler, a type analogous to @code{Parameterless_Handler}
7430 should be specified in a child package of @code{Interrupts}, with the
7431 same operations as in the predefined package Interrupts.
7432 @end cartouche
7433 Followed.
7434
7435 @cindex Pre-elaboration requirements
7436 @unnumberedsec C.4(14): Pre-elaboration Requirements
7437 @sp 1
7438 @cartouche
7439 It is recommended that pre-elaborated packages be implemented in such a
7440 way that there should be little or no code executed at run time for the
7441 elaboration of entities not already covered by the Implementation
7442 Requirements.
7443 @end cartouche
7444 Followed.  Executable code is generated in some cases, e.g.@: loops
7445 to initialize large arrays.
7446
7447 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7448
7449 @sp 1
7450 @cartouche
7451 If the pragma applies to an entity, then the implementation should
7452 reduce the amount of storage used for storing names associated with that
7453 entity.
7454 @end cartouche
7455 Followed.
7456
7457 @cindex Package @code{Task_Attributes}
7458 @findex Task_Attributes
7459 @unnumberedsec C.7.2(30): The Package Task_Attributes
7460 @sp 1
7461 @cartouche
7462 Some implementations are targeted to domains in which memory use at run
7463 time must be completely deterministic.  For such implementations, it is
7464 recommended that the storage for task attributes will be pre-allocated
7465 statically and not from the heap.  This can be accomplished by either
7466 placing restrictions on the number and the size of the task's
7467 attributes, or by using the pre-allocated storage for the first @var{N}
7468 attribute objects, and the heap for the others.  In the latter case,
7469 @var{N} should be documented.
7470 @end cartouche
7471 Not followed.  This implementation is not targeted to such a domain.
7472
7473 @cindex Locking Policies
7474 @unnumberedsec D.3(17): Locking Policies
7475
7476 @sp 1
7477 @cartouche
7478 The implementation should use names that end with @samp{_Locking} for
7479 locking policies defined by the implementation.
7480 @end cartouche
7481 Followed.  A single implementation-defined locking policy is defined,
7482 whose name (@code{Inheritance_Locking}) follows this suggestion.
7483
7484 @cindex Entry queuing policies
7485 @unnumberedsec D.4(16): Entry Queuing Policies
7486 @sp 1
7487 @cartouche
7488 Names that end with @samp{_Queuing} should be used
7489 for all implementation-defined queuing policies.
7490 @end cartouche
7491 Followed.  No such implementation-defined queuing policies exist.
7492
7493 @cindex Preemptive abort
7494 @unnumberedsec D.6(9-10): Preemptive Abort
7495 @sp 1
7496 @cartouche
7497 Even though the @code{abort_statement} is included in the list of
7498 potentially blocking operations (see 9.5.1), it is recommended that this
7499 statement be implemented in a way that never requires the task executing
7500 the @code{abort_statement} to block.
7501 @end cartouche
7502 Followed.
7503
7504 @sp 1
7505 @cartouche
7506 On a multi-processor, the delay associated with aborting a task on
7507 another processor should be bounded; the implementation should use
7508 periodic polling, if necessary, to achieve this.
7509 @end cartouche
7510 Followed.
7511
7512 @cindex Tasking restrictions
7513 @unnumberedsec D.7(21): Tasking Restrictions
7514 @sp 1
7515 @cartouche
7516 When feasible, the implementation should take advantage of the specified
7517 restrictions to produce a more efficient implementation.
7518 @end cartouche
7519 GNAT currently takes advantage of these restrictions by providing an optimized
7520 run time when the Ravenscar profile and the GNAT restricted run time set
7521 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7522 pragma @code{Profile (Restricted)} for more details.
7523
7524 @cindex Time, monotonic
7525 @unnumberedsec D.8(47-49): Monotonic Time
7526 @sp 1
7527 @cartouche
7528 When appropriate, implementations should provide configuration
7529 mechanisms to change the value of @code{Tick}.
7530 @end cartouche
7531 Such configuration mechanisms are not appropriate to this implementation
7532 and are thus not supported.
7533
7534 @sp 1
7535 @cartouche
7536 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7537 be implemented as transformations of the same time base.
7538 @end cartouche
7539 Followed.
7540
7541 @sp 1
7542 @cartouche
7543 It is recommended that the @dfn{best} time base which exists in
7544 the underlying system be available to the application through
7545 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7546 @end cartouche
7547 Followed.
7548
7549 @cindex Partition communication subsystem
7550 @cindex PCS
7551 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7552 @sp 1
7553 @cartouche
7554 Whenever possible, the PCS on the called partition should allow for
7555 multiple tasks to call the RPC-receiver with different messages and
7556 should allow them to block until the corresponding subprogram body
7557 returns.
7558 @end cartouche
7559 Followed by GLADE, a separately supplied PCS that can be used with
7560 GNAT.
7561
7562 @sp 1
7563 @cartouche
7564 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7565 should raise @code{Storage_Error} if it runs out of space trying to
7566 write the @code{Item} into the stream.
7567 @end cartouche
7568 Followed by GLADE, a separately supplied PCS that can be used with
7569 GNAT@.
7570
7571 @cindex COBOL support
7572 @unnumberedsec F(7): COBOL Support
7573 @sp 1
7574 @cartouche
7575 If COBOL (respectively, C) is widely supported in the target
7576 environment, implementations supporting the Information Systems Annex
7577 should provide the child package @code{Interfaces.COBOL} (respectively,
7578 @code{Interfaces.C}) specified in Annex B and should support a
7579 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7580 pragmas (see Annex B), thus allowing Ada programs to interface with
7581 programs written in that language.
7582 @end cartouche
7583 Followed.
7584
7585 @cindex Decimal radix support
7586 @unnumberedsec F.1(2): Decimal Radix Support
7587 @sp 1
7588 @cartouche
7589 Packed decimal should be used as the internal representation for objects
7590 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7591 @end cartouche
7592 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7593 representations.
7594
7595 @cindex Numerics
7596 @unnumberedsec G: Numerics
7597 @sp 2
7598 @cartouche
7599 If Fortran (respectively, C) is widely supported in the target
7600 environment, implementations supporting the Numerics Annex
7601 should provide the child package @code{Interfaces.Fortran} (respectively,
7602 @code{Interfaces.C}) specified in Annex B and should support a
7603 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7604 pragmas (see Annex B), thus allowing Ada programs to interface with
7605 programs written in that language.
7606 @end cartouche
7607 Followed.
7608
7609 @cindex Complex types
7610 @unnumberedsec G.1.1(56-58): Complex Types
7611 @sp 2
7612 @cartouche
7613 Because the usual mathematical meaning of multiplication of a complex
7614 operand and a real operand is that of the scaling of both components of
7615 the former by the latter, an implementation should not perform this
7616 operation by first promoting the real operand to complex type and then
7617 performing a full complex multiplication.  In systems that, in the
7618 future, support an Ada binding to IEC 559:1989, the latter technique
7619 will not generate the required result when one of the components of the
7620 complex operand is infinite.  (Explicit multiplication of the infinite
7621 component by the zero component obtained during promotion yields a NaN
7622 that propagates into the final result.) Analogous advice applies in the
7623 case of multiplication of a complex operand and a pure-imaginary
7624 operand, and in the case of division of a complex operand by a real or
7625 pure-imaginary operand.
7626 @end cartouche
7627 Not followed.
7628
7629 @sp 1
7630 @cartouche
7631 Similarly, because the usual mathematical meaning of addition of a
7632 complex operand and a real operand is that the imaginary operand remains
7633 unchanged, an implementation should not perform this operation by first
7634 promoting the real operand to complex type and then performing a full
7635 complex addition.  In implementations in which the @code{Signed_Zeros}
7636 attribute of the component type is @code{True} (and which therefore
7637 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7638 predefined arithmetic operations), the latter technique will not
7639 generate the required result when the imaginary component of the complex
7640 operand is a negatively signed zero.  (Explicit addition of the negative
7641 zero to the zero obtained during promotion yields a positive zero.)
7642 Analogous advice applies in the case of addition of a complex operand
7643 and a pure-imaginary operand, and in the case of subtraction of a
7644 complex operand and a real or pure-imaginary operand.
7645 @end cartouche
7646 Not followed.
7647
7648 @sp 1
7649 @cartouche
7650 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7651 attempt to provide a rational treatment of the signs of zero results and
7652 result components.  As one example, the result of the @code{Argument}
7653 function should have the sign of the imaginary component of the
7654 parameter @code{X} when the point represented by that parameter lies on
7655 the positive real axis; as another, the sign of the imaginary component
7656 of the @code{Compose_From_Polar} function should be the same as
7657 (respectively, the opposite of) that of the @code{Argument} parameter when that
7658 parameter has a value of zero and the @code{Modulus} parameter has a
7659 nonnegative (respectively, negative) value.
7660 @end cartouche
7661 Followed.
7662
7663 @cindex Complex elementary functions
7664 @unnumberedsec G.1.2(49): Complex Elementary Functions
7665 @sp 1
7666 @cartouche
7667 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7668 @code{True} should attempt to provide a rational treatment of the signs
7669 of zero results and result components.  For example, many of the complex
7670 elementary functions have components that are odd functions of one of
7671 the parameter components; in these cases, the result component should
7672 have the sign of the parameter component at the origin.  Other complex
7673 elementary functions have zero components whose sign is opposite that of
7674 a parameter component at the origin, or is always positive or always
7675 negative.
7676 @end cartouche
7677 Followed.
7678
7679 @cindex Accuracy requirements
7680 @unnumberedsec G.2.4(19): Accuracy Requirements
7681 @sp 1
7682 @cartouche
7683 The versions of the forward trigonometric functions without a
7684 @code{Cycle} parameter should not be implemented by calling the
7685 corresponding version with a @code{Cycle} parameter of
7686 @code{2.0*Numerics.Pi}, since this will not provide the required
7687 accuracy in some portions of the domain.  For the same reason, the
7688 version of @code{Log} without a @code{Base} parameter should not be
7689 implemented by calling the corresponding version with a @code{Base}
7690 parameter of @code{Numerics.e}.
7691 @end cartouche
7692 Followed.
7693
7694 @cindex Complex arithmetic accuracy
7695 @cindex Accuracy, complex arithmetic
7696 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7697
7698 @sp 1
7699 @cartouche
7700 The version of the @code{Compose_From_Polar} function without a
7701 @code{Cycle} parameter should not be implemented by calling the
7702 corresponding version with a @code{Cycle} parameter of
7703 @code{2.0*Numerics.Pi}, since this will not provide the required
7704 accuracy in some portions of the domain.
7705 @end cartouche
7706 Followed.
7707
7708 @c -----------------------------------------
7709 @node Implementation Defined Characteristics
7710 @chapter Implementation Defined Characteristics
7711
7712 @noindent
7713 In addition to the implementation dependent pragmas and attributes, and
7714 the implementation advice, there are a number of other Ada features
7715 that are potentially implementation dependent.  These are mentioned
7716 throughout the Ada Reference Manual, and are summarized in annex M@.
7717
7718 A requirement for conforming Ada compilers is that they provide
7719 documentation describing how the implementation deals with each of these
7720 issues.  In this chapter, you will find each point in annex M listed
7721 followed by a description in italic font of how GNAT
7722 @c SGI info:
7723 @ignore
7724 in the ProDev Ada
7725 implementation on IRIX 5.3 operating system or greater
7726 @end ignore
7727 handles the implementation dependence.
7728
7729 You can use this chapter as a guide to minimizing implementation
7730 dependent features in your programs if portability to other compilers
7731 and other operating systems is an important consideration.  The numbers
7732 in each section below correspond to the paragraph number in the Ada
7733 Reference Manual.
7734
7735 @sp 1
7736 @cartouche
7737 @noindent
7738 @strong{2}.  Whether or not each recommendation given in Implementation
7739 Advice is followed.  See 1.1.2(37).
7740 @end cartouche
7741 @noindent
7742 @xref{Implementation Advice}.
7743
7744 @sp 1
7745 @cartouche
7746 @noindent
7747 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7748 @end cartouche
7749 @noindent
7750 The complexity of programs that can be processed is limited only by the
7751 total amount of available virtual memory, and disk space for the
7752 generated object files.
7753
7754 @sp 1
7755 @cartouche
7756 @noindent
7757 @strong{4}.  Variations from the standard that are impractical to avoid
7758 given the implementation's execution environment.  See 1.1.3(6).
7759 @end cartouche
7760 @noindent
7761 There are no variations from the standard.
7762
7763 @sp 1
7764 @cartouche
7765 @noindent
7766 @strong{5}.  Which @code{code_statement}s cause external
7767 interactions.  See 1.1.3(10).
7768 @end cartouche
7769 @noindent
7770 Any @code{code_statement} can potentially cause external interactions.
7771
7772 @sp 1
7773 @cartouche
7774 @noindent
7775 @strong{6}.  The coded representation for the text of an Ada
7776 program.  See 2.1(4).
7777 @end cartouche
7778 @noindent
7779 See separate section on source representation.
7780
7781 @sp 1
7782 @cartouche
7783 @noindent
7784 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7785 @end cartouche
7786 @noindent
7787 See separate section on source representation.
7788
7789 @sp 1
7790 @cartouche
7791 @noindent
7792 @strong{8}.  The representation for an end of line.  See 2.2(2).
7793 @end cartouche
7794 @noindent
7795 See separate section on source representation.
7796
7797 @sp 1
7798 @cartouche
7799 @noindent
7800 @strong{9}.  Maximum supported line length and lexical element
7801 length.  See 2.2(15).
7802 @end cartouche
7803 @noindent
7804 The maximum line length is 255 characters and the maximum length of a
7805 lexical element is also 255 characters.
7806
7807 @sp 1
7808 @cartouche
7809 @noindent
7810 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7811 @end cartouche
7812 @noindent
7813
7814 @xref{Implementation Defined Pragmas}.
7815
7816 @sp 1
7817 @cartouche
7818 @noindent
7819 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7820 @end cartouche
7821 @noindent
7822 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7823 parameter, checks that the optimization flag is set, and aborts if it is
7824 not.
7825
7826 @sp 1
7827 @cartouche
7828 @noindent
7829 @strong{12}.  The sequence of characters of the value returned by
7830 @code{@var{S}'Image} when some of the graphic characters of
7831 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7832 3.5(37).
7833 @end cartouche
7834 @noindent
7835 The sequence of characters is as defined by the wide character encoding
7836 method used for the source.  See section on source representation for
7837 further details.
7838
7839 @sp 1
7840 @cartouche
7841 @noindent
7842 @strong{13}.  The predefined integer types declared in
7843 @code{Standard}.  See 3.5.4(25).
7844 @end cartouche
7845 @noindent
7846 @table @code
7847 @item Short_Short_Integer
7848 8 bit signed
7849 @item Short_Integer
7850 (Short) 16 bit signed
7851 @item Integer
7852 32 bit signed
7853 @item Long_Integer
7854 64 bit signed (Alpha OpenVMS only)
7855 32 bit signed (all other targets)
7856 @item Long_Long_Integer
7857 64 bit signed
7858 @end table
7859
7860 @sp 1
7861 @cartouche
7862 @noindent
7863 @strong{14}.  Any nonstandard integer types and the operators defined
7864 for them.  See 3.5.4(26).
7865 @end cartouche
7866 @noindent
7867 There are no nonstandard integer types.
7868
7869 @sp 1
7870 @cartouche
7871 @noindent
7872 @strong{15}.  Any nonstandard real types and the operators defined for
7873 them.  See 3.5.6(8).
7874 @end cartouche
7875 @noindent
7876 There are no nonstandard real types.
7877
7878 @sp 1
7879 @cartouche
7880 @noindent
7881 @strong{16}.  What combinations of requested decimal precision and range
7882 are supported for floating point types.  See 3.5.7(7).
7883 @end cartouche
7884 @noindent
7885 The precision and range is as defined by the IEEE standard.
7886
7887 @sp 1
7888 @cartouche
7889 @noindent
7890 @strong{17}.  The predefined floating point types declared in
7891 @code{Standard}.  See 3.5.7(16).
7892 @end cartouche
7893 @noindent
7894 @table @code
7895 @item Short_Float
7896 32 bit IEEE short
7897 @item Float
7898 (Short) 32 bit IEEE short
7899 @item Long_Float
7900 64 bit IEEE long
7901 @item Long_Long_Float
7902 64 bit IEEE long (80 bit IEEE long on x86 processors)
7903 @end table
7904
7905 @sp 1
7906 @cartouche
7907 @noindent
7908 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7909 @end cartouche
7910 @noindent
7911 @code{Fine_Delta} is 2**(@minus{}63)
7912
7913 @sp 1
7914 @cartouche
7915 @noindent
7916 @strong{19}.  What combinations of small, range, and digits are
7917 supported for fixed point types.  See 3.5.9(10).
7918 @end cartouche
7919 @noindent
7920 Any combinations are permitted that do not result in a small less than
7921 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7922 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7923 is 64 bits (true of all architectures except ia32), then the output from
7924 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7925 is because floating-point conversions are used to convert fixed point.
7926
7927 @sp 1
7928 @cartouche
7929 @noindent
7930 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7931 within an unnamed @code{block_statement}.  See 3.9(10).
7932 @end cartouche
7933 @noindent
7934 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7935 decimal integer are allocated.
7936
7937 @sp 1
7938 @cartouche
7939 @noindent
7940 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7941 @end cartouche
7942 @noindent
7943 @xref{Implementation Defined Attributes}.
7944
7945 @sp 1
7946 @cartouche
7947 @noindent
7948 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7949 @end cartouche
7950 @noindent
7951 There are no implementation-defined time types.
7952
7953 @sp 1
7954 @cartouche
7955 @noindent
7956 @strong{23}.  The time base associated with relative delays.
7957 @end cartouche
7958 @noindent
7959 See 9.6(20).  The time base used is that provided by the C library
7960 function @code{gettimeofday}.
7961
7962 @sp 1
7963 @cartouche
7964 @noindent
7965 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7966 9.6(23).
7967 @end cartouche
7968 @noindent
7969 The time base used is that provided by the C library function
7970 @code{gettimeofday}.
7971
7972 @sp 1
7973 @cartouche
7974 @noindent
7975 @strong{25}.  The time zone used for package @code{Calendar}
7976 operations.  See 9.6(24).
7977 @end cartouche
7978 @noindent
7979 The time zone used by package @code{Calendar} is the current system time zone
7980 setting for local time, as accessed by the C library function
7981 @code{localtime}.
7982
7983 @sp 1
7984 @cartouche
7985 @noindent
7986 @strong{26}.  Any limit on @code{delay_until_statements} of
7987 @code{select_statements}.  See 9.6(29).
7988 @end cartouche
7989 @noindent
7990 There are no such limits.
7991
7992 @sp 1
7993 @cartouche
7994 @noindent
7995 @strong{27}.  Whether or not two non-overlapping parts of a composite
7996 object are independently addressable, in the case where packing, record
7997 layout, or @code{Component_Size} is specified for the object.  See
7998 9.10(1).
7999 @end cartouche
8000 @noindent
8001 Separate components are independently addressable if they do not share
8002 overlapping storage units.
8003
8004 @sp 1
8005 @cartouche
8006 @noindent
8007 @strong{28}.  The representation for a compilation.  See 10.1(2).
8008 @end cartouche
8009 @noindent
8010 A compilation is represented by a sequence of files presented to the
8011 compiler in a single invocation of the @command{gcc} command.
8012
8013 @sp 1
8014 @cartouche
8015 @noindent
8016 @strong{29}.  Any restrictions on compilations that contain multiple
8017 compilation_units.  See 10.1(4).
8018 @end cartouche
8019 @noindent
8020 No single file can contain more than one compilation unit, but any
8021 sequence of files can be presented to the compiler as a single
8022 compilation.
8023
8024 @sp 1
8025 @cartouche
8026 @noindent
8027 @strong{30}.  The mechanisms for creating an environment and for adding
8028 and replacing compilation units.  See 10.1.4(3).
8029 @end cartouche
8030 @noindent
8031 See separate section on compilation model.
8032
8033 @sp 1
8034 @cartouche
8035 @noindent
8036 @strong{31}.  The manner of explicitly assigning library units to a
8037 partition.  See 10.2(2).
8038 @end cartouche
8039 @noindent
8040 If a unit contains an Ada main program, then the Ada units for the partition
8041 are determined by recursive application of the rules in the Ada Reference
8042 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8043 are needed by the main program, and then this definition of need is applied
8044 recursively to those units, and the partition contains the transitive
8045 closure determined by this relationship.  In short, all the necessary units
8046 are included, with no need to explicitly specify the list.  If additional
8047 units are required, e.g.@: by foreign language units, then all units must be
8048 mentioned in the context clause of one of the needed Ada units.
8049
8050 If the partition contains no main program, or if the main program is in
8051 a language other than Ada, then GNAT
8052 provides the binder options @option{-z} and @option{-n} respectively, and in
8053 this case a list of units can be explicitly supplied to the binder for
8054 inclusion in the partition (all units needed by these units will also
8055 be included automatically).  For full details on the use of these
8056 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8057 @value{EDITION} User's Guide}.
8058
8059 @sp 1
8060 @cartouche
8061 @noindent
8062 @strong{32}.  The implementation-defined means, if any, of specifying
8063 which compilation units are needed by a given compilation unit.  See
8064 10.2(2).
8065 @end cartouche
8066 @noindent
8067 The units needed by a given compilation unit are as defined in
8068 the Ada Reference Manual section 10.2(2-6).  There are no
8069 implementation-defined pragmas or other implementation-defined
8070 means for specifying needed units.
8071
8072 @sp 1
8073 @cartouche
8074 @noindent
8075 @strong{33}.  The manner of designating the main subprogram of a
8076 partition.  See 10.2(7).
8077 @end cartouche
8078 @noindent
8079 The main program is designated by providing the name of the
8080 corresponding @file{ALI} file as the input parameter to the binder.
8081
8082 @sp 1
8083 @cartouche
8084 @noindent
8085 @strong{34}.  The order of elaboration of @code{library_items}.  See
8086 10.2(18).
8087 @end cartouche
8088 @noindent
8089 The first constraint on ordering is that it meets the requirements of
8090 Chapter 10 of the Ada Reference Manual.  This still leaves some
8091 implementation dependent choices, which are resolved by first
8092 elaborating bodies as early as possible (i.e., in preference to specs
8093 where there is a choice), and second by evaluating the immediate with
8094 clauses of a unit to determine the probably best choice, and
8095 third by elaborating in alphabetical order of unit names
8096 where a choice still remains.
8097
8098 @sp 1
8099 @cartouche
8100 @noindent
8101 @strong{35}.  Parameter passing and function return for the main
8102 subprogram.  See 10.2(21).
8103 @end cartouche
8104 @noindent
8105 The main program has no parameters.  It may be a procedure, or a function
8106 returning an integer type.  In the latter case, the returned integer
8107 value is the return code of the program (overriding any value that
8108 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8109
8110 @sp 1
8111 @cartouche
8112 @noindent
8113 @strong{36}.  The mechanisms for building and running partitions.  See
8114 10.2(24).
8115 @end cartouche
8116 @noindent
8117 GNAT itself supports programs with only a single partition.  The GNATDIST
8118 tool provided with the GLADE package (which also includes an implementation
8119 of the PCS) provides a completely flexible method for building and running
8120 programs consisting of multiple partitions.  See the separate GLADE manual
8121 for details.
8122
8123 @sp 1
8124 @cartouche
8125 @noindent
8126 @strong{37}.  The details of program execution, including program
8127 termination.  See 10.2(25).
8128 @end cartouche
8129 @noindent
8130 See separate section on compilation model.
8131
8132 @sp 1
8133 @cartouche
8134 @noindent
8135 @strong{38}.  The semantics of any non-active partitions supported by the
8136 implementation.  See 10.2(28).
8137 @end cartouche
8138 @noindent
8139 Passive partitions are supported on targets where shared memory is
8140 provided by the operating system.  See the GLADE reference manual for
8141 further details.
8142
8143 @sp 1
8144 @cartouche
8145 @noindent
8146 @strong{39}.  The information returned by @code{Exception_Message}.  See
8147 11.4.1(10).
8148 @end cartouche
8149 @noindent
8150 Exception message returns the null string unless a specific message has
8151 been passed by the program.
8152
8153 @sp 1
8154 @cartouche
8155 @noindent
8156 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8157 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8158 @end cartouche
8159 @noindent
8160 Blocks have implementation defined names of the form @code{B@var{nnn}}
8161 where @var{nnn} is an integer.
8162
8163 @sp 1
8164 @cartouche
8165 @noindent
8166 @strong{41}.  The information returned by
8167 @code{Exception_Information}.  See 11.4.1(13).
8168 @end cartouche
8169 @noindent
8170 @code{Exception_Information} returns a string in the following format:
8171
8172 @smallexample
8173 @emph{Exception_Name:} nnnnn
8174 @emph{Message:} mmmmm
8175 @emph{PID:} ppp
8176 @emph{Call stack traceback locations:}
8177 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8178 @end smallexample
8179
8180 @noindent
8181 where
8182
8183 @itemize @bullet
8184 @item
8185 @code{nnnn} is the fully qualified name of the exception in all upper
8186 case letters. This line is always present.
8187
8188 @item
8189 @code{mmmm} is the message (this line present only if message is non-null)
8190
8191 @item
8192 @code{ppp} is the Process Id value as a decimal integer (this line is
8193 present only if the Process Id is nonzero). Currently we are
8194 not making use of this field.
8195
8196 @item
8197 The Call stack traceback locations line and the following values
8198 are present only if at least one traceback location was recorded.
8199 The values are given in C style format, with lower case letters
8200 for a-f, and only as many digits present as are necessary.
8201 @end itemize
8202
8203 @noindent
8204 The line terminator sequence at the end of each line, including
8205 the last line is a single @code{LF} character (@code{16#0A#}).
8206
8207 @sp 1
8208 @cartouche
8209 @noindent
8210 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8211 @end cartouche
8212 @noindent
8213 The implementation defined check name Alignment_Check controls checking of
8214 address clause values for proper alignment (that is, the address supplied
8215 must be consistent with the alignment of the type).
8216
8217 In addition, a user program can add implementation-defined check names
8218 by means of the pragma Check_Name.
8219
8220 @sp 1
8221 @cartouche
8222 @noindent
8223 @strong{43}.  The interpretation of each aspect of representation.  See
8224 13.1(20).
8225 @end cartouche
8226 @noindent
8227 See separate section on data representations.
8228
8229 @sp 1
8230 @cartouche
8231 @noindent
8232 @strong{44}.  Any restrictions placed upon representation items.  See
8233 13.1(20).
8234 @end cartouche
8235 @noindent
8236 See separate section on data representations.
8237
8238 @sp 1
8239 @cartouche
8240 @noindent
8241 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8242 13.3(48).
8243 @end cartouche
8244 @noindent
8245 Size for an indefinite subtype is the maximum possible size, except that
8246 for the case of a subprogram parameter, the size of the parameter object
8247 is the actual size.
8248
8249 @sp 1
8250 @cartouche
8251 @noindent
8252 @strong{46}.  The default external representation for a type tag.  See
8253 13.3(75).
8254 @end cartouche
8255 @noindent
8256 The default external representation for a type tag is the fully expanded
8257 name of the type in upper case letters.
8258
8259 @sp 1
8260 @cartouche
8261 @noindent
8262 @strong{47}.  What determines whether a compilation unit is the same in
8263 two different partitions.  See 13.3(76).
8264 @end cartouche
8265 @noindent
8266 A compilation unit is the same in two different partitions if and only
8267 if it derives from the same source file.
8268
8269 @sp 1
8270 @cartouche
8271 @noindent
8272 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8273 @end cartouche
8274 @noindent
8275 The only implementation defined component is the tag for a tagged type,
8276 which contains a pointer to the dispatching table.
8277
8278 @sp 1
8279 @cartouche
8280 @noindent
8281 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8282 ordering.  See 13.5.3(5).
8283 @end cartouche
8284 @noindent
8285 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8286 implementation, so no non-default bit ordering is supported.  The default
8287 bit ordering corresponds to the natural endianness of the target architecture.
8288
8289 @sp 1
8290 @cartouche
8291 @noindent
8292 @strong{50}.  The contents of the visible part of package @code{System}
8293 and its language-defined children.  See 13.7(2).
8294 @end cartouche
8295 @noindent
8296 See the definition of these packages in files @file{system.ads} and
8297 @file{s-stoele.ads}.
8298
8299 @sp 1
8300 @cartouche
8301 @noindent
8302 @strong{51}.  The contents of the visible part of package
8303 @code{System.Machine_Code}, and the meaning of
8304 @code{code_statements}.  See 13.8(7).
8305 @end cartouche
8306 @noindent
8307 See the definition and documentation in file @file{s-maccod.ads}.
8308
8309 @sp 1
8310 @cartouche
8311 @noindent
8312 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8313 @end cartouche
8314 @noindent
8315 Unchecked conversion between types of the same size
8316 results in an uninterpreted transmission of the bits from one type
8317 to the other.  If the types are of unequal sizes, then in the case of
8318 discrete types, a shorter source is first zero or sign extended as
8319 necessary, and a shorter target is simply truncated on the left.
8320 For all non-discrete types, the source is first copied if necessary
8321 to ensure that the alignment requirements of the target are met, then
8322 a pointer is constructed to the source value, and the result is obtained
8323 by dereferencing this pointer after converting it to be a pointer to the
8324 target type. Unchecked conversions where the target subtype is an
8325 unconstrained array are not permitted. If the target alignment is
8326 greater than the source alignment, then a copy of the result is
8327 made with appropriate alignment
8328
8329 @sp 1
8330 @cartouche
8331 @noindent
8332 @strong{53}.  The manner of choosing a storage pool for an access type
8333 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8334 @end cartouche
8335 @noindent
8336 There are 3 different standard pools used by the compiler when
8337 @code{Storage_Pool} is not specified depending whether the type is local
8338 to a subprogram or defined at the library level and whether
8339 @code{Storage_Size}is specified or not.  See documentation in the runtime
8340 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8341 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8342 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8343 default pools used.
8344
8345 @sp 1
8346 @cartouche
8347 @noindent
8348 @strong{54}.  Whether or not the implementation provides user-accessible
8349 names for the standard pool type(s).  See 13.11(17).
8350 @end cartouche
8351 @noindent
8352
8353 See documentation in the sources of the run time mentioned in paragraph
8354 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8355 these units.
8356
8357 @sp 1
8358 @cartouche
8359 @noindent
8360 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8361 @end cartouche
8362 @noindent
8363 @code{Storage_Size} is measured in storage units, and refers to the
8364 total space available for an access type collection, or to the primary
8365 stack space for a task.
8366
8367 @sp 1
8368 @cartouche
8369 @noindent
8370 @strong{56}.  Implementation-defined aspects of storage pools.  See
8371 13.11(22).
8372 @end cartouche
8373 @noindent
8374 See documentation in the sources of the run time mentioned in paragraph
8375 @strong{53} for details on GNAT-defined aspects of storage pools.
8376
8377 @sp 1
8378 @cartouche
8379 @noindent
8380 @strong{57}.  The set of restrictions allowed in a pragma
8381 @code{Restrictions}.  See 13.12(7).
8382 @end cartouche
8383 @noindent
8384 All RM defined Restriction identifiers are implemented.  The following
8385 additional restriction identifiers are provided.  There are two separate
8386 lists of implementation dependent restriction identifiers.  The first
8387 set requires consistency throughout a partition (in other words, if the
8388 restriction identifier is used for any compilation unit in the partition,
8389 then all compilation units in the partition must obey the restriction.
8390
8391 @table @code
8392
8393 @item Simple_Barriers
8394 @findex Simple_Barriers
8395 This restriction ensures at compile time that barriers in entry declarations
8396 for protected types are restricted to either static boolean expressions or
8397 references to simple boolean variables defined in the private part of the
8398 protected type.  No other form of entry barriers is permitted.  This is one
8399 of the restrictions of the Ravenscar profile for limited tasking (see also
8400 pragma @code{Profile (Ravenscar)}).
8401
8402 @item Max_Entry_Queue_Length => Expr
8403 @findex Max_Entry_Queue_Length
8404 This restriction is a declaration that any protected entry compiled in
8405 the scope of the restriction has at most the specified number of
8406 tasks waiting on the entry
8407 at any one time, and so no queue is required.  This restriction is not
8408 checked at compile time.  A program execution is erroneous if an attempt
8409 is made to queue more than the specified number of tasks on such an entry.
8410
8411 @item No_Calendar
8412 @findex No_Calendar
8413 This restriction ensures at compile time that there is no implicit or
8414 explicit dependence on the package @code{Ada.Calendar}.
8415
8416 @item No_Default_Initialization
8417 @findex No_Default_Initialization
8418
8419 This restriction prohibits any instance of default initialization of variables.
8420 The binder implements a consistency rule which prevents any unit compiled
8421 without the restriction from with'ing a unit with the restriction (this allows
8422 the generation of initialization procedures to be skipped, since you can be
8423 sure that no call is ever generated to an initialization procedure in a unit
8424 with the restriction active). If used in conjunction with Initialize_Scalars or
8425 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8426 without a specific initializer (including the case of OUT scalar parameters).
8427
8428 @item No_Direct_Boolean_Operators
8429 @findex No_Direct_Boolean_Operators
8430 This restriction ensures that no logical (and/or/xor) or comparison
8431 operators are used on operands of type Boolean (or any type derived
8432 from Boolean). This is intended for use in safety critical programs
8433 where the certification protocol requires the use of short-circuit
8434 (and then, or else) forms for all composite boolean operations.
8435
8436 @item No_Dispatching_Calls
8437 @findex No_Dispatching_Calls
8438 This restriction ensures at compile time that the code generated by the
8439 compiler involves no dispatching calls. The use of this restriction allows the
8440 safe use of record extensions, classwide membership tests and other classwide
8441 features not involving implicit dispatching. This restriction ensures that
8442 the code contains no indirect calls through a dispatching mechanism. Note that
8443 this includes internally-generated calls created by the compiler, for example
8444 in the implementation of class-wide objects assignments. The
8445 membership test is allowed in the presence of this restriction, because its
8446 implementation requires no dispatching.
8447 This restriction is comparable to the official Ada restriction
8448 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8449 all classwide constructs that do not imply dispatching.
8450 The following example indicates constructs that violate this restriction.
8451
8452 @smallexample
8453 package Pkg is
8454   type T is tagged record
8455     Data : Natural;
8456   end record;
8457   procedure P (X : T);
8458
8459   type DT is new T with record
8460     More_Data : Natural;
8461   end record;
8462   procedure Q (X : DT);
8463 end Pkg;
8464
8465 with Pkg; use Pkg;
8466 procedure Example is
8467   procedure Test (O : T'Class) is
8468     N : Natural  := O'Size;--  Error: Dispatching call
8469     C : T'Class := O;      --  Error: implicit Dispatching Call
8470   begin
8471     if O in DT'Class then  --  OK   : Membership test
8472        Q (DT (O));         --  OK   : Type conversion plus direct call
8473     else
8474        P (O);              --  Error: Dispatching call
8475     end if;
8476   end Test;
8477
8478   Obj : DT;
8479 begin
8480   P (Obj);                 --  OK   : Direct call
8481   P (T (Obj));             --  OK   : Type conversion plus direct call
8482   P (T'Class (Obj));       --  Error: Dispatching call
8483
8484   Test (Obj);              --  OK   : Type conversion
8485
8486   if Obj in T'Class then   --  OK   : Membership test
8487      null;
8488   end if;
8489 end Example;
8490 @end smallexample
8491
8492 @item No_Dynamic_Attachment
8493 @findex No_Dynamic_Attachment
8494 This restriction ensures that there is no call to any of the operations
8495 defined in package Ada.Interrupts.
8496
8497 @item No_Enumeration_Maps
8498 @findex No_Enumeration_Maps
8499 This restriction ensures at compile time that no operations requiring
8500 enumeration maps are used (that is Image and Value attributes applied
8501 to enumeration types).
8502
8503 @item No_Entry_Calls_In_Elaboration_Code
8504 @findex No_Entry_Calls_In_Elaboration_Code
8505 This restriction ensures at compile time that no task or protected entry
8506 calls are made during elaboration code.  As a result of the use of this
8507 restriction, the compiler can assume that no code past an accept statement
8508 in a task can be executed at elaboration time.
8509
8510 @item No_Exception_Handlers
8511 @findex No_Exception_Handlers
8512 This restriction ensures at compile time that there are no explicit
8513 exception handlers. It also indicates that no exception propagation will
8514 be provided. In this mode, exceptions may be raised but will result in
8515 an immediate call to the last chance handler, a routine that the user
8516 must define with the following profile:
8517
8518 @smallexample @c ada
8519 procedure Last_Chance_Handler
8520   (Source_Location : System.Address; Line : Integer);
8521 pragma Export (C, Last_Chance_Handler,
8522                "__gnat_last_chance_handler");
8523 @end smallexample
8524
8525 The parameter is a C null-terminated string representing a message to be
8526 associated with the exception (typically the source location of the raise
8527 statement generated by the compiler). The Line parameter when nonzero
8528 represents the line number in the source program where the raise occurs.
8529
8530 @item No_Exception_Propagation
8531 @findex No_Exception_Propagation
8532 This restriction guarantees that exceptions are never propagated to an outer
8533 subprogram scope). The only case in which an exception may be raised is when
8534 the handler is statically in the same subprogram, so that the effect of a raise
8535 is essentially like a goto statement. Any other raise statement (implicit or
8536 explicit) will be considered unhandled. Exception handlers are allowed, but may
8537 not contain an exception occurrence identifier (exception choice). In addition
8538 use of the package GNAT.Current_Exception is not permitted, and reraise
8539 statements (raise with no operand) are not permitted.
8540
8541 @item No_Exception_Registration
8542 @findex No_Exception_Registration
8543 This restriction ensures at compile time that no stream operations for
8544 types Exception_Id or Exception_Occurrence are used. This also makes it
8545 impossible to pass exceptions to or from a partition with this restriction
8546 in a distributed environment. If this exception is active, then the generated
8547 code is simplified by omitting the otherwise-required global registration
8548 of exceptions when they are declared.
8549
8550 @item No_Implicit_Conditionals
8551 @findex No_Implicit_Conditionals
8552 This restriction ensures that the generated code does not contain any
8553 implicit conditionals, either by modifying the generated code where possible,
8554 or by rejecting any construct that would otherwise generate an implicit
8555 conditional. Note that this check does not include run time constraint
8556 checks, which on some targets may generate implicit conditionals as
8557 well. To control the latter, constraint checks can be suppressed in the
8558 normal manner. Constructs generating implicit conditionals include comparisons
8559 of composite objects and the Max/Min attributes.
8560
8561 @item No_Implicit_Dynamic_Code
8562 @findex No_Implicit_Dynamic_Code
8563 @cindex trampoline
8564 This restriction prevents the compiler from building ``trampolines''.
8565 This is a structure that is built on the stack and contains dynamic
8566 code to be executed at run time. On some targets, a trampoline is
8567 built for the following features: @code{Access},
8568 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8569 nested task bodies; primitive operations of nested tagged types.
8570 Trampolines do not work on machines that prevent execution of stack
8571 data. For example, on windows systems, enabling DEP (data execution
8572 protection) will cause trampolines to raise an exception.
8573 Trampolines are also quite slow at run time.
8574
8575 On many targets, trampolines have been largely eliminated. Look at the
8576 version of system.ads for your target --- if it has
8577 Always_Compatible_Rep equal to False, then trampolines are largely
8578 eliminated. In particular, a trampoline is built for the following
8579 features: @code{Address} of a nested subprogram;
8580 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8581 but only if pragma Favor_Top_Level applies, or the access type has a
8582 foreign-language convention; primitive operations of nested tagged
8583 types.
8584
8585 @item No_Implicit_Loops
8586 @findex No_Implicit_Loops
8587 This restriction ensures that the generated code does not contain any
8588 implicit @code{for} loops, either by modifying
8589 the generated code where possible,
8590 or by rejecting any construct that would otherwise generate an implicit
8591 @code{for} loop. If this restriction is active, it is possible to build
8592 large array aggregates with all static components without generating an
8593 intermediate temporary, and without generating a loop to initialize individual
8594 components. Otherwise, a loop is created for arrays larger than about 5000
8595 scalar components.
8596
8597 @item No_Initialize_Scalars
8598 @findex No_Initialize_Scalars
8599 This restriction ensures that no unit in the partition is compiled with
8600 pragma Initialize_Scalars. This allows the generation of more efficient
8601 code, and in particular eliminates dummy null initialization routines that
8602 are otherwise generated for some record and array types.
8603
8604 @item No_Local_Protected_Objects
8605 @findex No_Local_Protected_Objects
8606 This restriction ensures at compile time that protected objects are
8607 only declared at the library level.
8608
8609 @item No_Protected_Type_Allocators
8610 @findex No_Protected_Type_Allocators
8611 This restriction ensures at compile time that there are no allocator
8612 expressions that attempt to allocate protected objects.
8613
8614 @item No_Secondary_Stack
8615 @findex No_Secondary_Stack
8616 This restriction ensures at compile time that the generated code does not
8617 contain any reference to the secondary stack.  The secondary stack is used
8618 to implement functions returning unconstrained objects (arrays or records)
8619 on some targets.
8620
8621 @item No_Select_Statements
8622 @findex No_Select_Statements
8623 This restriction ensures at compile time no select statements of any kind
8624 are permitted, that is the keyword @code{select} may not appear.
8625 This is one of the restrictions of the Ravenscar
8626 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8627
8628 @item No_Standard_Storage_Pools
8629 @findex No_Standard_Storage_Pools
8630 This restriction ensures at compile time that no access types
8631 use the standard default storage pool.  Any access type declared must
8632 have an explicit Storage_Pool attribute defined specifying a
8633 user-defined storage pool.
8634
8635 @item No_Streams
8636 @findex No_Streams
8637 This restriction ensures at compile/bind time that there are no
8638 stream objects created and no use of stream attributes.
8639 This restriction does not forbid dependences on the package
8640 @code{Ada.Streams}. So it is permissible to with
8641 @code{Ada.Streams} (or another package that does so itself)
8642 as long as no actual stream objects are created and no
8643 stream attributes are used.
8644
8645 Note that the use of restriction allows optimization of tagged types,
8646 since they do not need to worry about dispatching stream operations.
8647 To take maximum advantage of this space-saving optimization, any
8648 unit declaring a tagged type should be compiled with the restriction,
8649 though this is not required.
8650
8651 @item No_Task_Attributes_Package
8652 @findex No_Task_Attributes_Package
8653 This restriction ensures at compile time that there are no implicit or
8654 explicit dependencies on the package @code{Ada.Task_Attributes}.
8655
8656 @item No_Task_Termination
8657 @findex No_Task_Termination
8658 This restriction ensures at compile time that no terminate alternatives
8659 appear in any task body.
8660
8661 @item No_Tasking
8662 @findex No_Tasking
8663 This restriction prevents the declaration of tasks or task types throughout
8664 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8665 except that violations are caught at compile time and cause an error message
8666 to be output either by the compiler or binder.
8667
8668 @item Static_Priorities
8669 @findex Static_Priorities
8670 This restriction ensures at compile time that all priority expressions
8671 are static, and that there are no dependencies on the package
8672 @code{Ada.Dynamic_Priorities}.
8673
8674 @item Static_Storage_Size
8675 @findex Static_Storage_Size
8676 This restriction ensures at compile time that any expression appearing
8677 in a Storage_Size pragma or attribute definition clause is static.
8678
8679 @end table
8680
8681 @noindent
8682 The second set of implementation dependent restriction identifiers
8683 does not require partition-wide consistency.
8684 The restriction may be enforced for a single
8685 compilation unit without any effect on any of the
8686 other compilation units in the partition.
8687
8688 @table @code
8689
8690 @item No_Elaboration_Code
8691 @findex No_Elaboration_Code
8692 This restriction ensures at compile time that no elaboration code is
8693 generated.  Note that this is not the same condition as is enforced
8694 by pragma @code{Preelaborate}.  There are cases in which pragma
8695 @code{Preelaborate} still permits code to be generated (e.g.@: code
8696 to initialize a large array to all zeroes), and there are cases of units
8697 which do not meet the requirements for pragma @code{Preelaborate},
8698 but for which no elaboration code is generated.  Generally, it is
8699 the case that preelaborable units will meet the restrictions, with
8700 the exception of large aggregates initialized with an others_clause,
8701 and exception declarations (which generate calls to a run-time
8702 registry procedure).  This restriction is enforced on
8703 a unit by unit basis, it need not be obeyed consistently
8704 throughout a partition.
8705
8706 In the case of aggregates with others, if the aggregate has a dynamic
8707 size, there is no way to eliminate the elaboration code (such dynamic
8708 bounds would be incompatible with @code{Preelaborate} in any case). If
8709 the bounds are static, then use of this restriction actually modifies
8710 the code choice of the compiler to avoid generating a loop, and instead
8711 generate the aggregate statically if possible, no matter how many times
8712 the data for the others clause must be repeatedly generated.
8713
8714 It is not possible to precisely document
8715 the constructs which are compatible with this restriction, since,
8716 unlike most other restrictions, this is not a restriction on the
8717 source code, but a restriction on the generated object code. For
8718 example, if the source contains a declaration:
8719
8720 @smallexample
8721    Val : constant Integer := X;
8722 @end smallexample
8723
8724 @noindent
8725 where X is not a static constant, it may be possible, depending
8726 on complex optimization circuitry, for the compiler to figure
8727 out the value of X at compile time, in which case this initialization
8728 can be done by the loader, and requires no initialization code. It
8729 is not possible to document the precise conditions under which the
8730 optimizer can figure this out.
8731
8732 Note that this the implementation of this restriction requires full
8733 code generation. If it is used in conjunction with "semantics only"
8734 checking, then some cases of violations may be missed.
8735
8736 @item No_Entry_Queue
8737 @findex No_Entry_Queue
8738 This restriction is a declaration that any protected entry compiled in
8739 the scope of the restriction has at most one task waiting on the entry
8740 at any one time, and so no queue is required.  This restriction is not
8741 checked at compile time.  A program execution is erroneous if an attempt
8742 is made to queue a second task on such an entry.
8743
8744 @item No_Implementation_Attributes
8745 @findex No_Implementation_Attributes
8746 This restriction checks at compile time that no GNAT-defined attributes
8747 are present.  With this restriction, the only attributes that can be used
8748 are those defined in the Ada Reference Manual.
8749
8750 @item No_Implementation_Pragmas
8751 @findex No_Implementation_Pragmas
8752 This restriction checks at compile time that no GNAT-defined pragmas
8753 are present.  With this restriction, the only pragmas that can be used
8754 are those defined in the Ada Reference Manual.
8755
8756 @item No_Implementation_Restrictions
8757 @findex No_Implementation_Restrictions
8758 This restriction checks at compile time that no GNAT-defined restriction
8759 identifiers (other than @code{No_Implementation_Restrictions} itself)
8760 are present.  With this restriction, the only other restriction identifiers
8761 that can be used are those defined in the Ada Reference Manual.
8762
8763 @item No_Wide_Characters
8764 @findex No_Wide_Characters
8765 This restriction ensures at compile time that no uses of the types
8766 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8767 wide types
8768 appear, and that no wide or wide wide string or character literals
8769 appear in the program (that is literals representing characters not in
8770 type @code{Character}.
8771
8772 @end table
8773
8774 @sp 1
8775 @cartouche
8776 @noindent
8777 @strong{58}.  The consequences of violating limitations on
8778 @code{Restrictions} pragmas.  See 13.12(9).
8779 @end cartouche
8780 @noindent
8781 Restrictions that can be checked at compile time result in illegalities
8782 if violated.  Currently there are no other consequences of violating
8783 restrictions.
8784
8785 @sp 1
8786 @cartouche
8787 @noindent
8788 @strong{59}.  The representation used by the @code{Read} and
8789 @code{Write} attributes of elementary types in terms of stream
8790 elements.  See 13.13.2(9).
8791 @end cartouche
8792 @noindent
8793 The representation is the in-memory representation of the base type of
8794 the type, using the number of bits corresponding to the
8795 @code{@var{type}'Size} value, and the natural ordering of the machine.
8796
8797 @sp 1
8798 @cartouche
8799 @noindent
8800 @strong{60}.  The names and characteristics of the numeric subtypes
8801 declared in the visible part of package @code{Standard}.  See A.1(3).
8802 @end cartouche
8803 @noindent
8804 See items describing the integer and floating-point types supported.
8805
8806 @sp 1
8807 @cartouche
8808 @noindent
8809 @strong{61}.  The accuracy actually achieved by the elementary
8810 functions.  See A.5.1(1).
8811 @end cartouche
8812 @noindent
8813 The elementary functions correspond to the functions available in the C
8814 library.  Only fast math mode is implemented.
8815
8816 @sp 1
8817 @cartouche
8818 @noindent
8819 @strong{62}.  The sign of a zero result from some of the operators or
8820 functions in @code{Numerics.Generic_Elementary_Functions}, when
8821 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8822 @end cartouche
8823 @noindent
8824 The sign of zeroes follows the requirements of the IEEE 754 standard on
8825 floating-point.
8826
8827 @sp 1
8828 @cartouche
8829 @noindent
8830 @strong{63}.  The value of
8831 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8832 @end cartouche
8833 @noindent
8834 Maximum image width is 649, see library file @file{a-numran.ads}.
8835
8836 @sp 1
8837 @cartouche
8838 @noindent
8839 @strong{64}.  The value of
8840 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8841 @end cartouche
8842 @noindent
8843 Maximum image width is 80, see library file @file{a-nudira.ads}.
8844
8845 @sp 1
8846 @cartouche
8847 @noindent
8848 @strong{65}.  The algorithms for random number generation.  See
8849 A.5.2(32).
8850 @end cartouche
8851 @noindent
8852 The algorithm is documented in the source files @file{a-numran.ads} and
8853 @file{a-numran.adb}.
8854
8855 @sp 1
8856 @cartouche
8857 @noindent
8858 @strong{66}.  The string representation of a random number generator's
8859 state.  See A.5.2(38).
8860 @end cartouche
8861 @noindent
8862 See the documentation contained in the file @file{a-numran.adb}.
8863
8864 @sp 1
8865 @cartouche
8866 @noindent
8867 @strong{67}.  The minimum time interval between calls to the
8868 time-dependent Reset procedure that are guaranteed to initiate different
8869 random number sequences.  See A.5.2(45).
8870 @end cartouche
8871 @noindent
8872 The minimum period between reset calls to guarantee distinct series of
8873 random numbers is one microsecond.
8874
8875 @sp 1
8876 @cartouche
8877 @noindent
8878 @strong{68}.  The values of the @code{Model_Mantissa},
8879 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8880 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8881 Annex is not supported.  See A.5.3(72).
8882 @end cartouche
8883 @noindent
8884 See the source file @file{ttypef.ads} for the values of all numeric
8885 attributes.
8886
8887 @sp 1
8888 @cartouche
8889 @noindent
8890 @strong{69}.  Any implementation-defined characteristics of the
8891 input-output packages.  See A.7(14).
8892 @end cartouche
8893 @noindent
8894 There are no special implementation defined characteristics for these
8895 packages.
8896
8897 @sp 1
8898 @cartouche
8899 @noindent
8900 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8901 A.9(10).
8902 @end cartouche
8903 @noindent
8904 All type representations are contiguous, and the @code{Buffer_Size} is
8905 the value of @code{@var{type}'Size} rounded up to the next storage unit
8906 boundary.
8907
8908 @sp 1
8909 @cartouche
8910 @noindent
8911 @strong{71}.  External files for standard input, standard output, and
8912 standard error See A.10(5).
8913 @end cartouche
8914 @noindent
8915 These files are mapped onto the files provided by the C streams
8916 libraries.  See source file @file{i-cstrea.ads} for further details.
8917
8918 @sp 1
8919 @cartouche
8920 @noindent
8921 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8922 A.10.9(36).
8923 @end cartouche
8924 @noindent
8925 If more digits are requested in the output than are represented by the
8926 precision of the value, zeroes are output in the corresponding least
8927 significant digit positions.
8928
8929 @sp 1
8930 @cartouche
8931 @noindent
8932 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8933 @code{Command_Name}.  See A.15(1).
8934 @end cartouche
8935 @noindent
8936 These are mapped onto the @code{argv} and @code{argc} parameters of the
8937 main program in the natural manner.
8938
8939 @sp 1
8940 @cartouche
8941 @noindent
8942 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8943 @end cartouche
8944 @noindent
8945 The following convention names are supported
8946
8947 @table @code
8948 @item  Ada
8949 Ada
8950 @item Assembler
8951 Assembly language
8952 @item Asm
8953 Synonym for Assembler
8954 @item Assembly
8955 Synonym for Assembler
8956 @item C
8957 C
8958 @item C_Pass_By_Copy
8959 Allowed only for record types, like C, but also notes that record
8960 is to be passed by copy rather than reference.
8961 @item COBOL
8962 COBOL
8963 @item C_Plus_Plus (or CPP)
8964 C++
8965 @item Default
8966 Treated the same as C
8967 @item External
8968 Treated the same as C
8969 @item Fortran
8970 Fortran
8971 @item Intrinsic
8972 For support of pragma @code{Import} with convention Intrinsic, see
8973 separate section on Intrinsic Subprograms.
8974 @item Stdcall
8975 Stdcall (used for Windows implementations only).  This convention correspond
8976 to the WINAPI (previously called Pascal convention) C/C++ convention under
8977 Windows.  A function with this convention cleans the stack before exit.
8978 @item DLL
8979 Synonym for Stdcall
8980 @item Win32
8981 Synonym for Stdcall
8982 @item Stubbed
8983 Stubbed is a special convention used to indicate that the body of the
8984 subprogram will be entirely ignored.  Any call to the subprogram
8985 is converted into a raise of the @code{Program_Error} exception.  If a
8986 pragma @code{Import} specifies convention @code{stubbed} then no body need
8987 be present at all.  This convention is useful during development for the
8988 inclusion of subprograms whose body has not yet been written.
8989
8990 @end table
8991 @noindent
8992 In addition, all otherwise unrecognized convention names are also
8993 treated as being synonymous with convention C@.  In all implementations
8994 except for VMS, use of such other names results in a warning.  In VMS
8995 implementations, these names are accepted silently.
8996
8997 @sp 1
8998 @cartouche
8999 @noindent
9000 @strong{75}.  The meaning of link names.  See B.1(36).
9001 @end cartouche
9002 @noindent
9003 Link names are the actual names used by the linker.
9004
9005 @sp 1
9006 @cartouche
9007 @noindent
9008 @strong{76}.  The manner of choosing link names when neither the link
9009 name nor the address of an imported or exported entity is specified.  See
9010 B.1(36).
9011 @end cartouche
9012 @noindent
9013 The default linker name is that which would be assigned by the relevant
9014 external language, interpreting the Ada name as being in all lower case
9015 letters.
9016
9017 @sp 1
9018 @cartouche
9019 @noindent
9020 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9021 @end cartouche
9022 @noindent
9023 The string passed to @code{Linker_Options} is presented uninterpreted as
9024 an argument to the link command, unless it contains ASCII.NUL characters.
9025 NUL characters if they appear act as argument separators, so for example
9026
9027 @smallexample @c ada
9028 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9029 @end smallexample
9030
9031 @noindent
9032 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9033 linker. The order of linker options is preserved for a given unit. The final
9034 list of options passed to the linker is in reverse order of the elaboration
9035 order. For example, linker options for a body always appear before the options
9036 from the corresponding package spec.
9037
9038 @sp 1
9039 @cartouche
9040 @noindent
9041 @strong{78}.  The contents of the visible part of package
9042 @code{Interfaces} and its language-defined descendants.  See B.2(1).
9043 @end cartouche
9044 @noindent
9045 See files with prefix @file{i-} in the distributed library.
9046
9047 @sp 1
9048 @cartouche
9049 @noindent
9050 @strong{79}.  Implementation-defined children of package
9051 @code{Interfaces}.  The contents of the visible part of package
9052 @code{Interfaces}.  See B.2(11).
9053 @end cartouche
9054 @noindent
9055 See files with prefix @file{i-} in the distributed library.
9056
9057 @sp 1
9058 @cartouche
9059 @noindent
9060 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
9061 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9062 @code{COBOL_Character}; and the initialization of the variables
9063 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9064 @code{Interfaces.COBOL}.  See B.4(50).
9065 @end cartouche
9066 @noindent
9067 @table @code
9068 @item Floating
9069 Float
9070 @item Long_Floating
9071 (Floating) Long_Float
9072 @item Binary
9073 Integer
9074 @item Long_Binary
9075 Long_Long_Integer
9076 @item Decimal_Element
9077 Character
9078 @item COBOL_Character
9079 Character
9080 @end table
9081
9082 @noindent
9083 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9084
9085 @sp 1
9086 @cartouche
9087 @noindent
9088 @strong{81}.  Support for access to machine instructions.  See C.1(1).
9089 @end cartouche
9090 @noindent
9091 See documentation in file @file{s-maccod.ads} in the distributed library.
9092
9093 @sp 1
9094 @cartouche
9095 @noindent
9096 @strong{82}.  Implementation-defined aspects of access to machine
9097 operations.  See C.1(9).
9098 @end cartouche
9099 @noindent
9100 See documentation in file @file{s-maccod.ads} in the distributed library.
9101
9102 @sp 1
9103 @cartouche
9104 @noindent
9105 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
9106 @end cartouche
9107 @noindent
9108 Interrupts are mapped to signals or conditions as appropriate.  See
9109 definition of unit
9110 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9111 on the interrupts supported on a particular target.
9112
9113 @sp 1
9114 @cartouche
9115 @noindent
9116 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
9117 C.4(13).
9118 @end cartouche
9119 @noindent
9120 GNAT does not permit a partition to be restarted without reloading,
9121 except under control of the debugger.
9122
9123 @sp 1
9124 @cartouche
9125 @noindent
9126 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9127 @end cartouche
9128 @noindent
9129 Pragma @code{Discard_Names} causes names of enumeration literals to
9130 be suppressed.  In the presence of this pragma, the Image attribute
9131 provides the image of the Pos of the literal, and Value accepts
9132 Pos values.
9133
9134 @sp 1
9135 @cartouche
9136 @noindent
9137 @strong{86}.  The result of the @code{Task_Identification.Image}
9138 attribute.  See C.7.1(7).
9139 @end cartouche
9140 @noindent
9141 The result of this attribute is a string that identifies
9142 the object or component that denotes a given task. If a variable @code{Var}
9143 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9144 where the suffix
9145 is the hexadecimal representation of the virtual address of the corresponding
9146 task control block. If the variable is an array of tasks, the image of each
9147 task will have the form of an indexed component indicating the position of a
9148 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9149 component of a record, the image of the task will have the form of a selected
9150 component. These rules are fully recursive, so that the image of a task that
9151 is a subcomponent of a composite object corresponds to the expression that
9152 designates this task.
9153 @noindent
9154 If a task is created by an allocator, its image depends on the context. If the
9155 allocator is part of an object declaration, the rules described above are used
9156 to construct its image, and this image is not affected by subsequent
9157 assignments. If the allocator appears within an expression, the image
9158 includes only the name of the task type.
9159 @noindent
9160 If the configuration pragma Discard_Names is present, or if the restriction
9161 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9162 the numeric suffix, that is to say the hexadecimal representation of the
9163 virtual address of the control block of the task.
9164 @sp 1
9165 @cartouche
9166 @noindent
9167 @strong{87}.  The value of @code{Current_Task} when in a protected entry
9168 or interrupt handler.  See C.7.1(17).
9169 @end cartouche
9170 @noindent
9171 Protected entries or interrupt handlers can be executed by any
9172 convenient thread, so the value of @code{Current_Task} is undefined.
9173
9174 @sp 1
9175 @cartouche
9176 @noindent
9177 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9178 body or interrupt handler.  See C.7.1(19).
9179 @end cartouche
9180 @noindent
9181 The effect of calling @code{Current_Task} from an entry body or
9182 interrupt handler is to return the identification of the task currently
9183 executing the code.
9184
9185 @sp 1
9186 @cartouche
9187 @noindent
9188 @strong{89}.  Implementation-defined aspects of
9189 @code{Task_Attributes}.  See C.7.2(19).
9190 @end cartouche
9191 @noindent
9192 There are no implementation-defined aspects of @code{Task_Attributes}.
9193
9194 @sp 1
9195 @cartouche
9196 @noindent
9197 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9198 @end cartouche
9199 @noindent
9200 The metrics information for GNAT depends on the performance of the
9201 underlying operating system.  The sources of the run-time for tasking
9202 implementation, together with the output from @option{-gnatG} can be
9203 used to determine the exact sequence of operating systems calls made
9204 to implement various tasking constructs.  Together with appropriate
9205 information on the performance of the underlying operating system,
9206 on the exact target in use, this information can be used to determine
9207 the required metrics.
9208
9209 @sp 1
9210 @cartouche
9211 @noindent
9212 @strong{91}.  The declarations of @code{Any_Priority} and
9213 @code{Priority}.  See D.1(11).
9214 @end cartouche
9215 @noindent
9216 See declarations in file @file{system.ads}.
9217
9218 @sp 1
9219 @cartouche
9220 @noindent
9221 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9222 @end cartouche
9223 @noindent
9224 There are no implementation-defined execution resources.
9225
9226 @sp 1
9227 @cartouche
9228 @noindent
9229 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9230 access to a protected object keeps its processor busy.  See D.2.1(3).
9231 @end cartouche
9232 @noindent
9233 On a multi-processor, a task that is waiting for access to a protected
9234 object does not keep its processor busy.
9235
9236 @sp 1
9237 @cartouche
9238 @noindent
9239 @strong{94}.  The affect of implementation defined execution resources
9240 on task dispatching.  See D.2.1(9).
9241 @end cartouche
9242 @noindent
9243 @c SGI info
9244 @ignore
9245 Tasks map to IRIX threads, and the dispatching policy is as defined by
9246 the IRIX implementation of threads.
9247 @end ignore
9248 Tasks map to threads in the threads package used by GNAT@.  Where possible
9249 and appropriate, these threads correspond to native threads of the
9250 underlying operating system.
9251
9252 @sp 1
9253 @cartouche
9254 @noindent
9255 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9256 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9257 @end cartouche
9258 @noindent
9259 There are no implementation-defined policy-identifiers allowed in this
9260 pragma.
9261
9262 @sp 1
9263 @cartouche
9264 @noindent
9265 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9266 D.2.2(16).
9267 @end cartouche
9268 @noindent
9269 Execution of a task cannot be preempted by the implementation processing
9270 of delay expirations for lower priority tasks.
9271
9272 @sp 1
9273 @cartouche
9274 @noindent
9275 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9276 @end cartouche
9277 @noindent
9278 @c SGI info:
9279 @ignore
9280 Tasks map to IRIX threads, and the dispatching policy is as defined by
9281 the IRIX implementation of threads.
9282 @end ignore
9283 The policy is the same as that of the underlying threads implementation.
9284
9285 @sp 1
9286 @cartouche
9287 @noindent
9288 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9289 in a pragma @code{Locking_Policy}.  See D.3(4).
9290 @end cartouche
9291 @noindent
9292 The only implementation defined policy permitted in GNAT is
9293 @code{Inheritance_Locking}.  On targets that support this policy, locking
9294 is implemented by inheritance, i.e.@: the task owning the lock operates
9295 at a priority equal to the highest priority of any task currently
9296 requesting the lock.
9297
9298 @sp 1
9299 @cartouche
9300 @noindent
9301 @strong{99}.  Default ceiling priorities.  See D.3(10).
9302 @end cartouche
9303 @noindent
9304 The ceiling priority of protected objects of the type
9305 @code{System.Interrupt_Priority'Last} as described in the Ada
9306 Reference Manual D.3(10),
9307
9308 @sp 1
9309 @cartouche
9310 @noindent
9311 @strong{100}.  The ceiling of any protected object used internally by
9312 the implementation.  See D.3(16).
9313 @end cartouche
9314 @noindent
9315 The ceiling priority of internal protected objects is
9316 @code{System.Priority'Last}.
9317
9318 @sp 1
9319 @cartouche
9320 @noindent
9321 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9322 @end cartouche
9323 @noindent
9324 There are no implementation-defined queuing policies.
9325
9326 @sp 1
9327 @cartouche
9328 @noindent
9329 @strong{102}.  On a multiprocessor, any conditions that cause the
9330 completion of an aborted construct to be delayed later than what is
9331 specified for a single processor.  See D.6(3).
9332 @end cartouche
9333 @noindent
9334 The semantics for abort on a multi-processor is the same as on a single
9335 processor, there are no further delays.
9336
9337 @sp 1
9338 @cartouche
9339 @noindent
9340 @strong{103}.  Any operations that implicitly require heap storage
9341 allocation.  See D.7(8).
9342 @end cartouche
9343 @noindent
9344 The only operation that implicitly requires heap storage allocation is
9345 task creation.
9346
9347 @sp 1
9348 @cartouche
9349 @noindent
9350 @strong{104}.  Implementation-defined aspects of pragma
9351 @code{Restrictions}.  See D.7(20).
9352 @end cartouche
9353 @noindent
9354 There are no such implementation-defined aspects.
9355
9356 @sp 1
9357 @cartouche
9358 @noindent
9359 @strong{105}.  Implementation-defined aspects of package
9360 @code{Real_Time}.  See D.8(17).
9361 @end cartouche
9362 @noindent
9363 There are no implementation defined aspects of package @code{Real_Time}.
9364
9365 @sp 1
9366 @cartouche
9367 @noindent
9368 @strong{106}.  Implementation-defined aspects of
9369 @code{delay_statements}.  See D.9(8).
9370 @end cartouche
9371 @noindent
9372 Any difference greater than one microsecond will cause the task to be
9373 delayed (see D.9(7)).
9374
9375 @sp 1
9376 @cartouche
9377 @noindent
9378 @strong{107}.  The upper bound on the duration of interrupt blocking
9379 caused by the implementation.  See D.12(5).
9380 @end cartouche
9381 @noindent
9382 The upper bound is determined by the underlying operating system.  In
9383 no cases is it more than 10 milliseconds.
9384
9385 @sp 1
9386 @cartouche
9387 @noindent
9388 @strong{108}.  The means for creating and executing distributed
9389 programs.  See E(5).
9390 @end cartouche
9391 @noindent
9392 The GLADE package provides a utility GNATDIST for creating and executing
9393 distributed programs.  See the GLADE reference manual for further details.
9394
9395 @sp 1
9396 @cartouche
9397 @noindent
9398 @strong{109}.  Any events that can result in a partition becoming
9399 inaccessible.  See E.1(7).
9400 @end cartouche
9401 @noindent
9402 See the GLADE reference manual for full details on such events.
9403
9404 @sp 1
9405 @cartouche
9406 @noindent
9407 @strong{110}.  The scheduling policies, treatment of priorities, and
9408 management of shared resources between partitions in certain cases.  See
9409 E.1(11).
9410 @end cartouche
9411 @noindent
9412 See the GLADE reference manual for full details on these aspects of
9413 multi-partition execution.
9414
9415 @sp 1
9416 @cartouche
9417 @noindent
9418 @strong{111}.  Events that cause the version of a compilation unit to
9419 change.  See E.3(5).
9420 @end cartouche
9421 @noindent
9422 Editing the source file of a compilation unit, or the source files of
9423 any units on which it is dependent in a significant way cause the version
9424 to change.  No other actions cause the version number to change.  All changes
9425 are significant except those which affect only layout, capitalization or
9426 comments.
9427
9428 @sp 1
9429 @cartouche
9430 @noindent
9431 @strong{112}.  Whether the execution of the remote subprogram is
9432 immediately aborted as a result of cancellation.  See E.4(13).
9433 @end cartouche
9434 @noindent
9435 See the GLADE reference manual for details on the effect of abort in
9436 a distributed application.
9437
9438 @sp 1
9439 @cartouche
9440 @noindent
9441 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9442 @end cartouche
9443 @noindent
9444 See the GLADE reference manual for a full description of all implementation
9445 defined aspects of the PCS@.
9446
9447 @sp 1
9448 @cartouche
9449 @noindent
9450 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9451 E.5(26).
9452 @end cartouche
9453 @noindent
9454 See the GLADE reference manual for a full description of all
9455 implementation defined interfaces.
9456
9457 @sp 1
9458 @cartouche
9459 @noindent
9460 @strong{115}.  The values of named numbers in the package
9461 @code{Decimal}.  See F.2(7).
9462 @end cartouche
9463 @noindent
9464 @table @code
9465 @item Max_Scale
9466 +18
9467 @item Min_Scale
9468 -18
9469 @item Min_Delta
9470 1.0E-18
9471 @item Max_Delta
9472 1.0E+18
9473 @item Max_Decimal_Digits
9474 18
9475 @end table
9476
9477 @sp 1
9478 @cartouche
9479 @noindent
9480 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9481 @code{Text_IO.Editing}.  See F.3.3(16).
9482 @end cartouche
9483 @noindent
9484 64
9485
9486 @sp 1
9487 @cartouche
9488 @noindent
9489 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9490 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9491 @end cartouche
9492 @noindent
9493 64
9494
9495 @sp 1
9496 @cartouche
9497 @noindent
9498 @strong{118}.  The accuracy actually achieved by the complex elementary
9499 functions and by other complex arithmetic operations.  See G.1(1).
9500 @end cartouche
9501 @noindent
9502 Standard library functions are used for the complex arithmetic
9503 operations.  Only fast math mode is currently supported.
9504
9505 @sp 1
9506 @cartouche
9507 @noindent
9508 @strong{119}.  The sign of a zero result (or a component thereof) from
9509 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9510 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9511 @end cartouche
9512 @noindent
9513 The signs of zero values are as recommended by the relevant
9514 implementation advice.
9515
9516 @sp 1
9517 @cartouche
9518 @noindent
9519 @strong{120}.  The sign of a zero result (or a component thereof) from
9520 any operator or function in
9521 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9522 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9523 @end cartouche
9524 @noindent
9525 The signs of zero values are as recommended by the relevant
9526 implementation advice.
9527
9528 @sp 1
9529 @cartouche
9530 @noindent
9531 @strong{121}.  Whether the strict mode or the relaxed mode is the
9532 default.  See G.2(2).
9533 @end cartouche
9534 @noindent
9535 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9536 provides a highly efficient implementation of strict mode.
9537
9538 @sp 1
9539 @cartouche
9540 @noindent
9541 @strong{122}.  The result interval in certain cases of fixed-to-float
9542 conversion.  See G.2.1(10).
9543 @end cartouche
9544 @noindent
9545 For cases where the result interval is implementation dependent, the
9546 accuracy is that provided by performing all operations in 64-bit IEEE
9547 floating-point format.
9548
9549 @sp 1
9550 @cartouche
9551 @noindent
9552 @strong{123}.  The result of a floating point arithmetic operation in
9553 overflow situations, when the @code{Machine_Overflows} attribute of the
9554 result type is @code{False}.  See G.2.1(13).
9555 @end cartouche
9556 @noindent
9557 Infinite and NaN values are produced as dictated by the IEEE
9558 floating-point standard.
9559
9560 Note that on machines that are not fully compliant with the IEEE
9561 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9562 must be used for achieving IEEE confirming behavior (although at the cost
9563 of a significant performance penalty), so infinite and NaN values are
9564 properly generated.
9565
9566 @sp 1
9567 @cartouche
9568 @noindent
9569 @strong{124}.  The result interval for division (or exponentiation by a
9570 negative exponent), when the floating point hardware implements division
9571 as multiplication by a reciprocal.  See G.2.1(16).
9572 @end cartouche
9573 @noindent
9574 Not relevant, division is IEEE exact.
9575
9576 @sp 1
9577 @cartouche
9578 @noindent
9579 @strong{125}.  The definition of close result set, which determines the
9580 accuracy of certain fixed point multiplications and divisions.  See
9581 G.2.3(5).
9582 @end cartouche
9583 @noindent
9584 Operations in the close result set are performed using IEEE long format
9585 floating-point arithmetic.  The input operands are converted to
9586 floating-point, the operation is done in floating-point, and the result
9587 is converted to the target type.
9588
9589 @sp 1
9590 @cartouche
9591 @noindent
9592 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9593 point multiplication or division for which the result shall be in the
9594 perfect result set.  See G.2.3(22).
9595 @end cartouche
9596 @noindent
9597 The result is only defined to be in the perfect result set if the result
9598 can be computed by a single scaling operation involving a scale factor
9599 representable in 64-bits.
9600
9601 @sp 1
9602 @cartouche
9603 @noindent
9604 @strong{127}.  The result of a fixed point arithmetic operation in
9605 overflow situations, when the @code{Machine_Overflows} attribute of the
9606 result type is @code{False}.  See G.2.3(27).
9607 @end cartouche
9608 @noindent
9609 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9610 types.
9611
9612 @sp 1
9613 @cartouche
9614 @noindent
9615 @strong{128}.  The result of an elementary function reference in
9616 overflow situations, when the @code{Machine_Overflows} attribute of the
9617 result type is @code{False}.  See G.2.4(4).
9618 @end cartouche
9619 @noindent
9620 IEEE infinite and Nan values are produced as appropriate.
9621
9622 @sp 1
9623 @cartouche
9624 @noindent
9625 @strong{129}.  The value of the angle threshold, within which certain
9626 elementary functions, complex arithmetic operations, and complex
9627 elementary functions yield results conforming to a maximum relative
9628 error bound.  See G.2.4(10).
9629 @end cartouche
9630 @noindent
9631 Information on this subject is not yet available.
9632
9633 @sp 1
9634 @cartouche
9635 @noindent
9636 @strong{130}.  The accuracy of certain elementary functions for
9637 parameters beyond the angle threshold.  See G.2.4(10).
9638 @end cartouche
9639 @noindent
9640 Information on this subject is not yet available.
9641
9642 @sp 1
9643 @cartouche
9644 @noindent
9645 @strong{131}.  The result of a complex arithmetic operation or complex
9646 elementary function reference in overflow situations, when the
9647 @code{Machine_Overflows} attribute of the corresponding real type is
9648 @code{False}.  See G.2.6(5).
9649 @end cartouche
9650 @noindent
9651 IEEE infinite and Nan values are produced as appropriate.
9652
9653 @sp 1
9654 @cartouche
9655 @noindent
9656 @strong{132}.  The accuracy of certain complex arithmetic operations and
9657 certain complex elementary functions for parameters (or components
9658 thereof) beyond the angle threshold.  See G.2.6(8).
9659 @end cartouche
9660 @noindent
9661 Information on those subjects is not yet available.
9662
9663 @sp 1
9664 @cartouche
9665 @noindent
9666 @strong{133}.  Information regarding bounded errors and erroneous
9667 execution.  See H.2(1).
9668 @end cartouche
9669 @noindent
9670 Information on this subject is not yet available.
9671
9672 @sp 1
9673 @cartouche
9674 @noindent
9675 @strong{134}.  Implementation-defined aspects of pragma
9676 @code{Inspection_Point}.  See H.3.2(8).
9677 @end cartouche
9678 @noindent
9679 Pragma @code{Inspection_Point} ensures that the variable is live and can
9680 be examined by the debugger at the inspection point.
9681
9682 @sp 1
9683 @cartouche
9684 @noindent
9685 @strong{135}.  Implementation-defined aspects of pragma
9686 @code{Restrictions}.  See H.4(25).
9687 @end cartouche
9688 @noindent
9689 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9690 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9691 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9692
9693 @sp 1
9694 @cartouche
9695 @noindent
9696 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9697 H.4(27).
9698 @end cartouche
9699 @noindent
9700 There are no restrictions on pragma @code{Restrictions}.
9701
9702 @node Intrinsic Subprograms
9703 @chapter Intrinsic Subprograms
9704 @cindex Intrinsic Subprograms
9705
9706 @menu
9707 * Intrinsic Operators::
9708 * Enclosing_Entity::
9709 * Exception_Information::
9710 * Exception_Message::
9711 * Exception_Name::
9712 * File::
9713 * Line::
9714 * Rotate_Left::
9715 * Rotate_Right::
9716 * Shift_Left::
9717 * Shift_Right::
9718 * Shift_Right_Arithmetic::
9719 * Source_Location::
9720 @end menu
9721
9722 @noindent
9723 GNAT allows a user application program to write the declaration:
9724
9725 @smallexample @c ada
9726    pragma Import (Intrinsic, name);
9727 @end smallexample
9728
9729 @noindent
9730 providing that the name corresponds to one of the implemented intrinsic
9731 subprograms in GNAT, and that the parameter profile of the referenced
9732 subprogram meets the requirements.  This chapter describes the set of
9733 implemented intrinsic subprograms, and the requirements on parameter profiles.
9734 Note that no body is supplied; as with other uses of pragma Import, the
9735 body is supplied elsewhere (in this case by the compiler itself).  Note
9736 that any use of this feature is potentially non-portable, since the
9737 Ada standard does not require Ada compilers to implement this feature.
9738
9739 @node Intrinsic Operators
9740 @section Intrinsic Operators
9741 @cindex Intrinsic operator
9742
9743 @noindent
9744 All the predefined numeric operators in package Standard
9745 in @code{pragma Import (Intrinsic,..)}
9746 declarations.  In the binary operator case, the operands must have the same
9747 size.  The operand or operands must also be appropriate for
9748 the operator.  For example, for addition, the operands must
9749 both be floating-point or both be fixed-point, and the
9750 right operand for @code{"**"} must have a root type of
9751 @code{Standard.Integer'Base}.
9752 You can use an intrinsic operator declaration as in the following example:
9753
9754 @smallexample @c ada
9755    type Int1 is new Integer;
9756    type Int2 is new Integer;
9757
9758    function "+" (X1 : Int1; X2 : Int2) return Int1;
9759    function "+" (X1 : Int1; X2 : Int2) return Int2;
9760    pragma Import (Intrinsic, "+");
9761 @end smallexample
9762
9763 @noindent
9764 This declaration would permit ``mixed mode'' arithmetic on items
9765 of the differing types @code{Int1} and @code{Int2}.
9766 It is also possible to specify such operators for private types, if the
9767 full views are appropriate arithmetic types.
9768
9769 @node Enclosing_Entity
9770 @section Enclosing_Entity
9771 @cindex Enclosing_Entity
9772 @noindent
9773 This intrinsic subprogram is used in the implementation of the
9774 library routine @code{GNAT.Source_Info}.  The only useful use of the
9775 intrinsic import in this case is the one in this unit, so an
9776 application program should simply call the function
9777 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9778 the current subprogram, package, task, entry, or protected subprogram.
9779
9780 @node Exception_Information
9781 @section Exception_Information
9782 @cindex Exception_Information'
9783 @noindent
9784 This intrinsic subprogram is used in the implementation of the
9785 library routine @code{GNAT.Current_Exception}.  The only useful
9786 use of the intrinsic import in this case is the one in this unit,
9787 so an application program should simply call the function
9788 @code{GNAT.Current_Exception.Exception_Information} to obtain
9789 the exception information associated with the current exception.
9790
9791 @node Exception_Message
9792 @section Exception_Message
9793 @cindex Exception_Message
9794 @noindent
9795 This intrinsic subprogram is used in the implementation of the
9796 library routine @code{GNAT.Current_Exception}.  The only useful
9797 use of the intrinsic import in this case is the one in this unit,
9798 so an application program should simply call the function
9799 @code{GNAT.Current_Exception.Exception_Message} to obtain
9800 the message associated with the current exception.
9801
9802 @node Exception_Name
9803 @section Exception_Name
9804 @cindex Exception_Name
9805 @noindent
9806 This intrinsic subprogram is used in the implementation of the
9807 library routine @code{GNAT.Current_Exception}.  The only useful
9808 use of the intrinsic import in this case is the one in this unit,
9809 so an application program should simply call the function
9810 @code{GNAT.Current_Exception.Exception_Name} to obtain
9811 the name of the current exception.
9812
9813 @node File
9814 @section File
9815 @cindex File
9816 @noindent
9817 This intrinsic subprogram is used in the implementation of the
9818 library routine @code{GNAT.Source_Info}.  The only useful use of the
9819 intrinsic import in this case is the one in this unit, so an
9820 application program should simply call the function
9821 @code{GNAT.Source_Info.File} to obtain the name of the current
9822 file.
9823
9824 @node Line
9825 @section Line
9826 @cindex Line
9827 @noindent
9828 This intrinsic subprogram is used in the implementation of the
9829 library routine @code{GNAT.Source_Info}.  The only useful use of the
9830 intrinsic import in this case is the one in this unit, so an
9831 application program should simply call the function
9832 @code{GNAT.Source_Info.Line} to obtain the number of the current
9833 source line.
9834
9835 @node Rotate_Left
9836 @section Rotate_Left
9837 @cindex Rotate_Left
9838 @noindent
9839 In standard Ada, the @code{Rotate_Left} function is available only
9840 for the predefined modular types in package @code{Interfaces}.  However, in
9841 GNAT it is possible to define a Rotate_Left function for a user
9842 defined modular type or any signed integer type as in this example:
9843
9844 @smallexample @c ada
9845    function Shift_Left
9846      (Value  : My_Modular_Type;
9847       Amount : Natural)
9848       return   My_Modular_Type;
9849 @end smallexample
9850
9851 @noindent
9852 The requirements are that the profile be exactly as in the example
9853 above.  The only modifications allowed are in the formal parameter
9854 names, and in the type of @code{Value} and the return type, which
9855 must be the same, and must be either a signed integer type, or
9856 a modular integer type with a binary modulus, and the size must
9857 be 8.  16, 32 or 64 bits.
9858
9859 @node Rotate_Right
9860 @section Rotate_Right
9861 @cindex Rotate_Right
9862 @noindent
9863 A @code{Rotate_Right} function can be defined for any user defined
9864 binary modular integer type, or signed integer type, as described
9865 above for @code{Rotate_Left}.
9866
9867 @node Shift_Left
9868 @section Shift_Left
9869 @cindex Shift_Left
9870 @noindent
9871 A @code{Shift_Left} function can be defined for any user defined
9872 binary modular integer type, or signed integer type, as described
9873 above for @code{Rotate_Left}.
9874
9875 @node Shift_Right
9876 @section Shift_Right
9877 @cindex Shift_Right
9878 @noindent
9879 A @code{Shift_Right} function can be defined for any user defined
9880 binary modular integer type, or signed integer type, as described
9881 above for @code{Rotate_Left}.
9882
9883 @node Shift_Right_Arithmetic
9884 @section Shift_Right_Arithmetic
9885 @cindex Shift_Right_Arithmetic
9886 @noindent
9887 A @code{Shift_Right_Arithmetic} function can be defined for any user
9888 defined binary modular integer type, or signed integer type, as described
9889 above for @code{Rotate_Left}.
9890
9891 @node Source_Location
9892 @section Source_Location
9893 @cindex Source_Location
9894 @noindent
9895 This intrinsic subprogram is used in the implementation of the
9896 library routine @code{GNAT.Source_Info}.  The only useful use of the
9897 intrinsic import in this case is the one in this unit, so an
9898 application program should simply call the function
9899 @code{GNAT.Source_Info.Source_Location} to obtain the current
9900 source file location.
9901
9902 @node Representation Clauses and Pragmas
9903 @chapter Representation Clauses and Pragmas
9904 @cindex Representation Clauses
9905
9906 @menu
9907 * Alignment Clauses::
9908 * Size Clauses::
9909 * Storage_Size Clauses::
9910 * Size of Variant Record Objects::
9911 * Biased Representation ::
9912 * Value_Size and Object_Size Clauses::
9913 * Component_Size Clauses::
9914 * Bit_Order Clauses::
9915 * Effect of Bit_Order on Byte Ordering::
9916 * Pragma Pack for Arrays::
9917 * Pragma Pack for Records::
9918 * Record Representation Clauses::
9919 * Enumeration Clauses::
9920 * Address Clauses::
9921 * Effect of Convention on Representation::
9922 * Determining the Representations chosen by GNAT::
9923 @end menu
9924
9925 @noindent
9926 @cindex Representation Clause
9927 @cindex Representation Pragma
9928 @cindex Pragma, representation
9929 This section describes the representation clauses accepted by GNAT, and
9930 their effect on the representation of corresponding data objects.
9931
9932 GNAT fully implements Annex C (Systems Programming).  This means that all
9933 the implementation advice sections in chapter 13 are fully implemented.
9934 However, these sections only require a minimal level of support for
9935 representation clauses.  GNAT provides much more extensive capabilities,
9936 and this section describes the additional capabilities provided.
9937
9938 @node Alignment Clauses
9939 @section Alignment Clauses
9940 @cindex Alignment Clause
9941
9942 @noindent
9943 GNAT requires that all alignment clauses specify a power of 2, and all
9944 default alignments are always a power of 2.  The default alignment
9945 values are as follows:
9946
9947 @itemize @bullet
9948 @item @emph{Primitive Types}.
9949 For primitive types, the alignment is the minimum of the actual size of
9950 objects of the type divided by @code{Storage_Unit},
9951 and the maximum alignment supported by the target.
9952 (This maximum alignment is given by the GNAT-specific attribute
9953 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9954 @cindex @code{Maximum_Alignment} attribute
9955 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9956 default alignment will be 8 on any target that supports alignments
9957 this large, but on some targets, the maximum alignment may be smaller
9958 than 8, in which case objects of type @code{Long_Float} will be maximally
9959 aligned.
9960
9961 @item @emph{Arrays}.
9962 For arrays, the alignment is equal to the alignment of the component type
9963 for the normal case where no packing or component size is given.  If the
9964 array is packed, and the packing is effective (see separate section on
9965 packed arrays), then the alignment will be one for long packed arrays,
9966 or arrays whose length is not known at compile time.  For short packed
9967 arrays, which are handled internally as modular types, the alignment
9968 will be as described for primitive types, e.g.@: a packed array of length
9969 31 bits will have an object size of four bytes, and an alignment of 4.
9970
9971 @item @emph{Records}.
9972 For the normal non-packed case, the alignment of a record is equal to
9973 the maximum alignment of any of its components.  For tagged records, this
9974 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9975 is used and all components are packable (see separate section on pragma
9976 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9977 record makes it profitable to increase it.
9978
9979 A special case is when:
9980 @itemize @bullet
9981 @item
9982 the size of the record is given explicitly, or a
9983 full record representation clause is given, and
9984 @item
9985 the size of the record is 2, 4, or 8 bytes.
9986 @end itemize
9987 @noindent
9988 In this case, an alignment is chosen to match the
9989 size of the record. For example, if we have:
9990
9991 @smallexample @c ada
9992    type Small is record
9993       A, B : Character;
9994    end record;
9995    for Small'Size use 16;
9996 @end smallexample
9997
9998 @noindent
9999 then the default alignment of the record type @code{Small} is 2, not 1. This
10000 leads to more efficient code when the record is treated as a unit, and also
10001 allows the type to specified as @code{Atomic} on architectures requiring
10002 strict alignment.
10003
10004 @end itemize
10005
10006 @noindent
10007 An alignment clause may specify a larger alignment than the default value
10008 up to some maximum value dependent on the target (obtainable by using the
10009 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10010 a smaller alignment than the default value for enumeration, integer and
10011 fixed point types, as well as for record types, for example
10012
10013 @smallexample @c ada
10014   type V is record
10015      A : Integer;
10016   end record;
10017
10018   for V'alignment use 1;
10019 @end smallexample
10020
10021 @noindent
10022 @cindex Alignment, default
10023 The default alignment for the type @code{V} is 4, as a result of the
10024 Integer field in the record, but it is permissible, as shown, to
10025 override the default alignment of the record with a smaller value.
10026
10027 @node Size Clauses
10028 @section Size Clauses
10029 @cindex Size Clause
10030
10031 @noindent
10032 The default size for a type @code{T} is obtainable through the
10033 language-defined attribute @code{T'Size} and also through the
10034 equivalent GNAT-defined attribute @code{T'Value_Size}.
10035 For objects of type @code{T}, GNAT will generally increase the type size
10036 so that the object size (obtainable through the GNAT-defined attribute
10037 @code{T'Object_Size})
10038 is a multiple of @code{T'Alignment * Storage_Unit}.
10039 For example
10040
10041 @smallexample @c ada
10042    type Smallint is range 1 .. 6;
10043
10044    type Rec is record
10045       Y1 : integer;
10046       Y2 : boolean;
10047    end record;
10048 @end smallexample
10049
10050 @noindent
10051 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10052 as specified by the RM rules,
10053 but objects of this type will have a size of 8
10054 (@code{Smallint'Object_Size} = 8),
10055 since objects by default occupy an integral number
10056 of storage units.  On some targets, notably older
10057 versions of the Digital Alpha, the size of stand
10058 alone objects of this type may be 32, reflecting
10059 the inability of the hardware to do byte load/stores.
10060
10061 Similarly, the size of type @code{Rec} is 40 bits
10062 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10063 the alignment is 4, so objects of this type will have
10064 their size increased to 64 bits so that it is a multiple
10065 of the alignment (in bits).  This decision is
10066 in accordance with the specific Implementation Advice in RM 13.3(43):
10067
10068 @quotation
10069 A @code{Size} clause should be supported for an object if the specified
10070 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10071 to a size in storage elements that is a multiple of the object's
10072 @code{Alignment} (if the @code{Alignment} is nonzero).
10073 @end quotation
10074
10075 @noindent
10076 An explicit size clause may be used to override the default size by
10077 increasing it.  For example, if we have:
10078
10079 @smallexample @c ada
10080    type My_Boolean is new Boolean;
10081    for My_Boolean'Size use 32;
10082 @end smallexample
10083
10084 @noindent
10085 then values of this type will always be 32 bits long.  In the case of
10086 discrete types, the size can be increased up to 64 bits, with the effect
10087 that the entire specified field is used to hold the value, sign- or
10088 zero-extended as appropriate.  If more than 64 bits is specified, then
10089 padding space is allocated after the value, and a warning is issued that
10090 there are unused bits.
10091
10092 Similarly the size of records and arrays may be increased, and the effect
10093 is to add padding bits after the value.  This also causes a warning message
10094 to be generated.
10095
10096 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10097 Size in bits, this corresponds to an object of size 256 megabytes (minus
10098 one).  This limitation is true on all targets.  The reason for this
10099 limitation is that it improves the quality of the code in many cases
10100 if it is known that a Size value can be accommodated in an object of
10101 type Integer.
10102
10103 @node Storage_Size Clauses
10104 @section Storage_Size Clauses
10105 @cindex Storage_Size Clause
10106
10107 @noindent
10108 For tasks, the @code{Storage_Size} clause specifies the amount of space
10109 to be allocated for the task stack.  This cannot be extended, and if the
10110 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10111 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10112 or a @code{Storage_Size} pragma in the task definition to set the
10113 appropriate required size.  A useful technique is to include in every
10114 task definition a pragma of the form:
10115
10116 @smallexample @c ada
10117    pragma Storage_Size (Default_Stack_Size);
10118 @end smallexample
10119
10120 @noindent
10121 Then @code{Default_Stack_Size} can be defined in a global package, and
10122 modified as required. Any tasks requiring stack sizes different from the
10123 default can have an appropriate alternative reference in the pragma.
10124
10125 You can also use the @option{-d} binder switch to modify the default stack
10126 size.
10127
10128 For access types, the @code{Storage_Size} clause specifies the maximum
10129 space available for allocation of objects of the type.  If this space is
10130 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10131 In the case where the access type is declared local to a subprogram, the
10132 use of a @code{Storage_Size} clause triggers automatic use of a special
10133 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10134 space for the pool is automatically reclaimed on exit from the scope in
10135 which the type is declared.
10136
10137 A special case recognized by the compiler is the specification of a
10138 @code{Storage_Size} of zero for an access type.  This means that no
10139 items can be allocated from the pool, and this is recognized at compile
10140 time, and all the overhead normally associated with maintaining a fixed
10141 size storage pool is eliminated.  Consider the following example:
10142
10143 @smallexample @c ada
10144    procedure p is
10145       type R is array (Natural) of Character;
10146       type P is access all R;
10147       for P'Storage_Size use 0;
10148       --  Above access type intended only for interfacing purposes
10149
10150       y : P;
10151
10152       procedure g (m : P);
10153       pragma Import (C, g);
10154
10155       --  @dots{}
10156
10157    begin
10158       --  @dots{}
10159       y := new R;
10160    end;
10161 @end smallexample
10162
10163 @noindent
10164 As indicated in this example, these dummy storage pools are often useful in
10165 connection with interfacing where no object will ever be allocated.  If you
10166 compile the above example, you get the warning:
10167
10168 @smallexample
10169    p.adb:16:09: warning: allocation from empty storage pool
10170    p.adb:16:09: warning: Storage_Error will be raised at run time
10171 @end smallexample
10172
10173 @noindent
10174 Of course in practice, there will not be any explicit allocators in the
10175 case of such an access declaration.
10176
10177 @node Size of Variant Record Objects
10178 @section Size of Variant Record Objects
10179 @cindex Size, variant record objects
10180 @cindex Variant record objects, size
10181
10182 @noindent
10183 In the case of variant record objects, there is a question whether Size gives
10184 information about a particular variant, or the maximum size required
10185 for any variant.  Consider the following program
10186
10187 @smallexample @c ada
10188 with Text_IO; use Text_IO;
10189 procedure q is
10190    type R1 (A : Boolean := False) is record
10191      case A is
10192        when True  => X : Character;
10193        when False => null;
10194      end case;
10195    end record;
10196
10197    V1 : R1 (False);
10198    V2 : R1;
10199
10200 begin
10201    Put_Line (Integer'Image (V1'Size));
10202    Put_Line (Integer'Image (V2'Size));
10203 end q;
10204 @end smallexample
10205
10206 @noindent
10207 Here we are dealing with a variant record, where the True variant
10208 requires 16 bits, and the False variant requires 8 bits.
10209 In the above example, both V1 and V2 contain the False variant,
10210 which is only 8 bits long.  However, the result of running the
10211 program is:
10212
10213 @smallexample
10214 8
10215 16
10216 @end smallexample
10217
10218 @noindent
10219 The reason for the difference here is that the discriminant value of
10220 V1 is fixed, and will always be False.  It is not possible to assign
10221 a True variant value to V1, therefore 8 bits is sufficient.  On the
10222 other hand, in the case of V2, the initial discriminant value is
10223 False (from the default), but it is possible to assign a True
10224 variant value to V2, therefore 16 bits must be allocated for V2
10225 in the general case, even fewer bits may be needed at any particular
10226 point during the program execution.
10227
10228 As can be seen from the output of this program, the @code{'Size}
10229 attribute applied to such an object in GNAT gives the actual allocated
10230 size of the variable, which is the largest size of any of the variants.
10231 The Ada Reference Manual is not completely clear on what choice should
10232 be made here, but the GNAT behavior seems most consistent with the
10233 language in the RM@.
10234
10235 In some cases, it may be desirable to obtain the size of the current
10236 variant, rather than the size of the largest variant.  This can be
10237 achieved in GNAT by making use of the fact that in the case of a
10238 subprogram parameter, GNAT does indeed return the size of the current
10239 variant (because a subprogram has no way of knowing how much space
10240 is actually allocated for the actual).
10241
10242 Consider the following modified version of the above program:
10243
10244 @smallexample @c ada
10245 with Text_IO; use Text_IO;
10246 procedure q is
10247    type R1 (A : Boolean := False) is record
10248      case A is
10249        when True  => X : Character;
10250        when False => null;
10251      end case;
10252    end record;
10253
10254    V2 : R1;
10255
10256    function Size (V : R1) return Integer is
10257    begin
10258       return V'Size;
10259    end Size;
10260
10261 begin
10262    Put_Line (Integer'Image (V2'Size));
10263    Put_Line (Integer'IMage (Size (V2)));
10264    V2 := (True, 'x');
10265    Put_Line (Integer'Image (V2'Size));
10266    Put_Line (Integer'IMage (Size (V2)));
10267 end q;
10268 @end smallexample
10269
10270 @noindent
10271 The output from this program is
10272
10273 @smallexample
10274 16
10275 8
10276 16
10277 16
10278 @end smallexample
10279
10280 @noindent
10281 Here we see that while the @code{'Size} attribute always returns
10282 the maximum size, regardless of the current variant value, the
10283 @code{Size} function does indeed return the size of the current
10284 variant value.
10285
10286 @node Biased Representation
10287 @section Biased Representation
10288 @cindex Size for biased representation
10289 @cindex Biased representation
10290
10291 @noindent
10292 In the case of scalars with a range starting at other than zero, it is
10293 possible in some cases to specify a size smaller than the default minimum
10294 value, and in such cases, GNAT uses an unsigned biased representation,
10295 in which zero is used to represent the lower bound, and successive values
10296 represent successive values of the type.
10297
10298 For example, suppose we have the declaration:
10299
10300 @smallexample @c ada
10301    type Small is range -7 .. -4;
10302    for Small'Size use 2;
10303 @end smallexample
10304
10305 @noindent
10306 Although the default size of type @code{Small} is 4, the @code{Size}
10307 clause is accepted by GNAT and results in the following representation
10308 scheme:
10309
10310 @smallexample
10311   -7 is represented as 2#00#
10312   -6 is represented as 2#01#
10313   -5 is represented as 2#10#
10314   -4 is represented as 2#11#
10315 @end smallexample
10316
10317 @noindent
10318 Biased representation is only used if the specified @code{Size} clause
10319 cannot be accepted in any other manner.  These reduced sizes that force
10320 biased representation can be used for all discrete types except for
10321 enumeration types for which a representation clause is given.
10322
10323 @node Value_Size and Object_Size Clauses
10324 @section Value_Size and Object_Size Clauses
10325 @findex Value_Size
10326 @findex Object_Size
10327 @cindex Size, of objects
10328
10329 @noindent
10330 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10331 number of bits required to hold values of type @code{T}.
10332 Although this interpretation was allowed in Ada 83, it was not required,
10333 and this requirement in practice can cause some significant difficulties.
10334 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10335 However, in Ada 95 and Ada 2005,
10336 @code{Natural'Size} is
10337 typically 31.  This means that code may change in behavior when moving
10338 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10339
10340 @smallexample @c ada
10341    type Rec is record;
10342       A : Natural;
10343       B : Natural;
10344    end record;
10345
10346    for Rec use record
10347       at 0  range 0 .. Natural'Size - 1;
10348       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10349    end record;
10350 @end smallexample
10351
10352 @noindent
10353 In the above code, since the typical size of @code{Natural} objects
10354 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10355 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10356 there are cases where the fact that the object size can exceed the
10357 size of the type causes surprises.
10358
10359 To help get around this problem GNAT provides two implementation
10360 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10361 applied to a type, these attributes yield the size of the type
10362 (corresponding to the RM defined size attribute), and the size of
10363 objects of the type respectively.
10364
10365 The @code{Object_Size} is used for determining the default size of
10366 objects and components.  This size value can be referred to using the
10367 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10368 the basis of the determination of the size.  The backend is free to
10369 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10370 character might be stored in 32 bits on a machine with no efficient
10371 byte access instructions such as the Alpha.
10372
10373 The default rules for the value of @code{Object_Size} for
10374 discrete types are as follows:
10375
10376 @itemize @bullet
10377 @item
10378 The @code{Object_Size} for base subtypes reflect the natural hardware
10379 size in bits (run the compiler with @option{-gnatS} to find those values
10380 for numeric types). Enumeration types and fixed-point base subtypes have
10381 8, 16, 32 or 64 bits for this size, depending on the range of values
10382 to be stored.
10383
10384 @item
10385 The @code{Object_Size} of a subtype is the same as the
10386 @code{Object_Size} of
10387 the type from which it is obtained.
10388
10389 @item
10390 The @code{Object_Size} of a derived base type is copied from the parent
10391 base type, and the @code{Object_Size} of a derived first subtype is copied
10392 from the parent first subtype.
10393 @end itemize
10394
10395 @noindent
10396 The @code{Value_Size} attribute
10397 is the (minimum) number of bits required to store a value
10398 of the type.
10399 This value is used to determine how tightly to pack
10400 records or arrays with components of this type, and also affects
10401 the semantics of unchecked conversion (unchecked conversions where
10402 the @code{Value_Size} values differ generate a warning, and are potentially
10403 target dependent).
10404
10405 The default rules for the value of @code{Value_Size} are as follows:
10406
10407 @itemize @bullet
10408 @item
10409 The @code{Value_Size} for a base subtype is the minimum number of bits
10410 required to store all values of the type (including the sign bit
10411 only if negative values are possible).
10412
10413 @item
10414 If a subtype statically matches the first subtype of a given type, then it has
10415 by default the same @code{Value_Size} as the first subtype.  This is a
10416 consequence of RM 13.1(14) (``if two subtypes statically match,
10417 then their subtype-specific aspects are the same''.)
10418
10419 @item
10420 All other subtypes have a @code{Value_Size} corresponding to the minimum
10421 number of bits required to store all values of the subtype.  For
10422 dynamic bounds, it is assumed that the value can range down or up
10423 to the corresponding bound of the ancestor
10424 @end itemize
10425
10426 @noindent
10427 The RM defined attribute @code{Size} corresponds to the
10428 @code{Value_Size} attribute.
10429
10430 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10431 the @code{Value_Size} of
10432 the first-named subtype to the given value, and the
10433 @code{Object_Size} of this first-named subtype to the given value padded up
10434 to an appropriate boundary.  It is a consequence of the default rules
10435 above that this @code{Object_Size} will apply to all further subtypes.  On the
10436 other hand, @code{Value_Size} is affected only for the first subtype, any
10437 dynamic subtypes obtained from it directly, and any statically matching
10438 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10439
10440 @code{Value_Size} and
10441 @code{Object_Size} may be explicitly set for any subtype using
10442 an attribute definition clause.  Note that the use of these attributes
10443 can cause the RM 13.1(14) rule to be violated.  If two access types
10444 reference aliased objects whose subtypes have differing @code{Object_Size}
10445 values as a result of explicit attribute definition clauses, then it
10446 is erroneous to convert from one access subtype to the other.
10447
10448 At the implementation level, Esize stores the Object_Size and the
10449 RM_Size field stores the @code{Value_Size} (and hence the value of the
10450 @code{Size} attribute,
10451 which, as noted above, is equivalent to @code{Value_Size}).
10452
10453 To get a feel for the difference, consider the following examples (note
10454 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10455
10456 @smallexample
10457                                        Object_Size     Value_Size
10458
10459 type x1 is range 0 .. 5;                    8               3
10460
10461 type x2 is range 0 .. 5;
10462 for x2'size use 12;                        16              12
10463
10464 subtype x3 is x2 range 0 .. 3;             16               2
10465
10466 subtype x4 is x2'base range 0 .. 10;        8               4
10467
10468 subtype x5 is x2 range 0 .. dynamic;       16               3*
10469
10470 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10471
10472 @end smallexample
10473
10474 @noindent
10475 Note: the entries marked ``3*'' are not actually specified by the Ada
10476 Reference Manual, but it seems in the spirit of the RM rules to allocate
10477 the minimum number of bits (here 3, given the range for @code{x2})
10478 known to be large enough to hold the given range of values.
10479
10480 So far, so good, but GNAT has to obey the RM rules, so the question is
10481 under what conditions must the RM @code{Size} be used.
10482 The following is a list
10483 of the occasions on which the RM @code{Size} must be used:
10484
10485 @itemize @bullet
10486 @item
10487 Component size for packed arrays or records
10488
10489 @item
10490 Value of the attribute @code{Size} for a type
10491
10492 @item
10493 Warning about sizes not matching for unchecked conversion
10494 @end itemize
10495
10496 @noindent
10497 For record types, the @code{Object_Size} is always a multiple of the
10498 alignment of the type (this is true for all types). In some cases the
10499 @code{Value_Size} can be smaller. Consider:
10500
10501 @smallexample
10502    type R is record
10503      X : Integer;
10504      Y : Character;
10505    end record;
10506 @end smallexample
10507
10508 @noindent
10509 On a typical 32-bit architecture, the X component will be four bytes, and
10510 require four-byte alignment, and the Y component will be one byte. In this
10511 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10512 required to store a value of this type, and for example, it is permissible
10513 to have a component of type R in an outer array whose component size is
10514 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10515 since it must be rounded up so that this value is a multiple of the
10516 alignment (4 bytes = 32 bits).
10517
10518 @noindent
10519 For all other types, the @code{Object_Size}
10520 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10521 Only @code{Size} may be specified for such types.
10522
10523 @node Component_Size Clauses
10524 @section Component_Size Clauses
10525 @cindex Component_Size Clause
10526
10527 @noindent
10528 Normally, the value specified in a component size clause must be consistent
10529 with the subtype of the array component with regard to size and alignment.
10530 In other words, the value specified must be at least equal to the size
10531 of this subtype, and must be a multiple of the alignment value.
10532
10533 In addition, component size clauses are allowed which cause the array
10534 to be packed, by specifying a smaller value.  A first case is for
10535 component size values in the range 1 through 63.  The value specified
10536 must not be smaller than the Size of the subtype.  GNAT will accurately
10537 honor all packing requests in this range.  For example, if we have:
10538
10539 @smallexample @c ada
10540 type r is array (1 .. 8) of Natural;
10541 for r'Component_Size use 31;
10542 @end smallexample
10543
10544 @noindent
10545 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10546 Of course access to the components of such an array is considerably
10547 less efficient than if the natural component size of 32 is used.
10548 A second case is when the subtype of the component is a record type
10549 padded because of its default alignment.  For example, if we have:
10550
10551 @smallexample @c ada
10552 type r is record
10553   i : Integer;
10554   j : Integer;
10555   b : Boolean;
10556 end record;
10557
10558 type a is array (1 .. 8) of r;
10559 for a'Component_Size use 72;
10560 @end smallexample
10561
10562 @noindent
10563 then the resulting array has a length of 72 bytes, instead of 96 bytes
10564 if the alignment of the record (4) was obeyed.
10565
10566 Note that there is no point in giving both a component size clause
10567 and a pragma Pack for the same array type. if such duplicate
10568 clauses are given, the pragma Pack will be ignored.
10569
10570 @node Bit_Order Clauses
10571 @section Bit_Order Clauses
10572 @cindex Bit_Order Clause
10573 @cindex bit ordering
10574 @cindex ordering, of bits
10575
10576 @noindent
10577 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10578 attribute.  The specification may either correspond to the default bit
10579 order for the target, in which case the specification has no effect and
10580 places no additional restrictions, or it may be for the non-standard
10581 setting (that is the opposite of the default).
10582
10583 In the case where the non-standard value is specified, the effect is
10584 to renumber bits within each byte, but the ordering of bytes is not
10585 affected.  There are certain
10586 restrictions placed on component clauses as follows:
10587
10588 @itemize @bullet
10589
10590 @item Components fitting within a single storage unit.
10591 @noindent
10592 These are unrestricted, and the effect is merely to renumber bits.  For
10593 example if we are on a little-endian machine with @code{Low_Order_First}
10594 being the default, then the following two declarations have exactly
10595 the same effect:
10596
10597 @smallexample @c ada
10598    type R1 is record
10599       A : Boolean;
10600       B : Integer range 1 .. 120;
10601    end record;
10602
10603    for R1 use record
10604       A at 0 range 0 .. 0;
10605       B at 0 range 1 .. 7;
10606    end record;
10607
10608    type R2 is record
10609       A : Boolean;
10610       B : Integer range 1 .. 120;
10611    end record;
10612
10613    for R2'Bit_Order use High_Order_First;
10614
10615    for R2 use record
10616       A at 0 range 7 .. 7;
10617       B at 0 range 0 .. 6;
10618    end record;
10619 @end smallexample
10620
10621 @noindent
10622 The useful application here is to write the second declaration with the
10623 @code{Bit_Order} attribute definition clause, and know that it will be treated
10624 the same, regardless of whether the target is little-endian or big-endian.
10625
10626 @item Components occupying an integral number of bytes.
10627 @noindent
10628 These are components that exactly fit in two or more bytes.  Such component
10629 declarations are allowed, but have no effect, since it is important to realize
10630 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10631 In particular, the following attempt at getting an endian-independent integer
10632 does not work:
10633
10634 @smallexample @c ada
10635    type R2 is record
10636       A : Integer;
10637    end record;
10638
10639    for R2'Bit_Order use High_Order_First;
10640
10641    for R2 use record
10642       A at 0 range 0 .. 31;
10643    end record;
10644 @end smallexample
10645
10646 @noindent
10647 This declaration will result in a little-endian integer on a
10648 little-endian machine, and a big-endian integer on a big-endian machine.
10649 If byte flipping is required for interoperability between big- and
10650 little-endian machines, this must be explicitly programmed.  This capability
10651 is not provided by @code{Bit_Order}.
10652
10653 @item Components that are positioned across byte boundaries
10654 @noindent
10655 but do not occupy an integral number of bytes.  Given that bytes are not
10656 reordered, such fields would occupy a non-contiguous sequence of bits
10657 in memory, requiring non-trivial code to reassemble.  They are for this
10658 reason not permitted, and any component clause specifying such a layout
10659 will be flagged as illegal by GNAT@.
10660
10661 @end itemize
10662
10663 @noindent
10664 Since the misconception that Bit_Order automatically deals with all
10665 endian-related incompatibilities is a common one, the specification of
10666 a component field that is an integral number of bytes will always
10667 generate a warning.  This warning may be suppressed using @code{pragma
10668 Warnings (Off)} if desired.  The following section contains additional
10669 details regarding the issue of byte ordering.
10670
10671 @node Effect of Bit_Order on Byte Ordering
10672 @section Effect of Bit_Order on Byte Ordering
10673 @cindex byte ordering
10674 @cindex ordering, of bytes
10675
10676 @noindent
10677 In this section we will review the effect of the @code{Bit_Order} attribute
10678 definition clause on byte ordering.  Briefly, it has no effect at all, but
10679 a detailed example will be helpful.  Before giving this
10680 example, let us review the precise
10681 definition of the effect of defining @code{Bit_Order}.  The effect of a
10682 non-standard bit order is described in section 15.5.3 of the Ada
10683 Reference Manual:
10684
10685 @quotation
10686 2   A bit ordering is a method of interpreting the meaning of
10687 the storage place attributes.
10688 @end quotation
10689
10690 @noindent
10691 To understand the precise definition of storage place attributes in
10692 this context, we visit section 13.5.1 of the manual:
10693
10694 @quotation
10695 13   A record_representation_clause (without the mod_clause)
10696 specifies the layout.  The storage place attributes (see 13.5.2)
10697 are taken from the values of the position, first_bit, and last_bit
10698 expressions after normalizing those values so that first_bit is
10699 less than Storage_Unit.
10700 @end quotation
10701
10702 @noindent
10703 The critical point here is that storage places are taken from
10704 the values after normalization, not before.  So the @code{Bit_Order}
10705 interpretation applies to normalized values.  The interpretation
10706 is described in the later part of the 15.5.3 paragraph:
10707
10708 @quotation
10709 2   A bit ordering is a method of interpreting the meaning of
10710 the storage place attributes.  High_Order_First (known in the
10711 vernacular as ``big endian'') means that the first bit of a
10712 storage element (bit 0) is the most significant bit (interpreting
10713 the sequence of bits that represent a component as an unsigned
10714 integer value).  Low_Order_First (known in the vernacular as
10715 ``little endian'') means the opposite: the first bit is the
10716 least significant.
10717 @end quotation
10718
10719 @noindent
10720 Note that the numbering is with respect to the bits of a storage
10721 unit.  In other words, the specification affects only the numbering
10722 of bits within a single storage unit.
10723
10724 We can make the effect clearer by giving an example.
10725
10726 Suppose that we have an external device which presents two bytes, the first
10727 byte presented, which is the first (low addressed byte) of the two byte
10728 record is called Master, and the second byte is called Slave.
10729
10730 The left most (most significant bit is called Control for each byte, and
10731 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10732 (least significant) bit.
10733
10734 On a big-endian machine, we can write the following representation clause
10735
10736 @smallexample @c ada
10737    type Data is record
10738       Master_Control : Bit;
10739       Master_V1      : Bit;
10740       Master_V2      : Bit;
10741       Master_V3      : Bit;
10742       Master_V4      : Bit;
10743       Master_V5      : Bit;
10744       Master_V6      : Bit;
10745       Master_V7      : Bit;
10746       Slave_Control  : Bit;
10747       Slave_V1       : Bit;
10748       Slave_V2       : Bit;
10749       Slave_V3       : Bit;
10750       Slave_V4       : Bit;
10751       Slave_V5       : Bit;
10752       Slave_V6       : Bit;
10753       Slave_V7       : Bit;
10754    end record;
10755
10756    for Data use record
10757       Master_Control at 0 range 0 .. 0;
10758       Master_V1      at 0 range 1 .. 1;
10759       Master_V2      at 0 range 2 .. 2;
10760       Master_V3      at 0 range 3 .. 3;
10761       Master_V4      at 0 range 4 .. 4;
10762       Master_V5      at 0 range 5 .. 5;
10763       Master_V6      at 0 range 6 .. 6;
10764       Master_V7      at 0 range 7 .. 7;
10765       Slave_Control  at 1 range 0 .. 0;
10766       Slave_V1       at 1 range 1 .. 1;
10767       Slave_V2       at 1 range 2 .. 2;
10768       Slave_V3       at 1 range 3 .. 3;
10769       Slave_V4       at 1 range 4 .. 4;
10770       Slave_V5       at 1 range 5 .. 5;
10771       Slave_V6       at 1 range 6 .. 6;
10772       Slave_V7       at 1 range 7 .. 7;
10773    end record;
10774 @end smallexample
10775
10776 @noindent
10777 Now if we move this to a little endian machine, then the bit ordering within
10778 the byte is backwards, so we have to rewrite the record rep clause as:
10779
10780 @smallexample @c ada
10781    for Data use record
10782       Master_Control at 0 range 7 .. 7;
10783       Master_V1      at 0 range 6 .. 6;
10784       Master_V2      at 0 range 5 .. 5;
10785       Master_V3      at 0 range 4 .. 4;
10786       Master_V4      at 0 range 3 .. 3;
10787       Master_V5      at 0 range 2 .. 2;
10788       Master_V6      at 0 range 1 .. 1;
10789       Master_V7      at 0 range 0 .. 0;
10790       Slave_Control  at 1 range 7 .. 7;
10791       Slave_V1       at 1 range 6 .. 6;
10792       Slave_V2       at 1 range 5 .. 5;
10793       Slave_V3       at 1 range 4 .. 4;
10794       Slave_V4       at 1 range 3 .. 3;
10795       Slave_V5       at 1 range 2 .. 2;
10796       Slave_V6       at 1 range 1 .. 1;
10797       Slave_V7       at 1 range 0 .. 0;
10798    end record;
10799 @end smallexample
10800
10801 @noindent
10802 It is a nuisance to have to rewrite the clause, especially if
10803 the code has to be maintained on both machines.  However,
10804 this is a case that we can handle with the
10805 @code{Bit_Order} attribute if it is implemented.
10806 Note that the implementation is not required on byte addressed
10807 machines, but it is indeed implemented in GNAT.
10808 This means that we can simply use the
10809 first record clause, together with the declaration
10810
10811 @smallexample @c ada
10812    for Data'Bit_Order use High_Order_First;
10813 @end smallexample
10814
10815 @noindent
10816 and the effect is what is desired, namely the layout is exactly the same,
10817 independent of whether the code is compiled on a big-endian or little-endian
10818 machine.
10819
10820 The important point to understand is that byte ordering is not affected.
10821 A @code{Bit_Order} attribute definition never affects which byte a field
10822 ends up in, only where it ends up in that byte.
10823 To make this clear, let us rewrite the record rep clause of the previous
10824 example as:
10825
10826 @smallexample @c ada
10827    for Data'Bit_Order use High_Order_First;
10828    for Data use record
10829       Master_Control at 0 range  0 .. 0;
10830       Master_V1      at 0 range  1 .. 1;
10831       Master_V2      at 0 range  2 .. 2;
10832       Master_V3      at 0 range  3 .. 3;
10833       Master_V4      at 0 range  4 .. 4;
10834       Master_V5      at 0 range  5 .. 5;
10835       Master_V6      at 0 range  6 .. 6;
10836       Master_V7      at 0 range  7 .. 7;
10837       Slave_Control  at 0 range  8 .. 8;
10838       Slave_V1       at 0 range  9 .. 9;
10839       Slave_V2       at 0 range 10 .. 10;
10840       Slave_V3       at 0 range 11 .. 11;
10841       Slave_V4       at 0 range 12 .. 12;
10842       Slave_V5       at 0 range 13 .. 13;
10843       Slave_V6       at 0 range 14 .. 14;
10844       Slave_V7       at 0 range 15 .. 15;
10845    end record;
10846 @end smallexample
10847
10848 @noindent
10849 This is exactly equivalent to saying (a repeat of the first example):
10850
10851 @smallexample @c ada
10852    for Data'Bit_Order use High_Order_First;
10853    for Data use record
10854       Master_Control at 0 range 0 .. 0;
10855       Master_V1      at 0 range 1 .. 1;
10856       Master_V2      at 0 range 2 .. 2;
10857       Master_V3      at 0 range 3 .. 3;
10858       Master_V4      at 0 range 4 .. 4;
10859       Master_V5      at 0 range 5 .. 5;
10860       Master_V6      at 0 range 6 .. 6;
10861       Master_V7      at 0 range 7 .. 7;
10862       Slave_Control  at 1 range 0 .. 0;
10863       Slave_V1       at 1 range 1 .. 1;
10864       Slave_V2       at 1 range 2 .. 2;
10865       Slave_V3       at 1 range 3 .. 3;
10866       Slave_V4       at 1 range 4 .. 4;
10867       Slave_V5       at 1 range 5 .. 5;
10868       Slave_V6       at 1 range 6 .. 6;
10869       Slave_V7       at 1 range 7 .. 7;
10870    end record;
10871 @end smallexample
10872
10873 @noindent
10874 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10875 field.  The storage place attributes are obtained by normalizing the
10876 values given so that the @code{First_Bit} value is less than 8.  After
10877 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10878 we specified in the other case.
10879
10880 Now one might expect that the @code{Bit_Order} attribute might affect
10881 bit numbering within the entire record component (two bytes in this
10882 case, thus affecting which byte fields end up in), but that is not
10883 the way this feature is defined, it only affects numbering of bits,
10884 not which byte they end up in.
10885
10886 Consequently it never makes sense to specify a starting bit number
10887 greater than 7 (for a byte addressable field) if an attribute
10888 definition for @code{Bit_Order} has been given, and indeed it
10889 may be actively confusing to specify such a value, so the compiler
10890 generates a warning for such usage.
10891
10892 If you do need to control byte ordering then appropriate conditional
10893 values must be used.  If in our example, the slave byte came first on
10894 some machines we might write:
10895
10896 @smallexample @c ada
10897    Master_Byte_First constant Boolean := @dots{};
10898
10899    Master_Byte : constant Natural :=
10900                    1 - Boolean'Pos (Master_Byte_First);
10901    Slave_Byte  : constant Natural :=
10902                    Boolean'Pos (Master_Byte_First);
10903
10904    for Data'Bit_Order use High_Order_First;
10905    for Data use record
10906       Master_Control at Master_Byte range 0 .. 0;
10907       Master_V1      at Master_Byte range 1 .. 1;
10908       Master_V2      at Master_Byte range 2 .. 2;
10909       Master_V3      at Master_Byte range 3 .. 3;
10910       Master_V4      at Master_Byte range 4 .. 4;
10911       Master_V5      at Master_Byte range 5 .. 5;
10912       Master_V6      at Master_Byte range 6 .. 6;
10913       Master_V7      at Master_Byte range 7 .. 7;
10914       Slave_Control  at Slave_Byte  range 0 .. 0;
10915       Slave_V1       at Slave_Byte  range 1 .. 1;
10916       Slave_V2       at Slave_Byte  range 2 .. 2;
10917       Slave_V3       at Slave_Byte  range 3 .. 3;
10918       Slave_V4       at Slave_Byte  range 4 .. 4;
10919       Slave_V5       at Slave_Byte  range 5 .. 5;
10920       Slave_V6       at Slave_Byte  range 6 .. 6;
10921       Slave_V7       at Slave_Byte  range 7 .. 7;
10922    end record;
10923 @end smallexample
10924
10925 @noindent
10926 Now to switch between machines, all that is necessary is
10927 to set the boolean constant @code{Master_Byte_First} in
10928 an appropriate manner.
10929
10930 @node Pragma Pack for Arrays
10931 @section Pragma Pack for Arrays
10932 @cindex Pragma Pack (for arrays)
10933
10934 @noindent
10935 Pragma @code{Pack} applied to an array has no effect unless the component type
10936 is packable.  For a component type to be packable, it must be one of the
10937 following cases:
10938
10939 @itemize @bullet
10940 @item
10941 Any scalar type
10942 @item
10943 Any type whose size is specified with a size clause
10944 @item
10945 Any packed array type with a static size
10946 @item
10947 Any record type padded because of its default alignment
10948 @end itemize
10949
10950 @noindent
10951 For all these cases, if the component subtype size is in the range
10952 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10953 component size were specified giving the component subtype size.
10954 For example if we have:
10955
10956 @smallexample @c ada
10957    type r is range 0 .. 17;
10958
10959    type ar is array (1 .. 8) of r;
10960    pragma Pack (ar);
10961 @end smallexample
10962
10963 @noindent
10964 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10965 and the size of the array @code{ar} will be exactly 40 bits.
10966
10967 Note that in some cases this rather fierce approach to packing can produce
10968 unexpected effects.  For example, in Ada 95 and Ada 2005,
10969 subtype @code{Natural} typically has a size of 31, meaning that if you
10970 pack an array of @code{Natural}, you get 31-bit
10971 close packing, which saves a few bits, but results in far less efficient
10972 access.  Since many other Ada compilers will ignore such a packing request,
10973 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10974 might not be what is intended.  You can easily remove this warning by
10975 using an explicit @code{Component_Size} setting instead, which never generates
10976 a warning, since the intention of the programmer is clear in this case.
10977
10978 GNAT treats packed arrays in one of two ways.  If the size of the array is
10979 known at compile time and is less than 64 bits, then internally the array
10980 is represented as a single modular type, of exactly the appropriate number
10981 of bits.  If the length is greater than 63 bits, or is not known at compile
10982 time, then the packed array is represented as an array of bytes, and the
10983 length is always a multiple of 8 bits.
10984
10985 Note that to represent a packed array as a modular type, the alignment must
10986 be suitable for the modular type involved. For example, on typical machines
10987 a 32-bit packed array will be represented by a 32-bit modular integer with
10988 an alignment of four bytes. If you explicitly override the default alignment
10989 with an alignment clause that is too small, the modular representation
10990 cannot be used. For example, consider the following set of declarations:
10991
10992 @smallexample @c ada
10993    type R is range 1 .. 3;
10994    type S is array (1 .. 31) of R;
10995    for S'Component_Size use 2;
10996    for S'Size use 62;
10997    for S'Alignment use 1;
10998 @end smallexample
10999
11000 @noindent
11001 If the alignment clause were not present, then a 62-bit modular
11002 representation would be chosen (typically with an alignment of 4 or 8
11003 bytes depending on the target). But the default alignment is overridden
11004 with the explicit alignment clause. This means that the modular
11005 representation cannot be used, and instead the array of bytes
11006 representation must be used, meaning that the length must be a multiple
11007 of 8. Thus the above set of declarations will result in a diagnostic
11008 rejecting the size clause and noting that the minimum size allowed is 64.
11009
11010 @cindex Pragma Pack (for type Natural)
11011 @cindex Pragma Pack warning
11012
11013 One special case that is worth noting occurs when the base type of the
11014 component size is 8/16/32 and the subtype is one bit less. Notably this
11015 occurs with subtype @code{Natural}. Consider:
11016
11017 @smallexample @c ada
11018    type Arr is array (1 .. 32) of Natural;
11019    pragma Pack (Arr);
11020 @end smallexample
11021
11022 @noindent
11023 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11024 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11025 Ada 83 compilers did not attempt 31 bit packing.
11026
11027 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11028 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11029 substantial unintended performance penalty when porting legacy Ada 83 code.
11030 To help prevent this, GNAT generates a warning in such cases. If you really
11031 want 31 bit packing in a case like this, you can set the component size
11032 explicitly:
11033
11034 @smallexample @c ada
11035    type Arr is array (1 .. 32) of Natural;
11036    for Arr'Component_Size use 31;
11037 @end smallexample
11038
11039 @noindent
11040 Here 31-bit packing is achieved as required, and no warning is generated,
11041 since in this case the programmer intention is clear.
11042
11043 @node Pragma Pack for Records
11044 @section Pragma Pack for Records
11045 @cindex Pragma Pack (for records)
11046
11047 @noindent
11048 Pragma @code{Pack} applied to a record will pack the components to reduce
11049 wasted space from alignment gaps and by reducing the amount of space
11050 taken by components.  We distinguish between @emph{packable} components and
11051 @emph{non-packable} components.
11052 Components of the following types are considered packable:
11053 @itemize @bullet
11054 @item
11055 All primitive types are packable.
11056
11057 @item
11058 Small packed arrays, whose size does not exceed 64 bits, and where the
11059 size is statically known at compile time, are represented internally
11060 as modular integers, and so they are also packable.
11061
11062 @end itemize
11063
11064 @noindent
11065 All packable components occupy the exact number of bits corresponding to
11066 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11067 can start on an arbitrary bit boundary.
11068
11069 All other types are non-packable, they occupy an integral number of
11070 storage units, and
11071 are placed at a boundary corresponding to their alignment requirements.
11072
11073 For example, consider the record
11074
11075 @smallexample @c ada
11076    type Rb1 is array (1 .. 13) of Boolean;
11077    pragma Pack (rb1);
11078
11079    type Rb2 is array (1 .. 65) of Boolean;
11080    pragma Pack (rb2);
11081
11082    type x2 is record
11083       l1 : Boolean;
11084       l2 : Duration;
11085       l3 : Float;
11086       l4 : Boolean;
11087       l5 : Rb1;
11088       l6 : Rb2;
11089    end record;
11090    pragma Pack (x2);
11091 @end smallexample
11092
11093 @noindent
11094 The representation for the record x2 is as follows:
11095
11096 @smallexample @c ada
11097 for x2'Size use 224;
11098 for x2 use record
11099    l1 at  0 range  0 .. 0;
11100    l2 at  0 range  1 .. 64;
11101    l3 at 12 range  0 .. 31;
11102    l4 at 16 range  0 .. 0;
11103    l5 at 16 range  1 .. 13;
11104    l6 at 18 range  0 .. 71;
11105 end record;
11106 @end smallexample
11107
11108 @noindent
11109 Studying this example, we see that the packable fields @code{l1}
11110 and @code{l2} are
11111 of length equal to their sizes, and placed at specific bit boundaries (and
11112 not byte boundaries) to
11113 eliminate padding.  But @code{l3} is of a non-packable float type, so
11114 it is on the next appropriate alignment boundary.
11115
11116 The next two fields are fully packable, so @code{l4} and @code{l5} are
11117 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11118 array that is longer than 64 bits, so it is itself non-packable.  Thus
11119 the @code{l6} field is aligned to the next byte boundary, and takes an
11120 integral number of bytes, i.e.@: 72 bits.
11121
11122 @node Record Representation Clauses
11123 @section Record Representation Clauses
11124 @cindex Record Representation Clause
11125
11126 @noindent
11127 Record representation clauses may be given for all record types, including
11128 types obtained by record extension.  Component clauses are allowed for any
11129 static component.  The restrictions on component clauses depend on the type
11130 of the component.
11131
11132 @cindex Component Clause
11133 For all components of an elementary type, the only restriction on component
11134 clauses is that the size must be at least the 'Size value of the type
11135 (actually the Value_Size).  There are no restrictions due to alignment,
11136 and such components may freely cross storage boundaries.
11137
11138 Packed arrays with a size up to and including 64 bits are represented
11139 internally using a modular type with the appropriate number of bits, and
11140 thus the same lack of restriction applies.  For example, if you declare:
11141
11142 @smallexample @c ada
11143    type R is array (1 .. 49) of Boolean;
11144    pragma Pack (R);
11145    for R'Size use 49;
11146 @end smallexample
11147
11148 @noindent
11149 then a component clause for a component of type R may start on any
11150 specified bit boundary, and may specify a value of 49 bits or greater.
11151
11152 For packed bit arrays that are longer than 64 bits, there are two
11153 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11154 including the important case of single bits or boolean values, then
11155 there are no limitations on placement of such components, and they
11156 may start and end at arbitrary bit boundaries.
11157
11158 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11159 an array of this type longer than 64 bits must always be placed on
11160 on a storage unit (byte) boundary and occupy an integral number
11161 of storage units (bytes). Any component clause that does not
11162 meet this requirement will be rejected.
11163
11164 Any aliased component, or component of an aliased type, must
11165 have its normal alignment and size. A component clause that
11166 does not meet this requirement will be rejected.
11167
11168 The tag field of a tagged type always occupies an address sized field at
11169 the start of the record.  No component clause may attempt to overlay this
11170 tag. When a tagged type appears as a component, the tag field must have
11171 proper alignment
11172
11173 In the case of a record extension T1, of a type T, no component clause applied
11174 to the type T1 can specify a storage location that would overlap the first
11175 T'Size bytes of the record.
11176
11177 For all other component types, including non-bit-packed arrays,
11178 the component can be placed at an arbitrary bit boundary,
11179 so for example, the following is permitted:
11180
11181 @smallexample @c ada
11182    type R is array (1 .. 10) of Boolean;
11183    for R'Size use 80;
11184
11185    type Q is record
11186       G, H : Boolean;
11187       L, M : R;
11188    end record;
11189
11190    for Q use record
11191       G at 0 range  0 ..   0;
11192       H at 0 range  1 ..   1;
11193       L at 0 range  2 ..  81;
11194       R at 0 range 82 .. 161;
11195    end record;
11196 @end smallexample
11197
11198 @noindent
11199 Note: the above rules apply to recent releases of GNAT 5.
11200 In GNAT 3, there are more severe restrictions on larger components.
11201 For non-primitive types, including packed arrays with a size greater than
11202 64 bits, component clauses must respect the alignment requirement of the
11203 type, in particular, always starting on a byte boundary, and the length
11204 must be a multiple of the storage unit.
11205
11206 @node Enumeration Clauses
11207 @section Enumeration Clauses
11208
11209 The only restriction on enumeration clauses is that the range of values
11210 must be representable.  For the signed case, if one or more of the
11211 representation values are negative, all values must be in the range:
11212
11213 @smallexample @c ada
11214    System.Min_Int .. System.Max_Int
11215 @end smallexample
11216
11217 @noindent
11218 For the unsigned case, where all values are nonnegative, the values must
11219 be in the range:
11220
11221 @smallexample @c ada
11222    0 .. System.Max_Binary_Modulus;
11223 @end smallexample
11224
11225 @noindent
11226 A @emph{confirming} representation clause is one in which the values range
11227 from 0 in sequence, i.e.@: a clause that confirms the default representation
11228 for an enumeration type.
11229 Such a confirming representation
11230 is permitted by these rules, and is specially recognized by the compiler so
11231 that no extra overhead results from the use of such a clause.
11232
11233 If an array has an index type which is an enumeration type to which an
11234 enumeration clause has been applied, then the array is stored in a compact
11235 manner.  Consider the declarations:
11236
11237 @smallexample @c ada
11238    type r is (A, B, C);
11239    for r use (A => 1, B => 5, C => 10);
11240    type t is array (r) of Character;
11241 @end smallexample
11242
11243 @noindent
11244 The array type t corresponds to a vector with exactly three elements and
11245 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11246 use of space, but means that accesses to elements of the array will incur
11247 the overhead of converting representation values to the corresponding
11248 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11249
11250 @node Address Clauses
11251 @section Address Clauses
11252 @cindex Address Clause
11253
11254 The reference manual allows a general restriction on representation clauses,
11255 as found in RM 13.1(22):
11256
11257 @quotation
11258 An implementation need not support representation
11259 items containing nonstatic expressions, except that
11260 an implementation should support a representation item
11261 for a given entity if each nonstatic expression in the
11262 representation item is a name that statically denotes
11263 a constant declared before the entity.
11264 @end quotation
11265
11266 @noindent
11267 In practice this is applicable only to address clauses, since this is the
11268 only case in which a non-static expression is permitted by the syntax.  As
11269 the AARM notes in sections 13.1 (22.a-22.h):
11270
11271 @display
11272   22.a   Reason: This is to avoid the following sort of thing:
11273
11274   22.b        X : Integer := F(@dots{});
11275               Y : Address := G(@dots{});
11276               for X'Address use Y;
11277
11278   22.c   In the above, we have to evaluate the
11279          initialization expression for X before we
11280          know where to put the result.  This seems
11281          like an unreasonable implementation burden.
11282
11283   22.d   The above code should instead be written
11284          like this:
11285
11286   22.e        Y : constant Address := G(@dots{});
11287               X : Integer := F(@dots{});
11288               for X'Address use Y;
11289
11290   22.f   This allows the expression ``Y'' to be safely
11291          evaluated before X is created.
11292
11293   22.g   The constant could be a formal parameter of mode in.
11294
11295   22.h   An implementation can support other nonstatic
11296          expressions if it wants to.  Expressions of type
11297          Address are hardly ever static, but their value
11298          might be known at compile time anyway in many
11299          cases.
11300 @end display
11301
11302 @noindent
11303 GNAT does indeed permit many additional cases of non-static expressions.  In
11304 particular, if the type involved is elementary there are no restrictions
11305 (since in this case, holding a temporary copy of the initialization value,
11306 if one is present, is inexpensive).  In addition, if there is no implicit or
11307 explicit initialization, then there are no restrictions.  GNAT will reject
11308 only the case where all three of these conditions hold:
11309
11310 @itemize @bullet
11311
11312 @item
11313 The type of the item is non-elementary (e.g.@: a record or array).
11314
11315 @item
11316 There is explicit or implicit initialization required for the object.
11317 Note that access values are always implicitly initialized, and also
11318 in GNAT, certain bit-packed arrays (those having a dynamic length or
11319 a length greater than 64) will also be implicitly initialized to zero.
11320
11321 @item
11322 The address value is non-static.  Here GNAT is more permissive than the
11323 RM, and allows the address value to be the address of a previously declared
11324 stand-alone variable, as long as it does not itself have an address clause.
11325
11326 @smallexample @c ada
11327            Anchor  : Some_Initialized_Type;
11328            Overlay : Some_Initialized_Type;
11329            for Overlay'Address use Anchor'Address;
11330 @end smallexample
11331
11332 @noindent
11333 However, the prefix of the address clause cannot be an array component, or
11334 a component of a discriminated record.
11335
11336 @end itemize
11337
11338 @noindent
11339 As noted above in section 22.h, address values are typically non-static.  In
11340 particular the To_Address function, even if applied to a literal value, is
11341 a non-static function call.  To avoid this minor annoyance, GNAT provides
11342 the implementation defined attribute 'To_Address.  The following two
11343 expressions have identical values:
11344
11345 @findex Attribute
11346 @findex To_Address
11347 @smallexample @c ada
11348    To_Address (16#1234_0000#)
11349    System'To_Address (16#1234_0000#);
11350 @end smallexample
11351
11352 @noindent
11353 except that the second form is considered to be a static expression, and
11354 thus when used as an address clause value is always permitted.
11355
11356 @noindent
11357 Additionally, GNAT treats as static an address clause that is an
11358 unchecked_conversion of a static integer value.  This simplifies the porting
11359 of legacy code, and provides a portable equivalent to the GNAT attribute
11360 @code{To_Address}.
11361
11362 Another issue with address clauses is the interaction with alignment
11363 requirements.  When an address clause is given for an object, the address
11364 value must be consistent with the alignment of the object (which is usually
11365 the same as the alignment of the type of the object).  If an address clause
11366 is given that specifies an inappropriately aligned address value, then the
11367 program execution is erroneous.
11368
11369 Since this source of erroneous behavior can have unfortunate effects, GNAT
11370 checks (at compile time if possible, generating a warning, or at execution
11371 time with a run-time check) that the alignment is appropriate.  If the
11372 run-time check fails, then @code{Program_Error} is raised.  This run-time
11373 check is suppressed if range checks are suppressed, or if the special GNAT
11374 check Alignment_Check is suppressed, or if
11375 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11376
11377 Finally, GNAT does not permit overlaying of objects of controlled types or
11378 composite types containing a controlled component. In most cases, the compiler
11379 can detect an attempt at such overlays and will generate a warning at compile
11380 time and a Program_Error exception at run time.
11381
11382 @findex Export
11383 An address clause cannot be given for an exported object.  More
11384 understandably the real restriction is that objects with an address
11385 clause cannot be exported.  This is because such variables are not
11386 defined by the Ada program, so there is no external object to export.
11387
11388 @findex Import
11389 It is permissible to give an address clause and a pragma Import for the
11390 same object.  In this case, the variable is not really defined by the
11391 Ada program, so there is no external symbol to be linked.  The link name
11392 and the external name are ignored in this case.  The reason that we allow this
11393 combination is that it provides a useful idiom to avoid unwanted
11394 initializations on objects with address clauses.
11395
11396 When an address clause is given for an object that has implicit or
11397 explicit initialization, then by default initialization takes place.  This
11398 means that the effect of the object declaration is to overwrite the
11399 memory at the specified address.  This is almost always not what the
11400 programmer wants, so GNAT will output a warning:
11401
11402 @smallexample
11403   with System;
11404   package G is
11405      type R is record
11406         M : Integer := 0;
11407      end record;
11408
11409      Ext : R;
11410      for Ext'Address use System'To_Address (16#1234_1234#);
11411          |
11412   >>> warning: implicit initialization of "Ext" may
11413       modify overlaid storage
11414   >>> warning: use pragma Import for "Ext" to suppress
11415       initialization (RM B(24))
11416
11417   end G;
11418 @end smallexample
11419
11420 @noindent
11421 As indicated by the warning message, the solution is to use a (dummy) pragma
11422 Import to suppress this initialization.  The pragma tell the compiler that the
11423 object is declared and initialized elsewhere.  The following package compiles
11424 without warnings (and the initialization is suppressed):
11425
11426 @smallexample @c ada
11427    with System;
11428    package G is
11429       type R is record
11430          M : Integer := 0;
11431       end record;
11432
11433       Ext : R;
11434       for Ext'Address use System'To_Address (16#1234_1234#);
11435       pragma Import (Ada, Ext);
11436    end G;
11437 @end smallexample
11438
11439 @noindent
11440 A final issue with address clauses involves their use for overlaying
11441 variables, as in the following example:
11442 @cindex Overlaying of objects
11443
11444 @smallexample @c ada
11445   A : Integer;
11446   B : Integer;
11447   for B'Address use A'Address;
11448 @end smallexample
11449
11450 @noindent
11451 or alternatively, using the form recommended by the RM:
11452
11453 @smallexample @c ada
11454   A    : Integer;
11455   Addr : constant Address := A'Address;
11456   B    : Integer;
11457   for B'Address use Addr;
11458 @end smallexample
11459
11460 @noindent
11461 In both of these cases, @code{A}
11462 and @code{B} become aliased to one another via the
11463 address clause. This use of address clauses to overlay
11464 variables, achieving an effect similar to unchecked
11465 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11466 the effect is implementation defined. Furthermore, the
11467 Ada RM specifically recommends that in a situation
11468 like this, @code{B} should be subject to the following
11469 implementation advice (RM 13.3(19)):
11470
11471 @quotation
11472 19  If the Address of an object is specified, or it is imported
11473     or exported, then the implementation should not perform
11474     optimizations based on assumptions of no aliases.
11475 @end quotation
11476
11477 @noindent
11478 GNAT follows this recommendation, and goes further by also applying
11479 this recommendation to the overlaid variable (@code{A}
11480 in the above example) in this case. This means that the overlay
11481 works "as expected", in that a modification to one of the variables
11482 will affect the value of the other.
11483
11484 @node Effect of Convention on Representation
11485 @section Effect of Convention on Representation
11486 @cindex Convention, effect on representation
11487
11488 @noindent
11489 Normally the specification of a foreign language convention for a type or
11490 an object has no effect on the chosen representation.  In particular, the
11491 representation chosen for data in GNAT generally meets the standard system
11492 conventions, and for example records are laid out in a manner that is
11493 consistent with C@.  This means that specifying convention C (for example)
11494 has no effect.
11495
11496 There are four exceptions to this general rule:
11497
11498 @itemize @bullet
11499
11500 @item Convention Fortran and array subtypes
11501 If pragma Convention Fortran is specified for an array subtype, then in
11502 accordance with the implementation advice in section 3.6.2(11) of the
11503 Ada Reference Manual, the array will be stored in a Fortran-compatible
11504 column-major manner, instead of the normal default row-major order.
11505
11506 @item Convention C and enumeration types
11507 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11508 to accommodate all values of the type.  For example, for the enumeration
11509 type declared by:
11510
11511 @smallexample @c ada
11512    type Color is (Red, Green, Blue);
11513 @end smallexample
11514
11515 @noindent
11516 8 bits is sufficient to store all values of the type, so by default, objects
11517 of type @code{Color} will be represented using 8 bits.  However, normal C
11518 convention is to use 32 bits for all enum values in C, since enum values
11519 are essentially of type int.  If pragma @code{Convention C} is specified for an
11520 Ada enumeration type, then the size is modified as necessary (usually to
11521 32 bits) to be consistent with the C convention for enum values.
11522
11523 Note that this treatment applies only to types. If Convention C is given for
11524 an enumeration object, where the enumeration type is not Convention C, then
11525 Object_Size bits are allocated. For example, for a normal enumeration type,
11526 with less than 256 elements, only 8 bits will be allocated for the object.
11527 Since this may be a surprise in terms of what C expects, GNAT will issue a
11528 warning in this situation. The warning can be suppressed by giving an explicit
11529 size clause specifying the desired size.
11530
11531 @item Convention C/Fortran and Boolean types
11532 In C, the usual convention for boolean values, that is values used for
11533 conditions, is that zero represents false, and nonzero values represent
11534 true.  In Ada, the normal convention is that two specific values, typically
11535 0/1, are used to represent false/true respectively.
11536
11537 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11538 value represents true).
11539
11540 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11541 C or Fortran convention for a derived Boolean, as in the following example:
11542
11543 @smallexample @c ada
11544    type C_Switch is new Boolean;
11545    pragma Convention (C, C_Switch);
11546 @end smallexample
11547
11548 @noindent
11549 then the GNAT generated code will treat any nonzero value as true.  For truth
11550 values generated by GNAT, the conventional value 1 will be used for True, but
11551 when one of these values is read, any nonzero value is treated as True.
11552
11553 @item Access types on OpenVMS
11554 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11555 arrays) are 64-bits long. An exception to this rule is for the case of
11556 C-convention access types where there is no explicit size clause present (or
11557 inherited for derived types). In this case, GNAT chooses to make these
11558 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11559 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11560
11561 @end itemize
11562
11563 @node Determining the Representations chosen by GNAT
11564 @section Determining the Representations chosen by GNAT
11565 @cindex Representation, determination of
11566 @cindex @option{-gnatR} switch
11567
11568 @noindent
11569 Although the descriptions in this section are intended to be complete, it is
11570 often easier to simply experiment to see what GNAT accepts and what the
11571 effect is on the layout of types and objects.
11572
11573 As required by the Ada RM, if a representation clause is not accepted, then
11574 it must be rejected as illegal by the compiler.  However, when a
11575 representation clause or pragma is accepted, there can still be questions
11576 of what the compiler actually does.  For example, if a partial record
11577 representation clause specifies the location of some components and not
11578 others, then where are the non-specified components placed? Or if pragma
11579 @code{Pack} is used on a record, then exactly where are the resulting
11580 fields placed? The section on pragma @code{Pack} in this chapter can be
11581 used to answer the second question, but it is often easier to just see
11582 what the compiler does.
11583
11584 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11585 with this option, then the compiler will output information on the actual
11586 representations chosen, in a format similar to source representation
11587 clauses.  For example, if we compile the package:
11588
11589 @smallexample @c ada
11590 package q is
11591    type r (x : boolean) is tagged record
11592       case x is
11593          when True => S : String (1 .. 100);
11594          when False => null;
11595       end case;
11596    end record;
11597
11598    type r2 is new r (false) with record
11599       y2 : integer;
11600    end record;
11601
11602    for r2 use record
11603       y2 at 16 range 0 .. 31;
11604    end record;
11605
11606    type x is record
11607       y : character;
11608    end record;
11609
11610    type x1 is array (1 .. 10) of x;
11611    for x1'component_size use 11;
11612
11613    type ia is access integer;
11614
11615    type Rb1 is array (1 .. 13) of Boolean;
11616    pragma Pack (rb1);
11617
11618    type Rb2 is array (1 .. 65) of Boolean;
11619    pragma Pack (rb2);
11620
11621    type x2 is record
11622       l1 : Boolean;
11623       l2 : Duration;
11624       l3 : Float;
11625       l4 : Boolean;
11626       l5 : Rb1;
11627       l6 : Rb2;
11628    end record;
11629    pragma Pack (x2);
11630 end q;
11631 @end smallexample
11632
11633 @noindent
11634 using the switch @option{-gnatR} we obtain the following output:
11635
11636 @smallexample
11637 Representation information for unit q
11638 -------------------------------------
11639
11640 for r'Size use ??;
11641 for r'Alignment use 4;
11642 for r use record
11643    x    at 4 range  0 .. 7;
11644    _tag at 0 range  0 .. 31;
11645    s    at 5 range  0 .. 799;
11646 end record;
11647
11648 for r2'Size use 160;
11649 for r2'Alignment use 4;
11650 for r2 use record
11651    x       at  4 range  0 .. 7;
11652    _tag    at  0 range  0 .. 31;
11653    _parent at  0 range  0 .. 63;
11654    y2      at 16 range  0 .. 31;
11655 end record;
11656
11657 for x'Size use 8;
11658 for x'Alignment use 1;
11659 for x use record
11660    y at 0 range  0 .. 7;
11661 end record;
11662
11663 for x1'Size use 112;
11664 for x1'Alignment use 1;
11665 for x1'Component_Size use 11;
11666
11667 for rb1'Size use 13;
11668 for rb1'Alignment use 2;
11669 for rb1'Component_Size use 1;
11670
11671 for rb2'Size use 72;
11672 for rb2'Alignment use 1;
11673 for rb2'Component_Size use 1;
11674
11675 for x2'Size use 224;
11676 for x2'Alignment use 4;
11677 for x2 use record
11678    l1 at  0 range  0 .. 0;
11679    l2 at  0 range  1 .. 64;
11680    l3 at 12 range  0 .. 31;
11681    l4 at 16 range  0 .. 0;
11682    l5 at 16 range  1 .. 13;
11683    l6 at 18 range  0 .. 71;
11684 end record;
11685 @end smallexample
11686
11687 @noindent
11688 The Size values are actually the Object_Size, i.e.@: the default size that
11689 will be allocated for objects of the type.
11690 The ?? size for type r indicates that we have a variant record, and the
11691 actual size of objects will depend on the discriminant value.
11692
11693 The Alignment values show the actual alignment chosen by the compiler
11694 for each record or array type.
11695
11696 The record representation clause for type r shows where all fields
11697 are placed, including the compiler generated tag field (whose location
11698 cannot be controlled by the programmer).
11699
11700 The record representation clause for the type extension r2 shows all the
11701 fields present, including the parent field, which is a copy of the fields
11702 of the parent type of r2, i.e.@: r1.
11703
11704 The component size and size clauses for types rb1 and rb2 show
11705 the exact effect of pragma @code{Pack} on these arrays, and the record
11706 representation clause for type x2 shows how pragma @code{Pack} affects
11707 this record type.
11708
11709 In some cases, it may be useful to cut and paste the representation clauses
11710 generated by the compiler into the original source to fix and guarantee
11711 the actual representation to be used.
11712
11713 @node Standard Library Routines
11714 @chapter Standard Library Routines
11715
11716 @noindent
11717 The Ada Reference Manual contains in Annex A a full description of an
11718 extensive set of standard library routines that can be used in any Ada
11719 program, and which must be provided by all Ada compilers.  They are
11720 analogous to the standard C library used by C programs.
11721
11722 GNAT implements all of the facilities described in annex A, and for most
11723 purposes the description in the Ada Reference Manual, or appropriate Ada
11724 text book, will be sufficient for making use of these facilities.
11725
11726 In the case of the input-output facilities,
11727 @xref{The Implementation of Standard I/O},
11728 gives details on exactly how GNAT interfaces to the
11729 file system.  For the remaining packages, the Ada Reference Manual
11730 should be sufficient.  The following is a list of the packages included,
11731 together with a brief description of the functionality that is provided.
11732
11733 For completeness, references are included to other predefined library
11734 routines defined in other sections of the Ada Reference Manual (these are
11735 cross-indexed from Annex A).
11736
11737 @table @code
11738 @item Ada (A.2)
11739 This is a parent package for all the standard library packages.  It is
11740 usually included implicitly in your program, and itself contains no
11741 useful data or routines.
11742
11743 @item Ada.Calendar (9.6)
11744 @code{Calendar} provides time of day access, and routines for
11745 manipulating times and durations.
11746
11747 @item Ada.Characters (A.3.1)
11748 This is a dummy parent package that contains no useful entities
11749
11750 @item Ada.Characters.Handling (A.3.2)
11751 This package provides some basic character handling capabilities,
11752 including classification functions for classes of characters (e.g.@: test
11753 for letters, or digits).
11754
11755 @item Ada.Characters.Latin_1 (A.3.3)
11756 This package includes a complete set of definitions of the characters
11757 that appear in type CHARACTER@.  It is useful for writing programs that
11758 will run in international environments.  For example, if you want an
11759 upper case E with an acute accent in a string, it is often better to use
11760 the definition of @code{UC_E_Acute} in this package.  Then your program
11761 will print in an understandable manner even if your environment does not
11762 support these extended characters.
11763
11764 @item Ada.Command_Line (A.15)
11765 This package provides access to the command line parameters and the name
11766 of the current program (analogous to the use of @code{argc} and @code{argv}
11767 in C), and also allows the exit status for the program to be set in a
11768 system-independent manner.
11769
11770 @item Ada.Decimal (F.2)
11771 This package provides constants describing the range of decimal numbers
11772 implemented, and also a decimal divide routine (analogous to the COBOL
11773 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11774
11775 @item Ada.Direct_IO (A.8.4)
11776 This package provides input-output using a model of a set of records of
11777 fixed-length, containing an arbitrary definite Ada type, indexed by an
11778 integer record number.
11779
11780 @item Ada.Dynamic_Priorities (D.5)
11781 This package allows the priorities of a task to be adjusted dynamically
11782 as the task is running.
11783
11784 @item Ada.Exceptions (11.4.1)
11785 This package provides additional information on exceptions, and also
11786 contains facilities for treating exceptions as data objects, and raising
11787 exceptions with associated messages.
11788
11789 @item Ada.Finalization (7.6)
11790 This package contains the declarations and subprograms to support the
11791 use of controlled types, providing for automatic initialization and
11792 finalization (analogous to the constructors and destructors of C++)
11793
11794 @item Ada.Interrupts (C.3.2)
11795 This package provides facilities for interfacing to interrupts, which
11796 includes the set of signals or conditions that can be raised and
11797 recognized as interrupts.
11798
11799 @item Ada.Interrupts.Names (C.3.2)
11800 This package provides the set of interrupt names (actually signal
11801 or condition names) that can be handled by GNAT@.
11802
11803 @item Ada.IO_Exceptions (A.13)
11804 This package defines the set of exceptions that can be raised by use of
11805 the standard IO packages.
11806
11807 @item Ada.Numerics
11808 This package contains some standard constants and exceptions used
11809 throughout the numerics packages.  Note that the constants pi and e are
11810 defined here, and it is better to use these definitions than rolling
11811 your own.
11812
11813 @item Ada.Numerics.Complex_Elementary_Functions
11814 Provides the implementation of standard elementary functions (such as
11815 log and trigonometric functions) operating on complex numbers using the
11816 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11817 created by the package @code{Numerics.Complex_Types}.
11818
11819 @item Ada.Numerics.Complex_Types
11820 This is a predefined instantiation of
11821 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11822 build the type @code{Complex} and @code{Imaginary}.
11823
11824 @item Ada.Numerics.Discrete_Random
11825 This package provides a random number generator suitable for generating
11826 random integer values from a specified range.
11827
11828 @item Ada.Numerics.Float_Random
11829 This package provides a random number generator suitable for generating
11830 uniformly distributed floating point values.
11831
11832 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11833 This is a generic version of the package that provides the
11834 implementation of standard elementary functions (such as log and
11835 trigonometric functions) for an arbitrary complex type.
11836
11837 The following predefined instantiations of this package are provided:
11838
11839 @table @code
11840 @item Short_Float
11841 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11842 @item Float
11843 @code{Ada.Numerics.Complex_Elementary_Functions}
11844 @item Long_Float
11845 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11846 @end table
11847
11848 @item Ada.Numerics.Generic_Complex_Types
11849 This is a generic package that allows the creation of complex types,
11850 with associated complex arithmetic operations.
11851
11852 The following predefined instantiations of this package exist
11853 @table @code
11854 @item Short_Float
11855 @code{Ada.Numerics.Short_Complex_Complex_Types}
11856 @item Float
11857 @code{Ada.Numerics.Complex_Complex_Types}
11858 @item Long_Float
11859 @code{Ada.Numerics.Long_Complex_Complex_Types}
11860 @end table
11861
11862 @item Ada.Numerics.Generic_Elementary_Functions
11863 This is a generic package that provides the implementation of standard
11864 elementary functions (such as log an trigonometric functions) for an
11865 arbitrary float type.
11866
11867 The following predefined instantiations of this package exist
11868
11869 @table @code
11870 @item Short_Float
11871 @code{Ada.Numerics.Short_Elementary_Functions}
11872 @item Float
11873 @code{Ada.Numerics.Elementary_Functions}
11874 @item Long_Float
11875 @code{Ada.Numerics.Long_Elementary_Functions}
11876 @end table
11877
11878 @item Ada.Real_Time (D.8)
11879 This package provides facilities similar to those of @code{Calendar}, but
11880 operating with a finer clock suitable for real time control. Note that
11881 annex D requires that there be no backward clock jumps, and GNAT generally
11882 guarantees this behavior, but of course if the external clock on which
11883 the GNAT runtime depends is deliberately reset by some external event,
11884 then such a backward jump may occur.
11885
11886 @item Ada.Sequential_IO (A.8.1)
11887 This package provides input-output facilities for sequential files,
11888 which can contain a sequence of values of a single type, which can be
11889 any Ada type, including indefinite (unconstrained) types.
11890
11891 @item Ada.Storage_IO (A.9)
11892 This package provides a facility for mapping arbitrary Ada types to and
11893 from a storage buffer.  It is primarily intended for the creation of new
11894 IO packages.
11895
11896 @item Ada.Streams (13.13.1)
11897 This is a generic package that provides the basic support for the
11898 concept of streams as used by the stream attributes (@code{Input},
11899 @code{Output}, @code{Read} and @code{Write}).
11900
11901 @item Ada.Streams.Stream_IO (A.12.1)
11902 This package is a specialization of the type @code{Streams} defined in
11903 package @code{Streams} together with a set of operations providing
11904 Stream_IO capability.  The Stream_IO model permits both random and
11905 sequential access to a file which can contain an arbitrary set of values
11906 of one or more Ada types.
11907
11908 @item Ada.Strings (A.4.1)
11909 This package provides some basic constants used by the string handling
11910 packages.
11911
11912 @item Ada.Strings.Bounded (A.4.4)
11913 This package provides facilities for handling variable length
11914 strings.  The bounded model requires a maximum length.  It is thus
11915 somewhat more limited than the unbounded model, but avoids the use of
11916 dynamic allocation or finalization.
11917
11918 @item Ada.Strings.Fixed (A.4.3)
11919 This package provides facilities for handling fixed length strings.
11920
11921 @item Ada.Strings.Maps (A.4.2)
11922 This package provides facilities for handling character mappings and
11923 arbitrarily defined subsets of characters.  For instance it is useful in
11924 defining specialized translation tables.
11925
11926 @item Ada.Strings.Maps.Constants (A.4.6)
11927 This package provides a standard set of predefined mappings and
11928 predefined character sets.  For example, the standard upper to lower case
11929 conversion table is found in this package.  Note that upper to lower case
11930 conversion is non-trivial if you want to take the entire set of
11931 characters, including extended characters like E with an acute accent,
11932 into account.  You should use the mappings in this package (rather than
11933 adding 32 yourself) to do case mappings.
11934
11935 @item Ada.Strings.Unbounded (A.4.5)
11936 This package provides facilities for handling variable length
11937 strings.  The unbounded model allows arbitrary length strings, but
11938 requires the use of dynamic allocation and finalization.
11939
11940 @item Ada.Strings.Wide_Bounded (A.4.7)
11941 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11942 @itemx Ada.Strings.Wide_Maps (A.4.7)
11943 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11944 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11945 These packages provide analogous capabilities to the corresponding
11946 packages without @samp{Wide_} in the name, but operate with the types
11947 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11948 and @code{Character}.
11949
11950 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11951 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11952 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11953 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11954 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11955 These packages provide analogous capabilities to the corresponding
11956 packages without @samp{Wide_} in the name, but operate with the types
11957 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11958 of @code{String} and @code{Character}.
11959
11960 @item Ada.Synchronous_Task_Control (D.10)
11961 This package provides some standard facilities for controlling task
11962 communication in a synchronous manner.
11963
11964 @item Ada.Tags
11965 This package contains definitions for manipulation of the tags of tagged
11966 values.
11967
11968 @item Ada.Task_Attributes
11969 This package provides the capability of associating arbitrary
11970 task-specific data with separate tasks.
11971
11972 @item Ada.Text_IO
11973 This package provides basic text input-output capabilities for
11974 character, string and numeric data.  The subpackages of this
11975 package are listed next.
11976
11977 @item Ada.Text_IO.Decimal_IO
11978 Provides input-output facilities for decimal fixed-point types
11979
11980 @item Ada.Text_IO.Enumeration_IO
11981 Provides input-output facilities for enumeration types.
11982
11983 @item Ada.Text_IO.Fixed_IO
11984 Provides input-output facilities for ordinary fixed-point types.
11985
11986 @item Ada.Text_IO.Float_IO
11987 Provides input-output facilities for float types.  The following
11988 predefined instantiations of this generic package are available:
11989
11990 @table @code
11991 @item Short_Float
11992 @code{Short_Float_Text_IO}
11993 @item Float
11994 @code{Float_Text_IO}
11995 @item Long_Float
11996 @code{Long_Float_Text_IO}
11997 @end table
11998
11999 @item Ada.Text_IO.Integer_IO
12000 Provides input-output facilities for integer types.  The following
12001 predefined instantiations of this generic package are available:
12002
12003 @table @code
12004 @item Short_Short_Integer
12005 @code{Ada.Short_Short_Integer_Text_IO}
12006 @item Short_Integer
12007 @code{Ada.Short_Integer_Text_IO}
12008 @item Integer
12009 @code{Ada.Integer_Text_IO}
12010 @item Long_Integer
12011 @code{Ada.Long_Integer_Text_IO}
12012 @item Long_Long_Integer
12013 @code{Ada.Long_Long_Integer_Text_IO}
12014 @end table
12015
12016 @item Ada.Text_IO.Modular_IO
12017 Provides input-output facilities for modular (unsigned) types
12018
12019 @item Ada.Text_IO.Complex_IO (G.1.3)
12020 This package provides basic text input-output capabilities for complex
12021 data.
12022
12023 @item Ada.Text_IO.Editing (F.3.3)
12024 This package contains routines for edited output, analogous to the use
12025 of pictures in COBOL@.  The picture formats used by this package are a
12026 close copy of the facility in COBOL@.
12027
12028 @item Ada.Text_IO.Text_Streams (A.12.2)
12029 This package provides a facility that allows Text_IO files to be treated
12030 as streams, so that the stream attributes can be used for writing
12031 arbitrary data, including binary data, to Text_IO files.
12032
12033 @item Ada.Unchecked_Conversion (13.9)
12034 This generic package allows arbitrary conversion from one type to
12035 another of the same size, providing for breaking the type safety in
12036 special circumstances.
12037
12038 If the types have the same Size (more accurately the same Value_Size),
12039 then the effect is simply to transfer the bits from the source to the
12040 target type without any modification.  This usage is well defined, and
12041 for simple types whose representation is typically the same across
12042 all implementations, gives a portable method of performing such
12043 conversions.
12044
12045 If the types do not have the same size, then the result is implementation
12046 defined, and thus may be non-portable.  The following describes how GNAT
12047 handles such unchecked conversion cases.
12048
12049 If the types are of different sizes, and are both discrete types, then
12050 the effect is of a normal type conversion without any constraint checking.
12051 In particular if the result type has a larger size, the result will be
12052 zero or sign extended.  If the result type has a smaller size, the result
12053 will be truncated by ignoring high order bits.
12054
12055 If the types are of different sizes, and are not both discrete types,
12056 then the conversion works as though pointers were created to the source
12057 and target, and the pointer value is converted.  The effect is that bits
12058 are copied from successive low order storage units and bits of the source
12059 up to the length of the target type.
12060
12061 A warning is issued if the lengths differ, since the effect in this
12062 case is implementation dependent, and the above behavior may not match
12063 that of some other compiler.
12064
12065 A pointer to one type may be converted to a pointer to another type using
12066 unchecked conversion.  The only case in which the effect is undefined is
12067 when one or both pointers are pointers to unconstrained array types.  In
12068 this case, the bounds information may get incorrectly transferred, and in
12069 particular, GNAT uses double size pointers for such types, and it is
12070 meaningless to convert between such pointer types.  GNAT will issue a
12071 warning if the alignment of the target designated type is more strict
12072 than the alignment of the source designated type (since the result may
12073 be unaligned in this case).
12074
12075 A pointer other than a pointer to an unconstrained array type may be
12076 converted to and from System.Address.  Such usage is common in Ada 83
12077 programs, but note that Ada.Address_To_Access_Conversions is the
12078 preferred method of performing such conversions in Ada 95 and Ada 2005.
12079 Neither
12080 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12081 used in conjunction with pointers to unconstrained objects, since
12082 the bounds information cannot be handled correctly in this case.
12083
12084 @item Ada.Unchecked_Deallocation (13.11.2)
12085 This generic package allows explicit freeing of storage previously
12086 allocated by use of an allocator.
12087
12088 @item Ada.Wide_Text_IO (A.11)
12089 This package is similar to @code{Ada.Text_IO}, except that the external
12090 file supports wide character representations, and the internal types are
12091 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12092 and @code{String}.  It contains generic subpackages listed next.
12093
12094 @item Ada.Wide_Text_IO.Decimal_IO
12095 Provides input-output facilities for decimal fixed-point types
12096
12097 @item Ada.Wide_Text_IO.Enumeration_IO
12098 Provides input-output facilities for enumeration types.
12099
12100 @item Ada.Wide_Text_IO.Fixed_IO
12101 Provides input-output facilities for ordinary fixed-point types.
12102
12103 @item Ada.Wide_Text_IO.Float_IO
12104 Provides input-output facilities for float types.  The following
12105 predefined instantiations of this generic package are available:
12106
12107 @table @code
12108 @item Short_Float
12109 @code{Short_Float_Wide_Text_IO}
12110 @item Float
12111 @code{Float_Wide_Text_IO}
12112 @item Long_Float
12113 @code{Long_Float_Wide_Text_IO}
12114 @end table
12115
12116 @item Ada.Wide_Text_IO.Integer_IO
12117 Provides input-output facilities for integer types.  The following
12118 predefined instantiations of this generic package are available:
12119
12120 @table @code
12121 @item Short_Short_Integer
12122 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12123 @item Short_Integer
12124 @code{Ada.Short_Integer_Wide_Text_IO}
12125 @item Integer
12126 @code{Ada.Integer_Wide_Text_IO}
12127 @item Long_Integer
12128 @code{Ada.Long_Integer_Wide_Text_IO}
12129 @item Long_Long_Integer
12130 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12131 @end table
12132
12133 @item Ada.Wide_Text_IO.Modular_IO
12134 Provides input-output facilities for modular (unsigned) types
12135
12136 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12137 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12138 external file supports wide character representations.
12139
12140 @item Ada.Wide_Text_IO.Editing (F.3.4)
12141 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12142 types are @code{Wide_Character} and @code{Wide_String} instead of
12143 @code{Character} and @code{String}.
12144
12145 @item Ada.Wide_Text_IO.Streams (A.12.3)
12146 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12147 types are @code{Wide_Character} and @code{Wide_String} instead of
12148 @code{Character} and @code{String}.
12149
12150 @item Ada.Wide_Wide_Text_IO (A.11)
12151 This package is similar to @code{Ada.Text_IO}, except that the external
12152 file supports wide character representations, and the internal types are
12153 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12154 and @code{String}.  It contains generic subpackages listed next.
12155
12156 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12157 Provides input-output facilities for decimal fixed-point types
12158
12159 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12160 Provides input-output facilities for enumeration types.
12161
12162 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12163 Provides input-output facilities for ordinary fixed-point types.
12164
12165 @item Ada.Wide_Wide_Text_IO.Float_IO
12166 Provides input-output facilities for float types.  The following
12167 predefined instantiations of this generic package are available:
12168
12169 @table @code
12170 @item Short_Float
12171 @code{Short_Float_Wide_Wide_Text_IO}
12172 @item Float
12173 @code{Float_Wide_Wide_Text_IO}
12174 @item Long_Float
12175 @code{Long_Float_Wide_Wide_Text_IO}
12176 @end table
12177
12178 @item Ada.Wide_Wide_Text_IO.Integer_IO
12179 Provides input-output facilities for integer types.  The following
12180 predefined instantiations of this generic package are available:
12181
12182 @table @code
12183 @item Short_Short_Integer
12184 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12185 @item Short_Integer
12186 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12187 @item Integer
12188 @code{Ada.Integer_Wide_Wide_Text_IO}
12189 @item Long_Integer
12190 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12191 @item Long_Long_Integer
12192 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12193 @end table
12194
12195 @item Ada.Wide_Wide_Text_IO.Modular_IO
12196 Provides input-output facilities for modular (unsigned) types
12197
12198 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12199 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12200 external file supports wide character representations.
12201
12202 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12203 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12204 types are @code{Wide_Character} and @code{Wide_String} instead of
12205 @code{Character} and @code{String}.
12206
12207 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12208 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12209 types are @code{Wide_Character} and @code{Wide_String} instead of
12210 @code{Character} and @code{String}.
12211 @end table
12212
12213
12214
12215 @node The Implementation of Standard I/O
12216 @chapter The Implementation of Standard I/O
12217
12218 @noindent
12219 GNAT implements all the required input-output facilities described in
12220 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12221 required behavior of these packages from the Ada point of view, and if
12222 you are writing a portable Ada program that does not need to know the
12223 exact manner in which Ada maps to the outside world when it comes to
12224 reading or writing external files, then you do not need to read this
12225 chapter.  As long as your files are all regular files (not pipes or
12226 devices), and as long as you write and read the files only from Ada, the
12227 description in the Ada Reference Manual is sufficient.
12228
12229 However, if you want to do input-output to pipes or other devices, such
12230 as the keyboard or screen, or if the files you are dealing with are
12231 either generated by some other language, or to be read by some other
12232 language, then you need to know more about the details of how the GNAT
12233 implementation of these input-output facilities behaves.
12234
12235 In this chapter we give a detailed description of exactly how GNAT
12236 interfaces to the file system.  As always, the sources of the system are
12237 available to you for answering questions at an even more detailed level,
12238 but for most purposes the information in this chapter will suffice.
12239
12240 Another reason that you may need to know more about how input-output is
12241 implemented arises when you have a program written in mixed languages
12242 where, for example, files are shared between the C and Ada sections of
12243 the same program.  GNAT provides some additional facilities, in the form
12244 of additional child library packages, that facilitate this sharing, and
12245 these additional facilities are also described in this chapter.
12246
12247 @menu
12248 * Standard I/O Packages::
12249 * FORM Strings::
12250 * Direct_IO::
12251 * Sequential_IO::
12252 * Text_IO::
12253 * Wide_Text_IO::
12254 * Wide_Wide_Text_IO::
12255 * Stream_IO::
12256 * Text Translation::
12257 * Shared Files::
12258 * Filenames encoding::
12259 * Open Modes::
12260 * Operations on C Streams::
12261 * Interfacing to C Streams::
12262 @end menu
12263
12264 @node Standard I/O Packages
12265 @section Standard I/O Packages
12266
12267 @noindent
12268 The Standard I/O packages described in Annex A for
12269
12270 @itemize @bullet
12271 @item
12272 Ada.Text_IO
12273 @item
12274 Ada.Text_IO.Complex_IO
12275 @item
12276 Ada.Text_IO.Text_Streams
12277 @item
12278 Ada.Wide_Text_IO
12279 @item
12280 Ada.Wide_Text_IO.Complex_IO
12281 @item
12282 Ada.Wide_Text_IO.Text_Streams
12283 @item
12284 Ada.Wide_Wide_Text_IO
12285 @item
12286 Ada.Wide_Wide_Text_IO.Complex_IO
12287 @item
12288 Ada.Wide_Wide_Text_IO.Text_Streams
12289 @item
12290 Ada.Stream_IO
12291 @item
12292 Ada.Sequential_IO
12293 @item
12294 Ada.Direct_IO
12295 @end itemize
12296
12297 @noindent
12298 are implemented using the C
12299 library streams facility; where
12300
12301 @itemize @bullet
12302 @item
12303 All files are opened using @code{fopen}.
12304 @item
12305 All input/output operations use @code{fread}/@code{fwrite}.
12306 @end itemize
12307
12308 @noindent
12309 There is no internal buffering of any kind at the Ada library level. The only
12310 buffering is that provided at the system level in the implementation of the
12311 library routines that support streams. This facilitates shared use of these
12312 streams by mixed language programs. Note though that system level buffering is
12313 explicitly enabled at elaboration of the standard I/O packages and that can
12314 have an impact on mixed language programs, in particular those using I/O before
12315 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12316 the Ada elaboration routine before performing any I/O or when impractical,
12317 flush the common I/O streams and in particular Standard_Output before
12318 elaborating the Ada code.
12319
12320 @node FORM Strings
12321 @section FORM Strings
12322
12323 @noindent
12324 The format of a FORM string in GNAT is:
12325
12326 @smallexample
12327 "keyword=value,keyword=value,@dots{},keyword=value"
12328 @end smallexample
12329
12330 @noindent
12331 where letters may be in upper or lower case, and there are no spaces
12332 between values.  The order of the entries is not important.  Currently
12333 the following keywords defined.
12334
12335 @smallexample
12336 TEXT_TRANSLATION=[YES|NO]
12337 SHARED=[YES|NO]
12338 WCEM=[n|h|u|s|e|8|b]
12339 ENCODING=[UTF8|8BITS]
12340 @end smallexample
12341
12342 @noindent
12343 The use of these parameters is described later in this section.
12344
12345 @node Direct_IO
12346 @section Direct_IO
12347
12348 @noindent
12349 Direct_IO can only be instantiated for definite types.  This is a
12350 restriction of the Ada language, which means that the records are fixed
12351 length (the length being determined by @code{@var{type}'Size}, rounded
12352 up to the next storage unit boundary if necessary).
12353
12354 The records of a Direct_IO file are simply written to the file in index
12355 sequence, with the first record starting at offset zero, and subsequent
12356 records following.  There is no control information of any kind.  For
12357 example, if 32-bit integers are being written, each record takes
12358 4-bytes, so the record at index @var{K} starts at offset
12359 (@var{K}@minus{}1)*4.
12360
12361 There is no limit on the size of Direct_IO files, they are expanded as
12362 necessary to accommodate whatever records are written to the file.
12363
12364 @node Sequential_IO
12365 @section Sequential_IO
12366
12367 @noindent
12368 Sequential_IO may be instantiated with either a definite (constrained)
12369 or indefinite (unconstrained) type.
12370
12371 For the definite type case, the elements written to the file are simply
12372 the memory images of the data values with no control information of any
12373 kind.  The resulting file should be read using the same type, no validity
12374 checking is performed on input.
12375
12376 For the indefinite type case, the elements written consist of two
12377 parts.  First is the size of the data item, written as the memory image
12378 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12379 the data value.  The resulting file can only be read using the same
12380 (unconstrained) type.  Normal assignment checks are performed on these
12381 read operations, and if these checks fail, @code{Data_Error} is
12382 raised.  In particular, in the array case, the lengths must match, and in
12383 the variant record case, if the variable for a particular read operation
12384 is constrained, the discriminants must match.
12385
12386 Note that it is not possible to use Sequential_IO to write variable
12387 length array items, and then read the data back into different length
12388 arrays.  For example, the following will raise @code{Data_Error}:
12389
12390 @smallexample @c ada
12391  package IO is new Sequential_IO (String);
12392  F : IO.File_Type;
12393  S : String (1..4);
12394  @dots{}
12395  IO.Create (F)
12396  IO.Write (F, "hello!")
12397  IO.Reset (F, Mode=>In_File);
12398  IO.Read (F, S);
12399  Put_Line (S);
12400
12401 @end smallexample
12402
12403 @noindent
12404 On some Ada implementations, this will print @code{hell}, but the program is
12405 clearly incorrect, since there is only one element in the file, and that
12406 element is the string @code{hello!}.
12407
12408 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12409 using Stream_IO, and this is the preferred mechanism.  In particular, the
12410 above program fragment rewritten to use Stream_IO will work correctly.
12411
12412 @node Text_IO
12413 @section Text_IO
12414
12415 @noindent
12416 Text_IO files consist of a stream of characters containing the following
12417 special control characters:
12418
12419 @smallexample
12420 LF (line feed, 16#0A#) Line Mark
12421 FF (form feed, 16#0C#) Page Mark
12422 @end smallexample
12423
12424 @noindent
12425 A canonical Text_IO file is defined as one in which the following
12426 conditions are met:
12427
12428 @itemize @bullet
12429 @item
12430 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12431 of the line.
12432
12433 @item
12434 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12435 end of a page and consequently can appear only immediately following a
12436 @code{LF} (line mark) character.
12437
12438 @item
12439 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12440 (line mark, page mark).  In the former case, the page mark is implicitly
12441 assumed to be present.
12442 @end itemize
12443
12444 @noindent
12445 A file written using Text_IO will be in canonical form provided that no
12446 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12447 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12448 the file unless an explicit @code{New_Page} operation was performed
12449 before closing the file.
12450
12451 A canonical Text_IO file that is a regular file (i.e., not a device or a
12452 pipe) can be read using any of the routines in Text_IO@.  The
12453 semantics in this case will be exactly as defined in the Ada Reference
12454 Manual, and all the routines in Text_IO are fully implemented.
12455
12456 A text file that does not meet the requirements for a canonical Text_IO
12457 file has one of the following:
12458
12459 @itemize @bullet
12460 @item
12461 The file contains @code{FF} characters not immediately following a
12462 @code{LF} character.
12463
12464 @item
12465 The file contains @code{LF} or @code{FF} characters written by
12466 @code{Put} or @code{Put_Line}, which are not logically considered to be
12467 line marks or page marks.
12468
12469 @item
12470 The file ends in a character other than @code{LF} or @code{FF},
12471 i.e.@: there is no explicit line mark or page mark at the end of the file.
12472 @end itemize
12473
12474 @noindent
12475 Text_IO can be used to read such non-standard text files but subprograms
12476 to do with line or page numbers do not have defined meanings.  In
12477 particular, a @code{FF} character that does not follow a @code{LF}
12478 character may or may not be treated as a page mark from the point of
12479 view of page and line numbering.  Every @code{LF} character is considered
12480 to end a line, and there is an implied @code{LF} character at the end of
12481 the file.
12482
12483 @menu
12484 * Text_IO Stream Pointer Positioning::
12485 * Text_IO Reading and Writing Non-Regular Files::
12486 * Get_Immediate::
12487 * Treating Text_IO Files as Streams::
12488 * Text_IO Extensions::
12489 * Text_IO Facilities for Unbounded Strings::
12490 @end menu
12491
12492 @node Text_IO Stream Pointer Positioning
12493 @subsection Stream Pointer Positioning
12494
12495 @noindent
12496 @code{Ada.Text_IO} has a definition of current position for a file that
12497 is being read.  No internal buffering occurs in Text_IO, and usually the
12498 physical position in the stream used to implement the file corresponds
12499 to this logical position defined by Text_IO@.  There are two exceptions:
12500
12501 @itemize @bullet
12502 @item
12503 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12504 is positioned past the @code{LF} (line mark) that precedes the page
12505 mark.  Text_IO maintains an internal flag so that subsequent read
12506 operations properly handle the logical position which is unchanged by
12507 the @code{End_Of_Page} call.
12508
12509 @item
12510 After a call to @code{End_Of_File} that returns @code{True}, if the
12511 Text_IO file was positioned before the line mark at the end of file
12512 before the call, then the logical position is unchanged, but the stream
12513 is physically positioned right at the end of file (past the line mark,
12514 and past a possible page mark following the line mark.  Again Text_IO
12515 maintains internal flags so that subsequent read operations properly
12516 handle the logical position.
12517 @end itemize
12518
12519 @noindent
12520 These discrepancies have no effect on the observable behavior of
12521 Text_IO, but if a single Ada stream is shared between a C program and
12522 Ada program, or shared (using @samp{shared=yes} in the form string)
12523 between two Ada files, then the difference may be observable in some
12524 situations.
12525
12526 @node Text_IO Reading and Writing Non-Regular Files
12527 @subsection Reading and Writing Non-Regular Files
12528
12529 @noindent
12530 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12531 can be used for reading and writing.  Writing is not affected and the
12532 sequence of characters output is identical to the normal file case, but
12533 for reading, the behavior of Text_IO is modified to avoid undesirable
12534 look-ahead as follows:
12535
12536 An input file that is not a regular file is considered to have no page
12537 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12538 page mark) appearing in the file are considered to be data
12539 characters.  In particular:
12540
12541 @itemize @bullet
12542 @item
12543 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12544 following a line mark.  If a page mark appears, it will be treated as a
12545 data character.
12546
12547 @item
12548 This avoids the need to wait for an extra character to be typed or
12549 entered from the pipe to complete one of these operations.
12550
12551 @item
12552 @code{End_Of_Page} always returns @code{False}
12553
12554 @item
12555 @code{End_Of_File} will return @code{False} if there is a page mark at
12556 the end of the file.
12557 @end itemize
12558
12559 @noindent
12560 Output to non-regular files is the same as for regular files.  Page marks
12561 may be written to non-regular files using @code{New_Page}, but as noted
12562 above they will not be treated as page marks on input if the output is
12563 piped to another Ada program.
12564
12565 Another important discrepancy when reading non-regular files is that the end
12566 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12567 pressing the @key{EOT} key,
12568 then end of file
12569 is signaled once (i.e.@: the test @code{End_Of_File}
12570 will yield @code{True}, or a read will
12571 raise @code{End_Error}), but then reading can resume
12572 to read data past that end of
12573 file indication, until another end of file indication is entered.
12574
12575 @node Get_Immediate
12576 @subsection Get_Immediate
12577 @cindex Get_Immediate
12578
12579 @noindent
12580 Get_Immediate returns the next character (including control characters)
12581 from the input file.  In particular, Get_Immediate will return LF or FF
12582 characters used as line marks or page marks.  Such operations leave the
12583 file positioned past the control character, and it is thus not treated
12584 as having its normal function.  This means that page, line and column
12585 counts after this kind of Get_Immediate call are set as though the mark
12586 did not occur.  In the case where a Get_Immediate leaves the file
12587 positioned between the line mark and page mark (which is not normally
12588 possible), it is undefined whether the FF character will be treated as a
12589 page mark.
12590
12591 @node Treating Text_IO Files as Streams
12592 @subsection Treating Text_IO Files as Streams
12593 @cindex Stream files
12594
12595 @noindent
12596 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12597 as a stream.  Data written to a Text_IO file in this stream mode is
12598 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12599 16#0C# (@code{FF}), the resulting file may have non-standard
12600 format.  Similarly if read operations are used to read from a Text_IO
12601 file treated as a stream, then @code{LF} and @code{FF} characters may be
12602 skipped and the effect is similar to that described above for
12603 @code{Get_Immediate}.
12604
12605 @node Text_IO Extensions
12606 @subsection Text_IO Extensions
12607 @cindex Text_IO extensions
12608
12609 @noindent
12610 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12611 to the standard @code{Text_IO} package:
12612
12613 @itemize @bullet
12614 @item function File_Exists (Name : String) return Boolean;
12615 Determines if a file of the given name exists.
12616
12617 @item function Get_Line return String;
12618 Reads a string from the standard input file.  The value returned is exactly
12619 the length of the line that was read.
12620
12621 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12622 Similar, except that the parameter File specifies the file from which
12623 the string is to be read.
12624
12625 @end itemize
12626
12627 @node Text_IO Facilities for Unbounded Strings
12628 @subsection Text_IO Facilities for Unbounded Strings
12629 @cindex Text_IO for unbounded strings
12630 @cindex Unbounded_String, Text_IO operations
12631
12632 @noindent
12633 The package @code{Ada.Strings.Unbounded.Text_IO}
12634 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12635 subprograms useful for Text_IO operations on unbounded strings:
12636
12637 @itemize @bullet
12638
12639 @item function Get_Line (File : File_Type) return Unbounded_String;
12640 Reads a line from the specified file
12641 and returns the result as an unbounded string.
12642
12643 @item procedure Put (File : File_Type; U : Unbounded_String);
12644 Writes the value of the given unbounded string to the specified file
12645 Similar to the effect of
12646 @code{Put (To_String (U))} except that an extra copy is avoided.
12647
12648 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12649 Writes the value of the given unbounded string to the specified file,
12650 followed by a @code{New_Line}.
12651 Similar to the effect of @code{Put_Line (To_String (U))} except
12652 that an extra copy is avoided.
12653 @end itemize
12654
12655 @noindent
12656 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12657 and is optional.  If the parameter is omitted, then the standard input or
12658 output file is referenced as appropriate.
12659
12660 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12661 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12662 @code{Wide_Text_IO} functionality for unbounded wide strings.
12663
12664 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12665 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12666 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12667
12668 @node Wide_Text_IO
12669 @section Wide_Text_IO
12670
12671 @noindent
12672 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12673 both input and output files may contain special sequences that represent
12674 wide character values.  The encoding scheme for a given file may be
12675 specified using a FORM parameter:
12676
12677 @smallexample
12678 WCEM=@var{x}
12679 @end smallexample
12680
12681 @noindent
12682 as part of the FORM string (WCEM = wide character encoding method),
12683 where @var{x} is one of the following characters
12684
12685 @table @samp
12686 @item h
12687 Hex ESC encoding
12688 @item u
12689 Upper half encoding
12690 @item s
12691 Shift-JIS encoding
12692 @item e
12693 EUC Encoding
12694 @item 8
12695 UTF-8 encoding
12696 @item b
12697 Brackets encoding
12698 @end table
12699
12700 @noindent
12701 The encoding methods match those that
12702 can be used in a source
12703 program, but there is no requirement that the encoding method used for
12704 the source program be the same as the encoding method used for files,
12705 and different files may use different encoding methods.
12706
12707 The default encoding method for the standard files, and for opened files
12708 for which no WCEM parameter is given in the FORM string matches the
12709 wide character encoding specified for the main program (the default
12710 being brackets encoding if no coding method was specified with -gnatW).
12711
12712 @table @asis
12713 @item Hex Coding
12714 In this encoding, a wide character is represented by a five character
12715 sequence:
12716
12717 @smallexample
12718 ESC a b c d
12719 @end smallexample
12720
12721 @noindent
12722 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12723 characters (using upper case letters) of the wide character code.  For
12724 example, ESC A345 is used to represent the wide character with code
12725 16#A345#.  This scheme is compatible with use of the full
12726 @code{Wide_Character} set.
12727
12728 @item Upper Half Coding
12729 The wide character with encoding 16#abcd#, where the upper bit is on
12730 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12731 16#cd#.  The second byte may never be a format control character, but is
12732 not required to be in the upper half.  This method can be also used for
12733 shift-JIS or EUC where the internal coding matches the external coding.
12734
12735 @item Shift JIS Coding
12736 A wide character is represented by a two character sequence 16#ab# and
12737 16#cd#, with the restrictions described for upper half encoding as
12738 described above.  The internal character code is the corresponding JIS
12739 character according to the standard algorithm for Shift-JIS
12740 conversion.  Only characters defined in the JIS code set table can be
12741 used with this encoding method.
12742
12743 @item EUC Coding
12744 A wide character is represented by a two character sequence 16#ab# and
12745 16#cd#, with both characters being in the upper half.  The internal
12746 character code is the corresponding JIS character according to the EUC
12747 encoding algorithm.  Only characters defined in the JIS code set table
12748 can be used with this encoding method.
12749
12750 @item UTF-8 Coding
12751 A wide character is represented using
12752 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12753 10646-1/Am.2.  Depending on the character value, the representation
12754 is a one, two, or three byte sequence:
12755
12756 @smallexample
12757 16#0000#-16#007f#: 2#0xxxxxxx#
12758 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12759 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12760 @end smallexample
12761
12762 @noindent
12763 where the @var{xxx} bits correspond to the left-padded bits of the
12764 16-bit character value.  Note that all lower half ASCII characters
12765 are represented as ASCII bytes and all upper half characters and
12766 other wide characters are represented as sequences of upper-half
12767 (The full UTF-8 scheme allows for encoding 31-bit characters as
12768 6-byte sequences, but in this implementation, all UTF-8 sequences
12769 of four or more bytes length will raise a Constraint_Error, as
12770 will all invalid UTF-8 sequences.)
12771
12772 @item Brackets Coding
12773 In this encoding, a wide character is represented by the following eight
12774 character sequence:
12775
12776 @smallexample
12777 [ " a b c d " ]
12778 @end smallexample
12779
12780 @noindent
12781 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12782 characters (using uppercase letters) of the wide character code.  For
12783 example, @code{["A345"]} is used to represent the wide character with code
12784 @code{16#A345#}.
12785 This scheme is compatible with use of the full Wide_Character set.
12786 On input, brackets coding can also be used for upper half characters,
12787 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12788 is only used for wide characters with a code greater than @code{16#FF#}.
12789
12790 Note that brackets coding is not normally used in the context of
12791 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12792 a portable way of encoding source files. In the context of Wide_Text_IO
12793 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12794 any instance of the left bracket character other than to encode wide
12795 character values using the brackets encoding method. In practice it is
12796 expected that some standard wide character encoding method such
12797 as UTF-8 will be used for text input output.
12798
12799 If brackets notation is used, then any occurrence of a left bracket
12800 in the input file which is not the start of a valid wide character
12801 sequence will cause Constraint_Error to be raised. It is possible to
12802 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12803 input will interpret this as a left bracket.
12804
12805 However, when a left bracket is output, it will be output as a left bracket
12806 and not as ["5B"]. We make this decision because for normal use of
12807 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12808 brackets. For example, if we write:
12809
12810 @smallexample
12811    Put_Line ("Start of output [first run]");
12812 @end smallexample
12813
12814 @noindent
12815 we really do not want to have the left bracket in this message clobbered so
12816 that the output reads:
12817
12818 @smallexample
12819    Start of output ["5B"]first run]
12820 @end smallexample
12821
12822 @noindent
12823 In practice brackets encoding is reasonably useful for normal Put_Line use
12824 since we won't get confused between left brackets and wide character
12825 sequences in the output. But for input, or when files are written out
12826 and read back in, it really makes better sense to use one of the standard
12827 encoding methods such as UTF-8.
12828
12829 @end table
12830
12831 @noindent
12832 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12833 not all wide character
12834 values can be represented.  An attempt to output a character that cannot
12835 be represented using the encoding scheme for the file causes
12836 Constraint_Error to be raised.  An invalid wide character sequence on
12837 input also causes Constraint_Error to be raised.
12838
12839 @menu
12840 * Wide_Text_IO Stream Pointer Positioning::
12841 * Wide_Text_IO Reading and Writing Non-Regular Files::
12842 @end menu
12843
12844 @node Wide_Text_IO Stream Pointer Positioning
12845 @subsection Stream Pointer Positioning
12846
12847 @noindent
12848 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12849 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12850 case:
12851
12852 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12853 normal lower ASCII set (i.e.@: a character in the range:
12854
12855 @smallexample @c ada
12856 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12857 @end smallexample
12858
12859 @noindent
12860 then although the logical position of the file pointer is unchanged by
12861 the @code{Look_Ahead} call, the stream is physically positioned past the
12862 wide character sequence.  Again this is to avoid the need for buffering
12863 or backup, and all @code{Wide_Text_IO} routines check the internal
12864 indication that this situation has occurred so that this is not visible
12865 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12866 can be observed if the wide text file shares a stream with another file.
12867
12868 @node Wide_Text_IO Reading and Writing Non-Regular Files
12869 @subsection Reading and Writing Non-Regular Files
12870
12871 @noindent
12872 As in the case of Text_IO, when a non-regular file is read, it is
12873 assumed that the file contains no page marks (any form characters are
12874 treated as data characters), and @code{End_Of_Page} always returns
12875 @code{False}.  Similarly, the end of file indication is not sticky, so
12876 it is possible to read beyond an end of file.
12877
12878 @node Wide_Wide_Text_IO
12879 @section Wide_Wide_Text_IO
12880
12881 @noindent
12882 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12883 both input and output files may contain special sequences that represent
12884 wide wide character values.  The encoding scheme for a given file may be
12885 specified using a FORM parameter:
12886
12887 @smallexample
12888 WCEM=@var{x}
12889 @end smallexample
12890
12891 @noindent
12892 as part of the FORM string (WCEM = wide character encoding method),
12893 where @var{x} is one of the following characters
12894
12895 @table @samp
12896 @item h
12897 Hex ESC encoding
12898 @item u
12899 Upper half encoding
12900 @item s
12901 Shift-JIS encoding
12902 @item e
12903 EUC Encoding
12904 @item 8
12905 UTF-8 encoding
12906 @item b
12907 Brackets encoding
12908 @end table
12909
12910 @noindent
12911 The encoding methods match those that
12912 can be used in a source
12913 program, but there is no requirement that the encoding method used for
12914 the source program be the same as the encoding method used for files,
12915 and different files may use different encoding methods.
12916
12917 The default encoding method for the standard files, and for opened files
12918 for which no WCEM parameter is given in the FORM string matches the
12919 wide character encoding specified for the main program (the default
12920 being brackets encoding if no coding method was specified with -gnatW).
12921
12922 @table @asis
12923
12924 @item UTF-8 Coding
12925 A wide character is represented using
12926 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12927 10646-1/Am.2.  Depending on the character value, the representation
12928 is a one, two, three, or four byte sequence:
12929
12930 @smallexample
12931 16#000000#-16#00007f#: 2#0xxxxxxx#
12932 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12933 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12934 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12935 @end smallexample
12936
12937 @noindent
12938 where the @var{xxx} bits correspond to the left-padded bits of the
12939 21-bit character value.  Note that all lower half ASCII characters
12940 are represented as ASCII bytes and all upper half characters and
12941 other wide characters are represented as sequences of upper-half
12942 characters.
12943
12944 @item Brackets Coding
12945 In this encoding, a wide wide character is represented by the following eight
12946 character sequence if is in wide character range
12947
12948 @smallexample
12949 [ " a b c d " ]
12950 @end smallexample
12951
12952 and by the following ten character sequence if not
12953
12954 @smallexample
12955 [ " a b c d e f " ]
12956 @end smallexample
12957
12958 @noindent
12959 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12960 are the four or six hexadecimal
12961 characters (using uppercase letters) of the wide wide character code.  For
12962 example, @code{["01A345"]} is used to represent the wide wide character
12963 with code @code{16#01A345#}.
12964
12965 This scheme is compatible with use of the full Wide_Wide_Character set.
12966 On input, brackets coding can also be used for upper half characters,
12967 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12968 is only used for wide characters with a code greater than @code{16#FF#}.
12969
12970 @end table
12971
12972 @noindent
12973 If is also possible to use the other Wide_Character encoding methods,
12974 such as Shift-JIS, but the other schemes cannot support the full range
12975 of wide wide characters.
12976 An attempt to output a character that cannot
12977 be represented using the encoding scheme for the file causes
12978 Constraint_Error to be raised.  An invalid wide character sequence on
12979 input also causes Constraint_Error to be raised.
12980
12981 @menu
12982 * Wide_Wide_Text_IO Stream Pointer Positioning::
12983 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12984 @end menu
12985
12986 @node Wide_Wide_Text_IO Stream Pointer Positioning
12987 @subsection Stream Pointer Positioning
12988
12989 @noindent
12990 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12991 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12992 case:
12993
12994 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12995 normal lower ASCII set (i.e.@: a character in the range:
12996
12997 @smallexample @c ada
12998 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12999 @end smallexample
13000
13001 @noindent
13002 then although the logical position of the file pointer is unchanged by
13003 the @code{Look_Ahead} call, the stream is physically positioned past the
13004 wide character sequence.  Again this is to avoid the need for buffering
13005 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13006 indication that this situation has occurred so that this is not visible
13007 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13008 can be observed if the wide text file shares a stream with another file.
13009
13010 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13011 @subsection Reading and Writing Non-Regular Files
13012
13013 @noindent
13014 As in the case of Text_IO, when a non-regular file is read, it is
13015 assumed that the file contains no page marks (any form characters are
13016 treated as data characters), and @code{End_Of_Page} always returns
13017 @code{False}.  Similarly, the end of file indication is not sticky, so
13018 it is possible to read beyond an end of file.
13019
13020 @node Stream_IO
13021 @section Stream_IO
13022
13023 @noindent
13024 A stream file is a sequence of bytes, where individual elements are
13025 written to the file as described in the Ada Reference Manual.  The type
13026 @code{Stream_Element} is simply a byte.  There are two ways to read or
13027 write a stream file.
13028
13029 @itemize @bullet
13030 @item
13031 The operations @code{Read} and @code{Write} directly read or write a
13032 sequence of stream elements with no control information.
13033
13034 @item
13035 The stream attributes applied to a stream file transfer data in the
13036 manner described for stream attributes.
13037 @end itemize
13038
13039 @node Text Translation
13040 @section Text Translation
13041
13042 @noindent
13043 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13044 passed to Text_IO.Create and Text_IO.Open:
13045 @samp{Text_Translation=@var{Yes}} is the default, which means to
13046 translate LF to/from CR/LF on Windows systems.
13047 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13048 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13049 may be used to create Unix-style files on
13050 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13051 systems.
13052
13053 @node Shared Files
13054 @section Shared Files
13055
13056 @noindent
13057 Section A.14 of the Ada Reference Manual allows implementations to
13058 provide a wide variety of behavior if an attempt is made to access the
13059 same external file with two or more internal files.
13060
13061 To provide a full range of functionality, while at the same time
13062 minimizing the problems of portability caused by this implementation
13063 dependence, GNAT handles file sharing as follows:
13064
13065 @itemize @bullet
13066 @item
13067 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13068 to open two or more files with the same full name is considered an error
13069 and is not supported.  The exception @code{Use_Error} will be
13070 raised.  Note that a file that is not explicitly closed by the program
13071 remains open until the program terminates.
13072
13073 @item
13074 If the form parameter @samp{shared=no} appears in the form string, the
13075 file can be opened or created with its own separate stream identifier,
13076 regardless of whether other files sharing the same external file are
13077 opened.  The exact effect depends on how the C stream routines handle
13078 multiple accesses to the same external files using separate streams.
13079
13080 @item
13081 If the form parameter @samp{shared=yes} appears in the form string for
13082 each of two or more files opened using the same full name, the same
13083 stream is shared between these files, and the semantics are as described
13084 in Ada Reference Manual, Section A.14.
13085 @end itemize
13086
13087 @noindent
13088 When a program that opens multiple files with the same name is ported
13089 from another Ada compiler to GNAT, the effect will be that
13090 @code{Use_Error} is raised.
13091
13092 The documentation of the original compiler and the documentation of the
13093 program should then be examined to determine if file sharing was
13094 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13095 and @code{Create} calls as required.
13096
13097 When a program is ported from GNAT to some other Ada compiler, no
13098 special attention is required unless the @samp{shared=@var{xxx}} form
13099 parameter is used in the program.  In this case, you must examine the
13100 documentation of the new compiler to see if it supports the required
13101 file sharing semantics, and form strings modified appropriately.  Of
13102 course it may be the case that the program cannot be ported if the
13103 target compiler does not support the required functionality.  The best
13104 approach in writing portable code is to avoid file sharing (and hence
13105 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13106 completely.
13107
13108 One common use of file sharing in Ada 83 is the use of instantiations of
13109 Sequential_IO on the same file with different types, to achieve
13110 heterogeneous input-output.  Although this approach will work in GNAT if
13111 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13112 for this purpose (using the stream attributes)
13113
13114 @node Filenames encoding
13115 @section Filenames encoding
13116
13117 @noindent
13118 An encoding form parameter can be used to specify the filename
13119 encoding @samp{encoding=@var{xxx}}.
13120
13121 @itemize @bullet
13122 @item
13123 If the form parameter @samp{encoding=utf8} appears in the form string, the
13124 filename must be encoded in UTF-8.
13125
13126 @item
13127 If the form parameter @samp{encoding=8bits} appears in the form
13128 string, the filename must be a standard 8bits string.
13129 @end itemize
13130
13131 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13132 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13133 variable. And if not set @samp{utf8} is assumed.
13134
13135 @table @samp
13136 @item CP_ACP
13137 The current system Windows ANSI code page.
13138 @item CP_UTF8
13139 UTF-8 encoding
13140 @end table
13141
13142 This encoding form parameter is only supported on the Windows
13143 platform. On the other Operating Systems the run-time is supporting
13144 UTF-8 natively.
13145
13146 @node Open Modes
13147 @section Open Modes
13148
13149 @noindent
13150 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13151 using the mode shown in the following table:
13152
13153 @sp 2
13154 @center @code{Open} and @code{Create} Call Modes
13155 @smallexample
13156                                @b{OPEN }           @b{CREATE}
13157 Append_File                    "r+"             "w+"
13158 In_File                        "r"              "w+"
13159 Out_File (Direct_IO)           "r+"             "w"
13160 Out_File (all other cases)     "w"              "w"
13161 Inout_File                     "r+"             "w+"
13162 @end smallexample
13163
13164 @noindent
13165 If text file translation is required, then either @samp{b} or @samp{t}
13166 is added to the mode, depending on the setting of Text.  Text file
13167 translation refers to the mapping of CR/LF sequences in an external file
13168 to LF characters internally.  This mapping only occurs in DOS and
13169 DOS-like systems, and is not relevant to other systems.
13170
13171 A special case occurs with Stream_IO@.  As shown in the above table, the
13172 file is initially opened in @samp{r} or @samp{w} mode for the
13173 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13174 subsequently requires switching from reading to writing or vice-versa,
13175 then the file is reopened in @samp{r+} mode to permit the required operation.
13176
13177 @node Operations on C Streams
13178 @section Operations on C Streams
13179 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13180 access to the C library functions for operations on C streams:
13181
13182 @smallexample @c adanocomment
13183 package Interfaces.C_Streams is
13184   -- Note: the reason we do not use the types that are in
13185   -- Interfaces.C is that we want to avoid dragging in the
13186   -- code in this unit if possible.
13187   subtype chars is System.Address;
13188   -- Pointer to null-terminated array of characters
13189   subtype FILEs is System.Address;
13190   -- Corresponds to the C type FILE*
13191   subtype voids is System.Address;
13192   -- Corresponds to the C type void*
13193   subtype int is Integer;
13194   subtype long is Long_Integer;
13195   -- Note: the above types are subtypes deliberately, and it
13196   -- is part of this spec that the above correspondences are
13197   -- guaranteed.  This means that it is legitimate to, for
13198   -- example, use Integer instead of int.  We provide these
13199   -- synonyms for clarity, but in some cases it may be
13200   -- convenient to use the underlying types (for example to
13201   -- avoid an unnecessary dependency of a spec on the spec
13202   -- of this unit).
13203   type size_t is mod 2 ** Standard'Address_Size;
13204   NULL_Stream : constant FILEs;
13205   -- Value returned (NULL in C) to indicate an
13206   -- fdopen/fopen/tmpfile error
13207   ----------------------------------
13208   -- Constants Defined in stdio.h --
13209   ----------------------------------
13210   EOF : constant int;
13211   -- Used by a number of routines to indicate error or
13212   -- end of file
13213   IOFBF : constant int;
13214   IOLBF : constant int;
13215   IONBF : constant int;
13216   -- Used to indicate buffering mode for setvbuf call
13217   SEEK_CUR : constant int;
13218   SEEK_END : constant int;
13219   SEEK_SET : constant int;
13220   -- Used to indicate origin for fseek call
13221   function stdin return FILEs;
13222   function stdout return FILEs;
13223   function stderr return FILEs;
13224   -- Streams associated with standard files
13225   --------------------------
13226   -- Standard C functions --
13227   --------------------------
13228   -- The functions selected below are ones that are
13229   -- available in DOS, OS/2, UNIX and Xenix (but not
13230   -- necessarily in ANSI C).  These are very thin interfaces
13231   -- which copy exactly the C headers.  For more
13232   -- documentation on these functions, see the Microsoft C
13233   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13234   -- ISBN 1-55615-225-6), which includes useful information
13235   -- on system compatibility.
13236   procedure clearerr (stream : FILEs);
13237   function fclose (stream : FILEs) return int;
13238   function fdopen (handle : int; mode : chars) return FILEs;
13239   function feof (stream : FILEs) return int;
13240   function ferror (stream : FILEs) return int;
13241   function fflush (stream : FILEs) return int;
13242   function fgetc (stream : FILEs) return int;
13243   function fgets (strng : chars; n : int; stream : FILEs)
13244       return chars;
13245   function fileno (stream : FILEs) return int;
13246   function fopen (filename : chars; Mode : chars)
13247       return FILEs;
13248   -- Note: to maintain target independence, use
13249   -- text_translation_required, a boolean variable defined in
13250   -- a-sysdep.c to deal with the target dependent text
13251   -- translation requirement.  If this variable is set,
13252   -- then  b/t should be appended to the standard mode
13253   -- argument to set the text translation mode off or on
13254   -- as required.
13255   function fputc (C : int; stream : FILEs) return int;
13256   function fputs (Strng : chars; Stream : FILEs) return int;
13257   function fread
13258      (buffer : voids;
13259       size : size_t;
13260       count : size_t;
13261       stream : FILEs)
13262       return size_t;
13263   function freopen
13264      (filename : chars;
13265       mode : chars;
13266       stream : FILEs)
13267       return FILEs;
13268   function fseek
13269      (stream : FILEs;
13270       offset : long;
13271       origin : int)
13272       return int;
13273   function ftell (stream : FILEs) return long;
13274   function fwrite
13275      (buffer : voids;
13276       size : size_t;
13277       count : size_t;
13278       stream : FILEs)
13279       return size_t;
13280   function isatty (handle : int) return int;
13281   procedure mktemp (template : chars);
13282   -- The return value (which is just a pointer to template)
13283   -- is discarded
13284   procedure rewind (stream : FILEs);
13285   function rmtmp return int;
13286   function setvbuf
13287      (stream : FILEs;
13288       buffer : chars;
13289       mode : int;
13290       size : size_t)
13291       return int;
13292
13293   function tmpfile return FILEs;
13294   function ungetc (c : int; stream : FILEs) return int;
13295   function unlink (filename : chars) return int;
13296   ---------------------
13297   -- Extra functions --
13298   ---------------------
13299   -- These functions supply slightly thicker bindings than
13300   -- those above.  They are derived from functions in the
13301   -- C Run-Time Library, but may do a bit more work than
13302   -- just directly calling one of the Library functions.
13303   function is_regular_file (handle : int) return int;
13304   -- Tests if given handle is for a regular file (result 1)
13305   -- or for a non-regular file (pipe or device, result 0).
13306   ---------------------------------
13307   -- Control of Text/Binary Mode --
13308   ---------------------------------
13309   -- If text_translation_required is true, then the following
13310   -- functions may be used to dynamically switch a file from
13311   -- binary to text mode or vice versa.  These functions have
13312   -- no effect if text_translation_required is false (i.e.@: in
13313   -- normal UNIX mode).  Use fileno to get a stream handle.
13314   procedure set_binary_mode (handle : int);
13315   procedure set_text_mode (handle : int);
13316   ----------------------------
13317   -- Full Path Name support --
13318   ----------------------------
13319   procedure full_name (nam : chars; buffer : chars);
13320   -- Given a NUL terminated string representing a file
13321   -- name, returns in buffer a NUL terminated string
13322   -- representing the full path name for the file name.
13323   -- On systems where it is relevant the   drive is also
13324   -- part of the full path name.  It is the responsibility
13325   -- of the caller to pass an actual parameter for buffer
13326   -- that is big enough for any full path name.  Use
13327   -- max_path_len given below as the size of buffer.
13328   max_path_len : integer;
13329   -- Maximum length of an allowable full path name on the
13330   -- system, including a terminating NUL character.
13331 end Interfaces.C_Streams;
13332 @end smallexample
13333
13334 @node Interfacing to C Streams
13335 @section Interfacing to C Streams
13336
13337 @noindent
13338 The packages in this section permit interfacing Ada files to C Stream
13339 operations.
13340
13341 @smallexample @c ada
13342  with Interfaces.C_Streams;
13343  package Ada.Sequential_IO.C_Streams is
13344     function C_Stream (F : File_Type)
13345        return Interfaces.C_Streams.FILEs;
13346     procedure Open
13347       (File : in out File_Type;
13348        Mode : in File_Mode;
13349        C_Stream : in Interfaces.C_Streams.FILEs;
13350        Form : in String := "");
13351  end Ada.Sequential_IO.C_Streams;
13352
13353   with Interfaces.C_Streams;
13354   package Ada.Direct_IO.C_Streams is
13355      function C_Stream (F : File_Type)
13356         return Interfaces.C_Streams.FILEs;
13357      procedure Open
13358        (File : in out File_Type;
13359         Mode : in File_Mode;
13360         C_Stream : in Interfaces.C_Streams.FILEs;
13361         Form : in String := "");
13362   end Ada.Direct_IO.C_Streams;
13363
13364   with Interfaces.C_Streams;
13365   package Ada.Text_IO.C_Streams is
13366      function C_Stream (F : File_Type)
13367         return Interfaces.C_Streams.FILEs;
13368      procedure Open
13369        (File : in out File_Type;
13370         Mode : in File_Mode;
13371         C_Stream : in Interfaces.C_Streams.FILEs;
13372         Form : in String := "");
13373   end Ada.Text_IO.C_Streams;
13374
13375   with Interfaces.C_Streams;
13376   package Ada.Wide_Text_IO.C_Streams is
13377      function C_Stream (F : File_Type)
13378         return Interfaces.C_Streams.FILEs;
13379      procedure Open
13380        (File : in out File_Type;
13381         Mode : in File_Mode;
13382         C_Stream : in Interfaces.C_Streams.FILEs;
13383         Form : in String := "");
13384  end Ada.Wide_Text_IO.C_Streams;
13385
13386   with Interfaces.C_Streams;
13387   package Ada.Wide_Wide_Text_IO.C_Streams is
13388      function C_Stream (F : File_Type)
13389         return Interfaces.C_Streams.FILEs;
13390      procedure Open
13391        (File : in out File_Type;
13392         Mode : in File_Mode;
13393         C_Stream : in Interfaces.C_Streams.FILEs;
13394         Form : in String := "");
13395  end Ada.Wide_Wide_Text_IO.C_Streams;
13396
13397  with Interfaces.C_Streams;
13398  package Ada.Stream_IO.C_Streams is
13399     function C_Stream (F : File_Type)
13400        return Interfaces.C_Streams.FILEs;
13401     procedure Open
13402       (File : in out File_Type;
13403        Mode : in File_Mode;
13404        C_Stream : in Interfaces.C_Streams.FILEs;
13405        Form : in String := "");
13406  end Ada.Stream_IO.C_Streams;
13407 @end smallexample
13408
13409 @noindent
13410 In each of these six packages, the @code{C_Stream} function obtains the
13411 @code{FILE} pointer from a currently opened Ada file.  It is then
13412 possible to use the @code{Interfaces.C_Streams} package to operate on
13413 this stream, or the stream can be passed to a C program which can
13414 operate on it directly.  Of course the program is responsible for
13415 ensuring that only appropriate sequences of operations are executed.
13416
13417 One particular use of relevance to an Ada program is that the
13418 @code{setvbuf} function can be used to control the buffering of the
13419 stream used by an Ada file.  In the absence of such a call the standard
13420 default buffering is used.
13421
13422 The @code{Open} procedures in these packages open a file giving an
13423 existing C Stream instead of a file name.  Typically this stream is
13424 imported from a C program, allowing an Ada file to operate on an
13425 existing C file.
13426
13427 @node The GNAT Library
13428 @chapter The GNAT Library
13429
13430 @noindent
13431 The GNAT library contains a number of general and special purpose packages.
13432 It represents functionality that the GNAT developers have found useful, and
13433 which is made available to GNAT users.  The packages described here are fully
13434 supported, and upwards compatibility will be maintained in future releases,
13435 so you can use these facilities with the confidence that the same functionality
13436 will be available in future releases.
13437
13438 The chapter here simply gives a brief summary of the facilities available.
13439 The full documentation is found in the spec file for the package.  The full
13440 sources of these library packages, including both spec and body, are provided
13441 with all GNAT releases.  For example, to find out the full specifications of
13442 the SPITBOL pattern matching capability, including a full tutorial and
13443 extensive examples, look in the @file{g-spipat.ads} file in the library.
13444
13445 For each entry here, the package name (as it would appear in a @code{with}
13446 clause) is given, followed by the name of the corresponding spec file in
13447 parentheses.  The packages are children in four hierarchies, @code{Ada},
13448 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13449 GNAT-specific hierarchy.
13450
13451 Note that an application program should only use packages in one of these
13452 four hierarchies if the package is defined in the Ada Reference Manual,
13453 or is listed in this section of the GNAT Programmers Reference Manual.
13454 All other units should be considered internal implementation units and
13455 should not be directly @code{with}'ed by application code.  The use of
13456 a @code{with} statement that references one of these internal implementation
13457 units makes an application potentially dependent on changes in versions
13458 of GNAT, and will generate a warning message.
13459
13460 @menu
13461 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13462 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13463 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13464 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13465 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13466 * Ada.Command_Line.Environment (a-colien.ads)::
13467 * Ada.Command_Line.Remove (a-colire.ads)::
13468 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13469 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13470 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13471 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13472 * Ada.Exceptions.Traceback (a-exctra.ads)::
13473 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13474 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13475 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13476 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13477 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13478 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13479 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13480 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13481 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13482 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13483 * GNAT.Altivec (g-altive.ads)::
13484 * GNAT.Altivec.Conversions (g-altcon.ads)::
13485 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13486 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13487 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13488 * GNAT.Array_Split (g-arrspl.ads)::
13489 * GNAT.AWK (g-awk.ads)::
13490 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13491 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13492 * GNAT.Bubble_Sort (g-bubsor.ads)::
13493 * GNAT.Bubble_Sort_A (g-busora.ads)::
13494 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13495 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13496 * GNAT.Byte_Swapping (g-bytswa.ads)::
13497 * GNAT.Calendar (g-calend.ads)::
13498 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13499 * GNAT.Case_Util (g-casuti.ads)::
13500 * GNAT.CGI (g-cgi.ads)::
13501 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13502 * GNAT.CGI.Debug (g-cgideb.ads)::
13503 * GNAT.Command_Line (g-comlin.ads)::
13504 * GNAT.Compiler_Version (g-comver.ads)::
13505 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13506 * GNAT.CRC32 (g-crc32.ads)::
13507 * GNAT.Current_Exception (g-curexc.ads)::
13508 * GNAT.Debug_Pools (g-debpoo.ads)::
13509 * GNAT.Debug_Utilities (g-debuti.ads)::
13510 * GNAT.Decode_String (g-decstr.ads)::
13511 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13512 * GNAT.Directory_Operations (g-dirope.ads)::
13513 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13514 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13515 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13516 * GNAT.Encode_String (g-encstr.ads)::
13517 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13518 * GNAT.Exception_Actions (g-excact.ads)::
13519 * GNAT.Exception_Traces (g-exctra.ads)::
13520 * GNAT.Exceptions (g-except.ads)::
13521 * GNAT.Expect (g-expect.ads)::
13522 * GNAT.Float_Control (g-flocon.ads)::
13523 * GNAT.Heap_Sort (g-heasor.ads)::
13524 * GNAT.Heap_Sort_A (g-hesora.ads)::
13525 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13526 * GNAT.HTable (g-htable.ads)::
13527 * GNAT.IO (g-io.ads)::
13528 * GNAT.IO_Aux (g-io_aux.ads)::
13529 * GNAT.Lock_Files (g-locfil.ads)::
13530 * GNAT.MD5 (g-md5.ads)::
13531 * GNAT.Memory_Dump (g-memdum.ads)::
13532 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13533 * GNAT.OS_Lib (g-os_lib.ads)::
13534 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13535 * GNAT.Random_Numbers (g-rannum.ads)::
13536 * GNAT.Regexp (g-regexp.ads)::
13537 * GNAT.Registry (g-regist.ads)::
13538 * GNAT.Regpat (g-regpat.ads)::
13539 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13540 * GNAT.Semaphores (g-semaph.ads)::
13541 * GNAT.Serial_Communications (g-sercom.ads)::
13542 * GNAT.SHA1 (g-sha1.ads)::
13543 * GNAT.Signals (g-signal.ads)::
13544 * GNAT.Sockets (g-socket.ads)::
13545 * GNAT.Source_Info (g-souinf.ads)::
13546 * GNAT.Spelling_Checker (g-speche.ads)::
13547 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13548 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13549 * GNAT.Spitbol (g-spitbo.ads)::
13550 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13551 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13552 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13553 * GNAT.Strings (g-string.ads)::
13554 * GNAT.String_Split (g-strspl.ads)::
13555 * GNAT.Table (g-table.ads)::
13556 * GNAT.Task_Lock (g-tasloc.ads)::
13557 * GNAT.Threads (g-thread.ads)::
13558 * GNAT.Time_Stamp (g-timsta.ads)::
13559 * GNAT.Traceback (g-traceb.ads)::
13560 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13561 * GNAT.UTF_32 (g-utf_32.ads)::
13562 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13563 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13564 * GNAT.Wide_String_Split (g-wistsp.ads)::
13565 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13566 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13567 * Interfaces.C.Extensions (i-cexten.ads)::
13568 * Interfaces.C.Streams (i-cstrea.ads)::
13569 * Interfaces.CPP (i-cpp.ads)::
13570 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13571 * Interfaces.VxWorks (i-vxwork.ads)::
13572 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13573 * System.Address_Image (s-addima.ads)::
13574 * System.Assertions (s-assert.ads)::
13575 * System.Memory (s-memory.ads)::
13576 * System.Partition_Interface (s-parint.ads)::
13577 * System.Pool_Global (s-pooglo.ads)::
13578 * System.Pool_Local (s-pooloc.ads)::
13579 * System.Restrictions (s-restri.ads)::
13580 * System.Rident (s-rident.ads)::
13581 * System.Task_Info (s-tasinf.ads)::
13582 * System.Wch_Cnv (s-wchcnv.ads)::
13583 * System.Wch_Con (s-wchcon.ads)::
13584 @end menu
13585
13586 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13587 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13588 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13589 @cindex Latin_9 constants for Character
13590
13591 @noindent
13592 This child of @code{Ada.Characters}
13593 provides a set of definitions corresponding to those in the
13594 RM-defined package @code{Ada.Characters.Latin_1} but with the
13595 few modifications required for @code{Latin-9}
13596 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.Characters.Wide_Latin_1 (a-cwila1.ads)
13601 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13602 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13603 @cindex Latin_1 constants for Wide_Character
13604
13605 @noindent
13606 This child of @code{Ada.Characters}
13607 provides a set of definitions corresponding to those in the
13608 RM-defined package @code{Ada.Characters.Latin_1} but with the
13609 types of the constants being @code{Wide_Character}
13610 instead of @code{Character}.  The provision of such a package
13611 is specifically authorized by the Ada Reference Manual
13612 (RM A.3.3(27)).
13613
13614 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13615 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13616 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13617 @cindex Latin_9 constants for Wide_Character
13618
13619 @noindent
13620 This child of @code{Ada.Characters}
13621 provides a set of definitions corresponding to those in the
13622 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13623 types of the constants being @code{Wide_Character}
13624 instead of @code{Character}.  The provision of such a package
13625 is specifically authorized by the Ada Reference Manual
13626 (RM A.3.3(27)).
13627
13628 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13629 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13630 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13631 @cindex Latin_1 constants for Wide_Wide_Character
13632
13633 @noindent
13634 This child of @code{Ada.Characters}
13635 provides a set of definitions corresponding to those in the
13636 RM-defined package @code{Ada.Characters.Latin_1} but with the
13637 types of the constants being @code{Wide_Wide_Character}
13638 instead of @code{Character}.  The provision of such a package
13639 is specifically authorized by the Ada Reference Manual
13640 (RM A.3.3(27)).
13641
13642 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13643 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13644 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13645 @cindex Latin_9 constants for Wide_Wide_Character
13646
13647 @noindent
13648 This child of @code{Ada.Characters}
13649 provides a set of definitions corresponding to those in the
13650 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13651 types of the constants being @code{Wide_Wide_Character}
13652 instead of @code{Character}.  The provision of such a package
13653 is specifically authorized by the Ada Reference Manual
13654 (RM A.3.3(27)).
13655
13656 @node Ada.Command_Line.Environment (a-colien.ads)
13657 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13658 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13659 @cindex Environment entries
13660
13661 @noindent
13662 This child of @code{Ada.Command_Line}
13663 provides a mechanism for obtaining environment values on systems
13664 where this concept makes sense.
13665
13666 @node Ada.Command_Line.Remove (a-colire.ads)
13667 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13668 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13669 @cindex Removing command line arguments
13670 @cindex Command line, argument removal
13671
13672 @noindent
13673 This child of @code{Ada.Command_Line}
13674 provides a mechanism for logically removing
13675 arguments from the argument list.  Once removed, an argument is not visible
13676 to further calls on the subprograms in @code{Ada.Command_Line} will not
13677 see the removed argument.
13678
13679 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13680 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13681 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13682 @cindex Response file for command line
13683 @cindex Command line, response file
13684 @cindex Command line, handling long command lines
13685
13686 @noindent
13687 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13688 getting command line arguments from a text file, called a "response file".
13689 Using a response file allow passing a set of arguments to an executable longer
13690 than the maximum allowed by the system on the command line.
13691
13692 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13693 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13694 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13695 @cindex C Streams, Interfacing with Direct_IO
13696
13697 @noindent
13698 This package provides subprograms that allow interfacing between
13699 C streams and @code{Direct_IO}.  The stream identifier can be
13700 extracted from a file opened on the Ada side, and an Ada file
13701 can be constructed from a stream opened on the C side.
13702
13703 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13704 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13705 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13706 @cindex Null_Occurrence, testing for
13707
13708 @noindent
13709 This child subprogram provides a way of testing for the null
13710 exception occurrence (@code{Null_Occurrence}) without raising
13711 an exception.
13712
13713 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13714 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13715 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13716 @cindex Null_Occurrence, testing for
13717
13718 @noindent
13719 This child subprogram is used for handling otherwise unhandled
13720 exceptions (hence the name last chance), and perform clean ups before
13721 terminating the program. Note that this subprogram never returns.
13722
13723 @node Ada.Exceptions.Traceback (a-exctra.ads)
13724 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13725 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13726 @cindex Traceback for Exception Occurrence
13727
13728 @noindent
13729 This child package provides the subprogram (@code{Tracebacks}) to
13730 give a traceback array of addresses based on an exception
13731 occurrence.
13732
13733 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13734 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13735 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13736 @cindex C Streams, Interfacing with Sequential_IO
13737
13738 @noindent
13739 This package provides subprograms that allow interfacing between
13740 C streams and @code{Sequential_IO}.  The stream identifier can be
13741 extracted from a file opened on the Ada side, and an Ada file
13742 can be constructed from a stream opened on the C side.
13743
13744 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13745 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13746 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13747 @cindex C Streams, Interfacing with Stream_IO
13748
13749 @noindent
13750 This package provides subprograms that allow interfacing between
13751 C streams and @code{Stream_IO}.  The stream identifier can be
13752 extracted from a file opened on the Ada side, and an Ada file
13753 can be constructed from a stream opened on the C side.
13754
13755 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13756 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13757 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13758 @cindex @code{Unbounded_String}, IO support
13759 @cindex @code{Text_IO}, extensions for unbounded strings
13760
13761 @noindent
13762 This package provides subprograms for Text_IO for unbounded
13763 strings, avoiding the necessity for an intermediate operation
13764 with ordinary strings.
13765
13766 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13767 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13768 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13769 @cindex @code{Unbounded_Wide_String}, IO support
13770 @cindex @code{Text_IO}, extensions for unbounded wide strings
13771
13772 @noindent
13773 This package provides subprograms for Text_IO for unbounded
13774 wide strings, avoiding the necessity for an intermediate operation
13775 with ordinary wide strings.
13776
13777 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13778 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13779 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13780 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13781 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13782
13783 @noindent
13784 This package provides subprograms for Text_IO for unbounded
13785 wide wide strings, avoiding the necessity for an intermediate operation
13786 with ordinary wide wide strings.
13787
13788 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13789 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13790 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13791 @cindex C Streams, Interfacing with @code{Text_IO}
13792
13793 @noindent
13794 This package provides subprograms that allow interfacing between
13795 C streams and @code{Text_IO}.  The stream identifier can be
13796 extracted from a file opened on the Ada side, and an Ada file
13797 can be constructed from a stream opened on the C side.
13798
13799 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13800 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13801 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13802 @cindex Unicode categorization, Wide_Character
13803
13804 @noindent
13805 This package provides subprograms that allow categorization of
13806 Wide_Character values according to Unicode categories.
13807
13808 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13809 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13810 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13811 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13812
13813 @noindent
13814 This package provides subprograms that allow interfacing between
13815 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13816 extracted from a file opened on the Ada side, and an Ada file
13817 can be constructed from a stream opened on the C side.
13818
13819 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13820 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13821 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13822 @cindex Unicode categorization, Wide_Wide_Character
13823
13824 @noindent
13825 This package provides subprograms that allow categorization of
13826 Wide_Wide_Character values according to Unicode categories.
13827
13828 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13829 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13830 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13831 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13832
13833 @noindent
13834 This package provides subprograms that allow interfacing between
13835 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13836 extracted from a file opened on the Ada side, and an Ada file
13837 can be constructed from a stream opened on the C side.
13838
13839 @node GNAT.Altivec (g-altive.ads)
13840 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13841 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13842 @cindex AltiVec
13843
13844 @noindent
13845 This is the root package of the GNAT AltiVec binding. It provides
13846 definitions of constants and types common to all the versions of the
13847 binding.
13848
13849 @node GNAT.Altivec.Conversions (g-altcon.ads)
13850 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13851 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13852 @cindex AltiVec
13853
13854 @noindent
13855 This package provides the Vector/View conversion routines.
13856
13857 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13858 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13859 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13860 @cindex AltiVec
13861
13862 @noindent
13863 This package exposes the Ada interface to the AltiVec operations on
13864 vector objects. A soft emulation is included by default in the GNAT
13865 library. The hard binding is provided as a separate package. This unit
13866 is common to both bindings.
13867
13868 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13869 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13870 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13871 @cindex AltiVec
13872
13873 @noindent
13874 This package exposes the various vector types part of the Ada binding
13875 to AltiVec facilities.
13876
13877 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13878 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13879 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13880 @cindex AltiVec
13881
13882 @noindent
13883 This package provides public 'View' data types from/to which private
13884 vector representations can be converted via
13885 GNAT.Altivec.Conversions. This allows convenient access to individual
13886 vector elements and provides a simple way to initialize vector
13887 objects.
13888
13889 @node GNAT.Array_Split (g-arrspl.ads)
13890 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13891 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13892 @cindex Array splitter
13893
13894 @noindent
13895 Useful array-manipulation routines: given a set of separators, split
13896 an array wherever the separators appear, and provide direct access
13897 to the resulting slices.
13898
13899 @node GNAT.AWK (g-awk.ads)
13900 @section @code{GNAT.AWK} (@file{g-awk.ads})
13901 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13902 @cindex Parsing
13903 @cindex AWK
13904
13905 @noindent
13906 Provides AWK-like parsing functions, with an easy interface for parsing one
13907 or more files containing formatted data.  The file is viewed as a database
13908 where each record is a line and a field is a data element in this line.
13909
13910 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13911 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13912 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13913 @cindex Parsing
13914 @cindex Bounded Buffers
13915
13916 @noindent
13917 Provides a concurrent generic bounded buffer abstraction.  Instances are
13918 useful directly or as parts of the implementations of other abstractions,
13919 such as mailboxes.
13920
13921 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13922 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13923 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13924 @cindex Parsing
13925 @cindex Mailboxes
13926
13927 @noindent
13928 Provides a thread-safe asynchronous intertask mailbox communication facility.
13929
13930 @node GNAT.Bubble_Sort (g-bubsor.ads)
13931 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13932 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13933 @cindex Sorting
13934 @cindex Bubble sort
13935
13936 @noindent
13937 Provides a general implementation of bubble sort usable for sorting arbitrary
13938 data items.  Exchange and comparison procedures are provided by passing
13939 access-to-procedure values.
13940
13941 @node GNAT.Bubble_Sort_A (g-busora.ads)
13942 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13943 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13944 @cindex Sorting
13945 @cindex Bubble sort
13946
13947 @noindent
13948 Provides a general implementation of bubble sort usable for sorting arbitrary
13949 data items.  Move and comparison procedures are provided by passing
13950 access-to-procedure values. This is an older version, retained for
13951 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13952
13953 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13954 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13955 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13956 @cindex Sorting
13957 @cindex Bubble sort
13958
13959 @noindent
13960 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13961 are provided as generic parameters, this improves efficiency, especially
13962 if the procedures can be inlined, at the expense of duplicating code for
13963 multiple instantiations.
13964
13965 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13966 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13967 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13968 @cindex UTF-8 representation
13969 @cindex Wide characte representations
13970
13971 @noindent
13972 Provides a routine which given a string, reads the start of the string to
13973 see whether it is one of the standard byte order marks (BOM's) which signal
13974 the encoding of the string. The routine includes detection of special XML
13975 sequences for various UCS input formats.
13976
13977 @node GNAT.Byte_Swapping (g-bytswa.ads)
13978 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13979 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13980 @cindex Byte swapping
13981 @cindex Endian
13982
13983 @noindent
13984 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13985 Machine-specific implementations are available in some cases.
13986
13987 @node GNAT.Calendar (g-calend.ads)
13988 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13989 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13990 @cindex @code{Calendar}
13991
13992 @noindent
13993 Extends the facilities provided by @code{Ada.Calendar} to include handling
13994 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13995 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13996 C @code{timeval} format.
13997
13998 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13999 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14000 @cindex @code{Calendar}
14001 @cindex Time
14002 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14003
14004 @node GNAT.CRC32 (g-crc32.ads)
14005 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14006 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14007 @cindex CRC32
14008 @cindex Cyclic Redundancy Check
14009
14010 @noindent
14011 This package implements the CRC-32 algorithm.  For a full description
14012 of this algorithm see
14013 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14014 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14015 Aug.@: 1988.  Sarwate, D.V@.
14016
14017 @node GNAT.Case_Util (g-casuti.ads)
14018 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14019 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14020 @cindex Casing utilities
14021 @cindex Character handling (@code{GNAT.Case_Util})
14022
14023 @noindent
14024 A set of simple routines for handling upper and lower casing of strings
14025 without the overhead of the full casing tables
14026 in @code{Ada.Characters.Handling}.
14027
14028 @node GNAT.CGI (g-cgi.ads)
14029 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14030 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14031 @cindex CGI (Common Gateway Interface)
14032
14033 @noindent
14034 This is a package for interfacing a GNAT program with a Web server via the
14035 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14036 parameters, which are a set of key/value pairs sent by the Web server.  It
14037 builds a table whose index is the key and provides some services to deal
14038 with this table.
14039
14040 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14041 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14042 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14043 @cindex CGI (Common Gateway Interface) cookie support
14044 @cindex Cookie support in CGI
14045
14046 @noindent
14047 This is a package to interface a GNAT program with a Web server via the
14048 Common Gateway Interface (CGI).  It exports services to deal with Web
14049 cookies (piece of information kept in the Web client software).
14050
14051 @node GNAT.CGI.Debug (g-cgideb.ads)
14052 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14053 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14054 @cindex CGI (Common Gateway Interface) debugging
14055
14056 @noindent
14057 This is a package to help debugging CGI (Common Gateway Interface)
14058 programs written in Ada.
14059
14060 @node GNAT.Command_Line (g-comlin.ads)
14061 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14062 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14063 @cindex Command line
14064
14065 @noindent
14066 Provides a high level interface to @code{Ada.Command_Line} facilities,
14067 including the ability to scan for named switches with optional parameters
14068 and expand file names using wild card notations.
14069
14070 @node GNAT.Compiler_Version (g-comver.ads)
14071 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14072 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14073 @cindex Compiler Version
14074 @cindex Version, of compiler
14075
14076 @noindent
14077 Provides a routine for obtaining the version of the compiler used to
14078 compile the program. More accurately this is the version of the binder
14079 used to bind the program (this will normally be the same as the version
14080 of the compiler if a consistent tool set is used to compile all units
14081 of a partition).
14082
14083 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14084 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14085 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14086 @cindex Interrupt
14087
14088 @noindent
14089 Provides a simple interface to handle Ctrl-C keyboard events.
14090
14091 @node GNAT.Current_Exception (g-curexc.ads)
14092 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14093 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14094 @cindex Current exception
14095 @cindex Exception retrieval
14096
14097 @noindent
14098 Provides access to information on the current exception that has been raised
14099 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14100 specification syntax.
14101 This is particularly useful in simulating typical facilities for
14102 obtaining information about exceptions provided by Ada 83 compilers.
14103
14104 @node GNAT.Debug_Pools (g-debpoo.ads)
14105 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14106 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14107 @cindex Debugging
14108 @cindex Debug pools
14109 @cindex Memory corruption debugging
14110
14111 @noindent
14112 Provide a debugging storage pools that helps tracking memory corruption
14113 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14114 @value{EDITION} User's Guide}.
14115
14116 @node GNAT.Debug_Utilities (g-debuti.ads)
14117 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14118 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14119 @cindex Debugging
14120
14121 @noindent
14122 Provides a few useful utilities for debugging purposes, including conversion
14123 to and from string images of address values. Supports both C and Ada formats
14124 for hexadecimal literals.
14125
14126 @node GNAT.Decode_String (g-decstr.ads)
14127 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14128 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14129 @cindex Decoding strings
14130 @cindex String decoding
14131 @cindex Wide character encoding
14132 @cindex UTF-8
14133 @cindex Unicode
14134
14135 @noindent
14136 A generic package providing routines for decoding wide character and wide wide
14137 character strings encoded as sequences of 8-bit characters using a specified
14138 encoding method. Includes validation routines, and also routines for stepping
14139 to next or previous encoded character in an encoded string.
14140 Useful in conjunction with Unicode character coding. Note there is a
14141 preinstantiation for UTF-8. See next entry.
14142
14143 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14144 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14145 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14146 @cindex Decoding strings
14147 @cindex Decoding UTF-8 strings
14148 @cindex UTF-8 string decoding
14149 @cindex Wide character decoding
14150 @cindex UTF-8
14151 @cindex Unicode
14152
14153 @noindent
14154 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14155
14156 @node GNAT.Directory_Operations (g-dirope.ads)
14157 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14158 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14159 @cindex Directory operations
14160
14161 @noindent
14162 Provides a set of routines for manipulating directories, including changing
14163 the current directory, making new directories, and scanning the files in a
14164 directory.
14165
14166 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14167 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14168 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14169 @cindex Directory operations iteration
14170
14171 @noindent
14172 A child unit of GNAT.Directory_Operations providing additional operations
14173 for iterating through directories.
14174
14175 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14176 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14177 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14178 @cindex Hash tables
14179
14180 @noindent
14181 A generic implementation of hash tables that can be used to hash arbitrary
14182 data.  Provided in two forms, a simple form with built in hash functions,
14183 and a more complex form in which the hash function is supplied.
14184
14185 @noindent
14186 This package provides a facility similar to that of @code{GNAT.HTable},
14187 except that this package declares a type that can be used to define
14188 dynamic instances of the hash table, while an instantiation of
14189 @code{GNAT.HTable} creates a single instance of the hash table.
14190
14191 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14192 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14193 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14194 @cindex Table implementation
14195 @cindex Arrays, extendable
14196
14197 @noindent
14198 A generic package providing a single dimension array abstraction where the
14199 length of the array can be dynamically modified.
14200
14201 @noindent
14202 This package provides a facility similar to that of @code{GNAT.Table},
14203 except that this package declares a type that can be used to define
14204 dynamic instances of the table, while an instantiation of
14205 @code{GNAT.Table} creates a single instance of the table type.
14206
14207 @node GNAT.Encode_String (g-encstr.ads)
14208 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14209 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14210 @cindex Encoding strings
14211 @cindex String encoding
14212 @cindex Wide character encoding
14213 @cindex UTF-8
14214 @cindex Unicode
14215
14216 @noindent
14217 A generic package providing routines for encoding wide character and wide
14218 wide character strings as sequences of 8-bit characters using a specified
14219 encoding method. Useful in conjunction with Unicode character coding.
14220 Note there is a preinstantiation for UTF-8. See next entry.
14221
14222 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14223 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14224 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14225 @cindex Encoding strings
14226 @cindex Encoding UTF-8 strings
14227 @cindex UTF-8 string encoding
14228 @cindex Wide character encoding
14229 @cindex UTF-8
14230 @cindex Unicode
14231
14232 @noindent
14233 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14234
14235 @node GNAT.Exception_Actions (g-excact.ads)
14236 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14237 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14238 @cindex Exception actions
14239
14240 @noindent
14241 Provides callbacks when an exception is raised. Callbacks can be registered
14242 for specific exceptions, or when any exception is raised. This
14243 can be used for instance to force a core dump to ease debugging.
14244
14245 @node GNAT.Exception_Traces (g-exctra.ads)
14246 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14247 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14248 @cindex Exception traces
14249 @cindex Debugging
14250
14251 @noindent
14252 Provides an interface allowing to control automatic output upon exception
14253 occurrences.
14254
14255 @node GNAT.Exceptions (g-except.ads)
14256 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14257 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14258 @cindex Exceptions, Pure
14259 @cindex Pure packages, exceptions
14260
14261 @noindent
14262 Normally it is not possible to raise an exception with
14263 a message from a subprogram in a pure package, since the
14264 necessary types and subprograms are in @code{Ada.Exceptions}
14265 which is not a pure unit. @code{GNAT.Exceptions} provides a
14266 facility for getting around this limitation for a few
14267 predefined exceptions, and for example allow raising
14268 @code{Constraint_Error} with a message from a pure subprogram.
14269
14270 @node GNAT.Expect (g-expect.ads)
14271 @section @code{GNAT.Expect} (@file{g-expect.ads})
14272 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14273
14274 @noindent
14275 Provides a set of subprograms similar to what is available
14276 with the standard Tcl Expect tool.
14277 It allows you to easily spawn and communicate with an external process.
14278 You can send commands or inputs to the process, and compare the output
14279 with some expected regular expression. Currently @code{GNAT.Expect}
14280 is implemented on all native GNAT ports except for OpenVMS@.
14281 It is not implemented for cross ports, and in particular is not
14282 implemented for VxWorks or LynxOS@.
14283
14284 @node GNAT.Float_Control (g-flocon.ads)
14285 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14286 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14287 @cindex Floating-Point Processor
14288
14289 @noindent
14290 Provides an interface for resetting the floating-point processor into the
14291 mode required for correct semantic operation in Ada.  Some third party
14292 library calls may cause this mode to be modified, and the Reset procedure
14293 in this package can be used to reestablish the required mode.
14294
14295 @node GNAT.Heap_Sort (g-heasor.ads)
14296 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14297 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14298 @cindex Sorting
14299
14300 @noindent
14301 Provides a general implementation of heap sort usable for sorting arbitrary
14302 data items. Exchange and comparison procedures are provided by passing
14303 access-to-procedure values.  The algorithm used is a modified heap sort
14304 that performs approximately N*log(N) comparisons in the worst case.
14305
14306 @node GNAT.Heap_Sort_A (g-hesora.ads)
14307 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14308 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14309 @cindex Sorting
14310
14311 @noindent
14312 Provides a general implementation of heap sort usable for sorting arbitrary
14313 data items. Move and comparison procedures are provided by passing
14314 access-to-procedure values.  The algorithm used is a modified heap sort
14315 that performs approximately N*log(N) comparisons in the worst case.
14316 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14317 interface, but may be slightly more efficient.
14318
14319 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14320 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14321 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14322 @cindex Sorting
14323
14324 @noindent
14325 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14326 are provided as generic parameters, this improves efficiency, especially
14327 if the procedures can be inlined, at the expense of duplicating code for
14328 multiple instantiations.
14329
14330 @node GNAT.HTable (g-htable.ads)
14331 @section @code{GNAT.HTable} (@file{g-htable.ads})
14332 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14333 @cindex Hash tables
14334
14335 @noindent
14336 A generic implementation of hash tables that can be used to hash arbitrary
14337 data.  Provides two approaches, one a simple static approach, and the other
14338 allowing arbitrary dynamic hash tables.
14339
14340 @node GNAT.IO (g-io.ads)
14341 @section @code{GNAT.IO} (@file{g-io.ads})
14342 @cindex @code{GNAT.IO} (@file{g-io.ads})
14343 @cindex Simple I/O
14344 @cindex Input/Output facilities
14345
14346 @noindent
14347 A simple preelaborable input-output package that provides a subset of
14348 simple Text_IO functions for reading characters and strings from
14349 Standard_Input, and writing characters, strings and integers to either
14350 Standard_Output or Standard_Error.
14351
14352 @node GNAT.IO_Aux (g-io_aux.ads)
14353 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14354 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14355 @cindex Text_IO
14356 @cindex Input/Output facilities
14357
14358 Provides some auxiliary functions for use with Text_IO, including a test
14359 for whether a file exists, and functions for reading a line of text.
14360
14361 @node GNAT.Lock_Files (g-locfil.ads)
14362 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14363 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14364 @cindex File locking
14365 @cindex Locking using files
14366
14367 @noindent
14368 Provides a general interface for using files as locks.  Can be used for
14369 providing program level synchronization.
14370
14371 @node GNAT.MD5 (g-md5.ads)
14372 @section @code{GNAT.MD5} (@file{g-md5.ads})
14373 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14374 @cindex Message Digest MD5
14375
14376 @noindent
14377 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14378
14379 @node GNAT.Memory_Dump (g-memdum.ads)
14380 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14381 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14382 @cindex Dump Memory
14383
14384 @noindent
14385 Provides a convenient routine for dumping raw memory to either the
14386 standard output or standard error files. Uses GNAT.IO for actual
14387 output.
14388
14389 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14390 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14391 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14392 @cindex Exception, obtaining most recent
14393
14394 @noindent
14395 Provides access to the most recently raised exception.  Can be used for
14396 various logging purposes, including duplicating functionality of some
14397 Ada 83 implementation dependent extensions.
14398
14399 @node GNAT.OS_Lib (g-os_lib.ads)
14400 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14401 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14402 @cindex Operating System interface
14403 @cindex Spawn capability
14404
14405 @noindent
14406 Provides a range of target independent operating system interface functions,
14407 including time/date management, file operations, subprocess management,
14408 including a portable spawn procedure, and access to environment variables
14409 and error return codes.
14410
14411 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14412 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14413 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14414 @cindex Hash functions
14415
14416 @noindent
14417 Provides a generator of static minimal perfect hash functions. No
14418 collisions occur and each item can be retrieved from the table in one
14419 probe (perfect property). The hash table size corresponds to the exact
14420 size of the key set and no larger (minimal property). The key set has to
14421 be know in advance (static property). The hash functions are also order
14422 preserving. If w2 is inserted after w1 in the generator, their
14423 hashcode are in the same order. These hashing functions are very
14424 convenient for use with realtime applications.
14425
14426 @node GNAT.Random_Numbers (g-rannum.ads)
14427 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14428 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14429 @cindex Random number generation
14430
14431 @noindent
14432 Provides random number capabilities which extend those available in the
14433 standard Ada library and are more convenient to use.
14434
14435 @node GNAT.Regexp (g-regexp.ads)
14436 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14437 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14438 @cindex Regular expressions
14439 @cindex Pattern matching
14440
14441 @noindent
14442 A simple implementation of regular expressions, using a subset of regular
14443 expression syntax copied from familiar Unix style utilities.  This is the
14444 simples of the three pattern matching packages provided, and is particularly
14445 suitable for ``file globbing'' applications.
14446
14447 @node GNAT.Registry (g-regist.ads)
14448 @section @code{GNAT.Registry} (@file{g-regist.ads})
14449 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14450 @cindex Windows Registry
14451
14452 @noindent
14453 This is a high level binding to the Windows registry.  It is possible to
14454 do simple things like reading a key value, creating a new key.  For full
14455 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14456 package provided with the Win32Ada binding
14457
14458 @node GNAT.Regpat (g-regpat.ads)
14459 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14460 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14461 @cindex Regular expressions
14462 @cindex Pattern matching
14463
14464 @noindent
14465 A complete implementation of Unix-style regular expression matching, copied
14466 from the original V7 style regular expression library written in C by
14467 Henry Spencer (and binary compatible with this C library).
14468
14469 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14470 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14471 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14472 @cindex Secondary Stack Info
14473
14474 @noindent
14475 Provide the capability to query the high water mark of the current task's
14476 secondary stack.
14477
14478 @node GNAT.Semaphores (g-semaph.ads)
14479 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14480 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14481 @cindex Semaphores
14482
14483 @noindent
14484 Provides classic counting and binary semaphores using protected types.
14485
14486 @node GNAT.Serial_Communications (g-sercom.ads)
14487 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14488 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14489 @cindex Serial_Communications
14490
14491 @noindent
14492 Provides a simple interface to send and receive data over a serial
14493 port. This is only supported on GNU/Linux and Windows.
14494
14495 @node GNAT.SHA1 (g-sha1.ads)
14496 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14497 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14498 @cindex Secure Hash Algorithm SHA-1
14499
14500 @noindent
14501 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14502
14503 @node GNAT.Signals (g-signal.ads)
14504 @section @code{GNAT.Signals} (@file{g-signal.ads})
14505 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14506 @cindex Signals
14507
14508 @noindent
14509 Provides the ability to manipulate the blocked status of signals on supported
14510 targets.
14511
14512 @node GNAT.Sockets (g-socket.ads)
14513 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14514 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14515 @cindex Sockets
14516
14517 @noindent
14518 A high level and portable interface to develop sockets based applications.
14519 This package is based on the sockets thin binding found in
14520 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14521 on all native GNAT ports except for OpenVMS@.  It is not implemented
14522 for the LynxOS@ cross port.
14523
14524 @node GNAT.Source_Info (g-souinf.ads)
14525 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14526 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14527 @cindex Source Information
14528
14529 @noindent
14530 Provides subprograms that give access to source code information known at
14531 compile time, such as the current file name and line number.
14532
14533 @node GNAT.Spelling_Checker (g-speche.ads)
14534 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14535 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14536 @cindex Spell checking
14537
14538 @noindent
14539 Provides a function for determining whether one string is a plausible
14540 near misspelling of another string.
14541
14542 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14543 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14544 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14545 @cindex Spell checking
14546
14547 @noindent
14548 Provides a generic function that can be instantiated with a string type for
14549 determining whether one string is a plausible near misspelling of another
14550 string.
14551
14552 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14553 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14554 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14555 @cindex SPITBOL pattern matching
14556 @cindex Pattern matching
14557
14558 @noindent
14559 A complete implementation of SNOBOL4 style pattern matching.  This is the
14560 most elaborate of the pattern matching packages provided.  It fully duplicates
14561 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14562 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14563
14564 @node GNAT.Spitbol (g-spitbo.ads)
14565 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14566 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14567 @cindex SPITBOL interface
14568
14569 @noindent
14570 The top level package of the collection of SPITBOL-style functionality, this
14571 package provides basic SNOBOL4 string manipulation functions, such as
14572 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14573 useful for constructing arbitrary mappings from strings in the style of
14574 the SNOBOL4 TABLE function.
14575
14576 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14577 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14578 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14579 @cindex Sets of strings
14580 @cindex SPITBOL Tables
14581
14582 @noindent
14583 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14584 for type @code{Standard.Boolean}, giving an implementation of sets of
14585 string values.
14586
14587 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14588 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14589 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14590 @cindex Integer maps
14591 @cindex Maps
14592 @cindex SPITBOL Tables
14593
14594 @noindent
14595 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14596 for type @code{Standard.Integer}, giving an implementation of maps
14597 from string to integer values.
14598
14599 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14600 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14601 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14602 @cindex String maps
14603 @cindex Maps
14604 @cindex SPITBOL Tables
14605
14606 @noindent
14607 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14608 a variable length string type, giving an implementation of general
14609 maps from strings to strings.
14610
14611 @node GNAT.Strings (g-string.ads)
14612 @section @code{GNAT.Strings} (@file{g-string.ads})
14613 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14614
14615 @noindent
14616 Common String access types and related subprograms. Basically it
14617 defines a string access and an array of string access types.
14618
14619 @node GNAT.String_Split (g-strspl.ads)
14620 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14621 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14622 @cindex String splitter
14623
14624 @noindent
14625 Useful string manipulation routines: given a set of separators, split
14626 a string wherever the separators appear, and provide direct access
14627 to the resulting slices. This package is instantiated from
14628 @code{GNAT.Array_Split}.
14629
14630 @node GNAT.Table (g-table.ads)
14631 @section @code{GNAT.Table} (@file{g-table.ads})
14632 @cindex @code{GNAT.Table} (@file{g-table.ads})
14633 @cindex Table implementation
14634 @cindex Arrays, extendable
14635
14636 @noindent
14637 A generic package providing a single dimension array abstraction where the
14638 length of the array can be dynamically modified.
14639
14640 @noindent
14641 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14642 except that this package declares a single instance of the table type,
14643 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14644 used to define dynamic instances of the table.
14645
14646 @node GNAT.Task_Lock (g-tasloc.ads)
14647 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14648 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14649 @cindex Task synchronization
14650 @cindex Task locking
14651 @cindex Locking
14652
14653 @noindent
14654 A very simple facility for locking and unlocking sections of code using a
14655 single global task lock.  Appropriate for use in situations where contention
14656 between tasks is very rarely expected.
14657
14658 @node GNAT.Time_Stamp (g-timsta.ads)
14659 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14660 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14661 @cindex Time stamp
14662 @cindex Current time
14663
14664 @noindent
14665 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14666 represents the current date and time in ISO 8601 format. This is a very simple
14667 routine with minimal code and there are no dependencies on any other unit.
14668
14669 @node GNAT.Threads (g-thread.ads)
14670 @section @code{GNAT.Threads} (@file{g-thread.ads})
14671 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14672 @cindex Foreign threads
14673 @cindex Threads, foreign
14674
14675 @noindent
14676 Provides facilities for dealing with foreign threads which need to be known
14677 by the GNAT run-time system. Consult the documentation of this package for
14678 further details if your program has threads that are created by a non-Ada
14679 environment which then accesses Ada code.
14680
14681 @node GNAT.Traceback (g-traceb.ads)
14682 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14683 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14684 @cindex Trace back facilities
14685
14686 @noindent
14687 Provides a facility for obtaining non-symbolic traceback information, useful
14688 in various debugging situations.
14689
14690 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14691 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14692 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14693 @cindex Trace back facilities
14694
14695 @node GNAT.UTF_32 (g-utf_32.ads)
14696 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14697 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14698 @cindex Wide character codes
14699
14700 @noindent
14701 This is a package intended to be used in conjunction with the
14702 @code{Wide_Character} type in Ada 95 and the
14703 @code{Wide_Wide_Character} type in Ada 2005 (available
14704 in @code{GNAT} in Ada 2005 mode). This package contains
14705 Unicode categorization routines, as well as lexical
14706 categorization routines corresponding to the Ada 2005
14707 lexical rules for identifiers and strings, and also a
14708 lower case to upper case fold routine corresponding to
14709 the Ada 2005 rules for identifier equivalence.
14710
14711 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14712 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14713 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14714 @cindex Spell checking
14715
14716 @noindent
14717 Provides a function for determining whether one wide wide string is a plausible
14718 near misspelling of another wide wide string, where the strings are represented
14719 using the UTF_32_String type defined in System.Wch_Cnv.
14720
14721 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14722 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14723 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14724 @cindex Spell checking
14725
14726 @noindent
14727 Provides a function for determining whether one wide string is a plausible
14728 near misspelling of another wide string.
14729
14730 @node GNAT.Wide_String_Split (g-wistsp.ads)
14731 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14732 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14733 @cindex Wide_String splitter
14734
14735 @noindent
14736 Useful wide string manipulation routines: given a set of separators, split
14737 a wide string wherever the separators appear, and provide direct access
14738 to the resulting slices. This package is instantiated from
14739 @code{GNAT.Array_Split}.
14740
14741 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14742 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14743 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14744 @cindex Spell checking
14745
14746 @noindent
14747 Provides a function for determining whether one wide wide string is a plausible
14748 near misspelling of another wide wide string.
14749
14750 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14751 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14752 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14753 @cindex Wide_Wide_String splitter
14754
14755 @noindent
14756 Useful wide wide string manipulation routines: given a set of separators, split
14757 a wide wide string wherever the separators appear, and provide direct access
14758 to the resulting slices. This package is instantiated from
14759 @code{GNAT.Array_Split}.
14760
14761 @node Interfaces.C.Extensions (i-cexten.ads)
14762 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14763 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14764
14765 @noindent
14766 This package contains additional C-related definitions, intended
14767 for use with either manually or automatically generated bindings
14768 to C libraries.
14769
14770 @node Interfaces.C.Streams (i-cstrea.ads)
14771 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14772 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14773 @cindex  C streams, interfacing
14774
14775 @noindent
14776 This package is a binding for the most commonly used operations
14777 on C streams.
14778
14779 @node Interfaces.CPP (i-cpp.ads)
14780 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14781 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14782 @cindex  C++ interfacing
14783 @cindex  Interfacing, to C++
14784
14785 @noindent
14786 This package provides facilities for use in interfacing to C++.  It
14787 is primarily intended to be used in connection with automated tools
14788 for the generation of C++ interfaces.
14789
14790 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14791 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14792 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14793 @cindex  IBM Packed Format
14794 @cindex  Packed Decimal
14795
14796 @noindent
14797 This package provides a set of routines for conversions to and
14798 from a packed decimal format compatible with that used on IBM
14799 mainframes.
14800
14801 @node Interfaces.VxWorks (i-vxwork.ads)
14802 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14803 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14804 @cindex Interfacing to VxWorks
14805 @cindex VxWorks, interfacing
14806
14807 @noindent
14808 This package provides a limited binding to the VxWorks API.
14809 In particular, it interfaces with the
14810 VxWorks hardware interrupt facilities.
14811
14812 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14813 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14814 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14815 @cindex Interfacing to VxWorks' I/O
14816 @cindex VxWorks, I/O interfacing
14817 @cindex VxWorks, Get_Immediate
14818 @cindex Get_Immediate, VxWorks
14819
14820 @noindent
14821 This package provides a binding to the ioctl (IO/Control)
14822 function of VxWorks, defining a set of option values and
14823 function codes. A particular use of this package is
14824 to enable the use of Get_Immediate under VxWorks.
14825
14826 @node System.Address_Image (s-addima.ads)
14827 @section @code{System.Address_Image} (@file{s-addima.ads})
14828 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14829 @cindex Address image
14830 @cindex Image, of an address
14831
14832 @noindent
14833 This function provides a useful debugging
14834 function that gives an (implementation dependent)
14835 string which identifies an address.
14836
14837 @node System.Assertions (s-assert.ads)
14838 @section @code{System.Assertions} (@file{s-assert.ads})
14839 @cindex @code{System.Assertions} (@file{s-assert.ads})
14840 @cindex Assertions
14841 @cindex Assert_Failure, exception
14842
14843 @noindent
14844 This package provides the declaration of the exception raised
14845 by an run-time assertion failure, as well as the routine that
14846 is used internally to raise this assertion.
14847
14848 @node System.Memory (s-memory.ads)
14849 @section @code{System.Memory} (@file{s-memory.ads})
14850 @cindex @code{System.Memory} (@file{s-memory.ads})
14851 @cindex Memory allocation
14852
14853 @noindent
14854 This package provides the interface to the low level routines used
14855 by the generated code for allocation and freeing storage for the
14856 default storage pool (analogous to the C routines malloc and free.
14857 It also provides a reallocation interface analogous to the C routine
14858 realloc. The body of this unit may be modified to provide alternative
14859 allocation mechanisms for the default pool, and in addition, direct
14860 calls to this unit may be made for low level allocation uses (for
14861 example see the body of @code{GNAT.Tables}).
14862
14863 @node System.Partition_Interface (s-parint.ads)
14864 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14865 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14866 @cindex Partition interfacing functions
14867
14868 @noindent
14869 This package provides facilities for partition interfacing.  It
14870 is used primarily in a distribution context when using Annex E
14871 with @code{GLADE}.
14872
14873 @node System.Pool_Global (s-pooglo.ads)
14874 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14875 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14876 @cindex Storage pool, global
14877 @cindex Global storage pool
14878
14879 @noindent
14880 This package provides a storage pool that is equivalent to the default
14881 storage pool used for access types for which no pool is specifically
14882 declared. It uses malloc/free to allocate/free and does not attempt to
14883 do any automatic reclamation.
14884
14885 @node System.Pool_Local (s-pooloc.ads)
14886 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14887 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14888 @cindex Storage pool, local
14889 @cindex Local storage pool
14890
14891 @noindent
14892 This package provides a storage pool that is intended for use with locally
14893 defined access types. It uses malloc/free for allocate/free, and maintains
14894 a list of allocated blocks, so that all storage allocated for the pool can
14895 be freed automatically when the pool is finalized.
14896
14897 @node System.Restrictions (s-restri.ads)
14898 @section @code{System.Restrictions} (@file{s-restri.ads})
14899 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14900 @cindex Run-time restrictions access
14901
14902 @noindent
14903 This package provides facilities for accessing at run time
14904 the status of restrictions specified at compile time for
14905 the partition. Information is available both with regard
14906 to actual restrictions specified, and with regard to
14907 compiler determined information on which restrictions
14908 are violated by one or more packages in the partition.
14909
14910 @node System.Rident (s-rident.ads)
14911 @section @code{System.Rident} (@file{s-rident.ads})
14912 @cindex @code{System.Rident} (@file{s-rident.ads})
14913 @cindex Restrictions definitions
14914
14915 @noindent
14916 This package provides definitions of the restrictions
14917 identifiers supported by GNAT, and also the format of
14918 the restrictions provided in package System.Restrictions.
14919 It is not normally necessary to @code{with} this generic package
14920 since the necessary instantiation is included in
14921 package System.Restrictions.
14922
14923 @node System.Task_Info (s-tasinf.ads)
14924 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14925 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14926 @cindex Task_Info pragma
14927
14928 @noindent
14929 This package provides target dependent functionality that is used
14930 to support the @code{Task_Info} pragma
14931
14932 @node System.Wch_Cnv (s-wchcnv.ads)
14933 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14934 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14935 @cindex Wide Character, Representation
14936 @cindex Wide String, Conversion
14937 @cindex Representation of wide characters
14938
14939 @noindent
14940 This package provides routines for converting between
14941 wide and wide wide characters and a representation as a value of type
14942 @code{Standard.String}, using a specified wide character
14943 encoding method.  It uses definitions in
14944 package @code{System.Wch_Con}.
14945
14946 @node System.Wch_Con (s-wchcon.ads)
14947 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14948 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14949
14950 @noindent
14951 This package provides definitions and descriptions of
14952 the various methods used for encoding wide characters
14953 in ordinary strings.  These definitions are used by
14954 the package @code{System.Wch_Cnv}.
14955
14956 @node Interfacing to Other Languages
14957 @chapter Interfacing to Other Languages
14958 @noindent
14959 The facilities in annex B of the Ada Reference Manual are fully
14960 implemented in GNAT, and in addition, a full interface to C++ is
14961 provided.
14962
14963 @menu
14964 * Interfacing to C::
14965 * Interfacing to C++::
14966 * Interfacing to COBOL::
14967 * Interfacing to Fortran::
14968 * Interfacing to non-GNAT Ada code::
14969 @end menu
14970
14971 @node Interfacing to C
14972 @section Interfacing to C
14973
14974 @noindent
14975 Interfacing to C with GNAT can use one of two approaches:
14976
14977 @itemize @bullet
14978 @item
14979 The types in the package @code{Interfaces.C} may be used.
14980 @item
14981 Standard Ada types may be used directly.  This may be less portable to
14982 other compilers, but will work on all GNAT compilers, which guarantee
14983 correspondence between the C and Ada types.
14984 @end itemize
14985
14986 @noindent
14987 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14988 effect, since this is the default.  The following table shows the
14989 correspondence between Ada scalar types and the corresponding C types.
14990
14991 @table @code
14992 @item Integer
14993 @code{int}
14994 @item Short_Integer
14995 @code{short}
14996 @item Short_Short_Integer
14997 @code{signed char}
14998 @item Long_Integer
14999 @code{long}
15000 @item Long_Long_Integer
15001 @code{long long}
15002 @item Short_Float
15003 @code{float}
15004 @item Float
15005 @code{float}
15006 @item Long_Float
15007 @code{double}
15008 @item Long_Long_Float
15009 This is the longest floating-point type supported by the hardware.
15010 @end table
15011
15012 @noindent
15013 Additionally, there are the following general correspondences between Ada
15014 and C types:
15015 @itemize @bullet
15016 @item
15017 Ada enumeration types map to C enumeration types directly if pragma
15018 @code{Convention C} is specified, which causes them to have int
15019 length.  Without pragma @code{Convention C}, Ada enumeration types map to
15020 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15021 @code{int}, respectively) depending on the number of values passed.
15022 This is the only case in which pragma @code{Convention C} affects the
15023 representation of an Ada type.
15024
15025 @item
15026 Ada access types map to C pointers, except for the case of pointers to
15027 unconstrained types in Ada, which have no direct C equivalent.
15028
15029 @item
15030 Ada arrays map directly to C arrays.
15031
15032 @item
15033 Ada records map directly to C structures.
15034
15035 @item
15036 Packed Ada records map to C structures where all members are bit fields
15037 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15038 @end itemize
15039
15040 @node Interfacing to C++
15041 @section Interfacing to C++
15042
15043 @noindent
15044 The interface to C++ makes use of the following pragmas, which are
15045 primarily intended to be constructed automatically using a binding generator
15046 tool, although it is possible to construct them by hand.  No suitable binding
15047 generator tool is supplied with GNAT though.
15048
15049 Using these pragmas it is possible to achieve complete
15050 inter-operability between Ada tagged types and C++ class definitions.
15051 See @ref{Implementation Defined Pragmas}, for more details.
15052
15053 @table @code
15054 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15055 The argument denotes an entity in the current declarative region that is
15056 declared as a tagged or untagged record type. It indicates that the type
15057 corresponds to an externally declared C++ class type, and is to be laid
15058 out the same way that C++ would lay out the type.
15059
15060 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15061 for backward compatibility but its functionality is available
15062 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15063
15064 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15065 This pragma identifies an imported function (imported in the usual way
15066 with pragma @code{Import}) as corresponding to a C++ constructor.
15067 @end table
15068
15069 @node Interfacing to COBOL
15070 @section Interfacing to COBOL
15071
15072 @noindent
15073 Interfacing to COBOL is achieved as described in section B.4 of
15074 the Ada Reference Manual.
15075
15076 @node Interfacing to Fortran
15077 @section Interfacing to Fortran
15078
15079 @noindent
15080 Interfacing to Fortran is achieved as described in section B.5 of the
15081 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15082 multi-dimensional array causes the array to be stored in column-major
15083 order as required for convenient interface to Fortran.
15084
15085 @node Interfacing to non-GNAT Ada code
15086 @section Interfacing to non-GNAT Ada code
15087
15088 It is possible to specify the convention @code{Ada} in a pragma
15089 @code{Import} or pragma @code{Export}.  However this refers to
15090 the calling conventions used by GNAT, which may or may not be
15091 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15092 compiler to allow interoperation.
15093
15094 If arguments types are kept simple, and if the foreign compiler generally
15095 follows system calling conventions, then it may be possible to integrate
15096 files compiled by other Ada compilers, provided that the elaboration
15097 issues are adequately addressed (for example by eliminating the
15098 need for any load time elaboration).
15099
15100 In particular, GNAT running on VMS is designed to
15101 be highly compatible with the DEC Ada 83 compiler, so this is one
15102 case in which it is possible to import foreign units of this type,
15103 provided that the data items passed are restricted to simple scalar
15104 values or simple record types without variants, or simple array
15105 types with fixed bounds.
15106
15107 @node Specialized Needs Annexes
15108 @chapter Specialized Needs Annexes
15109
15110 @noindent
15111 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15112 required in all implementations.  However, as described in this chapter,
15113 GNAT implements all of these annexes:
15114
15115 @table @asis
15116 @item Systems Programming (Annex C)
15117 The Systems Programming Annex is fully implemented.
15118
15119 @item Real-Time Systems (Annex D)
15120 The Real-Time Systems Annex is fully implemented.
15121
15122 @item Distributed Systems (Annex E)
15123 Stub generation is fully implemented in the GNAT compiler.  In addition,
15124 a complete compatible PCS is available as part of the GLADE system,
15125 a separate product.  When the two
15126 products are used in conjunction, this annex is fully implemented.
15127
15128 @item Information Systems (Annex F)
15129 The Information Systems annex is fully implemented.
15130
15131 @item Numerics (Annex G)
15132 The Numerics Annex is fully implemented.
15133
15134 @item Safety and Security / High-Integrity Systems (Annex H)
15135 The Safety and Security Annex (termed the High-Integrity Systems Annex
15136 in Ada 2005) is fully implemented.
15137 @end table
15138
15139 @node Implementation of Specific Ada Features
15140 @chapter Implementation of Specific Ada Features
15141
15142 @noindent
15143 This chapter describes the GNAT implementation of several Ada language
15144 facilities.
15145
15146 @menu
15147 * Machine Code Insertions::
15148 * GNAT Implementation of Tasking::
15149 * GNAT Implementation of Shared Passive Packages::
15150 * Code Generation for Array Aggregates::
15151 * The Size of Discriminated Records with Default Discriminants::
15152 * Strict Conformance to the Ada Reference Manual::
15153 @end menu
15154
15155 @node Machine Code Insertions
15156 @section Machine Code Insertions
15157 @cindex Machine Code insertions
15158
15159 @noindent
15160 Package @code{Machine_Code} provides machine code support as described
15161 in the Ada Reference Manual in two separate forms:
15162 @itemize @bullet
15163 @item
15164 Machine code statements, consisting of qualified expressions that
15165 fit the requirements of RM section 13.8.
15166 @item
15167 An intrinsic callable procedure, providing an alternative mechanism of
15168 including machine instructions in a subprogram.
15169 @end itemize
15170
15171 @noindent
15172 The two features are similar, and both are closely related to the mechanism
15173 provided by the asm instruction in the GNU C compiler.  Full understanding
15174 and use of the facilities in this package requires understanding the asm
15175 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15176 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15177
15178 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15179 semantic restrictions and effects as described below.  Both are provided so
15180 that the procedure call can be used as a statement, and the function call
15181 can be used to form a code_statement.
15182
15183 The first example given in the GCC documentation is the C @code{asm}
15184 instruction:
15185 @smallexample
15186    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15187 @end smallexample
15188
15189 @noindent
15190 The equivalent can be written for GNAT as:
15191
15192 @smallexample @c ada
15193 Asm ("fsinx %1 %0",
15194      My_Float'Asm_Output ("=f", result),
15195      My_Float'Asm_Input  ("f",  angle));
15196 @end smallexample
15197
15198 @noindent
15199 The first argument to @code{Asm} is the assembler template, and is
15200 identical to what is used in GNU C@.  This string must be a static
15201 expression.  The second argument is the output operand list.  It is
15202 either a single @code{Asm_Output} attribute reference, or a list of such
15203 references enclosed in parentheses (technically an array aggregate of
15204 such references).
15205
15206 The @code{Asm_Output} attribute denotes a function that takes two
15207 parameters.  The first is a string, the second is the name of a variable
15208 of the type designated by the attribute prefix.  The first (string)
15209 argument is required to be a static expression and designates the
15210 constraint for the parameter (e.g.@: what kind of register is
15211 required).  The second argument is the variable to be updated with the
15212 result.  The possible values for constraint are the same as those used in
15213 the RTL, and are dependent on the configuration file used to build the
15214 GCC back end.  If there are no output operands, then this argument may
15215 either be omitted, or explicitly given as @code{No_Output_Operands}.
15216
15217 The second argument of @code{@var{my_float}'Asm_Output} functions as
15218 though it were an @code{out} parameter, which is a little curious, but
15219 all names have the form of expressions, so there is no syntactic
15220 irregularity, even though normally functions would not be permitted
15221 @code{out} parameters.  The third argument is the list of input
15222 operands.  It is either a single @code{Asm_Input} attribute reference, or
15223 a list of such references enclosed in parentheses (technically an array
15224 aggregate of such references).
15225
15226 The @code{Asm_Input} attribute denotes a function that takes two
15227 parameters.  The first is a string, the second is an expression of the
15228 type designated by the prefix.  The first (string) argument is required
15229 to be a static expression, and is the constraint for the parameter,
15230 (e.g.@: what kind of register is required).  The second argument is the
15231 value to be used as the input argument.  The possible values for the
15232 constant are the same as those used in the RTL, and are dependent on
15233 the configuration file used to built the GCC back end.
15234
15235 If there are no input operands, this argument may either be omitted, or
15236 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15237 present in the above example, is a list of register names, called the
15238 @dfn{clobber} argument.  This argument, if given, must be a static string
15239 expression, and is a space or comma separated list of names of registers
15240 that must be considered destroyed as a result of the @code{Asm} call.  If
15241 this argument is the null string (the default value), then the code
15242 generator assumes that no additional registers are destroyed.
15243
15244 The fifth argument, not present in the above example, called the
15245 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15246 the literal value @code{True} to indicate to the code generator that all
15247 optimizations with respect to the instruction specified should be
15248 suppressed, and that in particular, for an instruction that has outputs,
15249 the instruction will still be generated, even if none of the outputs are
15250 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15251 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15252 Generally it is strongly advisable to use Volatile for any ASM statement
15253 that is missing either input or output operands, or when two or more ASM
15254 statements appear in sequence, to avoid unwanted optimizations. A warning
15255 is generated if this advice is not followed.
15256
15257 The @code{Asm} subprograms may be used in two ways.  First the procedure
15258 forms can be used anywhere a procedure call would be valid, and
15259 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15260 be used to intersperse machine instructions with other Ada statements.
15261 Second, the function forms, which return a dummy value of the limited
15262 private type @code{Asm_Insn}, can be used in code statements, and indeed
15263 this is the only context where such calls are allowed.  Code statements
15264 appear as aggregates of the form:
15265
15266 @smallexample @c ada
15267 Asm_Insn'(Asm (@dots{}));
15268 Asm_Insn'(Asm_Volatile (@dots{}));
15269 @end smallexample
15270
15271 @noindent
15272 In accordance with RM rules, such code statements are allowed only
15273 within subprograms whose entire body consists of such statements.  It is
15274 not permissible to intermix such statements with other Ada statements.
15275
15276 Typically the form using intrinsic procedure calls is more convenient
15277 and more flexible.  The code statement form is provided to meet the RM
15278 suggestion that such a facility should be made available.  The following
15279 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15280 is used, the arguments may be given in arbitrary order, following the
15281 normal rules for use of positional and named arguments)
15282
15283 @smallexample
15284 ASM_CALL ::= Asm (
15285                  [Template =>] static_string_EXPRESSION
15286                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15287                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15288                [,[Clobber  =>] static_string_EXPRESSION ]
15289                [,[Volatile =>] static_boolean_EXPRESSION] )
15290
15291 OUTPUT_OPERAND_LIST ::=
15292   [PREFIX.]No_Output_Operands
15293 | OUTPUT_OPERAND_ATTRIBUTE
15294 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15295
15296 OUTPUT_OPERAND_ATTRIBUTE ::=
15297   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15298
15299 INPUT_OPERAND_LIST ::=
15300   [PREFIX.]No_Input_Operands
15301 | INPUT_OPERAND_ATTRIBUTE
15302 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15303
15304 INPUT_OPERAND_ATTRIBUTE ::=
15305   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15306 @end smallexample
15307
15308 @noindent
15309 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15310 are declared in the package @code{Machine_Code} and must be referenced
15311 according to normal visibility rules. In particular if there is no
15312 @code{use} clause for this package, then appropriate package name
15313 qualification is required.
15314
15315 @node GNAT Implementation of Tasking
15316 @section GNAT Implementation of Tasking
15317
15318 @noindent
15319 This chapter outlines the basic GNAT approach to tasking (in particular,
15320 a multi-layered library for portability) and discusses issues related
15321 to compliance with the Real-Time Systems Annex.
15322
15323 @menu
15324 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15325 * Ensuring Compliance with the Real-Time Annex::
15326 @end menu
15327
15328 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15329 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15330
15331 @noindent
15332 GNAT's run-time support comprises two layers:
15333
15334 @itemize @bullet
15335 @item GNARL (GNAT Run-time Layer)
15336 @item GNULL (GNAT Low-level Library)
15337 @end itemize
15338
15339 @noindent
15340 In GNAT, Ada's tasking services rely on a platform and OS independent
15341 layer known as GNARL@.  This code is responsible for implementing the
15342 correct semantics of Ada's task creation, rendezvous, protected
15343 operations etc.
15344
15345 GNARL decomposes Ada's tasking semantics into simpler lower level
15346 operations such as create a thread, set the priority of a thread,
15347 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15348 operations constitutes GNULLI, the GNULL Interface.  This interface is
15349 directly inspired from the POSIX real-time API@.
15350
15351 If the underlying executive or OS implements the POSIX standard
15352 faithfully, the GNULL Interface maps as is to the services offered by
15353 the underlying kernel.  Otherwise, some target dependent glue code maps
15354 the services offered by the underlying kernel to the semantics expected
15355 by GNARL@.
15356
15357 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15358 key point is that each Ada task is mapped on a thread in the underlying
15359 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15360
15361 In addition Ada task priorities map onto the underlying thread priorities.
15362 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15363
15364 @itemize @bullet
15365 @item
15366 The underlying scheduler is used to schedule the Ada tasks.  This
15367 makes Ada tasks as efficient as kernel threads from a scheduling
15368 standpoint.
15369
15370 @item
15371 Interaction with code written in C containing threads is eased
15372 since at the lowest level Ada tasks and C threads map onto the same
15373 underlying kernel concept.
15374
15375 @item
15376 When an Ada task is blocked during I/O the remaining Ada tasks are
15377 able to proceed.
15378
15379 @item
15380 On multiprocessor systems Ada tasks can execute in parallel.
15381 @end itemize
15382
15383 @noindent
15384 Some threads libraries offer a mechanism to fork a new process, with the
15385 child process duplicating the threads from the parent.
15386 GNAT does not
15387 support this functionality when the parent contains more than one task.
15388 @cindex Forking a new process
15389
15390 @node Ensuring Compliance with the Real-Time Annex
15391 @subsection Ensuring Compliance with the Real-Time Annex
15392 @cindex Real-Time Systems Annex compliance
15393
15394 @noindent
15395 Although mapping Ada tasks onto
15396 the underlying threads has significant advantages, it does create some
15397 complications when it comes to respecting the scheduling semantics
15398 specified in the real-time annex (Annex D).
15399
15400 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15401 scheduling policy states:
15402
15403 @quotation
15404 @emph{When the active priority of a ready task that is not running
15405 changes, or the setting of its base priority takes effect, the
15406 task is removed from the ready queue for its old active priority
15407 and is added at the tail of the ready queue for its new active
15408 priority, except in the case where the active priority is lowered
15409 due to the loss of inherited priority, in which case the task is
15410 added at the head of the ready queue for its new active priority.}
15411 @end quotation
15412
15413 @noindent
15414 While most kernels do put tasks at the end of the priority queue when
15415 a task changes its priority, (which respects the main
15416 FIFO_Within_Priorities requirement), almost none keep a thread at the
15417 beginning of its priority queue when its priority drops from the loss
15418 of inherited priority.
15419
15420 As a result most vendors have provided incomplete Annex D implementations.
15421
15422 The GNAT run-time, has a nice cooperative solution to this problem
15423 which ensures that accurate FIFO_Within_Priorities semantics are
15424 respected.
15425
15426 The principle is as follows.  When an Ada task T is about to start
15427 running, it checks whether some other Ada task R with the same
15428 priority as T has been suspended due to the loss of priority
15429 inheritance.  If this is the case, T yields and is placed at the end of
15430 its priority queue.  When R arrives at the front of the queue it
15431 executes.
15432
15433 Note that this simple scheme preserves the relative order of the tasks
15434 that were ready to execute in the priority queue where R has been
15435 placed at the end.
15436
15437 @node GNAT Implementation of Shared Passive Packages
15438 @section GNAT Implementation of Shared Passive Packages
15439 @cindex Shared passive packages
15440
15441 @noindent
15442 GNAT fully implements the pragma @code{Shared_Passive} for
15443 @cindex pragma @code{Shared_Passive}
15444 the purpose of designating shared passive packages.
15445 This allows the use of passive partitions in the
15446 context described in the Ada Reference Manual; i.e., for communication
15447 between separate partitions of a distributed application using the
15448 features in Annex E.
15449 @cindex Annex E
15450 @cindex Distribution Systems Annex
15451
15452 However, the implementation approach used by GNAT provides for more
15453 extensive usage as follows:
15454
15455 @table @emph
15456 @item Communication between separate programs
15457
15458 This allows separate programs to access the data in passive
15459 partitions, using protected objects for synchronization where
15460 needed. The only requirement is that the two programs have a
15461 common shared file system. It is even possible for programs
15462 running on different machines with different architectures
15463 (e.g.@: different endianness) to communicate via the data in
15464 a passive partition.
15465
15466 @item Persistence between program runs
15467
15468 The data in a passive package can persist from one run of a
15469 program to another, so that a later program sees the final
15470 values stored by a previous run of the same program.
15471
15472 @end table
15473
15474 @noindent
15475 The implementation approach used is to store the data in files. A
15476 separate stream file is created for each object in the package, and
15477 an access to an object causes the corresponding file to be read or
15478 written.
15479
15480 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15481 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15482 set to the directory to be used for these files.
15483 The files in this directory
15484 have names that correspond to their fully qualified names. For
15485 example, if we have the package
15486
15487 @smallexample @c ada
15488 package X is
15489   pragma Shared_Passive (X);
15490   Y : Integer;
15491   Z : Float;
15492 end X;
15493 @end smallexample
15494
15495 @noindent
15496 and the environment variable is set to @code{/stemp/}, then the files created
15497 will have the names:
15498
15499 @smallexample
15500 /stemp/x.y
15501 /stemp/x.z
15502 @end smallexample
15503
15504 @noindent
15505 These files are created when a value is initially written to the object, and
15506 the files are retained until manually deleted. This provides the persistence
15507 semantics. If no file exists, it means that no partition has assigned a value
15508 to the variable; in this case the initial value declared in the package
15509 will be used. This model ensures that there are no issues in synchronizing
15510 the elaboration process, since elaboration of passive packages elaborates the
15511 initial values, but does not create the files.
15512
15513 The files are written using normal @code{Stream_IO} access.
15514 If you want to be able
15515 to communicate between programs or partitions running on different
15516 architectures, then you should use the XDR versions of the stream attribute
15517 routines, since these are architecture independent.
15518
15519 If active synchronization is required for access to the variables in the
15520 shared passive package, then as described in the Ada Reference Manual, the
15521 package may contain protected objects used for this purpose. In this case
15522 a lock file (whose name is @file{___lock} (three underscores)
15523 is created in the shared memory directory.
15524 @cindex @file{___lock} file (for shared passive packages)
15525 This is used to provide the required locking
15526 semantics for proper protected object synchronization.
15527
15528 As of January 2003, GNAT supports shared passive packages on all platforms
15529 except for OpenVMS.
15530
15531 @node Code Generation for Array Aggregates
15532 @section Code Generation for Array Aggregates
15533
15534 @menu
15535 * Static constant aggregates with static bounds::
15536 * Constant aggregates with unconstrained nominal types::
15537 * Aggregates with static bounds::
15538 * Aggregates with non-static bounds::
15539 * Aggregates in assignment statements::
15540 @end menu
15541
15542 @noindent
15543 Aggregates have a rich syntax and allow the user to specify the values of
15544 complex data structures by means of a single construct.  As a result, the
15545 code generated for aggregates can be quite complex and involve loops, case
15546 statements and multiple assignments.  In the simplest cases, however, the
15547 compiler will recognize aggregates whose components and constraints are
15548 fully static, and in those cases the compiler will generate little or no
15549 executable code.  The following is an outline of the code that GNAT generates
15550 for various aggregate constructs.  For further details, you will find it
15551 useful to examine the output produced by the -gnatG flag to see the expanded
15552 source that is input to the code generator.  You may also want to examine
15553 the assembly code generated at various levels of optimization.
15554
15555 The code generated for aggregates depends on the context, the component values,
15556 and the type.  In the context of an object declaration the code generated is
15557 generally simpler than in the case of an assignment.  As a general rule, static
15558 component values and static subtypes also lead to simpler code.
15559
15560 @node Static constant aggregates with static bounds
15561 @subsection Static constant aggregates with static bounds
15562
15563 @noindent
15564 For the declarations:
15565 @smallexample @c ada
15566     type One_Dim is array (1..10) of integer;
15567     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15568 @end smallexample
15569
15570 @noindent
15571 GNAT generates no executable code: the constant ar0 is placed in static memory.
15572 The same is true for constant aggregates with named associations:
15573
15574 @smallexample @c ada
15575     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15576     Cr3 : constant One_Dim := (others => 7777);
15577 @end smallexample
15578
15579 @noindent
15580 The same is true for multidimensional constant arrays such as:
15581
15582 @smallexample @c ada
15583     type two_dim is array (1..3, 1..3) of integer;
15584     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15585 @end smallexample
15586
15587 @noindent
15588 The same is true for arrays of one-dimensional arrays: the following are
15589 static:
15590
15591 @smallexample @c ada
15592 type ar1b  is array (1..3) of boolean;
15593 type ar_ar is array (1..3) of ar1b;
15594 None  : constant ar1b := (others => false);     --  fully static
15595 None2 : constant ar_ar := (1..3 => None);       --  fully static
15596 @end smallexample
15597
15598 @noindent
15599 However, for multidimensional aggregates with named associations, GNAT will
15600 generate assignments and loops, even if all associations are static.  The
15601 following two declarations generate a loop for the first dimension, and
15602 individual component assignments for the second dimension:
15603
15604 @smallexample @c ada
15605 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15606 Zero2: constant two_dim := (others => (others => 0));
15607 @end smallexample
15608
15609 @node Constant aggregates with unconstrained nominal types
15610 @subsection Constant aggregates with unconstrained nominal types
15611
15612 @noindent
15613 In such cases the aggregate itself establishes the subtype, so that
15614 associations with @code{others} cannot be used.  GNAT determines the
15615 bounds for the actual subtype of the aggregate, and allocates the
15616 aggregate statically as well.  No code is generated for the following:
15617
15618 @smallexample @c ada
15619     type One_Unc is array (natural range <>) of integer;
15620     Cr_Unc : constant One_Unc := (12,24,36);
15621 @end smallexample
15622
15623 @node Aggregates with static bounds
15624 @subsection Aggregates with static bounds
15625
15626 @noindent
15627 In all previous examples the aggregate was the initial (and immutable) value
15628 of a constant.  If the aggregate initializes a variable, then code is generated
15629 for it as a combination of individual assignments and loops over the target
15630 object.  The declarations
15631
15632 @smallexample @c ada
15633        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15634        Cr_Var2 : One_Dim := (others > -1);
15635 @end smallexample
15636
15637 @noindent
15638 generate the equivalent of
15639
15640 @smallexample @c ada
15641        Cr_Var1 (1) := 2;
15642        Cr_Var1 (2) := 3;
15643        Cr_Var1 (3) := 5;
15644        Cr_Var1 (4) := 11;
15645
15646        for I in Cr_Var2'range loop
15647           Cr_Var2 (I) := -1;
15648        end loop;
15649 @end smallexample
15650
15651 @node Aggregates with non-static bounds
15652 @subsection Aggregates with non-static bounds
15653
15654 @noindent
15655 If the bounds of the aggregate are not statically compatible with the bounds
15656 of the nominal subtype  of the target, then constraint checks have to be
15657 generated on the bounds.  For a multidimensional array, constraint checks may
15658 have to be applied to sub-arrays individually, if they do not have statically
15659 compatible subtypes.
15660
15661 @node Aggregates in assignment statements
15662 @subsection Aggregates in assignment statements
15663
15664 @noindent
15665 In general, aggregate assignment requires the construction of a temporary,
15666 and a copy from the temporary to the target of the assignment.  This is because
15667 it is not always possible to convert the assignment into a series of individual
15668 component assignments.  For example, consider the simple case:
15669
15670 @smallexample @c ada
15671         A := (A(2), A(1));
15672 @end smallexample
15673
15674 @noindent
15675 This cannot be converted into:
15676
15677 @smallexample @c ada
15678         A(1) := A(2);
15679         A(2) := A(1);
15680 @end smallexample
15681
15682 @noindent
15683 So the aggregate has to be built first in a separate location, and then
15684 copied into the target.  GNAT recognizes simple cases where this intermediate
15685 step is not required, and the assignments can be performed in place, directly
15686 into the target.  The following sufficient criteria are applied:
15687
15688 @itemize @bullet
15689 @item
15690 The bounds of the aggregate are static, and the associations are static.
15691 @item
15692 The components of the aggregate are static constants, names of
15693 simple variables that are not renamings, or expressions not involving
15694 indexed components whose operands obey these rules.
15695 @end itemize
15696
15697 @noindent
15698 If any of these conditions are violated, the aggregate will be built in
15699 a temporary (created either by the front-end or the code generator) and then
15700 that temporary will be copied onto the target.
15701
15702
15703 @node The Size of Discriminated Records with Default Discriminants
15704 @section The Size of Discriminated Records with Default Discriminants
15705
15706 @noindent
15707 If a discriminated type @code{T} has discriminants with default values, it is
15708 possible to declare an object of this type without providing an explicit
15709 constraint:
15710
15711 @smallexample @c ada
15712 @group
15713 type Size is range 1..100;
15714
15715 type Rec (D : Size := 15) is record
15716    Name : String (1..D);
15717 end T;
15718
15719 Word : Rec;
15720 @end group
15721 @end smallexample
15722
15723 @noindent
15724 Such an object is said to be @emph{unconstrained}.
15725 The discriminant of the object
15726 can be modified by a full assignment to the object, as long as it preserves the
15727 relation between the value of the discriminant, and the value of the components
15728 that depend on it:
15729
15730 @smallexample @c ada
15731 @group
15732 Word := (3, "yes");
15733
15734 Word := (5, "maybe");
15735
15736 Word := (5, "no"); -- raises Constraint_Error
15737 @end group
15738 @end smallexample
15739
15740 @noindent
15741 In order to support this behavior efficiently, an unconstrained object is
15742 given the maximum size that any value of the type requires. In the case
15743 above, @code{Word} has storage for the discriminant and for
15744 a @code{String} of length 100.
15745 It is important to note that unconstrained objects do not require dynamic
15746 allocation. It would be an improper implementation to place on the heap those
15747 components whose size depends on discriminants. (This improper implementation
15748 was used by some Ada83 compilers, where the @code{Name} component above
15749 would have
15750 been stored as a pointer to a dynamic string). Following the principle that
15751 dynamic storage management should never be introduced implicitly,
15752 an Ada compiler should reserve the full size for an unconstrained declared
15753 object, and place it on the stack.
15754
15755 This maximum size approach
15756 has been a source of surprise to some users, who expect the default
15757 values of the discriminants to determine the size reserved for an
15758 unconstrained object: ``If the default is 15, why should the object occupy
15759 a larger size?''
15760 The answer, of course, is that the discriminant may be later modified,
15761 and its full range of values must be taken into account. This is why the
15762 declaration:
15763
15764 @smallexample
15765 @group
15766 type Rec (D : Positive := 15) is record
15767    Name : String (1..D);
15768 end record;
15769
15770 Too_Large : Rec;
15771 @end group
15772 @end smallexample
15773
15774 @noindent
15775 is flagged by the compiler with a warning:
15776 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15777 because the required size includes @code{Positive'Last}
15778 bytes. As the first example indicates, the proper approach is to declare an
15779 index type of ``reasonable'' range so that unconstrained objects are not too
15780 large.
15781
15782 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15783 created in the heap by means of an allocator, then it is @emph{not}
15784 unconstrained:
15785 it is constrained by the default values of the discriminants, and those values
15786 cannot be modified by full assignment. This is because in the presence of
15787 aliasing all views of the object (which may be manipulated by different tasks,
15788 say) must be consistent, so it is imperative that the object, once created,
15789 remain invariant.
15790
15791 @node Strict Conformance to the Ada Reference Manual
15792 @section Strict Conformance to the Ada Reference Manual
15793
15794 @noindent
15795 The dynamic semantics defined by the Ada Reference Manual impose a set of
15796 run-time checks to be generated. By default, the GNAT compiler will insert many
15797 run-time checks into the compiled code, including most of those required by the
15798 Ada Reference Manual. However, there are three checks that are not enabled
15799 in the default mode for efficiency reasons: arithmetic overflow checking for
15800 integer operations (including division by zero), checks for access before
15801 elaboration on subprogram calls, and stack overflow checking (most operating
15802 systems do not perform this check by default).
15803
15804 Strict conformance to the Ada Reference Manual can be achieved by adding
15805 three compiler options for overflow checking for integer operations
15806 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15807 calls and generic instantiations (@option{-gnatE}), and stack overflow
15808 checking (@option{-fstack-check}).
15809
15810 Note that the result of a floating point arithmetic operation in overflow and
15811 invalid situations, when the @code{Machine_Overflows} attribute of the result
15812 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15813 case for machines compliant with the IEEE floating-point standard, but on
15814 machines that are not fully compliant with this standard, such as Alpha, the
15815 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15816 behavior (although at the cost of a significant performance penalty), so
15817 infinite and and NaN values are properly generated.
15818
15819
15820 @node Project File Reference
15821 @chapter Project File Reference
15822
15823 @noindent
15824 This chapter describes the syntax and semantics of project files.
15825 Project files specify the options to be used when building a system.
15826 Project files can specify global settings for all tools,
15827 as well as tool-specific settings.
15828 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15829 for examples of use.
15830
15831 @menu
15832 * Reserved Words::
15833 * Lexical Elements::
15834 * Declarations::
15835 * Empty declarations::
15836 * Typed string declarations::
15837 * Variables::
15838 * Expressions::
15839 * Attributes::
15840 * Project Attributes::
15841 * Attribute References::
15842 * External Values::
15843 * Case Construction::
15844 * Packages::
15845 * Package Renamings::
15846 * Projects::
15847 * Project Extensions::
15848 * Project File Elaboration::
15849 @end menu
15850
15851 @node Reserved Words
15852 @section Reserved Words
15853
15854 @noindent
15855 All Ada reserved words are reserved in project files, and cannot be used
15856 as variable names or project names. In addition, the following are
15857 also reserved in project files:
15858
15859 @itemize
15860 @item @code{extends}
15861
15862 @item @code{external}
15863
15864 @item @code{project}
15865
15866 @end itemize
15867
15868 @node Lexical Elements
15869 @section Lexical Elements
15870
15871 @noindent
15872 Rules for identifiers are the same as in Ada. Identifiers
15873 are case-insensitive.  Strings are case sensitive, except where noted.
15874 Comments have the same form as in Ada.
15875
15876 @noindent
15877 Syntax:
15878
15879 @smallexample
15880 simple_name ::=
15881   identifier
15882
15883 name ::=
15884   simple_name @{. simple_name@}
15885 @end smallexample
15886
15887 @node Declarations
15888 @section Declarations
15889
15890 @noindent
15891 Declarations introduce new entities that denote types, variables, attributes,
15892 and packages. Some declarations can only appear immediately within a project
15893 declaration. Others can appear within a project or within a package.
15894
15895 Syntax:
15896 @smallexample
15897 declarative_item ::=
15898   simple_declarative_item |
15899   typed_string_declaration |
15900   package_declaration
15901
15902 simple_declarative_item ::=
15903   variable_declaration |
15904   typed_variable_declaration |
15905   attribute_declaration |
15906   case_construction |
15907   empty_declaration
15908 @end smallexample
15909
15910 @node Empty declarations
15911 @section Empty declarations
15912
15913 @smallexample
15914 empty_declaration ::=
15915   @b{null} ;
15916 @end smallexample
15917
15918 An empty declaration is allowed anywhere a declaration is allowed.
15919 It has no effect.
15920
15921 @node Typed string declarations
15922 @section Typed string declarations
15923
15924 @noindent
15925 Typed strings are sequences of string literals. Typed strings are the only
15926 named types in project files. They are used in case constructions, where they
15927 provide support for conditional attribute definitions.
15928
15929 Syntax:
15930 @smallexample
15931 typed_string_declaration ::=
15932   @b{type} <typed_string_>_simple_name @b{is}
15933    ( string_literal @{, string_literal@} );
15934 @end smallexample
15935
15936 @noindent
15937 A typed string declaration can only appear immediately within a project
15938 declaration.
15939
15940 All the string literals in a typed string declaration must be distinct.
15941
15942 @node Variables
15943 @section Variables
15944
15945 @noindent
15946 Variables denote values, and appear as constituents of expressions.
15947
15948 @smallexample
15949 typed_variable_declaration ::=
15950   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15951
15952 variable_declaration ::=
15953   <variable_>simple_name := expression;
15954 @end smallexample
15955
15956 @noindent
15957 The elaboration of a variable declaration introduces the variable and
15958 assigns to it the value of the expression. The name of the variable is
15959 available after the assignment symbol.
15960
15961 @noindent
15962 A typed_variable can only be declare once.
15963
15964 @noindent
15965 a non-typed variable can be declared multiple times.
15966
15967 @noindent
15968 Before the completion of its first declaration, the value of variable
15969 is the null string.
15970
15971 @node Expressions
15972 @section Expressions
15973
15974 @noindent
15975 An expression is a formula that defines a computation or retrieval of a value.
15976 In a project file the value of an expression is either a string or a list
15977 of strings. A string value in an expression is either a literal, the current
15978 value of a variable, an external value, an attribute reference, or a
15979 concatenation operation.
15980
15981 Syntax:
15982
15983 @smallexample
15984 expression ::=
15985   term @{& term@}
15986
15987 term ::=
15988   string_literal |
15989   string_list |
15990   <variable_>name |
15991   external_value |
15992   attribute_reference
15993
15994 string_literal ::=
15995   (same as Ada)
15996
15997 string_list ::=
15998   ( <string_>expression @{ , <string_>expression @} )
15999 @end smallexample
16000
16001 @subsection Concatenation
16002 @noindent
16003 The following concatenation functions are defined:
16004
16005 @smallexample @c ada
16006   function "&" (X : String;      Y : String)      return String;
16007   function "&" (X : String_List; Y : String)      return String_List;
16008   function "&" (X : String_List; Y : String_List) return String_List;
16009 @end smallexample
16010
16011 @node Attributes
16012 @section Attributes
16013
16014 @noindent
16015 An attribute declaration defines a property of a project or package. This
16016 property can later be queried by means of an attribute reference.
16017 Attribute values are strings or string lists.
16018
16019 Some attributes are associative arrays. These attributes are mappings whose
16020 domain is a set of strings. These attributes are declared one association
16021 at a time, by specifying a point in the domain and the corresponding image
16022 of the attribute. They may also be declared as a full associative array,
16023 getting the same associations as the corresponding attribute in an imported
16024 or extended project.
16025
16026 Attributes that are not associative arrays are called simple attributes.
16027
16028 Syntax:
16029 @smallexample
16030 attribute_declaration ::=
16031   full_associative_array_declaration |
16032   @b{for} attribute_designator @b{use} expression ;
16033
16034 full_associative_array_declaration ::=
16035   @b{for} <associative_array_attribute_>simple_name @b{use}
16036   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16037
16038 attribute_designator ::=
16039   <simple_attribute_>simple_name |
16040   <associative_array_attribute_>simple_name ( string_literal )
16041 @end smallexample
16042
16043 @noindent
16044 Some attributes are project-specific, and can only appear immediately within
16045 a project declaration. Others are package-specific, and can only appear within
16046 the proper package.
16047
16048 The expression in an attribute definition must be a string or a string_list.
16049 The string literal appearing in the attribute_designator of an associative
16050 array attribute is case-insensitive.
16051
16052 @node Project Attributes
16053 @section Project Attributes
16054
16055 @noindent
16056 The following attributes apply to a project. All of them are simple
16057 attributes.
16058
16059 @table @code
16060 @item   Object_Dir
16061 Expression must be a path name. The attribute defines the
16062 directory in which the object files created by the build are to be placed. If
16063 not specified, object files are placed in the project directory.
16064
16065 @item   Exec_Dir
16066 Expression must be a path name. The attribute defines the
16067 directory in which the executables created by the build are to be placed.
16068 If not specified, executables are placed in the object directory.
16069
16070 @item  Source_Dirs
16071 Expression must be a list of path names. The attribute
16072 defines the directories in which the source files for the project are to be
16073 found. If not specified, source files are found in the project directory.
16074 If a string in the list ends with "/**", then the directory that precedes
16075 "/**" and all of its subdirectories (recursively) are included in the list
16076 of source directories.
16077
16078 @item  Excluded_Source_Dirs
16079 Expression must be a list of strings. Each entry designates a directory that
16080 is not to be included in the list of source directories of the project.
16081 This is normally used when there are strings ending with "/**" in the value
16082 of attribute Source_Dirs.
16083
16084 @item  Source_Files
16085 Expression must be a list of file names. The attribute
16086 defines the individual files, in the project directory, which are to be used
16087 as sources for the project. File names are path_names that contain no directory
16088 information. If the project has no sources the attribute must be declared
16089 explicitly with an empty list.
16090
16091 @item  Excluded_Source_Files (Locally_Removed_Files)
16092 Expression must be a list of strings that are legal file names.
16093 Each file name must designate a source that would normally be a source file
16094 in the source directories of the project or, if the project file is an
16095 extending project file, inherited by the current project file. It cannot
16096 designate an immediate source that is not inherited. Each of the source files
16097 in the list are not considered to be sources of the project file: they are not
16098 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16099 Excluded_Source_Files is preferred.
16100
16101 @item  Source_List_File
16102 Expression must a single path name. The attribute
16103 defines a text file that contains a list of source file names to be used
16104 as sources for the project
16105
16106 @item  Library_Dir
16107 Expression must be a path name. The attribute defines the
16108 directory in which a  library is to be built.  The directory must exist, must
16109 be distinct from the project's object directory, and must be writable.
16110
16111 @item  Library_Name
16112 Expression must be a string that is a legal file name,
16113 without extension. The attribute defines a string that is used to generate
16114 the name of the library to be built by the project.
16115
16116 @item  Library_Kind
16117 Argument must be a string value that must be one of the
16118 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16119 string is case-insensitive. If this attribute is not specified, the library is
16120 a static library. Otherwise, the library may be dynamic or relocatable. This
16121 distinction is operating-system dependent.
16122
16123 @item  Library_Version
16124 Expression must be a string value whose interpretation
16125 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16126 libraries as the internal name of the library (the @code{"soname"}). If the
16127 library file name (built from the @code{Library_Name}) is different from the
16128 @code{Library_Version}, then the library file will be a symbolic link to the
16129 actual file whose name will be @code{Library_Version}.
16130
16131 @item Library_Interface
16132 Expression must be a string list. Each element of the string list
16133 must designate a unit of the project.
16134 If this attribute is present in a Library Project File, then the project
16135 file is a Stand-alone Library_Project_File.
16136
16137 @item Library_Auto_Init
16138 Expression must be a single string "true" or "false", case-insensitive.
16139 If this attribute is present in a Stand-alone Library Project File,
16140 it indicates if initialization is automatic when the dynamic library
16141 is loaded.
16142
16143 @item Library_Options
16144 Expression must be a string list. Indicates additional switches that
16145 are to be used when building a shared library.
16146
16147 @item Library_GCC
16148 Expression must be a single string. Designates an alternative to "gcc"
16149 for building shared libraries.
16150
16151 @item  Library_Src_Dir
16152 Expression must be a path name. The attribute defines the
16153 directory in which the sources of the interfaces of a Stand-alone Library will
16154 be copied.  The directory must exist, must be distinct from the project's
16155 object directory and source directories of all projects in the project tree,
16156 and must be writable.
16157
16158 @item  Library_Src_Dir
16159 Expression must be a path name. The attribute defines the
16160 directory in which the ALI files of a Library will
16161 be copied.  The directory must exist, must be distinct from the project's
16162 object directory and source directories of all projects in the project tree,
16163 and must be writable.
16164
16165 @item  Library_Symbol_File
16166 Expression must be a single string. Its value is the single file name of a
16167 symbol file to be created when building a stand-alone library when the
16168 symbol policy is either "compliant", "controlled" or "restricted",
16169 on platforms that support symbol control, such as VMS. When symbol policy
16170 is "direct", then a file with this name must exist in the object directory.
16171
16172 @item   Library_Reference_Symbol_File
16173 Expression must be a single string. Its value is the path name of a
16174 reference symbol file that is read when the symbol policy is either
16175 "compliant" or "controlled", on platforms that support symbol control,
16176 such as VMS, when building a stand-alone library. The path may be an absolute
16177 path or a path relative to the project directory.
16178
16179 @item  Library_Symbol_Policy
16180 Expression must be a single string. Its case-insensitive value can only be
16181 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16182
16183 This attribute is not taken into account on all platforms. It controls the
16184 policy for exported symbols and, on some platforms (like VMS) that have the
16185 notions of major and minor IDs built in the library files, it controls
16186 the setting of these IDs.
16187
16188 "autonomous" or "default": exported symbols are not controlled.
16189
16190 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16191 it is equivalent to policy "autonomous". If there are exported symbols in
16192 the reference symbol file that are not in the object files of the interfaces,
16193 the major ID of the library is increased. If there are symbols in the
16194 object files of the interfaces that are not in the reference symbol file,
16195 these symbols are put at the end of the list in the newly created symbol file
16196 and the minor ID is increased.
16197
16198 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16199 The library will fail to build if the exported symbols in the object files of
16200 the interfaces do not match exactly the symbol in the symbol file.
16201
16202 "restricted": The attribute Library_Symbol_File must be defined. The library
16203 will fail to build if there are symbols in the symbol file that are not in
16204 the exported symbols of the object files of the interfaces. Additional symbols
16205 in the object files are not added to the symbol file.
16206
16207 "direct": The attribute Library_Symbol_File must be defined and must designate
16208 an existing file in the object directory. This symbol file is passed directly
16209 to the underlying linker without any symbol processing.
16210
16211 @item  Main
16212 Expression must be a list of strings that are legal file names.
16213 These file names designate existing compilation units in the source directory
16214 that are legal main subprograms.
16215
16216 When a project file is elaborated, as part of the execution of a gnatmake
16217 command, one or several executables are built and placed in the Exec_Dir.
16218 If the gnatmake command does not include explicit file names, the executables
16219 that are built correspond to the files specified by this attribute.
16220
16221 @item  Externally_Built
16222 Expression must be a single string. Its value must be either "true" of "false",
16223 case-insensitive. The default is "false". When the value of this attribute is
16224 "true", no attempt is made to compile the sources or to build the library,
16225 when the project is a library project.
16226
16227 @item Main_Language
16228 This is a simple attribute. Its value is a string that specifies the
16229 language of the main program.
16230
16231 @item  Languages
16232 Expression must be a string list. Each string designates
16233 a programming language that is known to GNAT. The strings are case-insensitive.
16234
16235 @end table
16236
16237 @node Attribute References
16238 @section Attribute References
16239
16240 @noindent
16241 Attribute references are used to retrieve the value of previously defined
16242 attribute for a package or project.
16243 Syntax:
16244 @smallexample
16245 attribute_reference ::=
16246   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16247
16248 attribute_prefix ::=
16249   @b{project} |
16250   <project_simple_name | package_identifier |
16251   <project_>simple_name . package_identifier
16252 @end smallexample
16253
16254 @noindent
16255 If an attribute has not been specified for a given package or project, its
16256 value is the null string or the empty list.
16257
16258 @node External Values
16259 @section External Values
16260
16261 @noindent
16262 An external value is an expression whose value is obtained from the command
16263 that invoked the processing of the current project file (typically a
16264 gnatmake command).
16265
16266 Syntax:
16267 @smallexample
16268 external_value ::=
16269   @b{external} ( string_literal [, string_literal] )
16270 @end smallexample
16271
16272 @noindent
16273 The first string_literal is the string to be used on the command line or
16274 in the environment to specify the external value. The second string_literal,
16275 if present, is the default to use if there is no specification for this
16276 external value either on the command line or in the environment.
16277
16278 @node Case Construction
16279 @section Case Construction
16280
16281 @noindent
16282 A case construction supports attribute and variable declarations that depend
16283 on the value of a previously declared variable.
16284
16285 Syntax:
16286 @smallexample
16287 case_construction ::=
16288   @b{case} <typed_variable_>name @b{is}
16289     @{case_item@}
16290   @b{end case} ;
16291
16292 case_item ::=
16293   @b{when} discrete_choice_list =>
16294     @{case_construction |
16295       attribute_declaration |
16296       variable_declaration |
16297       empty_declaration@}
16298
16299 discrete_choice_list ::=
16300   string_literal @{| string_literal@} |
16301     @b{others}
16302 @end smallexample
16303
16304 @noindent
16305 Inside a case construction, variable declarations must be for variables that
16306 have already been declared before the case construction.
16307
16308 All choices in a choice list must be distinct. The choice lists of two
16309 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16310 alternatives do not need to include all values of the type. An @code{others}
16311 choice must appear last in the list of alternatives.
16312
16313 @node Packages
16314 @section Packages
16315
16316 @noindent
16317 A package provides a grouping of variable declarations and attribute
16318 declarations to be used when invoking various GNAT tools. The name of
16319 the package indicates the tool(s) to which it applies.
16320 Syntax:
16321
16322 @smallexample
16323 package_declaration ::=
16324   package_spec | package_renaming
16325
16326 package_spec ::=
16327   @b{package} package_identifier @b{is}
16328     @{simple_declarative_item@}
16329   @b{end} package_identifier ;
16330
16331 package_identifier ::=
16332   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16333   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16334   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16335 @end smallexample
16336
16337 @subsection Package Naming
16338
16339 @noindent
16340 The attributes of a @code{Naming} package specifies the naming conventions
16341 that apply to the source files in a project. When invoking other GNAT tools,
16342 they will use the sources in the source directories that satisfy these
16343 naming conventions.
16344
16345 The following attributes apply to a @code{Naming} package:
16346
16347 @table @code
16348 @item Casing
16349 This is a simple attribute whose value is a string. Legal values of this
16350 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16351 These strings are themselves case insensitive.
16352
16353 @noindent
16354 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16355
16356 @item Dot_Replacement
16357 This is a simple attribute whose string value satisfies the following
16358 requirements:
16359
16360 @itemize @bullet
16361 @item It must not be empty
16362 @item It cannot start or end with an alphanumeric character
16363 @item It cannot be a single underscore
16364 @item It cannot start with an underscore followed by an alphanumeric
16365 @item It cannot contain a dot @code{'.'} if longer than one character
16366 @end itemize
16367
16368 @noindent
16369 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16370
16371 @item Spec_Suffix
16372 This is an associative array attribute, defined on language names,
16373 whose image is a string that must satisfy the following
16374 conditions:
16375
16376 @itemize @bullet
16377 @item It must not be empty
16378 @item It cannot start with an alphanumeric character
16379 @item It cannot start with an underscore followed by an alphanumeric character
16380 @end itemize
16381
16382 @noindent
16383 For Ada, the attribute denotes the suffix used in file names that contain
16384 library unit declarations, that is to say units that are package and
16385 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16386 specified, then the default is @code{".ads"}.
16387
16388 For C and C++, the attribute denotes the suffix used in file names that
16389 contain prototypes.
16390
16391 @item Body_Suffix
16392 This is an associative array attribute defined on language names,
16393 whose image is a string that must satisfy the following
16394 conditions:
16395
16396 @itemize @bullet
16397 @item It must not be empty
16398 @item It cannot start with an alphanumeric character
16399 @item It cannot start with an underscore followed by an alphanumeric character
16400 @item It cannot be a suffix of @code{Spec_Suffix}
16401 @end itemize
16402
16403 @noindent
16404 For Ada, the attribute denotes the suffix used in file names that contain
16405 library bodies, that is to say units that are package and subprogram bodies.
16406 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16407 @code{".adb"}.
16408
16409 For C and C++, the attribute denotes the suffix used in file names that contain
16410 source code.
16411
16412 @item Separate_Suffix
16413 This is a simple attribute whose value satisfies the same conditions as
16414 @code{Body_Suffix}.
16415
16416 This attribute is specific to Ada. It denotes the suffix used in file names
16417 that contain separate bodies. If it is not specified, then it defaults to same
16418 value as @code{Body_Suffix ("Ada")}.
16419
16420 @item Spec
16421 This is an associative array attribute, specific to Ada, defined over
16422 compilation unit names. The image is a string that is the name of the file
16423 that contains that library unit. The file name is case sensitive if the
16424 conventions of the host operating system require it.
16425
16426 @item Body
16427 This is an associative array attribute, specific to Ada, defined over
16428 compilation unit names. The image is a string that is the name of the file
16429 that contains the library unit body for the named unit. The file name is case
16430 sensitive if the conventions of the host operating system require it.
16431
16432 @item Specification_Exceptions
16433 This is an associative array attribute defined on language names,
16434 whose value is a list of strings.
16435
16436 This attribute is not significant for Ada.
16437
16438 For C and C++, each string in the list denotes the name of a file that
16439 contains prototypes, but whose suffix is not necessarily the
16440 @code{Spec_Suffix} for the language.
16441
16442 @item Implementation_Exceptions
16443 This is an associative array attribute defined on language names,
16444 whose value is a list of strings.
16445
16446 This attribute is not significant for Ada.
16447
16448 For C and C++, each string in the list denotes the name of a file that
16449 contains source code, but whose suffix is not necessarily the
16450 @code{Body_Suffix} for the language.
16451 @end table
16452
16453 The following attributes of package @code{Naming} are obsolescent. They are
16454 kept as synonyms of other attributes for compatibility with previous versions
16455 of the Project Manager.
16456
16457 @table @code
16458 @item Specification_Suffix
16459 This is a synonym of @code{Spec_Suffix}.
16460
16461 @item Implementation_Suffix
16462 This is a synonym of @code{Body_Suffix}.
16463
16464 @item Specification
16465 This is a synonym of @code{Spec}.
16466
16467 @item Implementation
16468 This is a synonym of @code{Body}.
16469 @end table
16470
16471 @subsection package Compiler
16472
16473 @noindent
16474 The attributes of the @code{Compiler} package specify the compilation options
16475 to be used by the underlying compiler.
16476
16477 @table @code
16478 @item  Default_Switches
16479 This is an associative array attribute. Its
16480 domain is a set of language names. Its range is a string list that
16481 specifies the compilation options to be used when compiling a component
16482 written in that language, for which no file-specific switches have been
16483 specified.
16484
16485 @item  Switches
16486 This is an associative array attribute. Its domain is
16487 a set of file names. Its range is a string list that specifies the
16488 compilation options to be used when compiling the named file. If a file
16489 is not specified in the Switches attribute, it is compiled with the
16490 options specified by Default_Switches of its language, if defined.
16491
16492 @item  Local_Configuration_Pragmas.
16493 This is a simple attribute, whose
16494 value is a path name that designates a file containing configuration pragmas
16495 to be used for all invocations of the compiler for immediate sources of the
16496 project.
16497 @end table
16498
16499 @subsection package Builder
16500
16501 @noindent
16502 The attributes of package @code{Builder} specify the compilation, binding, and
16503 linking options to be used when building an executable for a project. The
16504 following attributes apply to package @code{Builder}:
16505
16506 @table @code
16507 @item Default_Switches
16508 This is an associative array attribute. Its
16509 domain is a set of language names. Its range is a string list that
16510 specifies options to be used when building a main
16511 written in that language, for which no file-specific switches have been
16512 specified.
16513
16514 @item Switches
16515 This is an associative array attribute. Its domain is
16516 a set of file names. Its range is a string list that specifies
16517 options to be used when building the named main file. If a main file
16518 is not specified in the Switches attribute, it is built with the
16519 options specified by Default_Switches of its language, if defined.
16520
16521 @item Global_Configuration_Pragmas
16522 This is a simple attribute, whose
16523 value is a path name that designates a file that contains configuration pragmas
16524 to be used in every build of an executable. If both local and global
16525 configuration pragmas are specified, a compilation makes use of both sets.
16526
16527
16528 @item Executable
16529 This is an associative array attribute. Its domain is
16530 a set of main source file names. Its range is a simple string that specifies
16531 the executable file name to be used when linking the specified main source.
16532 If a main source is not specified in the Executable attribute, the executable
16533 file name is deducted from the main source file name.
16534 This attribute has no effect if its value is the empty string.
16535
16536 @item Executable_Suffix
16537 This is a simple attribute whose value is the suffix to be added to
16538 the executables that don't have an attribute Executable specified.
16539 @end table
16540
16541 @subsection package Gnatls
16542
16543 @noindent
16544 The attributes of package @code{Gnatls} specify the tool options to be used
16545 when invoking the library browser @command{gnatls}.
16546 The following attributes apply to package @code{Gnatls}:
16547
16548 @table @code
16549 @item Switches
16550 This is a single attribute with a string list value. Each nonempty string
16551 in the list is an option when invoking @code{gnatls}.
16552 @end table
16553
16554 @subsection package Binder
16555
16556 @noindent
16557 The attributes of package @code{Binder} specify the options to be used
16558 when invoking the binder in the construction of an executable.
16559 The following attributes apply to package @code{Binder}:
16560
16561 @table @code
16562 @item     Default_Switches
16563 This is an associative array attribute. Its
16564 domain is a set of language names. Its range is a string list that
16565 specifies options to be used when binding a main
16566 written in that language, for which no file-specific switches have been
16567 specified.
16568
16569 @item Switches
16570 This is an associative array attribute. Its domain is
16571 a set of file names. Its range is a string list that specifies
16572 options to be used when binding the named main file. If a main file
16573 is not specified in the Switches attribute, it is bound with the
16574 options specified by Default_Switches of its language, if defined.
16575 @end table
16576
16577 @subsection package Linker
16578
16579 @noindent
16580 The attributes of package @code{Linker} specify the options to be used when
16581 invoking the linker in the construction of an executable.
16582 The following attributes apply to package @code{Linker}:
16583
16584 @table @code
16585 @item     Default_Switches
16586 This is an associative array attribute. Its
16587 domain is a set of language names. Its range is a string list that
16588 specifies options to be used when linking a main
16589 written in that language, for which no file-specific switches have been
16590 specified.
16591
16592 @item Switches
16593 This is an associative array attribute. Its domain is
16594 a set of file names. Its range is a string list that specifies
16595 options to be used when linking the named main file. If a main file
16596 is not specified in the Switches attribute, it is linked with the
16597 options specified by Default_Switches of its language, if defined.
16598
16599 @item  Linker_Options
16600 This is a string list attribute. Its value specifies additional options that
16601 be given to the linker when linking an executable. This attribute is not
16602 used in the main project, only in projects imported directly or indirectly.
16603
16604 @end table
16605
16606 @subsection package Cross_Reference
16607
16608 @noindent
16609 The attributes of package @code{Cross_Reference} specify the tool options
16610 to be used
16611 when invoking the library tool @command{gnatxref}.
16612 The following attributes apply to package @code{Cross_Reference}:
16613
16614 @table @code
16615 @item     Default_Switches
16616 This is an associative array attribute. Its
16617 domain is a set of language names. Its range is a string list that
16618 specifies options to be used when calling @command{gnatxref} on a source
16619 written in that language, for which no file-specific switches have been
16620 specified.
16621
16622 @item Switches
16623 This is an associative array attribute. Its domain is
16624 a set of file names. Its range is a string list that specifies
16625 options to be used when calling @command{gnatxref} on the named main source.
16626 If a source is not specified in the Switches attribute, @command{gnatxref} will
16627 be called with the options specified by Default_Switches of its language,
16628 if defined.
16629 @end table
16630
16631 @subsection package   Finder
16632
16633 @noindent
16634 The attributes of package @code{Finder} specify the tool options to be used
16635 when invoking the search tool @command{gnatfind}.
16636 The following attributes apply to package @code{Finder}:
16637
16638 @table @code
16639 @item     Default_Switches
16640 This is an associative array attribute. Its
16641 domain is a set of language names. Its range is a string list that
16642 specifies options to be used when calling @command{gnatfind} on a source
16643 written in that language, for which no file-specific switches have been
16644 specified.
16645
16646 @item Switches
16647 This is an associative array attribute. Its domain is
16648 a set of file names. Its range is a string list that specifies
16649 options to be used when calling @command{gnatfind} on the named main source.
16650 If a source is not specified in the Switches attribute, @command{gnatfind} will
16651 be called with the options specified by Default_Switches of its language,
16652 if defined.
16653 @end table
16654
16655 @subsection package Pretty_Printer
16656
16657 @noindent
16658 The attributes of package @code{Pretty_Printer}
16659 specify the tool options to be used
16660 when invoking the formatting tool @command{gnatpp}.
16661 The following attributes apply to package @code{Pretty_Printer}:
16662
16663 @table @code
16664 @item     Default_switches
16665 This is an associative array attribute. Its
16666 domain is a set of language names. Its range is a string list that
16667 specifies options to be used when calling @command{gnatpp} on a source
16668 written in that language, for which no file-specific switches have been
16669 specified.
16670
16671 @item Switches
16672 This is an associative array attribute. Its domain is
16673 a set of file names. Its range is a string list that specifies
16674 options to be used when calling @command{gnatpp} on the named main source.
16675 If a source is not specified in the Switches attribute, @command{gnatpp} will
16676 be called with the options specified by Default_Switches of its language,
16677 if defined.
16678 @end table
16679
16680 @subsection package gnatstub
16681
16682 @noindent
16683 The attributes of package @code{gnatstub}
16684 specify the tool options to be used
16685 when invoking the tool @command{gnatstub}.
16686 The following attributes apply to package @code{gnatstub}:
16687
16688 @table @code
16689 @item     Default_switches
16690 This is an associative array attribute. Its
16691 domain is a set of language names. Its range is a string list that
16692 specifies options to be used when calling @command{gnatstub} on a source
16693 written in that language, for which no file-specific switches have been
16694 specified.
16695
16696 @item Switches
16697 This is an associative array attribute. Its domain is
16698 a set of file names. Its range is a string list that specifies
16699 options to be used when calling @command{gnatstub} on the named main source.
16700 If a source is not specified in the Switches attribute, @command{gnatpp} will
16701 be called with the options specified by Default_Switches of its language,
16702 if defined.
16703 @end table
16704
16705 @subsection package Eliminate
16706
16707 @noindent
16708 The attributes of package @code{Eliminate}
16709 specify the tool options to be used
16710 when invoking the tool @command{gnatelim}.
16711 The following attributes apply to package @code{Eliminate}:
16712
16713 @table @code
16714 @item     Default_switches
16715 This is an associative array attribute. Its
16716 domain is a set of language names. Its range is a string list that
16717 specifies options to be used when calling @command{gnatelim} on a source
16718 written in that language, for which no file-specific switches have been
16719 specified.
16720
16721 @item Switches
16722 This is an associative array attribute. Its domain is
16723 a set of file names. Its range is a string list that specifies
16724 options to be used when calling @command{gnatelim} on the named main source.
16725 If a source is not specified in the Switches attribute, @command{gnatelim} will
16726 be called with the options specified by Default_Switches of its language,
16727 if defined.
16728 @end table
16729
16730 @subsection package Metrics
16731
16732 @noindent
16733 The attributes of package @code{Metrics}
16734 specify the tool options to be used
16735 when invoking the tool @command{gnatmetric}.
16736 The following attributes apply to package @code{Metrics}:
16737
16738 @table @code
16739 @item     Default_switches
16740 This is an associative array attribute. Its
16741 domain is a set of language names. Its range is a string list that
16742 specifies options to be used when calling @command{gnatmetric} on a source
16743 written in that language, for which no file-specific switches have been
16744 specified.
16745
16746 @item Switches
16747 This is an associative array attribute. Its domain is
16748 a set of file names. Its range is a string list that specifies
16749 options to be used when calling @command{gnatmetric} on the named main source.
16750 If a source is not specified in the Switches attribute, @command{gnatmetric}
16751 will be called with the options specified by Default_Switches of its language,
16752 if defined.
16753 @end table
16754
16755 @subsection  package IDE
16756
16757 @noindent
16758 The attributes of package @code{IDE} specify the options to be used when using
16759 an Integrated Development Environment such as @command{GPS}.
16760
16761 @table @code
16762 @item Remote_Host
16763 This is a simple attribute. Its value is a string that designates the remote
16764 host in a cross-compilation environment, to be used for remote compilation and
16765 debugging. This field should not be specified when running on the local
16766 machine.
16767
16768 @item Program_Host
16769 This is a simple attribute. Its value is a string that specifies the
16770 name of IP address of the embedded target in a cross-compilation environment,
16771 on which the program should execute.
16772
16773 @item Communication_Protocol
16774 This is a simple string attribute. Its value is the name of the protocol
16775 to use to communicate with the target in a cross-compilation environment,
16776 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16777
16778 @item Compiler_Command
16779 This is an associative array attribute, whose domain is a language name. Its
16780 value is  string that denotes the command to be used to invoke the compiler.
16781 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16782 gnatmake, in particular in the handling of switches.
16783
16784 @item Debugger_Command
16785 This is simple attribute, Its value is a string that specifies the name of
16786 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16787
16788 @item Default_Switches
16789 This is an associative array attribute. Its indexes are the name of the
16790 external tools that the GNAT Programming System (GPS) is supporting. Its
16791 value is a list of switches to use when invoking that tool.
16792
16793 @item  Gnatlist
16794 This is a simple attribute.  Its value is a string that specifies the name
16795 of the @command{gnatls} utility to be used to retrieve information about the
16796 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16797
16798 @item VCS_Kind
16799 This is a simple attribute. Its value is a string used to specify the
16800 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16801 ClearCase or Perforce.
16802
16803 @item VCS_File_Check
16804 This is a simple attribute. Its value is a string that specifies the
16805 command used by the VCS to check the validity of a file, either
16806 when the user explicitly asks for a check, or as a sanity check before
16807 doing the check-in.
16808
16809 @item VCS_Log_Check
16810 This is a simple attribute. Its value is a string that specifies
16811 the command used by the VCS to check the validity of a log file.
16812
16813 @item VCS_Repository_Root
16814 The VCS repository root path. This is used to create tags or branches
16815 of the repository. For subversion the value should be the @code{URL}
16816 as specified to check-out the working copy of the repository.
16817
16818 @item VCS_Patch_Root
16819 The local root directory to use for building patch file. All patch chunks
16820 will be relative to this path. The root project directory is used if
16821 this value is not defined.
16822
16823 @end table
16824
16825 @node Package Renamings
16826 @section Package Renamings
16827
16828 @noindent
16829 A package can be defined by a renaming declaration. The new package renames
16830 a package declared in a different project file, and has the same attributes
16831 as the package it renames.
16832 Syntax:
16833 @smallexample
16834 package_renaming ::==
16835   @b{package} package_identifier @b{renames}
16836        <project_>simple_name.package_identifier ;
16837 @end smallexample
16838
16839 @noindent
16840 The package_identifier of the renamed package must be the same as the
16841 package_identifier. The project whose name is the prefix of the renamed
16842 package must contain a package declaration with this name. This project
16843 must appear in the context_clause of the enclosing project declaration,
16844 or be the parent project of the enclosing child project.
16845
16846 @node Projects
16847 @section Projects
16848
16849 @noindent
16850 A project file specifies a set of rules for constructing a software system.
16851 A project file can be self-contained, or depend on other project files.
16852 Dependencies are expressed through a context clause that names other projects.
16853
16854 Syntax:
16855
16856 @smallexample
16857 project ::=
16858   context_clause project_declaration
16859
16860 project_declaration ::=
16861   simple_project_declaration | project_extension
16862
16863 simple_project_declaration ::=
16864   @b{project} <project_>simple_name @b{is}
16865     @{declarative_item@}
16866   @b{end} <project_>simple_name;
16867
16868 context_clause ::=
16869   @{with_clause@}
16870
16871 with_clause ::=
16872   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16873
16874 path_name ::=
16875    string_literal
16876 @end smallexample
16877
16878 @noindent
16879 A path name denotes a project file. A path name can be absolute or relative.
16880 An absolute path name includes a sequence of directories, in the syntax of
16881 the host operating system, that identifies uniquely the project file in the
16882 file system. A relative path name identifies the project file, relative
16883 to the directory that contains the current project, or relative to a
16884 directory listed in the environment variable ADA_PROJECT_PATH.
16885 Path names are case sensitive if file names in the host operating system
16886 are case sensitive.
16887
16888 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16889 directory names separated by colons (semicolons on Windows).
16890
16891 A given project name can appear only once in a context_clause.
16892
16893 It is illegal for a project imported by a context clause to refer, directly
16894 or indirectly, to the project in which this context clause appears (the
16895 dependency graph cannot contain cycles), except when one of the with_clause
16896 in the cycle is a @code{limited with}.
16897
16898 @node Project Extensions
16899 @section Project Extensions
16900
16901 @noindent
16902 A project extension introduces a new project, which inherits the declarations
16903 of another project.
16904 Syntax:
16905 @smallexample
16906
16907 project_extension ::=
16908   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16909     @{declarative_item@}
16910   @b{end} <project_>simple_name;
16911 @end smallexample
16912
16913 @noindent
16914 The project extension declares a child project. The child project inherits
16915 all the declarations and all the files of the parent project, These inherited
16916 declaration can be overridden in the child project, by means of suitable
16917 declarations.
16918
16919 @node Project File Elaboration
16920 @section Project File Elaboration
16921
16922 @noindent
16923 A project file is processed as part of the invocation of a gnat tool that
16924 uses the project option. Elaboration of the process file consists in the
16925 sequential elaboration of all its declarations. The computed values of
16926 attributes and variables in the project are then used to establish the
16927 environment in which the gnat tool will execute.
16928
16929 @node Obsolescent Features
16930 @chapter Obsolescent Features
16931
16932 @noindent
16933 This chapter describes features that are provided by GNAT, but are
16934 considered obsolescent since there are preferred ways of achieving
16935 the same effect. These features are provided solely for historical
16936 compatibility purposes.
16937
16938 @menu
16939 * pragma No_Run_Time::
16940 * pragma Ravenscar::
16941 * pragma Restricted_Run_Time::
16942 @end menu
16943
16944 @node pragma No_Run_Time
16945 @section pragma No_Run_Time
16946
16947 The pragma @code{No_Run_Time} is used to achieve an affect similar
16948 to the use of the "Zero Foot Print" configurable run time, but without
16949 requiring a specially configured run time. The result of using this
16950 pragma, which must be used for all units in a partition, is to restrict
16951 the use of any language features requiring run-time support code. The
16952 preferred usage is to use an appropriately configured run-time that
16953 includes just those features that are to be made accessible.
16954
16955 @node pragma Ravenscar
16956 @section pragma Ravenscar
16957
16958 The pragma @code{Ravenscar} has exactly the same effect as pragma
16959 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16960 is part of the new Ada 2005 standard.
16961
16962 @node pragma Restricted_Run_Time
16963 @section pragma Restricted_Run_Time
16964
16965 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16966 pragma @code{Profile (Restricted)}. The latter usage is
16967 preferred since the Ada 2005 pragma @code{Profile} is intended for
16968 this kind of implementation dependent addition.
16969
16970 @include fdl.texi
16971 @c GNU Free Documentation License
16972
16973 @node Index,,GNU Free Documentation License, Top
16974 @unnumbered Index
16975
16976 @printindex cp
16977
16978 @contents
16979
16980 @bye