OSDN Git Service

2009-07-23 Olivier Hainque <hainque@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.2 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts.  A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index::
88
89  --- The Detailed Node Listing ---
90
91 About This Guide
92
93 * What This Reference Manual Contains::
94 * Related Information::
95
96 Implementation Defined Pragmas
97
98 * Pragma Abort_Defer::
99 * Pragma Ada_83::
100 * Pragma Ada_95::
101 * Pragma Ada_05::
102 * Pragma Ada_2005::
103 * Pragma Annotate::
104 * Pragma Assert::
105 * Pragma Assume_No_Invalid_Values::
106 * Pragma Ast_Entry::
107 * Pragma C_Pass_By_Copy::
108 * Pragma Check::
109 * Pragma Check_Name::
110 * Pragma Check_Policy::
111 * Pragma Comment::
112 * Pragma Common_Object::
113 * Pragma Compile_Time_Error::
114 * Pragma Compile_Time_Warning::
115 * Pragma Complete_Representation::
116 * Pragma Complex_Representation::
117 * Pragma Component_Alignment::
118 * Pragma Convention_Identifier::
119 * Pragma CPP_Class::
120 * Pragma CPP_Constructor::
121 * Pragma CPP_Virtual::
122 * Pragma CPP_Vtable::
123 * Pragma Debug::
124 * Pragma Debug_Policy::
125 * Pragma Detect_Blocking::
126 * Pragma Elaboration_Checks::
127 * Pragma Eliminate::
128 * Pragma Export_Exception::
129 * Pragma Export_Function::
130 * Pragma Export_Object::
131 * Pragma Export_Procedure::
132 * Pragma Export_Value::
133 * Pragma Export_Valued_Procedure::
134 * Pragma Extend_System::
135 * Pragma External::
136 * Pragma External_Name_Casing::
137 * Pragma Fast_Math::
138 * Pragma Favor_Top_Level::
139 * Pragma Finalize_Storage_Only::
140 * Pragma Float_Representation::
141 * Pragma Ident::
142 * Pragma Implemented_By_Entry::
143 * Pragma Implicit_Packing::
144 * Pragma Import_Exception::
145 * Pragma Import_Function::
146 * Pragma Import_Object::
147 * Pragma Import_Procedure::
148 * Pragma Import_Valued_Procedure::
149 * Pragma Initialize_Scalars::
150 * Pragma Inline_Always::
151 * Pragma Inline_Generic::
152 * Pragma Interface::
153 * Pragma Interface_Name::
154 * Pragma Interrupt_Handler::
155 * Pragma Interrupt_State::
156 * Pragma Keep_Names::
157 * Pragma License::
158 * Pragma Link_With::
159 * Pragma Linker_Alias::
160 * Pragma Linker_Constructor::
161 * Pragma Linker_Destructor::
162 * Pragma Linker_Section::
163 * Pragma Long_Float::
164 * Pragma Machine_Attribute::
165 * Pragma Main::
166 * Pragma Main_Storage::
167 * Pragma No_Body::
168 * Pragma No_Return::
169 * Pragma No_Strict_Aliasing ::
170 * Pragma Normalize_Scalars::
171 * Pragma Obsolescent::
172 * Pragma Optimize_Alignment::
173 * Pragma Passive::
174 * Pragma Persistent_BSS::
175 * Pragma Polling::
176 * Pragma Postcondition::
177 * Pragma Precondition::
178 * Pragma Profile (Ravenscar)::
179 * Pragma Profile (Restricted)::
180 * Pragma Psect_Object::
181 * Pragma Pure_Function::
182 * Pragma Restriction_Warnings::
183 * Pragma Shared::
184 * Pragma Source_File_Name::
185 * Pragma Source_File_Name_Project::
186 * Pragma Source_Reference::
187 * Pragma Stream_Convert::
188 * Pragma Style_Checks::
189 * Pragma Subtitle::
190 * Pragma Suppress::
191 * Pragma Suppress_All::
192 * Pragma Suppress_Exception_Locations::
193 * Pragma Suppress_Initialization::
194 * Pragma Task_Info::
195 * Pragma Task_Name::
196 * Pragma Task_Storage::
197 * Pragma Thread_Local_Storage::
198 * Pragma Time_Slice::
199 * Pragma Title::
200 * Pragma Unchecked_Union::
201 * Pragma Unimplemented_Unit::
202 * Pragma Universal_Aliasing ::
203 * Pragma Universal_Data::
204 * Pragma Unmodified::
205 * Pragma Unreferenced::
206 * Pragma Unreferenced_Objects::
207 * Pragma Unreserve_All_Interrupts::
208 * Pragma Unsuppress::
209 * Pragma Use_VADS_Size::
210 * Pragma Validity_Checks::
211 * Pragma Volatile::
212 * Pragma Warnings::
213 * Pragma Weak_External::
214 * Pragma Wide_Character_Encoding::
215
216 Implementation Defined Attributes
217
218 * Abort_Signal::
219 * Address_Size::
220 * Asm_Input::
221 * Asm_Output::
222 * AST_Entry::
223 * Bit::
224 * Bit_Position::
225 * 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.SSE (g-sse.ads)::
385 * GNAT.SSE.Internal_Types (g-ssinty.ads)::
386 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
387 * GNAT.Strings (g-string.ads)::
388 * GNAT.String_Split (g-strspl.ads)::
389 * GNAT.Table (g-table.ads)::
390 * GNAT.Task_Lock (g-tasloc.ads)::
391 * GNAT.Threads (g-thread.ads)::
392 * GNAT.Time_Stamp (g-timsta.ads)::
393 * GNAT.Traceback (g-traceb.ads)::
394 * GNAT.Traceback.Symbolic (g-trasym.ads)::
395 * GNAT.UTF_32 (g-utf_32.ads)::
396 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
397 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
398 * GNAT.Wide_String_Split (g-wistsp.ads)::
399 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
400 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
401 * Interfaces.C.Extensions (i-cexten.ads)::
402 * Interfaces.C.Streams (i-cstrea.ads)::
403 * Interfaces.CPP (i-cpp.ads)::
404 * Interfaces.Packed_Decimal (i-pacdec.ads)::
405 * Interfaces.VxWorks (i-vxwork.ads)::
406 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
407 * System.Address_Image (s-addima.ads)::
408 * System.Assertions (s-assert.ads)::
409 * System.Memory (s-memory.ads)::
410 * System.Partition_Interface (s-parint.ads)::
411 * System.Pool_Global (s-pooglo.ads)::
412 * System.Pool_Local (s-pooloc.ads)::
413 * System.Restrictions (s-restri.ads)::
414 * System.Rident (s-rident.ads)::
415 * System.Strings.Stream_Ops (s-ststop.ads)::
416 * System.Task_Info (s-tasinf.ads)::
417 * System.Wch_Cnv (s-wchcnv.ads)::
418 * System.Wch_Con (s-wchcon.ads)::
419
420 Text_IO
421
422 * Text_IO Stream Pointer Positioning::
423 * Text_IO Reading and Writing Non-Regular Files::
424 * Get_Immediate::
425 * Treating Text_IO Files as Streams::
426 * Text_IO Extensions::
427 * Text_IO Facilities for Unbounded Strings::
428
429 Wide_Text_IO
430
431 * Wide_Text_IO Stream Pointer Positioning::
432 * Wide_Text_IO Reading and Writing Non-Regular Files::
433
434 Wide_Wide_Text_IO
435
436 * Wide_Wide_Text_IO Stream Pointer Positioning::
437 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
438
439 Interfacing to Other Languages
440
441 * Interfacing to C::
442 * Interfacing to C++::
443 * Interfacing to COBOL::
444 * Interfacing to Fortran::
445 * Interfacing to non-GNAT Ada code::
446
447 Specialized Needs Annexes
448
449 Implementation of Specific Ada Features
450 * Machine Code Insertions::
451 * GNAT Implementation of Tasking::
452 * GNAT Implementation of Shared Passive Packages::
453 * Code Generation for Array Aggregates::
454 * The Size of Discriminated Records with Default Discriminants::
455 * Strict Conformance to the Ada Reference Manual::
456
457 Project File Reference
458
459 Obsolescent Features
460
461 GNU Free Documentation License
462
463 Index
464 @end menu
465
466 @end ifnottex
467
468 @node About This Guide
469 @unnumbered About This Guide
470
471 @noindent
472 This manual contains useful information in writing programs using the
473 @value{EDITION} compiler.  It includes information on implementation dependent
474 characteristics of @value{EDITION}, including all the information required by
475 Annex M of the Ada language standard.
476
477 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
478 Ada 83 compatibility mode.
479 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
480 but you can override with a compiler switch
481 to explicitly specify the language version.
482 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
483 @value{EDITION} User's Guide}, for details on these switches.)
484 Throughout this manual, references to ``Ada'' without a year suffix
485 apply to both the Ada 95 and Ada 2005 versions of the language.
486
487 Ada is designed to be highly portable.
488 In general, a program will have the same effect even when compiled by
489 different compilers on different platforms.
490 However, since Ada is designed to be used in a
491 wide variety of applications, it also contains a number of system
492 dependent features to be used in interfacing to the external world.
493 @cindex Implementation-dependent features
494 @cindex Portability
495
496 Note: Any program that makes use of implementation-dependent features
497 may be non-portable.  You should follow good programming practice and
498 isolate and clearly document any sections of your program that make use
499 of these features in a non-portable manner.
500
501 @ifset PROEDITION
502 For ease of exposition, ``GNAT Pro'' will be referred to simply as
503 ``GNAT'' in the remainder of this document.
504 @end ifset
505
506 @menu
507 * What This Reference Manual Contains::
508 * Conventions::
509 * Related Information::
510 @end menu
511
512 @node What This Reference Manual Contains
513 @unnumberedsec What This Reference Manual Contains
514
515 @noindent
516 This reference manual contains the following chapters:
517
518 @itemize @bullet
519 @item
520 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
521 pragmas, which can be used to extend and enhance the functionality of the
522 compiler.
523
524 @item
525 @ref{Implementation Defined Attributes}, lists GNAT
526 implementation-dependent attributes which can be used to extend and
527 enhance the functionality of the compiler.
528
529 @item
530 @ref{Implementation Advice}, provides information on generally
531 desirable behavior which are not requirements that all compilers must
532 follow since it cannot be provided on all systems, or which may be
533 undesirable on some systems.
534
535 @item
536 @ref{Implementation Defined Characteristics}, provides a guide to
537 minimizing implementation dependent features.
538
539 @item
540 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
541 implemented by GNAT, and how they can be imported into user
542 application programs.
543
544 @item
545 @ref{Representation Clauses and Pragmas}, describes in detail the
546 way that GNAT represents data, and in particular the exact set
547 of representation clauses and pragmas that is accepted.
548
549 @item
550 @ref{Standard Library Routines}, provides a listing of packages and a
551 brief description of the functionality that is provided by Ada's
552 extensive set of standard library routines as implemented by GNAT@.
553
554 @item
555 @ref{The Implementation of Standard I/O}, details how the GNAT
556 implementation of the input-output facilities.
557
558 @item
559 @ref{The GNAT Library}, is a catalog of packages that complement
560 the Ada predefined library.
561
562 @item
563 @ref{Interfacing to Other Languages}, describes how programs
564 written in Ada using GNAT can be interfaced to other programming
565 languages.
566
567 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
568 of the specialized needs annexes.
569
570 @item
571 @ref{Implementation of Specific Ada Features}, discusses issues related
572 to GNAT's implementation of machine code insertions, tasking, and several
573 other features.
574
575 @item
576 @ref{Project File Reference}, presents the syntax and semantics
577 of project files.
578
579 @item
580 @ref{Obsolescent Features} documents implementation dependent features,
581 including pragmas and attributes, which are considered obsolescent, since
582 there are other preferred ways of achieving the same results. These
583 obsolescent forms are retained for backwards compatibility.
584
585 @end itemize
586
587 @cindex Ada 95 Language Reference Manual
588 @cindex Ada 2005 Language Reference Manual
589 @noindent
590 This reference manual assumes a basic familiarity with the Ada 95 language, as
591 described in the International Standard ANSI/ISO/IEC-8652:1995,
592 January 1995.
593 It does not require knowledge of the new features introduced by Ada 2005,
594 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
595 and Amendment 1).
596 Both reference manuals are included in the GNAT documentation
597 package.
598
599 @node Conventions
600 @unnumberedsec Conventions
601 @cindex Conventions, typographical
602 @cindex Typographical conventions
603
604 @noindent
605 Following are examples of the typographical and graphic conventions used
606 in this guide:
607
608 @itemize @bullet
609 @item
610 @code{Functions}, @code{utility program names}, @code{standard names},
611 and @code{classes}.
612
613 @item
614 @code{Option flags}
615
616 @item
617 @file{File names}, @samp{button names}, and @samp{field names}.
618
619 @item
620 @code{Variables}, @env{environment variables}, and @var{metasyntactic
621 variables}.
622
623 @item
624 @emph{Emphasis}.
625
626 @item
627 [optional information or parameters]
628
629 @item
630 Examples are described by text
631 @smallexample
632 and then shown this way.
633 @end smallexample
634 @end itemize
635
636 @noindent
637 Commands that are entered by the user are preceded in this manual by the
638 characters @samp{$ } (dollar sign followed by space).  If your system uses this
639 sequence as a prompt, then the commands will appear exactly as you see them
640 in the manual.  If your system uses some other prompt, then the command will
641 appear with the @samp{$} replaced by whatever prompt character you are using.
642
643 @node Related Information
644 @unnumberedsec Related Information
645 @noindent
646 See the following documents for further information on GNAT:
647
648 @itemize @bullet
649 @item
650 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
651 @value{EDITION} User's Guide}, which provides information on how to use the
652 GNAT compiler system.
653
654 @item
655 @cite{Ada 95 Reference Manual}, which contains all reference
656 material for the Ada 95 programming language.
657
658 @item
659 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
660 of the Ada 95 standard.  The annotations describe
661 detailed aspects of the design decision, and in particular contain useful
662 sections on Ada 83 compatibility.
663
664 @item
665 @cite{Ada 2005 Reference Manual}, which contains all reference
666 material for the Ada 2005 programming language.
667
668 @item
669 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
670 of the Ada 2005 standard.  The annotations describe
671 detailed aspects of the design decision, and in particular contain useful
672 sections on Ada 83 and Ada 95 compatibility.
673
674 @item
675 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
676 which contains specific information on compatibility between GNAT and
677 DEC Ada 83 systems.
678
679 @item
680 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
681 describes in detail the pragmas and attributes provided by the DEC Ada 83
682 compiler system.
683
684 @end itemize
685
686 @node Implementation Defined Pragmas
687 @chapter Implementation Defined Pragmas
688
689 @noindent
690 Ada defines a set of pragmas that can be used to supply additional
691 information to the compiler.  These language defined pragmas are
692 implemented in GNAT and work as described in the Ada Reference Manual.
693
694 In addition, Ada allows implementations to define additional pragmas
695 whose meaning is defined by the implementation.  GNAT provides a number
696 of these implementation-defined pragmas, which can be used to extend
697 and enhance the functionality of the compiler.  This section of the GNAT
698 Reference Manual describes these additional pragmas.
699
700 Note that any program using these pragmas might not be portable to other
701 compilers (although GNAT implements this set of pragmas on all
702 platforms).  Therefore if portability to other compilers is an important
703 consideration, the use of these pragmas should be minimized.
704
705 @menu
706 * Pragma Abort_Defer::
707 * Pragma Ada_83::
708 * Pragma Ada_95::
709 * Pragma Ada_05::
710 * Pragma Ada_2005::
711 * Pragma Annotate::
712 * Pragma Assert::
713 * Pragma Assume_No_Invalid_Values::
714 * Pragma Ast_Entry::
715 * Pragma C_Pass_By_Copy::
716 * Pragma Check::
717 * Pragma Check_Name::
718 * Pragma Check_Policy::
719 * Pragma Comment::
720 * Pragma Common_Object::
721 * Pragma Compile_Time_Error::
722 * Pragma Compile_Time_Warning::
723 * Pragma Complete_Representation::
724 * Pragma Complex_Representation::
725 * Pragma Component_Alignment::
726 * Pragma Convention_Identifier::
727 * Pragma CPP_Class::
728 * Pragma CPP_Constructor::
729 * Pragma CPP_Virtual::
730 * Pragma CPP_Vtable::
731 * Pragma Debug::
732 * Pragma Debug_Policy::
733 * Pragma Detect_Blocking::
734 * Pragma Elaboration_Checks::
735 * Pragma Eliminate::
736 * Pragma Export_Exception::
737 * Pragma Export_Function::
738 * Pragma Export_Object::
739 * Pragma Export_Procedure::
740 * Pragma Export_Value::
741 * Pragma Export_Valued_Procedure::
742 * Pragma Extend_System::
743 * Pragma External::
744 * Pragma External_Name_Casing::
745 * Pragma Fast_Math::
746 * Pragma Favor_Top_Level::
747 * Pragma Finalize_Storage_Only::
748 * Pragma Float_Representation::
749 * Pragma Ident::
750 * Pragma Implemented_By_Entry::
751 * Pragma Implicit_Packing::
752 * Pragma Import_Exception::
753 * Pragma Import_Function::
754 * Pragma Import_Object::
755 * Pragma Import_Procedure::
756 * Pragma Import_Valued_Procedure::
757 * Pragma Initialize_Scalars::
758 * Pragma Inline_Always::
759 * Pragma Inline_Generic::
760 * Pragma Interface::
761 * Pragma Interface_Name::
762 * Pragma Interrupt_Handler::
763 * Pragma Interrupt_State::
764 * Pragma Keep_Names::
765 * Pragma License::
766 * Pragma Link_With::
767 * Pragma Linker_Alias::
768 * Pragma Linker_Constructor::
769 * Pragma Linker_Destructor::
770 * Pragma Linker_Section::
771 * Pragma Long_Float::
772 * Pragma Machine_Attribute::
773 * Pragma Main::
774 * Pragma Main_Storage::
775 * Pragma No_Body::
776 * Pragma No_Return::
777 * Pragma No_Strict_Aliasing::
778 * Pragma Normalize_Scalars::
779 * Pragma Obsolescent::
780 * Pragma Optimize_Alignment::
781 * Pragma Passive::
782 * Pragma Persistent_BSS::
783 * Pragma Polling::
784 * Pragma Postcondition::
785 * Pragma Precondition::
786 * Pragma Profile (Ravenscar)::
787 * Pragma Profile (Restricted)::
788 * Pragma Psect_Object::
789 * Pragma Pure_Function::
790 * Pragma Restriction_Warnings::
791 * Pragma Shared::
792 * Pragma Source_File_Name::
793 * Pragma Source_File_Name_Project::
794 * Pragma Source_Reference::
795 * Pragma Stream_Convert::
796 * Pragma Style_Checks::
797 * Pragma Subtitle::
798 * Pragma Suppress::
799 * Pragma Suppress_All::
800 * Pragma Suppress_Exception_Locations::
801 * Pragma Suppress_Initialization::
802 * Pragma Task_Info::
803 * Pragma Task_Name::
804 * Pragma Task_Storage::
805 * Pragma Thread_Local_Storage::
806 * Pragma Time_Slice::
807 * Pragma Title::
808 * Pragma Unchecked_Union::
809 * Pragma Unimplemented_Unit::
810 * Pragma Universal_Aliasing ::
811 * Pragma Universal_Data::
812 * Pragma Unmodified::
813 * Pragma Unreferenced::
814 * Pragma Unreferenced_Objects::
815 * Pragma Unreserve_All_Interrupts::
816 * Pragma Unsuppress::
817 * Pragma Use_VADS_Size::
818 * Pragma Validity_Checks::
819 * Pragma Volatile::
820 * Pragma Warnings::
821 * Pragma Weak_External::
822 * Pragma Wide_Character_Encoding::
823 @end menu
824
825 @node Pragma Abort_Defer
826 @unnumberedsec Pragma Abort_Defer
827 @findex Abort_Defer
828 @cindex Deferring aborts
829 @noindent
830 Syntax:
831 @smallexample
832 pragma Abort_Defer;
833 @end smallexample
834
835 @noindent
836 This pragma must appear at the start of the statement sequence of a
837 handled sequence of statements (right after the @code{begin}).  It has
838 the effect of deferring aborts for the sequence of statements (but not
839 for the declarations or handlers, if any, associated with this statement
840 sequence).
841
842 @node Pragma Ada_83
843 @unnumberedsec Pragma Ada_83
844 @findex Ada_83
845 @noindent
846 Syntax:
847 @smallexample @c ada
848 pragma Ada_83;
849 @end smallexample
850
851 @noindent
852 A configuration pragma that establishes Ada 83 mode for the unit to
853 which it applies, regardless of the mode set by the command line
854 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
855 the syntax and semantics of Ada 83, as defined in the original Ada
856 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
857 and Ada 2005 are not recognized, optional package bodies are allowed,
858 and generics may name types with unknown discriminants without using
859 the @code{(<>)} notation.  In addition, some but not all of the additional
860 restrictions of Ada 83 are enforced.
861
862 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
863 Ada 83 code to be compiled and adapted to GNAT with less effort.
864 Secondly, it aids in keeping code backwards compatible with Ada 83.
865 However, there is no guarantee that code that is processed correctly
866 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
867 83 compiler, since GNAT does not enforce all the additional checks
868 required by Ada 83.
869
870 @node Pragma Ada_95
871 @unnumberedsec Pragma Ada_95
872 @findex Ada_95
873 @noindent
874 Syntax:
875 @smallexample @c ada
876 pragma Ada_95;
877 @end smallexample
878
879 @noindent
880 A configuration pragma that establishes Ada 95 mode for the unit to which
881 it applies, regardless of the mode set by the command line switches.
882 This mode is set automatically for the @code{Ada} and @code{System}
883 packages and their children, so you need not specify it in these
884 contexts.  This pragma is useful when writing a reusable component that
885 itself uses Ada 95 features, but which is intended to be usable from
886 either Ada 83 or Ada 95 programs.
887
888 @node Pragma Ada_05
889 @unnumberedsec Pragma Ada_05
890 @findex Ada_05
891 @noindent
892 Syntax:
893 @smallexample @c ada
894 pragma Ada_05;
895 @end smallexample
896
897 @noindent
898 A configuration pragma that establishes Ada 2005 mode for the unit to which
899 it applies, regardless of the mode set by the command line switches.
900 This mode is set automatically for the @code{Ada} and @code{System}
901 packages and their children, so you need not specify it in these
902 contexts.  This pragma is useful when writing a reusable component that
903 itself uses Ada 2005 features, but which is intended to be usable from
904 either Ada 83 or Ada 95 programs.
905
906 @node Pragma Ada_2005
907 @unnumberedsec Pragma Ada_2005
908 @findex Ada_2005
909 @noindent
910 Syntax:
911 @smallexample @c ada
912 pragma Ada_2005;
913 @end smallexample
914
915 @noindent
916 This configuration pragma is a synonym for pragma Ada_05 and has the
917 same syntax and effect.
918
919 @node Pragma Annotate
920 @unnumberedsec Pragma Annotate
921 @findex Annotate
922 @noindent
923 Syntax:
924 @smallexample @c ada
925 pragma Annotate (IDENTIFIER @{, ARG@});
926
927 ARG ::= NAME | EXPRESSION
928 @end smallexample
929
930 @noindent
931 This pragma is used to annotate programs.  @var{identifier} identifies
932 the type of annotation.  GNAT verifies that it is an identifier, but does
933 not otherwise analyze it.  The @var{arg} argument
934 can be either a string literal or an
935 expression.  String literals are assumed to be of type
936 @code{Standard.String}.  Names of entities are simply analyzed as entity
937 names.  All other expressions are analyzed as expressions, and must be
938 unambiguous.
939
940 The analyzed pragma is retained in the tree, but not otherwise processed
941 by any part of the GNAT compiler.  This pragma is intended for use by
942 external tools, including ASIS@.
943
944 @node Pragma Assert
945 @unnumberedsec Pragma Assert
946 @findex Assert
947 @noindent
948 Syntax:
949 @smallexample @c ada
950 pragma Assert (
951   boolean_EXPRESSION
952   [, string_EXPRESSION]);
953 @end smallexample
954
955 @noindent
956 The effect of this pragma depends on whether the corresponding command
957 line switch is set to activate assertions.  The pragma expands into code
958 equivalent to the following:
959
960 @smallexample @c ada
961 if assertions-enabled then
962    if not boolean_EXPRESSION then
963       System.Assertions.Raise_Assert_Failure
964         (string_EXPRESSION);
965    end if;
966 end if;
967 @end smallexample
968
969 @noindent
970 The string argument, if given, is the message that will be associated
971 with the exception occurrence if the exception is raised.  If no second
972 argument is given, the default message is @samp{@var{file}:@var{nnn}},
973 where @var{file} is the name of the source file containing the assert,
974 and @var{nnn} is the line number of the assert.  A pragma is not a
975 statement, so if a statement sequence contains nothing but a pragma
976 assert, then a null statement is required in addition, as in:
977
978 @smallexample @c ada
979 @dots{}
980 if J > 3 then
981    pragma Assert (K > 3, "Bad value for K");
982    null;
983 end if;
984 @end smallexample
985
986 @noindent
987 Note that, as with the @code{if} statement to which it is equivalent, the
988 type of the expression is either @code{Standard.Boolean}, or any type derived
989 from this standard type.
990
991 If assertions are disabled (switch @option{-gnata} not used), then there
992 is no run-time effect (and in particular, any side effects from the
993 expression will not occur at run time).  (The expression is still
994 analyzed at compile time, and may cause types to be frozen if they are
995 mentioned here for the first time).
996
997 If assertions are enabled, then the given expression is tested, and if
998 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
999 which results in the raising of @code{Assert_Failure} with the given message.
1000
1001 You should generally avoid side effects in the expression arguments of
1002 this pragma, because these side effects will turn on and off with the
1003 setting of the assertions mode, resulting in assertions that have an
1004 effect on the program.  However, the expressions are analyzed for
1005 semantic correctness whether or not assertions are enabled, so turning
1006 assertions on and off cannot affect the legality of a program.
1007
1008 @node Pragma Assume_No_Invalid_Values
1009 @unnumberedsec Pragma Assume_No_Invalid_Values
1010 @findex Assume_No_Invalid_Values
1011 @cindex Invalid representations
1012 @cindex Invalid values
1013 @noindent
1014 Syntax:
1015 @smallexample @c ada
1016 pragma Assume_No_Invalid_Values (On | Off);
1017 @end smallexample
1018
1019 @noindent
1020 This is a configuration pragma that controls the assumptions made by the
1021 compiler about the occurrence of invalid representations (invalid values)
1022 in the code.
1023
1024 The default behavior (corresponding to an Off argument for this pragma), is
1025 to assume that values may in general be invalid unless the compiler can
1026 prove they are valid. Consider the following example:
1027
1028 @smallexample @c ada
1029 V1 : Integer range 1 .. 10;
1030 V2 : Integer range 11 .. 20;
1031 ...
1032 for J in V2 .. V1 loop
1033    ...
1034 end loop;
1035 @end smallexample
1036
1037 @noindent
1038 if V1 and V2 have valid values, then the loop is known at compile
1039 time not to execute since the lower bound must be greater than the
1040 upper bound. However in default mode, no such assumption is made,
1041 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1042 is given, the compiler will assume that any occurrence of a variable
1043 other than in an explicit @code{'Valid} test always has a valid
1044 value, and the loop above will be optimized away.
1045
1046 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1047 you know your code is free of uninitialized variables and other
1048 possible sources of invalid representations, and may result in
1049 more efficient code. A program that accesses an invalid representation
1050 with this pragma in effect is erroneous, so no guarantees can be made
1051 about its behavior.
1052
1053 It is peculiar though permissible to use this pragma in conjunction
1054 with validity checking (-gnatVa). In such cases, accessing invalid
1055 values will generally give an exception, though formally the program
1056 is erroneous so there are no guarantees that this will always be the
1057 case, and it is recommended that these two options not be used together.
1058
1059 @node Pragma Ast_Entry
1060 @unnumberedsec Pragma Ast_Entry
1061 @cindex OpenVMS
1062 @findex Ast_Entry
1063 @noindent
1064 Syntax:
1065 @smallexample @c ada
1066 pragma AST_Entry (entry_IDENTIFIER);
1067 @end smallexample
1068
1069 @noindent
1070 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1071 argument is the simple name of a single entry; at most one @code{AST_Entry}
1072 pragma is allowed for any given entry.  This pragma must be used in
1073 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1074 the entry declaration and in the same task type specification or single task
1075 as the entry to which it applies.  This pragma specifies that the given entry
1076 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1077 resulting from an OpenVMS system service call.  The pragma does not affect
1078 normal use of the entry.  For further details on this pragma, see the
1079 DEC Ada Language Reference Manual, section 9.12a.
1080
1081 @node Pragma C_Pass_By_Copy
1082 @unnumberedsec Pragma C_Pass_By_Copy
1083 @cindex Passing by copy
1084 @findex C_Pass_By_Copy
1085 @noindent
1086 Syntax:
1087 @smallexample @c ada
1088 pragma C_Pass_By_Copy
1089   ([Max_Size =>] static_integer_EXPRESSION);
1090 @end smallexample
1091
1092 @noindent
1093 Normally the default mechanism for passing C convention records to C
1094 convention subprograms is to pass them by reference, as suggested by RM
1095 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1096 this default, by requiring that record formal parameters be passed by
1097 copy if all of the following conditions are met:
1098
1099 @itemize @bullet
1100 @item
1101 The size of the record type does not exceed the value specified for
1102 @code{Max_Size}.
1103 @item
1104 The record type has @code{Convention C}.
1105 @item
1106 The formal parameter has this record type, and the subprogram has a
1107 foreign (non-Ada) convention.
1108 @end itemize
1109
1110 @noindent
1111 If these conditions are met the argument is passed by copy, i.e.@: in a
1112 manner consistent with what C expects if the corresponding formal in the
1113 C prototype is a struct (rather than a pointer to a struct).
1114
1115 You can also pass records by copy by specifying the convention
1116 @code{C_Pass_By_Copy} for the record type, or by using the extended
1117 @code{Import} and @code{Export} pragmas, which allow specification of
1118 passing mechanisms on a parameter by parameter basis.
1119
1120 @node Pragma Check
1121 @unnumberedsec Pragma Check
1122 @cindex Assertions
1123 @cindex Named assertions
1124 @findex Check
1125 @noindent
1126 Syntax:
1127 @smallexample @c ada
1128 pragma Check (
1129      [Name    =>] Identifier,
1130      [Check   =>] Boolean_EXPRESSION
1131   [, [Message =>] string_EXPRESSION] );
1132 @end smallexample
1133
1134 @noindent
1135 This pragma is similar to the predefined pragma @code{Assert} except that an
1136 extra identifier argument is present. In conjunction with pragma
1137 @code{Check_Policy}, this can be used to define groups of assertions that can
1138 be independently controlled. The identifier @code{Assertion} is special, it
1139 refers to the normal set of pragma @code{Assert} statements. The identifiers
1140 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1141 names, so these three names would normally not be used directly in a pragma
1142 @code{Check}.
1143
1144 Checks introduced by this pragma are normally deactivated by default. They can
1145 be activated either by the command line option @option{-gnata}, which turns on
1146 all checks, or individually controlled using pragma @code{Check_Policy}.
1147
1148 @node Pragma Check_Name
1149 @unnumberedsec Pragma Check_Name
1150 @cindex Defining check names
1151 @cindex Check names, defining
1152 @findex Check_Name
1153 @noindent
1154 Syntax:
1155 @smallexample @c ada
1156 pragma Check_Name (check_name_IDENTIFIER);
1157 @end smallexample
1158
1159 @noindent
1160 This is a configuration pragma that defines a new implementation
1161 defined check name (unless IDENTIFIER matches one of the predefined
1162 check names, in which case the pragma has no effect). Check names
1163 are global to a partition, so if two or more configuration pragmas
1164 are present in a partition mentioning the same name, only one new
1165 check name is introduced.
1166
1167 An implementation defined check name introduced with this pragma may
1168 be used in only three contexts: @code{pragma Suppress},
1169 @code{pragma Unsuppress},
1170 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1171 any of these three cases, the check name must be visible. A check
1172 name is visible if it is in the configuration pragmas applying to
1173 the current unit, or if it appears at the start of any unit that
1174 is part of the dependency set of the current unit (e.g., units that
1175 are mentioned in @code{with} clauses).
1176
1177 @node Pragma Check_Policy
1178 @unnumberedsec Pragma Check_Policy
1179 @cindex Controlling assertions
1180 @cindex Assertions, control
1181 @cindex Check pragma control
1182 @cindex Named assertions
1183 @findex Check
1184 @noindent
1185 Syntax:
1186 @smallexample @c ada
1187 pragma Check_Policy
1188  ([Name   =>] Identifier,
1189   [Policy =>] POLICY_IDENTIFIER);
1190
1191 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1192 @end smallexample
1193
1194 @noindent
1195 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1196 except that it controls sets of named assertions introduced using the
1197 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1198 @code{Assertion_Policy}) can be used within a declarative part, in which case
1199 it controls the status to the end of the corresponding construct (in a manner
1200 identical to pragma @code{Suppress)}.
1201
1202 The identifier given as the first argument corresponds to a name used in
1203 associated @code{Check} pragmas. For example, if the pragma:
1204
1205 @smallexample @c ada
1206 pragma Check_Policy (Critical_Error, Off);
1207 @end smallexample
1208
1209 @noindent
1210 is given, then subsequent @code{Check} pragmas whose first argument is also
1211 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1212 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1213 @code{Check_Policy} with this identifier is similar to the normal
1214 @code{Assertion_Policy} pragma except that it can appear within a
1215 declarative part).
1216
1217 The special identifiers @code{Precondition} and @code{Postcondition} control
1218 the status of preconditions and postconditions. If a @code{Precondition} pragma
1219 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1220 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1221 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1222 are recognized.
1223
1224 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1225 to turn on corresponding checks. The default for a set of checks for which no
1226 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1227 @option{-gnata} is given, which turns on all checks by default.
1228
1229 The check policy settings @code{Check} and @code{Ignore} are also recognized
1230 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1231 compatibility with the standard @code{Assertion_Policy} pragma.
1232
1233 @node Pragma Comment
1234 @unnumberedsec Pragma Comment
1235 @findex Comment
1236 @noindent
1237 Syntax:
1238
1239 @smallexample @c ada
1240 pragma Comment (static_string_EXPRESSION);
1241 @end smallexample
1242
1243 @noindent
1244 This is almost identical in effect to pragma @code{Ident}.  It allows the
1245 placement of a comment into the object file and hence into the
1246 executable file if the operating system permits such usage.  The
1247 difference is that @code{Comment}, unlike @code{Ident}, has
1248 no limitations on placement of the pragma (it can be placed
1249 anywhere in the main source unit), and if more than one pragma
1250 is used, all comments are retained.
1251
1252 @node Pragma Common_Object
1253 @unnumberedsec Pragma Common_Object
1254 @findex Common_Object
1255 @noindent
1256 Syntax:
1257
1258 @smallexample @c ada
1259 pragma Common_Object (
1260      [Internal =>] LOCAL_NAME
1261   [, [External =>] EXTERNAL_SYMBOL]
1262   [, [Size     =>] EXTERNAL_SYMBOL] );
1263
1264 EXTERNAL_SYMBOL ::=
1265   IDENTIFIER
1266 | static_string_EXPRESSION
1267 @end smallexample
1268
1269 @noindent
1270 This pragma enables the shared use of variables stored in overlaid
1271 linker areas corresponding to the use of @code{COMMON}
1272 in Fortran.  The single
1273 object @var{LOCAL_NAME} is assigned to the area designated by
1274 the @var{External} argument.
1275 You may define a record to correspond to a series
1276 of fields.  The @var{Size} argument
1277 is syntax checked in GNAT, but otherwise ignored.
1278
1279 @code{Common_Object} is not supported on all platforms.  If no
1280 support is available, then the code generator will issue a message
1281 indicating that the necessary attribute for implementation of this
1282 pragma is not available.
1283
1284 @node Pragma Compile_Time_Error
1285 @unnumberedsec Pragma Compile_Time_Error
1286 @findex Compile_Time_Error
1287 @noindent
1288 Syntax:
1289
1290 @smallexample @c ada
1291 pragma Compile_Time_Error
1292          (boolean_EXPRESSION, static_string_EXPRESSION);
1293 @end smallexample
1294
1295 @noindent
1296 This pragma can be used to generate additional compile time
1297 error messages. It
1298 is particularly useful in generics, where errors can be issued for
1299 specific problematic instantiations. The first parameter is a boolean
1300 expression. The pragma is effective only if the value of this expression
1301 is known at compile time, and has the value True. The set of expressions
1302 whose values are known at compile time includes all static boolean
1303 expressions, and also other values which the compiler can determine
1304 at compile time (e.g., the size of a record type set by an explicit
1305 size representation clause, or the value of a variable which was
1306 initialized to a constant and is known not to have been modified).
1307 If these conditions are met, an error message is generated using
1308 the value given as the second argument. This string value may contain
1309 embedded ASCII.LF characters to break the message into multiple lines.
1310
1311 @node Pragma Compile_Time_Warning
1312 @unnumberedsec Pragma Compile_Time_Warning
1313 @findex Compile_Time_Warning
1314 @noindent
1315 Syntax:
1316
1317 @smallexample @c ada
1318 pragma Compile_Time_Warning
1319          (boolean_EXPRESSION, static_string_EXPRESSION);
1320 @end smallexample
1321
1322 @noindent
1323 Same as pragma Compile_Time_Error, except a warning is issued instead
1324 of an error message. Note that if this pragma is used in a package that
1325 is with'ed by a client, the client will get the warning even though it
1326 is issued by a with'ed package (normally warnings in with'ed units are
1327 suppressed, but this is a special exception to that rule).
1328
1329 One typical use is within a generic where compile time known characteristics
1330 of formal parameters are tested, and warnings given appropriately. Another use
1331 with a first parameter of True is to warn a client about use of a package,
1332 for example that it is not fully implemented.
1333
1334 @node Pragma Complete_Representation
1335 @unnumberedsec Pragma Complete_Representation
1336 @findex Complete_Representation
1337 @noindent
1338 Syntax:
1339
1340 @smallexample @c ada
1341 pragma Complete_Representation;
1342 @end smallexample
1343
1344 @noindent
1345 This pragma must appear immediately within a record representation
1346 clause. Typical placements are before the first component clause
1347 or after the last component clause. The effect is to give an error
1348 message if any component is missing a component clause. This pragma
1349 may be used to ensure that a record representation clause is
1350 complete, and that this invariant is maintained if fields are
1351 added to the record in the future.
1352
1353 @node Pragma Complex_Representation
1354 @unnumberedsec Pragma Complex_Representation
1355 @findex Complex_Representation
1356 @noindent
1357 Syntax:
1358
1359 @smallexample @c ada
1360 pragma Complex_Representation
1361         ([Entity =>] LOCAL_NAME);
1362 @end smallexample
1363
1364 @noindent
1365 The @var{Entity} argument must be the name of a record type which has
1366 two fields of the same floating-point type.  The effect of this pragma is
1367 to force gcc to use the special internal complex representation form for
1368 this record, which may be more efficient.  Note that this may result in
1369 the code for this type not conforming to standard ABI (application
1370 binary interface) requirements for the handling of record types.  For
1371 example, in some environments, there is a requirement for passing
1372 records by pointer, and the use of this pragma may result in passing
1373 this type in floating-point registers.
1374
1375 @node Pragma Component_Alignment
1376 @unnumberedsec Pragma Component_Alignment
1377 @cindex Alignments of components
1378 @findex Component_Alignment
1379 @noindent
1380 Syntax:
1381
1382 @smallexample @c ada
1383 pragma Component_Alignment (
1384      [Form =>] ALIGNMENT_CHOICE
1385   [, [Name =>] type_LOCAL_NAME]);
1386
1387 ALIGNMENT_CHOICE ::=
1388   Component_Size
1389 | Component_Size_4
1390 | Storage_Unit
1391 | Default
1392 @end smallexample
1393
1394 @noindent
1395 Specifies the alignment of components in array or record types.
1396 The meaning of the @var{Form} argument is as follows:
1397
1398 @table @code
1399 @findex Component_Size
1400 @item Component_Size
1401 Aligns scalar components and subcomponents of the array or record type
1402 on boundaries appropriate to their inherent size (naturally
1403 aligned).  For example, 1-byte components are aligned on byte boundaries,
1404 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1405 integer components are aligned on 4-byte boundaries and so on.  These
1406 alignment rules correspond to the normal rules for C compilers on all
1407 machines except the VAX@.
1408
1409 @findex Component_Size_4
1410 @item Component_Size_4
1411 Naturally aligns components with a size of four or fewer
1412 bytes.  Components that are larger than 4 bytes are placed on the next
1413 4-byte boundary.
1414
1415 @findex Storage_Unit
1416 @item Storage_Unit
1417 Specifies that array or record components are byte aligned, i.e.@:
1418 aligned on boundaries determined by the value of the constant
1419 @code{System.Storage_Unit}.
1420
1421 @cindex OpenVMS
1422 @item Default
1423 Specifies that array or record components are aligned on default
1424 boundaries, appropriate to the underlying hardware or operating system or
1425 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1426 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1427 the @code{Default} choice is the same as @code{Component_Size} (natural
1428 alignment).
1429 @end table
1430
1431 @noindent
1432 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1433 refer to a local record or array type, and the specified alignment
1434 choice applies to the specified type.  The use of
1435 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1436 @code{Component_Alignment} pragma to be ignored.  The use of
1437 @code{Component_Alignment} together with a record representation clause
1438 is only effective for fields not specified by the representation clause.
1439
1440 If the @code{Name} parameter is absent, the pragma can be used as either
1441 a configuration pragma, in which case it applies to one or more units in
1442 accordance with the normal rules for configuration pragmas, or it can be
1443 used within a declarative part, in which case it applies to types that
1444 are declared within this declarative part, or within any nested scope
1445 within this declarative part.  In either case it specifies the alignment
1446 to be applied to any record or array type which has otherwise standard
1447 representation.
1448
1449 If the alignment for a record or array type is not specified (using
1450 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1451 clause), the GNAT uses the default alignment as described previously.
1452
1453 @node Pragma Convention_Identifier
1454 @unnumberedsec Pragma Convention_Identifier
1455 @findex Convention_Identifier
1456 @cindex Conventions, synonyms
1457 @noindent
1458 Syntax:
1459
1460 @smallexample @c ada
1461 pragma Convention_Identifier (
1462          [Name =>]       IDENTIFIER,
1463          [Convention =>] convention_IDENTIFIER);
1464 @end smallexample
1465
1466 @noindent
1467 This pragma provides a mechanism for supplying synonyms for existing
1468 convention identifiers. The @code{Name} identifier can subsequently
1469 be used as a synonym for the given convention in other pragmas (including
1470 for example pragma @code{Import} or another @code{Convention_Identifier}
1471 pragma). As an example of the use of this, suppose you had legacy code
1472 which used Fortran77 as the identifier for Fortran. Then the pragma:
1473
1474 @smallexample @c ada
1475 pragma Convention_Identifier (Fortran77, Fortran);
1476 @end smallexample
1477
1478 @noindent
1479 would allow the use of the convention identifier @code{Fortran77} in
1480 subsequent code, avoiding the need to modify the sources. As another
1481 example, you could use this to parametrize convention requirements
1482 according to systems. Suppose you needed to use @code{Stdcall} on
1483 windows systems, and @code{C} on some other system, then you could
1484 define a convention identifier @code{Library} and use a single
1485 @code{Convention_Identifier} pragma to specify which convention
1486 would be used system-wide.
1487
1488 @node Pragma CPP_Class
1489 @unnumberedsec Pragma CPP_Class
1490 @findex CPP_Class
1491 @cindex Interfacing with C++
1492 @noindent
1493 Syntax:
1494
1495 @smallexample @c ada
1496 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1497 @end smallexample
1498
1499 @noindent
1500 The argument denotes an entity in the current declarative region that is
1501 declared as a record type. It indicates that the type corresponds to an
1502 externally declared C++ class type, and is to be laid out the same way
1503 that C++ would lay out the type. If the C++ class has virtual primitives
1504 then the record must be declared as a tagged record type.
1505
1506 Types for which @code{CPP_Class} is specified do not have assignment or
1507 equality operators defined (such operations can be imported or declared
1508 as subprograms as required). Initialization is allowed only by constructor
1509 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1510 limited if not explicitly declared as limited or derived from a limited
1511 type, and an error is issued in that case.
1512
1513 Pragma @code{CPP_Class} is intended primarily for automatic generation
1514 using an automatic binding generator tool.
1515 See @ref{Interfacing to C++} for related information.
1516
1517 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1518 for backward compatibility but its functionality is available
1519 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1520
1521 @node Pragma CPP_Constructor
1522 @unnumberedsec Pragma CPP_Constructor
1523 @cindex Interfacing with C++
1524 @findex CPP_Constructor
1525 @noindent
1526 Syntax:
1527
1528 @smallexample @c ada
1529 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1530   [, [External_Name =>] static_string_EXPRESSION ]
1531   [, [Link_Name     =>] static_string_EXPRESSION ]);
1532 @end smallexample
1533
1534 @noindent
1535 This pragma identifies an imported function (imported in the usual way
1536 with pragma @code{Import}) as corresponding to a C++ constructor. If
1537 @code{External_Name} and @code{Link_Name} are not specified then the
1538 @code{Entity} argument is a name that must have been previously mentioned
1539 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1540 must be of one of the following forms:
1541
1542 @itemize @bullet
1543 @item
1544 @code{function @var{Fname} return @var{T}}
1545
1546 @itemize @bullet
1547 @item
1548 @code{function @var{Fname} return @var{T}'Class}
1549
1550 @item
1551 @code{function @var{Fname} (@dots{}) return @var{T}}
1552 @end itemize
1553
1554 @item
1555 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1556 @end itemize
1557
1558 @noindent
1559 where @var{T} is a limited record type imported from C++ with pragma
1560 @code{Import} and @code{Convention} = @code{CPP}.
1561
1562 The first two forms import the default constructor, used when an object
1563 of type @var{T} is created on the Ada side with no explicit constructor.
1564 The latter two forms cover all the non-default constructors of the type.
1565 See the GNAT users guide for details.
1566
1567 If no constructors are imported, it is impossible to create any objects
1568 on the Ada side and the type is implicitly declared abstract.
1569
1570 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1571 using an automatic binding generator tool.
1572 See @ref{Interfacing to C++} for more related information.
1573
1574 Note: The use of functions returning class-wide types for constructors is
1575 currently obsolete. They are supported for backward compatibility. The
1576 use of functions returning the type T leave the Ada sources more clear
1577 because the imported C++ constructors always return an object of type T;
1578 that is, they never return an object whose type is a descendant of type T.
1579
1580 @node Pragma CPP_Virtual
1581 @unnumberedsec Pragma CPP_Virtual
1582 @cindex Interfacing to C++
1583 @findex CPP_Virtual
1584 @noindent
1585 This pragma is now obsolete has has no effect because GNAT generates
1586 the same object layout than the G++ compiler.
1587
1588 See @ref{Interfacing to C++} for related information.
1589
1590 @node Pragma CPP_Vtable
1591 @unnumberedsec Pragma CPP_Vtable
1592 @cindex Interfacing with C++
1593 @findex CPP_Vtable
1594 @noindent
1595 This pragma is now obsolete has has no effect because GNAT generates
1596 the same object layout than the G++ compiler.
1597
1598 See @ref{Interfacing to C++} for related information.
1599
1600 @node Pragma Debug
1601 @unnumberedsec Pragma Debug
1602 @findex Debug
1603 @noindent
1604 Syntax:
1605
1606 @smallexample @c ada
1607 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1608
1609 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1610   PROCEDURE_NAME
1611 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1612 @end smallexample
1613
1614 @noindent
1615 The procedure call argument has the syntactic form of an expression, meeting
1616 the syntactic requirements for pragmas.
1617
1618 If debug pragmas are not enabled or if the condition is present and evaluates
1619 to False, this pragma has no effect. If debug pragmas are enabled, the
1620 semantics of the pragma is exactly equivalent to the procedure call statement
1621 corresponding to the argument with a terminating semicolon. Pragmas are
1622 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1623 intersperse calls to debug procedures in the middle of declarations. Debug
1624 pragmas can be enabled either by use of the command line switch @option{-gnata}
1625 or by use of the configuration pragma @code{Debug_Policy}.
1626
1627 @node Pragma Debug_Policy
1628 @unnumberedsec Pragma Debug_Policy
1629 @findex Debug_Policy
1630 @noindent
1631 Syntax:
1632
1633 @smallexample @c ada
1634 pragma Debug_Policy (CHECK | IGNORE);
1635 @end smallexample
1636
1637 @noindent
1638 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1639 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1640 This pragma overrides the effect of the @option{-gnata} switch on the
1641 command line.
1642
1643 @node Pragma Detect_Blocking
1644 @unnumberedsec Pragma Detect_Blocking
1645 @findex Detect_Blocking
1646 @noindent
1647 Syntax:
1648
1649 @smallexample @c ada
1650 pragma Detect_Blocking;
1651 @end smallexample
1652
1653 @noindent
1654 This is a configuration pragma that forces the detection of potentially
1655 blocking operations within a protected operation, and to raise Program_Error
1656 if that happens.
1657
1658 @node Pragma Elaboration_Checks
1659 @unnumberedsec Pragma Elaboration_Checks
1660 @cindex Elaboration control
1661 @findex Elaboration_Checks
1662 @noindent
1663 Syntax:
1664
1665 @smallexample @c ada
1666 pragma Elaboration_Checks (Dynamic | Static);
1667 @end smallexample
1668
1669 @noindent
1670 This is a configuration pragma that provides control over the
1671 elaboration model used by the compilation affected by the
1672 pragma.  If the parameter is @code{Dynamic},
1673 then the dynamic elaboration
1674 model described in the Ada Reference Manual is used, as though
1675 the @option{-gnatE} switch had been specified on the command
1676 line.  If the parameter is @code{Static}, then the default GNAT static
1677 model is used.  This configuration pragma overrides the setting
1678 of the command line.  For full details on the elaboration models
1679 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1680 gnat_ugn, @value{EDITION} User's Guide}.
1681
1682 @node Pragma Eliminate
1683 @unnumberedsec Pragma Eliminate
1684 @cindex Elimination of unused subprograms
1685 @findex Eliminate
1686 @noindent
1687 Syntax:
1688
1689 @smallexample @c ada
1690 pragma Eliminate (
1691     [Unit_Name =>] IDENTIFIER |
1692                    SELECTED_COMPONENT);
1693
1694 pragma Eliminate (
1695     [Unit_Name       =>]  IDENTIFIER |
1696                           SELECTED_COMPONENT,
1697     [Entity          =>]  IDENTIFIER |
1698                           SELECTED_COMPONENT |
1699                           STRING_LITERAL
1700     [,OVERLOADING_RESOLUTION]);
1701
1702 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1703                            SOURCE_LOCATION
1704
1705 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1706                                       FUNCTION_PROFILE
1707
1708 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1709
1710 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1711                       Result_Type => result_SUBTYPE_NAME]
1712
1713 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1714 SUBTYPE_NAME    ::= STRING_VALUE
1715
1716 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1717 SOURCE_TRACE    ::= STRING_VALUE
1718
1719 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1720 @end smallexample
1721
1722 @noindent
1723 This pragma indicates that the given entity is not used outside the
1724 compilation unit it is defined in. The entity must be an explicitly declared
1725 subprogram; this includes  generic subprogram instances and
1726 subprograms declared in generic package instances.
1727
1728 If the entity to be eliminated is a library level subprogram, then
1729 the first form of pragma @code{Eliminate} is used with only a single argument.
1730 In this form, the @code{Unit_Name} argument specifies the name of the
1731 library  level unit to be eliminated.
1732
1733 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1734 are required. If item is an entity of a library package, then the first
1735 argument specifies the unit name, and the second argument specifies
1736 the particular entity.  If the second argument is in string form, it must
1737 correspond to the internal manner in which GNAT stores entity names (see
1738 compilation unit Namet in the compiler sources for details).
1739
1740 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1741 to distinguish between overloaded subprograms. If a pragma does not contain
1742 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1743 subprograms denoted by the first two parameters.
1744
1745 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1746 to be eliminated in a manner similar to that used for the extended
1747 @code{Import} and @code{Export} pragmas, except that the subtype names are
1748 always given as strings. At the moment, this form of distinguishing
1749 overloaded subprograms is implemented only partially, so we do not recommend
1750 using it for practical subprogram elimination.
1751
1752 Note that in case of a parameterless procedure its profile is represented
1753 as @code{Parameter_Types => ("")}
1754
1755 Alternatively, the @code{Source_Location} parameter is used to specify
1756 which overloaded alternative is to be eliminated by pointing to the
1757 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1758 source text. The string literal (or concatenation of string literals)
1759 given as SOURCE_TRACE must have the following format:
1760
1761 @smallexample @c ada
1762 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1763
1764 LBRACKET ::= [
1765 RBRACKET ::= ]
1766
1767 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1768 FILE_NAME       ::= STRING_LITERAL
1769 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1770 @end smallexample
1771
1772 SOURCE_TRACE should be the short name of the source file (with no directory
1773 information), and LINE_NUMBER is supposed to point to the line where the
1774 defining name of the subprogram is located.
1775
1776 For the subprograms that are not a part of generic instantiations, only one
1777 SOURCE_LOCATION is used. If a subprogram is declared in a package
1778 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1779 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1780 second one denotes the declaration of the corresponding subprogram in the
1781 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1782 in case of nested instantiations.
1783
1784 The effect of the pragma is to allow the compiler to eliminate
1785 the code or data associated with the named entity.  Any reference to
1786 an eliminated entity outside the compilation unit it is defined in,
1787 causes a compile time or link time error.
1788
1789 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1790 in a system independent manner, with unused entities eliminated, without
1791 the requirement of modifying the source text.  Normally the required set
1792 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1793 tool. Elimination of unused entities local to a compilation unit is
1794 automatic, without requiring the use of pragma @code{Eliminate}.
1795
1796 Note that the reason this pragma takes string literals where names might
1797 be expected is that a pragma @code{Eliminate} can appear in a context where the
1798 relevant names are not visible.
1799
1800 Note that any change in the source files that includes removing, splitting of
1801 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1802 parameter illegal.
1803
1804 It is legal to use pragma Eliminate where the referenced entity is a
1805 dispatching operation, but it is not clear what this would mean, since
1806 in general the call does not know which entity is actually being called.
1807 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1808
1809 @node Pragma Export_Exception
1810 @unnumberedsec Pragma Export_Exception
1811 @cindex OpenVMS
1812 @findex Export_Exception
1813 @noindent
1814 Syntax:
1815
1816 @smallexample @c ada
1817 pragma Export_Exception (
1818      [Internal =>] LOCAL_NAME
1819   [, [External =>] EXTERNAL_SYMBOL]
1820   [, [Form     =>] Ada | VMS]
1821   [, [Code     =>] static_integer_EXPRESSION]);
1822
1823 EXTERNAL_SYMBOL ::=
1824   IDENTIFIER
1825 | static_string_EXPRESSION
1826 @end smallexample
1827
1828 @noindent
1829 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1830 causes the specified exception to be propagated outside of the Ada program,
1831 so that it can be handled by programs written in other OpenVMS languages.
1832 This pragma establishes an external name for an Ada exception and makes the
1833 name available to the OpenVMS Linker as a global symbol.  For further details
1834 on this pragma, see the
1835 DEC Ada Language Reference Manual, section 13.9a3.2.
1836
1837 @node Pragma Export_Function
1838 @unnumberedsec Pragma Export_Function
1839 @cindex Argument passing mechanisms
1840 @findex Export_Function
1841
1842 @noindent
1843 Syntax:
1844
1845 @smallexample @c ada
1846 pragma Export_Function (
1847      [Internal         =>] LOCAL_NAME
1848   [, [External         =>] EXTERNAL_SYMBOL]
1849   [, [Parameter_Types  =>] PARAMETER_TYPES]
1850   [, [Result_Type      =>] result_SUBTYPE_MARK]
1851   [, [Mechanism        =>] MECHANISM]
1852   [, [Result_Mechanism =>] MECHANISM_NAME]);
1853
1854 EXTERNAL_SYMBOL ::=
1855   IDENTIFIER
1856 | static_string_EXPRESSION
1857 | ""
1858
1859 PARAMETER_TYPES ::=
1860   null
1861 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1862
1863 TYPE_DESIGNATOR ::=
1864   subtype_NAME
1865 | subtype_Name ' Access
1866
1867 MECHANISM ::=
1868   MECHANISM_NAME
1869 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1870
1871 MECHANISM_ASSOCIATION ::=
1872   [formal_parameter_NAME =>] MECHANISM_NAME
1873
1874 MECHANISM_NAME ::=
1875   Value
1876 | Reference
1877 | Descriptor [([Class =>] CLASS_NAME)]
1878 | Short_Descriptor [([Class =>] CLASS_NAME)]
1879
1880 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1881 @end smallexample
1882
1883 @noindent
1884 Use this pragma to make a function externally callable and optionally
1885 provide information on mechanisms to be used for passing parameter and
1886 result values.  We recommend, for the purposes of improving portability,
1887 this pragma always be used in conjunction with a separate pragma
1888 @code{Export}, which must precede the pragma @code{Export_Function}.
1889 GNAT does not require a separate pragma @code{Export}, but if none is
1890 present, @code{Convention Ada} is assumed, which is usually
1891 not what is wanted, so it is usually appropriate to use this
1892 pragma in conjunction with a @code{Export} or @code{Convention}
1893 pragma that specifies the desired foreign convention.
1894 Pragma @code{Export_Function}
1895 (and @code{Export}, if present) must appear in the same declarative
1896 region as the function to which they apply.
1897
1898 @var{internal_name} must uniquely designate the function to which the
1899 pragma applies.  If more than one function name exists of this name in
1900 the declarative part you must use the @code{Parameter_Types} and
1901 @code{Result_Type} parameters is mandatory to achieve the required
1902 unique designation.  @var{subtype_mark}s in these parameters must
1903 exactly match the subtypes in the corresponding function specification,
1904 using positional notation to match parameters with subtype marks.
1905 The form with an @code{'Access} attribute can be used to match an
1906 anonymous access parameter.
1907
1908 @cindex OpenVMS
1909 @cindex Passing by descriptor
1910 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1911 The default behavior for Export_Function is to accept either 64bit or
1912 32bit descriptors unless short_descriptor is specified, then only 32bit
1913 descriptors are accepted.
1914
1915 @cindex Suppressing external name
1916 Special treatment is given if the EXTERNAL is an explicit null
1917 string or a static string expressions that evaluates to the null
1918 string. In this case, no external name is generated. This form
1919 still allows the specification of parameter mechanisms.
1920
1921 @node Pragma Export_Object
1922 @unnumberedsec Pragma Export_Object
1923 @findex Export_Object
1924 @noindent
1925 Syntax:
1926
1927 @smallexample @c ada
1928 pragma Export_Object
1929       [Internal =>] LOCAL_NAME
1930    [, [External =>] EXTERNAL_SYMBOL]
1931    [, [Size     =>] EXTERNAL_SYMBOL]
1932
1933 EXTERNAL_SYMBOL ::=
1934   IDENTIFIER
1935 | static_string_EXPRESSION
1936 @end smallexample
1937
1938 @noindent
1939 This pragma designates an object as exported, and apart from the
1940 extended rules for external symbols, is identical in effect to the use of
1941 the normal @code{Export} pragma applied to an object.  You may use a
1942 separate Export pragma (and you probably should from the point of view
1943 of portability), but it is not required.  @var{Size} is syntax checked,
1944 but otherwise ignored by GNAT@.
1945
1946 @node Pragma Export_Procedure
1947 @unnumberedsec Pragma Export_Procedure
1948 @findex Export_Procedure
1949 @noindent
1950 Syntax:
1951
1952 @smallexample @c ada
1953 pragma Export_Procedure (
1954      [Internal        =>] LOCAL_NAME
1955   [, [External        =>] EXTERNAL_SYMBOL]
1956   [, [Parameter_Types =>] PARAMETER_TYPES]
1957   [, [Mechanism       =>] MECHANISM]);
1958
1959 EXTERNAL_SYMBOL ::=
1960   IDENTIFIER
1961 | static_string_EXPRESSION
1962 | ""
1963
1964 PARAMETER_TYPES ::=
1965   null
1966 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1967
1968 TYPE_DESIGNATOR ::=
1969   subtype_NAME
1970 | subtype_Name ' Access
1971
1972 MECHANISM ::=
1973   MECHANISM_NAME
1974 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1975
1976 MECHANISM_ASSOCIATION ::=
1977   [formal_parameter_NAME =>] MECHANISM_NAME
1978
1979 MECHANISM_NAME ::=
1980   Value
1981 | Reference
1982 | Descriptor [([Class =>] CLASS_NAME)]
1983 | Short_Descriptor [([Class =>] CLASS_NAME)]
1984
1985 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1986 @end smallexample
1987
1988 @noindent
1989 This pragma is identical to @code{Export_Function} except that it
1990 applies to a procedure rather than a function and the parameters
1991 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1992 GNAT does not require a separate pragma @code{Export}, but if none is
1993 present, @code{Convention Ada} is assumed, which is usually
1994 not what is wanted, so it is usually appropriate to use this
1995 pragma in conjunction with a @code{Export} or @code{Convention}
1996 pragma that specifies the desired foreign convention.
1997
1998 @cindex OpenVMS
1999 @cindex Passing by descriptor
2000 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2001 The default behavior for Export_Procedure is to accept either 64bit or
2002 32bit descriptors unless short_descriptor is specified, then only 32bit
2003 descriptors are accepted.
2004
2005 @cindex Suppressing external name
2006 Special treatment is given if the EXTERNAL is an explicit null
2007 string or a static string expressions that evaluates to the null
2008 string. In this case, no external name is generated. This form
2009 still allows the specification of parameter mechanisms.
2010
2011 @node Pragma Export_Value
2012 @unnumberedsec Pragma Export_Value
2013 @findex Export_Value
2014 @noindent
2015 Syntax:
2016
2017 @smallexample @c ada
2018 pragma Export_Value (
2019   [Value     =>] static_integer_EXPRESSION,
2020   [Link_Name =>] static_string_EXPRESSION);
2021 @end smallexample
2022
2023 @noindent
2024 This pragma serves to export a static integer value for external use.
2025 The first argument specifies the value to be exported. The Link_Name
2026 argument specifies the symbolic name to be associated with the integer
2027 value. This pragma is useful for defining a named static value in Ada
2028 that can be referenced in assembly language units to be linked with
2029 the application. This pragma is currently supported only for the
2030 AAMP target and is ignored for other targets.
2031
2032 @node Pragma Export_Valued_Procedure
2033 @unnumberedsec Pragma Export_Valued_Procedure
2034 @findex Export_Valued_Procedure
2035 @noindent
2036 Syntax:
2037
2038 @smallexample @c ada
2039 pragma Export_Valued_Procedure (
2040      [Internal        =>] LOCAL_NAME
2041   [, [External        =>] EXTERNAL_SYMBOL]
2042   [, [Parameter_Types =>] PARAMETER_TYPES]
2043   [, [Mechanism       =>] MECHANISM]);
2044
2045 EXTERNAL_SYMBOL ::=
2046   IDENTIFIER
2047 | static_string_EXPRESSION
2048 | ""
2049
2050 PARAMETER_TYPES ::=
2051   null
2052 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2053
2054 TYPE_DESIGNATOR ::=
2055   subtype_NAME
2056 | subtype_Name ' Access
2057
2058 MECHANISM ::=
2059   MECHANISM_NAME
2060 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2061
2062 MECHANISM_ASSOCIATION ::=
2063   [formal_parameter_NAME =>] MECHANISM_NAME
2064
2065 MECHANISM_NAME ::=
2066   Value
2067 | Reference
2068 | Descriptor [([Class =>] CLASS_NAME)]
2069 | Short_Descriptor [([Class =>] CLASS_NAME)]
2070
2071 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2072 @end smallexample
2073
2074 @noindent
2075 This pragma is identical to @code{Export_Procedure} except that the
2076 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2077 mode @code{OUT}, and externally the subprogram is treated as a function
2078 with this parameter as the result of the function.  GNAT provides for
2079 this capability to allow the use of @code{OUT} and @code{IN OUT}
2080 parameters in interfacing to external functions (which are not permitted
2081 in Ada functions).
2082 GNAT does not require a separate pragma @code{Export}, but if none is
2083 present, @code{Convention Ada} is assumed, which is almost certainly
2084 not what is wanted since the whole point of this pragma is to interface
2085 with foreign language functions, so it is usually appropriate to use this
2086 pragma in conjunction with a @code{Export} or @code{Convention}
2087 pragma that specifies the desired foreign convention.
2088
2089 @cindex OpenVMS
2090 @cindex Passing by descriptor
2091 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2092 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2093 32bit descriptors unless short_descriptor is specified, then only 32bit
2094 descriptors are accepted.
2095
2096 @cindex Suppressing external name
2097 Special treatment is given if the EXTERNAL is an explicit null
2098 string or a static string expressions that evaluates to the null
2099 string. In this case, no external name is generated. This form
2100 still allows the specification of parameter mechanisms.
2101
2102 @node Pragma Extend_System
2103 @unnumberedsec Pragma Extend_System
2104 @cindex @code{system}, extending
2105 @cindex Dec Ada 83
2106 @findex Extend_System
2107 @noindent
2108 Syntax:
2109
2110 @smallexample @c ada
2111 pragma Extend_System ([Name =>] IDENTIFIER);
2112 @end smallexample
2113
2114 @noindent
2115 This pragma is used to provide backwards compatibility with other
2116 implementations that extend the facilities of package @code{System}.  In
2117 GNAT, @code{System} contains only the definitions that are present in
2118 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2119 implementation, provide many extensions to package @code{System}.
2120
2121 For each such implementation accommodated by this pragma, GNAT provides a
2122 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2123 implementation, which provides the required additional definitions.  You
2124 can use this package in two ways.  You can @code{with} it in the normal
2125 way and access entities either by selection or using a @code{use}
2126 clause.  In this case no special processing is required.
2127
2128 However, if existing code contains references such as
2129 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2130 definitions provided in package @code{System}, you may use this pragma
2131 to extend visibility in @code{System} in a non-standard way that
2132 provides greater compatibility with the existing code.  Pragma
2133 @code{Extend_System} is a configuration pragma whose single argument is
2134 the name of the package containing the extended definition
2135 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2136 control of this pragma will be processed using special visibility
2137 processing that looks in package @code{System.Aux_@var{xxx}} where
2138 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2139 package @code{System}, but not found in package @code{System}.
2140
2141 You can use this pragma either to access a predefined @code{System}
2142 extension supplied with the compiler, for example @code{Aux_DEC} or
2143 you can construct your own extension unit following the above
2144 definition.  Note that such a package is a child of @code{System}
2145 and thus is considered part of the implementation.  To compile
2146 it you will have to use the appropriate switch for compiling
2147 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2148 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2149
2150 @node Pragma External
2151 @unnumberedsec Pragma External
2152 @findex External
2153 @noindent
2154 Syntax:
2155
2156 @smallexample @c ada
2157 pragma External (
2158   [   Convention    =>] convention_IDENTIFIER,
2159   [   Entity        =>] LOCAL_NAME
2160   [, [External_Name =>] static_string_EXPRESSION ]
2161   [, [Link_Name     =>] static_string_EXPRESSION ]);
2162 @end smallexample
2163
2164 @noindent
2165 This pragma is identical in syntax and semantics to pragma
2166 @code{Export} as defined in the Ada Reference Manual.  It is
2167 provided for compatibility with some Ada 83 compilers that
2168 used this pragma for exactly the same purposes as pragma
2169 @code{Export} before the latter was standardized.
2170
2171 @node Pragma External_Name_Casing
2172 @unnumberedsec Pragma External_Name_Casing
2173 @cindex Dec Ada 83 casing compatibility
2174 @cindex External Names, casing
2175 @cindex Casing of External names
2176 @findex External_Name_Casing
2177 @noindent
2178 Syntax:
2179
2180 @smallexample @c ada
2181 pragma External_Name_Casing (
2182   Uppercase | Lowercase
2183   [, Uppercase | Lowercase | As_Is]);
2184 @end smallexample
2185
2186 @noindent
2187 This pragma provides control over the casing of external names associated
2188 with Import and Export pragmas.  There are two cases to consider:
2189
2190 @table @asis
2191 @item Implicit external names
2192 Implicit external names are derived from identifiers.  The most common case
2193 arises when a standard Ada Import or Export pragma is used with only two
2194 arguments, as in:
2195
2196 @smallexample @c ada
2197    pragma Import (C, C_Routine);
2198 @end smallexample
2199
2200 @noindent
2201 Since Ada is a case-insensitive language, the spelling of the identifier in
2202 the Ada source program does not provide any information on the desired
2203 casing of the external name, and so a convention is needed.  In GNAT the
2204 default treatment is that such names are converted to all lower case
2205 letters.  This corresponds to the normal C style in many environments.
2206 The first argument of pragma @code{External_Name_Casing} can be used to
2207 control this treatment.  If @code{Uppercase} is specified, then the name
2208 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2209 then the normal default of all lower case letters will be used.
2210
2211 This same implicit treatment is also used in the case of extended DEC Ada 83
2212 compatible Import and Export pragmas where an external name is explicitly
2213 specified using an identifier rather than a string.
2214
2215 @item Explicit external names
2216 Explicit external names are given as string literals.  The most common case
2217 arises when a standard Ada Import or Export pragma is used with three
2218 arguments, as in:
2219
2220 @smallexample @c ada
2221 pragma Import (C, C_Routine, "C_routine");
2222 @end smallexample
2223
2224 @noindent
2225 In this case, the string literal normally provides the exact casing required
2226 for the external name.  The second argument of pragma
2227 @code{External_Name_Casing} may be used to modify this behavior.
2228 If @code{Uppercase} is specified, then the name
2229 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2230 then the name will be forced to all lowercase letters.  A specification of
2231 @code{As_Is} provides the normal default behavior in which the casing is
2232 taken from the string provided.
2233 @end table
2234
2235 @noindent
2236 This pragma may appear anywhere that a pragma is valid.  In particular, it
2237 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2238 case it applies to all subsequent compilations, or it can be used as a program
2239 unit pragma, in which case it only applies to the current unit, or it can
2240 be used more locally to control individual Import/Export pragmas.
2241
2242 It is primarily intended for use with OpenVMS systems, where many
2243 compilers convert all symbols to upper case by default.  For interfacing to
2244 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2245 the pragma:
2246
2247 @smallexample @c ada
2248 pragma External_Name_Casing (Uppercase, Uppercase);
2249 @end smallexample
2250
2251 @noindent
2252 to enforce the upper casing of all external symbols.
2253
2254 @node Pragma Fast_Math
2255 @unnumberedsec Pragma Fast_Math
2256 @findex Fast_Math
2257 @noindent
2258 Syntax:
2259
2260 @smallexample @c ada
2261 pragma Fast_Math;
2262 @end smallexample
2263
2264 @noindent
2265 This is a configuration pragma which activates a mode in which speed is
2266 considered more important for floating-point operations than absolutely
2267 accurate adherence to the requirements of the standard. Currently the
2268 following operations are affected:
2269
2270 @table @asis
2271 @item Complex Multiplication
2272 The normal simple formula for complex multiplication can result in intermediate
2273 overflows for numbers near the end of the range. The Ada standard requires that
2274 this situation be detected and corrected by scaling, but in Fast_Math mode such
2275 cases will simply result in overflow. Note that to take advantage of this you
2276 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2277 under control of the pragma, rather than use the preinstantiated versions.
2278 @end table
2279
2280 @node Pragma Favor_Top_Level
2281 @unnumberedsec Pragma Favor_Top_Level
2282 @findex Favor_Top_Level
2283 @noindent
2284 Syntax:
2285
2286 @smallexample @c ada
2287 pragma Favor_Top_Level (type_NAME);
2288 @end smallexample
2289
2290 @noindent
2291 The named type must be an access-to-subprogram type. This pragma is an
2292 efficiency hint to the compiler, regarding the use of 'Access or
2293 'Unrestricted_Access on nested (non-library-level) subprograms. The
2294 pragma means that nested subprograms are not used with this type, or
2295 are rare, so that the generated code should be efficient in the
2296 top-level case. When this pragma is used, dynamically generated
2297 trampolines may be used on some targets for nested subprograms.
2298 See also the No_Implicit_Dynamic_Code restriction.
2299
2300 @node Pragma Finalize_Storage_Only
2301 @unnumberedsec Pragma Finalize_Storage_Only
2302 @findex Finalize_Storage_Only
2303 @noindent
2304 Syntax:
2305
2306 @smallexample @c ada
2307 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2308 @end smallexample
2309
2310 @noindent
2311 This pragma allows the compiler not to emit a Finalize call for objects
2312 defined at the library level.  This is mostly useful for types where
2313 finalization is only used to deal with storage reclamation since in most
2314 environments it is not necessary to reclaim memory just before terminating
2315 execution, hence the name.
2316
2317 @node Pragma Float_Representation
2318 @unnumberedsec Pragma Float_Representation
2319 @cindex OpenVMS
2320 @findex Float_Representation
2321 @noindent
2322 Syntax:
2323
2324 @smallexample @c ada
2325 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2326
2327 FLOAT_REP ::= VAX_Float | IEEE_Float
2328 @end smallexample
2329
2330 @noindent
2331 In the one argument form, this pragma is a configuration pragma which
2332 allows control over the internal representation chosen for the predefined
2333 floating point types declared in the packages @code{Standard} and
2334 @code{System}. On all systems other than OpenVMS, the argument must
2335 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2336 argument may be @code{VAX_Float} to specify the use of the VAX float
2337 format for the floating-point types in Standard. This requires that
2338 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2339 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2340 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2341
2342 The two argument form specifies the representation to be used for
2343 the specified floating-point type. On all systems other than OpenVMS,
2344 the argument must
2345 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2346 argument may be @code{VAX_Float} to specify the use of the VAX float
2347 format, as follows:
2348
2349 @itemize @bullet
2350 @item
2351 For digits values up to 6, F float format will be used.
2352 @item
2353 For digits values from 7 to 9, G float format will be used.
2354 @item
2355 For digits values from 10 to 15, F float format will be used.
2356 @item
2357 Digits values above 15 are not allowed.
2358 @end itemize
2359
2360 @node Pragma Ident
2361 @unnumberedsec Pragma Ident
2362 @findex Ident
2363 @noindent
2364 Syntax:
2365
2366 @smallexample @c ada
2367 pragma Ident (static_string_EXPRESSION);
2368 @end smallexample
2369
2370 @noindent
2371 This pragma provides a string identification in the generated object file,
2372 if the system supports the concept of this kind of identification string.
2373 This pragma is allowed only in the outermost declarative part or
2374 declarative items of a compilation unit. If more than one @code{Ident}
2375 pragma is given, only the last one processed is effective.
2376 @cindex OpenVMS
2377 On OpenVMS systems, the effect of the pragma is identical to the effect of
2378 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2379 maximum allowed length is 31 characters, so if it is important to
2380 maintain compatibility with this compiler, you should obey this length
2381 limit.
2382
2383 @node Pragma Implemented_By_Entry
2384 @unnumberedsec Pragma Implemented_By_Entry
2385 @findex Implemented_By_Entry
2386 @noindent
2387 Syntax:
2388
2389 @smallexample @c ada
2390 pragma Implemented_By_Entry (LOCAL_NAME);
2391 @end smallexample
2392
2393 @noindent
2394 This is a representation pragma which applies to protected, synchronized and
2395 task interface primitives. If the pragma is applied to primitive operation Op
2396 of interface Iface, it is illegal to override Op in a type that implements
2397 Iface, with anything other than an entry.
2398
2399 @smallexample @c ada
2400 type Iface is protected interface;
2401 procedure Do_Something (Object : in out Iface) is abstract;
2402 pragma Implemented_By_Entry (Do_Something);
2403
2404 protected type P is new Iface with
2405    procedure Do_Something;  --  Illegal
2406 end P;
2407
2408 task type T is new Iface with
2409    entry Do_Something;      --  Legal
2410 end T;
2411 @end smallexample
2412
2413 @noindent
2414 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2415 is intended to be used in conjunction with dispatching requeue statements as
2416 described in AI05-0030. Should the ARG decide on an official name and syntax,
2417 this pragma will become language-defined rather than GNAT-specific.
2418
2419 @node Pragma Implicit_Packing
2420 @unnumberedsec Pragma Implicit_Packing
2421 @findex Implicit_Packing
2422 @noindent
2423 Syntax:
2424
2425 @smallexample @c ada
2426 pragma Implicit_Packing;
2427 @end smallexample
2428
2429 @noindent
2430 This is a configuration pragma that requests implicit packing for packed
2431 arrays for which a size clause is given but no explicit pragma Pack or
2432 specification of Component_Size is present. It also applies to records
2433 where no record representation clause is present. Consider this example:
2434
2435 @smallexample @c ada
2436 type R is array (0 .. 7) of Boolean;
2437 for R'Size use 8;
2438 @end smallexample
2439
2440 @noindent
2441 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2442 does not change the layout of a composite object. So the Size clause in the
2443 above example is normally rejected, since the default layout of the array uses
2444 8-bit components, and thus the array requires a minimum of 64 bits.
2445
2446 If this declaration is compiled in a region of code covered by an occurrence
2447 of the configuration pragma Implicit_Packing, then the Size clause in this
2448 and similar examples will cause implicit packing and thus be accepted. For
2449 this implicit packing to occur, the type in question must be an array of small
2450 components whose size is known at compile time, and the Size clause must
2451 specify the exact size that corresponds to the length of the array multiplied
2452 by the size in bits of the component type.
2453 @cindex Array packing
2454
2455 Similarly, the following example shows the use in the record case
2456
2457 @smallexample @c ada
2458 type r is record
2459    a, b, c, d, e, f, g, h : boolean;
2460    chr                    : character;
2461 end record;
2462 for r'size use 16;
2463 @end smallexample
2464
2465 @noindent
2466 Without a pragma Pack, each Boolean field requires 8 bits, so the
2467 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2468 sufficient. The use of pragma Implciit_Packing allows this record
2469 declaration to compile without an explicit pragma Pack.
2470 @node Pragma Import_Exception
2471 @unnumberedsec Pragma Import_Exception
2472 @cindex OpenVMS
2473 @findex Import_Exception
2474 @noindent
2475 Syntax:
2476
2477 @smallexample @c ada
2478 pragma Import_Exception (
2479      [Internal =>] LOCAL_NAME
2480   [, [External =>] EXTERNAL_SYMBOL]
2481   [, [Form     =>] Ada | VMS]
2482   [, [Code     =>] static_integer_EXPRESSION]);
2483
2484 EXTERNAL_SYMBOL ::=
2485   IDENTIFIER
2486 | static_string_EXPRESSION
2487 @end smallexample
2488
2489 @noindent
2490 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2491 It allows OpenVMS conditions (for example, from OpenVMS system services or
2492 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2493 The pragma specifies that the exception associated with an exception
2494 declaration in an Ada program be defined externally (in non-Ada code).
2495 For further details on this pragma, see the
2496 DEC Ada Language Reference Manual, section 13.9a.3.1.
2497
2498 @node Pragma Import_Function
2499 @unnumberedsec Pragma Import_Function
2500 @findex Import_Function
2501 @noindent
2502 Syntax:
2503
2504 @smallexample @c ada
2505 pragma Import_Function (
2506      [Internal                 =>] LOCAL_NAME,
2507   [, [External                 =>] EXTERNAL_SYMBOL]
2508   [, [Parameter_Types          =>] PARAMETER_TYPES]
2509   [, [Result_Type              =>] SUBTYPE_MARK]
2510   [, [Mechanism                =>] MECHANISM]
2511   [, [Result_Mechanism         =>] MECHANISM_NAME]
2512   [, [First_Optional_Parameter =>] IDENTIFIER]);
2513
2514 EXTERNAL_SYMBOL ::=
2515   IDENTIFIER
2516 | static_string_EXPRESSION
2517
2518 PARAMETER_TYPES ::=
2519   null
2520 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2521
2522 TYPE_DESIGNATOR ::=
2523   subtype_NAME
2524 | subtype_Name ' Access
2525
2526 MECHANISM ::=
2527   MECHANISM_NAME
2528 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2529
2530 MECHANISM_ASSOCIATION ::=
2531   [formal_parameter_NAME =>] MECHANISM_NAME
2532
2533 MECHANISM_NAME ::=
2534   Value
2535 | Reference
2536 | Descriptor [([Class =>] CLASS_NAME)]
2537 | Short_Descriptor [([Class =>] CLASS_NAME)]
2538
2539 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2540 @end smallexample
2541
2542 @noindent
2543 This pragma is used in conjunction with a pragma @code{Import} to
2544 specify additional information for an imported function.  The pragma
2545 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2546 @code{Import_Function} pragma and both must appear in the same
2547 declarative part as the function specification.
2548
2549 The @var{Internal} argument must uniquely designate
2550 the function to which the
2551 pragma applies.  If more than one function name exists of this name in
2552 the declarative part you must use the @code{Parameter_Types} and
2553 @var{Result_Type} parameters to achieve the required unique
2554 designation.  Subtype marks in these parameters must exactly match the
2555 subtypes in the corresponding function specification, using positional
2556 notation to match parameters with subtype marks.
2557 The form with an @code{'Access} attribute can be used to match an
2558 anonymous access parameter.
2559
2560 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2561 parameters to specify passing mechanisms for the
2562 parameters and result.  If you specify a single mechanism name, it
2563 applies to all parameters.  Otherwise you may specify a mechanism on a
2564 parameter by parameter basis using either positional or named
2565 notation.  If the mechanism is not specified, the default mechanism
2566 is used.
2567
2568 @cindex OpenVMS
2569 @cindex Passing by descriptor
2570 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2571 The default behavior for Import_Function is to pass a 64bit descriptor
2572 unless short_descriptor is specified, then a 32bit descriptor is passed.
2573
2574 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2575 It specifies that the designated parameter and all following parameters
2576 are optional, meaning that they are not passed at the generated code
2577 level (this is distinct from the notion of optional parameters in Ada
2578 where the parameters are passed anyway with the designated optional
2579 parameters).  All optional parameters must be of mode @code{IN} and have
2580 default parameter values that are either known at compile time
2581 expressions, or uses of the @code{'Null_Parameter} attribute.
2582
2583 @node Pragma Import_Object
2584 @unnumberedsec Pragma Import_Object
2585 @findex Import_Object
2586 @noindent
2587 Syntax:
2588
2589 @smallexample @c ada
2590 pragma Import_Object
2591      [Internal =>] LOCAL_NAME
2592   [, [External =>] EXTERNAL_SYMBOL]
2593   [, [Size     =>] EXTERNAL_SYMBOL]);
2594
2595 EXTERNAL_SYMBOL ::=
2596   IDENTIFIER
2597 | static_string_EXPRESSION
2598 @end smallexample
2599
2600 @noindent
2601 This pragma designates an object as imported, and apart from the
2602 extended rules for external symbols, is identical in effect to the use of
2603 the normal @code{Import} pragma applied to an object.  Unlike the
2604 subprogram case, you need not use a separate @code{Import} pragma,
2605 although you may do so (and probably should do so from a portability
2606 point of view).  @var{size} is syntax checked, but otherwise ignored by
2607 GNAT@.
2608
2609 @node Pragma Import_Procedure
2610 @unnumberedsec Pragma Import_Procedure
2611 @findex Import_Procedure
2612 @noindent
2613 Syntax:
2614
2615 @smallexample @c ada
2616 pragma Import_Procedure (
2617      [Internal                 =>] LOCAL_NAME
2618   [, [External                 =>] EXTERNAL_SYMBOL]
2619   [, [Parameter_Types          =>] PARAMETER_TYPES]
2620   [, [Mechanism                =>] MECHANISM]
2621   [, [First_Optional_Parameter =>] IDENTIFIER]);
2622
2623 EXTERNAL_SYMBOL ::=
2624   IDENTIFIER
2625 | static_string_EXPRESSION
2626
2627 PARAMETER_TYPES ::=
2628   null
2629 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2630
2631 TYPE_DESIGNATOR ::=
2632   subtype_NAME
2633 | subtype_Name ' Access
2634
2635 MECHANISM ::=
2636   MECHANISM_NAME
2637 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2638
2639 MECHANISM_ASSOCIATION ::=
2640   [formal_parameter_NAME =>] MECHANISM_NAME
2641
2642 MECHANISM_NAME ::=
2643   Value
2644 | Reference
2645 | Descriptor [([Class =>] CLASS_NAME)]
2646 | Short_Descriptor [([Class =>] CLASS_NAME)]
2647
2648 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2649 @end smallexample
2650
2651 @noindent
2652 This pragma is identical to @code{Import_Function} except that it
2653 applies to a procedure rather than a function and the parameters
2654 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2655
2656 @node Pragma Import_Valued_Procedure
2657 @unnumberedsec Pragma Import_Valued_Procedure
2658 @findex Import_Valued_Procedure
2659 @noindent
2660 Syntax:
2661
2662 @smallexample @c ada
2663 pragma Import_Valued_Procedure (
2664      [Internal                 =>] LOCAL_NAME
2665   [, [External                 =>] EXTERNAL_SYMBOL]
2666   [, [Parameter_Types          =>] PARAMETER_TYPES]
2667   [, [Mechanism                =>] MECHANISM]
2668   [, [First_Optional_Parameter =>] IDENTIFIER]);
2669
2670 EXTERNAL_SYMBOL ::=
2671   IDENTIFIER
2672 | static_string_EXPRESSION
2673
2674 PARAMETER_TYPES ::=
2675   null
2676 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2677
2678 TYPE_DESIGNATOR ::=
2679   subtype_NAME
2680 | subtype_Name ' Access
2681
2682 MECHANISM ::=
2683   MECHANISM_NAME
2684 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2685
2686 MECHANISM_ASSOCIATION ::=
2687   [formal_parameter_NAME =>] MECHANISM_NAME
2688
2689 MECHANISM_NAME ::=
2690   Value
2691 | Reference
2692 | Descriptor [([Class =>] CLASS_NAME)]
2693 | Short_Descriptor [([Class =>] CLASS_NAME)]
2694
2695 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2696 @end smallexample
2697
2698 @noindent
2699 This pragma is identical to @code{Import_Procedure} except that the
2700 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2701 mode @code{OUT}, and externally the subprogram is treated as a function
2702 with this parameter as the result of the function.  The purpose of this
2703 capability is to allow the use of @code{OUT} and @code{IN OUT}
2704 parameters in interfacing to external functions (which are not permitted
2705 in Ada functions).  You may optionally use the @code{Mechanism}
2706 parameters to specify passing mechanisms for the parameters.
2707 If you specify a single mechanism name, it applies to all parameters.
2708 Otherwise you may specify a mechanism on a parameter by parameter
2709 basis using either positional or named notation.  If the mechanism is not
2710 specified, the default mechanism is used.
2711
2712 Note that it is important to use this pragma in conjunction with a separate
2713 pragma Import that specifies the desired convention, since otherwise the
2714 default convention is Ada, which is almost certainly not what is required.
2715
2716 @node Pragma Initialize_Scalars
2717 @unnumberedsec Pragma Initialize_Scalars
2718 @findex Initialize_Scalars
2719 @cindex debugging with Initialize_Scalars
2720 @noindent
2721 Syntax:
2722
2723 @smallexample @c ada
2724 pragma Initialize_Scalars;
2725 @end smallexample
2726
2727 @noindent
2728 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2729 two important differences.  First, there is no requirement for the pragma
2730 to be used uniformly in all units of a partition, in particular, it is fine
2731 to use this just for some or all of the application units of a partition,
2732 without needing to recompile the run-time library.
2733
2734 In the case where some units are compiled with the pragma, and some without,
2735 then a declaration of a variable where the type is defined in package
2736 Standard or is locally declared will always be subject to initialization,
2737 as will any declaration of a scalar variable.  For composite variables,
2738 whether the variable is initialized may also depend on whether the package
2739 in which the type of the variable is declared is compiled with the pragma.
2740
2741 The other important difference is that you can control the value used
2742 for initializing scalar objects.  At bind time, you can select several
2743 options for initialization. You can
2744 initialize with invalid values (similar to Normalize_Scalars, though for
2745 Initialize_Scalars it is not always possible to determine the invalid
2746 values in complex cases like signed component fields with non-standard
2747 sizes). You can also initialize with high or
2748 low values, or with a specified bit pattern.  See the users guide for binder
2749 options for specifying these cases.
2750
2751 This means that you can compile a program, and then without having to
2752 recompile the program, you can run it with different values being used
2753 for initializing otherwise uninitialized values, to test if your program
2754 behavior depends on the choice.  Of course the behavior should not change,
2755 and if it does, then most likely you have an erroneous reference to an
2756 uninitialized value.
2757
2758 It is even possible to change the value at execution time eliminating even
2759 the need to rebind with a different switch using an environment variable.
2760 See the GNAT users guide for details.
2761
2762 Note that pragma @code{Initialize_Scalars} is particularly useful in
2763 conjunction with the enhanced validity checking that is now provided
2764 in GNAT, which checks for invalid values under more conditions.
2765 Using this feature (see description of the @option{-gnatV} flag in the
2766 users guide) in conjunction with pragma @code{Initialize_Scalars}
2767 provides a powerful new tool to assist in the detection of problems
2768 caused by uninitialized variables.
2769
2770 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2771 effect on the generated code. This may cause your code to be
2772 substantially larger. It may also cause an increase in the amount
2773 of stack required, so it is probably a good idea to turn on stack
2774 checking (see description of stack checking in the GNAT users guide)
2775 when using this pragma.
2776
2777 @node Pragma Inline_Always
2778 @unnumberedsec Pragma Inline_Always
2779 @findex Inline_Always
2780 @noindent
2781 Syntax:
2782
2783 @smallexample @c ada
2784 pragma Inline_Always (NAME [, NAME]);
2785 @end smallexample
2786
2787 @noindent
2788 Similar to pragma @code{Inline} except that inlining is not subject to
2789 the use of option @option{-gnatn} and the inlining happens regardless of
2790 whether this option is used.
2791
2792 @node Pragma Inline_Generic
2793 @unnumberedsec Pragma Inline_Generic
2794 @findex Inline_Generic
2795 @noindent
2796 Syntax:
2797
2798 @smallexample @c ada
2799 pragma Inline_Generic (generic_package_NAME);
2800 @end smallexample
2801
2802 @noindent
2803 This is implemented for compatibility with DEC Ada 83 and is recognized,
2804 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2805 by default when using GNAT@.
2806
2807 @node Pragma Interface
2808 @unnumberedsec Pragma Interface
2809 @findex Interface
2810 @noindent
2811 Syntax:
2812
2813 @smallexample @c ada
2814 pragma Interface (
2815      [Convention    =>] convention_identifier,
2816      [Entity        =>] local_NAME
2817   [, [External_Name =>] static_string_expression]
2818   [, [Link_Name     =>] static_string_expression]);
2819 @end smallexample
2820
2821 @noindent
2822 This pragma is identical in syntax and semantics to
2823 the standard Ada pragma @code{Import}.  It is provided for compatibility
2824 with Ada 83.  The definition is upwards compatible both with pragma
2825 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2826 with some extended implementations of this pragma in certain Ada 83
2827 implementations.
2828
2829 @node Pragma Interface_Name
2830 @unnumberedsec Pragma Interface_Name
2831 @findex Interface_Name
2832 @noindent
2833 Syntax:
2834
2835 @smallexample @c ada
2836 pragma Interface_Name (
2837      [Entity        =>] LOCAL_NAME
2838   [, [External_Name =>] static_string_EXPRESSION]
2839   [, [Link_Name     =>] static_string_EXPRESSION]);
2840 @end smallexample
2841
2842 @noindent
2843 This pragma provides an alternative way of specifying the interface name
2844 for an interfaced subprogram, and is provided for compatibility with Ada
2845 83 compilers that use the pragma for this purpose.  You must provide at
2846 least one of @var{External_Name} or @var{Link_Name}.
2847
2848 @node Pragma Interrupt_Handler
2849 @unnumberedsec Pragma Interrupt_Handler
2850 @findex Interrupt_Handler
2851 @noindent
2852 Syntax:
2853
2854 @smallexample @c ada
2855 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2856 @end smallexample
2857
2858 @noindent
2859 This program unit pragma is supported for parameterless protected procedures
2860 as described in Annex C of the Ada Reference Manual. On the AAMP target
2861 the pragma can also be specified for nonprotected parameterless procedures
2862 that are declared at the library level (which includes procedures
2863 declared at the top level of a library package). In the case of AAMP,
2864 when this pragma is applied to a nonprotected procedure, the instruction
2865 @code{IERET} is generated for returns from the procedure, enabling
2866 maskable interrupts, in place of the normal return instruction.
2867
2868 @node Pragma Interrupt_State
2869 @unnumberedsec Pragma Interrupt_State
2870 @findex Interrupt_State
2871 @noindent
2872 Syntax:
2873
2874 @smallexample @c ada
2875 pragma Interrupt_State
2876  ([Name  =>] value,
2877   [State =>] SYSTEM | RUNTIME | USER);
2878 @end smallexample
2879
2880 @noindent
2881 Normally certain interrupts are reserved to the implementation.  Any attempt
2882 to attach an interrupt causes Program_Error to be raised, as described in
2883 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2884 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2885 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2886 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2887 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2888 Ada exceptions, or used to implement run-time functions such as the
2889 @code{abort} statement and stack overflow checking.
2890
2891 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2892 such uses of interrupts.  It subsumes the functionality of pragma
2893 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2894 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2895 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2896 and may be used to mark interrupts required by the board support package
2897 as reserved.
2898
2899 Interrupts can be in one of three states:
2900 @itemize @bullet
2901 @item System
2902
2903 The interrupt is reserved (no Ada handler can be installed), and the
2904 Ada run-time may not install a handler. As a result you are guaranteed
2905 standard system default action if this interrupt is raised.
2906
2907 @item Runtime
2908
2909 The interrupt is reserved (no Ada handler can be installed). The run time
2910 is allowed to install a handler for internal control purposes, but is
2911 not required to do so.
2912
2913 @item User
2914
2915 The interrupt is unreserved.  The user may install a handler to provide
2916 some other action.
2917 @end itemize
2918
2919 @noindent
2920 These states are the allowed values of the @code{State} parameter of the
2921 pragma.  The @code{Name} parameter is a value of the type
2922 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2923 @code{Ada.Interrupts.Names}.
2924
2925 This is a configuration pragma, and the binder will check that there
2926 are no inconsistencies between different units in a partition in how a
2927 given interrupt is specified. It may appear anywhere a pragma is legal.
2928
2929 The effect is to move the interrupt to the specified state.
2930
2931 By declaring interrupts to be SYSTEM, you guarantee the standard system
2932 action, such as a core dump.
2933
2934 By declaring interrupts to be USER, you guarantee that you can install
2935 a handler.
2936
2937 Note that certain signals on many operating systems cannot be caught and
2938 handled by applications.  In such cases, the pragma is ignored.  See the
2939 operating system documentation, or the value of the array @code{Reserved}
2940 declared in the spec of package @code{System.OS_Interface}.
2941
2942 Overriding the default state of signals used by the Ada runtime may interfere
2943 with an application's runtime behavior in the cases of the synchronous signals,
2944 and in the case of the signal used to implement the @code{abort} statement.
2945
2946 @node Pragma Keep_Names
2947 @unnumberedsec Pragma Keep_Names
2948 @findex Keep_Names
2949 @noindent
2950 Syntax:
2951
2952 @smallexample @c ada
2953 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2954 @end smallexample
2955
2956 @noindent
2957 The @var{LOCAL_NAME} argument
2958 must refer to an enumeration first subtype
2959 in the current declarative part. The effect is to retain the enumeration
2960 literal names for use by @code{Image} and @code{Value} even if a global
2961 @code{Discard_Names} pragma applies. This is useful when you want to
2962 generally suppress enumeration literal names and for example you therefore
2963 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2964 want to retain the names for specific enumeration types.
2965
2966 @node Pragma License
2967 @unnumberedsec Pragma License
2968 @findex License
2969 @cindex License checking
2970 @noindent
2971 Syntax:
2972
2973 @smallexample @c ada
2974 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2975 @end smallexample
2976
2977 @noindent
2978 This pragma is provided to allow automated checking for appropriate license
2979 conditions with respect to the standard and modified GPL@.  A pragma
2980 @code{License}, which is a configuration pragma that typically appears at
2981 the start of a source file or in a separate @file{gnat.adc} file, specifies
2982 the licensing conditions of a unit as follows:
2983
2984 @itemize @bullet
2985 @item Unrestricted
2986 This is used for a unit that can be freely used with no license restrictions.
2987 Examples of such units are public domain units, and units from the Ada
2988 Reference Manual.
2989
2990 @item GPL
2991 This is used for a unit that is licensed under the unmodified GPL, and which
2992 therefore cannot be @code{with}'ed by a restricted unit.
2993
2994 @item Modified_GPL
2995 This is used for a unit licensed under the GNAT modified GPL that includes
2996 a special exception paragraph that specifically permits the inclusion of
2997 the unit in programs without requiring the entire program to be released
2998 under the GPL@.
2999
3000 @item Restricted
3001 This is used for a unit that is restricted in that it is not permitted to
3002 depend on units that are licensed under the GPL@.  Typical examples are
3003 proprietary code that is to be released under more restrictive license
3004 conditions.  Note that restricted units are permitted to @code{with} units
3005 which are licensed under the modified GPL (this is the whole point of the
3006 modified GPL).
3007
3008 @end itemize
3009
3010 @noindent
3011 Normally a unit with no @code{License} pragma is considered to have an
3012 unknown license, and no checking is done.  However, standard GNAT headers
3013 are recognized, and license information is derived from them as follows.
3014
3015 @itemize @bullet
3016
3017 A GNAT license header starts with a line containing 78 hyphens.  The following
3018 comment text is searched for the appearance of any of the following strings.
3019
3020 If the string ``GNU General Public License'' is found, then the unit is assumed
3021 to have GPL license, unless the string ``As a special exception'' follows, in
3022 which case the license is assumed to be modified GPL@.
3023
3024 If one of the strings
3025 ``This specification is adapted from the Ada Semantic Interface'' or
3026 ``This specification is derived from the Ada Reference Manual'' is found
3027 then the unit is assumed to be unrestricted.
3028 @end itemize
3029
3030 @noindent
3031 These default actions means that a program with a restricted license pragma
3032 will automatically get warnings if a GPL unit is inappropriately
3033 @code{with}'ed.  For example, the program:
3034
3035 @smallexample @c ada
3036 with Sem_Ch3;
3037 with GNAT.Sockets;
3038 procedure Secret_Stuff is
3039   @dots{}
3040 end Secret_Stuff
3041 @end smallexample
3042
3043 @noindent
3044 if compiled with pragma @code{License} (@code{Restricted}) in a
3045 @file{gnat.adc} file will generate the warning:
3046
3047 @smallexample
3048 1.  with Sem_Ch3;
3049         |
3050    >>> license of withed unit "Sem_Ch3" is incompatible
3051
3052 2.  with GNAT.Sockets;
3053 3.  procedure Secret_Stuff is
3054 @end smallexample
3055
3056 @noindent
3057 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3058 compiler and is licensed under the
3059 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3060 run time, and is therefore licensed under the modified GPL@.
3061
3062 @node Pragma Link_With
3063 @unnumberedsec Pragma Link_With
3064 @findex Link_With
3065 @noindent
3066 Syntax:
3067
3068 @smallexample @c ada
3069 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3070 @end smallexample
3071
3072 @noindent
3073 This pragma is provided for compatibility with certain Ada 83 compilers.
3074 It has exactly the same effect as pragma @code{Linker_Options} except
3075 that spaces occurring within one of the string expressions are treated
3076 as separators. For example, in the following case:
3077
3078 @smallexample @c ada
3079 pragma Link_With ("-labc -ldef");
3080 @end smallexample
3081
3082 @noindent
3083 results in passing the strings @code{-labc} and @code{-ldef} as two
3084 separate arguments to the linker. In addition pragma Link_With allows
3085 multiple arguments, with the same effect as successive pragmas.
3086
3087 @node Pragma Linker_Alias
3088 @unnumberedsec Pragma Linker_Alias
3089 @findex Linker_Alias
3090 @noindent
3091 Syntax:
3092
3093 @smallexample @c ada
3094 pragma Linker_Alias (
3095   [Entity =>] LOCAL_NAME,
3096   [Target =>] static_string_EXPRESSION);
3097 @end smallexample
3098
3099 @noindent
3100 @var{LOCAL_NAME} must refer to an object that is declared at the library
3101 level. This pragma establishes the given entity as a linker alias for the
3102 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3103 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3104 @var{static_string_EXPRESSION} in the object file, that is to say no space
3105 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3106 to the same address as @var{static_string_EXPRESSION} by the linker.
3107
3108 The actual linker name for the target must be used (e.g.@: the fully
3109 encoded name with qualification in Ada, or the mangled name in C++),
3110 or it must be declared using the C convention with @code{pragma Import}
3111 or @code{pragma Export}.
3112
3113 Not all target machines support this pragma. On some of them it is accepted
3114 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3115
3116 @smallexample @c ada
3117 --  Example of the use of pragma Linker_Alias
3118
3119 package p is
3120   i : Integer := 1;
3121   pragma Export (C, i);
3122
3123   new_name_for_i : Integer;
3124   pragma Linker_Alias (new_name_for_i, "i");
3125 end p;
3126 @end smallexample
3127
3128 @node Pragma Linker_Constructor
3129 @unnumberedsec Pragma Linker_Constructor
3130 @findex Linker_Constructor
3131 @noindent
3132 Syntax:
3133
3134 @smallexample @c ada
3135 pragma Linker_Constructor (procedure_LOCAL_NAME);
3136 @end smallexample
3137
3138 @noindent
3139 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3140 is declared at the library level. A procedure to which this pragma is
3141 applied will be treated as an initialization routine by the linker.
3142 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3143 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3144 of the executable is called (or immediately after the shared library is
3145 loaded if the procedure is linked in a shared library), in particular
3146 before the Ada run-time environment is set up.
3147
3148 Because of these specific contexts, the set of operations such a procedure
3149 can perform is very limited and the type of objects it can manipulate is
3150 essentially restricted to the elementary types. In particular, it must only
3151 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3152
3153 This pragma is used by GNAT to implement auto-initialization of shared Stand
3154 Alone Libraries, which provides a related capability without the restrictions
3155 listed above. Where possible, the use of Stand Alone Libraries is preferable
3156 to the use of this pragma.
3157
3158 @node Pragma Linker_Destructor
3159 @unnumberedsec Pragma Linker_Destructor
3160 @findex Linker_Destructor
3161 @noindent
3162 Syntax:
3163
3164 @smallexample @c ada
3165 pragma Linker_Destructor (procedure_LOCAL_NAME);
3166 @end smallexample
3167
3168 @noindent
3169 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3170 is declared at the library level. A procedure to which this pragma is
3171 applied will be treated as a finalization routine by the linker.
3172 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3173 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3174 of the executable has exited (or immediately before the shared library
3175 is unloaded if the procedure is linked in a shared library), in particular
3176 after the Ada run-time environment is shut down.
3177
3178 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3179 because of these specific contexts.
3180
3181 @node Pragma Linker_Section
3182 @unnumberedsec Pragma Linker_Section
3183 @findex Linker_Section
3184 @noindent
3185 Syntax:
3186
3187 @smallexample @c ada
3188 pragma Linker_Section (
3189   [Entity  =>] LOCAL_NAME,
3190   [Section =>] static_string_EXPRESSION);
3191 @end smallexample
3192
3193 @noindent
3194 @var{LOCAL_NAME} must refer to an object that is declared at the library
3195 level. This pragma specifies the name of the linker section for the given
3196 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3197 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3198 section of the executable (assuming the linker doesn't rename the section).
3199
3200 The compiler normally places library-level objects in standard sections
3201 depending on their type: procedures and functions generally go in the
3202 @code{.text} section, initialized variables in the @code{.data} section
3203 and uninitialized variables in the @code{.bss} section.
3204
3205 Other, special sections may exist on given target machines to map special
3206 hardware, for example I/O ports or flash memory. This pragma is a means to
3207 defer the final layout of the executable to the linker, thus fully working
3208 at the symbolic level with the compiler.
3209
3210 Some file formats do not support arbitrary sections so not all target
3211 machines support this pragma. The use of this pragma may cause a program
3212 execution to be erroneous if it is used to place an entity into an
3213 inappropriate section (e.g.@: a modified variable into the @code{.text}
3214 section). See also @code{pragma Persistent_BSS}.
3215
3216 @smallexample @c ada
3217 --  Example of the use of pragma Linker_Section
3218
3219 package IO_Card is
3220   Port_A : Integer;
3221   pragma Volatile (Port_A);
3222   pragma Linker_Section (Port_A, ".bss.port_a");
3223
3224   Port_B : Integer;
3225   pragma Volatile (Port_B);
3226   pragma Linker_Section (Port_B, ".bss.port_b");
3227 end IO_Card;
3228 @end smallexample
3229
3230 @node Pragma Long_Float
3231 @unnumberedsec Pragma Long_Float
3232 @cindex OpenVMS
3233 @findex Long_Float
3234 @noindent
3235 Syntax:
3236
3237 @smallexample @c ada
3238 pragma Long_Float (FLOAT_FORMAT);
3239
3240 FLOAT_FORMAT ::= D_Float | G_Float
3241 @end smallexample
3242
3243 @noindent
3244 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3245 It allows control over the internal representation chosen for the predefined
3246 type @code{Long_Float} and for floating point type representations with
3247 @code{digits} specified in the range 7 through 15.
3248 For further details on this pragma, see the
3249 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3250 this pragma, the standard runtime libraries must be recompiled.
3251 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3252 @value{EDITION} User's Guide OpenVMS}, for a description of the
3253 @code{GNAT LIBRARY} command.
3254
3255 @node Pragma Machine_Attribute
3256 @unnumberedsec Pragma Machine_Attribute
3257 @findex Machine_Attribute
3258 @noindent
3259 Syntax:
3260
3261 @smallexample @c ada
3262 pragma Machine_Attribute (
3263      [Entity         =>] LOCAL_NAME,
3264      [Attribute_Name =>] static_string_EXPRESSION
3265   [, [Info           =>] static_EXPRESSION] );
3266 @end smallexample
3267
3268 @noindent
3269 Machine-dependent attributes can be specified for types and/or
3270 declarations.  This pragma is semantically equivalent to
3271 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3272 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3273 in GNU C, where @code{@var{attribute_name}} is recognized by the
3274 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3275 specific macro.  A string literal for the optional parameter @var{info}
3276 is transformed into an identifier, which may make this pragma unusable
3277 for some attributes.  @xref{Target Attributes,, Defining target-specific
3278 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3279 Internals}, further information.
3280
3281 @node Pragma Main
3282 @unnumberedsec Pragma Main
3283 @cindex OpenVMS
3284 @findex Main
3285 @noindent
3286 Syntax:
3287
3288 @smallexample @c ada
3289 pragma Main
3290  (MAIN_OPTION [, MAIN_OPTION]);
3291
3292 MAIN_OPTION ::=
3293   [Stack_Size              =>] static_integer_EXPRESSION
3294 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3295 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3296 @end smallexample
3297
3298 @noindent
3299 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3300 no effect in GNAT, other than being syntax checked.
3301
3302 @node Pragma Main_Storage
3303 @unnumberedsec Pragma Main_Storage
3304 @cindex OpenVMS
3305 @findex Main_Storage
3306 @noindent
3307 Syntax:
3308
3309 @smallexample @c ada
3310 pragma Main_Storage
3311   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3312
3313 MAIN_STORAGE_OPTION ::=
3314   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3315 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3316 @end smallexample
3317
3318 @noindent
3319 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3320 no effect in GNAT, other than being syntax checked.  Note that the pragma
3321 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3322
3323 @node Pragma No_Body
3324 @unnumberedsec Pragma No_Body
3325 @findex No_Body
3326 @noindent
3327 Syntax:
3328
3329 @smallexample @c ada
3330 pragma No_Body;
3331 @end smallexample
3332
3333 @noindent
3334 There are a number of cases in which a package spec does not require a body,
3335 and in fact a body is not permitted. GNAT will not permit the spec to be
3336 compiled if there is a body around. The pragma No_Body allows you to provide
3337 a body file, even in a case where no body is allowed. The body file must
3338 contain only comments and a single No_Body pragma. This is recognized by
3339 the compiler as indicating that no body is logically present.
3340
3341 This is particularly useful during maintenance when a package is modified in
3342 such a way that a body needed before is no longer needed. The provision of a
3343 dummy body with a No_Body pragma ensures that there is no interference from
3344 earlier versions of the package body.
3345
3346 @node Pragma No_Return
3347 @unnumberedsec Pragma No_Return
3348 @findex No_Return
3349 @noindent
3350 Syntax:
3351
3352 @smallexample @c ada
3353 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3354 @end smallexample
3355
3356 @noindent
3357 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3358 declarations in the current declarative part.  A procedure to which this
3359 pragma is applied may not contain any explicit @code{return} statements.
3360 In addition, if the procedure contains any implicit returns from falling
3361 off the end of a statement sequence, then execution of that implicit
3362 return will cause Program_Error to be raised.
3363
3364 One use of this pragma is to identify procedures whose only purpose is to raise
3365 an exception. Another use of this pragma is to suppress incorrect warnings
3366 about missing returns in functions, where the last statement of a function
3367 statement sequence is a call to such a procedure.
3368
3369 Note that in Ada 2005 mode, this pragma is part of the language, and is
3370 identical in effect to the pragma as implemented in Ada 95 mode.
3371
3372 @node Pragma No_Strict_Aliasing
3373 @unnumberedsec Pragma No_Strict_Aliasing
3374 @findex No_Strict_Aliasing
3375 @noindent
3376 Syntax:
3377
3378 @smallexample @c ada
3379 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3380 @end smallexample
3381
3382 @noindent
3383 @var{type_LOCAL_NAME} must refer to an access type
3384 declaration in the current declarative part.  The effect is to inhibit
3385 strict aliasing optimization for the given type.  The form with no
3386 arguments is a configuration pragma which applies to all access types
3387 declared in units to which the pragma applies. For a detailed
3388 description of the strict aliasing optimization, and the situations
3389 in which it must be suppressed, see @ref{Optimization and Strict
3390 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3391
3392 @node Pragma Normalize_Scalars
3393 @unnumberedsec Pragma Normalize_Scalars
3394 @findex Normalize_Scalars
3395 @noindent
3396 Syntax:
3397
3398 @smallexample @c ada
3399 pragma Normalize_Scalars;
3400 @end smallexample
3401
3402 @noindent
3403 This is a language defined pragma which is fully implemented in GNAT@.  The
3404 effect is to cause all scalar objects that are not otherwise initialized
3405 to be initialized.  The initial values are implementation dependent and
3406 are as follows:
3407
3408 @table @code
3409 @item Standard.Character
3410 @noindent
3411 Objects whose root type is Standard.Character are initialized to
3412 Character'Last unless the subtype range excludes NUL (in which case
3413 NUL is used). This choice will always generate an invalid value if
3414 one exists.
3415
3416 @item Standard.Wide_Character
3417 @noindent
3418 Objects whose root type is Standard.Wide_Character are initialized to
3419 Wide_Character'Last unless the subtype range excludes NUL (in which case
3420 NUL is used). This choice will always generate an invalid value if
3421 one exists.
3422
3423 @item Standard.Wide_Wide_Character
3424 @noindent
3425 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3426 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3427 which case NUL is used). This choice will always generate an invalid value if
3428 one exists.
3429
3430 @item Integer types
3431 @noindent
3432 Objects of an integer type are treated differently depending on whether
3433 negative values are present in the subtype. If no negative values are
3434 present, then all one bits is used as the initial value except in the
3435 special case where zero is excluded from the subtype, in which case
3436 all zero bits are used. This choice will always generate an invalid
3437 value if one exists.
3438
3439 For subtypes with negative values present, the largest negative number
3440 is used, except in the unusual case where this largest negative number
3441 is in the subtype, and the largest positive number is not, in which case
3442 the largest positive value is used. This choice will always generate
3443 an invalid value if one exists.
3444
3445 @item Floating-Point Types
3446 Objects of all floating-point types are initialized to all 1-bits. For
3447 standard IEEE format, this corresponds to a NaN (not a number) which is
3448 indeed an invalid value.
3449
3450 @item Fixed-Point Types
3451 Objects of all fixed-point types are treated as described above for integers,
3452 with the rules applying to the underlying integer value used to represent
3453 the fixed-point value.
3454
3455 @item Modular types
3456 Objects of a modular type are initialized to all one bits, except in
3457 the special case where zero is excluded from the subtype, in which
3458 case all zero bits are used. This choice will always generate an
3459 invalid value if one exists.
3460
3461 @item Enumeration types
3462 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3463 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3464 whose Pos value is zero, in which case a code of zero is used. This choice
3465 will always generate an invalid value if one exists.
3466
3467 @end table
3468
3469 @node Pragma Obsolescent
3470 @unnumberedsec Pragma Obsolescent
3471 @findex Obsolescent
3472 @noindent
3473 Syntax:
3474
3475 @smallexample @c ada
3476 pragma Obsolescent;
3477
3478 pragma Obsolescent (
3479   [Message =>] static_string_EXPRESSION
3480 [,[Version =>] Ada_05]]);
3481
3482 pragma Obsolescent (
3483   [Entity  =>] NAME
3484 [,[Message =>] static_string_EXPRESSION
3485 [,[Version =>] Ada_05]] );
3486 @end smallexample
3487
3488 @noindent
3489 This pragma can occur immediately following a declaration of an entity,
3490 including the case of a record component. If no Entity argument is present,
3491 then this declaration is the one to which the pragma applies. If an Entity
3492 parameter is present, it must either match the name of the entity in this
3493 declaration, or alternatively, the pragma can immediately follow an enumeration
3494 type declaration, where the Entity argument names one of the enumeration
3495 literals.
3496
3497 This pragma is used to indicate that the named entity
3498 is considered obsolescent and should not be used. Typically this is
3499 used when an API must be modified by eventually removing or modifying
3500 existing subprograms or other entities. The pragma can be used at an
3501 intermediate stage when the entity is still present, but will be
3502 removed later.
3503
3504 The effect of this pragma is to output a warning message on a reference to
3505 an entity thus marked that the subprogram is obsolescent if the appropriate
3506 warning option in the compiler is activated. If the Message parameter is
3507 present, then a second warning message is given containing this text. In
3508 addition, a reference to the eneity is considered to be a violation of pragma
3509 Restrictions (No_Obsolescent_Features).
3510
3511 This pragma can also be used as a program unit pragma for a package,
3512 in which case the entity name is the name of the package, and the
3513 pragma indicates that the entire package is considered
3514 obsolescent. In this case a client @code{with}'ing such a package
3515 violates the restriction, and the @code{with} statement is
3516 flagged with warnings if the warning option is set.
3517
3518 If the Version parameter is present (which must be exactly
3519 the identifier Ada_05, no other argument is allowed), then the
3520 indication of obsolescence applies only when compiling in Ada 2005
3521 mode. This is primarily intended for dealing with the situations
3522 in the predefined library where subprograms or packages
3523 have become defined as obsolescent in Ada 2005
3524 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3525
3526 The following examples show typical uses of this pragma:
3527
3528 @smallexample @c ada
3529 package p is
3530    pragma Obsolescent (p, Message => "use pp instead of p");
3531 end p;
3532
3533 package q is
3534    procedure q2;
3535    pragma Obsolescent ("use q2new instead");
3536
3537    type R is new integer;
3538    pragma Obsolescent
3539      (Entity  => R,
3540       Message => "use RR in Ada 2005",
3541       Version => Ada_05);
3542
3543    type M is record
3544       F1 : Integer;
3545       F2 : Integer;
3546       pragma Obsolescent;
3547       F3 : Integer;
3548    end record;
3549
3550    type E is (a, bc, 'd', quack);
3551    pragma Obsolescent (Entity => bc)
3552    pragma Obsolescent (Entity => 'd')
3553
3554    function "+"
3555      (a, b : character) return character;
3556    pragma Obsolescent (Entity => "+");
3557 end;
3558 @end smallexample
3559
3560 @noindent
3561 Note that, as for all pragmas, if you use a pragma argument identifier,
3562 then all subsequent parameters must also use a pragma argument identifier.
3563 So if you specify "Entity =>" for the Entity argument, and a Message
3564 argument is present, it must be preceded by "Message =>".
3565
3566 @node Pragma Optimize_Alignment
3567 @unnumberedsec Pragma Optimize_Alignment
3568 @findex Optimize_Alignment
3569 @cindex Alignment, default settings
3570 @noindent
3571 Syntax:
3572
3573 @smallexample @c ada
3574 pragma Optimize_Alignment (TIME | SPACE | OFF);
3575 @end smallexample
3576
3577 @noindent
3578 This is a configuration pragma which affects the choice of default alignments
3579 for types where no alignment is explicitly specified. There is a time/space
3580 trade-off in the selection of these values. Large alignments result in more
3581 efficient code, at the expense of larger data space, since sizes have to be
3582 increased to match these alignments. Smaller alignments save space, but the
3583 access code is slower. The normal choice of default alignments (which is what
3584 you get if you do not use this pragma, or if you use an argument of OFF),
3585 tries to balance these two requirements.
3586
3587 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3588 First any packed record is given an alignment of 1. Second, if a size is given
3589 for the type, then the alignment is chosen to avoid increasing this size. For
3590 example, consider:
3591
3592 @smallexample @c ada
3593    type R is record
3594       X : Integer;
3595       Y : Character;
3596    end record;
3597
3598    for R'Size use 5*8;
3599 @end smallexample
3600
3601 @noindent
3602 In the default mode, this type gets an alignment of 4, so that access to the
3603 Integer field X are efficient. But this means that objects of the type end up
3604 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3605 allowed to be bigger than the size of the type, but it can waste space if for
3606 example fields of type R appear in an enclosing record. If the above type is
3607 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3608
3609 Specifying TIME causes larger default alignments to be chosen in the case of
3610 small types with sizes that are not a power of 2. For example, consider:
3611
3612 @smallexample @c ada
3613    type R is record
3614       A : Character;
3615       B : Character;
3616       C : Boolean;
3617    end record;
3618
3619    pragma Pack (R);
3620    for R'Size use 17;
3621 @end smallexample
3622
3623 @noindent
3624 The default alignment for this record is normally 1, but if this type is
3625 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3626 to 4, which wastes space for objects of the type, since they are now 4 bytes
3627 long, but results in more efficient access when the whole record is referenced.
3628
3629 As noted above, this is a configuration pragma, and there is a requirement
3630 that all units in a partition be compiled with a consistent setting of the
3631 optimization setting. This would normally be achieved by use of a configuration
3632 pragma file containing the appropriate setting. The exception to this rule is
3633 that units with an explicit configuration pragma in the same file as the source
3634 unit are excluded from the consistency check, as are all predefined units. The
3635 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3636 pragma appears at the start of the file.
3637
3638 @node Pragma Passive
3639 @unnumberedsec Pragma Passive
3640 @findex Passive
3641 @noindent
3642 Syntax:
3643
3644 @smallexample @c ada
3645 pragma Passive [(Semaphore | No)];
3646 @end smallexample
3647
3648 @noindent
3649 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3650 compatibility with DEC Ada 83 implementations, where it is used within a
3651 task definition to request that a task be made passive.  If the argument
3652 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3653 treats the pragma as an assertion that the containing task is passive
3654 and that optimization of context switch with this task is permitted and
3655 desired.  If the argument @code{No} is present, the task must not be
3656 optimized.  GNAT does not attempt to optimize any tasks in this manner
3657 (since protected objects are available in place of passive tasks).
3658
3659 @node Pragma Persistent_BSS
3660 @unnumberedsec Pragma Persistent_BSS
3661 @findex Persistent_BSS
3662 @noindent
3663 Syntax:
3664
3665 @smallexample @c ada
3666 pragma Persistent_BSS [(LOCAL_NAME)]
3667 @end smallexample
3668
3669 @noindent
3670 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3671 section. On some targets the linker and loader provide for special
3672 treatment of this section, allowing a program to be reloaded without
3673 affecting the contents of this data (hence the name persistent).
3674
3675 There are two forms of usage. If an argument is given, it must be the
3676 local name of a library level object, with no explicit initialization
3677 and whose type is potentially persistent. If no argument is given, then
3678 the pragma is a configuration pragma, and applies to all library level
3679 objects with no explicit initialization of potentially persistent types.
3680
3681 A potentially persistent type is a scalar type, or a non-tagged,
3682 non-discriminated record, all of whose components have no explicit
3683 initialization and are themselves of a potentially persistent type,
3684 or an array, all of whose constraints are static, and whose component
3685 type is potentially persistent.
3686
3687 If this pragma is used on a target where this feature is not supported,
3688 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3689
3690 @node Pragma Polling
3691 @unnumberedsec Pragma Polling
3692 @findex Polling
3693 @noindent
3694 Syntax:
3695
3696 @smallexample @c ada
3697 pragma Polling (ON | OFF);
3698 @end smallexample
3699
3700 @noindent
3701 This pragma controls the generation of polling code.  This is normally off.
3702 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3703 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3704 runtime library, and can be found in file @file{a-excpol.adb}.
3705
3706 Pragma @code{Polling} can appear as a configuration pragma (for example it
3707 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3708 can be used in the statement or declaration sequence to control polling
3709 more locally.
3710
3711 A call to the polling routine is generated at the start of every loop and
3712 at the start of every subprogram call.  This guarantees that the @code{Poll}
3713 routine is called frequently, and places an upper bound (determined by
3714 the complexity of the code) on the period between two @code{Poll} calls.
3715
3716 The primary purpose of the polling interface is to enable asynchronous
3717 aborts on targets that cannot otherwise support it (for example Windows
3718 NT), but it may be used for any other purpose requiring periodic polling.
3719 The standard version is null, and can be replaced by a user program.  This
3720 will require re-compilation of the @code{Ada.Exceptions} package that can
3721 be found in files @file{a-except.ads} and @file{a-except.adb}.
3722
3723 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3724 distribution) is used to enable the asynchronous abort capability on
3725 targets that do not normally support the capability.  The version of
3726 @code{Poll} in this file makes a call to the appropriate runtime routine
3727 to test for an abort condition.
3728
3729 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3730 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3731 details.
3732
3733 @node Pragma Postcondition
3734 @unnumberedsec Pragma Postcondition
3735 @cindex Postconditions
3736 @cindex Checks, postconditions
3737 @findex Postconditions
3738 @noindent
3739 Syntax:
3740
3741 @smallexample @c ada
3742 pragma Postcondition (
3743    [Check   =>] Boolean_Expression
3744  [,[Message =>] String_Expression]);
3745 @end smallexample
3746
3747 @noindent
3748 The @code{Postcondition} pragma allows specification of automatic
3749 postcondition checks for subprograms. These checks are similar to
3750 assertions, but are automatically inserted just prior to the return
3751 statements of the subprogram with which they are associated (including
3752 implicit returns at the end of procedure bodies and associated
3753 exception handlers).
3754
3755 In addition, the boolean expression which is the condition which
3756 must be true may contain references to function'Result in the case
3757 of a function to refer to the returned value.
3758
3759 @code{Postcondition} pragmas may appear either immediate following the
3760 (separate) declaration of a subprogram, or at the start of the
3761 declarations of a subprogram body. Only other pragmas may intervene
3762 (that is appear between the subprogram declaration and its
3763 postconditions, or appear before the postcondition in the
3764 declaration sequence in a subprogram body). In the case of a
3765 postcondition appearing after a subprogram declaration, the
3766 formal arguments of the subprogram are visible, and can be
3767 referenced in the postcondition expressions.
3768
3769 The postconditions are collected and automatically tested just
3770 before any return (implicit or explicit) in the subprogram body.
3771 A postcondition is only recognized if postconditions are active
3772 at the time the pragma is encountered. The compiler switch @option{gnata}
3773 turns on all postconditions by default, and pragma @code{Check_Policy}
3774 with an identifier of @code{Postcondition} can also be used to
3775 control whether postconditions are active.
3776
3777 The general approach is that postconditions are placed in the spec
3778 if they represent functional aspects which make sense to the client.
3779 For example we might have:
3780
3781 @smallexample @c ada
3782    function Direction return Integer;
3783    pragma Postcondition
3784     (Direction'Result = +1
3785        or else
3786      Direction'Result = -1);
3787 @end smallexample
3788
3789 @noindent
3790 which serves to document that the result must be +1 or -1, and
3791 will test that this is the case at run time if postcondition
3792 checking is active.
3793
3794 Postconditions within the subprogram body can be used to
3795 check that some internal aspect of the implementation,
3796 not visible to the client, is operating as expected.
3797 For instance if a square root routine keeps an internal
3798 counter of the number of times it is called, then we
3799 might have the following postcondition:
3800
3801 @smallexample @c ada
3802    Sqrt_Calls : Natural := 0;
3803
3804    function Sqrt (Arg : Float) return Float is
3805      pragma Postcondition
3806        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3807      ...
3808    end Sqrt
3809 @end smallexample
3810
3811 @noindent
3812 As this example, shows, the use of the @code{Old} attribute
3813 is often useful in postconditions to refer to the state on
3814 entry to the subprogram.
3815
3816 Note that postconditions are only checked on normal returns
3817 from the subprogram. If an abnormal return results from
3818 raising an exception, then the postconditions are not checked.
3819
3820 If a postcondition fails, then the exception
3821 @code{System.Assertions.Assert_Failure} is raised. If
3822 a message argument was supplied, then the given string
3823 will be used as the exception message. If no message
3824 argument was supplied, then the default message has
3825 the form "Postcondition failed at file:line". The
3826 exception is raised in the context of the subprogram
3827 body, so it is possible to catch postcondition failures
3828 within the subprogram body itself.
3829
3830 Within a package spec, normal visibility rules
3831 in Ada would prevent forward references within a
3832 postcondition pragma to functions defined later in
3833 the same package. This would introduce undesirable
3834 ordering constraints. To avoid this problem, all
3835 postcondition pragmas are analyzed at the end of
3836 the package spec, allowing forward references.
3837
3838 The following example shows that this even allows
3839 mutually recursive postconditions as in:
3840
3841 @smallexample @c ada
3842 package Parity_Functions is
3843    function Odd  (X : Natural) return Boolean;
3844    pragma Postcondition
3845      (Odd'Result =
3846         (x = 1
3847           or else
3848         (x /= 0 and then Even (X - 1))));
3849
3850    function Even (X : Natural) return Boolean;
3851    pragma Postcondition
3852      (Even'Result =
3853         (x = 0
3854           or else
3855         (x /= 1 and then Odd (X - 1))));
3856
3857 end Parity_Functions;
3858 @end smallexample
3859
3860 @noindent
3861 There are no restrictions on the complexity or form of
3862 conditions used within @code{Postcondition} pragmas.
3863 The following example shows that it is even possible
3864 to verify performance behavior.
3865
3866 @smallexample @c ada
3867 package Sort is
3868
3869    Performance : constant Float;
3870    --  Performance constant set by implementation
3871    --  to match target architecture behavior.
3872
3873    procedure Treesort (Arg : String);
3874    --  Sorts characters of argument using N*logN sort
3875    pragma Postcondition
3876      (Float (Clock - Clock'Old) <=
3877         Float (Arg'Length) *
3878         log (Float (Arg'Length)) *
3879         Performance);
3880 end Sort;
3881 @end smallexample
3882
3883 @noindent
3884 Note: postcondition pragmas associated with subprograms that are
3885 marked as Inline_Always, or those marked as Inline with front-end
3886 inlining (-gnatN option set) are accepted and legality-checked
3887 by the compiler, but are ignored at run-time even if postcondition
3888 checking is enabled.
3889
3890 @node Pragma Precondition
3891 @unnumberedsec Pragma Precondition
3892 @cindex Preconditions
3893 @cindex Checks, preconditions
3894 @findex Preconditions
3895 @noindent
3896 Syntax:
3897
3898 @smallexample @c ada
3899 pragma Precondition (
3900    [Check   =>] Boolean_Expression
3901  [,[Message =>] String_Expression]);
3902 @end smallexample
3903
3904 @noindent
3905 The @code{Precondition} pragma is similar to @code{Postcondition}
3906 except that the corresponding checks take place immediately upon
3907 entry to the subprogram, and if a precondition fails, the exception
3908 is raised in the context of the caller, and the attribute 'Result
3909 cannot be used within the precondition expression.
3910
3911 Otherwise, the placement and visibility rules are identical to those
3912 described for postconditions. The following is an example of use
3913 within a package spec:
3914
3915 @smallexample @c ada
3916 package Math_Functions is
3917    ...
3918    function Sqrt (Arg : Float) return Float;
3919    pragma Precondition (Arg >= 0.0)
3920    ...
3921 end Math_Functions;
3922 @end smallexample
3923
3924 @noindent
3925 @code{Precondition} pragmas may appear either immediate following the
3926 (separate) declaration of a subprogram, or at the start of the
3927 declarations of a subprogram body. Only other pragmas may intervene
3928 (that is appear between the subprogram declaration and its
3929 postconditions, or appear before the postcondition in the
3930 declaration sequence in a subprogram body).
3931
3932 Note: postcondition pragmas associated with subprograms that are
3933 marked as Inline_Always, or those marked as Inline with front-end
3934 inlining (-gnatN option set) are accepted and legality-checked
3935 by the compiler, but are ignored at run-time even if postcondition
3936 checking is enabled.
3937
3938
3939
3940 @node Pragma Profile (Ravenscar)
3941 @unnumberedsec Pragma Profile (Ravenscar)
3942 @findex Ravenscar
3943 @noindent
3944 Syntax:
3945
3946 @smallexample @c ada
3947 pragma Profile (Ravenscar);
3948 @end smallexample
3949
3950 @noindent
3951 A configuration pragma that establishes the following set of configuration
3952 pragmas:
3953
3954 @table @code
3955 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3956 [RM D.2.2] Tasks are dispatched following a preemptive
3957 priority-ordered scheduling policy.
3958
3959 @item Locking_Policy (Ceiling_Locking)
3960 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3961 the ceiling priority of the corresponding protected object.
3962 @c
3963 @c @item Detect_Blocking
3964 @c This pragma forces the detection of potentially blocking operations within a
3965 @c protected operation, and to raise Program_Error if that happens.
3966 @end table
3967 @noindent
3968
3969 plus the following set of restrictions:
3970
3971 @table @code
3972 @item Max_Entry_Queue_Length = 1
3973 Defines the maximum number of calls that are queued on a (protected) entry.
3974 Note that this restrictions is checked at run time. Violation of this
3975 restriction results in the raising of Program_Error exception at the point of
3976 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3977 always 1 and hence no task can be queued on a protected entry.
3978
3979 @item Max_Protected_Entries = 1
3980 [RM D.7] Specifies the maximum number of entries per protected type. The
3981 bounds of every entry family of a protected unit shall be static, or shall be
3982 defined by a discriminant of a subtype whose corresponding bound is static.
3983 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3984
3985 @item Max_Task_Entries = 0
3986 [RM D.7] Specifies the maximum number of entries
3987 per task.  The bounds of every entry family
3988 of a task unit shall be static, or shall be
3989 defined by a discriminant of a subtype whose
3990 corresponding bound is static.  A value of zero
3991 indicates that no rendezvous are possible.  For
3992 the Profile (Ravenscar), the value of Max_Task_Entries is always
3993 0 (zero).
3994
3995 @item No_Abort_Statements
3996 [RM D.7] There are no abort_statements, and there are
3997 no calls to Task_Identification.Abort_Task.
3998
3999 @item No_Asynchronous_Control
4000 There are no semantic dependences on the package
4001 Asynchronous_Task_Control.
4002
4003 @item No_Calendar
4004 There are no semantic dependencies on the package Ada.Calendar.
4005
4006 @item No_Dynamic_Attachment
4007 There is no call to any of the operations defined in package Ada.Interrupts
4008 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4009 Detach_Handler, and Reference).
4010
4011 @item No_Dynamic_Priorities
4012 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4013
4014 @item No_Implicit_Heap_Allocations
4015 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4016
4017 @item No_Local_Protected_Objects
4018 Protected objects and access types that designate
4019 such objects shall be declared only at library level.
4020
4021 @item No_Local_Timing_Events
4022 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4023 declared at the library level.
4024
4025 @item No_Protected_Type_Allocators
4026 There are no allocators for protected types or
4027 types containing protected subcomponents.
4028
4029 @item No_Relative_Delay
4030 There are no delay_relative statements.
4031
4032 @item No_Requeue_Statements
4033 Requeue statements are not allowed.
4034
4035 @item No_Select_Statements
4036 There are no select_statements.
4037
4038 @item No_Specific_Termination_Handlers
4039 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4040 or to Ada.Task_Termination.Specific_Handler.
4041
4042 @item No_Task_Allocators
4043 [RM D.7] There are no allocators for task types
4044 or types containing task subcomponents.
4045
4046 @item No_Task_Attributes_Package
4047 There are no semantic dependencies on the Ada.Task_Attributes package.
4048
4049 @item No_Task_Hierarchy
4050 [RM D.7] All (non-environment) tasks depend
4051 directly on the environment task of the partition.
4052
4053 @item No_Task_Termination
4054 Tasks which terminate are erroneous.
4055
4056 @item No_Unchecked_Conversion
4057 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4058
4059 @item No_Unchecked_Deallocation
4060 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4061
4062 @item Simple_Barriers
4063 Entry barrier condition expressions shall be either static
4064 boolean expressions or boolean objects which are declared in
4065 the protected type which contains the entry.
4066 @end table
4067
4068 @noindent
4069 This set of configuration pragmas and restrictions correspond to the
4070 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4071 published by the @cite{International Real-Time Ada Workshop}, 1997,
4072 and whose most recent description is available at
4073 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4074
4075 The original definition of the profile was revised at subsequent IRTAW
4076 meetings. It has been included in the ISO
4077 @cite{Guide for the Use of the Ada Programming Language in High
4078 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4079 the next revision of the standard. The formal definition given by
4080 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4081 AI-305) available at
4082 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4083 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4084 respectively.
4085
4086 The above set is a superset of the restrictions provided by pragma
4087 @code{Profile (Restricted)}, it includes six additional restrictions
4088 (@code{Simple_Barriers}, @code{No_Select_Statements},
4089 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4090 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4091 that pragma @code{Profile (Ravenscar)}, like the pragma
4092 @code{Profile (Restricted)},
4093 automatically causes the use of a simplified,
4094 more efficient version of the tasking run-time system.
4095
4096 @node Pragma Profile (Restricted)
4097 @unnumberedsec Pragma Profile (Restricted)
4098 @findex Restricted Run Time
4099 @noindent
4100 Syntax:
4101
4102 @smallexample @c ada
4103 pragma Profile (Restricted);
4104 @end smallexample
4105
4106 @noindent
4107 A configuration pragma that establishes the following set of restrictions:
4108
4109 @itemize @bullet
4110 @item No_Abort_Statements
4111 @item No_Entry_Queue
4112 @item No_Task_Hierarchy
4113 @item No_Task_Allocators
4114 @item No_Dynamic_Priorities
4115 @item No_Terminate_Alternatives
4116 @item No_Dynamic_Attachment
4117 @item No_Protected_Type_Allocators
4118 @item No_Local_Protected_Objects
4119 @item No_Requeue_Statements
4120 @item No_Task_Attributes_Package
4121 @item Max_Asynchronous_Select_Nesting =  0
4122 @item Max_Task_Entries =  0
4123 @item Max_Protected_Entries = 1
4124 @item Max_Select_Alternatives = 0
4125 @end itemize
4126
4127 @noindent
4128 This set of restrictions causes the automatic selection of a simplified
4129 version of the run time that provides improved performance for the
4130 limited set of tasking functionality permitted by this set of restrictions.
4131
4132 @node Pragma Psect_Object
4133 @unnumberedsec Pragma Psect_Object
4134 @findex Psect_Object
4135 @noindent
4136 Syntax:
4137
4138 @smallexample @c ada
4139 pragma Psect_Object (
4140      [Internal =>] LOCAL_NAME,
4141   [, [External =>] EXTERNAL_SYMBOL]
4142   [, [Size     =>] EXTERNAL_SYMBOL]);
4143
4144 EXTERNAL_SYMBOL ::=
4145   IDENTIFIER
4146 | static_string_EXPRESSION
4147 @end smallexample
4148
4149 @noindent
4150 This pragma is identical in effect to pragma @code{Common_Object}.
4151
4152 @node Pragma Pure_Function
4153 @unnumberedsec Pragma Pure_Function
4154 @findex Pure_Function
4155 @noindent
4156 Syntax:
4157
4158 @smallexample @c ada
4159 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4160 @end smallexample
4161
4162 @noindent
4163 This pragma appears in the same declarative part as a function
4164 declaration (or a set of function declarations if more than one
4165 overloaded declaration exists, in which case the pragma applies
4166 to all entities).  It specifies that the function @code{Entity} is
4167 to be considered pure for the purposes of code generation.  This means
4168 that the compiler can assume that there are no side effects, and
4169 in particular that two calls with identical arguments produce the
4170 same result.  It also means that the function can be used in an
4171 address clause.
4172
4173 Note that, quite deliberately, there are no static checks to try
4174 to ensure that this promise is met, so @code{Pure_Function} can be used
4175 with functions that are conceptually pure, even if they do modify
4176 global variables.  For example, a square root function that is
4177 instrumented to count the number of times it is called is still
4178 conceptually pure, and can still be optimized, even though it
4179 modifies a global variable (the count).  Memo functions are another
4180 example (where a table of previous calls is kept and consulted to
4181 avoid re-computation).
4182
4183 @findex Pure
4184 Note: Most functions in a @code{Pure} package are automatically pure, and
4185 there is no need to use pragma @code{Pure_Function} for such functions.  One
4186 exception is any function that has at least one formal of type
4187 @code{System.Address} or a type derived from it.  Such functions are not
4188 considered pure by default, since the compiler assumes that the
4189 @code{Address} parameter may be functioning as a pointer and that the
4190 referenced data may change even if the address value does not.
4191 Similarly, imported functions are not considered to be pure by default,
4192 since there is no way of checking that they are in fact pure.  The use
4193 of pragma @code{Pure_Function} for such a function will override these default
4194 assumption, and cause the compiler to treat a designated subprogram as pure
4195 in these cases.
4196
4197 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4198 applies to the underlying renamed function.  This can be used to
4199 disambiguate cases of overloading where some but not all functions
4200 in a set of overloaded functions are to be designated as pure.
4201
4202 If pragma @code{Pure_Function} is applied to a library level function, the
4203 function is also considered pure from an optimization point of view, but the
4204 unit is not a Pure unit in the categorization sense. So for example, a function
4205 thus marked is free to @code{with} non-pure units.
4206
4207 @node Pragma Restriction_Warnings
4208 @unnumberedsec Pragma Restriction_Warnings
4209 @findex Restriction_Warnings
4210 @noindent
4211 Syntax:
4212
4213 @smallexample @c ada
4214 pragma Restriction_Warnings
4215   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4216 @end smallexample
4217
4218 @noindent
4219 This pragma allows a series of restriction identifiers to be
4220 specified (the list of allowed identifiers is the same as for
4221 pragma @code{Restrictions}). For each of these identifiers
4222 the compiler checks for violations of the restriction, but
4223 generates a warning message rather than an error message
4224 if the restriction is violated.
4225
4226 @node Pragma Shared
4227 @unnumberedsec Pragma Shared
4228 @findex Shared
4229
4230 @noindent
4231 This pragma is provided for compatibility with Ada 83. The syntax and
4232 semantics are identical to pragma Atomic.
4233
4234 @node Pragma Source_File_Name
4235 @unnumberedsec Pragma Source_File_Name
4236 @findex Source_File_Name
4237 @noindent
4238 Syntax:
4239
4240 @smallexample @c ada
4241 pragma Source_File_Name (
4242   [Unit_Name   =>] unit_NAME,
4243   Spec_File_Name =>  STRING_LITERAL,
4244   [Index => INTEGER_LITERAL]);
4245
4246 pragma Source_File_Name (
4247   [Unit_Name   =>] unit_NAME,
4248   Body_File_Name =>  STRING_LITERAL,
4249   [Index => INTEGER_LITERAL]);
4250 @end smallexample
4251
4252 @noindent
4253 Use this to override the normal naming convention.  It is a configuration
4254 pragma, and so has the usual applicability of configuration pragmas
4255 (i.e.@: it applies to either an entire partition, or to all units in a
4256 compilation, or to a single unit, depending on how it is used.
4257 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4258 the second argument is required, and indicates whether this is the file
4259 name for the spec or for the body.
4260
4261 The optional Index argument should be used when a file contains multiple
4262 units, and when you do not want to use @code{gnatchop} to separate then
4263 into multiple files (which is the recommended procedure to limit the
4264 number of recompilation that are needed when some sources change).
4265 For instance, if the source file @file{source.ada} contains
4266
4267 @smallexample @c ada
4268 package B is
4269 ...
4270 end B;
4271
4272 with B;
4273 procedure A is
4274 begin
4275    ..
4276 end A;
4277 @end smallexample
4278
4279 you could use the following configuration pragmas:
4280
4281 @smallexample @c ada
4282 pragma Source_File_Name
4283   (B, Spec_File_Name => "source.ada", Index => 1);
4284 pragma Source_File_Name
4285   (A, Body_File_Name => "source.ada", Index => 2);
4286 @end smallexample
4287
4288 Note that the @code{gnatname} utility can also be used to generate those
4289 configuration pragmas.
4290
4291 Another form of the @code{Source_File_Name} pragma allows
4292 the specification of patterns defining alternative file naming schemes
4293 to apply to all files.
4294
4295 @smallexample @c ada
4296 pragma Source_File_Name
4297   (  [Spec_File_Name  =>] STRING_LITERAL
4298    [,[Casing          =>] CASING_SPEC]
4299    [,[Dot_Replacement =>] STRING_LITERAL]);
4300
4301 pragma Source_File_Name
4302   (  [Body_File_Name  =>] STRING_LITERAL
4303    [,[Casing          =>] CASING_SPEC]
4304    [,[Dot_Replacement =>] STRING_LITERAL]);
4305
4306 pragma Source_File_Name
4307   (  [Subunit_File_Name =>] STRING_LITERAL
4308    [,[Casing            =>] CASING_SPEC]
4309    [,[Dot_Replacement   =>] STRING_LITERAL]);
4310
4311 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4312 @end smallexample
4313
4314 @noindent
4315 The first argument is a pattern that contains a single asterisk indicating
4316 the point at which the unit name is to be inserted in the pattern string
4317 to form the file name.  The second argument is optional.  If present it
4318 specifies the casing of the unit name in the resulting file name string.
4319 The default is lower case.  Finally the third argument allows for systematic
4320 replacement of any dots in the unit name by the specified string literal.
4321
4322 A pragma Source_File_Name cannot appear after a
4323 @ref{Pragma Source_File_Name_Project}.
4324
4325 For more details on the use of the @code{Source_File_Name} pragma,
4326 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4327 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4328 User's Guide}.
4329
4330 @node Pragma Source_File_Name_Project
4331 @unnumberedsec Pragma Source_File_Name_Project
4332 @findex Source_File_Name_Project
4333 @noindent
4334
4335 This pragma has the same syntax and semantics as pragma Source_File_Name.
4336 It is only allowed as a stand alone configuration pragma.
4337 It cannot appear after a @ref{Pragma Source_File_Name}, and
4338 most importantly, once pragma Source_File_Name_Project appears,
4339 no further Source_File_Name pragmas are allowed.
4340
4341 The intention is that Source_File_Name_Project pragmas are always
4342 generated by the Project Manager in a manner consistent with the naming
4343 specified in a project file, and when naming is controlled in this manner,
4344 it is not permissible to attempt to modify this naming scheme using
4345 Source_File_Name pragmas (which would not be known to the project manager).
4346
4347 @node Pragma Source_Reference
4348 @unnumberedsec Pragma Source_Reference
4349 @findex Source_Reference
4350 @noindent
4351 Syntax:
4352
4353 @smallexample @c ada
4354 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4355 @end smallexample
4356
4357 @noindent
4358 This pragma must appear as the first line of a source file.
4359 @var{integer_literal} is the logical line number of the line following
4360 the pragma line (for use in error messages and debugging
4361 information).  @var{string_literal} is a static string constant that
4362 specifies the file name to be used in error messages and debugging
4363 information.  This is most notably used for the output of @code{gnatchop}
4364 with the @option{-r} switch, to make sure that the original unchopped
4365 source file is the one referred to.
4366
4367 The second argument must be a string literal, it cannot be a static
4368 string expression other than a string literal.  This is because its value
4369 is needed for error messages issued by all phases of the compiler.
4370
4371 @node Pragma Stream_Convert
4372 @unnumberedsec Pragma Stream_Convert
4373 @findex Stream_Convert
4374 @noindent
4375 Syntax:
4376
4377 @smallexample @c ada
4378 pragma Stream_Convert (
4379   [Entity =>] type_LOCAL_NAME,
4380   [Read   =>] function_NAME,
4381   [Write  =>] function_NAME);
4382 @end smallexample
4383
4384 @noindent
4385 This pragma provides an efficient way of providing stream functions for
4386 types defined in packages.  Not only is it simpler to use than declaring
4387 the necessary functions with attribute representation clauses, but more
4388 significantly, it allows the declaration to made in such a way that the
4389 stream packages are not loaded unless they are needed.  The use of
4390 the Stream_Convert pragma adds no overhead at all, unless the stream
4391 attributes are actually used on the designated type.
4392
4393 The first argument specifies the type for which stream functions are
4394 provided.  The second parameter provides a function used to read values
4395 of this type.  It must name a function whose argument type may be any
4396 subtype, and whose returned type must be the type given as the first
4397 argument to the pragma.
4398
4399 The meaning of the @var{Read}
4400 parameter is that if a stream attribute directly
4401 or indirectly specifies reading of the type given as the first parameter,
4402 then a value of the type given as the argument to the Read function is
4403 read from the stream, and then the Read function is used to convert this
4404 to the required target type.
4405
4406 Similarly the @var{Write} parameter specifies how to treat write attributes
4407 that directly or indirectly apply to the type given as the first parameter.
4408 It must have an input parameter of the type specified by the first parameter,
4409 and the return type must be the same as the input type of the Read function.
4410 The effect is to first call the Write function to convert to the given stream
4411 type, and then write the result type to the stream.
4412
4413 The Read and Write functions must not be overloaded subprograms.  If necessary
4414 renamings can be supplied to meet this requirement.
4415 The usage of this attribute is best illustrated by a simple example, taken
4416 from the GNAT implementation of package Ada.Strings.Unbounded:
4417
4418 @smallexample @c ada
4419 function To_Unbounded (S : String)
4420            return Unbounded_String
4421   renames To_Unbounded_String;
4422
4423 pragma Stream_Convert
4424   (Unbounded_String, To_Unbounded, To_String);
4425 @end smallexample
4426
4427 @noindent
4428 The specifications of the referenced functions, as given in the Ada
4429 Reference Manual are:
4430
4431 @smallexample @c ada
4432 function To_Unbounded_String (Source : String)
4433   return Unbounded_String;
4434
4435 function To_String (Source : Unbounded_String)
4436   return String;
4437 @end smallexample
4438
4439 @noindent
4440 The effect is that if the value of an unbounded string is written to a stream,
4441 then the representation of the item in the stream is in the same format that
4442 would be used for @code{Standard.String'Output}, and this same representation
4443 is expected when a value of this type is read from the stream. Note that the
4444 value written always includes the bounds, even for Unbounded_String'Write,
4445 since Unbounded_String is not an array type.
4446
4447 @node Pragma Style_Checks
4448 @unnumberedsec Pragma Style_Checks
4449 @findex Style_Checks
4450 @noindent
4451 Syntax:
4452
4453 @smallexample @c ada
4454 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4455                      On | Off [, LOCAL_NAME]);
4456 @end smallexample
4457
4458 @noindent
4459 This pragma is used in conjunction with compiler switches to control the
4460 built in style checking provided by GNAT@.  The compiler switches, if set,
4461 provide an initial setting for the switches, and this pragma may be used
4462 to modify these settings, or the settings may be provided entirely by
4463 the use of the pragma.  This pragma can be used anywhere that a pragma
4464 is legal, including use as a configuration pragma (including use in
4465 the @file{gnat.adc} file).
4466
4467 The form with a string literal specifies which style options are to be
4468 activated.  These are additive, so they apply in addition to any previously
4469 set style check options.  The codes for the options are the same as those
4470 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4471 For example the following two methods can be used to enable
4472 layout checking:
4473
4474 @itemize @bullet
4475 @item
4476 @smallexample @c ada
4477 pragma Style_Checks ("l");
4478 @end smallexample
4479
4480 @item
4481 @smallexample
4482 gcc -c -gnatyl @dots{}
4483 @end smallexample
4484 @end itemize
4485
4486 @noindent
4487 The form ALL_CHECKS activates all standard checks (its use is equivalent
4488 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4489 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4490 @value{EDITION} User's Guide}, for details.
4491
4492 The forms with @code{Off} and @code{On}
4493 can be used to temporarily disable style checks
4494 as shown in the following example:
4495
4496 @smallexample @c ada
4497 @iftex
4498 @leftskip=0cm
4499 @end iftex
4500 pragma Style_Checks ("k"); -- requires keywords in lower case
4501 pragma Style_Checks (Off); -- turn off style checks
4502 NULL;                      -- this will not generate an error message
4503 pragma Style_Checks (On);  -- turn style checks back on
4504 NULL;                      -- this will generate an error message
4505 @end smallexample
4506
4507 @noindent
4508 Finally the two argument form is allowed only if the first argument is
4509 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4510 for the specified entity, as shown in the following example:
4511
4512 @smallexample @c ada
4513 @iftex
4514 @leftskip=0cm
4515 @end iftex
4516 pragma Style_Checks ("r"); -- require consistency of identifier casing
4517 Arg : Integer;
4518 Rf1 : Integer := ARG;      -- incorrect, wrong case
4519 pragma Style_Checks (Off, Arg);
4520 Rf2 : Integer := ARG;      -- OK, no error
4521 @end smallexample
4522
4523 @node Pragma Subtitle
4524 @unnumberedsec Pragma Subtitle
4525 @findex Subtitle
4526 @noindent
4527 Syntax:
4528
4529 @smallexample @c ada
4530 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4531 @end smallexample
4532
4533 @noindent
4534 This pragma is recognized for compatibility with other Ada compilers
4535 but is ignored by GNAT@.
4536
4537 @node Pragma Suppress
4538 @unnumberedsec Pragma Suppress
4539 @findex Suppress
4540 @noindent
4541 Syntax:
4542
4543 @smallexample @c ada
4544 pragma Suppress (Identifier [, [On =>] Name]);
4545 @end smallexample
4546
4547 @noindent
4548 This is a standard pragma, and supports all the check names required in
4549 the RM. It is included here because GNAT recognizes one additional check
4550 name: @code{Alignment_Check} which can be used to suppress alignment checks
4551 on addresses used in address clauses. Such checks can also be suppressed
4552 by suppressing range checks, but the specific use of @code{Alignment_Check}
4553 allows suppression of alignment checks without suppressing other range checks.
4554
4555 Note that pragma Suppress gives the compiler permission to omit
4556 checks, but does not require the compiler to omit checks. The compiler
4557 will generate checks if they are essentially free, even when they are
4558 suppressed. In particular, if the compiler can prove that a certain
4559 check will necessarily fail, it will generate code to do an
4560 unconditional ``raise'', even if checks are suppressed. The compiler
4561 warns in this case.
4562
4563 Of course, run-time checks are omitted whenever the compiler can prove
4564 that they will not fail, whether or not checks are suppressed.
4565
4566 @node Pragma Suppress_All
4567 @unnumberedsec Pragma Suppress_All
4568 @findex Suppress_All
4569 @noindent
4570 Syntax:
4571
4572 @smallexample @c ada
4573 pragma Suppress_All;
4574 @end smallexample
4575
4576 @noindent
4577 This pragma can only appear immediately following a compilation
4578 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4579 which it follows.  This pragma is implemented for compatibility with DEC
4580 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4581 configuration pragma is the preferred usage in GNAT@.
4582
4583 @node Pragma Suppress_Exception_Locations
4584 @unnumberedsec Pragma Suppress_Exception_Locations
4585 @findex Suppress_Exception_Locations
4586 @noindent
4587 Syntax:
4588
4589 @smallexample @c ada
4590 pragma Suppress_Exception_Locations;
4591 @end smallexample
4592
4593 @noindent
4594 In normal mode, a raise statement for an exception by default generates
4595 an exception message giving the file name and line number for the location
4596 of the raise. This is useful for debugging and logging purposes, but this
4597 entails extra space for the strings for the messages. The configuration
4598 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4599 generation of these strings, with the result that space is saved, but the
4600 exception message for such raises is null. This configuration pragma may
4601 appear in a global configuration pragma file, or in a specific unit as
4602 usual. It is not required that this pragma be used consistently within
4603 a partition, so it is fine to have some units within a partition compiled
4604 with this pragma and others compiled in normal mode without it.
4605
4606 @node Pragma Suppress_Initialization
4607 @unnumberedsec Pragma Suppress_Initialization
4608 @findex Suppress_Initialization
4609 @cindex Suppressing initialization
4610 @cindex Initialization, suppression of
4611 @noindent
4612 Syntax:
4613
4614 @smallexample @c ada
4615 pragma Suppress_Initialization ([Entity =>] type_Name);
4616 @end smallexample
4617
4618 @noindent
4619 This pragma suppresses any implicit or explicit initialization
4620 associated with the given type name for all variables of this type.
4621
4622 @node Pragma Task_Info
4623 @unnumberedsec Pragma Task_Info
4624 @findex Task_Info
4625 @noindent
4626 Syntax
4627
4628 @smallexample @c ada
4629 pragma Task_Info (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 @code{System.Task_Info.Task_Info_Type}.
4636 The @code{Task_Info} pragma provides system dependent control over
4637 aspects of tasking implementation, for example, the ability to map
4638 tasks to specific processors.  For details on the facilities available
4639 for the version of GNAT that you are using, see the documentation
4640 in the spec of package System.Task_Info in the runtime
4641 library.
4642
4643 @node Pragma Task_Name
4644 @unnumberedsec Pragma Task_Name
4645 @findex Task_Name
4646 @noindent
4647 Syntax
4648
4649 @smallexample @c ada
4650 pragma Task_Name (string_EXPRESSION);
4651 @end smallexample
4652
4653 @noindent
4654 This pragma appears within a task definition (like pragma
4655 @code{Priority}) and applies to the task in which it appears.  The
4656 argument must be of type String, and provides a name to be used for
4657 the task instance when the task is created.  Note that this expression
4658 is not required to be static, and in particular, it can contain
4659 references to task discriminants.  This facility can be used to
4660 provide different names for different tasks as they are created,
4661 as illustrated in the example below.
4662
4663 The task name is recorded internally in the run-time structures
4664 and is accessible to tools like the debugger.  In addition the
4665 routine @code{Ada.Task_Identification.Image} will return this
4666 string, with a unique task address appended.
4667
4668 @smallexample @c ada
4669 --  Example of the use of pragma Task_Name
4670
4671 with Ada.Task_Identification;
4672 use Ada.Task_Identification;
4673 with Text_IO; use Text_IO;
4674 procedure t3 is
4675
4676    type Astring is access String;
4677
4678    task type Task_Typ (Name : access String) is
4679       pragma Task_Name (Name.all);
4680    end Task_Typ;
4681
4682    task body Task_Typ is
4683       Nam : constant String := Image (Current_Task);
4684    begin
4685       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4686    end Task_Typ;
4687
4688    type Ptr_Task is access Task_Typ;
4689    Task_Var : Ptr_Task;
4690
4691 begin
4692    Task_Var :=
4693      new Task_Typ (new String'("This is task 1"));
4694    Task_Var :=
4695      new Task_Typ (new String'("This is task 2"));
4696 end;
4697 @end smallexample
4698
4699 @node Pragma Task_Storage
4700 @unnumberedsec Pragma Task_Storage
4701 @findex Task_Storage
4702 Syntax:
4703
4704 @smallexample @c ada
4705 pragma Task_Storage (
4706   [Task_Type =>] LOCAL_NAME,
4707   [Top_Guard =>] static_integer_EXPRESSION);
4708 @end smallexample
4709
4710 @noindent
4711 This pragma specifies the length of the guard area for tasks.  The guard
4712 area is an additional storage area allocated to a task.  A value of zero
4713 means that either no guard area is created or a minimal guard area is
4714 created, depending on the target.  This pragma can appear anywhere a
4715 @code{Storage_Size} attribute definition clause is allowed for a task
4716 type.
4717
4718 @node Pragma Thread_Local_Storage
4719 @unnumberedsec Pragma Thread_Local_Storage
4720 @findex Thread_Local_Storage
4721 @cindex Task specific storage
4722 @cindex TLS (Thread Local Storage)
4723 Syntax:
4724
4725 @smallexample @c ada
4726 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4727 @end smallexample
4728
4729 @noindent
4730 This pragma specifies that the specified entity, which must be
4731 a variable declared in a library level package, is to be marked as
4732 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4733 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4734 (and hence each Ada task) to see a distinct copy of the variable.
4735
4736 The variable may not have default initialization, and if there is
4737 an explicit initialization, it must be either @code{null} for an
4738 access variable, or a static expression for a scalar variable.
4739 This provides a low level mechanism similar to that provided by
4740 the @code{Ada.Task_Attributes} package, but much more efficient
4741 and is also useful in writing interface code that will interact
4742 with foreign threads.
4743
4744 If this pragma is used on a system where @code{TLS} is not supported,
4745 then an error message will be generated and the program will be rejected.
4746
4747 @node Pragma Time_Slice
4748 @unnumberedsec Pragma Time_Slice
4749 @findex Time_Slice
4750 @noindent
4751 Syntax:
4752
4753 @smallexample @c ada
4754 pragma Time_Slice (static_duration_EXPRESSION);
4755 @end smallexample
4756
4757 @noindent
4758 For implementations of GNAT on operating systems where it is possible
4759 to supply a time slice value, this pragma may be used for this purpose.
4760 It is ignored if it is used in a system that does not allow this control,
4761 or if it appears in other than the main program unit.
4762 @cindex OpenVMS
4763 Note that the effect of this pragma is identical to the effect of the
4764 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4765
4766 @node Pragma Title
4767 @unnumberedsec Pragma Title
4768 @findex Title
4769 @noindent
4770 Syntax:
4771
4772 @smallexample @c ada
4773 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4774
4775 TITLING_OPTION ::=
4776   [Title    =>] STRING_LITERAL,
4777 | [Subtitle =>] STRING_LITERAL
4778 @end smallexample
4779
4780 @noindent
4781 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4782 pragma used in DEC Ada 83 implementations to provide a title and/or
4783 subtitle for the program listing.  The program listing generated by GNAT
4784 does not have titles or subtitles.
4785
4786 Unlike other pragmas, the full flexibility of named notation is allowed
4787 for this pragma, i.e.@: the parameters may be given in any order if named
4788 notation is used, and named and positional notation can be mixed
4789 following the normal rules for procedure calls in Ada.
4790
4791 @node Pragma Unchecked_Union
4792 @unnumberedsec Pragma Unchecked_Union
4793 @cindex Unions in C
4794 @findex Unchecked_Union
4795 @noindent
4796 Syntax:
4797
4798 @smallexample @c ada
4799 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4800 @end smallexample
4801
4802 @noindent
4803 This pragma is used to specify a representation of a record type that is
4804 equivalent to a C union. It was introduced as a GNAT implementation defined
4805 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4806 pragma, making it language defined, and GNAT fully implements this extended
4807 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4808 details, consult the Ada 2005 Reference Manual, section B.3.3.
4809
4810 @node Pragma Unimplemented_Unit
4811 @unnumberedsec Pragma Unimplemented_Unit
4812 @findex Unimplemented_Unit
4813 @noindent
4814 Syntax:
4815
4816 @smallexample @c ada
4817 pragma Unimplemented_Unit;
4818 @end smallexample
4819
4820 @noindent
4821 If this pragma occurs in a unit that is processed by the compiler, GNAT
4822 aborts with the message @samp{@var{xxx} not implemented}, where
4823 @var{xxx} is the name of the current compilation unit.  This pragma is
4824 intended to allow the compiler to handle unimplemented library units in
4825 a clean manner.
4826
4827 The abort only happens if code is being generated.  Thus you can use
4828 specs of unimplemented packages in syntax or semantic checking mode.
4829
4830 @node Pragma Universal_Aliasing
4831 @unnumberedsec Pragma Universal_Aliasing
4832 @findex Universal_Aliasing
4833 @noindent
4834 Syntax:
4835
4836 @smallexample @c ada
4837 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4838 @end smallexample
4839
4840 @noindent
4841 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4842 declarative part.  The effect is to inhibit strict type-based aliasing
4843 optimization for the given type.  In other words, the effect is as though
4844 access types designating this type were subject to pragma No_Strict_Aliasing.
4845 For a detailed description of the strict aliasing optimization, and the
4846 situations in which it must be suppressed, @xref{Optimization and Strict
4847 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4848
4849 @node Pragma Universal_Data
4850 @unnumberedsec Pragma Universal_Data
4851 @findex Universal_Data
4852 @noindent
4853 Syntax:
4854
4855 @smallexample @c ada
4856 pragma Universal_Data [(library_unit_Name)];
4857 @end smallexample
4858
4859 @noindent
4860 This pragma is supported only for the AAMP target and is ignored for
4861 other targets. The pragma specifies that all library-level objects
4862 (Counter 0 data) associated with the library unit are to be accessed
4863 and updated using universal addressing (24-bit addresses for AAMP5)
4864 rather than the default of 16-bit Data Environment (DENV) addressing.
4865 Use of this pragma will generally result in less efficient code for
4866 references to global data associated with the library unit, but
4867 allows such data to be located anywhere in memory. This pragma is
4868 a library unit pragma, but can also be used as a configuration pragma
4869 (including use in the @file{gnat.adc} file). The functionality
4870 of this pragma is also available by applying the -univ switch on the
4871 compilations of units where universal addressing of the data is desired.
4872
4873 @node Pragma Unmodified
4874 @unnumberedsec Pragma Unmodified
4875 @findex Unmodified
4876 @cindex Warnings, unmodified
4877 @noindent
4878 Syntax:
4879
4880 @smallexample @c ada
4881 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4882 @end smallexample
4883
4884 @noindent
4885 This pragma signals that the assignable entities (variables,
4886 @code{out} parameters, @code{in out} parameters) whose names are listed are
4887 deliberately not assigned in the current source unit. This
4888 suppresses warnings about the
4889 entities being referenced but not assigned, and in addition a warning will be
4890 generated if one of these entities is in fact assigned in the
4891 same unit as the pragma (or in the corresponding body, or one
4892 of its subunits).
4893
4894 This is particularly useful for clearly signaling that a particular
4895 parameter is not modified, even though the spec suggests that it might
4896 be.
4897
4898 @node Pragma Unreferenced
4899 @unnumberedsec Pragma Unreferenced
4900 @findex Unreferenced
4901 @cindex Warnings, unreferenced
4902 @noindent
4903 Syntax:
4904
4905 @smallexample @c ada
4906 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4907 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4908 @end smallexample
4909
4910 @noindent
4911 This pragma signals that the entities whose names are listed are
4912 deliberately not referenced in the current source unit. This
4913 suppresses warnings about the
4914 entities being unreferenced, and in addition a warning will be
4915 generated if one of these entities is in fact referenced in the
4916 same unit as the pragma (or in the corresponding body, or one
4917 of its subunits).
4918
4919 This is particularly useful for clearly signaling that a particular
4920 parameter is not referenced in some particular subprogram implementation
4921 and that this is deliberate. It can also be useful in the case of
4922 objects declared only for their initialization or finalization side
4923 effects.
4924
4925 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4926 current scope, then the entity most recently declared is the one to which
4927 the pragma applies. Note that in the case of accept formals, the pragma
4928 Unreferenced may appear immediately after the keyword @code{do} which
4929 allows the indication of whether or not accept formals are referenced
4930 or not to be given individually for each accept statement.
4931
4932 The left hand side of an assignment does not count as a reference for the
4933 purpose of this pragma. Thus it is fine to assign to an entity for which
4934 pragma Unreferenced is given.
4935
4936 Note that if a warning is desired for all calls to a given subprogram,
4937 regardless of whether they occur in the same unit as the subprogram
4938 declaration, then this pragma should not be used (calls from another
4939 unit would not be flagged); pragma Obsolescent can be used instead
4940 for this purpose, see @xref{Pragma Obsolescent}.
4941
4942 The second form of pragma @code{Unreferenced} is used within a context
4943 clause. In this case the arguments must be unit names of units previously
4944 mentioned in @code{with} clauses (similar to the usage of pragma
4945 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4946 units and unreferenced entities within these units.
4947
4948 @node Pragma Unreferenced_Objects
4949 @unnumberedsec Pragma Unreferenced_Objects
4950 @findex Unreferenced_Objects
4951 @cindex Warnings, unreferenced
4952 @noindent
4953 Syntax:
4954
4955 @smallexample @c ada
4956 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4957 @end smallexample
4958
4959 @noindent
4960 This pragma signals that for the types or subtypes whose names are
4961 listed, objects which are declared with one of these types or subtypes may
4962 not be referenced, and if no references appear, no warnings are given.
4963
4964 This is particularly useful for objects which are declared solely for their
4965 initialization and finalization effect. Such variables are sometimes referred
4966 to as RAII variables (Resource Acquisition Is Initialization). Using this
4967 pragma on the relevant type (most typically a limited controlled type), the
4968 compiler will automatically suppress unwanted warnings about these variables
4969 not being referenced.
4970
4971 @node Pragma Unreserve_All_Interrupts
4972 @unnumberedsec Pragma Unreserve_All_Interrupts
4973 @findex Unreserve_All_Interrupts
4974 @noindent
4975 Syntax:
4976
4977 @smallexample @c ada
4978 pragma Unreserve_All_Interrupts;
4979 @end smallexample
4980
4981 @noindent
4982 Normally certain interrupts are reserved to the implementation.  Any attempt
4983 to attach an interrupt causes Program_Error to be raised, as described in
4984 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4985 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4986 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4987 interrupt execution.
4988
4989 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4990 a program, then all such interrupts are unreserved.  This allows the
4991 program to handle these interrupts, but disables their standard
4992 functions.  For example, if this pragma is used, then pressing
4993 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4994 a program can then handle the @code{SIGINT} interrupt as it chooses.
4995
4996 For a full list of the interrupts handled in a specific implementation,
4997 see the source code for the spec of @code{Ada.Interrupts.Names} in
4998 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4999 list of interrupts recognized for a given target.  The documentation in
5000 this file also specifies what interrupts are affected by the use of
5001 the @code{Unreserve_All_Interrupts} pragma.
5002
5003 For a more general facility for controlling what interrupts can be
5004 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5005 of the @code{Unreserve_All_Interrupts} pragma.
5006
5007 @node Pragma Unsuppress
5008 @unnumberedsec Pragma Unsuppress
5009 @findex Unsuppress
5010 @noindent
5011 Syntax:
5012
5013 @smallexample @c ada
5014 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5015 @end smallexample
5016
5017 @noindent
5018 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5019 there is no corresponding pragma @code{Suppress} in effect, it has no
5020 effect.  The range of the effect is the same as for pragma
5021 @code{Suppress}.  The meaning of the arguments is identical to that used
5022 in pragma @code{Suppress}.
5023
5024 One important application is to ensure that checks are on in cases where
5025 code depends on the checks for its correct functioning, so that the code
5026 will compile correctly even if the compiler switches are set to suppress
5027 checks.
5028
5029 @node Pragma Use_VADS_Size
5030 @unnumberedsec Pragma Use_VADS_Size
5031 @cindex @code{Size}, VADS compatibility
5032 @findex Use_VADS_Size
5033 @noindent
5034 Syntax:
5035
5036 @smallexample @c ada
5037 pragma Use_VADS_Size;
5038 @end smallexample
5039
5040 @noindent
5041 This is a configuration pragma.  In a unit to which it applies, any use
5042 of the 'Size attribute is automatically interpreted as a use of the
5043 'VADS_Size attribute.  Note that this may result in incorrect semantic
5044 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5045 the handling of existing code which depends on the interpretation of Size
5046 as implemented in the VADS compiler.  See description of the VADS_Size
5047 attribute for further details.
5048
5049 @node Pragma Validity_Checks
5050 @unnumberedsec Pragma Validity_Checks
5051 @findex Validity_Checks
5052 @noindent
5053 Syntax:
5054
5055 @smallexample @c ada
5056 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5057 @end smallexample
5058
5059 @noindent
5060 This pragma is used in conjunction with compiler switches to control the
5061 built-in validity checking provided by GNAT@.  The compiler switches, if set
5062 provide an initial setting for the switches, and this pragma may be used
5063 to modify these settings, or the settings may be provided entirely by
5064 the use of the pragma.  This pragma can be used anywhere that a pragma
5065 is legal, including use as a configuration pragma (including use in
5066 the @file{gnat.adc} file).
5067
5068 The form with a string literal specifies which validity options are to be
5069 activated.  The validity checks are first set to include only the default
5070 reference manual settings, and then a string of letters in the string
5071 specifies the exact set of options required.  The form of this string
5072 is exactly as described for the @option{-gnatVx} compiler switch (see the
5073 GNAT users guide for details).  For example the following two methods
5074 can be used to enable validity checking for mode @code{in} and
5075 @code{in out} subprogram parameters:
5076
5077 @itemize @bullet
5078 @item
5079 @smallexample @c ada
5080 pragma Validity_Checks ("im");
5081 @end smallexample
5082
5083 @item
5084 @smallexample
5085 gcc -c -gnatVim @dots{}
5086 @end smallexample
5087 @end itemize
5088
5089 @noindent
5090 The form ALL_CHECKS activates all standard checks (its use is equivalent
5091 to the use of the @code{gnatva} switch.
5092
5093 The forms with @code{Off} and @code{On}
5094 can be used to temporarily disable validity checks
5095 as shown in the following example:
5096
5097 @smallexample @c ada
5098 @iftex
5099 @leftskip=0cm
5100 @end iftex
5101 pragma Validity_Checks ("c"); -- validity checks for copies
5102 pragma Validity_Checks (Off); -- turn off validity checks
5103 A := B;                       -- B will not be validity checked
5104 pragma Validity_Checks (On);  -- turn validity checks back on
5105 A := C;                       -- C will be validity checked
5106 @end smallexample
5107
5108 @node Pragma Volatile
5109 @unnumberedsec Pragma Volatile
5110 @findex Volatile
5111 @noindent
5112 Syntax:
5113
5114 @smallexample @c ada
5115 pragma Volatile (LOCAL_NAME);
5116 @end smallexample
5117
5118 @noindent
5119 This pragma is defined by the Ada Reference Manual, and the GNAT
5120 implementation is fully conformant with this definition.  The reason it
5121 is mentioned in this section is that a pragma of the same name was supplied
5122 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5123 implementation of pragma Volatile is upwards compatible with the
5124 implementation in DEC Ada 83.
5125
5126 @node Pragma Warnings
5127 @unnumberedsec Pragma Warnings
5128 @findex Warnings
5129 @noindent
5130 Syntax:
5131
5132 @smallexample @c ada
5133 pragma Warnings (On | Off);
5134 pragma Warnings (On | Off, LOCAL_NAME);
5135 pragma Warnings (static_string_EXPRESSION);
5136 pragma Warnings (On | Off, static_string_EXPRESSION);
5137 @end smallexample
5138
5139 @noindent
5140 Normally warnings are enabled, with the output being controlled by
5141 the command line switch.  Warnings (@code{Off}) turns off generation of
5142 warnings until a Warnings (@code{On}) is encountered or the end of the
5143 current unit.  If generation of warnings is turned off using this
5144 pragma, then no warning messages are output, regardless of the
5145 setting of the command line switches.
5146
5147 The form with a single argument may be used as a configuration pragma.
5148
5149 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5150 the specified entity.  This suppression is effective from the point where
5151 it occurs till the end of the extended scope of the variable (similar to
5152 the scope of @code{Suppress}).
5153
5154 The form with a single static_string_EXPRESSION argument provides more precise
5155 control over which warnings are active. The string is a list of letters
5156 specifying which warnings are to be activated and which deactivated. The
5157 code for these letters is the same as the string used in the command
5158 line switch controlling warnings. The following is a brief summary. For
5159 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5160 User's Guide}.
5161
5162 @smallexample
5163 a    turn on all optional warnings (except d h l .o)
5164 A    turn off all optional warnings
5165 .a*  turn on warnings for failing assertions
5166 .A   turn off warnings for failing assertions
5167 b    turn on warnings for bad fixed value (not multiple of small)
5168 B*   turn off warnings for bad fixed value (not multiple of small)
5169 .b*  turn on warnings for biased representation
5170 .B   turn off warnings for biased representation
5171 c    turn on warnings for constant conditional
5172 C*   turn off warnings for constant conditional
5173 .c   turn on warnings for unrepped components
5174 .C*  turn off warnings for unrepped components
5175 d    turn on warnings for implicit dereference
5176 D*   turn off warnings for implicit dereference
5177 e    treat all warnings as errors
5178 .e   turn on every optional warning
5179 f    turn on warnings for unreferenced formal
5180 F*   turn off warnings for unreferenced formal
5181 g*   turn on warnings for unrecognized pragma
5182 G    turn off warnings for unrecognized pragma
5183 h    turn on warnings for hiding variable
5184 H*   turn off warnings for hiding variable
5185 i*   turn on warnings for implementation unit
5186 I    turn off warnings for implementation unit
5187 j    turn on warnings for obsolescent (annex J) feature
5188 J*   turn off warnings for obsolescent (annex J) feature
5189 k    turn on warnings on constant variable
5190 K*   turn off warnings on constant variable
5191 l    turn on warnings for missing elaboration pragma
5192 L*   turn off warnings for missing elaboration pragma
5193 m    turn on warnings for variable assigned but not read
5194 M*   turn off warnings for variable assigned but not read
5195 n*   normal warning mode (cancels -gnatws/-gnatwe)
5196 o*   turn on warnings for address clause overlay
5197 O    turn off warnings for address clause overlay
5198 .o   turn on warnings for out parameters assigned but not read
5199 .O*  turn off warnings for out parameters assigned but not read
5200 p    turn on warnings for ineffective pragma Inline in frontend
5201 P*   turn off warnings for ineffective pragma Inline in frontend
5202 .p   turn on warnings for parameter ordering
5203 .P*  turn off warnings for parameter ordering
5204 q*   turn on warnings for questionable missing parentheses
5205 Q    turn off warnings for questionable missing parentheses
5206 r    turn on warnings for redundant construct
5207 R*   turn off warnings for redundant construct
5208 .r   turn on warnings for object renaming function
5209 .R*  turn off warnings for object renaming function
5210 s    suppress all warnings
5211 t    turn on warnings for tracking deleted code
5212 T*   turn off warnings for tracking deleted code
5213 u    turn on warnings for unused entity
5214 U*   turn off warnings for unused entity
5215 v*   turn on warnings for unassigned variable
5216 V    turn off warnings for unassigned variable
5217 w*   turn on warnings for wrong low bound assumption
5218 W    turn off warnings for wrong low bound assumption
5219 .w   turn on warnings for unnecessary Warnings Off pragmas
5220 .W*  turn off warnings for unnecessary Warnings Off pragmas
5221 x*   turn on warnings for export/import
5222 X    turn off warnings for export/import
5223 .x   turn on warnings for non-local exceptions
5224 .X*  turn off warnings for non-local exceptions
5225 y*   turn on warnings for Ada 2005 incompatibility
5226 Y    turn off warnings for Ada 2005 incompatibility
5227 z*   turn on convention/size/align warnings for unchecked conversion
5228 Z    turn off convention/size/align warnings for unchecked conversion
5229 *    indicates default in above list
5230 @end smallexample
5231
5232 @noindent
5233 The specified warnings will be in effect until the end of the program
5234 or another pragma Warnings is encountered. The effect of the pragma is
5235 cumulative. Initially the set of warnings is the standard default set
5236 as possibly modified by compiler switches. Then each pragma Warning
5237 modifies this set of warnings as specified. This form of the pragma may
5238 also be used as a configuration pragma.
5239
5240 The fourth form, with an On|Off parameter and a string, is used to
5241 control individual messages, based on their text. The string argument
5242 is a pattern that is used to match against the text of individual
5243 warning messages (not including the initial "warning: " tag).
5244
5245 The pattern may contain asterisks, which match zero or more characters in
5246 the message. For example, you can use
5247 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5248 message @code{warning: 960 bits of "a" unused}. No other regular
5249 expression notations are permitted. All characters other than asterisk in
5250 these three specific cases are treated as literal characters in the match.
5251
5252 There are two ways to use this pragma. The OFF form can be used as a
5253 configuration pragma. The effect is to suppress all warnings (if any)
5254 that match the pattern string throughout the compilation.
5255
5256 The second usage is to suppress a warning locally, and in this case, two
5257 pragmas must appear in sequence:
5258
5259 @smallexample @c ada
5260 pragma Warnings (Off, Pattern);
5261 @dots{} code where given warning is to be suppressed
5262 pragma Warnings (On, Pattern);
5263 @end smallexample
5264
5265 @noindent
5266 In this usage, the pattern string must match in the Off and On pragmas,
5267 and at least one matching warning must be suppressed.
5268
5269 @node Pragma Weak_External
5270 @unnumberedsec Pragma Weak_External
5271 @findex Weak_External
5272 @noindent
5273 Syntax:
5274
5275 @smallexample @c ada
5276 pragma Weak_External ([Entity =>] LOCAL_NAME);
5277 @end smallexample
5278
5279 @noindent
5280 @var{LOCAL_NAME} must refer to an object that is declared at the library
5281 level. This pragma specifies that the given entity should be marked as a
5282 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5283 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5284 of a regular symbol, that is to say a symbol that does not have to be
5285 resolved by the linker if used in conjunction with a pragma Import.
5286
5287 When a weak symbol is not resolved by the linker, its address is set to
5288 zero. This is useful in writing interfaces to external modules that may
5289 or may not be linked in the final executable, for example depending on
5290 configuration settings.
5291
5292 If a program references at run time an entity to which this pragma has been
5293 applied, and the corresponding symbol was not resolved at link time, then
5294 the execution of the program is erroneous. It is not erroneous to take the
5295 Address of such an entity, for example to guard potential references,
5296 as shown in the example below.
5297
5298 Some file formats do not support weak symbols so not all target machines
5299 support this pragma.
5300
5301 @smallexample @c ada
5302 --  Example of the use of pragma Weak_External
5303
5304 package External_Module is
5305   key : Integer;
5306   pragma Import (C, key);
5307   pragma Weak_External (key);
5308   function Present return boolean;
5309 end External_Module;
5310
5311 with System; use System;
5312 package body External_Module is
5313   function Present return boolean is
5314   begin
5315     return key'Address /= System.Null_Address;
5316   end Present;
5317 end External_Module;
5318 @end smallexample
5319
5320 @node Pragma Wide_Character_Encoding
5321 @unnumberedsec Pragma Wide_Character_Encoding
5322 @findex Wide_Character_Encoding
5323 @noindent
5324 Syntax:
5325
5326 @smallexample @c ada
5327 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5328 @end smallexample
5329
5330 @noindent
5331 This pragma specifies the wide character encoding to be used in program
5332 source text appearing subsequently. It is a configuration pragma, but may
5333 also be used at any point that a pragma is allowed, and it is permissible
5334 to have more than one such pragma in a file, allowing multiple encodings
5335 to appear within the same file.
5336
5337 The argument can be an identifier or a character literal. In the identifier
5338 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5339 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5340 case it is correspondingly one of the characters @samp{h}, @samp{u},
5341 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5342
5343 Note that when the pragma is used within a file, it affects only the
5344 encoding within that file, and does not affect withed units, specs,
5345 or subunits.
5346
5347 @node Implementation Defined Attributes
5348 @chapter Implementation Defined Attributes
5349 Ada defines (throughout the Ada reference manual,
5350 summarized in Annex K),
5351 a set of attributes that provide useful additional functionality in all
5352 areas of the language.  These language defined attributes are implemented
5353 in GNAT and work as described in the Ada Reference Manual.
5354
5355 In addition, Ada allows implementations to define additional
5356 attributes whose meaning is defined by the implementation.  GNAT provides
5357 a number of these implementation-dependent attributes which can be used
5358 to extend and enhance the functionality of the compiler.  This section of
5359 the GNAT reference manual describes these additional attributes.
5360
5361 Note that any program using these attributes may not be portable to
5362 other compilers (although GNAT implements this set of attributes on all
5363 platforms).  Therefore if portability to other compilers is an important
5364 consideration, you should minimize the use of these attributes.
5365
5366 @menu
5367 * Abort_Signal::
5368 * Address_Size::
5369 * Asm_Input::
5370 * Asm_Output::
5371 * AST_Entry::
5372 * Bit::
5373 * Bit_Position::
5374 * Compiler_Version::
5375 * Code_Address::
5376 * Default_Bit_Order::
5377 * Elaborated::
5378 * Elab_Body::
5379 * Elab_Spec::
5380 * Emax::
5381 * Enabled::
5382 * Enum_Rep::
5383 * Enum_Val::
5384 * Epsilon::
5385 * Fixed_Value::
5386 * Has_Access_Values::
5387 * Has_Discriminants::
5388 * Img::
5389 * Integer_Value::
5390 * Invalid_Value::
5391 * Large::
5392 * Machine_Size::
5393 * Mantissa::
5394 * Max_Interrupt_Priority::
5395 * Max_Priority::
5396 * Maximum_Alignment::
5397 * Mechanism_Code::
5398 * Null_Parameter::
5399 * Object_Size::
5400 * Old::
5401 * Passed_By_Reference::
5402 * Pool_Address::
5403 * Range_Length::
5404 * Safe_Emax::
5405 * Safe_Large::
5406 * Small::
5407 * Storage_Unit::
5408 * Stub_Type::
5409 * Target_Name::
5410 * Tick::
5411 * To_Address::
5412 * Type_Class::
5413 * UET_Address::
5414 * Unconstrained_Array::
5415 * Universal_Literal_String::
5416 * Unrestricted_Access::
5417 * VADS_Size::
5418 * Value_Size::
5419 * Wchar_T_Size::
5420 * Word_Size::
5421 @end menu
5422
5423 @node Abort_Signal
5424 @unnumberedsec Abort_Signal
5425 @findex Abort_Signal
5426 @noindent
5427 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5428 prefix) provides the entity for the special exception used to signal
5429 task abort or asynchronous transfer of control.  Normally this attribute
5430 should only be used in the tasking runtime (it is highly peculiar, and
5431 completely outside the normal semantics of Ada, for a user program to
5432 intercept the abort exception).
5433
5434 @node Address_Size
5435 @unnumberedsec Address_Size
5436 @cindex Size of @code{Address}
5437 @findex Address_Size
5438 @noindent
5439 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5440 prefix) is a static constant giving the number of bits in an
5441 @code{Address}. It is the same value as System.Address'Size,
5442 but has the advantage of being static, while a direct
5443 reference to System.Address'Size is non-static because Address
5444 is a private type.
5445
5446 @node Asm_Input
5447 @unnumberedsec Asm_Input
5448 @findex Asm_Input
5449 @noindent
5450 The @code{Asm_Input} attribute denotes a function that takes two
5451 parameters.  The first is a string, the second is an expression of the
5452 type designated by the prefix.  The first (string) argument is required
5453 to be a static expression, and is the constraint for the parameter,
5454 (e.g.@: what kind of register is required).  The second argument is the
5455 value to be used as the input argument.  The possible values for the
5456 constant are the same as those used in the RTL, and are dependent on
5457 the configuration file used to built the GCC back end.
5458 @ref{Machine Code Insertions}
5459
5460 @node Asm_Output
5461 @unnumberedsec Asm_Output
5462 @findex Asm_Output
5463 @noindent
5464 The @code{Asm_Output} attribute denotes a function that takes two
5465 parameters.  The first is a string, the second is the name of a variable
5466 of the type designated by the attribute prefix.  The first (string)
5467 argument is required to be a static expression and designates the
5468 constraint for the parameter (e.g.@: what kind of register is
5469 required).  The second argument is the variable to be updated with the
5470 result.  The possible values for constraint are the same as those used in
5471 the RTL, and are dependent on the configuration file used to build the
5472 GCC back end.  If there are no output operands, then this argument may
5473 either be omitted, or explicitly given as @code{No_Output_Operands}.
5474 @ref{Machine Code Insertions}
5475
5476 @node AST_Entry
5477 @unnumberedsec AST_Entry
5478 @cindex OpenVMS
5479 @findex AST_Entry
5480 @noindent
5481 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5482 the name of an entry, it yields a value of the predefined type AST_Handler
5483 (declared in the predefined package System, as extended by the use of
5484 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5485 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5486 Language Reference Manual}, section 9.12a.
5487
5488 @node Bit
5489 @unnumberedsec Bit
5490 @findex Bit
5491 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5492 offset within the storage unit (byte) that contains the first bit of
5493 storage allocated for the object.  The value of this attribute is of the
5494 type @code{Universal_Integer}, and is always a non-negative number not
5495 exceeding the value of @code{System.Storage_Unit}.
5496
5497 For an object that is a variable or a constant allocated in a register,
5498 the value is zero.  (The use of this attribute does not force the
5499 allocation of a variable to memory).
5500
5501 For an object that is a formal parameter, this attribute applies
5502 to either the matching actual parameter or to a copy of the
5503 matching actual parameter.
5504
5505 For an access object the value is zero.  Note that
5506 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5507 designated object.  Similarly for a record component
5508 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5509 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5510 are subject to index checks.
5511
5512 This attribute is designed to be compatible with the DEC Ada 83 definition
5513 and implementation of the @code{Bit} attribute.
5514
5515 @node Bit_Position
5516 @unnumberedsec Bit_Position
5517 @findex Bit_Position
5518 @noindent
5519 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5520 of the fields of the record type, yields the bit
5521 offset within the record contains the first bit of
5522 storage allocated for the object.  The value of this attribute is of the
5523 type @code{Universal_Integer}.  The value depends only on the field
5524 @var{C} and is independent of the alignment of
5525 the containing record @var{R}.
5526
5527 @node Compiler_Version
5528 @unnumberedsec Compiler_Version
5529 @findex Compiler_Version
5530 @noindent
5531 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5532 prefix) yields a static string identifying the version of the compiler
5533 being used to compile the unit containing the attribute reference. A
5534 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5535
5536 @node Code_Address
5537 @unnumberedsec Code_Address
5538 @findex Code_Address
5539 @cindex Subprogram address
5540 @cindex Address of subprogram code
5541 @noindent
5542 The @code{'Address}
5543 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5544 intended effect seems to be to provide
5545 an address value which can be used to call the subprogram by means of
5546 an address clause as in the following example:
5547
5548 @smallexample @c ada
5549 procedure K is @dots{}
5550
5551 procedure L;
5552 for L'Address use K'Address;
5553 pragma Import (Ada, L);
5554 @end smallexample
5555
5556 @noindent
5557 A call to @code{L} is then expected to result in a call to @code{K}@.
5558 In Ada 83, where there were no access-to-subprogram values, this was
5559 a common work-around for getting the effect of an indirect call.
5560 GNAT implements the above use of @code{Address} and the technique
5561 illustrated by the example code works correctly.
5562
5563 However, for some purposes, it is useful to have the address of the start
5564 of the generated code for the subprogram.  On some architectures, this is
5565 not necessarily the same as the @code{Address} value described above.
5566 For example, the @code{Address} value may reference a subprogram
5567 descriptor rather than the subprogram itself.
5568
5569 The @code{'Code_Address} attribute, which can only be applied to
5570 subprogram entities, always returns the address of the start of the
5571 generated code of the specified subprogram, which may or may not be
5572 the same value as is returned by the corresponding @code{'Address}
5573 attribute.
5574
5575 @node Default_Bit_Order
5576 @unnumberedsec Default_Bit_Order
5577 @cindex Big endian
5578 @cindex Little endian
5579 @findex Default_Bit_Order
5580 @noindent
5581 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5582 permissible prefix), provides the value @code{System.Default_Bit_Order}
5583 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5584 @code{Low_Order_First}).  This is used to construct the definition of
5585 @code{Default_Bit_Order} in package @code{System}.
5586
5587 @node Elaborated
5588 @unnumberedsec Elaborated
5589 @findex Elaborated
5590 @noindent
5591 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5592 value is a Boolean which indicates whether or not the given unit has been
5593 elaborated.  This attribute is primarily intended for internal use by the
5594 generated code for dynamic elaboration checking, but it can also be used
5595 in user programs.  The value will always be True once elaboration of all
5596 units has been completed.  An exception is for units which need no
5597 elaboration, the value is always False for such units.
5598
5599 @node Elab_Body
5600 @unnumberedsec Elab_Body
5601 @findex Elab_Body
5602 @noindent
5603 This attribute can only be applied to a program unit name.  It returns
5604 the entity for the corresponding elaboration procedure for elaborating
5605 the body of the referenced unit.  This is used in the main generated
5606 elaboration procedure by the binder and is not normally used in any
5607 other context.  However, there may be specialized situations in which it
5608 is useful to be able to call this elaboration procedure from Ada code,
5609 e.g.@: if it is necessary to do selective re-elaboration to fix some
5610 error.
5611
5612 @node Elab_Spec
5613 @unnumberedsec Elab_Spec
5614 @findex Elab_Spec
5615 @noindent
5616 This attribute can only be applied to a program unit name.  It returns
5617 the entity for the corresponding elaboration procedure for elaborating
5618 the spec of the referenced unit.  This is used in the main
5619 generated elaboration procedure by the binder and is not normally used
5620 in any other context.  However, there may be specialized situations in
5621 which it is useful to be able to call this elaboration procedure from
5622 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5623 some error.
5624
5625 @node Emax
5626 @unnumberedsec Emax
5627 @cindex Ada 83 attributes
5628 @findex Emax
5629 @noindent
5630 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5631 the Ada 83 reference manual for an exact description of the semantics of
5632 this attribute.
5633
5634 @node Enabled
5635 @unnumberedsec Enabled
5636 @findex Enabled
5637 @noindent
5638 The @code{Enabled} attribute allows an application program to check at compile
5639 time to see if the designated check is currently enabled. The prefix is a
5640 simple identifier, referencing any predefined check name (other than
5641 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5642 no argument is given for the attribute, the check is for the general state
5643 of the check, if an argument is given, then it is an entity name, and the
5644 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5645 given naming the entity (if not, then the argument is ignored).
5646
5647 Note that instantiations inherit the check status at the point of the
5648 instantiation, so a useful idiom is to have a library package that
5649 introduces a check name with @code{pragma Check_Name}, and then contains
5650 generic packages or subprograms which use the @code{Enabled} attribute
5651 to see if the check is enabled. A user of this package can then issue
5652 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5653 the package or subprogram, controlling whether the check will be present.
5654
5655 @node Enum_Rep
5656 @unnumberedsec Enum_Rep
5657 @cindex Representation of enums
5658 @findex Enum_Rep
5659 @noindent
5660 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5661 function with the following spec:
5662
5663 @smallexample @c ada
5664 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5665   return @i{Universal_Integer};
5666 @end smallexample
5667
5668 @noindent
5669 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5670 enumeration type or to a non-overloaded enumeration
5671 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5672 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5673 enumeration literal or object.
5674
5675 The function returns the representation value for the given enumeration
5676 value.  This will be equal to value of the @code{Pos} attribute in the
5677 absence of an enumeration representation clause.  This is a static
5678 attribute (i.e.@: the result is static if the argument is static).
5679
5680 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5681 in which case it simply returns the integer value.  The reason for this
5682 is to allow it to be used for @code{(<>)} discrete formal arguments in
5683 a generic unit that can be instantiated with either enumeration types
5684 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5685 type whose upper bound exceeds the upper bound of the largest signed
5686 integer type, and the argument is a variable, so that the universal
5687 integer calculation is done at run time, then the call to @code{Enum_Rep}
5688 may raise @code{Constraint_Error}.
5689
5690 @node Enum_Val
5691 @unnumberedsec Enum_Val
5692 @cindex Representation of enums
5693 @findex Enum_Val
5694 @noindent
5695 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5696 function with the following spec:
5697
5698 @smallexample @c ada
5699 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5700   return @var{S}'Base};
5701 @end smallexample
5702
5703 @noindent
5704 The function returns the enumeration value whose representation matches the
5705 argument, or raises Constraint_Error if no enumeration literal of the type
5706 has the matching value.
5707 This will be equal to value of the @code{Val} attribute in the
5708 absence of an enumeration representation clause.  This is a static
5709 attribute (i.e.@: the result is static if the argument is static).
5710
5711 @node Epsilon
5712 @unnumberedsec Epsilon
5713 @cindex Ada 83 attributes
5714 @findex Epsilon
5715 @noindent
5716 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5717 the Ada 83 reference manual for an exact description of the semantics of
5718 this attribute.
5719
5720 @node Fixed_Value
5721 @unnumberedsec Fixed_Value
5722 @findex Fixed_Value
5723 @noindent
5724 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5725 function with the following specification:
5726
5727 @smallexample @c ada
5728 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5729   return @var{S};
5730 @end smallexample
5731
5732 @noindent
5733 The value returned is the fixed-point value @var{V} such that
5734
5735 @smallexample @c ada
5736 @var{V} = Arg * @var{S}'Small
5737 @end smallexample
5738
5739 @noindent
5740 The effect is thus similar to first converting the argument to the
5741 integer type used to represent @var{S}, and then doing an unchecked
5742 conversion to the fixed-point type.  The difference is
5743 that there are full range checks, to ensure that the result is in range.
5744 This attribute is primarily intended for use in implementation of the
5745 input-output functions for fixed-point values.
5746
5747 @node Has_Access_Values
5748 @unnumberedsec Has_Access_Values
5749 @cindex Access values, testing for
5750 @findex Has_Access_Values
5751 @noindent
5752 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5753 is a Boolean value which is True if the is an access type, or is a composite
5754 type with a component (at any nesting depth) that is an access type, and is
5755 False otherwise.
5756 The intended use of this attribute is in conjunction with generic
5757 definitions.  If the attribute is applied to a generic private type, it
5758 indicates whether or not the corresponding actual type has access values.
5759
5760 @node Has_Discriminants
5761 @unnumberedsec Has_Discriminants
5762 @cindex Discriminants, testing for
5763 @findex Has_Discriminants
5764 @noindent
5765 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5766 is a Boolean value which is True if the type has discriminants, and False
5767 otherwise.  The intended use of this attribute is in conjunction with generic
5768 definitions.  If the attribute is applied to a generic private type, it
5769 indicates whether or not the corresponding actual type has discriminants.
5770
5771 @node Img
5772 @unnumberedsec Img
5773 @findex Img
5774 @noindent
5775 The @code{Img} attribute differs from @code{Image} in that it may be
5776 applied to objects as well as types, in which case it gives the
5777 @code{Image} for the subtype of the object.  This is convenient for
5778 debugging:
5779
5780 @smallexample @c ada
5781 Put_Line ("X = " & X'Img);
5782 @end smallexample
5783
5784 @noindent
5785 has the same meaning as the more verbose:
5786
5787 @smallexample @c ada
5788 Put_Line ("X = " & @var{T}'Image (X));
5789 @end smallexample
5790
5791 @noindent
5792 where @var{T} is the (sub)type of the object @code{X}.
5793
5794 @node Integer_Value
5795 @unnumberedsec Integer_Value
5796 @findex Integer_Value
5797 @noindent
5798 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5799 function with the following spec:
5800
5801 @smallexample @c ada
5802 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5803   return @var{S};
5804 @end smallexample
5805
5806 @noindent
5807 The value returned is the integer value @var{V}, such that
5808
5809 @smallexample @c ada
5810 Arg = @var{V} * @var{T}'Small
5811 @end smallexample
5812
5813 @noindent
5814 where @var{T} is the type of @code{Arg}.
5815 The effect is thus similar to first doing an unchecked conversion from
5816 the fixed-point type to its corresponding implementation type, and then
5817 converting the result to the target integer type.  The difference is
5818 that there are full range checks, to ensure that the result is in range.
5819 This attribute is primarily intended for use in implementation of the
5820 standard input-output functions for fixed-point values.
5821
5822 @node Invalid_Value
5823 @unnumberedsec Invalid_Value
5824 @findex Invalid_Value
5825 @noindent
5826 For every scalar type S, S'Invalid_Value returns an undefined value of the
5827 type. If possible this value is an invalid representation for the type. The
5828 value returned is identical to the value used to initialize an otherwise
5829 uninitialized value of the type if pragma Initialize_Scalars is used,
5830 including the ability to modify the value with the binder -Sxx flag and
5831 relevant environment variables at run time.
5832
5833 @node Large
5834 @unnumberedsec Large
5835 @cindex Ada 83 attributes
5836 @findex Large
5837 @noindent
5838 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5839 the Ada 83 reference manual for an exact description of the semantics of
5840 this attribute.
5841
5842 @node Machine_Size
5843 @unnumberedsec Machine_Size
5844 @findex Machine_Size
5845 @noindent
5846 This attribute is identical to the @code{Object_Size} attribute.  It is
5847 provided for compatibility with the DEC Ada 83 attribute of this name.
5848
5849 @node Mantissa
5850 @unnumberedsec Mantissa
5851 @cindex Ada 83 attributes
5852 @findex Mantissa
5853 @noindent
5854 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5855 the Ada 83 reference manual for an exact description of the semantics of
5856 this attribute.
5857
5858 @node Max_Interrupt_Priority
5859 @unnumberedsec Max_Interrupt_Priority
5860 @cindex Interrupt priority, maximum
5861 @findex Max_Interrupt_Priority
5862 @noindent
5863 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5864 permissible prefix), provides the same value as
5865 @code{System.Max_Interrupt_Priority}.
5866
5867 @node Max_Priority
5868 @unnumberedsec Max_Priority
5869 @cindex Priority, maximum
5870 @findex Max_Priority
5871 @noindent
5872 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5873 prefix) provides the same value as @code{System.Max_Priority}.
5874
5875 @node Maximum_Alignment
5876 @unnumberedsec Maximum_Alignment
5877 @cindex Alignment, maximum
5878 @findex Maximum_Alignment
5879 @noindent
5880 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5881 permissible prefix) provides the maximum useful alignment value for the
5882 target.  This is a static value that can be used to specify the alignment
5883 for an object, guaranteeing that it is properly aligned in all
5884 cases.
5885
5886 @node Mechanism_Code
5887 @unnumberedsec Mechanism_Code
5888 @cindex Return values, passing mechanism
5889 @cindex Parameters, passing mechanism
5890 @findex Mechanism_Code
5891 @noindent
5892 @code{@var{function}'Mechanism_Code} yields an integer code for the
5893 mechanism used for the result of function, and
5894 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5895 used for formal parameter number @var{n} (a static integer value with 1
5896 meaning the first parameter) of @var{subprogram}.  The code returned is:
5897
5898 @table @asis
5899 @item 1
5900 by copy (value)
5901 @item 2
5902 by reference
5903 @item 3
5904 by descriptor (default descriptor class)
5905 @item 4
5906 by descriptor (UBS: unaligned bit string)
5907 @item 5
5908 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5909 @item 6
5910 by descriptor (UBA: unaligned bit array)
5911 @item 7
5912 by descriptor (S: string, also scalar access type parameter)
5913 @item 8
5914 by descriptor (SB: string with arbitrary bounds)
5915 @item 9
5916 by descriptor (A: contiguous array)
5917 @item 10
5918 by descriptor (NCA: non-contiguous array)
5919 @end table
5920
5921 @noindent
5922 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5923 @cindex OpenVMS
5924
5925 @node Null_Parameter
5926 @unnumberedsec Null_Parameter
5927 @cindex Zero address, passing
5928 @findex Null_Parameter
5929 @noindent
5930 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5931 type or subtype @var{T} allocated at machine address zero.  The attribute
5932 is allowed only as the default expression of a formal parameter, or as
5933 an actual expression of a subprogram call.  In either case, the
5934 subprogram must be imported.
5935
5936 The identity of the object is represented by the address zero in the
5937 argument list, independent of the passing mechanism (explicit or
5938 default).
5939
5940 This capability is needed to specify that a zero address should be
5941 passed for a record or other composite object passed by reference.
5942 There is no way of indicating this without the @code{Null_Parameter}
5943 attribute.
5944
5945 @node Object_Size
5946 @unnumberedsec Object_Size
5947 @cindex Size, used for objects
5948 @findex Object_Size
5949 @noindent
5950 The size of an object is not necessarily the same as the size of the type
5951 of an object.  This is because by default object sizes are increased to be
5952 a multiple of the alignment of the object.  For example,
5953 @code{Natural'Size} is
5954 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5955 Similarly, a record containing an integer and a character:
5956
5957 @smallexample @c ada
5958 type Rec is record
5959    I : Integer;
5960    C : Character;
5961 end record;
5962 @end smallexample
5963
5964 @noindent
5965 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5966 alignment will be 4, because of the
5967 integer field, and so the default size of record objects for this type
5968 will be 64 (8 bytes).
5969
5970 @node Old
5971 @unnumberedsec Old
5972 @cindex Capturing Old values
5973 @cindex Postconditions
5974 @noindent
5975 The attribute Prefix'Old can be used within a
5976 subprogram to refer to the value of the prefix on entry. So for
5977 example if you have an argument of a record type X called Arg1,
5978 you can refer to Arg1.Field'Old which yields the value of
5979 Arg1.Field on entry. The implementation simply involves generating
5980 an object declaration which captures the value on entry. Any
5981 prefix is allowed except one of a limited type (since limited
5982 types cannot be copied to capture their values) or a local variable
5983 (since it does not exist at subprogram entry time).
5984
5985 The following example shows the use of 'Old to implement
5986 a test of a postcondition:
5987
5988 @smallexample @c ada
5989 with Old_Pkg;
5990 procedure Old is
5991 begin
5992    Old_Pkg.Incr;
5993 end Old;
5994
5995 package Old_Pkg is
5996    procedure Incr;
5997 end Old_Pkg;
5998
5999 package body Old_Pkg is
6000    Count : Natural := 0;
6001
6002    procedure Incr is
6003    begin
6004       ... code manipulating the value of Count
6005
6006       pragma Assert (Count = Count'Old + 1);
6007    end Incr;
6008 end Old_Pkg;
6009 @end smallexample
6010
6011 @noindent
6012 Note that it is allowed to apply 'Old to a constant entity, but this will
6013 result in a warning, since the old and new values will always be the same.
6014
6015 @node Passed_By_Reference
6016 @unnumberedsec Passed_By_Reference
6017 @cindex Parameters, when passed by reference
6018 @findex Passed_By_Reference
6019 @noindent
6020 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6021 a value of type @code{Boolean} value that is @code{True} if the type is
6022 normally passed by reference and @code{False} if the type is normally
6023 passed by copy in calls.  For scalar types, the result is always @code{False}
6024 and is static.  For non-scalar types, the result is non-static.
6025
6026 @node Pool_Address
6027 @unnumberedsec Pool_Address
6028 @cindex Parameters, when passed by reference
6029 @findex Pool_Address
6030 @noindent
6031 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6032 of X within its storage pool. This is the same as
6033 @code{@var{X}'Address}, except that for an unconstrained array whose
6034 bounds are allocated just before the first component,
6035 @code{@var{X}'Pool_Address} returns the address of those bounds,
6036 whereas @code{@var{X}'Address} returns the address of the first
6037 component.
6038
6039 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6040 the object is allocated'', which could be a user-defined storage pool,
6041 the global heap, on the stack, or in a static memory area. For an
6042 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6043 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6044
6045 @node Range_Length
6046 @unnumberedsec Range_Length
6047 @findex Range_Length
6048 @noindent
6049 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6050 the number of values represented by the subtype (zero for a null
6051 range).  The result is static for static subtypes.  @code{Range_Length}
6052 applied to the index subtype of a one dimensional array always gives the
6053 same result as @code{Range} applied to the array itself.
6054
6055 @node Safe_Emax
6056 @unnumberedsec Safe_Emax
6057 @cindex Ada 83 attributes
6058 @findex Safe_Emax
6059 @noindent
6060 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6061 the Ada 83 reference manual for an exact description of the semantics of
6062 this attribute.
6063
6064 @node Safe_Large
6065 @unnumberedsec Safe_Large
6066 @cindex Ada 83 attributes
6067 @findex Safe_Large
6068 @noindent
6069 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6070 the Ada 83 reference manual for an exact description of the semantics of
6071 this attribute.
6072
6073 @node Small
6074 @unnumberedsec Small
6075 @cindex Ada 83 attributes
6076 @findex Small
6077 @noindent
6078 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6079 fixed-point types.
6080 GNAT also allows this attribute to be applied to floating-point types
6081 for compatibility with Ada 83.  See
6082 the Ada 83 reference manual for an exact description of the semantics of
6083 this attribute when applied to floating-point types.
6084
6085 @node Storage_Unit
6086 @unnumberedsec Storage_Unit
6087 @findex Storage_Unit
6088 @noindent
6089 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6090 prefix) provides the same value as @code{System.Storage_Unit}.
6091
6092 @node Stub_Type
6093 @unnumberedsec Stub_Type
6094 @findex Stub_Type
6095 @noindent
6096 The GNAT implementation of remote access-to-classwide types is
6097 organized as described in AARM section E.4 (20.t): a value of an RACW type
6098 (designating a remote object) is represented as a normal access
6099 value, pointing to a "stub" object which in turn contains the
6100 necessary information to contact the designated remote object. A
6101 call on any dispatching operation of such a stub object does the
6102 remote call, if necessary, using the information in the stub object
6103 to locate the target partition, etc.
6104
6105 For a prefix @code{T} that denotes a remote access-to-classwide type,
6106 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6107
6108 By construction, the layout of @code{T'Stub_Type} is identical to that of
6109 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6110 unit @code{System.Partition_Interface}. Use of this attribute will create
6111 an implicit dependency on this unit.
6112
6113 @node Target_Name
6114 @unnumberedsec Target_Name
6115 @findex Target_Name
6116 @noindent
6117 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6118 prefix) provides a static string value that identifies the target
6119 for the current compilation. For GCC implementations, this is the
6120 standard gcc target name without the terminating slash (for
6121 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6122
6123 @node Tick
6124 @unnumberedsec Tick
6125 @findex Tick
6126 @noindent
6127 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6128 provides the same value as @code{System.Tick},
6129
6130 @node To_Address
6131 @unnumberedsec To_Address
6132 @findex To_Address
6133 @noindent
6134 The @code{System'To_Address}
6135 (@code{System} is the only permissible prefix)
6136 denotes a function identical to
6137 @code{System.Storage_Elements.To_Address} except that
6138 it is a static attribute.  This means that if its argument is
6139 a static expression, then the result of the attribute is a
6140 static expression.  The result is that such an expression can be
6141 used in contexts (e.g.@: preelaborable packages) which require a
6142 static expression and where the function call could not be used
6143 (since the function call is always non-static, even if its
6144 argument is static).
6145
6146 @node Type_Class
6147 @unnumberedsec Type_Class
6148 @findex Type_Class
6149 @noindent
6150 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6151 the value of the type class for the full type of @var{type}.  If
6152 @var{type} is a generic formal type, the value is the value for the
6153 corresponding actual subtype.  The value of this attribute is of type
6154 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6155
6156 @smallexample @c ada
6157   type Type_Class is
6158     (Type_Class_Enumeration,
6159      Type_Class_Integer,
6160      Type_Class_Fixed_Point,
6161      Type_Class_Floating_Point,
6162      Type_Class_Array,
6163      Type_Class_Record,
6164      Type_Class_Access,
6165      Type_Class_Task,
6166      Type_Class_Address);
6167 @end smallexample
6168
6169 @noindent
6170 Protected types yield the value @code{Type_Class_Task}, which thus
6171 applies to all concurrent types.  This attribute is designed to
6172 be compatible with the DEC Ada 83 attribute of the same name.
6173
6174 @node UET_Address
6175 @unnumberedsec UET_Address
6176 @findex UET_Address
6177 @noindent
6178 The @code{UET_Address} attribute can only be used for a prefix which
6179 denotes a library package.  It yields the address of the unit exception
6180 table when zero cost exception handling is used.  This attribute is
6181 intended only for use within the GNAT implementation.  See the unit
6182 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6183 for details on how this attribute is used in the implementation.
6184
6185 @node Unconstrained_Array
6186 @unnumberedsec Unconstrained_Array
6187 @findex Unconstrained_Array
6188 @noindent
6189 The @code{Unconstrained_Array} attribute can be used with a prefix that
6190 denotes any type or subtype. It is a static attribute that yields
6191 @code{True} if the prefix designates an unconstrained array,
6192 and @code{False} otherwise. In a generic instance, the result is
6193 still static, and yields the result of applying this test to the
6194 generic actual.
6195
6196 @node Universal_Literal_String
6197 @unnumberedsec Universal_Literal_String
6198 @cindex Named numbers, representation of
6199 @findex Universal_Literal_String
6200 @noindent
6201 The prefix of @code{Universal_Literal_String} must be a named
6202 number.  The static result is the string consisting of the characters of
6203 the number as defined in the original source.  This allows the user
6204 program to access the actual text of named numbers without intermediate
6205 conversions and without the need to enclose the strings in quotes (which
6206 would preclude their use as numbers).  This is used internally for the
6207 construction of values of the floating-point attributes from the file
6208 @file{ttypef.ads}, but may also be used by user programs.
6209
6210 For example, the following program prints the first 50 digits of pi:
6211
6212 @smallexample @c ada
6213 with Text_IO; use Text_IO;
6214 with Ada.Numerics;
6215 procedure Pi is
6216 begin
6217    Put (Ada.Numerics.Pi'Universal_Literal_String);
6218 end;
6219 @end smallexample
6220
6221 @node Unrestricted_Access
6222 @unnumberedsec Unrestricted_Access
6223 @cindex @code{Access}, unrestricted
6224 @findex Unrestricted_Access
6225 @noindent
6226 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6227 except that all accessibility and aliased view checks are omitted.  This
6228 is a user-beware attribute.  It is similar to
6229 @code{Address}, for which it is a desirable replacement where the value
6230 desired is an access type.  In other words, its effect is identical to
6231 first applying the @code{Address} attribute and then doing an unchecked
6232 conversion to a desired access type.  In GNAT, but not necessarily in
6233 other implementations, the use of static chains for inner level
6234 subprograms means that @code{Unrestricted_Access} applied to a
6235 subprogram yields a value that can be called as long as the subprogram
6236 is in scope (normal Ada accessibility rules restrict this usage).
6237
6238 It is possible to use @code{Unrestricted_Access} for any type, but care
6239 must be exercised if it is used to create pointers to unconstrained
6240 objects. In this case, the resulting pointer has the same scope as the
6241 context of the attribute, and may not be returned to some enclosing
6242 scope. For instance, a function cannot use @code{Unrestricted_Access}
6243 to create a unconstrained pointer and then return that value to the
6244 caller.
6245
6246 @node VADS_Size
6247 @unnumberedsec VADS_Size
6248 @cindex @code{Size}, VADS compatibility
6249 @findex VADS_Size
6250 @noindent
6251 The @code{'VADS_Size} attribute is intended to make it easier to port
6252 legacy code which relies on the semantics of @code{'Size} as implemented
6253 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6254 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6255 to a predefined or other primitive type with no Size clause yields the
6256 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6257 typical machines).  In addition @code{'VADS_Size} applied to an object
6258 gives the result that would be obtained by applying the attribute to
6259 the corresponding type.
6260
6261 @node Value_Size
6262 @unnumberedsec Value_Size
6263 @cindex @code{Size}, setting for not-first subtype
6264 @findex Value_Size
6265 @code{@var{type}'Value_Size} is the number of bits required to represent
6266 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6267 but, unlike @code{Size}, may be set for non-first subtypes.
6268
6269 @node Wchar_T_Size
6270 @unnumberedsec Wchar_T_Size
6271 @findex Wchar_T_Size
6272 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6273 prefix) provides the size in bits of the C @code{wchar_t} type
6274 primarily for constructing the definition of this type in
6275 package @code{Interfaces.C}.
6276
6277 @node Word_Size
6278 @unnumberedsec Word_Size
6279 @findex Word_Size
6280 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6281 prefix) provides the value @code{System.Word_Size}.
6282
6283 @c ------------------------
6284 @node Implementation Advice
6285 @chapter Implementation Advice
6286 @noindent
6287 The main text of the Ada Reference Manual describes the required
6288 behavior of all Ada compilers, and the GNAT compiler conforms to
6289 these requirements.
6290
6291 In addition, there are sections throughout the Ada Reference Manual headed
6292 by the phrase ``Implementation advice''.  These sections are not normative,
6293 i.e., they do not specify requirements that all compilers must
6294 follow.  Rather they provide advice on generally desirable behavior.  You
6295 may wonder why they are not requirements.  The most typical answer is
6296 that they describe behavior that seems generally desirable, but cannot
6297 be provided on all systems, or which may be undesirable on some systems.
6298
6299 As far as practical, GNAT follows the implementation advice sections in
6300 the Ada Reference Manual.  This chapter contains a table giving the
6301 reference manual section number, paragraph number and several keywords
6302 for each advice.  Each entry consists of the text of the advice followed
6303 by the GNAT interpretation of this advice.  Most often, this simply says
6304 ``followed'', which means that GNAT follows the advice.  However, in a
6305 number of cases, GNAT deliberately deviates from this advice, in which
6306 case the text describes what GNAT does and why.
6307
6308 @cindex Error detection
6309 @unnumberedsec 1.1.3(20): Error Detection
6310 @sp 1
6311 @cartouche
6312 If an implementation detects the use of an unsupported Specialized Needs
6313 Annex feature at run time, it should raise @code{Program_Error} if
6314 feasible.
6315 @end cartouche
6316 Not relevant.  All specialized needs annex features are either supported,
6317 or diagnosed at compile time.
6318
6319 @cindex Child Units
6320 @unnumberedsec 1.1.3(31): Child Units
6321 @sp 1
6322 @cartouche
6323 If an implementation wishes to provide implementation-defined
6324 extensions to the functionality of a language-defined library unit, it
6325 should normally do so by adding children to the library unit.
6326 @end cartouche
6327 Followed.
6328
6329 @cindex Bounded errors
6330 @unnumberedsec 1.1.5(12): Bounded Errors
6331 @sp 1
6332 @cartouche
6333 If an implementation detects a bounded error or erroneous
6334 execution, it should raise @code{Program_Error}.
6335 @end cartouche
6336 Followed in all cases in which the implementation detects a bounded
6337 error or erroneous execution.  Not all such situations are detected at
6338 runtime.
6339
6340 @cindex Pragmas
6341 @unnumberedsec 2.8(16): Pragmas
6342 @sp 1
6343 @cartouche
6344 Normally, implementation-defined pragmas should have no semantic effect
6345 for error-free programs; that is, if the implementation-defined pragmas
6346 are removed from a working program, the program should still be legal,
6347 and should still have the same semantics.
6348 @end cartouche
6349 The following implementation defined pragmas are exceptions to this
6350 rule:
6351
6352 @table @code
6353 @item Abort_Defer
6354 Affects semantics
6355 @item Ada_83
6356 Affects legality
6357 @item Assert
6358 Affects semantics
6359 @item CPP_Class
6360 Affects semantics
6361 @item CPP_Constructor
6362 Affects semantics
6363 @item Debug
6364 Affects semantics
6365 @item Interface_Name
6366 Affects semantics
6367 @item Machine_Attribute
6368 Affects semantics
6369 @item Unimplemented_Unit
6370 Affects legality
6371 @item Unchecked_Union
6372 Affects semantics
6373 @end table
6374
6375 @noindent
6376 In each of the above cases, it is essential to the purpose of the pragma
6377 that this advice not be followed.  For details see the separate section
6378 on implementation defined pragmas.
6379
6380 @unnumberedsec 2.8(17-19): Pragmas
6381 @sp 1
6382 @cartouche
6383 Normally, an implementation should not define pragmas that can
6384 make an illegal program legal, except as follows:
6385 @end cartouche
6386 @sp 1
6387 @cartouche
6388 A pragma used to complete a declaration, such as a pragma @code{Import};
6389 @end cartouche
6390 @sp 1
6391 @cartouche
6392 A pragma used to configure the environment by adding, removing, or
6393 replacing @code{library_items}.
6394 @end cartouche
6395 See response to paragraph 16 of this same section.
6396
6397 @cindex Character Sets
6398 @cindex Alternative Character Sets
6399 @unnumberedsec 3.5.2(5): Alternative Character Sets
6400 @sp 1
6401 @cartouche
6402 If an implementation supports a mode with alternative interpretations
6403 for @code{Character} and @code{Wide_Character}, the set of graphic
6404 characters of @code{Character} should nevertheless remain a proper
6405 subset of the set of graphic characters of @code{Wide_Character}.  Any
6406 character set ``localizations'' should be reflected in the results of
6407 the subprograms defined in the language-defined package
6408 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6409 an alternative interpretation of @code{Character}, the implementation should
6410 also support a corresponding change in what is a legal
6411 @code{identifier_letter}.
6412 @end cartouche
6413 Not all wide character modes follow this advice, in particular the JIS
6414 and IEC modes reflect standard usage in Japan, and in these encoding,
6415 the upper half of the Latin-1 set is not part of the wide-character
6416 subset, since the most significant bit is used for wide character
6417 encoding.  However, this only applies to the external forms.  Internally
6418 there is no such restriction.
6419
6420 @cindex Integer types
6421 @unnumberedsec 3.5.4(28): Integer Types
6422
6423 @sp 1
6424 @cartouche
6425 An implementation should support @code{Long_Integer} in addition to
6426 @code{Integer} if the target machine supports 32-bit (or longer)
6427 arithmetic.  No other named integer subtypes are recommended for package
6428 @code{Standard}.  Instead, appropriate named integer subtypes should be
6429 provided in the library package @code{Interfaces} (see B.2).
6430 @end cartouche
6431 @code{Long_Integer} is supported.  Other standard integer types are supported
6432 so this advice is not fully followed.  These types
6433 are supported for convenient interface to C, and so that all hardware
6434 types of the machine are easily available.
6435 @unnumberedsec 3.5.4(29): Integer Types
6436
6437 @sp 1
6438 @cartouche
6439 An implementation for a two's complement machine should support
6440 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6441 implementation should support a non-binary modules up to @code{Integer'Last}.
6442 @end cartouche
6443 Followed.
6444
6445 @cindex Enumeration values
6446 @unnumberedsec 3.5.5(8): Enumeration Values
6447 @sp 1
6448 @cartouche
6449 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6450 subtype, if the value of the operand does not correspond to the internal
6451 code for any enumeration literal of its type (perhaps due to an
6452 un-initialized variable), then the implementation should raise
6453 @code{Program_Error}.  This is particularly important for enumeration
6454 types with noncontiguous internal codes specified by an
6455 enumeration_representation_clause.
6456 @end cartouche
6457 Followed.
6458
6459 @cindex Float types
6460 @unnumberedsec 3.5.7(17): Float Types
6461 @sp 1
6462 @cartouche
6463 An implementation should support @code{Long_Float} in addition to
6464 @code{Float} if the target machine supports 11 or more digits of
6465 precision.  No other named floating point subtypes are recommended for
6466 package @code{Standard}.  Instead, appropriate named floating point subtypes
6467 should be provided in the library package @code{Interfaces} (see B.2).
6468 @end cartouche
6469 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6470 former provides improved compatibility with other implementations
6471 supporting this type.  The latter corresponds to the highest precision
6472 floating-point type supported by the hardware.  On most machines, this
6473 will be the same as @code{Long_Float}, but on some machines, it will
6474 correspond to the IEEE extended form.  The notable case is all ia32
6475 (x86) implementations, where @code{Long_Long_Float} corresponds to
6476 the 80-bit extended precision format supported in hardware on this
6477 processor.  Note that the 128-bit format on SPARC is not supported,
6478 since this is a software rather than a hardware format.
6479
6480 @cindex Multidimensional arrays
6481 @cindex Arrays, multidimensional
6482 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6483 @sp 1
6484 @cartouche
6485 An implementation should normally represent multidimensional arrays in
6486 row-major order, consistent with the notation used for multidimensional
6487 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6488 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6489 column-major order should be used instead (see B.5, ``Interfacing with
6490 Fortran'').
6491 @end cartouche
6492 Followed.
6493
6494 @findex Duration'Small
6495 @unnumberedsec 9.6(30-31): Duration'Small
6496 @sp 1
6497 @cartouche
6498 Whenever possible in an implementation, the value of @code{Duration'Small}
6499 should be no greater than 100 microseconds.
6500 @end cartouche
6501 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6502
6503 @sp 1
6504 @cartouche
6505 The time base for @code{delay_relative_statements} should be monotonic;
6506 it need not be the same time base as used for @code{Calendar.Clock}.
6507 @end cartouche
6508 Followed.
6509
6510 @unnumberedsec 10.2.1(12): Consistent Representation
6511 @sp 1
6512 @cartouche
6513 In an implementation, a type declared in a pre-elaborated package should
6514 have the same representation in every elaboration of a given version of
6515 the package, whether the elaborations occur in distinct executions of
6516 the same program, or in executions of distinct programs or partitions
6517 that include the given version.
6518 @end cartouche
6519 Followed, except in the case of tagged types.  Tagged types involve
6520 implicit pointers to a local copy of a dispatch table, and these pointers
6521 have representations which thus depend on a particular elaboration of the
6522 package.  It is not easy to see how it would be possible to follow this
6523 advice without severely impacting efficiency of execution.
6524
6525 @cindex Exception information
6526 @unnumberedsec 11.4.1(19): Exception Information
6527 @sp 1
6528 @cartouche
6529 @code{Exception_Message} by default and @code{Exception_Information}
6530 should produce information useful for
6531 debugging.  @code{Exception_Message} should be short, about one
6532 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6533 should not include the
6534 @code{Exception_Name}.  @code{Exception_Information} should include both
6535 the @code{Exception_Name} and the @code{Exception_Message}.
6536 @end cartouche
6537 Followed.  For each exception that doesn't have a specified
6538 @code{Exception_Message}, the compiler generates one containing the location
6539 of the raise statement.  This location has the form ``file:line'', where
6540 file is the short file name (without path information) and line is the line
6541 number in the file.  Note that in the case of the Zero Cost Exception
6542 mechanism, these messages become redundant with the Exception_Information that
6543 contains a full backtrace of the calling sequence, so they are disabled.
6544 To disable explicitly the generation of the source location message, use the
6545 Pragma @code{Discard_Names}.
6546
6547 @cindex Suppression of checks
6548 @cindex Checks, suppression of
6549 @unnumberedsec 11.5(28): Suppression of Checks
6550 @sp 1
6551 @cartouche
6552 The implementation should minimize the code executed for checks that
6553 have been suppressed.
6554 @end cartouche
6555 Followed.
6556
6557 @cindex Representation clauses
6558 @unnumberedsec 13.1 (21-24): Representation Clauses
6559 @sp 1
6560 @cartouche
6561 The recommended level of support for all representation items is
6562 qualified as follows:
6563 @end cartouche
6564 @sp 1
6565 @cartouche
6566 An implementation need not support representation items containing
6567 non-static expressions, except that an implementation should support a
6568 representation item for a given entity if each non-static expression in
6569 the representation item is a name that statically denotes a constant
6570 declared before the entity.
6571 @end cartouche
6572 Followed.  In fact, GNAT goes beyond the recommended level of support
6573 by allowing nonstatic expressions in some representation clauses even
6574 without the need to declare constants initialized with the values of
6575 such expressions.
6576 For example:
6577
6578 @smallexample @c ada
6579   X : Integer;
6580   Y : Float;
6581   for Y'Address use X'Address;>>
6582 @end smallexample
6583
6584
6585 @sp 1
6586 @cartouche
6587 An implementation need not support a specification for the @code{Size}
6588 for a given composite subtype, nor the size or storage place for an
6589 object (including a component) of a given composite subtype, unless the
6590 constraints on the subtype and its composite subcomponents (if any) are
6591 all static constraints.
6592 @end cartouche
6593 Followed.  Size Clauses are not permitted on non-static components, as
6594 described above.
6595
6596 @sp 1
6597 @cartouche
6598 An aliased component, or a component whose type is by-reference, should
6599 always be allocated at an addressable location.
6600 @end cartouche
6601 Followed.
6602
6603 @cindex Packed types
6604 @unnumberedsec 13.2(6-8): Packed Types
6605 @sp 1
6606 @cartouche
6607 If a type is packed, then the implementation should try to minimize
6608 storage allocated to objects of the type, possibly at the expense of
6609 speed of accessing components, subject to reasonable complexity in
6610 addressing calculations.
6611 @end cartouche
6612 @sp 1
6613 @cartouche
6614 The recommended level of support pragma @code{Pack} is:
6615
6616 For a packed record type, the components should be packed as tightly as
6617 possible subject to the Sizes of the component subtypes, and subject to
6618 any @code{record_representation_clause} that applies to the type; the
6619 implementation may, but need not, reorder components or cross aligned
6620 word boundaries to improve the packing.  A component whose @code{Size} is
6621 greater than the word size may be allocated an integral number of words.
6622 @end cartouche
6623 Followed.  Tight packing of arrays is supported for all component sizes
6624 up to 64-bits. If the array component size is 1 (that is to say, if
6625 the component is a boolean type or an enumeration type with two values)
6626 then values of the type are implicitly initialized to zero. This
6627 happens both for objects of the packed type, and for objects that have a
6628 subcomponent of the packed type.
6629
6630 @sp 1
6631 @cartouche
6632 An implementation should support Address clauses for imported
6633 subprograms.
6634 @end cartouche
6635 Followed.
6636 @cindex @code{Address} clauses
6637 @unnumberedsec 13.3(14-19): Address Clauses
6638
6639 @sp 1
6640 @cartouche
6641 For an array @var{X}, @code{@var{X}'Address} should point at the first
6642 component of the array, and not at the array bounds.
6643 @end cartouche
6644 Followed.
6645
6646 @sp 1
6647 @cartouche
6648 The recommended level of support for the @code{Address} attribute is:
6649
6650 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6651 object that is aliased or of a by-reference type, or is an entity whose
6652 @code{Address} has been specified.
6653 @end cartouche
6654 Followed.  A valid address will be produced even if none of those
6655 conditions have been met.  If necessary, the object is forced into
6656 memory to ensure the address is valid.
6657
6658 @sp 1
6659 @cartouche
6660 An implementation should support @code{Address} clauses for imported
6661 subprograms.
6662 @end cartouche
6663 Followed.
6664
6665 @sp 1
6666 @cartouche
6667 Objects (including subcomponents) that are aliased or of a by-reference
6668 type should be allocated on storage element boundaries.
6669 @end cartouche
6670 Followed.
6671
6672 @sp 1
6673 @cartouche
6674 If the @code{Address} of an object is specified, or it is imported or exported,
6675 then the implementation should not perform optimizations based on
6676 assumptions of no aliases.
6677 @end cartouche
6678 Followed.
6679
6680 @cindex @code{Alignment} clauses
6681 @unnumberedsec 13.3(29-35): Alignment Clauses
6682 @sp 1
6683 @cartouche
6684 The recommended level of support for the @code{Alignment} attribute for
6685 subtypes is:
6686
6687 An implementation should support specified Alignments that are factors
6688 and multiples of the number of storage elements per word, subject to the
6689 following:
6690 @end cartouche
6691 Followed.
6692
6693 @sp 1
6694 @cartouche
6695 An implementation need not support specified @code{Alignment}s for
6696 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6697 loaded and stored by available machine instructions.
6698 @end cartouche
6699 Followed.
6700
6701 @sp 1
6702 @cartouche
6703 An implementation need not support specified @code{Alignment}s that are
6704 greater than the maximum @code{Alignment} the implementation ever returns by
6705 default.
6706 @end cartouche
6707 Followed.
6708
6709 @sp 1
6710 @cartouche
6711 The recommended level of support for the @code{Alignment} attribute for
6712 objects is:
6713
6714 Same as above, for subtypes, but in addition:
6715 @end cartouche
6716 Followed.
6717
6718 @sp 1
6719 @cartouche
6720 For stand-alone library-level objects of statically constrained
6721 subtypes, the implementation should support all @code{Alignment}s
6722 supported by the target linker.  For example, page alignment is likely to
6723 be supported for such objects, but not for subtypes.
6724 @end cartouche
6725 Followed.
6726
6727 @cindex @code{Size} clauses
6728 @unnumberedsec 13.3(42-43): Size Clauses
6729 @sp 1
6730 @cartouche
6731 The recommended level of support for the @code{Size} attribute of
6732 objects is:
6733
6734 A @code{Size} clause should be supported for an object if the specified
6735 @code{Size} is at least as large as its subtype's @code{Size}, and
6736 corresponds to a size in storage elements that is a multiple of the
6737 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6738 @end cartouche
6739 Followed.
6740
6741 @unnumberedsec 13.3(50-56): Size Clauses
6742 @sp 1
6743 @cartouche
6744 If the @code{Size} of a subtype is specified, and allows for efficient
6745 independent addressability (see 9.10) on the target architecture, then
6746 the @code{Size} of the following objects of the subtype should equal the
6747 @code{Size} of the subtype:
6748
6749 Aliased objects (including components).
6750 @end cartouche
6751 Followed.
6752
6753 @sp 1
6754 @cartouche
6755 @code{Size} clause on a composite subtype should not affect the
6756 internal layout of components.
6757 @end cartouche
6758 Followed. But note that this can be overridden by use of the implementation
6759 pragma Implicit_Packing in the case of packed arrays.
6760
6761 @sp 1
6762 @cartouche
6763 The recommended level of support for the @code{Size} attribute of subtypes is:
6764 @end cartouche
6765 @sp 1
6766 @cartouche
6767 The @code{Size} (if not specified) of a static discrete or fixed point
6768 subtype should be the number of bits needed to represent each value
6769 belonging to the subtype using an unbiased representation, leaving space
6770 for a sign bit only if the subtype contains negative values.  If such a
6771 subtype is a first subtype, then an implementation should support a
6772 specified @code{Size} for it that reflects this representation.
6773 @end cartouche
6774 Followed.
6775
6776 @sp 1
6777 @cartouche
6778 For a subtype implemented with levels of indirection, the @code{Size}
6779 should include the size of the pointers, but not the size of what they
6780 point at.
6781 @end cartouche
6782 Followed.
6783
6784 @cindex @code{Component_Size} clauses
6785 @unnumberedsec 13.3(71-73): Component Size Clauses
6786 @sp 1
6787 @cartouche
6788 The recommended level of support for the @code{Component_Size}
6789 attribute is:
6790 @end cartouche
6791 @sp 1
6792 @cartouche
6793 An implementation need not support specified @code{Component_Sizes} that are
6794 less than the @code{Size} of the component subtype.
6795 @end cartouche
6796 Followed.
6797
6798 @sp 1
6799 @cartouche
6800 An implementation should support specified @code{Component_Size}s that
6801 are factors and multiples of the word size.  For such
6802 @code{Component_Size}s, the array should contain no gaps between
6803 components.  For other @code{Component_Size}s (if supported), the array
6804 should contain no gaps between components when packing is also
6805 specified; the implementation should forbid this combination in cases
6806 where it cannot support a no-gaps representation.
6807 @end cartouche
6808 Followed.
6809
6810 @cindex Enumeration representation clauses
6811 @cindex Representation clauses, enumeration
6812 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6813 @sp 1
6814 @cartouche
6815 The recommended level of support for enumeration representation clauses
6816 is:
6817
6818 An implementation need not support enumeration representation clauses
6819 for boolean types, but should at minimum support the internal codes in
6820 the range @code{System.Min_Int.System.Max_Int}.
6821 @end cartouche
6822 Followed.
6823
6824 @cindex Record representation clauses
6825 @cindex Representation clauses, records
6826 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6827 @sp 1
6828 @cartouche
6829 The recommended level of support for
6830 @*@code{record_representation_clauses} is:
6831
6832 An implementation should support storage places that can be extracted
6833 with a load, mask, shift sequence of machine code, and set with a load,
6834 shift, mask, store sequence, given the available machine instructions
6835 and run-time model.
6836 @end cartouche
6837 Followed.
6838
6839 @sp 1
6840 @cartouche
6841 A storage place should be supported if its size is equal to the
6842 @code{Size} of the component subtype, and it starts and ends on a
6843 boundary that obeys the @code{Alignment} of the component subtype.
6844 @end cartouche
6845 Followed.
6846
6847 @sp 1
6848 @cartouche
6849 If the default bit ordering applies to the declaration of a given type,
6850 then for a component whose subtype's @code{Size} is less than the word
6851 size, any storage place that does not cross an aligned word boundary
6852 should be supported.
6853 @end cartouche
6854 Followed.
6855
6856 @sp 1
6857 @cartouche
6858 An implementation may reserve a storage place for the tag field of a
6859 tagged type, and disallow other components from overlapping that place.
6860 @end cartouche
6861 Followed.  The storage place for the tag field is the beginning of the tagged
6862 record, and its size is Address'Size.  GNAT will reject an explicit component
6863 clause for the tag field.
6864
6865 @sp 1
6866 @cartouche
6867 An implementation need not support a @code{component_clause} for a
6868 component of an extension part if the storage place is not after the
6869 storage places of all components of the parent type, whether or not
6870 those storage places had been specified.
6871 @end cartouche
6872 Followed.  The above advice on record representation clauses is followed,
6873 and all mentioned features are implemented.
6874
6875 @cindex Storage place attributes
6876 @unnumberedsec 13.5.2(5): Storage Place Attributes
6877 @sp 1
6878 @cartouche
6879 If a component is represented using some form of pointer (such as an
6880 offset) to the actual data of the component, and this data is contiguous
6881 with the rest of the object, then the storage place attributes should
6882 reflect the place of the actual data, not the pointer.  If a component is
6883 allocated discontinuously from the rest of the object, then a warning
6884 should be generated upon reference to one of its storage place
6885 attributes.
6886 @end cartouche
6887 Followed.  There are no such components in GNAT@.
6888
6889 @cindex Bit ordering
6890 @unnumberedsec 13.5.3(7-8): Bit Ordering
6891 @sp 1
6892 @cartouche
6893 The recommended level of support for the non-default bit ordering is:
6894 @end cartouche
6895 @sp 1
6896 @cartouche
6897 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6898 should support the non-default bit ordering in addition to the default
6899 bit ordering.
6900 @end cartouche
6901 Followed.  Word size does not equal storage size in this implementation.
6902 Thus non-default bit ordering is not supported.
6903
6904 @cindex @code{Address}, as private type
6905 @unnumberedsec 13.7(37): Address as Private
6906 @sp 1
6907 @cartouche
6908 @code{Address} should be of a private type.
6909 @end cartouche
6910 Followed.
6911
6912 @cindex Operations, on @code{Address}
6913 @cindex @code{Address}, operations of
6914 @unnumberedsec 13.7.1(16): Address Operations
6915 @sp 1
6916 @cartouche
6917 Operations in @code{System} and its children should reflect the target
6918 environment semantics as closely as is reasonable.  For example, on most
6919 machines, it makes sense for address arithmetic to ``wrap around''.
6920 Operations that do not make sense should raise @code{Program_Error}.
6921 @end cartouche
6922 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6923 operation raises @code{Program_Error}, since all operations make sense.
6924
6925 @cindex Unchecked conversion
6926 @unnumberedsec 13.9(14-17): Unchecked Conversion
6927 @sp 1
6928 @cartouche
6929 The @code{Size} of an array object should not include its bounds; hence,
6930 the bounds should not be part of the converted data.
6931 @end cartouche
6932 Followed.
6933
6934 @sp 1
6935 @cartouche
6936 The implementation should not generate unnecessary run-time checks to
6937 ensure that the representation of @var{S} is a representation of the
6938 target type.  It should take advantage of the permission to return by
6939 reference when possible.  Restrictions on unchecked conversions should be
6940 avoided unless required by the target environment.
6941 @end cartouche
6942 Followed.  There are no restrictions on unchecked conversion.  A warning is
6943 generated if the source and target types do not have the same size since
6944 the semantics in this case may be target dependent.
6945
6946 @sp 1
6947 @cartouche
6948 The recommended level of support for unchecked conversions is:
6949 @end cartouche
6950 @sp 1
6951 @cartouche
6952 Unchecked conversions should be supported and should be reversible in
6953 the cases where this clause defines the result.  To enable meaningful use
6954 of unchecked conversion, a contiguous representation should be used for
6955 elementary subtypes, for statically constrained array subtypes whose
6956 component subtype is one of the subtypes described in this paragraph,
6957 and for record subtypes without discriminants whose component subtypes
6958 are described in this paragraph.
6959 @end cartouche
6960 Followed.
6961
6962 @cindex Heap usage, implicit
6963 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6964 @sp 1
6965 @cartouche
6966 An implementation should document any cases in which it dynamically
6967 allocates heap storage for a purpose other than the evaluation of an
6968 allocator.
6969 @end cartouche
6970 Followed, the only other points at which heap storage is dynamically
6971 allocated are as follows:
6972
6973 @itemize @bullet
6974 @item
6975 At initial elaboration time, to allocate dynamically sized global
6976 objects.
6977
6978 @item
6979 To allocate space for a task when a task is created.
6980
6981 @item
6982 To extend the secondary stack dynamically when needed.  The secondary
6983 stack is used for returning variable length results.
6984 @end itemize
6985
6986 @sp 1
6987 @cartouche
6988 A default (implementation-provided) storage pool for an
6989 access-to-constant type should not have overhead to support deallocation of
6990 individual objects.
6991 @end cartouche
6992 Followed.
6993
6994 @sp 1
6995 @cartouche
6996 A storage pool for an anonymous access type should be created at the
6997 point of an allocator for the type, and be reclaimed when the designated
6998 object becomes inaccessible.
6999 @end cartouche
7000 Followed.
7001
7002 @cindex Unchecked deallocation
7003 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7004 @sp 1
7005 @cartouche
7006 For a standard storage pool, @code{Free} should actually reclaim the
7007 storage.
7008 @end cartouche
7009 Followed.
7010
7011 @cindex Stream oriented attributes
7012 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7013 @sp 1
7014 @cartouche
7015 If a stream element is the same size as a storage element, then the
7016 normal in-memory representation should be used by @code{Read} and
7017 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
7018 should use the smallest number of stream elements needed to represent
7019 all values in the base range of the scalar type.
7020 @end cartouche
7021
7022 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7023 which specifies using the size of the first subtype.
7024 However, such an implementation is based on direct binary
7025 representations and is therefore target- and endianness-dependent.
7026 To address this issue, GNAT also supplies an alternate implementation
7027 of the stream attributes @code{Read} and @code{Write},
7028 which uses the target-independent XDR standard representation
7029 for scalar types.
7030 @cindex XDR representation
7031 @cindex @code{Read} attribute
7032 @cindex @code{Write} attribute
7033 @cindex Stream oriented attributes
7034 The XDR implementation is provided as an alternative body of the
7035 @code{System.Stream_Attributes} package, in the file
7036 @file{s-strxdr.adb} in the GNAT library.
7037 There is no @file{s-strxdr.ads} file.
7038 In order to install the XDR implementation, do the following:
7039 @enumerate
7040 @item Replace the default implementation of the
7041 @code{System.Stream_Attributes} package with the XDR implementation.
7042 For example on a Unix platform issue the commands:
7043 @smallexample
7044 $ mv s-stratt.adb s-strold.adb
7045 $ mv s-strxdr.adb s-stratt.adb
7046 @end smallexample
7047
7048 @item
7049 Rebuild the GNAT run-time library as documented in
7050 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7051 @end enumerate
7052
7053 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7054 @sp 1
7055 @cartouche
7056 If an implementation provides additional named predefined integer types,
7057 then the names should end with @samp{Integer} as in
7058 @samp{Long_Integer}.  If an implementation provides additional named
7059 predefined floating point types, then the names should end with
7060 @samp{Float} as in @samp{Long_Float}.
7061 @end cartouche
7062 Followed.
7063
7064 @findex Ada.Characters.Handling
7065 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7066 @sp 1
7067 @cartouche
7068 If an implementation provides a localized definition of @code{Character}
7069 or @code{Wide_Character}, then the effects of the subprograms in
7070 @code{Characters.Handling} should reflect the localizations.  See also
7071 3.5.2.
7072 @end cartouche
7073 Followed.  GNAT provides no such localized definitions.
7074
7075 @cindex Bounded-length strings
7076 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7077 @sp 1
7078 @cartouche
7079 Bounded string objects should not be implemented by implicit pointers
7080 and dynamic allocation.
7081 @end cartouche
7082 Followed.  No implicit pointers or dynamic allocation are used.
7083
7084 @cindex Random number generation
7085 @unnumberedsec A.5.2(46-47): Random Number Generation
7086 @sp 1
7087 @cartouche
7088 Any storage associated with an object of type @code{Generator} should be
7089 reclaimed on exit from the scope of the object.
7090 @end cartouche
7091 Followed.
7092
7093 @sp 1
7094 @cartouche
7095 If the generator period is sufficiently long in relation to the number
7096 of distinct initiator values, then each possible value of
7097 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7098 random numbers that does not, in a practical sense, overlap the sequence
7099 initiated by any other value.  If this is not possible, then the mapping
7100 between initiator values and generator states should be a rapidly
7101 varying function of the initiator value.
7102 @end cartouche
7103 Followed.  The generator period is sufficiently long for the first
7104 condition here to hold true.
7105
7106 @findex Get_Immediate
7107 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7108 @sp 1
7109 @cartouche
7110 The @code{Get_Immediate} procedures should be implemented with
7111 unbuffered input.  For a device such as a keyboard, input should be
7112 @dfn{available} if a key has already been typed, whereas for a disk
7113 file, input should always be available except at end of file.  For a file
7114 associated with a keyboard-like device, any line-editing features of the
7115 underlying operating system should be disabled during the execution of
7116 @code{Get_Immediate}.
7117 @end cartouche
7118 Followed on all targets except VxWorks. For VxWorks, there is no way to
7119 provide this functionality that does not result in the input buffer being
7120 flushed before the @code{Get_Immediate} call. A special unit
7121 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7122 this functionality.
7123
7124 @findex Export
7125 @unnumberedsec B.1(39-41): Pragma @code{Export}
7126 @sp 1
7127 @cartouche
7128 If an implementation supports pragma @code{Export} to a given language,
7129 then it should also allow the main subprogram to be written in that
7130 language.  It should support some mechanism for invoking the elaboration
7131 of the Ada library units included in the system, and for invoking the
7132 finalization of the environment task.  On typical systems, the
7133 recommended mechanism is to provide two subprograms whose link names are
7134 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7135 elaboration code for library units.  @code{adafinal} should contain the
7136 finalization code.  These subprograms should have no effect the second
7137 and subsequent time they are called.
7138 @end cartouche
7139 Followed.
7140
7141 @sp 1
7142 @cartouche
7143 Automatic elaboration of pre-elaborated packages should be
7144 provided when pragma @code{Export} is supported.
7145 @end cartouche
7146 Followed when the main program is in Ada.  If the main program is in a
7147 foreign language, then
7148 @code{adainit} must be called to elaborate pre-elaborated
7149 packages.
7150
7151 @sp 1
7152 @cartouche
7153 For each supported convention @var{L} other than @code{Intrinsic}, an
7154 implementation should support @code{Import} and @code{Export} pragmas
7155 for objects of @var{L}-compatible types and for subprograms, and pragma
7156 @code{Convention} for @var{L}-eligible types and for subprograms,
7157 presuming the other language has corresponding features.  Pragma
7158 @code{Convention} need not be supported for scalar types.
7159 @end cartouche
7160 Followed.
7161
7162 @cindex Package @code{Interfaces}
7163 @findex Interfaces
7164 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7165 @sp 1
7166 @cartouche
7167 For each implementation-defined convention identifier, there should be a
7168 child package of package Interfaces with the corresponding name.  This
7169 package should contain any declarations that would be useful for
7170 interfacing to the language (implementation) represented by the
7171 convention.  Any declarations useful for interfacing to any language on
7172 the given hardware architecture should be provided directly in
7173 @code{Interfaces}.
7174 @end cartouche
7175 Followed. An additional package not defined
7176 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7177 for interfacing to C++.
7178
7179 @sp 1
7180 @cartouche
7181 An implementation supporting an interface to C, COBOL, or Fortran should
7182 provide the corresponding package or packages described in the following
7183 clauses.
7184 @end cartouche
7185 Followed.  GNAT provides all the packages described in this section.
7186
7187 @cindex C, interfacing with
7188 @unnumberedsec B.3(63-71): Interfacing with C
7189 @sp 1
7190 @cartouche
7191 An implementation should support the following interface correspondences
7192 between Ada and C@.
7193 @end cartouche
7194 Followed.
7195
7196 @sp 1
7197 @cartouche
7198 An Ada procedure corresponds to a void-returning C function.
7199 @end cartouche
7200 Followed.
7201
7202 @sp 1
7203 @cartouche
7204 An Ada function corresponds to a non-void C function.
7205 @end cartouche
7206 Followed.
7207
7208 @sp 1
7209 @cartouche
7210 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7211 function.
7212 @end cartouche
7213 Followed.
7214
7215 @sp 1
7216 @cartouche
7217 An Ada @code{in} parameter of an access-to-object type with designated
7218 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7219 where @var{t} is the C type corresponding to the Ada type @var{T}.
7220 @end cartouche
7221 Followed.
7222
7223 @sp 1
7224 @cartouche
7225 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7226 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7227 argument to a C function, where @var{t} is the C type corresponding to
7228 the Ada type @var{T}.  In the case of an elementary @code{out} or
7229 @code{in out} parameter, a pointer to a temporary copy is used to
7230 preserve by-copy semantics.
7231 @end cartouche
7232 Followed.
7233
7234 @sp 1
7235 @cartouche
7236 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7237 @code{@var{t}*} argument to a C function, where @var{t} is the C
7238 structure corresponding to the Ada type @var{T}.
7239 @end cartouche
7240 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7241 pragma, or Convention, or by explicitly specifying the mechanism for a given
7242 call using an extended import or export pragma.
7243
7244 @sp 1
7245 @cartouche
7246 An Ada parameter of an array type with component type @var{T}, of any
7247 mode, is passed as a @code{@var{t}*} argument to a C function, where
7248 @var{t} is the C type corresponding to the Ada type @var{T}.
7249 @end cartouche
7250 Followed.
7251
7252 @sp 1
7253 @cartouche
7254 An Ada parameter of an access-to-subprogram type is passed as a pointer
7255 to a C function whose prototype corresponds to the designated
7256 subprogram's specification.
7257 @end cartouche
7258 Followed.
7259
7260 @cindex COBOL, interfacing with
7261 @unnumberedsec B.4(95-98): Interfacing with COBOL
7262 @sp 1
7263 @cartouche
7264 An Ada implementation should support the following interface
7265 correspondences between Ada and COBOL@.
7266 @end cartouche
7267 Followed.
7268
7269 @sp 1
7270 @cartouche
7271 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7272 the COBOL type corresponding to @var{T}.
7273 @end cartouche
7274 Followed.
7275
7276 @sp 1
7277 @cartouche
7278 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7279 the corresponding COBOL type.
7280 @end cartouche
7281 Followed.
7282
7283 @sp 1
7284 @cartouche
7285 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7286 COBOL type corresponding to the Ada parameter type; for scalars, a local
7287 copy is used if necessary to ensure by-copy semantics.
7288 @end cartouche
7289 Followed.
7290
7291 @cindex Fortran, interfacing with
7292 @unnumberedsec B.5(22-26): Interfacing with Fortran
7293 @sp 1
7294 @cartouche
7295 An Ada implementation should support the following interface
7296 correspondences between Ada and Fortran:
7297 @end cartouche
7298 Followed.
7299
7300 @sp 1
7301 @cartouche
7302 An Ada procedure corresponds to a Fortran subroutine.
7303 @end cartouche
7304 Followed.
7305
7306 @sp 1
7307 @cartouche
7308 An Ada function corresponds to a Fortran function.
7309 @end cartouche
7310 Followed.
7311
7312 @sp 1
7313 @cartouche
7314 An Ada parameter of an elementary, array, or record type @var{T} is
7315 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7316 the Fortran type corresponding to the Ada type @var{T}, and where the
7317 INTENT attribute of the corresponding dummy argument matches the Ada
7318 formal parameter mode; the Fortran implementation's parameter passing
7319 conventions are used.  For elementary types, a local copy is used if
7320 necessary to ensure by-copy semantics.
7321 @end cartouche
7322 Followed.
7323
7324 @sp 1
7325 @cartouche
7326 An Ada parameter of an access-to-subprogram type is passed as a
7327 reference to a Fortran procedure whose interface corresponds to the
7328 designated subprogram's specification.
7329 @end cartouche
7330 Followed.
7331
7332 @cindex Machine operations
7333 @unnumberedsec C.1(3-5): Access to Machine Operations
7334 @sp 1
7335 @cartouche
7336 The machine code or intrinsic support should allow access to all
7337 operations normally available to assembly language programmers for the
7338 target environment, including privileged instructions, if any.
7339 @end cartouche
7340 Followed.
7341
7342 @sp 1
7343 @cartouche
7344 The interfacing pragmas (see Annex B) should support interface to
7345 assembler; the default assembler should be associated with the
7346 convention identifier @code{Assembler}.
7347 @end cartouche
7348 Followed.
7349
7350 @sp 1
7351 @cartouche
7352 If an entity is exported to assembly language, then the implementation
7353 should allocate it at an addressable location, and should ensure that it
7354 is retained by the linking process, even if not otherwise referenced
7355 from the Ada code.  The implementation should assume that any call to a
7356 machine code or assembler subprogram is allowed to read or update every
7357 object that is specified as exported.
7358 @end cartouche
7359 Followed.
7360
7361 @unnumberedsec C.1(10-16): Access to Machine Operations
7362 @sp 1
7363 @cartouche
7364 The implementation should ensure that little or no overhead is
7365 associated with calling intrinsic and machine-code subprograms.
7366 @end cartouche
7367 Followed for both intrinsics and machine-code subprograms.
7368
7369 @sp 1
7370 @cartouche
7371 It is recommended that intrinsic subprograms be provided for convenient
7372 access to any machine operations that provide special capabilities or
7373 efficiency and that are not otherwise available through the language
7374 constructs.
7375 @end cartouche
7376 Followed.  A full set of machine operation intrinsic subprograms is provided.
7377
7378 @sp 1
7379 @cartouche
7380 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7381 swap, decrement and test, enqueue/dequeue.
7382 @end cartouche
7383 Followed on any target supporting such operations.
7384
7385 @sp 1
7386 @cartouche
7387 Standard numeric functions---e.g.@:, sin, log.
7388 @end cartouche
7389 Followed on any target supporting such operations.
7390
7391 @sp 1
7392 @cartouche
7393 String manipulation operations---e.g.@:, translate and test.
7394 @end cartouche
7395 Followed on any target supporting such operations.
7396
7397 @sp 1
7398 @cartouche
7399 Vector operations---e.g.@:, compare vector against thresholds.
7400 @end cartouche
7401 Followed on any target supporting such operations.
7402
7403 @sp 1
7404 @cartouche
7405 Direct operations on I/O ports.
7406 @end cartouche
7407 Followed on any target supporting such operations.
7408
7409 @cindex Interrupt support
7410 @unnumberedsec C.3(28): Interrupt Support
7411 @sp 1
7412 @cartouche
7413 If the @code{Ceiling_Locking} policy is not in effect, the
7414 implementation should provide means for the application to specify which
7415 interrupts are to be blocked during protected actions, if the underlying
7416 system allows for a finer-grain control of interrupt blocking.
7417 @end cartouche
7418 Followed.  The underlying system does not allow for finer-grain control
7419 of interrupt blocking.
7420
7421 @cindex Protected procedure handlers
7422 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7423 @sp 1
7424 @cartouche
7425 Whenever possible, the implementation should allow interrupt handlers to
7426 be called directly by the hardware.
7427 @end cartouche
7428 @c SGI info:
7429 @ignore
7430 This is never possible under IRIX, so this is followed by default.
7431 @end ignore
7432 Followed on any target where the underlying operating system permits
7433 such direct calls.
7434
7435 @sp 1
7436 @cartouche
7437 Whenever practical, violations of any
7438 implementation-defined restrictions should be detected before run time.
7439 @end cartouche
7440 Followed.  Compile time warnings are given when possible.
7441
7442 @cindex Package @code{Interrupts}
7443 @findex Interrupts
7444 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7445
7446 @sp 1
7447 @cartouche
7448 If implementation-defined forms of interrupt handler procedures are
7449 supported, such as protected procedures with parameters, then for each
7450 such form of a handler, a type analogous to @code{Parameterless_Handler}
7451 should be specified in a child package of @code{Interrupts}, with the
7452 same operations as in the predefined package Interrupts.
7453 @end cartouche
7454 Followed.
7455
7456 @cindex Pre-elaboration requirements
7457 @unnumberedsec C.4(14): Pre-elaboration Requirements
7458 @sp 1
7459 @cartouche
7460 It is recommended that pre-elaborated packages be implemented in such a
7461 way that there should be little or no code executed at run time for the
7462 elaboration of entities not already covered by the Implementation
7463 Requirements.
7464 @end cartouche
7465 Followed.  Executable code is generated in some cases, e.g.@: loops
7466 to initialize large arrays.
7467
7468 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7469
7470 @sp 1
7471 @cartouche
7472 If the pragma applies to an entity, then the implementation should
7473 reduce the amount of storage used for storing names associated with that
7474 entity.
7475 @end cartouche
7476 Followed.
7477
7478 @cindex Package @code{Task_Attributes}
7479 @findex Task_Attributes
7480 @unnumberedsec C.7.2(30): The Package Task_Attributes
7481 @sp 1
7482 @cartouche
7483 Some implementations are targeted to domains in which memory use at run
7484 time must be completely deterministic.  For such implementations, it is
7485 recommended that the storage for task attributes will be pre-allocated
7486 statically and not from the heap.  This can be accomplished by either
7487 placing restrictions on the number and the size of the task's
7488 attributes, or by using the pre-allocated storage for the first @var{N}
7489 attribute objects, and the heap for the others.  In the latter case,
7490 @var{N} should be documented.
7491 @end cartouche
7492 Not followed.  This implementation is not targeted to such a domain.
7493
7494 @cindex Locking Policies
7495 @unnumberedsec D.3(17): Locking Policies
7496
7497 @sp 1
7498 @cartouche
7499 The implementation should use names that end with @samp{_Locking} for
7500 locking policies defined by the implementation.
7501 @end cartouche
7502 Followed.  A single implementation-defined locking policy is defined,
7503 whose name (@code{Inheritance_Locking}) follows this suggestion.
7504
7505 @cindex Entry queuing policies
7506 @unnumberedsec D.4(16): Entry Queuing Policies
7507 @sp 1
7508 @cartouche
7509 Names that end with @samp{_Queuing} should be used
7510 for all implementation-defined queuing policies.
7511 @end cartouche
7512 Followed.  No such implementation-defined queuing policies exist.
7513
7514 @cindex Preemptive abort
7515 @unnumberedsec D.6(9-10): Preemptive Abort
7516 @sp 1
7517 @cartouche
7518 Even though the @code{abort_statement} is included in the list of
7519 potentially blocking operations (see 9.5.1), it is recommended that this
7520 statement be implemented in a way that never requires the task executing
7521 the @code{abort_statement} to block.
7522 @end cartouche
7523 Followed.
7524
7525 @sp 1
7526 @cartouche
7527 On a multi-processor, the delay associated with aborting a task on
7528 another processor should be bounded; the implementation should use
7529 periodic polling, if necessary, to achieve this.
7530 @end cartouche
7531 Followed.
7532
7533 @cindex Tasking restrictions
7534 @unnumberedsec D.7(21): Tasking Restrictions
7535 @sp 1
7536 @cartouche
7537 When feasible, the implementation should take advantage of the specified
7538 restrictions to produce a more efficient implementation.
7539 @end cartouche
7540 GNAT currently takes advantage of these restrictions by providing an optimized
7541 run time when the Ravenscar profile and the GNAT restricted run time set
7542 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7543 pragma @code{Profile (Restricted)} for more details.
7544
7545 @cindex Time, monotonic
7546 @unnumberedsec D.8(47-49): Monotonic Time
7547 @sp 1
7548 @cartouche
7549 When appropriate, implementations should provide configuration
7550 mechanisms to change the value of @code{Tick}.
7551 @end cartouche
7552 Such configuration mechanisms are not appropriate to this implementation
7553 and are thus not supported.
7554
7555 @sp 1
7556 @cartouche
7557 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7558 be implemented as transformations of the same time base.
7559 @end cartouche
7560 Followed.
7561
7562 @sp 1
7563 @cartouche
7564 It is recommended that the @dfn{best} time base which exists in
7565 the underlying system be available to the application through
7566 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7567 @end cartouche
7568 Followed.
7569
7570 @cindex Partition communication subsystem
7571 @cindex PCS
7572 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7573 @sp 1
7574 @cartouche
7575 Whenever possible, the PCS on the called partition should allow for
7576 multiple tasks to call the RPC-receiver with different messages and
7577 should allow them to block until the corresponding subprogram body
7578 returns.
7579 @end cartouche
7580 Followed by GLADE, a separately supplied PCS that can be used with
7581 GNAT.
7582
7583 @sp 1
7584 @cartouche
7585 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7586 should raise @code{Storage_Error} if it runs out of space trying to
7587 write the @code{Item} into the stream.
7588 @end cartouche
7589 Followed by GLADE, a separately supplied PCS that can be used with
7590 GNAT@.
7591
7592 @cindex COBOL support
7593 @unnumberedsec F(7): COBOL Support
7594 @sp 1
7595 @cartouche
7596 If COBOL (respectively, C) is widely supported in the target
7597 environment, implementations supporting the Information Systems Annex
7598 should provide the child package @code{Interfaces.COBOL} (respectively,
7599 @code{Interfaces.C}) specified in Annex B and should support a
7600 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7601 pragmas (see Annex B), thus allowing Ada programs to interface with
7602 programs written in that language.
7603 @end cartouche
7604 Followed.
7605
7606 @cindex Decimal radix support
7607 @unnumberedsec F.1(2): Decimal Radix Support
7608 @sp 1
7609 @cartouche
7610 Packed decimal should be used as the internal representation for objects
7611 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7612 @end cartouche
7613 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7614 representations.
7615
7616 @cindex Numerics
7617 @unnumberedsec G: Numerics
7618 @sp 2
7619 @cartouche
7620 If Fortran (respectively, C) is widely supported in the target
7621 environment, implementations supporting the Numerics Annex
7622 should provide the child package @code{Interfaces.Fortran} (respectively,
7623 @code{Interfaces.C}) specified in Annex B and should support a
7624 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7625 pragmas (see Annex B), thus allowing Ada programs to interface with
7626 programs written in that language.
7627 @end cartouche
7628 Followed.
7629
7630 @cindex Complex types
7631 @unnumberedsec G.1.1(56-58): Complex Types
7632 @sp 2
7633 @cartouche
7634 Because the usual mathematical meaning of multiplication of a complex
7635 operand and a real operand is that of the scaling of both components of
7636 the former by the latter, an implementation should not perform this
7637 operation by first promoting the real operand to complex type and then
7638 performing a full complex multiplication.  In systems that, in the
7639 future, support an Ada binding to IEC 559:1989, the latter technique
7640 will not generate the required result when one of the components of the
7641 complex operand is infinite.  (Explicit multiplication of the infinite
7642 component by the zero component obtained during promotion yields a NaN
7643 that propagates into the final result.) Analogous advice applies in the
7644 case of multiplication of a complex operand and a pure-imaginary
7645 operand, and in the case of division of a complex operand by a real or
7646 pure-imaginary operand.
7647 @end cartouche
7648 Not followed.
7649
7650 @sp 1
7651 @cartouche
7652 Similarly, because the usual mathematical meaning of addition of a
7653 complex operand and a real operand is that the imaginary operand remains
7654 unchanged, an implementation should not perform this operation by first
7655 promoting the real operand to complex type and then performing a full
7656 complex addition.  In implementations in which the @code{Signed_Zeros}
7657 attribute of the component type is @code{True} (and which therefore
7658 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7659 predefined arithmetic operations), the latter technique will not
7660 generate the required result when the imaginary component of the complex
7661 operand is a negatively signed zero.  (Explicit addition of the negative
7662 zero to the zero obtained during promotion yields a positive zero.)
7663 Analogous advice applies in the case of addition of a complex operand
7664 and a pure-imaginary operand, and in the case of subtraction of a
7665 complex operand and a real or pure-imaginary operand.
7666 @end cartouche
7667 Not followed.
7668
7669 @sp 1
7670 @cartouche
7671 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7672 attempt to provide a rational treatment of the signs of zero results and
7673 result components.  As one example, the result of the @code{Argument}
7674 function should have the sign of the imaginary component of the
7675 parameter @code{X} when the point represented by that parameter lies on
7676 the positive real axis; as another, the sign of the imaginary component
7677 of the @code{Compose_From_Polar} function should be the same as
7678 (respectively, the opposite of) that of the @code{Argument} parameter when that
7679 parameter has a value of zero and the @code{Modulus} parameter has a
7680 nonnegative (respectively, negative) value.
7681 @end cartouche
7682 Followed.
7683
7684 @cindex Complex elementary functions
7685 @unnumberedsec G.1.2(49): Complex Elementary Functions
7686 @sp 1
7687 @cartouche
7688 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7689 @code{True} should attempt to provide a rational treatment of the signs
7690 of zero results and result components.  For example, many of the complex
7691 elementary functions have components that are odd functions of one of
7692 the parameter components; in these cases, the result component should
7693 have the sign of the parameter component at the origin.  Other complex
7694 elementary functions have zero components whose sign is opposite that of
7695 a parameter component at the origin, or is always positive or always
7696 negative.
7697 @end cartouche
7698 Followed.
7699
7700 @cindex Accuracy requirements
7701 @unnumberedsec G.2.4(19): Accuracy Requirements
7702 @sp 1
7703 @cartouche
7704 The versions of the forward trigonometric functions without a
7705 @code{Cycle} parameter should not be implemented by calling the
7706 corresponding version with a @code{Cycle} parameter of
7707 @code{2.0*Numerics.Pi}, since this will not provide the required
7708 accuracy in some portions of the domain.  For the same reason, the
7709 version of @code{Log} without a @code{Base} parameter should not be
7710 implemented by calling the corresponding version with a @code{Base}
7711 parameter of @code{Numerics.e}.
7712 @end cartouche
7713 Followed.
7714
7715 @cindex Complex arithmetic accuracy
7716 @cindex Accuracy, complex arithmetic
7717 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7718
7719 @sp 1
7720 @cartouche
7721 The version of the @code{Compose_From_Polar} function without a
7722 @code{Cycle} parameter should not be implemented by calling the
7723 corresponding version with a @code{Cycle} parameter of
7724 @code{2.0*Numerics.Pi}, since this will not provide the required
7725 accuracy in some portions of the domain.
7726 @end cartouche
7727 Followed.
7728
7729 @c -----------------------------------------
7730 @node Implementation Defined Characteristics
7731 @chapter Implementation Defined Characteristics
7732
7733 @noindent
7734 In addition to the implementation dependent pragmas and attributes, and
7735 the implementation advice, there are a number of other Ada features
7736 that are potentially implementation dependent.  These are mentioned
7737 throughout the Ada Reference Manual, and are summarized in annex M@.
7738
7739 A requirement for conforming Ada compilers is that they provide
7740 documentation describing how the implementation deals with each of these
7741 issues.  In this chapter, you will find each point in annex M listed
7742 followed by a description in italic font of how GNAT
7743 @c SGI info:
7744 @ignore
7745 in the ProDev Ada
7746 implementation on IRIX 5.3 operating system or greater
7747 @end ignore
7748 handles the implementation dependence.
7749
7750 You can use this chapter as a guide to minimizing implementation
7751 dependent features in your programs if portability to other compilers
7752 and other operating systems is an important consideration.  The numbers
7753 in each section below correspond to the paragraph number in the Ada
7754 Reference Manual.
7755
7756 @sp 1
7757 @cartouche
7758 @noindent
7759 @strong{2}.  Whether or not each recommendation given in Implementation
7760 Advice is followed.  See 1.1.2(37).
7761 @end cartouche
7762 @noindent
7763 @xref{Implementation Advice}.
7764
7765 @sp 1
7766 @cartouche
7767 @noindent
7768 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7769 @end cartouche
7770 @noindent
7771 The complexity of programs that can be processed is limited only by the
7772 total amount of available virtual memory, and disk space for the
7773 generated object files.
7774
7775 @sp 1
7776 @cartouche
7777 @noindent
7778 @strong{4}.  Variations from the standard that are impractical to avoid
7779 given the implementation's execution environment.  See 1.1.3(6).
7780 @end cartouche
7781 @noindent
7782 There are no variations from the standard.
7783
7784 @sp 1
7785 @cartouche
7786 @noindent
7787 @strong{5}.  Which @code{code_statement}s cause external
7788 interactions.  See 1.1.3(10).
7789 @end cartouche
7790 @noindent
7791 Any @code{code_statement} can potentially cause external interactions.
7792
7793 @sp 1
7794 @cartouche
7795 @noindent
7796 @strong{6}.  The coded representation for the text of an Ada
7797 program.  See 2.1(4).
7798 @end cartouche
7799 @noindent
7800 See separate section on source representation.
7801
7802 @sp 1
7803 @cartouche
7804 @noindent
7805 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7806 @end cartouche
7807 @noindent
7808 See separate section on source representation.
7809
7810 @sp 1
7811 @cartouche
7812 @noindent
7813 @strong{8}.  The representation for an end of line.  See 2.2(2).
7814 @end cartouche
7815 @noindent
7816 See separate section on source representation.
7817
7818 @sp 1
7819 @cartouche
7820 @noindent
7821 @strong{9}.  Maximum supported line length and lexical element
7822 length.  See 2.2(15).
7823 @end cartouche
7824 @noindent
7825 The maximum line length is 255 characters and the maximum length of a
7826 lexical element is also 255 characters.
7827
7828 @sp 1
7829 @cartouche
7830 @noindent
7831 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7832 @end cartouche
7833 @noindent
7834
7835 @xref{Implementation Defined Pragmas}.
7836
7837 @sp 1
7838 @cartouche
7839 @noindent
7840 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7841 @end cartouche
7842 @noindent
7843 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7844 parameter, checks that the optimization flag is set, and aborts if it is
7845 not.
7846
7847 @sp 1
7848 @cartouche
7849 @noindent
7850 @strong{12}.  The sequence of characters of the value returned by
7851 @code{@var{S}'Image} when some of the graphic characters of
7852 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7853 3.5(37).
7854 @end cartouche
7855 @noindent
7856 The sequence of characters is as defined by the wide character encoding
7857 method used for the source.  See section on source representation for
7858 further details.
7859
7860 @sp 1
7861 @cartouche
7862 @noindent
7863 @strong{13}.  The predefined integer types declared in
7864 @code{Standard}.  See 3.5.4(25).
7865 @end cartouche
7866 @noindent
7867 @table @code
7868 @item Short_Short_Integer
7869 8 bit signed
7870 @item Short_Integer
7871 (Short) 16 bit signed
7872 @item Integer
7873 32 bit signed
7874 @item Long_Integer
7875 64 bit signed (Alpha OpenVMS only)
7876 32 bit signed (all other targets)
7877 @item Long_Long_Integer
7878 64 bit signed
7879 @end table
7880
7881 @sp 1
7882 @cartouche
7883 @noindent
7884 @strong{14}.  Any nonstandard integer types and the operators defined
7885 for them.  See 3.5.4(26).
7886 @end cartouche
7887 @noindent
7888 There are no nonstandard integer types.
7889
7890 @sp 1
7891 @cartouche
7892 @noindent
7893 @strong{15}.  Any nonstandard real types and the operators defined for
7894 them.  See 3.5.6(8).
7895 @end cartouche
7896 @noindent
7897 There are no nonstandard real types.
7898
7899 @sp 1
7900 @cartouche
7901 @noindent
7902 @strong{16}.  What combinations of requested decimal precision and range
7903 are supported for floating point types.  See 3.5.7(7).
7904 @end cartouche
7905 @noindent
7906 The precision and range is as defined by the IEEE standard.
7907
7908 @sp 1
7909 @cartouche
7910 @noindent
7911 @strong{17}.  The predefined floating point types declared in
7912 @code{Standard}.  See 3.5.7(16).
7913 @end cartouche
7914 @noindent
7915 @table @code
7916 @item Short_Float
7917 32 bit IEEE short
7918 @item Float
7919 (Short) 32 bit IEEE short
7920 @item Long_Float
7921 64 bit IEEE long
7922 @item Long_Long_Float
7923 64 bit IEEE long (80 bit IEEE long on x86 processors)
7924 @end table
7925
7926 @sp 1
7927 @cartouche
7928 @noindent
7929 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7930 @end cartouche
7931 @noindent
7932 @code{Fine_Delta} is 2**(@minus{}63)
7933
7934 @sp 1
7935 @cartouche
7936 @noindent
7937 @strong{19}.  What combinations of small, range, and digits are
7938 supported for fixed point types.  See 3.5.9(10).
7939 @end cartouche
7940 @noindent
7941 Any combinations are permitted that do not result in a small less than
7942 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7943 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7944 is 64 bits (true of all architectures except ia32), then the output from
7945 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7946 is because floating-point conversions are used to convert fixed point.
7947
7948 @sp 1
7949 @cartouche
7950 @noindent
7951 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7952 within an unnamed @code{block_statement}.  See 3.9(10).
7953 @end cartouche
7954 @noindent
7955 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7956 decimal integer are allocated.
7957
7958 @sp 1
7959 @cartouche
7960 @noindent
7961 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7962 @end cartouche
7963 @noindent
7964 @xref{Implementation Defined Attributes}.
7965
7966 @sp 1
7967 @cartouche
7968 @noindent
7969 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7970 @end cartouche
7971 @noindent
7972 There are no implementation-defined time types.
7973
7974 @sp 1
7975 @cartouche
7976 @noindent
7977 @strong{23}.  The time base associated with relative delays.
7978 @end cartouche
7979 @noindent
7980 See 9.6(20).  The time base used is that provided by the C library
7981 function @code{gettimeofday}.
7982
7983 @sp 1
7984 @cartouche
7985 @noindent
7986 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7987 9.6(23).
7988 @end cartouche
7989 @noindent
7990 The time base used is that provided by the C library function
7991 @code{gettimeofday}.
7992
7993 @sp 1
7994 @cartouche
7995 @noindent
7996 @strong{25}.  The time zone used for package @code{Calendar}
7997 operations.  See 9.6(24).
7998 @end cartouche
7999 @noindent
8000 The time zone used by package @code{Calendar} is the current system time zone
8001 setting for local time, as accessed by the C library function
8002 @code{localtime}.
8003
8004 @sp 1
8005 @cartouche
8006 @noindent
8007 @strong{26}.  Any limit on @code{delay_until_statements} of
8008 @code{select_statements}.  See 9.6(29).
8009 @end cartouche
8010 @noindent
8011 There are no such limits.
8012
8013 @sp 1
8014 @cartouche
8015 @noindent
8016 @strong{27}.  Whether or not two non-overlapping parts of a composite
8017 object are independently addressable, in the case where packing, record
8018 layout, or @code{Component_Size} is specified for the object.  See
8019 9.10(1).
8020 @end cartouche
8021 @noindent
8022 Separate components are independently addressable if they do not share
8023 overlapping storage units.
8024
8025 @sp 1
8026 @cartouche
8027 @noindent
8028 @strong{28}.  The representation for a compilation.  See 10.1(2).
8029 @end cartouche
8030 @noindent
8031 A compilation is represented by a sequence of files presented to the
8032 compiler in a single invocation of the @command{gcc} command.
8033
8034 @sp 1
8035 @cartouche
8036 @noindent
8037 @strong{29}.  Any restrictions on compilations that contain multiple
8038 compilation_units.  See 10.1(4).
8039 @end cartouche
8040 @noindent
8041 No single file can contain more than one compilation unit, but any
8042 sequence of files can be presented to the compiler as a single
8043 compilation.
8044
8045 @sp 1
8046 @cartouche
8047 @noindent
8048 @strong{30}.  The mechanisms for creating an environment and for adding
8049 and replacing compilation units.  See 10.1.4(3).
8050 @end cartouche
8051 @noindent
8052 See separate section on compilation model.
8053
8054 @sp 1
8055 @cartouche
8056 @noindent
8057 @strong{31}.  The manner of explicitly assigning library units to a
8058 partition.  See 10.2(2).
8059 @end cartouche
8060 @noindent
8061 If a unit contains an Ada main program, then the Ada units for the partition
8062 are determined by recursive application of the rules in the Ada Reference
8063 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8064 are needed by the main program, and then this definition of need is applied
8065 recursively to those units, and the partition contains the transitive
8066 closure determined by this relationship.  In short, all the necessary units
8067 are included, with no need to explicitly specify the list.  If additional
8068 units are required, e.g.@: by foreign language units, then all units must be
8069 mentioned in the context clause of one of the needed Ada units.
8070
8071 If the partition contains no main program, or if the main program is in
8072 a language other than Ada, then GNAT
8073 provides the binder options @option{-z} and @option{-n} respectively, and in
8074 this case a list of units can be explicitly supplied to the binder for
8075 inclusion in the partition (all units needed by these units will also
8076 be included automatically).  For full details on the use of these
8077 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8078 @value{EDITION} User's Guide}.
8079
8080 @sp 1
8081 @cartouche
8082 @noindent
8083 @strong{32}.  The implementation-defined means, if any, of specifying
8084 which compilation units are needed by a given compilation unit.  See
8085 10.2(2).
8086 @end cartouche
8087 @noindent
8088 The units needed by a given compilation unit are as defined in
8089 the Ada Reference Manual section 10.2(2-6).  There are no
8090 implementation-defined pragmas or other implementation-defined
8091 means for specifying needed units.
8092
8093 @sp 1
8094 @cartouche
8095 @noindent
8096 @strong{33}.  The manner of designating the main subprogram of a
8097 partition.  See 10.2(7).
8098 @end cartouche
8099 @noindent
8100 The main program is designated by providing the name of the
8101 corresponding @file{ALI} file as the input parameter to the binder.
8102
8103 @sp 1
8104 @cartouche
8105 @noindent
8106 @strong{34}.  The order of elaboration of @code{library_items}.  See
8107 10.2(18).
8108 @end cartouche
8109 @noindent
8110 The first constraint on ordering is that it meets the requirements of
8111 Chapter 10 of the Ada Reference Manual.  This still leaves some
8112 implementation dependent choices, which are resolved by first
8113 elaborating bodies as early as possible (i.e., in preference to specs
8114 where there is a choice), and second by evaluating the immediate with
8115 clauses of a unit to determine the probably best choice, and
8116 third by elaborating in alphabetical order of unit names
8117 where a choice still remains.
8118
8119 @sp 1
8120 @cartouche
8121 @noindent
8122 @strong{35}.  Parameter passing and function return for the main
8123 subprogram.  See 10.2(21).
8124 @end cartouche
8125 @noindent
8126 The main program has no parameters.  It may be a procedure, or a function
8127 returning an integer type.  In the latter case, the returned integer
8128 value is the return code of the program (overriding any value that
8129 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8130
8131 @sp 1
8132 @cartouche
8133 @noindent
8134 @strong{36}.  The mechanisms for building and running partitions.  See
8135 10.2(24).
8136 @end cartouche
8137 @noindent
8138 GNAT itself supports programs with only a single partition.  The GNATDIST
8139 tool provided with the GLADE package (which also includes an implementation
8140 of the PCS) provides a completely flexible method for building and running
8141 programs consisting of multiple partitions.  See the separate GLADE manual
8142 for details.
8143
8144 @sp 1
8145 @cartouche
8146 @noindent
8147 @strong{37}.  The details of program execution, including program
8148 termination.  See 10.2(25).
8149 @end cartouche
8150 @noindent
8151 See separate section on compilation model.
8152
8153 @sp 1
8154 @cartouche
8155 @noindent
8156 @strong{38}.  The semantics of any non-active partitions supported by the
8157 implementation.  See 10.2(28).
8158 @end cartouche
8159 @noindent
8160 Passive partitions are supported on targets where shared memory is
8161 provided by the operating system.  See the GLADE reference manual for
8162 further details.
8163
8164 @sp 1
8165 @cartouche
8166 @noindent
8167 @strong{39}.  The information returned by @code{Exception_Message}.  See
8168 11.4.1(10).
8169 @end cartouche
8170 @noindent
8171 Exception message returns the null string unless a specific message has
8172 been passed by the program.
8173
8174 @sp 1
8175 @cartouche
8176 @noindent
8177 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8178 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8179 @end cartouche
8180 @noindent
8181 Blocks have implementation defined names of the form @code{B@var{nnn}}
8182 where @var{nnn} is an integer.
8183
8184 @sp 1
8185 @cartouche
8186 @noindent
8187 @strong{41}.  The information returned by
8188 @code{Exception_Information}.  See 11.4.1(13).
8189 @end cartouche
8190 @noindent
8191 @code{Exception_Information} returns a string in the following format:
8192
8193 @smallexample
8194 @emph{Exception_Name:} nnnnn
8195 @emph{Message:} mmmmm
8196 @emph{PID:} ppp
8197 @emph{Call stack traceback locations:}
8198 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8199 @end smallexample
8200
8201 @noindent
8202 where
8203
8204 @itemize @bullet
8205 @item
8206 @code{nnnn} is the fully qualified name of the exception in all upper
8207 case letters. This line is always present.
8208
8209 @item
8210 @code{mmmm} is the message (this line present only if message is non-null)
8211
8212 @item
8213 @code{ppp} is the Process Id value as a decimal integer (this line is
8214 present only if the Process Id is nonzero). Currently we are
8215 not making use of this field.
8216
8217 @item
8218 The Call stack traceback locations line and the following values
8219 are present only if at least one traceback location was recorded.
8220 The values are given in C style format, with lower case letters
8221 for a-f, and only as many digits present as are necessary.
8222 @end itemize
8223
8224 @noindent
8225 The line terminator sequence at the end of each line, including
8226 the last line is a single @code{LF} character (@code{16#0A#}).
8227
8228 @sp 1
8229 @cartouche
8230 @noindent
8231 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8232 @end cartouche
8233 @noindent
8234 The implementation defined check name Alignment_Check controls checking of
8235 address clause values for proper alignment (that is, the address supplied
8236 must be consistent with the alignment of the type).
8237
8238 In addition, a user program can add implementation-defined check names
8239 by means of the pragma Check_Name.
8240
8241 @sp 1
8242 @cartouche
8243 @noindent
8244 @strong{43}.  The interpretation of each aspect of representation.  See
8245 13.1(20).
8246 @end cartouche
8247 @noindent
8248 See separate section on data representations.
8249
8250 @sp 1
8251 @cartouche
8252 @noindent
8253 @strong{44}.  Any restrictions placed upon representation items.  See
8254 13.1(20).
8255 @end cartouche
8256 @noindent
8257 See separate section on data representations.
8258
8259 @sp 1
8260 @cartouche
8261 @noindent
8262 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8263 13.3(48).
8264 @end cartouche
8265 @noindent
8266 Size for an indefinite subtype is the maximum possible size, except that
8267 for the case of a subprogram parameter, the size of the parameter object
8268 is the actual size.
8269
8270 @sp 1
8271 @cartouche
8272 @noindent
8273 @strong{46}.  The default external representation for a type tag.  See
8274 13.3(75).
8275 @end cartouche
8276 @noindent
8277 The default external representation for a type tag is the fully expanded
8278 name of the type in upper case letters.
8279
8280 @sp 1
8281 @cartouche
8282 @noindent
8283 @strong{47}.  What determines whether a compilation unit is the same in
8284 two different partitions.  See 13.3(76).
8285 @end cartouche
8286 @noindent
8287 A compilation unit is the same in two different partitions if and only
8288 if it derives from the same source file.
8289
8290 @sp 1
8291 @cartouche
8292 @noindent
8293 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8294 @end cartouche
8295 @noindent
8296 The only implementation defined component is the tag for a tagged type,
8297 which contains a pointer to the dispatching table.
8298
8299 @sp 1
8300 @cartouche
8301 @noindent
8302 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8303 ordering.  See 13.5.3(5).
8304 @end cartouche
8305 @noindent
8306 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8307 implementation, so no non-default bit ordering is supported.  The default
8308 bit ordering corresponds to the natural endianness of the target architecture.
8309
8310 @sp 1
8311 @cartouche
8312 @noindent
8313 @strong{50}.  The contents of the visible part of package @code{System}
8314 and its language-defined children.  See 13.7(2).
8315 @end cartouche
8316 @noindent
8317 See the definition of these packages in files @file{system.ads} and
8318 @file{s-stoele.ads}.
8319
8320 @sp 1
8321 @cartouche
8322 @noindent
8323 @strong{51}.  The contents of the visible part of package
8324 @code{System.Machine_Code}, and the meaning of
8325 @code{code_statements}.  See 13.8(7).
8326 @end cartouche
8327 @noindent
8328 See the definition and documentation in file @file{s-maccod.ads}.
8329
8330 @sp 1
8331 @cartouche
8332 @noindent
8333 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8334 @end cartouche
8335 @noindent
8336 Unchecked conversion between types of the same size
8337 results in an uninterpreted transmission of the bits from one type
8338 to the other.  If the types are of unequal sizes, then in the case of
8339 discrete types, a shorter source is first zero or sign extended as
8340 necessary, and a shorter target is simply truncated on the left.
8341 For all non-discrete types, the source is first copied if necessary
8342 to ensure that the alignment requirements of the target are met, then
8343 a pointer is constructed to the source value, and the result is obtained
8344 by dereferencing this pointer after converting it to be a pointer to the
8345 target type. Unchecked conversions where the target subtype is an
8346 unconstrained array are not permitted. If the target alignment is
8347 greater than the source alignment, then a copy of the result is
8348 made with appropriate alignment
8349
8350 @sp 1
8351 @cartouche
8352 @noindent
8353 @strong{53}.  The manner of choosing a storage pool for an access type
8354 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8355 @end cartouche
8356 @noindent
8357 There are 3 different standard pools used by the compiler when
8358 @code{Storage_Pool} is not specified depending whether the type is local
8359 to a subprogram or defined at the library level and whether
8360 @code{Storage_Size}is specified or not.  See documentation in the runtime
8361 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8362 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8363 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8364 default pools used.
8365
8366 @sp 1
8367 @cartouche
8368 @noindent
8369 @strong{54}.  Whether or not the implementation provides user-accessible
8370 names for the standard pool type(s).  See 13.11(17).
8371 @end cartouche
8372 @noindent
8373
8374 See documentation in the sources of the run time mentioned in paragraph
8375 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8376 these units.
8377
8378 @sp 1
8379 @cartouche
8380 @noindent
8381 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8382 @end cartouche
8383 @noindent
8384 @code{Storage_Size} is measured in storage units, and refers to the
8385 total space available for an access type collection, or to the primary
8386 stack space for a task.
8387
8388 @sp 1
8389 @cartouche
8390 @noindent
8391 @strong{56}.  Implementation-defined aspects of storage pools.  See
8392 13.11(22).
8393 @end cartouche
8394 @noindent
8395 See documentation in the sources of the run time mentioned in paragraph
8396 @strong{53} for details on GNAT-defined aspects of storage pools.
8397
8398 @sp 1
8399 @cartouche
8400 @noindent
8401 @strong{57}.  The set of restrictions allowed in a pragma
8402 @code{Restrictions}.  See 13.12(7).
8403 @end cartouche
8404 @noindent
8405 All RM defined Restriction identifiers are implemented.  The following
8406 additional restriction identifiers are provided.  There are two separate
8407 lists of implementation dependent restriction identifiers.  The first
8408 set requires consistency throughout a partition (in other words, if the
8409 restriction identifier is used for any compilation unit in the partition,
8410 then all compilation units in the partition must obey the restriction.
8411
8412 @table @code
8413
8414 @item Simple_Barriers
8415 @findex Simple_Barriers
8416 This restriction ensures at compile time that barriers in entry declarations
8417 for protected types are restricted to either static boolean expressions or
8418 references to simple boolean variables defined in the private part of the
8419 protected type.  No other form of entry barriers is permitted.  This is one
8420 of the restrictions of the Ravenscar profile for limited tasking (see also
8421 pragma @code{Profile (Ravenscar)}).
8422
8423 @item Max_Entry_Queue_Length => Expr
8424 @findex Max_Entry_Queue_Length
8425 This restriction is a declaration that any protected entry compiled in
8426 the scope of the restriction has at most the specified number of
8427 tasks waiting on the entry
8428 at any one time, and so no queue is required.  This restriction is not
8429 checked at compile time.  A program execution is erroneous if an attempt
8430 is made to queue more than the specified number of tasks on such an entry.
8431
8432 @item No_Calendar
8433 @findex No_Calendar
8434 This restriction ensures at compile time that there is no implicit or
8435 explicit dependence on the package @code{Ada.Calendar}.
8436
8437 @item No_Default_Initialization
8438 @findex No_Default_Initialization
8439
8440 This restriction prohibits any instance of default initialization of variables.
8441 The binder implements a consistency rule which prevents any unit compiled
8442 without the restriction from with'ing a unit with the restriction (this allows
8443 the generation of initialization procedures to be skipped, since you can be
8444 sure that no call is ever generated to an initialization procedure in a unit
8445 with the restriction active). If used in conjunction with Initialize_Scalars or
8446 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8447 without a specific initializer (including the case of OUT scalar parameters).
8448
8449 @item No_Direct_Boolean_Operators
8450 @findex No_Direct_Boolean_Operators
8451 This restriction ensures that no logical (and/or/xor) are used on
8452 operands of type Boolean (or any type derived
8453 from Boolean). This is intended for use in safety critical programs
8454 where the certification protocol requires the use of short-circuit
8455 (and then, or else) forms for all composite boolean operations.
8456
8457 @item No_Dispatching_Calls
8458 @findex No_Dispatching_Calls
8459 This restriction ensures at compile time that the code generated by the
8460 compiler involves no dispatching calls. The use of this restriction allows the
8461 safe use of record extensions, classwide membership tests and other classwide
8462 features not involving implicit dispatching. This restriction ensures that
8463 the code contains no indirect calls through a dispatching mechanism. Note that
8464 this includes internally-generated calls created by the compiler, for example
8465 in the implementation of class-wide objects assignments. The
8466 membership test is allowed in the presence of this restriction, because its
8467 implementation requires no dispatching.
8468 This restriction is comparable to the official Ada restriction
8469 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8470 all classwide constructs that do not imply dispatching.
8471 The following example indicates constructs that violate this restriction.
8472
8473 @smallexample
8474 package Pkg is
8475   type T is tagged record
8476     Data : Natural;
8477   end record;
8478   procedure P (X : T);
8479
8480   type DT is new T with record
8481     More_Data : Natural;
8482   end record;
8483   procedure Q (X : DT);
8484 end Pkg;
8485
8486 with Pkg; use Pkg;
8487 procedure Example is
8488   procedure Test (O : T'Class) is
8489     N : Natural  := O'Size;--  Error: Dispatching call
8490     C : T'Class := O;      --  Error: implicit Dispatching Call
8491   begin
8492     if O in DT'Class then  --  OK   : Membership test
8493        Q (DT (O));         --  OK   : Type conversion plus direct call
8494     else
8495        P (O);              --  Error: Dispatching call
8496     end if;
8497   end Test;
8498
8499   Obj : DT;
8500 begin
8501   P (Obj);                 --  OK   : Direct call
8502   P (T (Obj));             --  OK   : Type conversion plus direct call
8503   P (T'Class (Obj));       --  Error: Dispatching call
8504
8505   Test (Obj);              --  OK   : Type conversion
8506
8507   if Obj in T'Class then   --  OK   : Membership test
8508      null;
8509   end if;
8510 end Example;
8511 @end smallexample
8512
8513 @item No_Dynamic_Attachment
8514 @findex No_Dynamic_Attachment
8515 This restriction ensures that there is no call to any of the operations
8516 defined in package Ada.Interrupts.
8517
8518 @item No_Enumeration_Maps
8519 @findex No_Enumeration_Maps
8520 This restriction ensures at compile time that no operations requiring
8521 enumeration maps are used (that is Image and Value attributes applied
8522 to enumeration types).
8523
8524 @item No_Entry_Calls_In_Elaboration_Code
8525 @findex No_Entry_Calls_In_Elaboration_Code
8526 This restriction ensures at compile time that no task or protected entry
8527 calls are made during elaboration code.  As a result of the use of this
8528 restriction, the compiler can assume that no code past an accept statement
8529 in a task can be executed at elaboration time.
8530
8531 @item No_Exception_Handlers
8532 @findex No_Exception_Handlers
8533 This restriction ensures at compile time that there are no explicit
8534 exception handlers. It also indicates that no exception propagation will
8535 be provided. In this mode, exceptions may be raised but will result in
8536 an immediate call to the last chance handler, a routine that the user
8537 must define with the following profile:
8538
8539 @smallexample @c ada
8540 procedure Last_Chance_Handler
8541   (Source_Location : System.Address; Line : Integer);
8542 pragma Export (C, Last_Chance_Handler,
8543                "__gnat_last_chance_handler");
8544 @end smallexample
8545
8546 The parameter is a C null-terminated string representing a message to be
8547 associated with the exception (typically the source location of the raise
8548 statement generated by the compiler). The Line parameter when nonzero
8549 represents the line number in the source program where the raise occurs.
8550
8551 @item No_Exception_Propagation
8552 @findex No_Exception_Propagation
8553 This restriction guarantees that exceptions are never propagated to an outer
8554 subprogram scope). The only case in which an exception may be raised is when
8555 the handler is statically in the same subprogram, so that the effect of a raise
8556 is essentially like a goto statement. Any other raise statement (implicit or
8557 explicit) will be considered unhandled. Exception handlers are allowed, but may
8558 not contain an exception occurrence identifier (exception choice). In addition
8559 use of the package GNAT.Current_Exception is not permitted, and reraise
8560 statements (raise with no operand) are not permitted.
8561
8562 @item No_Exception_Registration
8563 @findex No_Exception_Registration
8564 This restriction ensures at compile time that no stream operations for
8565 types Exception_Id or Exception_Occurrence are used. This also makes it
8566 impossible to pass exceptions to or from a partition with this restriction
8567 in a distributed environment. If this exception is active, then the generated
8568 code is simplified by omitting the otherwise-required global registration
8569 of exceptions when they are declared.
8570
8571 @item No_Implicit_Conditionals
8572 @findex No_Implicit_Conditionals
8573 This restriction ensures that the generated code does not contain any
8574 implicit conditionals, either by modifying the generated code where possible,
8575 or by rejecting any construct that would otherwise generate an implicit
8576 conditional. Note that this check does not include run time constraint
8577 checks, which on some targets may generate implicit conditionals as
8578 well. To control the latter, constraint checks can be suppressed in the
8579 normal manner. Constructs generating implicit conditionals include comparisons
8580 of composite objects and the Max/Min attributes.
8581
8582 @item No_Implicit_Dynamic_Code
8583 @findex No_Implicit_Dynamic_Code
8584 @cindex trampoline
8585 This restriction prevents the compiler from building ``trampolines''.
8586 This is a structure that is built on the stack and contains dynamic
8587 code to be executed at run time. On some targets, a trampoline is
8588 built for the following features: @code{Access},
8589 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8590 nested task bodies; primitive operations of nested tagged types.
8591 Trampolines do not work on machines that prevent execution of stack
8592 data. For example, on windows systems, enabling DEP (data execution
8593 protection) will cause trampolines to raise an exception.
8594 Trampolines are also quite slow at run time.
8595
8596 On many targets, trampolines have been largely eliminated. Look at the
8597 version of system.ads for your target --- if it has
8598 Always_Compatible_Rep equal to False, then trampolines are largely
8599 eliminated. In particular, a trampoline is built for the following
8600 features: @code{Address} of a nested subprogram;
8601 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8602 but only if pragma Favor_Top_Level applies, or the access type has a
8603 foreign-language convention; primitive operations of nested tagged
8604 types.
8605
8606 @item No_Implicit_Loops
8607 @findex No_Implicit_Loops
8608 This restriction ensures that the generated code does not contain any
8609 implicit @code{for} loops, either by modifying
8610 the generated code where possible,
8611 or by rejecting any construct that would otherwise generate an implicit
8612 @code{for} loop. If this restriction is active, it is possible to build
8613 large array aggregates with all static components without generating an
8614 intermediate temporary, and without generating a loop to initialize individual
8615 components. Otherwise, a loop is created for arrays larger than about 5000
8616 scalar components.
8617
8618 @item No_Initialize_Scalars
8619 @findex No_Initialize_Scalars
8620 This restriction ensures that no unit in the partition is compiled with
8621 pragma Initialize_Scalars. This allows the generation of more efficient
8622 code, and in particular eliminates dummy null initialization routines that
8623 are otherwise generated for some record and array types.
8624
8625 @item No_Local_Protected_Objects
8626 @findex No_Local_Protected_Objects
8627 This restriction ensures at compile time that protected objects are
8628 only declared at the library level.
8629
8630 @item No_Protected_Type_Allocators
8631 @findex No_Protected_Type_Allocators
8632 This restriction ensures at compile time that there are no allocator
8633 expressions that attempt to allocate protected objects.
8634
8635 @item No_Secondary_Stack
8636 @findex No_Secondary_Stack
8637 This restriction ensures at compile time that the generated code does not
8638 contain any reference to the secondary stack.  The secondary stack is used
8639 to implement functions returning unconstrained objects (arrays or records)
8640 on some targets.
8641
8642 @item No_Select_Statements
8643 @findex No_Select_Statements
8644 This restriction ensures at compile time no select statements of any kind
8645 are permitted, that is the keyword @code{select} may not appear.
8646 This is one of the restrictions of the Ravenscar
8647 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8648
8649 @item No_Standard_Storage_Pools
8650 @findex No_Standard_Storage_Pools
8651 This restriction ensures at compile time that no access types
8652 use the standard default storage pool.  Any access type declared must
8653 have an explicit Storage_Pool attribute defined specifying a
8654 user-defined storage pool.
8655
8656 @item No_Streams
8657 @findex No_Streams
8658 This restriction ensures at compile/bind time that there are no
8659 stream objects created and no use of stream attributes.
8660 This restriction does not forbid dependences on the package
8661 @code{Ada.Streams}. So it is permissible to with
8662 @code{Ada.Streams} (or another package that does so itself)
8663 as long as no actual stream objects are created and no
8664 stream attributes are used.
8665
8666 Note that the use of restriction allows optimization of tagged types,
8667 since they do not need to worry about dispatching stream operations.
8668 To take maximum advantage of this space-saving optimization, any
8669 unit declaring a tagged type should be compiled with the restriction,
8670 though this is not required.
8671
8672 @item No_Task_Attributes_Package
8673 @findex No_Task_Attributes_Package
8674 This restriction ensures at compile time that there are no implicit or
8675 explicit dependencies on the package @code{Ada.Task_Attributes}.
8676
8677 @item No_Task_Termination
8678 @findex No_Task_Termination
8679 This restriction ensures at compile time that no terminate alternatives
8680 appear in any task body.
8681
8682 @item No_Tasking
8683 @findex No_Tasking
8684 This restriction prevents the declaration of tasks or task types throughout
8685 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8686 except that violations are caught at compile time and cause an error message
8687 to be output either by the compiler or binder.
8688
8689 @item Static_Priorities
8690 @findex Static_Priorities
8691 This restriction ensures at compile time that all priority expressions
8692 are static, and that there are no dependencies on the package
8693 @code{Ada.Dynamic_Priorities}.
8694
8695 @item Static_Storage_Size
8696 @findex Static_Storage_Size
8697 This restriction ensures at compile time that any expression appearing
8698 in a Storage_Size pragma or attribute definition clause is static.
8699
8700 @end table
8701
8702 @noindent
8703 The second set of implementation dependent restriction identifiers
8704 does not require partition-wide consistency.
8705 The restriction may be enforced for a single
8706 compilation unit without any effect on any of the
8707 other compilation units in the partition.
8708
8709 @table @code
8710
8711 @item No_Elaboration_Code
8712 @findex No_Elaboration_Code
8713 This restriction ensures at compile time that no elaboration code is
8714 generated.  Note that this is not the same condition as is enforced
8715 by pragma @code{Preelaborate}.  There are cases in which pragma
8716 @code{Preelaborate} still permits code to be generated (e.g.@: code
8717 to initialize a large array to all zeroes), and there are cases of units
8718 which do not meet the requirements for pragma @code{Preelaborate},
8719 but for which no elaboration code is generated.  Generally, it is
8720 the case that preelaborable units will meet the restrictions, with
8721 the exception of large aggregates initialized with an others_clause,
8722 and exception declarations (which generate calls to a run-time
8723 registry procedure).  This restriction is enforced on
8724 a unit by unit basis, it need not be obeyed consistently
8725 throughout a partition.
8726
8727 In the case of aggregates with others, if the aggregate has a dynamic
8728 size, there is no way to eliminate the elaboration code (such dynamic
8729 bounds would be incompatible with @code{Preelaborate} in any case). If
8730 the bounds are static, then use of this restriction actually modifies
8731 the code choice of the compiler to avoid generating a loop, and instead
8732 generate the aggregate statically if possible, no matter how many times
8733 the data for the others clause must be repeatedly generated.
8734
8735 It is not possible to precisely document
8736 the constructs which are compatible with this restriction, since,
8737 unlike most other restrictions, this is not a restriction on the
8738 source code, but a restriction on the generated object code. For
8739 example, if the source contains a declaration:
8740
8741 @smallexample
8742    Val : constant Integer := X;
8743 @end smallexample
8744
8745 @noindent
8746 where X is not a static constant, it may be possible, depending
8747 on complex optimization circuitry, for the compiler to figure
8748 out the value of X at compile time, in which case this initialization
8749 can be done by the loader, and requires no initialization code. It
8750 is not possible to document the precise conditions under which the
8751 optimizer can figure this out.
8752
8753 Note that this the implementation of this restriction requires full
8754 code generation. If it is used in conjunction with "semantics only"
8755 checking, then some cases of violations may be missed.
8756
8757 @item No_Entry_Queue
8758 @findex No_Entry_Queue
8759 This restriction is a declaration that any protected entry compiled in
8760 the scope of the restriction has at most one task waiting on the entry
8761 at any one time, and so no queue is required.  This restriction is not
8762 checked at compile time.  A program execution is erroneous if an attempt
8763 is made to queue a second task on such an entry.
8764
8765 @item No_Implementation_Attributes
8766 @findex No_Implementation_Attributes
8767 This restriction checks at compile time that no GNAT-defined attributes
8768 are present.  With this restriction, the only attributes that can be used
8769 are those defined in the Ada Reference Manual.
8770
8771 @item No_Implementation_Pragmas
8772 @findex No_Implementation_Pragmas
8773 This restriction checks at compile time that no GNAT-defined pragmas
8774 are present.  With this restriction, the only pragmas that can be used
8775 are those defined in the Ada Reference Manual.
8776
8777 @item No_Implementation_Restrictions
8778 @findex No_Implementation_Restrictions
8779 This restriction checks at compile time that no GNAT-defined restriction
8780 identifiers (other than @code{No_Implementation_Restrictions} itself)
8781 are present.  With this restriction, the only other restriction identifiers
8782 that can be used are those defined in the Ada Reference Manual.
8783
8784 @item No_Wide_Characters
8785 @findex No_Wide_Characters
8786 This restriction ensures at compile time that no uses of the types
8787 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8788 wide types
8789 appear, and that no wide or wide wide string or character literals
8790 appear in the program (that is literals representing characters not in
8791 type @code{Character}.
8792
8793 @end table
8794
8795 @sp 1
8796 @cartouche
8797 @noindent
8798 @strong{58}.  The consequences of violating limitations on
8799 @code{Restrictions} pragmas.  See 13.12(9).
8800 @end cartouche
8801 @noindent
8802 Restrictions that can be checked at compile time result in illegalities
8803 if violated.  Currently there are no other consequences of violating
8804 restrictions.
8805
8806 @sp 1
8807 @cartouche
8808 @noindent
8809 @strong{59}.  The representation used by the @code{Read} and
8810 @code{Write} attributes of elementary types in terms of stream
8811 elements.  See 13.13.2(9).
8812 @end cartouche
8813 @noindent
8814 The representation is the in-memory representation of the base type of
8815 the type, using the number of bits corresponding to the
8816 @code{@var{type}'Size} value, and the natural ordering of the machine.
8817
8818 @sp 1
8819 @cartouche
8820 @noindent
8821 @strong{60}.  The names and characteristics of the numeric subtypes
8822 declared in the visible part of package @code{Standard}.  See A.1(3).
8823 @end cartouche
8824 @noindent
8825 See items describing the integer and floating-point types supported.
8826
8827 @sp 1
8828 @cartouche
8829 @noindent
8830 @strong{61}.  The accuracy actually achieved by the elementary
8831 functions.  See A.5.1(1).
8832 @end cartouche
8833 @noindent
8834 The elementary functions correspond to the functions available in the C
8835 library.  Only fast math mode is implemented.
8836
8837 @sp 1
8838 @cartouche
8839 @noindent
8840 @strong{62}.  The sign of a zero result from some of the operators or
8841 functions in @code{Numerics.Generic_Elementary_Functions}, when
8842 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8843 @end cartouche
8844 @noindent
8845 The sign of zeroes follows the requirements of the IEEE 754 standard on
8846 floating-point.
8847
8848 @sp 1
8849 @cartouche
8850 @noindent
8851 @strong{63}.  The value of
8852 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8853 @end cartouche
8854 @noindent
8855 Maximum image width is 649, see library file @file{a-numran.ads}.
8856
8857 @sp 1
8858 @cartouche
8859 @noindent
8860 @strong{64}.  The value of
8861 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8862 @end cartouche
8863 @noindent
8864 Maximum image width is 80, see library file @file{a-nudira.ads}.
8865
8866 @sp 1
8867 @cartouche
8868 @noindent
8869 @strong{65}.  The algorithms for random number generation.  See
8870 A.5.2(32).
8871 @end cartouche
8872 @noindent
8873 The algorithm is documented in the source files @file{a-numran.ads} and
8874 @file{a-numran.adb}.
8875
8876 @sp 1
8877 @cartouche
8878 @noindent
8879 @strong{66}.  The string representation of a random number generator's
8880 state.  See A.5.2(38).
8881 @end cartouche
8882 @noindent
8883 See the documentation contained in the file @file{a-numran.adb}.
8884
8885 @sp 1
8886 @cartouche
8887 @noindent
8888 @strong{67}.  The minimum time interval between calls to the
8889 time-dependent Reset procedure that are guaranteed to initiate different
8890 random number sequences.  See A.5.2(45).
8891 @end cartouche
8892 @noindent
8893 The minimum period between reset calls to guarantee distinct series of
8894 random numbers is one microsecond.
8895
8896 @sp 1
8897 @cartouche
8898 @noindent
8899 @strong{68}.  The values of the @code{Model_Mantissa},
8900 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8901 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8902 Annex is not supported.  See A.5.3(72).
8903 @end cartouche
8904 @noindent
8905 See the source file @file{ttypef.ads} for the values of all numeric
8906 attributes.
8907
8908 @sp 1
8909 @cartouche
8910 @noindent
8911 @strong{69}.  Any implementation-defined characteristics of the
8912 input-output packages.  See A.7(14).
8913 @end cartouche
8914 @noindent
8915 There are no special implementation defined characteristics for these
8916 packages.
8917
8918 @sp 1
8919 @cartouche
8920 @noindent
8921 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8922 A.9(10).
8923 @end cartouche
8924 @noindent
8925 All type representations are contiguous, and the @code{Buffer_Size} is
8926 the value of @code{@var{type}'Size} rounded up to the next storage unit
8927 boundary.
8928
8929 @sp 1
8930 @cartouche
8931 @noindent
8932 @strong{71}.  External files for standard input, standard output, and
8933 standard error See A.10(5).
8934 @end cartouche
8935 @noindent
8936 These files are mapped onto the files provided by the C streams
8937 libraries.  See source file @file{i-cstrea.ads} for further details.
8938
8939 @sp 1
8940 @cartouche
8941 @noindent
8942 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8943 A.10.9(36).
8944 @end cartouche
8945 @noindent
8946 If more digits are requested in the output than are represented by the
8947 precision of the value, zeroes are output in the corresponding least
8948 significant digit positions.
8949
8950 @sp 1
8951 @cartouche
8952 @noindent
8953 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8954 @code{Command_Name}.  See A.15(1).
8955 @end cartouche
8956 @noindent
8957 These are mapped onto the @code{argv} and @code{argc} parameters of the
8958 main program in the natural manner.
8959
8960 @sp 1
8961 @cartouche
8962 @noindent
8963 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8964 @end cartouche
8965 @noindent
8966 The following convention names are supported
8967
8968 @table @code
8969 @item  Ada
8970 Ada
8971 @item Assembler
8972 Assembly language
8973 @item Asm
8974 Synonym for Assembler
8975 @item Assembly
8976 Synonym for Assembler
8977 @item C
8978 C
8979 @item C_Pass_By_Copy
8980 Allowed only for record types, like C, but also notes that record
8981 is to be passed by copy rather than reference.
8982 @item COBOL
8983 COBOL
8984 @item C_Plus_Plus (or CPP)
8985 C++
8986 @item Default
8987 Treated the same as C
8988 @item External
8989 Treated the same as C
8990 @item Fortran
8991 Fortran
8992 @item Intrinsic
8993 For support of pragma @code{Import} with convention Intrinsic, see
8994 separate section on Intrinsic Subprograms.
8995 @item Stdcall
8996 Stdcall (used for Windows implementations only).  This convention correspond
8997 to the WINAPI (previously called Pascal convention) C/C++ convention under
8998 Windows.  A function with this convention cleans the stack before exit.
8999 @item DLL
9000 Synonym for Stdcall
9001 @item Win32
9002 Synonym for Stdcall
9003 @item Stubbed
9004 Stubbed is a special convention used to indicate that the body of the
9005 subprogram will be entirely ignored.  Any call to the subprogram
9006 is converted into a raise of the @code{Program_Error} exception.  If a
9007 pragma @code{Import} specifies convention @code{stubbed} then no body need
9008 be present at all.  This convention is useful during development for the
9009 inclusion of subprograms whose body has not yet been written.
9010
9011 @end table
9012 @noindent
9013 In addition, all otherwise unrecognized convention names are also
9014 treated as being synonymous with convention C@.  In all implementations
9015 except for VMS, use of such other names results in a warning.  In VMS
9016 implementations, these names are accepted silently.
9017
9018 @sp 1
9019 @cartouche
9020 @noindent
9021 @strong{75}.  The meaning of link names.  See B.1(36).
9022 @end cartouche
9023 @noindent
9024 Link names are the actual names used by the linker.
9025
9026 @sp 1
9027 @cartouche
9028 @noindent
9029 @strong{76}.  The manner of choosing link names when neither the link
9030 name nor the address of an imported or exported entity is specified.  See
9031 B.1(36).
9032 @end cartouche
9033 @noindent
9034 The default linker name is that which would be assigned by the relevant
9035 external language, interpreting the Ada name as being in all lower case
9036 letters.
9037
9038 @sp 1
9039 @cartouche
9040 @noindent
9041 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9042 @end cartouche
9043 @noindent
9044 The string passed to @code{Linker_Options} is presented uninterpreted as
9045 an argument to the link command, unless it contains ASCII.NUL characters.
9046 NUL characters if they appear act as argument separators, so for example
9047
9048 @smallexample @c ada
9049 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9050 @end smallexample
9051
9052 @noindent
9053 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9054 linker. The order of linker options is preserved for a given unit. The final
9055 list of options passed to the linker is in reverse order of the elaboration
9056 order. For example, linker options for a body always appear before the options
9057 from the corresponding package spec.
9058
9059 @sp 1
9060 @cartouche
9061 @noindent
9062 @strong{78}.  The contents of the visible part of package
9063 @code{Interfaces} and its language-defined descendants.  See B.2(1).
9064 @end cartouche
9065 @noindent
9066 See files with prefix @file{i-} in the distributed library.
9067
9068 @sp 1
9069 @cartouche
9070 @noindent
9071 @strong{79}.  Implementation-defined children of package
9072 @code{Interfaces}.  The contents of the visible part of package
9073 @code{Interfaces}.  See B.2(11).
9074 @end cartouche
9075 @noindent
9076 See files with prefix @file{i-} in the distributed library.
9077
9078 @sp 1
9079 @cartouche
9080 @noindent
9081 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
9082 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9083 @code{COBOL_Character}; and the initialization of the variables
9084 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9085 @code{Interfaces.COBOL}.  See B.4(50).
9086 @end cartouche
9087 @noindent
9088 @table @code
9089 @item Floating
9090 Float
9091 @item Long_Floating
9092 (Floating) Long_Float
9093 @item Binary
9094 Integer
9095 @item Long_Binary
9096 Long_Long_Integer
9097 @item Decimal_Element
9098 Character
9099 @item COBOL_Character
9100 Character
9101 @end table
9102
9103 @noindent
9104 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9105
9106 @sp 1
9107 @cartouche
9108 @noindent
9109 @strong{81}.  Support for access to machine instructions.  See C.1(1).
9110 @end cartouche
9111 @noindent
9112 See documentation in file @file{s-maccod.ads} in the distributed library.
9113
9114 @sp 1
9115 @cartouche
9116 @noindent
9117 @strong{82}.  Implementation-defined aspects of access to machine
9118 operations.  See C.1(9).
9119 @end cartouche
9120 @noindent
9121 See documentation in file @file{s-maccod.ads} in the distributed library.
9122
9123 @sp 1
9124 @cartouche
9125 @noindent
9126 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
9127 @end cartouche
9128 @noindent
9129 Interrupts are mapped to signals or conditions as appropriate.  See
9130 definition of unit
9131 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9132 on the interrupts supported on a particular target.
9133
9134 @sp 1
9135 @cartouche
9136 @noindent
9137 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
9138 C.4(13).
9139 @end cartouche
9140 @noindent
9141 GNAT does not permit a partition to be restarted without reloading,
9142 except under control of the debugger.
9143
9144 @sp 1
9145 @cartouche
9146 @noindent
9147 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9148 @end cartouche
9149 @noindent
9150 Pragma @code{Discard_Names} causes names of enumeration literals to
9151 be suppressed.  In the presence of this pragma, the Image attribute
9152 provides the image of the Pos of the literal, and Value accepts
9153 Pos values.
9154
9155 @sp 1
9156 @cartouche
9157 @noindent
9158 @strong{86}.  The result of the @code{Task_Identification.Image}
9159 attribute.  See C.7.1(7).
9160 @end cartouche
9161 @noindent
9162 The result of this attribute is a string that identifies
9163 the object or component that denotes a given task. If a variable @code{Var}
9164 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9165 where the suffix
9166 is the hexadecimal representation of the virtual address of the corresponding
9167 task control block. If the variable is an array of tasks, the image of each
9168 task will have the form of an indexed component indicating the position of a
9169 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9170 component of a record, the image of the task will have the form of a selected
9171 component. These rules are fully recursive, so that the image of a task that
9172 is a subcomponent of a composite object corresponds to the expression that
9173 designates this task.
9174 @noindent
9175 If a task is created by an allocator, its image depends on the context. If the
9176 allocator is part of an object declaration, the rules described above are used
9177 to construct its image, and this image is not affected by subsequent
9178 assignments. If the allocator appears within an expression, the image
9179 includes only the name of the task type.
9180 @noindent
9181 If the configuration pragma Discard_Names is present, or if the restriction
9182 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9183 the numeric suffix, that is to say the hexadecimal representation of the
9184 virtual address of the control block of the task.
9185 @sp 1
9186 @cartouche
9187 @noindent
9188 @strong{87}.  The value of @code{Current_Task} when in a protected entry
9189 or interrupt handler.  See C.7.1(17).
9190 @end cartouche
9191 @noindent
9192 Protected entries or interrupt handlers can be executed by any
9193 convenient thread, so the value of @code{Current_Task} is undefined.
9194
9195 @sp 1
9196 @cartouche
9197 @noindent
9198 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9199 body or interrupt handler.  See C.7.1(19).
9200 @end cartouche
9201 @noindent
9202 The effect of calling @code{Current_Task} from an entry body or
9203 interrupt handler is to return the identification of the task currently
9204 executing the code.
9205
9206 @sp 1
9207 @cartouche
9208 @noindent
9209 @strong{89}.  Implementation-defined aspects of
9210 @code{Task_Attributes}.  See C.7.2(19).
9211 @end cartouche
9212 @noindent
9213 There are no implementation-defined aspects of @code{Task_Attributes}.
9214
9215 @sp 1
9216 @cartouche
9217 @noindent
9218 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9219 @end cartouche
9220 @noindent
9221 The metrics information for GNAT depends on the performance of the
9222 underlying operating system.  The sources of the run-time for tasking
9223 implementation, together with the output from @option{-gnatG} can be
9224 used to determine the exact sequence of operating systems calls made
9225 to implement various tasking constructs.  Together with appropriate
9226 information on the performance of the underlying operating system,
9227 on the exact target in use, this information can be used to determine
9228 the required metrics.
9229
9230 @sp 1
9231 @cartouche
9232 @noindent
9233 @strong{91}.  The declarations of @code{Any_Priority} and
9234 @code{Priority}.  See D.1(11).
9235 @end cartouche
9236 @noindent
9237 See declarations in file @file{system.ads}.
9238
9239 @sp 1
9240 @cartouche
9241 @noindent
9242 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9243 @end cartouche
9244 @noindent
9245 There are no implementation-defined execution resources.
9246
9247 @sp 1
9248 @cartouche
9249 @noindent
9250 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9251 access to a protected object keeps its processor busy.  See D.2.1(3).
9252 @end cartouche
9253 @noindent
9254 On a multi-processor, a task that is waiting for access to a protected
9255 object does not keep its processor busy.
9256
9257 @sp 1
9258 @cartouche
9259 @noindent
9260 @strong{94}.  The affect of implementation defined execution resources
9261 on task dispatching.  See D.2.1(9).
9262 @end cartouche
9263 @noindent
9264 @c SGI info
9265 @ignore
9266 Tasks map to IRIX threads, and the dispatching policy is as defined by
9267 the IRIX implementation of threads.
9268 @end ignore
9269 Tasks map to threads in the threads package used by GNAT@.  Where possible
9270 and appropriate, these threads correspond to native threads of the
9271 underlying operating system.
9272
9273 @sp 1
9274 @cartouche
9275 @noindent
9276 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9277 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9278 @end cartouche
9279 @noindent
9280 There are no implementation-defined policy-identifiers allowed in this
9281 pragma.
9282
9283 @sp 1
9284 @cartouche
9285 @noindent
9286 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9287 D.2.2(16).
9288 @end cartouche
9289 @noindent
9290 Execution of a task cannot be preempted by the implementation processing
9291 of delay expirations for lower priority tasks.
9292
9293 @sp 1
9294 @cartouche
9295 @noindent
9296 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9297 @end cartouche
9298 @noindent
9299 @c SGI info:
9300 @ignore
9301 Tasks map to IRIX threads, and the dispatching policy is as defined by
9302 the IRIX implementation of threads.
9303 @end ignore
9304 The policy is the same as that of the underlying threads implementation.
9305
9306 @sp 1
9307 @cartouche
9308 @noindent
9309 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9310 in a pragma @code{Locking_Policy}.  See D.3(4).
9311 @end cartouche
9312 @noindent
9313 The only implementation defined policy permitted in GNAT is
9314 @code{Inheritance_Locking}.  On targets that support this policy, locking
9315 is implemented by inheritance, i.e.@: the task owning the lock operates
9316 at a priority equal to the highest priority of any task currently
9317 requesting the lock.
9318
9319 @sp 1
9320 @cartouche
9321 @noindent
9322 @strong{99}.  Default ceiling priorities.  See D.3(10).
9323 @end cartouche
9324 @noindent
9325 The ceiling priority of protected objects of the type
9326 @code{System.Interrupt_Priority'Last} as described in the Ada
9327 Reference Manual D.3(10),
9328
9329 @sp 1
9330 @cartouche
9331 @noindent
9332 @strong{100}.  The ceiling of any protected object used internally by
9333 the implementation.  See D.3(16).
9334 @end cartouche
9335 @noindent
9336 The ceiling priority of internal protected objects is
9337 @code{System.Priority'Last}.
9338
9339 @sp 1
9340 @cartouche
9341 @noindent
9342 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9343 @end cartouche
9344 @noindent
9345 There are no implementation-defined queuing policies.
9346
9347 @sp 1
9348 @cartouche
9349 @noindent
9350 @strong{102}.  On a multiprocessor, any conditions that cause the
9351 completion of an aborted construct to be delayed later than what is
9352 specified for a single processor.  See D.6(3).
9353 @end cartouche
9354 @noindent
9355 The semantics for abort on a multi-processor is the same as on a single
9356 processor, there are no further delays.
9357
9358 @sp 1
9359 @cartouche
9360 @noindent
9361 @strong{103}.  Any operations that implicitly require heap storage
9362 allocation.  See D.7(8).
9363 @end cartouche
9364 @noindent
9365 The only operation that implicitly requires heap storage allocation is
9366 task creation.
9367
9368 @sp 1
9369 @cartouche
9370 @noindent
9371 @strong{104}.  Implementation-defined aspects of pragma
9372 @code{Restrictions}.  See D.7(20).
9373 @end cartouche
9374 @noindent
9375 There are no such implementation-defined aspects.
9376
9377 @sp 1
9378 @cartouche
9379 @noindent
9380 @strong{105}.  Implementation-defined aspects of package
9381 @code{Real_Time}.  See D.8(17).
9382 @end cartouche
9383 @noindent
9384 There are no implementation defined aspects of package @code{Real_Time}.
9385
9386 @sp 1
9387 @cartouche
9388 @noindent
9389 @strong{106}.  Implementation-defined aspects of
9390 @code{delay_statements}.  See D.9(8).
9391 @end cartouche
9392 @noindent
9393 Any difference greater than one microsecond will cause the task to be
9394 delayed (see D.9(7)).
9395
9396 @sp 1
9397 @cartouche
9398 @noindent
9399 @strong{107}.  The upper bound on the duration of interrupt blocking
9400 caused by the implementation.  See D.12(5).
9401 @end cartouche
9402 @noindent
9403 The upper bound is determined by the underlying operating system.  In
9404 no cases is it more than 10 milliseconds.
9405
9406 @sp 1
9407 @cartouche
9408 @noindent
9409 @strong{108}.  The means for creating and executing distributed
9410 programs.  See E(5).
9411 @end cartouche
9412 @noindent
9413 The GLADE package provides a utility GNATDIST for creating and executing
9414 distributed programs.  See the GLADE reference manual for further details.
9415
9416 @sp 1
9417 @cartouche
9418 @noindent
9419 @strong{109}.  Any events that can result in a partition becoming
9420 inaccessible.  See E.1(7).
9421 @end cartouche
9422 @noindent
9423 See the GLADE reference manual for full details on such events.
9424
9425 @sp 1
9426 @cartouche
9427 @noindent
9428 @strong{110}.  The scheduling policies, treatment of priorities, and
9429 management of shared resources between partitions in certain cases.  See
9430 E.1(11).
9431 @end cartouche
9432 @noindent
9433 See the GLADE reference manual for full details on these aspects of
9434 multi-partition execution.
9435
9436 @sp 1
9437 @cartouche
9438 @noindent
9439 @strong{111}.  Events that cause the version of a compilation unit to
9440 change.  See E.3(5).
9441 @end cartouche
9442 @noindent
9443 Editing the source file of a compilation unit, or the source files of
9444 any units on which it is dependent in a significant way cause the version
9445 to change.  No other actions cause the version number to change.  All changes
9446 are significant except those which affect only layout, capitalization or
9447 comments.
9448
9449 @sp 1
9450 @cartouche
9451 @noindent
9452 @strong{112}.  Whether the execution of the remote subprogram is
9453 immediately aborted as a result of cancellation.  See E.4(13).
9454 @end cartouche
9455 @noindent
9456 See the GLADE reference manual for details on the effect of abort in
9457 a distributed application.
9458
9459 @sp 1
9460 @cartouche
9461 @noindent
9462 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9463 @end cartouche
9464 @noindent
9465 See the GLADE reference manual for a full description of all implementation
9466 defined aspects of the PCS@.
9467
9468 @sp 1
9469 @cartouche
9470 @noindent
9471 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9472 E.5(26).
9473 @end cartouche
9474 @noindent
9475 See the GLADE reference manual for a full description of all
9476 implementation defined interfaces.
9477
9478 @sp 1
9479 @cartouche
9480 @noindent
9481 @strong{115}.  The values of named numbers in the package
9482 @code{Decimal}.  See F.2(7).
9483 @end cartouche
9484 @noindent
9485 @table @code
9486 @item Max_Scale
9487 +18
9488 @item Min_Scale
9489 -18
9490 @item Min_Delta
9491 1.0E-18
9492 @item Max_Delta
9493 1.0E+18
9494 @item Max_Decimal_Digits
9495 18
9496 @end table
9497
9498 @sp 1
9499 @cartouche
9500 @noindent
9501 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9502 @code{Text_IO.Editing}.  See F.3.3(16).
9503 @end cartouche
9504 @noindent
9505 64
9506
9507 @sp 1
9508 @cartouche
9509 @noindent
9510 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9511 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9512 @end cartouche
9513 @noindent
9514 64
9515
9516 @sp 1
9517 @cartouche
9518 @noindent
9519 @strong{118}.  The accuracy actually achieved by the complex elementary
9520 functions and by other complex arithmetic operations.  See G.1(1).
9521 @end cartouche
9522 @noindent
9523 Standard library functions are used for the complex arithmetic
9524 operations.  Only fast math mode is currently supported.
9525
9526 @sp 1
9527 @cartouche
9528 @noindent
9529 @strong{119}.  The sign of a zero result (or a component thereof) from
9530 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9531 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9532 @end cartouche
9533 @noindent
9534 The signs of zero values are as recommended by the relevant
9535 implementation advice.
9536
9537 @sp 1
9538 @cartouche
9539 @noindent
9540 @strong{120}.  The sign of a zero result (or a component thereof) from
9541 any operator or function in
9542 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9543 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9544 @end cartouche
9545 @noindent
9546 The signs of zero values are as recommended by the relevant
9547 implementation advice.
9548
9549 @sp 1
9550 @cartouche
9551 @noindent
9552 @strong{121}.  Whether the strict mode or the relaxed mode is the
9553 default.  See G.2(2).
9554 @end cartouche
9555 @noindent
9556 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9557 provides a highly efficient implementation of strict mode.
9558
9559 @sp 1
9560 @cartouche
9561 @noindent
9562 @strong{122}.  The result interval in certain cases of fixed-to-float
9563 conversion.  See G.2.1(10).
9564 @end cartouche
9565 @noindent
9566 For cases where the result interval is implementation dependent, the
9567 accuracy is that provided by performing all operations in 64-bit IEEE
9568 floating-point format.
9569
9570 @sp 1
9571 @cartouche
9572 @noindent
9573 @strong{123}.  The result of a floating point arithmetic operation in
9574 overflow situations, when the @code{Machine_Overflows} attribute of the
9575 result type is @code{False}.  See G.2.1(13).
9576 @end cartouche
9577 @noindent
9578 Infinite and NaN values are produced as dictated by the IEEE
9579 floating-point standard.
9580
9581 Note that on machines that are not fully compliant with the IEEE
9582 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9583 must be used for achieving IEEE confirming behavior (although at the cost
9584 of a significant performance penalty), so infinite and NaN values are
9585 properly generated.
9586
9587 @sp 1
9588 @cartouche
9589 @noindent
9590 @strong{124}.  The result interval for division (or exponentiation by a
9591 negative exponent), when the floating point hardware implements division
9592 as multiplication by a reciprocal.  See G.2.1(16).
9593 @end cartouche
9594 @noindent
9595 Not relevant, division is IEEE exact.
9596
9597 @sp 1
9598 @cartouche
9599 @noindent
9600 @strong{125}.  The definition of close result set, which determines the
9601 accuracy of certain fixed point multiplications and divisions.  See
9602 G.2.3(5).
9603 @end cartouche
9604 @noindent
9605 Operations in the close result set are performed using IEEE long format
9606 floating-point arithmetic.  The input operands are converted to
9607 floating-point, the operation is done in floating-point, and the result
9608 is converted to the target type.
9609
9610 @sp 1
9611 @cartouche
9612 @noindent
9613 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9614 point multiplication or division for which the result shall be in the
9615 perfect result set.  See G.2.3(22).
9616 @end cartouche
9617 @noindent
9618 The result is only defined to be in the perfect result set if the result
9619 can be computed by a single scaling operation involving a scale factor
9620 representable in 64-bits.
9621
9622 @sp 1
9623 @cartouche
9624 @noindent
9625 @strong{127}.  The result of a fixed point arithmetic operation in
9626 overflow situations, when the @code{Machine_Overflows} attribute of the
9627 result type is @code{False}.  See G.2.3(27).
9628 @end cartouche
9629 @noindent
9630 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9631 types.
9632
9633 @sp 1
9634 @cartouche
9635 @noindent
9636 @strong{128}.  The result of an elementary function reference in
9637 overflow situations, when the @code{Machine_Overflows} attribute of the
9638 result type is @code{False}.  See G.2.4(4).
9639 @end cartouche
9640 @noindent
9641 IEEE infinite and Nan values are produced as appropriate.
9642
9643 @sp 1
9644 @cartouche
9645 @noindent
9646 @strong{129}.  The value of the angle threshold, within which certain
9647 elementary functions, complex arithmetic operations, and complex
9648 elementary functions yield results conforming to a maximum relative
9649 error bound.  See G.2.4(10).
9650 @end cartouche
9651 @noindent
9652 Information on this subject is not yet available.
9653
9654 @sp 1
9655 @cartouche
9656 @noindent
9657 @strong{130}.  The accuracy of certain elementary functions for
9658 parameters beyond the angle threshold.  See G.2.4(10).
9659 @end cartouche
9660 @noindent
9661 Information on this subject is not yet available.
9662
9663 @sp 1
9664 @cartouche
9665 @noindent
9666 @strong{131}.  The result of a complex arithmetic operation or complex
9667 elementary function reference in overflow situations, when the
9668 @code{Machine_Overflows} attribute of the corresponding real type is
9669 @code{False}.  See G.2.6(5).
9670 @end cartouche
9671 @noindent
9672 IEEE infinite and Nan values are produced as appropriate.
9673
9674 @sp 1
9675 @cartouche
9676 @noindent
9677 @strong{132}.  The accuracy of certain complex arithmetic operations and
9678 certain complex elementary functions for parameters (or components
9679 thereof) beyond the angle threshold.  See G.2.6(8).
9680 @end cartouche
9681 @noindent
9682 Information on those subjects is not yet available.
9683
9684 @sp 1
9685 @cartouche
9686 @noindent
9687 @strong{133}.  Information regarding bounded errors and erroneous
9688 execution.  See H.2(1).
9689 @end cartouche
9690 @noindent
9691 Information on this subject is not yet available.
9692
9693 @sp 1
9694 @cartouche
9695 @noindent
9696 @strong{134}.  Implementation-defined aspects of pragma
9697 @code{Inspection_Point}.  See H.3.2(8).
9698 @end cartouche
9699 @noindent
9700 Pragma @code{Inspection_Point} ensures that the variable is live and can
9701 be examined by the debugger at the inspection point.
9702
9703 @sp 1
9704 @cartouche
9705 @noindent
9706 @strong{135}.  Implementation-defined aspects of pragma
9707 @code{Restrictions}.  See H.4(25).
9708 @end cartouche
9709 @noindent
9710 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9711 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9712 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9713
9714 @sp 1
9715 @cartouche
9716 @noindent
9717 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9718 H.4(27).
9719 @end cartouche
9720 @noindent
9721 There are no restrictions on pragma @code{Restrictions}.
9722
9723 @node Intrinsic Subprograms
9724 @chapter Intrinsic Subprograms
9725 @cindex Intrinsic Subprograms
9726
9727 @menu
9728 * Intrinsic Operators::
9729 * Enclosing_Entity::
9730 * Exception_Information::
9731 * Exception_Message::
9732 * Exception_Name::
9733 * File::
9734 * Line::
9735 * Rotate_Left::
9736 * Rotate_Right::
9737 * Shift_Left::
9738 * Shift_Right::
9739 * Shift_Right_Arithmetic::
9740 * Source_Location::
9741 @end menu
9742
9743 @noindent
9744 GNAT allows a user application program to write the declaration:
9745
9746 @smallexample @c ada
9747    pragma Import (Intrinsic, name);
9748 @end smallexample
9749
9750 @noindent
9751 providing that the name corresponds to one of the implemented intrinsic
9752 subprograms in GNAT, and that the parameter profile of the referenced
9753 subprogram meets the requirements.  This chapter describes the set of
9754 implemented intrinsic subprograms, and the requirements on parameter profiles.
9755 Note that no body is supplied; as with other uses of pragma Import, the
9756 body is supplied elsewhere (in this case by the compiler itself).  Note
9757 that any use of this feature is potentially non-portable, since the
9758 Ada standard does not require Ada compilers to implement this feature.
9759
9760 @node Intrinsic Operators
9761 @section Intrinsic Operators
9762 @cindex Intrinsic operator
9763
9764 @noindent
9765 All the predefined numeric operators in package Standard
9766 in @code{pragma Import (Intrinsic,..)}
9767 declarations.  In the binary operator case, the operands must have the same
9768 size.  The operand or operands must also be appropriate for
9769 the operator.  For example, for addition, the operands must
9770 both be floating-point or both be fixed-point, and the
9771 right operand for @code{"**"} must have a root type of
9772 @code{Standard.Integer'Base}.
9773 You can use an intrinsic operator declaration as in the following example:
9774
9775 @smallexample @c ada
9776    type Int1 is new Integer;
9777    type Int2 is new Integer;
9778
9779    function "+" (X1 : Int1; X2 : Int2) return Int1;
9780    function "+" (X1 : Int1; X2 : Int2) return Int2;
9781    pragma Import (Intrinsic, "+");
9782 @end smallexample
9783
9784 @noindent
9785 This declaration would permit ``mixed mode'' arithmetic on items
9786 of the differing types @code{Int1} and @code{Int2}.
9787 It is also possible to specify such operators for private types, if the
9788 full views are appropriate arithmetic types.
9789
9790 @node Enclosing_Entity
9791 @section Enclosing_Entity
9792 @cindex Enclosing_Entity
9793 @noindent
9794 This intrinsic subprogram is used in the implementation of the
9795 library routine @code{GNAT.Source_Info}.  The only useful use of the
9796 intrinsic import in this case is the one in this unit, so an
9797 application program should simply call the function
9798 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9799 the current subprogram, package, task, entry, or protected subprogram.
9800
9801 @node Exception_Information
9802 @section Exception_Information
9803 @cindex Exception_Information'
9804 @noindent
9805 This intrinsic subprogram is used in the implementation of the
9806 library routine @code{GNAT.Current_Exception}.  The only useful
9807 use of the intrinsic import in this case is the one in this unit,
9808 so an application program should simply call the function
9809 @code{GNAT.Current_Exception.Exception_Information} to obtain
9810 the exception information associated with the current exception.
9811
9812 @node Exception_Message
9813 @section Exception_Message
9814 @cindex Exception_Message
9815 @noindent
9816 This intrinsic subprogram is used in the implementation of the
9817 library routine @code{GNAT.Current_Exception}.  The only useful
9818 use of the intrinsic import in this case is the one in this unit,
9819 so an application program should simply call the function
9820 @code{GNAT.Current_Exception.Exception_Message} to obtain
9821 the message associated with the current exception.
9822
9823 @node Exception_Name
9824 @section Exception_Name
9825 @cindex Exception_Name
9826 @noindent
9827 This intrinsic subprogram is used in the implementation of the
9828 library routine @code{GNAT.Current_Exception}.  The only useful
9829 use of the intrinsic import in this case is the one in this unit,
9830 so an application program should simply call the function
9831 @code{GNAT.Current_Exception.Exception_Name} to obtain
9832 the name of the current exception.
9833
9834 @node File
9835 @section File
9836 @cindex File
9837 @noindent
9838 This intrinsic subprogram is used in the implementation of the
9839 library routine @code{GNAT.Source_Info}.  The only useful use of the
9840 intrinsic import in this case is the one in this unit, so an
9841 application program should simply call the function
9842 @code{GNAT.Source_Info.File} to obtain the name of the current
9843 file.
9844
9845 @node Line
9846 @section Line
9847 @cindex Line
9848 @noindent
9849 This intrinsic subprogram is used in the implementation of the
9850 library routine @code{GNAT.Source_Info}.  The only useful use of the
9851 intrinsic import in this case is the one in this unit, so an
9852 application program should simply call the function
9853 @code{GNAT.Source_Info.Line} to obtain the number of the current
9854 source line.
9855
9856 @node Rotate_Left
9857 @section Rotate_Left
9858 @cindex Rotate_Left
9859 @noindent
9860 In standard Ada, the @code{Rotate_Left} function is available only
9861 for the predefined modular types in package @code{Interfaces}.  However, in
9862 GNAT it is possible to define a Rotate_Left function for a user
9863 defined modular type or any signed integer type as in this example:
9864
9865 @smallexample @c ada
9866    function Shift_Left
9867      (Value  : My_Modular_Type;
9868       Amount : Natural)
9869       return   My_Modular_Type;
9870 @end smallexample
9871
9872 @noindent
9873 The requirements are that the profile be exactly as in the example
9874 above.  The only modifications allowed are in the formal parameter
9875 names, and in the type of @code{Value} and the return type, which
9876 must be the same, and must be either a signed integer type, or
9877 a modular integer type with a binary modulus, and the size must
9878 be 8.  16, 32 or 64 bits.
9879
9880 @node Rotate_Right
9881 @section Rotate_Right
9882 @cindex Rotate_Right
9883 @noindent
9884 A @code{Rotate_Right} function can be defined for any user defined
9885 binary modular integer type, or signed integer type, as described
9886 above for @code{Rotate_Left}.
9887
9888 @node Shift_Left
9889 @section Shift_Left
9890 @cindex Shift_Left
9891 @noindent
9892 A @code{Shift_Left} function can be defined for any user defined
9893 binary modular integer type, or signed integer type, as described
9894 above for @code{Rotate_Left}.
9895
9896 @node Shift_Right
9897 @section Shift_Right
9898 @cindex Shift_Right
9899 @noindent
9900 A @code{Shift_Right} function can be defined for any user defined
9901 binary modular integer type, or signed integer type, as described
9902 above for @code{Rotate_Left}.
9903
9904 @node Shift_Right_Arithmetic
9905 @section Shift_Right_Arithmetic
9906 @cindex Shift_Right_Arithmetic
9907 @noindent
9908 A @code{Shift_Right_Arithmetic} function can be defined for any user
9909 defined binary modular integer type, or signed integer type, as described
9910 above for @code{Rotate_Left}.
9911
9912 @node Source_Location
9913 @section Source_Location
9914 @cindex Source_Location
9915 @noindent
9916 This intrinsic subprogram is used in the implementation of the
9917 library routine @code{GNAT.Source_Info}.  The only useful use of the
9918 intrinsic import in this case is the one in this unit, so an
9919 application program should simply call the function
9920 @code{GNAT.Source_Info.Source_Location} to obtain the current
9921 source file location.
9922
9923 @node Representation Clauses and Pragmas
9924 @chapter Representation Clauses and Pragmas
9925 @cindex Representation Clauses
9926
9927 @menu
9928 * Alignment Clauses::
9929 * Size Clauses::
9930 * Storage_Size Clauses::
9931 * Size of Variant Record Objects::
9932 * Biased Representation ::
9933 * Value_Size and Object_Size Clauses::
9934 * Component_Size Clauses::
9935 * Bit_Order Clauses::
9936 * Effect of Bit_Order on Byte Ordering::
9937 * Pragma Pack for Arrays::
9938 * Pragma Pack for Records::
9939 * Record Representation Clauses::
9940 * Enumeration Clauses::
9941 * Address Clauses::
9942 * Effect of Convention on Representation::
9943 * Determining the Representations chosen by GNAT::
9944 @end menu
9945
9946 @noindent
9947 @cindex Representation Clause
9948 @cindex Representation Pragma
9949 @cindex Pragma, representation
9950 This section describes the representation clauses accepted by GNAT, and
9951 their effect on the representation of corresponding data objects.
9952
9953 GNAT fully implements Annex C (Systems Programming).  This means that all
9954 the implementation advice sections in chapter 13 are fully implemented.
9955 However, these sections only require a minimal level of support for
9956 representation clauses.  GNAT provides much more extensive capabilities,
9957 and this section describes the additional capabilities provided.
9958
9959 @node Alignment Clauses
9960 @section Alignment Clauses
9961 @cindex Alignment Clause
9962
9963 @noindent
9964 GNAT requires that all alignment clauses specify a power of 2, and all
9965 default alignments are always a power of 2.  The default alignment
9966 values are as follows:
9967
9968 @itemize @bullet
9969 @item @emph{Primitive Types}.
9970 For primitive types, the alignment is the minimum of the actual size of
9971 objects of the type divided by @code{Storage_Unit},
9972 and the maximum alignment supported by the target.
9973 (This maximum alignment is given by the GNAT-specific attribute
9974 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9975 @cindex @code{Maximum_Alignment} attribute
9976 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9977 default alignment will be 8 on any target that supports alignments
9978 this large, but on some targets, the maximum alignment may be smaller
9979 than 8, in which case objects of type @code{Long_Float} will be maximally
9980 aligned.
9981
9982 @item @emph{Arrays}.
9983 For arrays, the alignment is equal to the alignment of the component type
9984 for the normal case where no packing or component size is given.  If the
9985 array is packed, and the packing is effective (see separate section on
9986 packed arrays), then the alignment will be one for long packed arrays,
9987 or arrays whose length is not known at compile time.  For short packed
9988 arrays, which are handled internally as modular types, the alignment
9989 will be as described for primitive types, e.g.@: a packed array of length
9990 31 bits will have an object size of four bytes, and an alignment of 4.
9991
9992 @item @emph{Records}.
9993 For the normal non-packed case, the alignment of a record is equal to
9994 the maximum alignment of any of its components.  For tagged records, this
9995 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9996 is used and all components are packable (see separate section on pragma
9997 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9998 record makes it profitable to increase it.
9999
10000 A special case is when:
10001 @itemize @bullet
10002 @item
10003 the size of the record is given explicitly, or a
10004 full record representation clause is given, and
10005 @item
10006 the size of the record is 2, 4, or 8 bytes.
10007 @end itemize
10008 @noindent
10009 In this case, an alignment is chosen to match the
10010 size of the record. For example, if we have:
10011
10012 @smallexample @c ada
10013    type Small is record
10014       A, B : Character;
10015    end record;
10016    for Small'Size use 16;
10017 @end smallexample
10018
10019 @noindent
10020 then the default alignment of the record type @code{Small} is 2, not 1. This
10021 leads to more efficient code when the record is treated as a unit, and also
10022 allows the type to specified as @code{Atomic} on architectures requiring
10023 strict alignment.
10024
10025 @end itemize
10026
10027 @noindent
10028 An alignment clause may specify a larger alignment than the default value
10029 up to some maximum value dependent on the target (obtainable by using the
10030 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10031 a smaller alignment than the default value for enumeration, integer and
10032 fixed point types, as well as for record types, for example
10033
10034 @smallexample @c ada
10035   type V is record
10036      A : Integer;
10037   end record;
10038
10039   for V'alignment use 1;
10040 @end smallexample
10041
10042 @noindent
10043 @cindex Alignment, default
10044 The default alignment for the type @code{V} is 4, as a result of the
10045 Integer field in the record, but it is permissible, as shown, to
10046 override the default alignment of the record with a smaller value.
10047
10048 @node Size Clauses
10049 @section Size Clauses
10050 @cindex Size Clause
10051
10052 @noindent
10053 The default size for a type @code{T} is obtainable through the
10054 language-defined attribute @code{T'Size} and also through the
10055 equivalent GNAT-defined attribute @code{T'Value_Size}.
10056 For objects of type @code{T}, GNAT will generally increase the type size
10057 so that the object size (obtainable through the GNAT-defined attribute
10058 @code{T'Object_Size})
10059 is a multiple of @code{T'Alignment * Storage_Unit}.
10060 For example
10061
10062 @smallexample @c ada
10063    type Smallint is range 1 .. 6;
10064
10065    type Rec is record
10066       Y1 : integer;
10067       Y2 : boolean;
10068    end record;
10069 @end smallexample
10070
10071 @noindent
10072 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10073 as specified by the RM rules,
10074 but objects of this type will have a size of 8
10075 (@code{Smallint'Object_Size} = 8),
10076 since objects by default occupy an integral number
10077 of storage units.  On some targets, notably older
10078 versions of the Digital Alpha, the size of stand
10079 alone objects of this type may be 32, reflecting
10080 the inability of the hardware to do byte load/stores.
10081
10082 Similarly, the size of type @code{Rec} is 40 bits
10083 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10084 the alignment is 4, so objects of this type will have
10085 their size increased to 64 bits so that it is a multiple
10086 of the alignment (in bits).  This decision is
10087 in accordance with the specific Implementation Advice in RM 13.3(43):
10088
10089 @quotation
10090 A @code{Size} clause should be supported for an object if the specified
10091 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10092 to a size in storage elements that is a multiple of the object's
10093 @code{Alignment} (if the @code{Alignment} is nonzero).
10094 @end quotation
10095
10096 @noindent
10097 An explicit size clause may be used to override the default size by
10098 increasing it.  For example, if we have:
10099
10100 @smallexample @c ada
10101    type My_Boolean is new Boolean;
10102    for My_Boolean'Size use 32;
10103 @end smallexample
10104
10105 @noindent
10106 then values of this type will always be 32 bits long.  In the case of
10107 discrete types, the size can be increased up to 64 bits, with the effect
10108 that the entire specified field is used to hold the value, sign- or
10109 zero-extended as appropriate.  If more than 64 bits is specified, then
10110 padding space is allocated after the value, and a warning is issued that
10111 there are unused bits.
10112
10113 Similarly the size of records and arrays may be increased, and the effect
10114 is to add padding bits after the value.  This also causes a warning message
10115 to be generated.
10116
10117 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10118 Size in bits, this corresponds to an object of size 256 megabytes (minus
10119 one).  This limitation is true on all targets.  The reason for this
10120 limitation is that it improves the quality of the code in many cases
10121 if it is known that a Size value can be accommodated in an object of
10122 type Integer.
10123
10124 @node Storage_Size Clauses
10125 @section Storage_Size Clauses
10126 @cindex Storage_Size Clause
10127
10128 @noindent
10129 For tasks, the @code{Storage_Size} clause specifies the amount of space
10130 to be allocated for the task stack.  This cannot be extended, and if the
10131 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10132 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10133 or a @code{Storage_Size} pragma in the task definition to set the
10134 appropriate required size.  A useful technique is to include in every
10135 task definition a pragma of the form:
10136
10137 @smallexample @c ada
10138    pragma Storage_Size (Default_Stack_Size);
10139 @end smallexample
10140
10141 @noindent
10142 Then @code{Default_Stack_Size} can be defined in a global package, and
10143 modified as required. Any tasks requiring stack sizes different from the
10144 default can have an appropriate alternative reference in the pragma.
10145
10146 You can also use the @option{-d} binder switch to modify the default stack
10147 size.
10148
10149 For access types, the @code{Storage_Size} clause specifies the maximum
10150 space available for allocation of objects of the type.  If this space is
10151 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10152 In the case where the access type is declared local to a subprogram, the
10153 use of a @code{Storage_Size} clause triggers automatic use of a special
10154 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10155 space for the pool is automatically reclaimed on exit from the scope in
10156 which the type is declared.
10157
10158 A special case recognized by the compiler is the specification of a
10159 @code{Storage_Size} of zero for an access type.  This means that no
10160 items can be allocated from the pool, and this is recognized at compile
10161 time, and all the overhead normally associated with maintaining a fixed
10162 size storage pool is eliminated.  Consider the following example:
10163
10164 @smallexample @c ada
10165    procedure p is
10166       type R is array (Natural) of Character;
10167       type P is access all R;
10168       for P'Storage_Size use 0;
10169       --  Above access type intended only for interfacing purposes
10170
10171       y : P;
10172
10173       procedure g (m : P);
10174       pragma Import (C, g);
10175
10176       --  @dots{}
10177
10178    begin
10179       --  @dots{}
10180       y := new R;
10181    end;
10182 @end smallexample
10183
10184 @noindent
10185 As indicated in this example, these dummy storage pools are often useful in
10186 connection with interfacing where no object will ever be allocated.  If you
10187 compile the above example, you get the warning:
10188
10189 @smallexample
10190    p.adb:16:09: warning: allocation from empty storage pool
10191    p.adb:16:09: warning: Storage_Error will be raised at run time
10192 @end smallexample
10193
10194 @noindent
10195 Of course in practice, there will not be any explicit allocators in the
10196 case of such an access declaration.
10197
10198 @node Size of Variant Record Objects
10199 @section Size of Variant Record Objects
10200 @cindex Size, variant record objects
10201 @cindex Variant record objects, size
10202
10203 @noindent
10204 In the case of variant record objects, there is a question whether Size gives
10205 information about a particular variant, or the maximum size required
10206 for any variant.  Consider the following program
10207
10208 @smallexample @c ada
10209 with Text_IO; use Text_IO;
10210 procedure q is
10211    type R1 (A : Boolean := False) is record
10212      case A is
10213        when True  => X : Character;
10214        when False => null;
10215      end case;
10216    end record;
10217
10218    V1 : R1 (False);
10219    V2 : R1;
10220
10221 begin
10222    Put_Line (Integer'Image (V1'Size));
10223    Put_Line (Integer'Image (V2'Size));
10224 end q;
10225 @end smallexample
10226
10227 @noindent
10228 Here we are dealing with a variant record, where the True variant
10229 requires 16 bits, and the False variant requires 8 bits.
10230 In the above example, both V1 and V2 contain the False variant,
10231 which is only 8 bits long.  However, the result of running the
10232 program is:
10233
10234 @smallexample
10235 8
10236 16
10237 @end smallexample
10238
10239 @noindent
10240 The reason for the difference here is that the discriminant value of
10241 V1 is fixed, and will always be False.  It is not possible to assign
10242 a True variant value to V1, therefore 8 bits is sufficient.  On the
10243 other hand, in the case of V2, the initial discriminant value is
10244 False (from the default), but it is possible to assign a True
10245 variant value to V2, therefore 16 bits must be allocated for V2
10246 in the general case, even fewer bits may be needed at any particular
10247 point during the program execution.
10248
10249 As can be seen from the output of this program, the @code{'Size}
10250 attribute applied to such an object in GNAT gives the actual allocated
10251 size of the variable, which is the largest size of any of the variants.
10252 The Ada Reference Manual is not completely clear on what choice should
10253 be made here, but the GNAT behavior seems most consistent with the
10254 language in the RM@.
10255
10256 In some cases, it may be desirable to obtain the size of the current
10257 variant, rather than the size of the largest variant.  This can be
10258 achieved in GNAT by making use of the fact that in the case of a
10259 subprogram parameter, GNAT does indeed return the size of the current
10260 variant (because a subprogram has no way of knowing how much space
10261 is actually allocated for the actual).
10262
10263 Consider the following modified version of the above program:
10264
10265 @smallexample @c ada
10266 with Text_IO; use Text_IO;
10267 procedure q is
10268    type R1 (A : Boolean := False) is record
10269      case A is
10270        when True  => X : Character;
10271        when False => null;
10272      end case;
10273    end record;
10274
10275    V2 : R1;
10276
10277    function Size (V : R1) return Integer is
10278    begin
10279       return V'Size;
10280    end Size;
10281
10282 begin
10283    Put_Line (Integer'Image (V2'Size));
10284    Put_Line (Integer'IMage (Size (V2)));
10285    V2 := (True, 'x');
10286    Put_Line (Integer'Image (V2'Size));
10287    Put_Line (Integer'IMage (Size (V2)));
10288 end q;
10289 @end smallexample
10290
10291 @noindent
10292 The output from this program is
10293
10294 @smallexample
10295 16
10296 8
10297 16
10298 16
10299 @end smallexample
10300
10301 @noindent
10302 Here we see that while the @code{'Size} attribute always returns
10303 the maximum size, regardless of the current variant value, the
10304 @code{Size} function does indeed return the size of the current
10305 variant value.
10306
10307 @node Biased Representation
10308 @section Biased Representation
10309 @cindex Size for biased representation
10310 @cindex Biased representation
10311
10312 @noindent
10313 In the case of scalars with a range starting at other than zero, it is
10314 possible in some cases to specify a size smaller than the default minimum
10315 value, and in such cases, GNAT uses an unsigned biased representation,
10316 in which zero is used to represent the lower bound, and successive values
10317 represent successive values of the type.
10318
10319 For example, suppose we have the declaration:
10320
10321 @smallexample @c ada
10322    type Small is range -7 .. -4;
10323    for Small'Size use 2;
10324 @end smallexample
10325
10326 @noindent
10327 Although the default size of type @code{Small} is 4, the @code{Size}
10328 clause is accepted by GNAT and results in the following representation
10329 scheme:
10330
10331 @smallexample
10332   -7 is represented as 2#00#
10333   -6 is represented as 2#01#
10334   -5 is represented as 2#10#
10335   -4 is represented as 2#11#
10336 @end smallexample
10337
10338 @noindent
10339 Biased representation is only used if the specified @code{Size} clause
10340 cannot be accepted in any other manner.  These reduced sizes that force
10341 biased representation can be used for all discrete types except for
10342 enumeration types for which a representation clause is given.
10343
10344 @node Value_Size and Object_Size Clauses
10345 @section Value_Size and Object_Size Clauses
10346 @findex Value_Size
10347 @findex Object_Size
10348 @cindex Size, of objects
10349
10350 @noindent
10351 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10352 number of bits required to hold values of type @code{T}.
10353 Although this interpretation was allowed in Ada 83, it was not required,
10354 and this requirement in practice can cause some significant difficulties.
10355 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10356 However, in Ada 95 and Ada 2005,
10357 @code{Natural'Size} is
10358 typically 31.  This means that code may change in behavior when moving
10359 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10360
10361 @smallexample @c ada
10362    type Rec is record;
10363       A : Natural;
10364       B : Natural;
10365    end record;
10366
10367    for Rec use record
10368       at 0  range 0 .. Natural'Size - 1;
10369       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10370    end record;
10371 @end smallexample
10372
10373 @noindent
10374 In the above code, since the typical size of @code{Natural} objects
10375 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10376 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10377 there are cases where the fact that the object size can exceed the
10378 size of the type causes surprises.
10379
10380 To help get around this problem GNAT provides two implementation
10381 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10382 applied to a type, these attributes yield the size of the type
10383 (corresponding to the RM defined size attribute), and the size of
10384 objects of the type respectively.
10385
10386 The @code{Object_Size} is used for determining the default size of
10387 objects and components.  This size value can be referred to using the
10388 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10389 the basis of the determination of the size.  The backend is free to
10390 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10391 character might be stored in 32 bits on a machine with no efficient
10392 byte access instructions such as the Alpha.
10393
10394 The default rules for the value of @code{Object_Size} for
10395 discrete types are as follows:
10396
10397 @itemize @bullet
10398 @item
10399 The @code{Object_Size} for base subtypes reflect the natural hardware
10400 size in bits (run the compiler with @option{-gnatS} to find those values
10401 for numeric types). Enumeration types and fixed-point base subtypes have
10402 8, 16, 32 or 64 bits for this size, depending on the range of values
10403 to be stored.
10404
10405 @item
10406 The @code{Object_Size} of a subtype is the same as the
10407 @code{Object_Size} of
10408 the type from which it is obtained.
10409
10410 @item
10411 The @code{Object_Size} of a derived base type is copied from the parent
10412 base type, and the @code{Object_Size} of a derived first subtype is copied
10413 from the parent first subtype.
10414 @end itemize
10415
10416 @noindent
10417 The @code{Value_Size} attribute
10418 is the (minimum) number of bits required to store a value
10419 of the type.
10420 This value is used to determine how tightly to pack
10421 records or arrays with components of this type, and also affects
10422 the semantics of unchecked conversion (unchecked conversions where
10423 the @code{Value_Size} values differ generate a warning, and are potentially
10424 target dependent).
10425
10426 The default rules for the value of @code{Value_Size} are as follows:
10427
10428 @itemize @bullet
10429 @item
10430 The @code{Value_Size} for a base subtype is the minimum number of bits
10431 required to store all values of the type (including the sign bit
10432 only if negative values are possible).
10433
10434 @item
10435 If a subtype statically matches the first subtype of a given type, then it has
10436 by default the same @code{Value_Size} as the first subtype.  This is a
10437 consequence of RM 13.1(14) (``if two subtypes statically match,
10438 then their subtype-specific aspects are the same''.)
10439
10440 @item
10441 All other subtypes have a @code{Value_Size} corresponding to the minimum
10442 number of bits required to store all values of the subtype.  For
10443 dynamic bounds, it is assumed that the value can range down or up
10444 to the corresponding bound of the ancestor
10445 @end itemize
10446
10447 @noindent
10448 The RM defined attribute @code{Size} corresponds to the
10449 @code{Value_Size} attribute.
10450
10451 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10452 the @code{Value_Size} of
10453 the first-named subtype to the given value, and the
10454 @code{Object_Size} of this first-named subtype to the given value padded up
10455 to an appropriate boundary.  It is a consequence of the default rules
10456 above that this @code{Object_Size} will apply to all further subtypes.  On the
10457 other hand, @code{Value_Size} is affected only for the first subtype, any
10458 dynamic subtypes obtained from it directly, and any statically matching
10459 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10460
10461 @code{Value_Size} and
10462 @code{Object_Size} may be explicitly set for any subtype using
10463 an attribute definition clause.  Note that the use of these attributes
10464 can cause the RM 13.1(14) rule to be violated.  If two access types
10465 reference aliased objects whose subtypes have differing @code{Object_Size}
10466 values as a result of explicit attribute definition clauses, then it
10467 is erroneous to convert from one access subtype to the other.
10468
10469 At the implementation level, Esize stores the Object_Size and the
10470 RM_Size field stores the @code{Value_Size} (and hence the value of the
10471 @code{Size} attribute,
10472 which, as noted above, is equivalent to @code{Value_Size}).
10473
10474 To get a feel for the difference, consider the following examples (note
10475 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10476
10477 @smallexample
10478                                        Object_Size     Value_Size
10479
10480 type x1 is range 0 .. 5;                    8               3
10481
10482 type x2 is range 0 .. 5;
10483 for x2'size use 12;                        16              12
10484
10485 subtype x3 is x2 range 0 .. 3;             16               2
10486
10487 subtype x4 is x2'base range 0 .. 10;        8               4
10488
10489 subtype x5 is x2 range 0 .. dynamic;       16               3*
10490
10491 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10492
10493 @end smallexample
10494
10495 @noindent
10496 Note: the entries marked ``3*'' are not actually specified by the Ada
10497 Reference Manual, but it seems in the spirit of the RM rules to allocate
10498 the minimum number of bits (here 3, given the range for @code{x2})
10499 known to be large enough to hold the given range of values.
10500
10501 So far, so good, but GNAT has to obey the RM rules, so the question is
10502 under what conditions must the RM @code{Size} be used.
10503 The following is a list
10504 of the occasions on which the RM @code{Size} must be used:
10505
10506 @itemize @bullet
10507 @item
10508 Component size for packed arrays or records
10509
10510 @item
10511 Value of the attribute @code{Size} for a type
10512
10513 @item
10514 Warning about sizes not matching for unchecked conversion
10515 @end itemize
10516
10517 @noindent
10518 For record types, the @code{Object_Size} is always a multiple of the
10519 alignment of the type (this is true for all types). In some cases the
10520 @code{Value_Size} can be smaller. Consider:
10521
10522 @smallexample
10523    type R is record
10524      X : Integer;
10525      Y : Character;
10526    end record;
10527 @end smallexample
10528
10529 @noindent
10530 On a typical 32-bit architecture, the X component will be four bytes, and
10531 require four-byte alignment, and the Y component will be one byte. In this
10532 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10533 required to store a value of this type, and for example, it is permissible
10534 to have a component of type R in an outer array whose component size is
10535 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10536 since it must be rounded up so that this value is a multiple of the
10537 alignment (4 bytes = 32 bits).
10538
10539 @noindent
10540 For all other types, the @code{Object_Size}
10541 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10542 Only @code{Size} may be specified for such types.
10543
10544 @node Component_Size Clauses
10545 @section Component_Size Clauses
10546 @cindex Component_Size Clause
10547
10548 @noindent
10549 Normally, the value specified in a component size clause must be consistent
10550 with the subtype of the array component with regard to size and alignment.
10551 In other words, the value specified must be at least equal to the size
10552 of this subtype, and must be a multiple of the alignment value.
10553
10554 In addition, component size clauses are allowed which cause the array
10555 to be packed, by specifying a smaller value.  A first case is for
10556 component size values in the range 1 through 63.  The value specified
10557 must not be smaller than the Size of the subtype.  GNAT will accurately
10558 honor all packing requests in this range.  For example, if we have:
10559
10560 @smallexample @c ada
10561 type r is array (1 .. 8) of Natural;
10562 for r'Component_Size use 31;
10563 @end smallexample
10564
10565 @noindent
10566 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10567 Of course access to the components of such an array is considerably
10568 less efficient than if the natural component size of 32 is used.
10569 A second case is when the subtype of the component is a record type
10570 padded because of its default alignment.  For example, if we have:
10571
10572 @smallexample @c ada
10573 type r is record
10574   i : Integer;
10575   j : Integer;
10576   b : Boolean;
10577 end record;
10578
10579 type a is array (1 .. 8) of r;
10580 for a'Component_Size use 72;
10581 @end smallexample
10582
10583 @noindent
10584 then the resulting array has a length of 72 bytes, instead of 96 bytes
10585 if the alignment of the record (4) was obeyed.
10586
10587 Note that there is no point in giving both a component size clause
10588 and a pragma Pack for the same array type. if such duplicate
10589 clauses are given, the pragma Pack will be ignored.
10590
10591 @node Bit_Order Clauses
10592 @section Bit_Order Clauses
10593 @cindex Bit_Order Clause
10594 @cindex bit ordering
10595 @cindex ordering, of bits
10596
10597 @noindent
10598 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10599 attribute.  The specification may either correspond to the default bit
10600 order for the target, in which case the specification has no effect and
10601 places no additional restrictions, or it may be for the non-standard
10602 setting (that is the opposite of the default).
10603
10604 In the case where the non-standard value is specified, the effect is
10605 to renumber bits within each byte, but the ordering of bytes is not
10606 affected.  There are certain
10607 restrictions placed on component clauses as follows:
10608
10609 @itemize @bullet
10610
10611 @item Components fitting within a single storage unit.
10612 @noindent
10613 These are unrestricted, and the effect is merely to renumber bits.  For
10614 example if we are on a little-endian machine with @code{Low_Order_First}
10615 being the default, then the following two declarations have exactly
10616 the same effect:
10617
10618 @smallexample @c ada
10619    type R1 is record
10620       A : Boolean;
10621       B : Integer range 1 .. 120;
10622    end record;
10623
10624    for R1 use record
10625       A at 0 range 0 .. 0;
10626       B at 0 range 1 .. 7;
10627    end record;
10628
10629    type R2 is record
10630       A : Boolean;
10631       B : Integer range 1 .. 120;
10632    end record;
10633
10634    for R2'Bit_Order use High_Order_First;
10635
10636    for R2 use record
10637       A at 0 range 7 .. 7;
10638       B at 0 range 0 .. 6;
10639    end record;
10640 @end smallexample
10641
10642 @noindent
10643 The useful application here is to write the second declaration with the
10644 @code{Bit_Order} attribute definition clause, and know that it will be treated
10645 the same, regardless of whether the target is little-endian or big-endian.
10646
10647 @item Components occupying an integral number of bytes.
10648 @noindent
10649 These are components that exactly fit in two or more bytes.  Such component
10650 declarations are allowed, but have no effect, since it is important to realize
10651 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10652 In particular, the following attempt at getting an endian-independent integer
10653 does not work:
10654
10655 @smallexample @c ada
10656    type R2 is record
10657       A : Integer;
10658    end record;
10659
10660    for R2'Bit_Order use High_Order_First;
10661
10662    for R2 use record
10663       A at 0 range 0 .. 31;
10664    end record;
10665 @end smallexample
10666
10667 @noindent
10668 This declaration will result in a little-endian integer on a
10669 little-endian machine, and a big-endian integer on a big-endian machine.
10670 If byte flipping is required for interoperability between big- and
10671 little-endian machines, this must be explicitly programmed.  This capability
10672 is not provided by @code{Bit_Order}.
10673
10674 @item Components that are positioned across byte boundaries
10675 @noindent
10676 but do not occupy an integral number of bytes.  Given that bytes are not
10677 reordered, such fields would occupy a non-contiguous sequence of bits
10678 in memory, requiring non-trivial code to reassemble.  They are for this
10679 reason not permitted, and any component clause specifying such a layout
10680 will be flagged as illegal by GNAT@.
10681
10682 @end itemize
10683
10684 @noindent
10685 Since the misconception that Bit_Order automatically deals with all
10686 endian-related incompatibilities is a common one, the specification of
10687 a component field that is an integral number of bytes will always
10688 generate a warning.  This warning may be suppressed using @code{pragma
10689 Warnings (Off)} if desired.  The following section contains additional
10690 details regarding the issue of byte ordering.
10691
10692 @node Effect of Bit_Order on Byte Ordering
10693 @section Effect of Bit_Order on Byte Ordering
10694 @cindex byte ordering
10695 @cindex ordering, of bytes
10696
10697 @noindent
10698 In this section we will review the effect of the @code{Bit_Order} attribute
10699 definition clause on byte ordering.  Briefly, it has no effect at all, but
10700 a detailed example will be helpful.  Before giving this
10701 example, let us review the precise
10702 definition of the effect of defining @code{Bit_Order}.  The effect of a
10703 non-standard bit order is described in section 15.5.3 of the Ada
10704 Reference Manual:
10705
10706 @quotation
10707 2   A bit ordering is a method of interpreting the meaning of
10708 the storage place attributes.
10709 @end quotation
10710
10711 @noindent
10712 To understand the precise definition of storage place attributes in
10713 this context, we visit section 13.5.1 of the manual:
10714
10715 @quotation
10716 13   A record_representation_clause (without the mod_clause)
10717 specifies the layout.  The storage place attributes (see 13.5.2)
10718 are taken from the values of the position, first_bit, and last_bit
10719 expressions after normalizing those values so that first_bit is
10720 less than Storage_Unit.
10721 @end quotation
10722
10723 @noindent
10724 The critical point here is that storage places are taken from
10725 the values after normalization, not before.  So the @code{Bit_Order}
10726 interpretation applies to normalized values.  The interpretation
10727 is described in the later part of the 15.5.3 paragraph:
10728
10729 @quotation
10730 2   A bit ordering is a method of interpreting the meaning of
10731 the storage place attributes.  High_Order_First (known in the
10732 vernacular as ``big endian'') means that the first bit of a
10733 storage element (bit 0) is the most significant bit (interpreting
10734 the sequence of bits that represent a component as an unsigned
10735 integer value).  Low_Order_First (known in the vernacular as
10736 ``little endian'') means the opposite: the first bit is the
10737 least significant.
10738 @end quotation
10739
10740 @noindent
10741 Note that the numbering is with respect to the bits of a storage
10742 unit.  In other words, the specification affects only the numbering
10743 of bits within a single storage unit.
10744
10745 We can make the effect clearer by giving an example.
10746
10747 Suppose that we have an external device which presents two bytes, the first
10748 byte presented, which is the first (low addressed byte) of the two byte
10749 record is called Master, and the second byte is called Slave.
10750
10751 The left most (most significant bit is called Control for each byte, and
10752 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10753 (least significant) bit.
10754
10755 On a big-endian machine, we can write the following representation clause
10756
10757 @smallexample @c ada
10758    type Data is record
10759       Master_Control : Bit;
10760       Master_V1      : Bit;
10761       Master_V2      : Bit;
10762       Master_V3      : Bit;
10763       Master_V4      : Bit;
10764       Master_V5      : Bit;
10765       Master_V6      : Bit;
10766       Master_V7      : Bit;
10767       Slave_Control  : Bit;
10768       Slave_V1       : Bit;
10769       Slave_V2       : Bit;
10770       Slave_V3       : Bit;
10771       Slave_V4       : Bit;
10772       Slave_V5       : Bit;
10773       Slave_V6       : Bit;
10774       Slave_V7       : Bit;
10775    end record;
10776
10777    for Data use record
10778       Master_Control at 0 range 0 .. 0;
10779       Master_V1      at 0 range 1 .. 1;
10780       Master_V2      at 0 range 2 .. 2;
10781       Master_V3      at 0 range 3 .. 3;
10782       Master_V4      at 0 range 4 .. 4;
10783       Master_V5      at 0 range 5 .. 5;
10784       Master_V6      at 0 range 6 .. 6;
10785       Master_V7      at 0 range 7 .. 7;
10786       Slave_Control  at 1 range 0 .. 0;
10787       Slave_V1       at 1 range 1 .. 1;
10788       Slave_V2       at 1 range 2 .. 2;
10789       Slave_V3       at 1 range 3 .. 3;
10790       Slave_V4       at 1 range 4 .. 4;
10791       Slave_V5       at 1 range 5 .. 5;
10792       Slave_V6       at 1 range 6 .. 6;
10793       Slave_V7       at 1 range 7 .. 7;
10794    end record;
10795 @end smallexample
10796
10797 @noindent
10798 Now if we move this to a little endian machine, then the bit ordering within
10799 the byte is backwards, so we have to rewrite the record rep clause as:
10800
10801 @smallexample @c ada
10802    for Data use record
10803       Master_Control at 0 range 7 .. 7;
10804       Master_V1      at 0 range 6 .. 6;
10805       Master_V2      at 0 range 5 .. 5;
10806       Master_V3      at 0 range 4 .. 4;
10807       Master_V4      at 0 range 3 .. 3;
10808       Master_V5      at 0 range 2 .. 2;
10809       Master_V6      at 0 range 1 .. 1;
10810       Master_V7      at 0 range 0 .. 0;
10811       Slave_Control  at 1 range 7 .. 7;
10812       Slave_V1       at 1 range 6 .. 6;
10813       Slave_V2       at 1 range 5 .. 5;
10814       Slave_V3       at 1 range 4 .. 4;
10815       Slave_V4       at 1 range 3 .. 3;
10816       Slave_V5       at 1 range 2 .. 2;
10817       Slave_V6       at 1 range 1 .. 1;
10818       Slave_V7       at 1 range 0 .. 0;
10819    end record;
10820 @end smallexample
10821
10822 @noindent
10823 It is a nuisance to have to rewrite the clause, especially if
10824 the code has to be maintained on both machines.  However,
10825 this is a case that we can handle with the
10826 @code{Bit_Order} attribute if it is implemented.
10827 Note that the implementation is not required on byte addressed
10828 machines, but it is indeed implemented in GNAT.
10829 This means that we can simply use the
10830 first record clause, together with the declaration
10831
10832 @smallexample @c ada
10833    for Data'Bit_Order use High_Order_First;
10834 @end smallexample
10835
10836 @noindent
10837 and the effect is what is desired, namely the layout is exactly the same,
10838 independent of whether the code is compiled on a big-endian or little-endian
10839 machine.
10840
10841 The important point to understand is that byte ordering is not affected.
10842 A @code{Bit_Order} attribute definition never affects which byte a field
10843 ends up in, only where it ends up in that byte.
10844 To make this clear, let us rewrite the record rep clause of the previous
10845 example as:
10846
10847 @smallexample @c ada
10848    for Data'Bit_Order use High_Order_First;
10849    for Data use record
10850       Master_Control at 0 range  0 .. 0;
10851       Master_V1      at 0 range  1 .. 1;
10852       Master_V2      at 0 range  2 .. 2;
10853       Master_V3      at 0 range  3 .. 3;
10854       Master_V4      at 0 range  4 .. 4;
10855       Master_V5      at 0 range  5 .. 5;
10856       Master_V6      at 0 range  6 .. 6;
10857       Master_V7      at 0 range  7 .. 7;
10858       Slave_Control  at 0 range  8 .. 8;
10859       Slave_V1       at 0 range  9 .. 9;
10860       Slave_V2       at 0 range 10 .. 10;
10861       Slave_V3       at 0 range 11 .. 11;
10862       Slave_V4       at 0 range 12 .. 12;
10863       Slave_V5       at 0 range 13 .. 13;
10864       Slave_V6       at 0 range 14 .. 14;
10865       Slave_V7       at 0 range 15 .. 15;
10866    end record;
10867 @end smallexample
10868
10869 @noindent
10870 This is exactly equivalent to saying (a repeat of the first example):
10871
10872 @smallexample @c ada
10873    for Data'Bit_Order use High_Order_First;
10874    for Data use record
10875       Master_Control at 0 range 0 .. 0;
10876       Master_V1      at 0 range 1 .. 1;
10877       Master_V2      at 0 range 2 .. 2;
10878       Master_V3      at 0 range 3 .. 3;
10879       Master_V4      at 0 range 4 .. 4;
10880       Master_V5      at 0 range 5 .. 5;
10881       Master_V6      at 0 range 6 .. 6;
10882       Master_V7      at 0 range 7 .. 7;
10883       Slave_Control  at 1 range 0 .. 0;
10884       Slave_V1       at 1 range 1 .. 1;
10885       Slave_V2       at 1 range 2 .. 2;
10886       Slave_V3       at 1 range 3 .. 3;
10887       Slave_V4       at 1 range 4 .. 4;
10888       Slave_V5       at 1 range 5 .. 5;
10889       Slave_V6       at 1 range 6 .. 6;
10890       Slave_V7       at 1 range 7 .. 7;
10891    end record;
10892 @end smallexample
10893
10894 @noindent
10895 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10896 field.  The storage place attributes are obtained by normalizing the
10897 values given so that the @code{First_Bit} value is less than 8.  After
10898 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10899 we specified in the other case.
10900
10901 Now one might expect that the @code{Bit_Order} attribute might affect
10902 bit numbering within the entire record component (two bytes in this
10903 case, thus affecting which byte fields end up in), but that is not
10904 the way this feature is defined, it only affects numbering of bits,
10905 not which byte they end up in.
10906
10907 Consequently it never makes sense to specify a starting bit number
10908 greater than 7 (for a byte addressable field) if an attribute
10909 definition for @code{Bit_Order} has been given, and indeed it
10910 may be actively confusing to specify such a value, so the compiler
10911 generates a warning for such usage.
10912
10913 If you do need to control byte ordering then appropriate conditional
10914 values must be used.  If in our example, the slave byte came first on
10915 some machines we might write:
10916
10917 @smallexample @c ada
10918    Master_Byte_First constant Boolean := @dots{};
10919
10920    Master_Byte : constant Natural :=
10921                    1 - Boolean'Pos (Master_Byte_First);
10922    Slave_Byte  : constant Natural :=
10923                    Boolean'Pos (Master_Byte_First);
10924
10925    for Data'Bit_Order use High_Order_First;
10926    for Data use record
10927       Master_Control at Master_Byte range 0 .. 0;
10928       Master_V1      at Master_Byte range 1 .. 1;
10929       Master_V2      at Master_Byte range 2 .. 2;
10930       Master_V3      at Master_Byte range 3 .. 3;
10931       Master_V4      at Master_Byte range 4 .. 4;
10932       Master_V5      at Master_Byte range 5 .. 5;
10933       Master_V6      at Master_Byte range 6 .. 6;
10934       Master_V7      at Master_Byte range 7 .. 7;
10935       Slave_Control  at Slave_Byte  range 0 .. 0;
10936       Slave_V1       at Slave_Byte  range 1 .. 1;
10937       Slave_V2       at Slave_Byte  range 2 .. 2;
10938       Slave_V3       at Slave_Byte  range 3 .. 3;
10939       Slave_V4       at Slave_Byte  range 4 .. 4;
10940       Slave_V5       at Slave_Byte  range 5 .. 5;
10941       Slave_V6       at Slave_Byte  range 6 .. 6;
10942       Slave_V7       at Slave_Byte  range 7 .. 7;
10943    end record;
10944 @end smallexample
10945
10946 @noindent
10947 Now to switch between machines, all that is necessary is
10948 to set the boolean constant @code{Master_Byte_First} in
10949 an appropriate manner.
10950
10951 @node Pragma Pack for Arrays
10952 @section Pragma Pack for Arrays
10953 @cindex Pragma Pack (for arrays)
10954
10955 @noindent
10956 Pragma @code{Pack} applied to an array has no effect unless the component type
10957 is packable.  For a component type to be packable, it must be one of the
10958 following cases:
10959
10960 @itemize @bullet
10961 @item
10962 Any scalar type
10963 @item
10964 Any type whose size is specified with a size clause
10965 @item
10966 Any packed array type with a static size
10967 @item
10968 Any record type padded because of its default alignment
10969 @end itemize
10970
10971 @noindent
10972 For all these cases, if the component subtype size is in the range
10973 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10974 component size were specified giving the component subtype size.
10975 For example if we have:
10976
10977 @smallexample @c ada
10978    type r is range 0 .. 17;
10979
10980    type ar is array (1 .. 8) of r;
10981    pragma Pack (ar);
10982 @end smallexample
10983
10984 @noindent
10985 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10986 and the size of the array @code{ar} will be exactly 40 bits.
10987
10988 Note that in some cases this rather fierce approach to packing can produce
10989 unexpected effects.  For example, in Ada 95 and Ada 2005,
10990 subtype @code{Natural} typically has a size of 31, meaning that if you
10991 pack an array of @code{Natural}, you get 31-bit
10992 close packing, which saves a few bits, but results in far less efficient
10993 access.  Since many other Ada compilers will ignore such a packing request,
10994 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10995 might not be what is intended.  You can easily remove this warning by
10996 using an explicit @code{Component_Size} setting instead, which never generates
10997 a warning, since the intention of the programmer is clear in this case.
10998
10999 GNAT treats packed arrays in one of two ways.  If the size of the array is
11000 known at compile time and is less than 64 bits, then internally the array
11001 is represented as a single modular type, of exactly the appropriate number
11002 of bits.  If the length is greater than 63 bits, or is not known at compile
11003 time, then the packed array is represented as an array of bytes, and the
11004 length is always a multiple of 8 bits.
11005
11006 Note that to represent a packed array as a modular type, the alignment must
11007 be suitable for the modular type involved. For example, on typical machines
11008 a 32-bit packed array will be represented by a 32-bit modular integer with
11009 an alignment of four bytes. If you explicitly override the default alignment
11010 with an alignment clause that is too small, the modular representation
11011 cannot be used. For example, consider the following set of declarations:
11012
11013 @smallexample @c ada
11014    type R is range 1 .. 3;
11015    type S is array (1 .. 31) of R;
11016    for S'Component_Size use 2;
11017    for S'Size use 62;
11018    for S'Alignment use 1;
11019 @end smallexample
11020
11021 @noindent
11022 If the alignment clause were not present, then a 62-bit modular
11023 representation would be chosen (typically with an alignment of 4 or 8
11024 bytes depending on the target). But the default alignment is overridden
11025 with the explicit alignment clause. This means that the modular
11026 representation cannot be used, and instead the array of bytes
11027 representation must be used, meaning that the length must be a multiple
11028 of 8. Thus the above set of declarations will result in a diagnostic
11029 rejecting the size clause and noting that the minimum size allowed is 64.
11030
11031 @cindex Pragma Pack (for type Natural)
11032 @cindex Pragma Pack warning
11033
11034 One special case that is worth noting occurs when the base type of the
11035 component size is 8/16/32 and the subtype is one bit less. Notably this
11036 occurs with subtype @code{Natural}. Consider:
11037
11038 @smallexample @c ada
11039    type Arr is array (1 .. 32) of Natural;
11040    pragma Pack (Arr);
11041 @end smallexample
11042
11043 @noindent
11044 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11045 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11046 Ada 83 compilers did not attempt 31 bit packing.
11047
11048 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11049 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11050 substantial unintended performance penalty when porting legacy Ada 83 code.
11051 To help prevent this, GNAT generates a warning in such cases. If you really
11052 want 31 bit packing in a case like this, you can set the component size
11053 explicitly:
11054
11055 @smallexample @c ada
11056    type Arr is array (1 .. 32) of Natural;
11057    for Arr'Component_Size use 31;
11058 @end smallexample
11059
11060 @noindent
11061 Here 31-bit packing is achieved as required, and no warning is generated,
11062 since in this case the programmer intention is clear.
11063
11064 @node Pragma Pack for Records
11065 @section Pragma Pack for Records
11066 @cindex Pragma Pack (for records)
11067
11068 @noindent
11069 Pragma @code{Pack} applied to a record will pack the components to reduce
11070 wasted space from alignment gaps and by reducing the amount of space
11071 taken by components.  We distinguish between @emph{packable} components and
11072 @emph{non-packable} components.
11073 Components of the following types are considered packable:
11074 @itemize @bullet
11075 @item
11076 All primitive types are packable.
11077
11078 @item
11079 Small packed arrays, whose size does not exceed 64 bits, and where the
11080 size is statically known at compile time, are represented internally
11081 as modular integers, and so they are also packable.
11082
11083 @end itemize
11084
11085 @noindent
11086 All packable components occupy the exact number of bits corresponding to
11087 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11088 can start on an arbitrary bit boundary.
11089
11090 All other types are non-packable, they occupy an integral number of
11091 storage units, and
11092 are placed at a boundary corresponding to their alignment requirements.
11093
11094 For example, consider the record
11095
11096 @smallexample @c ada
11097    type Rb1 is array (1 .. 13) of Boolean;
11098    pragma Pack (rb1);
11099
11100    type Rb2 is array (1 .. 65) of Boolean;
11101    pragma Pack (rb2);
11102
11103    type x2 is record
11104       l1 : Boolean;
11105       l2 : Duration;
11106       l3 : Float;
11107       l4 : Boolean;
11108       l5 : Rb1;
11109       l6 : Rb2;
11110    end record;
11111    pragma Pack (x2);
11112 @end smallexample
11113
11114 @noindent
11115 The representation for the record x2 is as follows:
11116
11117 @smallexample @c ada
11118 for x2'Size use 224;
11119 for x2 use record
11120    l1 at  0 range  0 .. 0;
11121    l2 at  0 range  1 .. 64;
11122    l3 at 12 range  0 .. 31;
11123    l4 at 16 range  0 .. 0;
11124    l5 at 16 range  1 .. 13;
11125    l6 at 18 range  0 .. 71;
11126 end record;
11127 @end smallexample
11128
11129 @noindent
11130 Studying this example, we see that the packable fields @code{l1}
11131 and @code{l2} are
11132 of length equal to their sizes, and placed at specific bit boundaries (and
11133 not byte boundaries) to
11134 eliminate padding.  But @code{l3} is of a non-packable float type, so
11135 it is on the next appropriate alignment boundary.
11136
11137 The next two fields are fully packable, so @code{l4} and @code{l5} are
11138 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11139 array that is longer than 64 bits, so it is itself non-packable.  Thus
11140 the @code{l6} field is aligned to the next byte boundary, and takes an
11141 integral number of bytes, i.e.@: 72 bits.
11142
11143 @node Record Representation Clauses
11144 @section Record Representation Clauses
11145 @cindex Record Representation Clause
11146
11147 @noindent
11148 Record representation clauses may be given for all record types, including
11149 types obtained by record extension.  Component clauses are allowed for any
11150 static component.  The restrictions on component clauses depend on the type
11151 of the component.
11152
11153 @cindex Component Clause
11154 For all components of an elementary type, the only restriction on component
11155 clauses is that the size must be at least the 'Size value of the type
11156 (actually the Value_Size).  There are no restrictions due to alignment,
11157 and such components may freely cross storage boundaries.
11158
11159 Packed arrays with a size up to and including 64 bits are represented
11160 internally using a modular type with the appropriate number of bits, and
11161 thus the same lack of restriction applies.  For example, if you declare:
11162
11163 @smallexample @c ada
11164    type R is array (1 .. 49) of Boolean;
11165    pragma Pack (R);
11166    for R'Size use 49;
11167 @end smallexample
11168
11169 @noindent
11170 then a component clause for a component of type R may start on any
11171 specified bit boundary, and may specify a value of 49 bits or greater.
11172
11173 For packed bit arrays that are longer than 64 bits, there are two
11174 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11175 including the important case of single bits or boolean values, then
11176 there are no limitations on placement of such components, and they
11177 may start and end at arbitrary bit boundaries.
11178
11179 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11180 an array of this type longer than 64 bits must always be placed on
11181 on a storage unit (byte) boundary and occupy an integral number
11182 of storage units (bytes). Any component clause that does not
11183 meet this requirement will be rejected.
11184
11185 Any aliased component, or component of an aliased type, must
11186 have its normal alignment and size. A component clause that
11187 does not meet this requirement will be rejected.
11188
11189 The tag field of a tagged type always occupies an address sized field at
11190 the start of the record.  No component clause may attempt to overlay this
11191 tag. When a tagged type appears as a component, the tag field must have
11192 proper alignment
11193
11194 In the case of a record extension T1, of a type T, no component clause applied
11195 to the type T1 can specify a storage location that would overlap the first
11196 T'Size bytes of the record.
11197
11198 For all other component types, including non-bit-packed arrays,
11199 the component can be placed at an arbitrary bit boundary,
11200 so for example, the following is permitted:
11201
11202 @smallexample @c ada
11203    type R is array (1 .. 10) of Boolean;
11204    for R'Size use 80;
11205
11206    type Q is record
11207       G, H : Boolean;
11208       L, M : R;
11209    end record;
11210
11211    for Q use record
11212       G at 0 range  0 ..   0;
11213       H at 0 range  1 ..   1;
11214       L at 0 range  2 ..  81;
11215       R at 0 range 82 .. 161;
11216    end record;
11217 @end smallexample
11218
11219 @noindent
11220 Note: the above rules apply to recent releases of GNAT 5.
11221 In GNAT 3, there are more severe restrictions on larger components.
11222 For non-primitive types, including packed arrays with a size greater than
11223 64 bits, component clauses must respect the alignment requirement of the
11224 type, in particular, always starting on a byte boundary, and the length
11225 must be a multiple of the storage unit.
11226
11227 @node Enumeration Clauses
11228 @section Enumeration Clauses
11229
11230 The only restriction on enumeration clauses is that the range of values
11231 must be representable.  For the signed case, if one or more of the
11232 representation values are negative, all values must be in the range:
11233
11234 @smallexample @c ada
11235    System.Min_Int .. System.Max_Int
11236 @end smallexample
11237
11238 @noindent
11239 For the unsigned case, where all values are nonnegative, the values must
11240 be in the range:
11241
11242 @smallexample @c ada
11243    0 .. System.Max_Binary_Modulus;
11244 @end smallexample
11245
11246 @noindent
11247 A @emph{confirming} representation clause is one in which the values range
11248 from 0 in sequence, i.e.@: a clause that confirms the default representation
11249 for an enumeration type.
11250 Such a confirming representation
11251 is permitted by these rules, and is specially recognized by the compiler so
11252 that no extra overhead results from the use of such a clause.
11253
11254 If an array has an index type which is an enumeration type to which an
11255 enumeration clause has been applied, then the array is stored in a compact
11256 manner.  Consider the declarations:
11257
11258 @smallexample @c ada
11259    type r is (A, B, C);
11260    for r use (A => 1, B => 5, C => 10);
11261    type t is array (r) of Character;
11262 @end smallexample
11263
11264 @noindent
11265 The array type t corresponds to a vector with exactly three elements and
11266 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11267 use of space, but means that accesses to elements of the array will incur
11268 the overhead of converting representation values to the corresponding
11269 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11270
11271 @node Address Clauses
11272 @section Address Clauses
11273 @cindex Address Clause
11274
11275 The reference manual allows a general restriction on representation clauses,
11276 as found in RM 13.1(22):
11277
11278 @quotation
11279 An implementation need not support representation
11280 items containing nonstatic expressions, except that
11281 an implementation should support a representation item
11282 for a given entity if each nonstatic expression in the
11283 representation item is a name that statically denotes
11284 a constant declared before the entity.
11285 @end quotation
11286
11287 @noindent
11288 In practice this is applicable only to address clauses, since this is the
11289 only case in which a non-static expression is permitted by the syntax.  As
11290 the AARM notes in sections 13.1 (22.a-22.h):
11291
11292 @display
11293   22.a   Reason: This is to avoid the following sort of thing:
11294
11295   22.b        X : Integer := F(@dots{});
11296               Y : Address := G(@dots{});
11297               for X'Address use Y;
11298
11299   22.c   In the above, we have to evaluate the
11300          initialization expression for X before we
11301          know where to put the result.  This seems
11302          like an unreasonable implementation burden.
11303
11304   22.d   The above code should instead be written
11305          like this:
11306
11307   22.e        Y : constant Address := G(@dots{});
11308               X : Integer := F(@dots{});
11309               for X'Address use Y;
11310
11311   22.f   This allows the expression ``Y'' to be safely
11312          evaluated before X is created.
11313
11314   22.g   The constant could be a formal parameter of mode in.
11315
11316   22.h   An implementation can support other nonstatic
11317          expressions if it wants to.  Expressions of type
11318          Address are hardly ever static, but their value
11319          might be known at compile time anyway in many
11320          cases.
11321 @end display
11322
11323 @noindent
11324 GNAT does indeed permit many additional cases of non-static expressions.  In
11325 particular, if the type involved is elementary there are no restrictions
11326 (since in this case, holding a temporary copy of the initialization value,
11327 if one is present, is inexpensive).  In addition, if there is no implicit or
11328 explicit initialization, then there are no restrictions.  GNAT will reject
11329 only the case where all three of these conditions hold:
11330
11331 @itemize @bullet
11332
11333 @item
11334 The type of the item is non-elementary (e.g.@: a record or array).
11335
11336 @item
11337 There is explicit or implicit initialization required for the object.
11338 Note that access values are always implicitly initialized, and also
11339 in GNAT, certain bit-packed arrays (those having a dynamic length or
11340 a length greater than 64) will also be implicitly initialized to zero.
11341
11342 @item
11343 The address value is non-static.  Here GNAT is more permissive than the
11344 RM, and allows the address value to be the address of a previously declared
11345 stand-alone variable, as long as it does not itself have an address clause.
11346
11347 @smallexample @c ada
11348            Anchor  : Some_Initialized_Type;
11349            Overlay : Some_Initialized_Type;
11350            for Overlay'Address use Anchor'Address;
11351 @end smallexample
11352
11353 @noindent
11354 However, the prefix of the address clause cannot be an array component, or
11355 a component of a discriminated record.
11356
11357 @end itemize
11358
11359 @noindent
11360 As noted above in section 22.h, address values are typically non-static.  In
11361 particular the To_Address function, even if applied to a literal value, is
11362 a non-static function call.  To avoid this minor annoyance, GNAT provides
11363 the implementation defined attribute 'To_Address.  The following two
11364 expressions have identical values:
11365
11366 @findex Attribute
11367 @findex To_Address
11368 @smallexample @c ada
11369    To_Address (16#1234_0000#)
11370    System'To_Address (16#1234_0000#);
11371 @end smallexample
11372
11373 @noindent
11374 except that the second form is considered to be a static expression, and
11375 thus when used as an address clause value is always permitted.
11376
11377 @noindent
11378 Additionally, GNAT treats as static an address clause that is an
11379 unchecked_conversion of a static integer value.  This simplifies the porting
11380 of legacy code, and provides a portable equivalent to the GNAT attribute
11381 @code{To_Address}.
11382
11383 Another issue with address clauses is the interaction with alignment
11384 requirements.  When an address clause is given for an object, the address
11385 value must be consistent with the alignment of the object (which is usually
11386 the same as the alignment of the type of the object).  If an address clause
11387 is given that specifies an inappropriately aligned address value, then the
11388 program execution is erroneous.
11389
11390 Since this source of erroneous behavior can have unfortunate effects, GNAT
11391 checks (at compile time if possible, generating a warning, or at execution
11392 time with a run-time check) that the alignment is appropriate.  If the
11393 run-time check fails, then @code{Program_Error} is raised.  This run-time
11394 check is suppressed if range checks are suppressed, or if the special GNAT
11395 check Alignment_Check is suppressed, or if
11396 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11397
11398 Finally, GNAT does not permit overlaying of objects of controlled types or
11399 composite types containing a controlled component. In most cases, the compiler
11400 can detect an attempt at such overlays and will generate a warning at compile
11401 time and a Program_Error exception at run time.
11402
11403 @findex Export
11404 An address clause cannot be given for an exported object.  More
11405 understandably the real restriction is that objects with an address
11406 clause cannot be exported.  This is because such variables are not
11407 defined by the Ada program, so there is no external object to export.
11408
11409 @findex Import
11410 It is permissible to give an address clause and a pragma Import for the
11411 same object.  In this case, the variable is not really defined by the
11412 Ada program, so there is no external symbol to be linked.  The link name
11413 and the external name are ignored in this case.  The reason that we allow this
11414 combination is that it provides a useful idiom to avoid unwanted
11415 initializations on objects with address clauses.
11416
11417 When an address clause is given for an object that has implicit or
11418 explicit initialization, then by default initialization takes place.  This
11419 means that the effect of the object declaration is to overwrite the
11420 memory at the specified address.  This is almost always not what the
11421 programmer wants, so GNAT will output a warning:
11422
11423 @smallexample
11424   with System;
11425   package G is
11426      type R is record
11427         M : Integer := 0;
11428      end record;
11429
11430      Ext : R;
11431      for Ext'Address use System'To_Address (16#1234_1234#);
11432          |
11433   >>> warning: implicit initialization of "Ext" may
11434       modify overlaid storage
11435   >>> warning: use pragma Import for "Ext" to suppress
11436       initialization (RM B(24))
11437
11438   end G;
11439 @end smallexample
11440
11441 @noindent
11442 As indicated by the warning message, the solution is to use a (dummy) pragma
11443 Import to suppress this initialization.  The pragma tell the compiler that the
11444 object is declared and initialized elsewhere.  The following package compiles
11445 without warnings (and the initialization is suppressed):
11446
11447 @smallexample @c ada
11448    with System;
11449    package G is
11450       type R is record
11451          M : Integer := 0;
11452       end record;
11453
11454       Ext : R;
11455       for Ext'Address use System'To_Address (16#1234_1234#);
11456       pragma Import (Ada, Ext);
11457    end G;
11458 @end smallexample
11459
11460 @noindent
11461 A final issue with address clauses involves their use for overlaying
11462 variables, as in the following example:
11463 @cindex Overlaying of objects
11464
11465 @smallexample @c ada
11466   A : Integer;
11467   B : Integer;
11468   for B'Address use A'Address;
11469 @end smallexample
11470
11471 @noindent
11472 or alternatively, using the form recommended by the RM:
11473
11474 @smallexample @c ada
11475   A    : Integer;
11476   Addr : constant Address := A'Address;
11477   B    : Integer;
11478   for B'Address use Addr;
11479 @end smallexample
11480
11481 @noindent
11482 In both of these cases, @code{A}
11483 and @code{B} become aliased to one another via the
11484 address clause. This use of address clauses to overlay
11485 variables, achieving an effect similar to unchecked
11486 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11487 the effect is implementation defined. Furthermore, the
11488 Ada RM specifically recommends that in a situation
11489 like this, @code{B} should be subject to the following
11490 implementation advice (RM 13.3(19)):
11491
11492 @quotation
11493 19  If the Address of an object is specified, or it is imported
11494     or exported, then the implementation should not perform
11495     optimizations based on assumptions of no aliases.
11496 @end quotation
11497
11498 @noindent
11499 GNAT follows this recommendation, and goes further by also applying
11500 this recommendation to the overlaid variable (@code{A}
11501 in the above example) in this case. This means that the overlay
11502 works "as expected", in that a modification to one of the variables
11503 will affect the value of the other.
11504
11505 @node Effect of Convention on Representation
11506 @section Effect of Convention on Representation
11507 @cindex Convention, effect on representation
11508
11509 @noindent
11510 Normally the specification of a foreign language convention for a type or
11511 an object has no effect on the chosen representation.  In particular, the
11512 representation chosen for data in GNAT generally meets the standard system
11513 conventions, and for example records are laid out in a manner that is
11514 consistent with C@.  This means that specifying convention C (for example)
11515 has no effect.
11516
11517 There are four exceptions to this general rule:
11518
11519 @itemize @bullet
11520
11521 @item Convention Fortran and array subtypes
11522 If pragma Convention Fortran is specified for an array subtype, then in
11523 accordance with the implementation advice in section 3.6.2(11) of the
11524 Ada Reference Manual, the array will be stored in a Fortran-compatible
11525 column-major manner, instead of the normal default row-major order.
11526
11527 @item Convention C and enumeration types
11528 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11529 to accommodate all values of the type.  For example, for the enumeration
11530 type declared by:
11531
11532 @smallexample @c ada
11533    type Color is (Red, Green, Blue);
11534 @end smallexample
11535
11536 @noindent
11537 8 bits is sufficient to store all values of the type, so by default, objects
11538 of type @code{Color} will be represented using 8 bits.  However, normal C
11539 convention is to use 32 bits for all enum values in C, since enum values
11540 are essentially of type int.  If pragma @code{Convention C} is specified for an
11541 Ada enumeration type, then the size is modified as necessary (usually to
11542 32 bits) to be consistent with the C convention for enum values.
11543
11544 Note that this treatment applies only to types. If Convention C is given for
11545 an enumeration object, where the enumeration type is not Convention C, then
11546 Object_Size bits are allocated. For example, for a normal enumeration type,
11547 with less than 256 elements, only 8 bits will be allocated for the object.
11548 Since this may be a surprise in terms of what C expects, GNAT will issue a
11549 warning in this situation. The warning can be suppressed by giving an explicit
11550 size clause specifying the desired size.
11551
11552 @item Convention C/Fortran and Boolean types
11553 In C, the usual convention for boolean values, that is values used for
11554 conditions, is that zero represents false, and nonzero values represent
11555 true.  In Ada, the normal convention is that two specific values, typically
11556 0/1, are used to represent false/true respectively.
11557
11558 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11559 value represents true).
11560
11561 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11562 C or Fortran convention for a derived Boolean, as in the following example:
11563
11564 @smallexample @c ada
11565    type C_Switch is new Boolean;
11566    pragma Convention (C, C_Switch);
11567 @end smallexample
11568
11569 @noindent
11570 then the GNAT generated code will treat any nonzero value as true.  For truth
11571 values generated by GNAT, the conventional value 1 will be used for True, but
11572 when one of these values is read, any nonzero value is treated as True.
11573
11574 @item Access types on OpenVMS
11575 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11576 arrays) are 64-bits long. An exception to this rule is for the case of
11577 C-convention access types where there is no explicit size clause present (or
11578 inherited for derived types). In this case, GNAT chooses to make these
11579 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11580 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11581
11582 @end itemize
11583
11584 @node Determining the Representations chosen by GNAT
11585 @section Determining the Representations chosen by GNAT
11586 @cindex Representation, determination of
11587 @cindex @option{-gnatR} switch
11588
11589 @noindent
11590 Although the descriptions in this section are intended to be complete, it is
11591 often easier to simply experiment to see what GNAT accepts and what the
11592 effect is on the layout of types and objects.
11593
11594 As required by the Ada RM, if a representation clause is not accepted, then
11595 it must be rejected as illegal by the compiler.  However, when a
11596 representation clause or pragma is accepted, there can still be questions
11597 of what the compiler actually does.  For example, if a partial record
11598 representation clause specifies the location of some components and not
11599 others, then where are the non-specified components placed? Or if pragma
11600 @code{Pack} is used on a record, then exactly where are the resulting
11601 fields placed? The section on pragma @code{Pack} in this chapter can be
11602 used to answer the second question, but it is often easier to just see
11603 what the compiler does.
11604
11605 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11606 with this option, then the compiler will output information on the actual
11607 representations chosen, in a format similar to source representation
11608 clauses.  For example, if we compile the package:
11609
11610 @smallexample @c ada
11611 package q is
11612    type r (x : boolean) is tagged record
11613       case x is
11614          when True => S : String (1 .. 100);
11615          when False => null;
11616       end case;
11617    end record;
11618
11619    type r2 is new r (false) with record
11620       y2 : integer;
11621    end record;
11622
11623    for r2 use record
11624       y2 at 16 range 0 .. 31;
11625    end record;
11626
11627    type x is record
11628       y : character;
11629    end record;
11630
11631    type x1 is array (1 .. 10) of x;
11632    for x1'component_size use 11;
11633
11634    type ia is access integer;
11635
11636    type Rb1 is array (1 .. 13) of Boolean;
11637    pragma Pack (rb1);
11638
11639    type Rb2 is array (1 .. 65) of Boolean;
11640    pragma Pack (rb2);
11641
11642    type x2 is record
11643       l1 : Boolean;
11644       l2 : Duration;
11645       l3 : Float;
11646       l4 : Boolean;
11647       l5 : Rb1;
11648       l6 : Rb2;
11649    end record;
11650    pragma Pack (x2);
11651 end q;
11652 @end smallexample
11653
11654 @noindent
11655 using the switch @option{-gnatR} we obtain the following output:
11656
11657 @smallexample
11658 Representation information for unit q
11659 -------------------------------------
11660
11661 for r'Size use ??;
11662 for r'Alignment use 4;
11663 for r use record
11664    x    at 4 range  0 .. 7;
11665    _tag at 0 range  0 .. 31;
11666    s    at 5 range  0 .. 799;
11667 end record;
11668
11669 for r2'Size use 160;
11670 for r2'Alignment use 4;
11671 for r2 use record
11672    x       at  4 range  0 .. 7;
11673    _tag    at  0 range  0 .. 31;
11674    _parent at  0 range  0 .. 63;
11675    y2      at 16 range  0 .. 31;
11676 end record;
11677
11678 for x'Size use 8;
11679 for x'Alignment use 1;
11680 for x use record
11681    y at 0 range  0 .. 7;
11682 end record;
11683
11684 for x1'Size use 112;
11685 for x1'Alignment use 1;
11686 for x1'Component_Size use 11;
11687
11688 for rb1'Size use 13;
11689 for rb1'Alignment use 2;
11690 for rb1'Component_Size use 1;
11691
11692 for rb2'Size use 72;
11693 for rb2'Alignment use 1;
11694 for rb2'Component_Size use 1;
11695
11696 for x2'Size use 224;
11697 for x2'Alignment use 4;
11698 for x2 use record
11699    l1 at  0 range  0 .. 0;
11700    l2 at  0 range  1 .. 64;
11701    l3 at 12 range  0 .. 31;
11702    l4 at 16 range  0 .. 0;
11703    l5 at 16 range  1 .. 13;
11704    l6 at 18 range  0 .. 71;
11705 end record;
11706 @end smallexample
11707
11708 @noindent
11709 The Size values are actually the Object_Size, i.e.@: the default size that
11710 will be allocated for objects of the type.
11711 The ?? size for type r indicates that we have a variant record, and the
11712 actual size of objects will depend on the discriminant value.
11713
11714 The Alignment values show the actual alignment chosen by the compiler
11715 for each record or array type.
11716
11717 The record representation clause for type r shows where all fields
11718 are placed, including the compiler generated tag field (whose location
11719 cannot be controlled by the programmer).
11720
11721 The record representation clause for the type extension r2 shows all the
11722 fields present, including the parent field, which is a copy of the fields
11723 of the parent type of r2, i.e.@: r1.
11724
11725 The component size and size clauses for types rb1 and rb2 show
11726 the exact effect of pragma @code{Pack} on these arrays, and the record
11727 representation clause for type x2 shows how pragma @code{Pack} affects
11728 this record type.
11729
11730 In some cases, it may be useful to cut and paste the representation clauses
11731 generated by the compiler into the original source to fix and guarantee
11732 the actual representation to be used.
11733
11734 @node Standard Library Routines
11735 @chapter Standard Library Routines
11736
11737 @noindent
11738 The Ada Reference Manual contains in Annex A a full description of an
11739 extensive set of standard library routines that can be used in any Ada
11740 program, and which must be provided by all Ada compilers.  They are
11741 analogous to the standard C library used by C programs.
11742
11743 GNAT implements all of the facilities described in annex A, and for most
11744 purposes the description in the Ada Reference Manual, or appropriate Ada
11745 text book, will be sufficient for making use of these facilities.
11746
11747 In the case of the input-output facilities,
11748 @xref{The Implementation of Standard I/O},
11749 gives details on exactly how GNAT interfaces to the
11750 file system.  For the remaining packages, the Ada Reference Manual
11751 should be sufficient.  The following is a list of the packages included,
11752 together with a brief description of the functionality that is provided.
11753
11754 For completeness, references are included to other predefined library
11755 routines defined in other sections of the Ada Reference Manual (these are
11756 cross-indexed from Annex A).
11757
11758 @table @code
11759 @item Ada (A.2)
11760 This is a parent package for all the standard library packages.  It is
11761 usually included implicitly in your program, and itself contains no
11762 useful data or routines.
11763
11764 @item Ada.Calendar (9.6)
11765 @code{Calendar} provides time of day access, and routines for
11766 manipulating times and durations.
11767
11768 @item Ada.Characters (A.3.1)
11769 This is a dummy parent package that contains no useful entities
11770
11771 @item Ada.Characters.Handling (A.3.2)
11772 This package provides some basic character handling capabilities,
11773 including classification functions for classes of characters (e.g.@: test
11774 for letters, or digits).
11775
11776 @item Ada.Characters.Latin_1 (A.3.3)
11777 This package includes a complete set of definitions of the characters
11778 that appear in type CHARACTER@.  It is useful for writing programs that
11779 will run in international environments.  For example, if you want an
11780 upper case E with an acute accent in a string, it is often better to use
11781 the definition of @code{UC_E_Acute} in this package.  Then your program
11782 will print in an understandable manner even if your environment does not
11783 support these extended characters.
11784
11785 @item Ada.Command_Line (A.15)
11786 This package provides access to the command line parameters and the name
11787 of the current program (analogous to the use of @code{argc} and @code{argv}
11788 in C), and also allows the exit status for the program to be set in a
11789 system-independent manner.
11790
11791 @item Ada.Decimal (F.2)
11792 This package provides constants describing the range of decimal numbers
11793 implemented, and also a decimal divide routine (analogous to the COBOL
11794 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11795
11796 @item Ada.Direct_IO (A.8.4)
11797 This package provides input-output using a model of a set of records of
11798 fixed-length, containing an arbitrary definite Ada type, indexed by an
11799 integer record number.
11800
11801 @item Ada.Dynamic_Priorities (D.5)
11802 This package allows the priorities of a task to be adjusted dynamically
11803 as the task is running.
11804
11805 @item Ada.Exceptions (11.4.1)
11806 This package provides additional information on exceptions, and also
11807 contains facilities for treating exceptions as data objects, and raising
11808 exceptions with associated messages.
11809
11810 @item Ada.Finalization (7.6)
11811 This package contains the declarations and subprograms to support the
11812 use of controlled types, providing for automatic initialization and
11813 finalization (analogous to the constructors and destructors of C++)
11814
11815 @item Ada.Interrupts (C.3.2)
11816 This package provides facilities for interfacing to interrupts, which
11817 includes the set of signals or conditions that can be raised and
11818 recognized as interrupts.
11819
11820 @item Ada.Interrupts.Names (C.3.2)
11821 This package provides the set of interrupt names (actually signal
11822 or condition names) that can be handled by GNAT@.
11823
11824 @item Ada.IO_Exceptions (A.13)
11825 This package defines the set of exceptions that can be raised by use of
11826 the standard IO packages.
11827
11828 @item Ada.Numerics
11829 This package contains some standard constants and exceptions used
11830 throughout the numerics packages.  Note that the constants pi and e are
11831 defined here, and it is better to use these definitions than rolling
11832 your own.
11833
11834 @item Ada.Numerics.Complex_Elementary_Functions
11835 Provides the implementation of standard elementary functions (such as
11836 log and trigonometric functions) operating on complex numbers using the
11837 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11838 created by the package @code{Numerics.Complex_Types}.
11839
11840 @item Ada.Numerics.Complex_Types
11841 This is a predefined instantiation of
11842 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11843 build the type @code{Complex} and @code{Imaginary}.
11844
11845 @item Ada.Numerics.Discrete_Random
11846 This package provides a random number generator suitable for generating
11847 random integer values from a specified range.
11848
11849 @item Ada.Numerics.Float_Random
11850 This package provides a random number generator suitable for generating
11851 uniformly distributed floating point values.
11852
11853 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11854 This is a generic version of the package that provides the
11855 implementation of standard elementary functions (such as log and
11856 trigonometric functions) for an arbitrary complex type.
11857
11858 The following predefined instantiations of this package are provided:
11859
11860 @table @code
11861 @item Short_Float
11862 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11863 @item Float
11864 @code{Ada.Numerics.Complex_Elementary_Functions}
11865 @item Long_Float
11866 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11867 @end table
11868
11869 @item Ada.Numerics.Generic_Complex_Types
11870 This is a generic package that allows the creation of complex types,
11871 with associated complex arithmetic operations.
11872
11873 The following predefined instantiations of this package exist
11874 @table @code
11875 @item Short_Float
11876 @code{Ada.Numerics.Short_Complex_Complex_Types}
11877 @item Float
11878 @code{Ada.Numerics.Complex_Complex_Types}
11879 @item Long_Float
11880 @code{Ada.Numerics.Long_Complex_Complex_Types}
11881 @end table
11882
11883 @item Ada.Numerics.Generic_Elementary_Functions
11884 This is a generic package that provides the implementation of standard
11885 elementary functions (such as log an trigonometric functions) for an
11886 arbitrary float type.
11887
11888 The following predefined instantiations of this package exist
11889
11890 @table @code
11891 @item Short_Float
11892 @code{Ada.Numerics.Short_Elementary_Functions}
11893 @item Float
11894 @code{Ada.Numerics.Elementary_Functions}
11895 @item Long_Float
11896 @code{Ada.Numerics.Long_Elementary_Functions}
11897 @end table
11898
11899 @item Ada.Real_Time (D.8)
11900 This package provides facilities similar to those of @code{Calendar}, but
11901 operating with a finer clock suitable for real time control. Note that
11902 annex D requires that there be no backward clock jumps, and GNAT generally
11903 guarantees this behavior, but of course if the external clock on which
11904 the GNAT runtime depends is deliberately reset by some external event,
11905 then such a backward jump may occur.
11906
11907 @item Ada.Sequential_IO (A.8.1)
11908 This package provides input-output facilities for sequential files,
11909 which can contain a sequence of values of a single type, which can be
11910 any Ada type, including indefinite (unconstrained) types.
11911
11912 @item Ada.Storage_IO (A.9)
11913 This package provides a facility for mapping arbitrary Ada types to and
11914 from a storage buffer.  It is primarily intended for the creation of new
11915 IO packages.
11916
11917 @item Ada.Streams (13.13.1)
11918 This is a generic package that provides the basic support for the
11919 concept of streams as used by the stream attributes (@code{Input},
11920 @code{Output}, @code{Read} and @code{Write}).
11921
11922 @item Ada.Streams.Stream_IO (A.12.1)
11923 This package is a specialization of the type @code{Streams} defined in
11924 package @code{Streams} together with a set of operations providing
11925 Stream_IO capability.  The Stream_IO model permits both random and
11926 sequential access to a file which can contain an arbitrary set of values
11927 of one or more Ada types.
11928
11929 @item Ada.Strings (A.4.1)
11930 This package provides some basic constants used by the string handling
11931 packages.
11932
11933 @item Ada.Strings.Bounded (A.4.4)
11934 This package provides facilities for handling variable length
11935 strings.  The bounded model requires a maximum length.  It is thus
11936 somewhat more limited than the unbounded model, but avoids the use of
11937 dynamic allocation or finalization.
11938
11939 @item Ada.Strings.Fixed (A.4.3)
11940 This package provides facilities for handling fixed length strings.
11941
11942 @item Ada.Strings.Maps (A.4.2)
11943 This package provides facilities for handling character mappings and
11944 arbitrarily defined subsets of characters.  For instance it is useful in
11945 defining specialized translation tables.
11946
11947 @item Ada.Strings.Maps.Constants (A.4.6)
11948 This package provides a standard set of predefined mappings and
11949 predefined character sets.  For example, the standard upper to lower case
11950 conversion table is found in this package.  Note that upper to lower case
11951 conversion is non-trivial if you want to take the entire set of
11952 characters, including extended characters like E with an acute accent,
11953 into account.  You should use the mappings in this package (rather than
11954 adding 32 yourself) to do case mappings.
11955
11956 @item Ada.Strings.Unbounded (A.4.5)
11957 This package provides facilities for handling variable length
11958 strings.  The unbounded model allows arbitrary length strings, but
11959 requires the use of dynamic allocation and finalization.
11960
11961 @item Ada.Strings.Wide_Bounded (A.4.7)
11962 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11963 @itemx Ada.Strings.Wide_Maps (A.4.7)
11964 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11965 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11966 These packages provide analogous capabilities to the corresponding
11967 packages without @samp{Wide_} in the name, but operate with the types
11968 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11969 and @code{Character}.
11970
11971 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11972 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11973 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11974 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11975 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11976 These packages provide analogous capabilities to the corresponding
11977 packages without @samp{Wide_} in the name, but operate with the types
11978 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11979 of @code{String} and @code{Character}.
11980
11981 @item Ada.Synchronous_Task_Control (D.10)
11982 This package provides some standard facilities for controlling task
11983 communication in a synchronous manner.
11984
11985 @item Ada.Tags
11986 This package contains definitions for manipulation of the tags of tagged
11987 values.
11988
11989 @item Ada.Task_Attributes
11990 This package provides the capability of associating arbitrary
11991 task-specific data with separate tasks.
11992
11993 @item Ada.Text_IO
11994 This package provides basic text input-output capabilities for
11995 character, string and numeric data.  The subpackages of this
11996 package are listed next.
11997
11998 @item Ada.Text_IO.Decimal_IO
11999 Provides input-output facilities for decimal fixed-point types
12000
12001 @item Ada.Text_IO.Enumeration_IO
12002 Provides input-output facilities for enumeration types.
12003
12004 @item Ada.Text_IO.Fixed_IO
12005 Provides input-output facilities for ordinary fixed-point types.
12006
12007 @item Ada.Text_IO.Float_IO
12008 Provides input-output facilities for float types.  The following
12009 predefined instantiations of this generic package are available:
12010
12011 @table @code
12012 @item Short_Float
12013 @code{Short_Float_Text_IO}
12014 @item Float
12015 @code{Float_Text_IO}
12016 @item Long_Float
12017 @code{Long_Float_Text_IO}
12018 @end table
12019
12020 @item Ada.Text_IO.Integer_IO
12021 Provides input-output facilities for integer types.  The following
12022 predefined instantiations of this generic package are available:
12023
12024 @table @code
12025 @item Short_Short_Integer
12026 @code{Ada.Short_Short_Integer_Text_IO}
12027 @item Short_Integer
12028 @code{Ada.Short_Integer_Text_IO}
12029 @item Integer
12030 @code{Ada.Integer_Text_IO}
12031 @item Long_Integer
12032 @code{Ada.Long_Integer_Text_IO}
12033 @item Long_Long_Integer
12034 @code{Ada.Long_Long_Integer_Text_IO}
12035 @end table
12036
12037 @item Ada.Text_IO.Modular_IO
12038 Provides input-output facilities for modular (unsigned) types
12039
12040 @item Ada.Text_IO.Complex_IO (G.1.3)
12041 This package provides basic text input-output capabilities for complex
12042 data.
12043
12044 @item Ada.Text_IO.Editing (F.3.3)
12045 This package contains routines for edited output, analogous to the use
12046 of pictures in COBOL@.  The picture formats used by this package are a
12047 close copy of the facility in COBOL@.
12048
12049 @item Ada.Text_IO.Text_Streams (A.12.2)
12050 This package provides a facility that allows Text_IO files to be treated
12051 as streams, so that the stream attributes can be used for writing
12052 arbitrary data, including binary data, to Text_IO files.
12053
12054 @item Ada.Unchecked_Conversion (13.9)
12055 This generic package allows arbitrary conversion from one type to
12056 another of the same size, providing for breaking the type safety in
12057 special circumstances.
12058
12059 If the types have the same Size (more accurately the same Value_Size),
12060 then the effect is simply to transfer the bits from the source to the
12061 target type without any modification.  This usage is well defined, and
12062 for simple types whose representation is typically the same across
12063 all implementations, gives a portable method of performing such
12064 conversions.
12065
12066 If the types do not have the same size, then the result is implementation
12067 defined, and thus may be non-portable.  The following describes how GNAT
12068 handles such unchecked conversion cases.
12069
12070 If the types are of different sizes, and are both discrete types, then
12071 the effect is of a normal type conversion without any constraint checking.
12072 In particular if the result type has a larger size, the result will be
12073 zero or sign extended.  If the result type has a smaller size, the result
12074 will be truncated by ignoring high order bits.
12075
12076 If the types are of different sizes, and are not both discrete types,
12077 then the conversion works as though pointers were created to the source
12078 and target, and the pointer value is converted.  The effect is that bits
12079 are copied from successive low order storage units and bits of the source
12080 up to the length of the target type.
12081
12082 A warning is issued if the lengths differ, since the effect in this
12083 case is implementation dependent, and the above behavior may not match
12084 that of some other compiler.
12085
12086 A pointer to one type may be converted to a pointer to another type using
12087 unchecked conversion.  The only case in which the effect is undefined is
12088 when one or both pointers are pointers to unconstrained array types.  In
12089 this case, the bounds information may get incorrectly transferred, and in
12090 particular, GNAT uses double size pointers for such types, and it is
12091 meaningless to convert between such pointer types.  GNAT will issue a
12092 warning if the alignment of the target designated type is more strict
12093 than the alignment of the source designated type (since the result may
12094 be unaligned in this case).
12095
12096 A pointer other than a pointer to an unconstrained array type may be
12097 converted to and from System.Address.  Such usage is common in Ada 83
12098 programs, but note that Ada.Address_To_Access_Conversions is the
12099 preferred method of performing such conversions in Ada 95 and Ada 2005.
12100 Neither
12101 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12102 used in conjunction with pointers to unconstrained objects, since
12103 the bounds information cannot be handled correctly in this case.
12104
12105 @item Ada.Unchecked_Deallocation (13.11.2)
12106 This generic package allows explicit freeing of storage previously
12107 allocated by use of an allocator.
12108
12109 @item Ada.Wide_Text_IO (A.11)
12110 This package is similar to @code{Ada.Text_IO}, except that the external
12111 file supports wide character representations, and the internal types are
12112 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12113 and @code{String}.  It contains generic subpackages listed next.
12114
12115 @item Ada.Wide_Text_IO.Decimal_IO
12116 Provides input-output facilities for decimal fixed-point types
12117
12118 @item Ada.Wide_Text_IO.Enumeration_IO
12119 Provides input-output facilities for enumeration types.
12120
12121 @item Ada.Wide_Text_IO.Fixed_IO
12122 Provides input-output facilities for ordinary fixed-point types.
12123
12124 @item Ada.Wide_Text_IO.Float_IO
12125 Provides input-output facilities for float types.  The following
12126 predefined instantiations of this generic package are available:
12127
12128 @table @code
12129 @item Short_Float
12130 @code{Short_Float_Wide_Text_IO}
12131 @item Float
12132 @code{Float_Wide_Text_IO}
12133 @item Long_Float
12134 @code{Long_Float_Wide_Text_IO}
12135 @end table
12136
12137 @item Ada.Wide_Text_IO.Integer_IO
12138 Provides input-output facilities for integer types.  The following
12139 predefined instantiations of this generic package are available:
12140
12141 @table @code
12142 @item Short_Short_Integer
12143 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12144 @item Short_Integer
12145 @code{Ada.Short_Integer_Wide_Text_IO}
12146 @item Integer
12147 @code{Ada.Integer_Wide_Text_IO}
12148 @item Long_Integer
12149 @code{Ada.Long_Integer_Wide_Text_IO}
12150 @item Long_Long_Integer
12151 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12152 @end table
12153
12154 @item Ada.Wide_Text_IO.Modular_IO
12155 Provides input-output facilities for modular (unsigned) types
12156
12157 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12158 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12159 external file supports wide character representations.
12160
12161 @item Ada.Wide_Text_IO.Editing (F.3.4)
12162 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12163 types are @code{Wide_Character} and @code{Wide_String} instead of
12164 @code{Character} and @code{String}.
12165
12166 @item Ada.Wide_Text_IO.Streams (A.12.3)
12167 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12168 types are @code{Wide_Character} and @code{Wide_String} instead of
12169 @code{Character} and @code{String}.
12170
12171 @item Ada.Wide_Wide_Text_IO (A.11)
12172 This package is similar to @code{Ada.Text_IO}, except that the external
12173 file supports wide character representations, and the internal types are
12174 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12175 and @code{String}.  It contains generic subpackages listed next.
12176
12177 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12178 Provides input-output facilities for decimal fixed-point types
12179
12180 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12181 Provides input-output facilities for enumeration types.
12182
12183 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12184 Provides input-output facilities for ordinary fixed-point types.
12185
12186 @item Ada.Wide_Wide_Text_IO.Float_IO
12187 Provides input-output facilities for float types.  The following
12188 predefined instantiations of this generic package are available:
12189
12190 @table @code
12191 @item Short_Float
12192 @code{Short_Float_Wide_Wide_Text_IO}
12193 @item Float
12194 @code{Float_Wide_Wide_Text_IO}
12195 @item Long_Float
12196 @code{Long_Float_Wide_Wide_Text_IO}
12197 @end table
12198
12199 @item Ada.Wide_Wide_Text_IO.Integer_IO
12200 Provides input-output facilities for integer types.  The following
12201 predefined instantiations of this generic package are available:
12202
12203 @table @code
12204 @item Short_Short_Integer
12205 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12206 @item Short_Integer
12207 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12208 @item Integer
12209 @code{Ada.Integer_Wide_Wide_Text_IO}
12210 @item Long_Integer
12211 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12212 @item Long_Long_Integer
12213 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12214 @end table
12215
12216 @item Ada.Wide_Wide_Text_IO.Modular_IO
12217 Provides input-output facilities for modular (unsigned) types
12218
12219 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12220 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12221 external file supports wide character representations.
12222
12223 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12224 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12225 types are @code{Wide_Character} and @code{Wide_String} instead of
12226 @code{Character} and @code{String}.
12227
12228 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12229 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12230 types are @code{Wide_Character} and @code{Wide_String} instead of
12231 @code{Character} and @code{String}.
12232 @end table
12233
12234
12235
12236 @node The Implementation of Standard I/O
12237 @chapter The Implementation of Standard I/O
12238
12239 @noindent
12240 GNAT implements all the required input-output facilities described in
12241 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12242 required behavior of these packages from the Ada point of view, and if
12243 you are writing a portable Ada program that does not need to know the
12244 exact manner in which Ada maps to the outside world when it comes to
12245 reading or writing external files, then you do not need to read this
12246 chapter.  As long as your files are all regular files (not pipes or
12247 devices), and as long as you write and read the files only from Ada, the
12248 description in the Ada Reference Manual is sufficient.
12249
12250 However, if you want to do input-output to pipes or other devices, such
12251 as the keyboard or screen, or if the files you are dealing with are
12252 either generated by some other language, or to be read by some other
12253 language, then you need to know more about the details of how the GNAT
12254 implementation of these input-output facilities behaves.
12255
12256 In this chapter we give a detailed description of exactly how GNAT
12257 interfaces to the file system.  As always, the sources of the system are
12258 available to you for answering questions at an even more detailed level,
12259 but for most purposes the information in this chapter will suffice.
12260
12261 Another reason that you may need to know more about how input-output is
12262 implemented arises when you have a program written in mixed languages
12263 where, for example, files are shared between the C and Ada sections of
12264 the same program.  GNAT provides some additional facilities, in the form
12265 of additional child library packages, that facilitate this sharing, and
12266 these additional facilities are also described in this chapter.
12267
12268 @menu
12269 * Standard I/O Packages::
12270 * FORM Strings::
12271 * Direct_IO::
12272 * Sequential_IO::
12273 * Text_IO::
12274 * Wide_Text_IO::
12275 * Wide_Wide_Text_IO::
12276 * Stream_IO::
12277 * Text Translation::
12278 * Shared Files::
12279 * Filenames encoding::
12280 * Open Modes::
12281 * Operations on C Streams::
12282 * Interfacing to C Streams::
12283 @end menu
12284
12285 @node Standard I/O Packages
12286 @section Standard I/O Packages
12287
12288 @noindent
12289 The Standard I/O packages described in Annex A for
12290
12291 @itemize @bullet
12292 @item
12293 Ada.Text_IO
12294 @item
12295 Ada.Text_IO.Complex_IO
12296 @item
12297 Ada.Text_IO.Text_Streams
12298 @item
12299 Ada.Wide_Text_IO
12300 @item
12301 Ada.Wide_Text_IO.Complex_IO
12302 @item
12303 Ada.Wide_Text_IO.Text_Streams
12304 @item
12305 Ada.Wide_Wide_Text_IO
12306 @item
12307 Ada.Wide_Wide_Text_IO.Complex_IO
12308 @item
12309 Ada.Wide_Wide_Text_IO.Text_Streams
12310 @item
12311 Ada.Stream_IO
12312 @item
12313 Ada.Sequential_IO
12314 @item
12315 Ada.Direct_IO
12316 @end itemize
12317
12318 @noindent
12319 are implemented using the C
12320 library streams facility; where
12321
12322 @itemize @bullet
12323 @item
12324 All files are opened using @code{fopen}.
12325 @item
12326 All input/output operations use @code{fread}/@code{fwrite}.
12327 @end itemize
12328
12329 @noindent
12330 There is no internal buffering of any kind at the Ada library level. The only
12331 buffering is that provided at the system level in the implementation of the
12332 library routines that support streams. This facilitates shared use of these
12333 streams by mixed language programs. Note though that system level buffering is
12334 explicitly enabled at elaboration of the standard I/O packages and that can
12335 have an impact on mixed language programs, in particular those using I/O before
12336 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12337 the Ada elaboration routine before performing any I/O or when impractical,
12338 flush the common I/O streams and in particular Standard_Output before
12339 elaborating the Ada code.
12340
12341 @node FORM Strings
12342 @section FORM Strings
12343
12344 @noindent
12345 The format of a FORM string in GNAT is:
12346
12347 @smallexample
12348 "keyword=value,keyword=value,@dots{},keyword=value"
12349 @end smallexample
12350
12351 @noindent
12352 where letters may be in upper or lower case, and there are no spaces
12353 between values.  The order of the entries is not important.  Currently
12354 the following keywords defined.
12355
12356 @smallexample
12357 TEXT_TRANSLATION=[YES|NO]
12358 SHARED=[YES|NO]
12359 WCEM=[n|h|u|s|e|8|b]
12360 ENCODING=[UTF8|8BITS]
12361 @end smallexample
12362
12363 @noindent
12364 The use of these parameters is described later in this section.
12365
12366 @node Direct_IO
12367 @section Direct_IO
12368
12369 @noindent
12370 Direct_IO can only be instantiated for definite types.  This is a
12371 restriction of the Ada language, which means that the records are fixed
12372 length (the length being determined by @code{@var{type}'Size}, rounded
12373 up to the next storage unit boundary if necessary).
12374
12375 The records of a Direct_IO file are simply written to the file in index
12376 sequence, with the first record starting at offset zero, and subsequent
12377 records following.  There is no control information of any kind.  For
12378 example, if 32-bit integers are being written, each record takes
12379 4-bytes, so the record at index @var{K} starts at offset
12380 (@var{K}@minus{}1)*4.
12381
12382 There is no limit on the size of Direct_IO files, they are expanded as
12383 necessary to accommodate whatever records are written to the file.
12384
12385 @node Sequential_IO
12386 @section Sequential_IO
12387
12388 @noindent
12389 Sequential_IO may be instantiated with either a definite (constrained)
12390 or indefinite (unconstrained) type.
12391
12392 For the definite type case, the elements written to the file are simply
12393 the memory images of the data values with no control information of any
12394 kind.  The resulting file should be read using the same type, no validity
12395 checking is performed on input.
12396
12397 For the indefinite type case, the elements written consist of two
12398 parts.  First is the size of the data item, written as the memory image
12399 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12400 the data value.  The resulting file can only be read using the same
12401 (unconstrained) type.  Normal assignment checks are performed on these
12402 read operations, and if these checks fail, @code{Data_Error} is
12403 raised.  In particular, in the array case, the lengths must match, and in
12404 the variant record case, if the variable for a particular read operation
12405 is constrained, the discriminants must match.
12406
12407 Note that it is not possible to use Sequential_IO to write variable
12408 length array items, and then read the data back into different length
12409 arrays.  For example, the following will raise @code{Data_Error}:
12410
12411 @smallexample @c ada
12412  package IO is new Sequential_IO (String);
12413  F : IO.File_Type;
12414  S : String (1..4);
12415  @dots{}
12416  IO.Create (F)
12417  IO.Write (F, "hello!")
12418  IO.Reset (F, Mode=>In_File);
12419  IO.Read (F, S);
12420  Put_Line (S);
12421
12422 @end smallexample
12423
12424 @noindent
12425 On some Ada implementations, this will print @code{hell}, but the program is
12426 clearly incorrect, since there is only one element in the file, and that
12427 element is the string @code{hello!}.
12428
12429 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12430 using Stream_IO, and this is the preferred mechanism.  In particular, the
12431 above program fragment rewritten to use Stream_IO will work correctly.
12432
12433 @node Text_IO
12434 @section Text_IO
12435
12436 @noindent
12437 Text_IO files consist of a stream of characters containing the following
12438 special control characters:
12439
12440 @smallexample
12441 LF (line feed, 16#0A#) Line Mark
12442 FF (form feed, 16#0C#) Page Mark
12443 @end smallexample
12444
12445 @noindent
12446 A canonical Text_IO file is defined as one in which the following
12447 conditions are met:
12448
12449 @itemize @bullet
12450 @item
12451 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12452 of the line.
12453
12454 @item
12455 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12456 end of a page and consequently can appear only immediately following a
12457 @code{LF} (line mark) character.
12458
12459 @item
12460 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12461 (line mark, page mark).  In the former case, the page mark is implicitly
12462 assumed to be present.
12463 @end itemize
12464
12465 @noindent
12466 A file written using Text_IO will be in canonical form provided that no
12467 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12468 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12469 the file unless an explicit @code{New_Page} operation was performed
12470 before closing the file.
12471
12472 A canonical Text_IO file that is a regular file (i.e., not a device or a
12473 pipe) can be read using any of the routines in Text_IO@.  The
12474 semantics in this case will be exactly as defined in the Ada Reference
12475 Manual, and all the routines in Text_IO are fully implemented.
12476
12477 A text file that does not meet the requirements for a canonical Text_IO
12478 file has one of the following:
12479
12480 @itemize @bullet
12481 @item
12482 The file contains @code{FF} characters not immediately following a
12483 @code{LF} character.
12484
12485 @item
12486 The file contains @code{LF} or @code{FF} characters written by
12487 @code{Put} or @code{Put_Line}, which are not logically considered to be
12488 line marks or page marks.
12489
12490 @item
12491 The file ends in a character other than @code{LF} or @code{FF},
12492 i.e.@: there is no explicit line mark or page mark at the end of the file.
12493 @end itemize
12494
12495 @noindent
12496 Text_IO can be used to read such non-standard text files but subprograms
12497 to do with line or page numbers do not have defined meanings.  In
12498 particular, a @code{FF} character that does not follow a @code{LF}
12499 character may or may not be treated as a page mark from the point of
12500 view of page and line numbering.  Every @code{LF} character is considered
12501 to end a line, and there is an implied @code{LF} character at the end of
12502 the file.
12503
12504 @menu
12505 * Text_IO Stream Pointer Positioning::
12506 * Text_IO Reading and Writing Non-Regular Files::
12507 * Get_Immediate::
12508 * Treating Text_IO Files as Streams::
12509 * Text_IO Extensions::
12510 * Text_IO Facilities for Unbounded Strings::
12511 @end menu
12512
12513 @node Text_IO Stream Pointer Positioning
12514 @subsection Stream Pointer Positioning
12515
12516 @noindent
12517 @code{Ada.Text_IO} has a definition of current position for a file that
12518 is being read.  No internal buffering occurs in Text_IO, and usually the
12519 physical position in the stream used to implement the file corresponds
12520 to this logical position defined by Text_IO@.  There are two exceptions:
12521
12522 @itemize @bullet
12523 @item
12524 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12525 is positioned past the @code{LF} (line mark) that precedes the page
12526 mark.  Text_IO maintains an internal flag so that subsequent read
12527 operations properly handle the logical position which is unchanged by
12528 the @code{End_Of_Page} call.
12529
12530 @item
12531 After a call to @code{End_Of_File} that returns @code{True}, if the
12532 Text_IO file was positioned before the line mark at the end of file
12533 before the call, then the logical position is unchanged, but the stream
12534 is physically positioned right at the end of file (past the line mark,
12535 and past a possible page mark following the line mark.  Again Text_IO
12536 maintains internal flags so that subsequent read operations properly
12537 handle the logical position.
12538 @end itemize
12539
12540 @noindent
12541 These discrepancies have no effect on the observable behavior of
12542 Text_IO, but if a single Ada stream is shared between a C program and
12543 Ada program, or shared (using @samp{shared=yes} in the form string)
12544 between two Ada files, then the difference may be observable in some
12545 situations.
12546
12547 @node Text_IO Reading and Writing Non-Regular Files
12548 @subsection Reading and Writing Non-Regular Files
12549
12550 @noindent
12551 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12552 can be used for reading and writing.  Writing is not affected and the
12553 sequence of characters output is identical to the normal file case, but
12554 for reading, the behavior of Text_IO is modified to avoid undesirable
12555 look-ahead as follows:
12556
12557 An input file that is not a regular file is considered to have no page
12558 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12559 page mark) appearing in the file are considered to be data
12560 characters.  In particular:
12561
12562 @itemize @bullet
12563 @item
12564 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12565 following a line mark.  If a page mark appears, it will be treated as a
12566 data character.
12567
12568 @item
12569 This avoids the need to wait for an extra character to be typed or
12570 entered from the pipe to complete one of these operations.
12571
12572 @item
12573 @code{End_Of_Page} always returns @code{False}
12574
12575 @item
12576 @code{End_Of_File} will return @code{False} if there is a page mark at
12577 the end of the file.
12578 @end itemize
12579
12580 @noindent
12581 Output to non-regular files is the same as for regular files.  Page marks
12582 may be written to non-regular files using @code{New_Page}, but as noted
12583 above they will not be treated as page marks on input if the output is
12584 piped to another Ada program.
12585
12586 Another important discrepancy when reading non-regular files is that the end
12587 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12588 pressing the @key{EOT} key,
12589 then end of file
12590 is signaled once (i.e.@: the test @code{End_Of_File}
12591 will yield @code{True}, or a read will
12592 raise @code{End_Error}), but then reading can resume
12593 to read data past that end of
12594 file indication, until another end of file indication is entered.
12595
12596 @node Get_Immediate
12597 @subsection Get_Immediate
12598 @cindex Get_Immediate
12599
12600 @noindent
12601 Get_Immediate returns the next character (including control characters)
12602 from the input file.  In particular, Get_Immediate will return LF or FF
12603 characters used as line marks or page marks.  Such operations leave the
12604 file positioned past the control character, and it is thus not treated
12605 as having its normal function.  This means that page, line and column
12606 counts after this kind of Get_Immediate call are set as though the mark
12607 did not occur.  In the case where a Get_Immediate leaves the file
12608 positioned between the line mark and page mark (which is not normally
12609 possible), it is undefined whether the FF character will be treated as a
12610 page mark.
12611
12612 @node Treating Text_IO Files as Streams
12613 @subsection Treating Text_IO Files as Streams
12614 @cindex Stream files
12615
12616 @noindent
12617 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12618 as a stream.  Data written to a Text_IO file in this stream mode is
12619 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12620 16#0C# (@code{FF}), the resulting file may have non-standard
12621 format.  Similarly if read operations are used to read from a Text_IO
12622 file treated as a stream, then @code{LF} and @code{FF} characters may be
12623 skipped and the effect is similar to that described above for
12624 @code{Get_Immediate}.
12625
12626 @node Text_IO Extensions
12627 @subsection Text_IO Extensions
12628 @cindex Text_IO extensions
12629
12630 @noindent
12631 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12632 to the standard @code{Text_IO} package:
12633
12634 @itemize @bullet
12635 @item function File_Exists (Name : String) return Boolean;
12636 Determines if a file of the given name exists.
12637
12638 @item function Get_Line return String;
12639 Reads a string from the standard input file.  The value returned is exactly
12640 the length of the line that was read.
12641
12642 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12643 Similar, except that the parameter File specifies the file from which
12644 the string is to be read.
12645
12646 @end itemize
12647
12648 @node Text_IO Facilities for Unbounded Strings
12649 @subsection Text_IO Facilities for Unbounded Strings
12650 @cindex Text_IO for unbounded strings
12651 @cindex Unbounded_String, Text_IO operations
12652
12653 @noindent
12654 The package @code{Ada.Strings.Unbounded.Text_IO}
12655 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12656 subprograms useful for Text_IO operations on unbounded strings:
12657
12658 @itemize @bullet
12659
12660 @item function Get_Line (File : File_Type) return Unbounded_String;
12661 Reads a line from the specified file
12662 and returns the result as an unbounded string.
12663
12664 @item procedure Put (File : File_Type; U : Unbounded_String);
12665 Writes the value of the given unbounded string to the specified file
12666 Similar to the effect of
12667 @code{Put (To_String (U))} except that an extra copy is avoided.
12668
12669 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12670 Writes the value of the given unbounded string to the specified file,
12671 followed by a @code{New_Line}.
12672 Similar to the effect of @code{Put_Line (To_String (U))} except
12673 that an extra copy is avoided.
12674 @end itemize
12675
12676 @noindent
12677 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12678 and is optional.  If the parameter is omitted, then the standard input or
12679 output file is referenced as appropriate.
12680
12681 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12682 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12683 @code{Wide_Text_IO} functionality for unbounded wide strings.
12684
12685 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12686 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12687 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12688
12689 @node Wide_Text_IO
12690 @section Wide_Text_IO
12691
12692 @noindent
12693 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12694 both input and output files may contain special sequences that represent
12695 wide character values.  The encoding scheme for a given file may be
12696 specified using a FORM parameter:
12697
12698 @smallexample
12699 WCEM=@var{x}
12700 @end smallexample
12701
12702 @noindent
12703 as part of the FORM string (WCEM = wide character encoding method),
12704 where @var{x} is one of the following characters
12705
12706 @table @samp
12707 @item h
12708 Hex ESC encoding
12709 @item u
12710 Upper half encoding
12711 @item s
12712 Shift-JIS encoding
12713 @item e
12714 EUC Encoding
12715 @item 8
12716 UTF-8 encoding
12717 @item b
12718 Brackets encoding
12719 @end table
12720
12721 @noindent
12722 The encoding methods match those that
12723 can be used in a source
12724 program, but there is no requirement that the encoding method used for
12725 the source program be the same as the encoding method used for files,
12726 and different files may use different encoding methods.
12727
12728 The default encoding method for the standard files, and for opened files
12729 for which no WCEM parameter is given in the FORM string matches the
12730 wide character encoding specified for the main program (the default
12731 being brackets encoding if no coding method was specified with -gnatW).
12732
12733 @table @asis
12734 @item Hex Coding
12735 In this encoding, a wide character is represented by a five character
12736 sequence:
12737
12738 @smallexample
12739 ESC a b c d
12740 @end smallexample
12741
12742 @noindent
12743 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12744 characters (using upper case letters) of the wide character code.  For
12745 example, ESC A345 is used to represent the wide character with code
12746 16#A345#.  This scheme is compatible with use of the full
12747 @code{Wide_Character} set.
12748
12749 @item Upper Half Coding
12750 The wide character with encoding 16#abcd#, where the upper bit is on
12751 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12752 16#cd#.  The second byte may never be a format control character, but is
12753 not required to be in the upper half.  This method can be also used for
12754 shift-JIS or EUC where the internal coding matches the external coding.
12755
12756 @item Shift JIS Coding
12757 A wide character is represented by a two character sequence 16#ab# and
12758 16#cd#, with the restrictions described for upper half encoding as
12759 described above.  The internal character code is the corresponding JIS
12760 character according to the standard algorithm for Shift-JIS
12761 conversion.  Only characters defined in the JIS code set table can be
12762 used with this encoding method.
12763
12764 @item EUC Coding
12765 A wide character is represented by a two character sequence 16#ab# and
12766 16#cd#, with both characters being in the upper half.  The internal
12767 character code is the corresponding JIS character according to the EUC
12768 encoding algorithm.  Only characters defined in the JIS code set table
12769 can be used with this encoding method.
12770
12771 @item UTF-8 Coding
12772 A wide character is represented using
12773 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12774 10646-1/Am.2.  Depending on the character value, the representation
12775 is a one, two, or three byte sequence:
12776
12777 @smallexample
12778 16#0000#-16#007f#: 2#0xxxxxxx#
12779 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12780 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12781 @end smallexample
12782
12783 @noindent
12784 where the @var{xxx} bits correspond to the left-padded bits of the
12785 16-bit character value.  Note that all lower half ASCII characters
12786 are represented as ASCII bytes and all upper half characters and
12787 other wide characters are represented as sequences of upper-half
12788 (The full UTF-8 scheme allows for encoding 31-bit characters as
12789 6-byte sequences, but in this implementation, all UTF-8 sequences
12790 of four or more bytes length will raise a Constraint_Error, as
12791 will all invalid UTF-8 sequences.)
12792
12793 @item Brackets Coding
12794 In this encoding, a wide character is represented by the following eight
12795 character sequence:
12796
12797 @smallexample
12798 [ " a b c d " ]
12799 @end smallexample
12800
12801 @noindent
12802 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12803 characters (using uppercase letters) of the wide character code.  For
12804 example, @code{["A345"]} is used to represent the wide character with code
12805 @code{16#A345#}.
12806 This scheme is compatible with use of the full Wide_Character set.
12807 On input, brackets coding can also be used for upper half characters,
12808 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12809 is only used for wide characters with a code greater than @code{16#FF#}.
12810
12811 Note that brackets coding is not normally used in the context of
12812 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12813 a portable way of encoding source files. In the context of Wide_Text_IO
12814 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12815 any instance of the left bracket character other than to encode wide
12816 character values using the brackets encoding method. In practice it is
12817 expected that some standard wide character encoding method such
12818 as UTF-8 will be used for text input output.
12819
12820 If brackets notation is used, then any occurrence of a left bracket
12821 in the input file which is not the start of a valid wide character
12822 sequence will cause Constraint_Error to be raised. It is possible to
12823 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12824 input will interpret this as a left bracket.
12825
12826 However, when a left bracket is output, it will be output as a left bracket
12827 and not as ["5B"]. We make this decision because for normal use of
12828 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12829 brackets. For example, if we write:
12830
12831 @smallexample
12832    Put_Line ("Start of output [first run]");
12833 @end smallexample
12834
12835 @noindent
12836 we really do not want to have the left bracket in this message clobbered so
12837 that the output reads:
12838
12839 @smallexample
12840    Start of output ["5B"]first run]
12841 @end smallexample
12842
12843 @noindent
12844 In practice brackets encoding is reasonably useful for normal Put_Line use
12845 since we won't get confused between left brackets and wide character
12846 sequences in the output. But for input, or when files are written out
12847 and read back in, it really makes better sense to use one of the standard
12848 encoding methods such as UTF-8.
12849
12850 @end table
12851
12852 @noindent
12853 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12854 not all wide character
12855 values can be represented.  An attempt to output a character that cannot
12856 be represented using the encoding scheme for the file causes
12857 Constraint_Error to be raised.  An invalid wide character sequence on
12858 input also causes Constraint_Error to be raised.
12859
12860 @menu
12861 * Wide_Text_IO Stream Pointer Positioning::
12862 * Wide_Text_IO Reading and Writing Non-Regular Files::
12863 @end menu
12864
12865 @node Wide_Text_IO Stream Pointer Positioning
12866 @subsection Stream Pointer Positioning
12867
12868 @noindent
12869 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12870 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12871 case:
12872
12873 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12874 normal lower ASCII set (i.e.@: a character in the range:
12875
12876 @smallexample @c ada
12877 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12878 @end smallexample
12879
12880 @noindent
12881 then although the logical position of the file pointer is unchanged by
12882 the @code{Look_Ahead} call, the stream is physically positioned past the
12883 wide character sequence.  Again this is to avoid the need for buffering
12884 or backup, and all @code{Wide_Text_IO} routines check the internal
12885 indication that this situation has occurred so that this is not visible
12886 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12887 can be observed if the wide text file shares a stream with another file.
12888
12889 @node Wide_Text_IO Reading and Writing Non-Regular Files
12890 @subsection Reading and Writing Non-Regular Files
12891
12892 @noindent
12893 As in the case of Text_IO, when a non-regular file is read, it is
12894 assumed that the file contains no page marks (any form characters are
12895 treated as data characters), and @code{End_Of_Page} always returns
12896 @code{False}.  Similarly, the end of file indication is not sticky, so
12897 it is possible to read beyond an end of file.
12898
12899 @node Wide_Wide_Text_IO
12900 @section Wide_Wide_Text_IO
12901
12902 @noindent
12903 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12904 both input and output files may contain special sequences that represent
12905 wide wide character values.  The encoding scheme for a given file may be
12906 specified using a FORM parameter:
12907
12908 @smallexample
12909 WCEM=@var{x}
12910 @end smallexample
12911
12912 @noindent
12913 as part of the FORM string (WCEM = wide character encoding method),
12914 where @var{x} is one of the following characters
12915
12916 @table @samp
12917 @item h
12918 Hex ESC encoding
12919 @item u
12920 Upper half encoding
12921 @item s
12922 Shift-JIS encoding
12923 @item e
12924 EUC Encoding
12925 @item 8
12926 UTF-8 encoding
12927 @item b
12928 Brackets encoding
12929 @end table
12930
12931 @noindent
12932 The encoding methods match those that
12933 can be used in a source
12934 program, but there is no requirement that the encoding method used for
12935 the source program be the same as the encoding method used for files,
12936 and different files may use different encoding methods.
12937
12938 The default encoding method for the standard files, and for opened files
12939 for which no WCEM parameter is given in the FORM string matches the
12940 wide character encoding specified for the main program (the default
12941 being brackets encoding if no coding method was specified with -gnatW).
12942
12943 @table @asis
12944
12945 @item UTF-8 Coding
12946 A wide character is represented using
12947 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12948 10646-1/Am.2.  Depending on the character value, the representation
12949 is a one, two, three, or four byte sequence:
12950
12951 @smallexample
12952 16#000000#-16#00007f#: 2#0xxxxxxx#
12953 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12954 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12955 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12956 @end smallexample
12957
12958 @noindent
12959 where the @var{xxx} bits correspond to the left-padded bits of the
12960 21-bit character value.  Note that all lower half ASCII characters
12961 are represented as ASCII bytes and all upper half characters and
12962 other wide characters are represented as sequences of upper-half
12963 characters.
12964
12965 @item Brackets Coding
12966 In this encoding, a wide wide character is represented by the following eight
12967 character sequence if is in wide character range
12968
12969 @smallexample
12970 [ " a b c d " ]
12971 @end smallexample
12972
12973 and by the following ten character sequence if not
12974
12975 @smallexample
12976 [ " a b c d e f " ]
12977 @end smallexample
12978
12979 @noindent
12980 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12981 are the four or six hexadecimal
12982 characters (using uppercase letters) of the wide wide character code.  For
12983 example, @code{["01A345"]} is used to represent the wide wide character
12984 with code @code{16#01A345#}.
12985
12986 This scheme is compatible with use of the full Wide_Wide_Character set.
12987 On input, brackets coding can also be used for upper half characters,
12988 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12989 is only used for wide characters with a code greater than @code{16#FF#}.
12990
12991 @end table
12992
12993 @noindent
12994 If is also possible to use the other Wide_Character encoding methods,
12995 such as Shift-JIS, but the other schemes cannot support the full range
12996 of wide wide characters.
12997 An attempt to output a character that cannot
12998 be represented using the encoding scheme for the file causes
12999 Constraint_Error to be raised.  An invalid wide character sequence on
13000 input also causes Constraint_Error to be raised.
13001
13002 @menu
13003 * Wide_Wide_Text_IO Stream Pointer Positioning::
13004 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13005 @end menu
13006
13007 @node Wide_Wide_Text_IO Stream Pointer Positioning
13008 @subsection Stream Pointer Positioning
13009
13010 @noindent
13011 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13012 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13013 case:
13014
13015 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13016 normal lower ASCII set (i.e.@: a character in the range:
13017
13018 @smallexample @c ada
13019 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13020 @end smallexample
13021
13022 @noindent
13023 then although the logical position of the file pointer is unchanged by
13024 the @code{Look_Ahead} call, the stream is physically positioned past the
13025 wide character sequence.  Again this is to avoid the need for buffering
13026 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13027 indication that this situation has occurred so that this is not visible
13028 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13029 can be observed if the wide text file shares a stream with another file.
13030
13031 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13032 @subsection Reading and Writing Non-Regular Files
13033
13034 @noindent
13035 As in the case of Text_IO, when a non-regular file is read, it is
13036 assumed that the file contains no page marks (any form characters are
13037 treated as data characters), and @code{End_Of_Page} always returns
13038 @code{False}.  Similarly, the end of file indication is not sticky, so
13039 it is possible to read beyond an end of file.
13040
13041 @node Stream_IO
13042 @section Stream_IO
13043
13044 @noindent
13045 A stream file is a sequence of bytes, where individual elements are
13046 written to the file as described in the Ada Reference Manual.  The type
13047 @code{Stream_Element} is simply a byte.  There are two ways to read or
13048 write a stream file.
13049
13050 @itemize @bullet
13051 @item
13052 The operations @code{Read} and @code{Write} directly read or write a
13053 sequence of stream elements with no control information.
13054
13055 @item
13056 The stream attributes applied to a stream file transfer data in the
13057 manner described for stream attributes.
13058 @end itemize
13059
13060 @node Text Translation
13061 @section Text Translation
13062
13063 @noindent
13064 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13065 passed to Text_IO.Create and Text_IO.Open:
13066 @samp{Text_Translation=@var{Yes}} is the default, which means to
13067 translate LF to/from CR/LF on Windows systems.
13068 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13069 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13070 may be used to create Unix-style files on
13071 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13072 systems.
13073
13074 @node Shared Files
13075 @section Shared Files
13076
13077 @noindent
13078 Section A.14 of the Ada Reference Manual allows implementations to
13079 provide a wide variety of behavior if an attempt is made to access the
13080 same external file with two or more internal files.
13081
13082 To provide a full range of functionality, while at the same time
13083 minimizing the problems of portability caused by this implementation
13084 dependence, GNAT handles file sharing as follows:
13085
13086 @itemize @bullet
13087 @item
13088 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13089 to open two or more files with the same full name is considered an error
13090 and is not supported.  The exception @code{Use_Error} will be
13091 raised.  Note that a file that is not explicitly closed by the program
13092 remains open until the program terminates.
13093
13094 @item
13095 If the form parameter @samp{shared=no} appears in the form string, the
13096 file can be opened or created with its own separate stream identifier,
13097 regardless of whether other files sharing the same external file are
13098 opened.  The exact effect depends on how the C stream routines handle
13099 multiple accesses to the same external files using separate streams.
13100
13101 @item
13102 If the form parameter @samp{shared=yes} appears in the form string for
13103 each of two or more files opened using the same full name, the same
13104 stream is shared between these files, and the semantics are as described
13105 in Ada Reference Manual, Section A.14.
13106 @end itemize
13107
13108 @noindent
13109 When a program that opens multiple files with the same name is ported
13110 from another Ada compiler to GNAT, the effect will be that
13111 @code{Use_Error} is raised.
13112
13113 The documentation of the original compiler and the documentation of the
13114 program should then be examined to determine if file sharing was
13115 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13116 and @code{Create} calls as required.
13117
13118 When a program is ported from GNAT to some other Ada compiler, no
13119 special attention is required unless the @samp{shared=@var{xxx}} form
13120 parameter is used in the program.  In this case, you must examine the
13121 documentation of the new compiler to see if it supports the required
13122 file sharing semantics, and form strings modified appropriately.  Of
13123 course it may be the case that the program cannot be ported if the
13124 target compiler does not support the required functionality.  The best
13125 approach in writing portable code is to avoid file sharing (and hence
13126 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13127 completely.
13128
13129 One common use of file sharing in Ada 83 is the use of instantiations of
13130 Sequential_IO on the same file with different types, to achieve
13131 heterogeneous input-output.  Although this approach will work in GNAT if
13132 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13133 for this purpose (using the stream attributes)
13134
13135 @node Filenames encoding
13136 @section Filenames encoding
13137
13138 @noindent
13139 An encoding form parameter can be used to specify the filename
13140 encoding @samp{encoding=@var{xxx}}.
13141
13142 @itemize @bullet
13143 @item
13144 If the form parameter @samp{encoding=utf8} appears in the form string, the
13145 filename must be encoded in UTF-8.
13146
13147 @item
13148 If the form parameter @samp{encoding=8bits} appears in the form
13149 string, the filename must be a standard 8bits string.
13150 @end itemize
13151
13152 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13153 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13154 variable. And if not set @samp{utf8} is assumed.
13155
13156 @table @samp
13157 @item CP_ACP
13158 The current system Windows ANSI code page.
13159 @item CP_UTF8
13160 UTF-8 encoding
13161 @end table
13162
13163 This encoding form parameter is only supported on the Windows
13164 platform. On the other Operating Systems the run-time is supporting
13165 UTF-8 natively.
13166
13167 @node Open Modes
13168 @section Open Modes
13169
13170 @noindent
13171 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13172 using the mode shown in the following table:
13173
13174 @sp 2
13175 @center @code{Open} and @code{Create} Call Modes
13176 @smallexample
13177                                @b{OPEN }           @b{CREATE}
13178 Append_File                    "r+"             "w+"
13179 In_File                        "r"              "w+"
13180 Out_File (Direct_IO)           "r+"             "w"
13181 Out_File (all other cases)     "w"              "w"
13182 Inout_File                     "r+"             "w+"
13183 @end smallexample
13184
13185 @noindent
13186 If text file translation is required, then either @samp{b} or @samp{t}
13187 is added to the mode, depending on the setting of Text.  Text file
13188 translation refers to the mapping of CR/LF sequences in an external file
13189 to LF characters internally.  This mapping only occurs in DOS and
13190 DOS-like systems, and is not relevant to other systems.
13191
13192 A special case occurs with Stream_IO@.  As shown in the above table, the
13193 file is initially opened in @samp{r} or @samp{w} mode for the
13194 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13195 subsequently requires switching from reading to writing or vice-versa,
13196 then the file is reopened in @samp{r+} mode to permit the required operation.
13197
13198 @node Operations on C Streams
13199 @section Operations on C Streams
13200 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13201 access to the C library functions for operations on C streams:
13202
13203 @smallexample @c adanocomment
13204 package Interfaces.C_Streams is
13205   -- Note: the reason we do not use the types that are in
13206   -- Interfaces.C is that we want to avoid dragging in the
13207   -- code in this unit if possible.
13208   subtype chars is System.Address;
13209   -- Pointer to null-terminated array of characters
13210   subtype FILEs is System.Address;
13211   -- Corresponds to the C type FILE*
13212   subtype voids is System.Address;
13213   -- Corresponds to the C type void*
13214   subtype int is Integer;
13215   subtype long is Long_Integer;
13216   -- Note: the above types are subtypes deliberately, and it
13217   -- is part of this spec that the above correspondences are
13218   -- guaranteed.  This means that it is legitimate to, for
13219   -- example, use Integer instead of int.  We provide these
13220   -- synonyms for clarity, but in some cases it may be
13221   -- convenient to use the underlying types (for example to
13222   -- avoid an unnecessary dependency of a spec on the spec
13223   -- of this unit).
13224   type size_t is mod 2 ** Standard'Address_Size;
13225   NULL_Stream : constant FILEs;
13226   -- Value returned (NULL in C) to indicate an
13227   -- fdopen/fopen/tmpfile error
13228   ----------------------------------
13229   -- Constants Defined in stdio.h --
13230   ----------------------------------
13231   EOF : constant int;
13232   -- Used by a number of routines to indicate error or
13233   -- end of file
13234   IOFBF : constant int;
13235   IOLBF : constant int;
13236   IONBF : constant int;
13237   -- Used to indicate buffering mode for setvbuf call
13238   SEEK_CUR : constant int;
13239   SEEK_END : constant int;
13240   SEEK_SET : constant int;
13241   -- Used to indicate origin for fseek call
13242   function stdin return FILEs;
13243   function stdout return FILEs;
13244   function stderr return FILEs;
13245   -- Streams associated with standard files
13246   --------------------------
13247   -- Standard C functions --
13248   --------------------------
13249   -- The functions selected below are ones that are
13250   -- available in DOS, OS/2, UNIX and Xenix (but not
13251   -- necessarily in ANSI C).  These are very thin interfaces
13252   -- which copy exactly the C headers.  For more
13253   -- documentation on these functions, see the Microsoft C
13254   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13255   -- ISBN 1-55615-225-6), which includes useful information
13256   -- on system compatibility.
13257   procedure clearerr (stream : FILEs);
13258   function fclose (stream : FILEs) return int;
13259   function fdopen (handle : int; mode : chars) return FILEs;
13260   function feof (stream : FILEs) return int;
13261   function ferror (stream : FILEs) return int;
13262   function fflush (stream : FILEs) return int;
13263   function fgetc (stream : FILEs) return int;
13264   function fgets (strng : chars; n : int; stream : FILEs)
13265       return chars;
13266   function fileno (stream : FILEs) return int;
13267   function fopen (filename : chars; Mode : chars)
13268       return FILEs;
13269   -- Note: to maintain target independence, use
13270   -- text_translation_required, a boolean variable defined in
13271   -- a-sysdep.c to deal with the target dependent text
13272   -- translation requirement.  If this variable is set,
13273   -- then  b/t should be appended to the standard mode
13274   -- argument to set the text translation mode off or on
13275   -- as required.
13276   function fputc (C : int; stream : FILEs) return int;
13277   function fputs (Strng : chars; Stream : FILEs) return int;
13278   function fread
13279      (buffer : voids;
13280       size : size_t;
13281       count : size_t;
13282       stream : FILEs)
13283       return size_t;
13284   function freopen
13285      (filename : chars;
13286       mode : chars;
13287       stream : FILEs)
13288       return FILEs;
13289   function fseek
13290      (stream : FILEs;
13291       offset : long;
13292       origin : int)
13293       return int;
13294   function ftell (stream : FILEs) return long;
13295   function fwrite
13296      (buffer : voids;
13297       size : size_t;
13298       count : size_t;
13299       stream : FILEs)
13300       return size_t;
13301   function isatty (handle : int) return int;
13302   procedure mktemp (template : chars);
13303   -- The return value (which is just a pointer to template)
13304   -- is discarded
13305   procedure rewind (stream : FILEs);
13306   function rmtmp return int;
13307   function setvbuf
13308      (stream : FILEs;
13309       buffer : chars;
13310       mode : int;
13311       size : size_t)
13312       return int;
13313
13314   function tmpfile return FILEs;
13315   function ungetc (c : int; stream : FILEs) return int;
13316   function unlink (filename : chars) return int;
13317   ---------------------
13318   -- Extra functions --
13319   ---------------------
13320   -- These functions supply slightly thicker bindings than
13321   -- those above.  They are derived from functions in the
13322   -- C Run-Time Library, but may do a bit more work than
13323   -- just directly calling one of the Library functions.
13324   function is_regular_file (handle : int) return int;
13325   -- Tests if given handle is for a regular file (result 1)
13326   -- or for a non-regular file (pipe or device, result 0).
13327   ---------------------------------
13328   -- Control of Text/Binary Mode --
13329   ---------------------------------
13330   -- If text_translation_required is true, then the following
13331   -- functions may be used to dynamically switch a file from
13332   -- binary to text mode or vice versa.  These functions have
13333   -- no effect if text_translation_required is false (i.e.@: in
13334   -- normal UNIX mode).  Use fileno to get a stream handle.
13335   procedure set_binary_mode (handle : int);
13336   procedure set_text_mode (handle : int);
13337   ----------------------------
13338   -- Full Path Name support --
13339   ----------------------------
13340   procedure full_name (nam : chars; buffer : chars);
13341   -- Given a NUL terminated string representing a file
13342   -- name, returns in buffer a NUL terminated string
13343   -- representing the full path name for the file name.
13344   -- On systems where it is relevant the   drive is also
13345   -- part of the full path name.  It is the responsibility
13346   -- of the caller to pass an actual parameter for buffer
13347   -- that is big enough for any full path name.  Use
13348   -- max_path_len given below as the size of buffer.
13349   max_path_len : integer;
13350   -- Maximum length of an allowable full path name on the
13351   -- system, including a terminating NUL character.
13352 end Interfaces.C_Streams;
13353 @end smallexample
13354
13355 @node Interfacing to C Streams
13356 @section Interfacing to C Streams
13357
13358 @noindent
13359 The packages in this section permit interfacing Ada files to C Stream
13360 operations.
13361
13362 @smallexample @c ada
13363  with Interfaces.C_Streams;
13364  package Ada.Sequential_IO.C_Streams is
13365     function C_Stream (F : File_Type)
13366        return Interfaces.C_Streams.FILEs;
13367     procedure Open
13368       (File : in out File_Type;
13369        Mode : in File_Mode;
13370        C_Stream : in Interfaces.C_Streams.FILEs;
13371        Form : in String := "");
13372  end Ada.Sequential_IO.C_Streams;
13373
13374   with Interfaces.C_Streams;
13375   package Ada.Direct_IO.C_Streams is
13376      function C_Stream (F : File_Type)
13377         return Interfaces.C_Streams.FILEs;
13378      procedure Open
13379        (File : in out File_Type;
13380         Mode : in File_Mode;
13381         C_Stream : in Interfaces.C_Streams.FILEs;
13382         Form : in String := "");
13383   end Ada.Direct_IO.C_Streams;
13384
13385   with Interfaces.C_Streams;
13386   package Ada.Text_IO.C_Streams is
13387      function C_Stream (F : File_Type)
13388         return Interfaces.C_Streams.FILEs;
13389      procedure Open
13390        (File : in out File_Type;
13391         Mode : in File_Mode;
13392         C_Stream : in Interfaces.C_Streams.FILEs;
13393         Form : in String := "");
13394   end Ada.Text_IO.C_Streams;
13395
13396   with Interfaces.C_Streams;
13397   package Ada.Wide_Text_IO.C_Streams is
13398      function C_Stream (F : File_Type)
13399         return Interfaces.C_Streams.FILEs;
13400      procedure Open
13401        (File : in out File_Type;
13402         Mode : in File_Mode;
13403         C_Stream : in Interfaces.C_Streams.FILEs;
13404         Form : in String := "");
13405  end Ada.Wide_Text_IO.C_Streams;
13406
13407   with Interfaces.C_Streams;
13408   package Ada.Wide_Wide_Text_IO.C_Streams is
13409      function C_Stream (F : File_Type)
13410         return Interfaces.C_Streams.FILEs;
13411      procedure Open
13412        (File : in out File_Type;
13413         Mode : in File_Mode;
13414         C_Stream : in Interfaces.C_Streams.FILEs;
13415         Form : in String := "");
13416  end Ada.Wide_Wide_Text_IO.C_Streams;
13417
13418  with Interfaces.C_Streams;
13419  package Ada.Stream_IO.C_Streams is
13420     function C_Stream (F : File_Type)
13421        return Interfaces.C_Streams.FILEs;
13422     procedure Open
13423       (File : in out File_Type;
13424        Mode : in File_Mode;
13425        C_Stream : in Interfaces.C_Streams.FILEs;
13426        Form : in String := "");
13427  end Ada.Stream_IO.C_Streams;
13428 @end smallexample
13429
13430 @noindent
13431 In each of these six packages, the @code{C_Stream} function obtains the
13432 @code{FILE} pointer from a currently opened Ada file.  It is then
13433 possible to use the @code{Interfaces.C_Streams} package to operate on
13434 this stream, or the stream can be passed to a C program which can
13435 operate on it directly.  Of course the program is responsible for
13436 ensuring that only appropriate sequences of operations are executed.
13437
13438 One particular use of relevance to an Ada program is that the
13439 @code{setvbuf} function can be used to control the buffering of the
13440 stream used by an Ada file.  In the absence of such a call the standard
13441 default buffering is used.
13442
13443 The @code{Open} procedures in these packages open a file giving an
13444 existing C Stream instead of a file name.  Typically this stream is
13445 imported from a C program, allowing an Ada file to operate on an
13446 existing C file.
13447
13448 @node The GNAT Library
13449 @chapter The GNAT Library
13450
13451 @noindent
13452 The GNAT library contains a number of general and special purpose packages.
13453 It represents functionality that the GNAT developers have found useful, and
13454 which is made available to GNAT users.  The packages described here are fully
13455 supported, and upwards compatibility will be maintained in future releases,
13456 so you can use these facilities with the confidence that the same functionality
13457 will be available in future releases.
13458
13459 The chapter here simply gives a brief summary of the facilities available.
13460 The full documentation is found in the spec file for the package.  The full
13461 sources of these library packages, including both spec and body, are provided
13462 with all GNAT releases.  For example, to find out the full specifications of
13463 the SPITBOL pattern matching capability, including a full tutorial and
13464 extensive examples, look in the @file{g-spipat.ads} file in the library.
13465
13466 For each entry here, the package name (as it would appear in a @code{with}
13467 clause) is given, followed by the name of the corresponding spec file in
13468 parentheses.  The packages are children in four hierarchies, @code{Ada},
13469 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13470 GNAT-specific hierarchy.
13471
13472 Note that an application program should only use packages in one of these
13473 four hierarchies if the package is defined in the Ada Reference Manual,
13474 or is listed in this section of the GNAT Programmers Reference Manual.
13475 All other units should be considered internal implementation units and
13476 should not be directly @code{with}'ed by application code.  The use of
13477 a @code{with} statement that references one of these internal implementation
13478 units makes an application potentially dependent on changes in versions
13479 of GNAT, and will generate a warning message.
13480
13481 @menu
13482 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13483 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13484 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13485 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13486 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13487 * Ada.Command_Line.Environment (a-colien.ads)::
13488 * Ada.Command_Line.Remove (a-colire.ads)::
13489 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13490 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13491 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13492 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13493 * Ada.Exceptions.Traceback (a-exctra.ads)::
13494 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13495 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13496 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13497 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13498 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13499 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13500 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13501 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13502 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13503 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13504 * GNAT.Altivec (g-altive.ads)::
13505 * GNAT.Altivec.Conversions (g-altcon.ads)::
13506 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13507 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13508 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13509 * GNAT.Array_Split (g-arrspl.ads)::
13510 * GNAT.AWK (g-awk.ads)::
13511 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13512 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13513 * GNAT.Bubble_Sort (g-bubsor.ads)::
13514 * GNAT.Bubble_Sort_A (g-busora.ads)::
13515 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13516 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13517 * GNAT.Byte_Swapping (g-bytswa.ads)::
13518 * GNAT.Calendar (g-calend.ads)::
13519 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13520 * GNAT.Case_Util (g-casuti.ads)::
13521 * GNAT.CGI (g-cgi.ads)::
13522 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13523 * GNAT.CGI.Debug (g-cgideb.ads)::
13524 * GNAT.Command_Line (g-comlin.ads)::
13525 * GNAT.Compiler_Version (g-comver.ads)::
13526 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13527 * GNAT.CRC32 (g-crc32.ads)::
13528 * GNAT.Current_Exception (g-curexc.ads)::
13529 * GNAT.Debug_Pools (g-debpoo.ads)::
13530 * GNAT.Debug_Utilities (g-debuti.ads)::
13531 * GNAT.Decode_String (g-decstr.ads)::
13532 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13533 * GNAT.Directory_Operations (g-dirope.ads)::
13534 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13535 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13536 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13537 * GNAT.Encode_String (g-encstr.ads)::
13538 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13539 * GNAT.Exception_Actions (g-excact.ads)::
13540 * GNAT.Exception_Traces (g-exctra.ads)::
13541 * GNAT.Exceptions (g-except.ads)::
13542 * GNAT.Expect (g-expect.ads)::
13543 * GNAT.Float_Control (g-flocon.ads)::
13544 * GNAT.Heap_Sort (g-heasor.ads)::
13545 * GNAT.Heap_Sort_A (g-hesora.ads)::
13546 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13547 * GNAT.HTable (g-htable.ads)::
13548 * GNAT.IO (g-io.ads)::
13549 * GNAT.IO_Aux (g-io_aux.ads)::
13550 * GNAT.Lock_Files (g-locfil.ads)::
13551 * GNAT.MD5 (g-md5.ads)::
13552 * GNAT.Memory_Dump (g-memdum.ads)::
13553 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13554 * GNAT.OS_Lib (g-os_lib.ads)::
13555 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13556 * GNAT.Random_Numbers (g-rannum.ads)::
13557 * GNAT.Regexp (g-regexp.ads)::
13558 * GNAT.Registry (g-regist.ads)::
13559 * GNAT.Regpat (g-regpat.ads)::
13560 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13561 * GNAT.Semaphores (g-semaph.ads)::
13562 * GNAT.Serial_Communications (g-sercom.ads)::
13563 * GNAT.SHA1 (g-sha1.ads)::
13564 * GNAT.Signals (g-signal.ads)::
13565 * GNAT.Sockets (g-socket.ads)::
13566 * GNAT.Source_Info (g-souinf.ads)::
13567 * GNAT.Spelling_Checker (g-speche.ads)::
13568 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13569 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13570 * GNAT.Spitbol (g-spitbo.ads)::
13571 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13572 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13573 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13574 * GNAT.SSE (g-sse.ads)::
13575 * GNAT.SSE.Internal_Types (g-ssinty.ads)::
13576 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13577 * GNAT.Strings (g-string.ads)::
13578 * GNAT.String_Split (g-strspl.ads)::
13579 * GNAT.Table (g-table.ads)::
13580 * GNAT.Task_Lock (g-tasloc.ads)::
13581 * GNAT.Threads (g-thread.ads)::
13582 * GNAT.Time_Stamp (g-timsta.ads)::
13583 * GNAT.Traceback (g-traceb.ads)::
13584 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13585 * GNAT.UTF_32 (g-utf_32.ads)::
13586 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13587 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13588 * GNAT.Wide_String_Split (g-wistsp.ads)::
13589 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13590 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13591 * Interfaces.C.Extensions (i-cexten.ads)::
13592 * Interfaces.C.Streams (i-cstrea.ads)::
13593 * Interfaces.CPP (i-cpp.ads)::
13594 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13595 * Interfaces.VxWorks (i-vxwork.ads)::
13596 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13597 * System.Address_Image (s-addima.ads)::
13598 * System.Assertions (s-assert.ads)::
13599 * System.Memory (s-memory.ads)::
13600 * System.Partition_Interface (s-parint.ads)::
13601 * System.Pool_Global (s-pooglo.ads)::
13602 * System.Pool_Local (s-pooloc.ads)::
13603 * System.Restrictions (s-restri.ads)::
13604 * System.Rident (s-rident.ads)::
13605 * System.Strings.Stream_Ops (s-ststop.ads)::
13606 * System.Task_Info (s-tasinf.ads)::
13607 * System.Wch_Cnv (s-wchcnv.ads)::
13608 * System.Wch_Con (s-wchcon.ads)::
13609 @end menu
13610
13611 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13612 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13613 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13614 @cindex Latin_9 constants for Character
13615
13616 @noindent
13617 This child of @code{Ada.Characters}
13618 provides a set of definitions corresponding to those in the
13619 RM-defined package @code{Ada.Characters.Latin_1} but with the
13620 few modifications required for @code{Latin-9}
13621 The provision of such a package
13622 is specifically authorized by the Ada Reference Manual
13623 (RM A.3.3(27)).
13624
13625 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13626 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13627 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13628 @cindex Latin_1 constants for Wide_Character
13629
13630 @noindent
13631 This child of @code{Ada.Characters}
13632 provides a set of definitions corresponding to those in the
13633 RM-defined package @code{Ada.Characters.Latin_1} but with the
13634 types of the constants being @code{Wide_Character}
13635 instead of @code{Character}.  The provision of such a package
13636 is specifically authorized by the Ada Reference Manual
13637 (RM A.3.3(27)).
13638
13639 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13640 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13641 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13642 @cindex Latin_9 constants for Wide_Character
13643
13644 @noindent
13645 This child of @code{Ada.Characters}
13646 provides a set of definitions corresponding to those in the
13647 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13648 types of the constants being @code{Wide_Character}
13649 instead of @code{Character}.  The provision of such a package
13650 is specifically authorized by the Ada Reference Manual
13651 (RM A.3.3(27)).
13652
13653 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13654 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13655 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13656 @cindex Latin_1 constants for Wide_Wide_Character
13657
13658 @noindent
13659 This child of @code{Ada.Characters}
13660 provides a set of definitions corresponding to those in the
13661 RM-defined package @code{Ada.Characters.Latin_1} but with the
13662 types of the constants being @code{Wide_Wide_Character}
13663 instead of @code{Character}.  The provision of such a package
13664 is specifically authorized by the Ada Reference Manual
13665 (RM A.3.3(27)).
13666
13667 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13668 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13669 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13670 @cindex Latin_9 constants for Wide_Wide_Character
13671
13672 @noindent
13673 This child of @code{Ada.Characters}
13674 provides a set of definitions corresponding to those in the
13675 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13676 types of the constants being @code{Wide_Wide_Character}
13677 instead of @code{Character}.  The provision of such a package
13678 is specifically authorized by the Ada Reference Manual
13679 (RM A.3.3(27)).
13680
13681 @node Ada.Command_Line.Environment (a-colien.ads)
13682 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13683 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13684 @cindex Environment entries
13685
13686 @noindent
13687 This child of @code{Ada.Command_Line}
13688 provides a mechanism for obtaining environment values on systems
13689 where this concept makes sense.
13690
13691 @node Ada.Command_Line.Remove (a-colire.ads)
13692 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13693 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13694 @cindex Removing command line arguments
13695 @cindex Command line, argument removal
13696
13697 @noindent
13698 This child of @code{Ada.Command_Line}
13699 provides a mechanism for logically removing
13700 arguments from the argument list.  Once removed, an argument is not visible
13701 to further calls on the subprograms in @code{Ada.Command_Line} will not
13702 see the removed argument.
13703
13704 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13705 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13706 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13707 @cindex Response file for command line
13708 @cindex Command line, response file
13709 @cindex Command line, handling long command lines
13710
13711 @noindent
13712 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13713 getting command line arguments from a text file, called a "response file".
13714 Using a response file allow passing a set of arguments to an executable longer
13715 than the maximum allowed by the system on the command line.
13716
13717 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13718 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13719 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13720 @cindex C Streams, Interfacing with Direct_IO
13721
13722 @noindent
13723 This package provides subprograms that allow interfacing between
13724 C streams and @code{Direct_IO}.  The stream identifier can be
13725 extracted from a file opened on the Ada side, and an Ada file
13726 can be constructed from a stream opened on the C side.
13727
13728 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13729 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13730 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13731 @cindex Null_Occurrence, testing for
13732
13733 @noindent
13734 This child subprogram provides a way of testing for the null
13735 exception occurrence (@code{Null_Occurrence}) without raising
13736 an exception.
13737
13738 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13739 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13740 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13741 @cindex Null_Occurrence, testing for
13742
13743 @noindent
13744 This child subprogram is used for handling otherwise unhandled
13745 exceptions (hence the name last chance), and perform clean ups before
13746 terminating the program. Note that this subprogram never returns.
13747
13748 @node Ada.Exceptions.Traceback (a-exctra.ads)
13749 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13750 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13751 @cindex Traceback for Exception Occurrence
13752
13753 @noindent
13754 This child package provides the subprogram (@code{Tracebacks}) to
13755 give a traceback array of addresses based on an exception
13756 occurrence.
13757
13758 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13759 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13760 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13761 @cindex C Streams, Interfacing with Sequential_IO
13762
13763 @noindent
13764 This package provides subprograms that allow interfacing between
13765 C streams and @code{Sequential_IO}.  The stream identifier can be
13766 extracted from a file opened on the Ada side, and an Ada file
13767 can be constructed from a stream opened on the C side.
13768
13769 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13770 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13771 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13772 @cindex C Streams, Interfacing with Stream_IO
13773
13774 @noindent
13775 This package provides subprograms that allow interfacing between
13776 C streams and @code{Stream_IO}.  The stream identifier can be
13777 extracted from a file opened on the Ada side, and an Ada file
13778 can be constructed from a stream opened on the C side.
13779
13780 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13781 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13782 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13783 @cindex @code{Unbounded_String}, IO support
13784 @cindex @code{Text_IO}, extensions for unbounded strings
13785
13786 @noindent
13787 This package provides subprograms for Text_IO for unbounded
13788 strings, avoiding the necessity for an intermediate operation
13789 with ordinary strings.
13790
13791 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13792 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13793 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13794 @cindex @code{Unbounded_Wide_String}, IO support
13795 @cindex @code{Text_IO}, extensions for unbounded wide strings
13796
13797 @noindent
13798 This package provides subprograms for Text_IO for unbounded
13799 wide strings, avoiding the necessity for an intermediate operation
13800 with ordinary wide strings.
13801
13802 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13803 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13804 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13805 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13806 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13807
13808 @noindent
13809 This package provides subprograms for Text_IO for unbounded
13810 wide wide strings, avoiding the necessity for an intermediate operation
13811 with ordinary wide wide strings.
13812
13813 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13814 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13815 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13816 @cindex C Streams, Interfacing with @code{Text_IO}
13817
13818 @noindent
13819 This package provides subprograms that allow interfacing between
13820 C streams and @code{Text_IO}.  The stream identifier can be
13821 extracted from a file opened on the Ada side, and an Ada file
13822 can be constructed from a stream opened on the C side.
13823
13824 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13825 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13826 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13827 @cindex Unicode categorization, Wide_Character
13828
13829 @noindent
13830 This package provides subprograms that allow categorization of
13831 Wide_Character values according to Unicode categories.
13832
13833 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13834 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13835 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13836 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13837
13838 @noindent
13839 This package provides subprograms that allow interfacing between
13840 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13841 extracted from a file opened on the Ada side, and an Ada file
13842 can be constructed from a stream opened on the C side.
13843
13844 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13845 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13846 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13847 @cindex Unicode categorization, Wide_Wide_Character
13848
13849 @noindent
13850 This package provides subprograms that allow categorization of
13851 Wide_Wide_Character values according to Unicode categories.
13852
13853 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13854 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13855 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13856 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13857
13858 @noindent
13859 This package provides subprograms that allow interfacing between
13860 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13861 extracted from a file opened on the Ada side, and an Ada file
13862 can be constructed from a stream opened on the C side.
13863
13864 @node GNAT.Altivec (g-altive.ads)
13865 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13866 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13867 @cindex AltiVec
13868
13869 @noindent
13870 This is the root package of the GNAT AltiVec binding. It provides
13871 definitions of constants and types common to all the versions of the
13872 binding.
13873
13874 @node GNAT.Altivec.Conversions (g-altcon.ads)
13875 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13876 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13877 @cindex AltiVec
13878
13879 @noindent
13880 This package provides the Vector/View conversion routines.
13881
13882 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13883 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13884 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13885 @cindex AltiVec
13886
13887 @noindent
13888 This package exposes the Ada interface to the AltiVec operations on
13889 vector objects. A soft emulation is included by default in the GNAT
13890 library. The hard binding is provided as a separate package. This unit
13891 is common to both bindings.
13892
13893 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13894 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13895 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13896 @cindex AltiVec
13897
13898 @noindent
13899 This package exposes the various vector types part of the Ada binding
13900 to AltiVec facilities.
13901
13902 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13903 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13904 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13905 @cindex AltiVec
13906
13907 @noindent
13908 This package provides public 'View' data types from/to which private
13909 vector representations can be converted via
13910 GNAT.Altivec.Conversions. This allows convenient access to individual
13911 vector elements and provides a simple way to initialize vector
13912 objects.
13913
13914 @node GNAT.Array_Split (g-arrspl.ads)
13915 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13916 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13917 @cindex Array splitter
13918
13919 @noindent
13920 Useful array-manipulation routines: given a set of separators, split
13921 an array wherever the separators appear, and provide direct access
13922 to the resulting slices.
13923
13924 @node GNAT.AWK (g-awk.ads)
13925 @section @code{GNAT.AWK} (@file{g-awk.ads})
13926 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13927 @cindex Parsing
13928 @cindex AWK
13929
13930 @noindent
13931 Provides AWK-like parsing functions, with an easy interface for parsing one
13932 or more files containing formatted data.  The file is viewed as a database
13933 where each record is a line and a field is a data element in this line.
13934
13935 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13936 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13937 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13938 @cindex Parsing
13939 @cindex Bounded Buffers
13940
13941 @noindent
13942 Provides a concurrent generic bounded buffer abstraction.  Instances are
13943 useful directly or as parts of the implementations of other abstractions,
13944 such as mailboxes.
13945
13946 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13947 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13948 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13949 @cindex Parsing
13950 @cindex Mailboxes
13951
13952 @noindent
13953 Provides a thread-safe asynchronous intertask mailbox communication facility.
13954
13955 @node GNAT.Bubble_Sort (g-bubsor.ads)
13956 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13957 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13958 @cindex Sorting
13959 @cindex Bubble sort
13960
13961 @noindent
13962 Provides a general implementation of bubble sort usable for sorting arbitrary
13963 data items.  Exchange and comparison procedures are provided by passing
13964 access-to-procedure values.
13965
13966 @node GNAT.Bubble_Sort_A (g-busora.ads)
13967 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13968 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13969 @cindex Sorting
13970 @cindex Bubble sort
13971
13972 @noindent
13973 Provides a general implementation of bubble sort usable for sorting arbitrary
13974 data items.  Move and comparison procedures are provided by passing
13975 access-to-procedure values. This is an older version, retained for
13976 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13977
13978 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13979 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13980 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13981 @cindex Sorting
13982 @cindex Bubble sort
13983
13984 @noindent
13985 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13986 are provided as generic parameters, this improves efficiency, especially
13987 if the procedures can be inlined, at the expense of duplicating code for
13988 multiple instantiations.
13989
13990 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13991 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13992 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13993 @cindex UTF-8 representation
13994 @cindex Wide characte representations
13995
13996 @noindent
13997 Provides a routine which given a string, reads the start of the string to
13998 see whether it is one of the standard byte order marks (BOM's) which signal
13999 the encoding of the string. The routine includes detection of special XML
14000 sequences for various UCS input formats.
14001
14002 @node GNAT.Byte_Swapping (g-bytswa.ads)
14003 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14004 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14005 @cindex Byte swapping
14006 @cindex Endian
14007
14008 @noindent
14009 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14010 Machine-specific implementations are available in some cases.
14011
14012 @node GNAT.Calendar (g-calend.ads)
14013 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14014 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14015 @cindex @code{Calendar}
14016
14017 @noindent
14018 Extends the facilities provided by @code{Ada.Calendar} to include handling
14019 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14020 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14021 C @code{timeval} format.
14022
14023 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14024 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14025 @cindex @code{Calendar}
14026 @cindex Time
14027 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14028
14029 @node GNAT.CRC32 (g-crc32.ads)
14030 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14031 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14032 @cindex CRC32
14033 @cindex Cyclic Redundancy Check
14034
14035 @noindent
14036 This package implements the CRC-32 algorithm.  For a full description
14037 of this algorithm see
14038 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14039 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14040 Aug.@: 1988.  Sarwate, D.V@.
14041
14042 @node GNAT.Case_Util (g-casuti.ads)
14043 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14044 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14045 @cindex Casing utilities
14046 @cindex Character handling (@code{GNAT.Case_Util})
14047
14048 @noindent
14049 A set of simple routines for handling upper and lower casing of strings
14050 without the overhead of the full casing tables
14051 in @code{Ada.Characters.Handling}.
14052
14053 @node GNAT.CGI (g-cgi.ads)
14054 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14055 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14056 @cindex CGI (Common Gateway Interface)
14057
14058 @noindent
14059 This is a package for interfacing a GNAT program with a Web server via the
14060 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14061 parameters, which are a set of key/value pairs sent by the Web server.  It
14062 builds a table whose index is the key and provides some services to deal
14063 with this table.
14064
14065 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14066 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14067 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14068 @cindex CGI (Common Gateway Interface) cookie support
14069 @cindex Cookie support in CGI
14070
14071 @noindent
14072 This is a package to interface a GNAT program with a Web server via the
14073 Common Gateway Interface (CGI).  It exports services to deal with Web
14074 cookies (piece of information kept in the Web client software).
14075
14076 @node GNAT.CGI.Debug (g-cgideb.ads)
14077 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14078 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14079 @cindex CGI (Common Gateway Interface) debugging
14080
14081 @noindent
14082 This is a package to help debugging CGI (Common Gateway Interface)
14083 programs written in Ada.
14084
14085 @node GNAT.Command_Line (g-comlin.ads)
14086 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14087 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14088 @cindex Command line
14089
14090 @noindent
14091 Provides a high level interface to @code{Ada.Command_Line} facilities,
14092 including the ability to scan for named switches with optional parameters
14093 and expand file names using wild card notations.
14094
14095 @node GNAT.Compiler_Version (g-comver.ads)
14096 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14097 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14098 @cindex Compiler Version
14099 @cindex Version, of compiler
14100
14101 @noindent
14102 Provides a routine for obtaining the version of the compiler used to
14103 compile the program. More accurately this is the version of the binder
14104 used to bind the program (this will normally be the same as the version
14105 of the compiler if a consistent tool set is used to compile all units
14106 of a partition).
14107
14108 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14109 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14110 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14111 @cindex Interrupt
14112
14113 @noindent
14114 Provides a simple interface to handle Ctrl-C keyboard events.
14115
14116 @node GNAT.Current_Exception (g-curexc.ads)
14117 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14118 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14119 @cindex Current exception
14120 @cindex Exception retrieval
14121
14122 @noindent
14123 Provides access to information on the current exception that has been raised
14124 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14125 specification syntax.
14126 This is particularly useful in simulating typical facilities for
14127 obtaining information about exceptions provided by Ada 83 compilers.
14128
14129 @node GNAT.Debug_Pools (g-debpoo.ads)
14130 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14131 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14132 @cindex Debugging
14133 @cindex Debug pools
14134 @cindex Memory corruption debugging
14135
14136 @noindent
14137 Provide a debugging storage pools that helps tracking memory corruption
14138 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14139 @value{EDITION} User's Guide}.
14140
14141 @node GNAT.Debug_Utilities (g-debuti.ads)
14142 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14143 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14144 @cindex Debugging
14145
14146 @noindent
14147 Provides a few useful utilities for debugging purposes, including conversion
14148 to and from string images of address values. Supports both C and Ada formats
14149 for hexadecimal literals.
14150
14151 @node GNAT.Decode_String (g-decstr.ads)
14152 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14153 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14154 @cindex Decoding strings
14155 @cindex String decoding
14156 @cindex Wide character encoding
14157 @cindex UTF-8
14158 @cindex Unicode
14159
14160 @noindent
14161 A generic package providing routines for decoding wide character and wide wide
14162 character strings encoded as sequences of 8-bit characters using a specified
14163 encoding method. Includes validation routines, and also routines for stepping
14164 to next or previous encoded character in an encoded string.
14165 Useful in conjunction with Unicode character coding. Note there is a
14166 preinstantiation for UTF-8. See next entry.
14167
14168 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14169 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14170 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14171 @cindex Decoding strings
14172 @cindex Decoding UTF-8 strings
14173 @cindex UTF-8 string decoding
14174 @cindex Wide character decoding
14175 @cindex UTF-8
14176 @cindex Unicode
14177
14178 @noindent
14179 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14180
14181 @node GNAT.Directory_Operations (g-dirope.ads)
14182 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14183 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14184 @cindex Directory operations
14185
14186 @noindent
14187 Provides a set of routines for manipulating directories, including changing
14188 the current directory, making new directories, and scanning the files in a
14189 directory.
14190
14191 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14192 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14193 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14194 @cindex Directory operations iteration
14195
14196 @noindent
14197 A child unit of GNAT.Directory_Operations providing additional operations
14198 for iterating through directories.
14199
14200 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14201 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14202 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14203 @cindex Hash tables
14204
14205 @noindent
14206 A generic implementation of hash tables that can be used to hash arbitrary
14207 data.  Provided in two forms, a simple form with built in hash functions,
14208 and a more complex form in which the hash function is supplied.
14209
14210 @noindent
14211 This package provides a facility similar to that of @code{GNAT.HTable},
14212 except that this package declares a type that can be used to define
14213 dynamic instances of the hash table, while an instantiation of
14214 @code{GNAT.HTable} creates a single instance of the hash table.
14215
14216 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14217 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14218 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14219 @cindex Table implementation
14220 @cindex Arrays, extendable
14221
14222 @noindent
14223 A generic package providing a single dimension array abstraction where the
14224 length of the array can be dynamically modified.
14225
14226 @noindent
14227 This package provides a facility similar to that of @code{GNAT.Table},
14228 except that this package declares a type that can be used to define
14229 dynamic instances of the table, while an instantiation of
14230 @code{GNAT.Table} creates a single instance of the table type.
14231
14232 @node GNAT.Encode_String (g-encstr.ads)
14233 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14234 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14235 @cindex Encoding strings
14236 @cindex String encoding
14237 @cindex Wide character encoding
14238 @cindex UTF-8
14239 @cindex Unicode
14240
14241 @noindent
14242 A generic package providing routines for encoding wide character and wide
14243 wide character strings as sequences of 8-bit characters using a specified
14244 encoding method. Useful in conjunction with Unicode character coding.
14245 Note there is a preinstantiation for UTF-8. See next entry.
14246
14247 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14248 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14249 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14250 @cindex Encoding strings
14251 @cindex Encoding UTF-8 strings
14252 @cindex UTF-8 string encoding
14253 @cindex Wide character encoding
14254 @cindex UTF-8
14255 @cindex Unicode
14256
14257 @noindent
14258 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14259
14260 @node GNAT.Exception_Actions (g-excact.ads)
14261 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14262 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14263 @cindex Exception actions
14264
14265 @noindent
14266 Provides callbacks when an exception is raised. Callbacks can be registered
14267 for specific exceptions, or when any exception is raised. This
14268 can be used for instance to force a core dump to ease debugging.
14269
14270 @node GNAT.Exception_Traces (g-exctra.ads)
14271 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14272 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14273 @cindex Exception traces
14274 @cindex Debugging
14275
14276 @noindent
14277 Provides an interface allowing to control automatic output upon exception
14278 occurrences.
14279
14280 @node GNAT.Exceptions (g-except.ads)
14281 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14282 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14283 @cindex Exceptions, Pure
14284 @cindex Pure packages, exceptions
14285
14286 @noindent
14287 Normally it is not possible to raise an exception with
14288 a message from a subprogram in a pure package, since the
14289 necessary types and subprograms are in @code{Ada.Exceptions}
14290 which is not a pure unit. @code{GNAT.Exceptions} provides a
14291 facility for getting around this limitation for a few
14292 predefined exceptions, and for example allow raising
14293 @code{Constraint_Error} with a message from a pure subprogram.
14294
14295 @node GNAT.Expect (g-expect.ads)
14296 @section @code{GNAT.Expect} (@file{g-expect.ads})
14297 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14298
14299 @noindent
14300 Provides a set of subprograms similar to what is available
14301 with the standard Tcl Expect tool.
14302 It allows you to easily spawn and communicate with an external process.
14303 You can send commands or inputs to the process, and compare the output
14304 with some expected regular expression. Currently @code{GNAT.Expect}
14305 is implemented on all native GNAT ports except for OpenVMS@.
14306 It is not implemented for cross ports, and in particular is not
14307 implemented for VxWorks or LynxOS@.
14308
14309 @node GNAT.Float_Control (g-flocon.ads)
14310 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14311 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14312 @cindex Floating-Point Processor
14313
14314 @noindent
14315 Provides an interface for resetting the floating-point processor into the
14316 mode required for correct semantic operation in Ada.  Some third party
14317 library calls may cause this mode to be modified, and the Reset procedure
14318 in this package can be used to reestablish the required mode.
14319
14320 @node GNAT.Heap_Sort (g-heasor.ads)
14321 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14322 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14323 @cindex Sorting
14324
14325 @noindent
14326 Provides a general implementation of heap sort usable for sorting arbitrary
14327 data items. Exchange and comparison procedures are provided by passing
14328 access-to-procedure values.  The algorithm used is a modified heap sort
14329 that performs approximately N*log(N) comparisons in the worst case.
14330
14331 @node GNAT.Heap_Sort_A (g-hesora.ads)
14332 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14333 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14334 @cindex Sorting
14335
14336 @noindent
14337 Provides a general implementation of heap sort usable for sorting arbitrary
14338 data items. Move and comparison procedures are provided by passing
14339 access-to-procedure values.  The algorithm used is a modified heap sort
14340 that performs approximately N*log(N) comparisons in the worst case.
14341 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14342 interface, but may be slightly more efficient.
14343
14344 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14345 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14346 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14347 @cindex Sorting
14348
14349 @noindent
14350 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14351 are provided as generic parameters, this improves efficiency, especially
14352 if the procedures can be inlined, at the expense of duplicating code for
14353 multiple instantiations.
14354
14355 @node GNAT.HTable (g-htable.ads)
14356 @section @code{GNAT.HTable} (@file{g-htable.ads})
14357 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14358 @cindex Hash tables
14359
14360 @noindent
14361 A generic implementation of hash tables that can be used to hash arbitrary
14362 data.  Provides two approaches, one a simple static approach, and the other
14363 allowing arbitrary dynamic hash tables.
14364
14365 @node GNAT.IO (g-io.ads)
14366 @section @code{GNAT.IO} (@file{g-io.ads})
14367 @cindex @code{GNAT.IO} (@file{g-io.ads})
14368 @cindex Simple I/O
14369 @cindex Input/Output facilities
14370
14371 @noindent
14372 A simple preelaborable input-output package that provides a subset of
14373 simple Text_IO functions for reading characters and strings from
14374 Standard_Input, and writing characters, strings and integers to either
14375 Standard_Output or Standard_Error.
14376
14377 @node GNAT.IO_Aux (g-io_aux.ads)
14378 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14379 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14380 @cindex Text_IO
14381 @cindex Input/Output facilities
14382
14383 Provides some auxiliary functions for use with Text_IO, including a test
14384 for whether a file exists, and functions for reading a line of text.
14385
14386 @node GNAT.Lock_Files (g-locfil.ads)
14387 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14388 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14389 @cindex File locking
14390 @cindex Locking using files
14391
14392 @noindent
14393 Provides a general interface for using files as locks.  Can be used for
14394 providing program level synchronization.
14395
14396 @node GNAT.MD5 (g-md5.ads)
14397 @section @code{GNAT.MD5} (@file{g-md5.ads})
14398 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14399 @cindex Message Digest MD5
14400
14401 @noindent
14402 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14403
14404 @node GNAT.Memory_Dump (g-memdum.ads)
14405 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14406 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14407 @cindex Dump Memory
14408
14409 @noindent
14410 Provides a convenient routine for dumping raw memory to either the
14411 standard output or standard error files. Uses GNAT.IO for actual
14412 output.
14413
14414 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14415 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14416 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14417 @cindex Exception, obtaining most recent
14418
14419 @noindent
14420 Provides access to the most recently raised exception.  Can be used for
14421 various logging purposes, including duplicating functionality of some
14422 Ada 83 implementation dependent extensions.
14423
14424 @node GNAT.OS_Lib (g-os_lib.ads)
14425 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14426 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14427 @cindex Operating System interface
14428 @cindex Spawn capability
14429
14430 @noindent
14431 Provides a range of target independent operating system interface functions,
14432 including time/date management, file operations, subprocess management,
14433 including a portable spawn procedure, and access to environment variables
14434 and error return codes.
14435
14436 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14437 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14438 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14439 @cindex Hash functions
14440
14441 @noindent
14442 Provides a generator of static minimal perfect hash functions. No
14443 collisions occur and each item can be retrieved from the table in one
14444 probe (perfect property). The hash table size corresponds to the exact
14445 size of the key set and no larger (minimal property). The key set has to
14446 be know in advance (static property). The hash functions are also order
14447 preserving. If w2 is inserted after w1 in the generator, their
14448 hashcode are in the same order. These hashing functions are very
14449 convenient for use with realtime applications.
14450
14451 @node GNAT.Random_Numbers (g-rannum.ads)
14452 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14453 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14454 @cindex Random number generation
14455
14456 @noindent
14457 Provides random number capabilities which extend those available in the
14458 standard Ada library and are more convenient to use.
14459
14460 @node GNAT.Regexp (g-regexp.ads)
14461 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14462 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14463 @cindex Regular expressions
14464 @cindex Pattern matching
14465
14466 @noindent
14467 A simple implementation of regular expressions, using a subset of regular
14468 expression syntax copied from familiar Unix style utilities.  This is the
14469 simples of the three pattern matching packages provided, and is particularly
14470 suitable for ``file globbing'' applications.
14471
14472 @node GNAT.Registry (g-regist.ads)
14473 @section @code{GNAT.Registry} (@file{g-regist.ads})
14474 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14475 @cindex Windows Registry
14476
14477 @noindent
14478 This is a high level binding to the Windows registry.  It is possible to
14479 do simple things like reading a key value, creating a new key.  For full
14480 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14481 package provided with the Win32Ada binding
14482
14483 @node GNAT.Regpat (g-regpat.ads)
14484 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14485 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14486 @cindex Regular expressions
14487 @cindex Pattern matching
14488
14489 @noindent
14490 A complete implementation of Unix-style regular expression matching, copied
14491 from the original V7 style regular expression library written in C by
14492 Henry Spencer (and binary compatible with this C library).
14493
14494 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14495 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14496 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14497 @cindex Secondary Stack Info
14498
14499 @noindent
14500 Provide the capability to query the high water mark of the current task's
14501 secondary stack.
14502
14503 @node GNAT.Semaphores (g-semaph.ads)
14504 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14505 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14506 @cindex Semaphores
14507
14508 @noindent
14509 Provides classic counting and binary semaphores using protected types.
14510
14511 @node GNAT.Serial_Communications (g-sercom.ads)
14512 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14513 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14514 @cindex Serial_Communications
14515
14516 @noindent
14517 Provides a simple interface to send and receive data over a serial
14518 port. This is only supported on GNU/Linux and Windows.
14519
14520 @node GNAT.SHA1 (g-sha1.ads)
14521 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14522 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14523 @cindex Secure Hash Algorithm SHA-1
14524
14525 @noindent
14526 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14527
14528 @node GNAT.Signals (g-signal.ads)
14529 @section @code{GNAT.Signals} (@file{g-signal.ads})
14530 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14531 @cindex Signals
14532
14533 @noindent
14534 Provides the ability to manipulate the blocked status of signals on supported
14535 targets.
14536
14537 @node GNAT.Sockets (g-socket.ads)
14538 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14539 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14540 @cindex Sockets
14541
14542 @noindent
14543 A high level and portable interface to develop sockets based applications.
14544 This package is based on the sockets thin binding found in
14545 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14546 on all native GNAT ports except for OpenVMS@.  It is not implemented
14547 for the LynxOS@ cross port.
14548
14549 @node GNAT.Source_Info (g-souinf.ads)
14550 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14551 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14552 @cindex Source Information
14553
14554 @noindent
14555 Provides subprograms that give access to source code information known at
14556 compile time, such as the current file name and line number.
14557
14558 @node GNAT.Spelling_Checker (g-speche.ads)
14559 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14560 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14561 @cindex Spell checking
14562
14563 @noindent
14564 Provides a function for determining whether one string is a plausible
14565 near misspelling of another string.
14566
14567 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14568 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14569 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14570 @cindex Spell checking
14571
14572 @noindent
14573 Provides a generic function that can be instantiated with a string type for
14574 determining whether one string is a plausible near misspelling of another
14575 string.
14576
14577 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14578 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14579 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14580 @cindex SPITBOL pattern matching
14581 @cindex Pattern matching
14582
14583 @noindent
14584 A complete implementation of SNOBOL4 style pattern matching.  This is the
14585 most elaborate of the pattern matching packages provided.  It fully duplicates
14586 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14587 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14588
14589 @node GNAT.Spitbol (g-spitbo.ads)
14590 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14591 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14592 @cindex SPITBOL interface
14593
14594 @noindent
14595 The top level package of the collection of SPITBOL-style functionality, this
14596 package provides basic SNOBOL4 string manipulation functions, such as
14597 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14598 useful for constructing arbitrary mappings from strings in the style of
14599 the SNOBOL4 TABLE function.
14600
14601 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14602 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14603 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14604 @cindex Sets of strings
14605 @cindex SPITBOL Tables
14606
14607 @noindent
14608 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14609 for type @code{Standard.Boolean}, giving an implementation of sets of
14610 string values.
14611
14612 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14613 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14614 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14615 @cindex Integer maps
14616 @cindex Maps
14617 @cindex SPITBOL Tables
14618
14619 @noindent
14620 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14621 for type @code{Standard.Integer}, giving an implementation of maps
14622 from string to integer values.
14623
14624 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14625 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14626 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14627 @cindex String maps
14628 @cindex Maps
14629 @cindex SPITBOL Tables
14630
14631 @noindent
14632 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14633 a variable length string type, giving an implementation of general
14634 maps from strings to strings.
14635
14636 @node GNAT.SSE (g-sse.ads)
14637 @section @code{GNAT.SSE} (@file{g-sse.ads})
14638 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
14639
14640 @noindent
14641 Root of a set of units aimed at offering Ada bindings to a subset of
14642 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14643 targets.  It exposes vector component types together with a general
14644 introduction to the binding contents and use.
14645
14646 @node GNAT.SSE.Internal_Types (g-ssinty.ads)
14647 @section @code{GNAT.SSE.Internal_Types} (@file{g-ssinty.ads})
14648 @cindex @code{GNAT.SSE.Internal_Types} (@file{g-ssinty.ads})
14649
14650 @noindent
14651 Low level GCC vector types for direct use of the vector related
14652 builtins, required for the development of higher level bindings to SSE
14653 intrinsic operations.
14654
14655 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
14656 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14657 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14658
14659 @noindent
14660 SSE vector types for use with SSE related intrinsics.
14661
14662 @node GNAT.Strings (g-string.ads)
14663 @section @code{GNAT.Strings} (@file{g-string.ads})
14664 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14665
14666 @noindent
14667 Common String access types and related subprograms. Basically it
14668 defines a string access and an array of string access types.
14669
14670 @node GNAT.String_Split (g-strspl.ads)
14671 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14672 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14673 @cindex String splitter
14674
14675 @noindent
14676 Useful string manipulation routines: given a set of separators, split
14677 a string wherever the separators appear, and provide direct access
14678 to the resulting slices. This package is instantiated from
14679 @code{GNAT.Array_Split}.
14680
14681 @node GNAT.Table (g-table.ads)
14682 @section @code{GNAT.Table} (@file{g-table.ads})
14683 @cindex @code{GNAT.Table} (@file{g-table.ads})
14684 @cindex Table implementation
14685 @cindex Arrays, extendable
14686
14687 @noindent
14688 A generic package providing a single dimension array abstraction where the
14689 length of the array can be dynamically modified.
14690
14691 @noindent
14692 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14693 except that this package declares a single instance of the table type,
14694 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14695 used to define dynamic instances of the table.
14696
14697 @node GNAT.Task_Lock (g-tasloc.ads)
14698 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14699 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14700 @cindex Task synchronization
14701 @cindex Task locking
14702 @cindex Locking
14703
14704 @noindent
14705 A very simple facility for locking and unlocking sections of code using a
14706 single global task lock.  Appropriate for use in situations where contention
14707 between tasks is very rarely expected.
14708
14709 @node GNAT.Time_Stamp (g-timsta.ads)
14710 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14711 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14712 @cindex Time stamp
14713 @cindex Current time
14714
14715 @noindent
14716 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14717 represents the current date and time in ISO 8601 format. This is a very simple
14718 routine with minimal code and there are no dependencies on any other unit.
14719
14720 @node GNAT.Threads (g-thread.ads)
14721 @section @code{GNAT.Threads} (@file{g-thread.ads})
14722 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14723 @cindex Foreign threads
14724 @cindex Threads, foreign
14725
14726 @noindent
14727 Provides facilities for dealing with foreign threads which need to be known
14728 by the GNAT run-time system. Consult the documentation of this package for
14729 further details if your program has threads that are created by a non-Ada
14730 environment which then accesses Ada code.
14731
14732 @node GNAT.Traceback (g-traceb.ads)
14733 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14734 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14735 @cindex Trace back facilities
14736
14737 @noindent
14738 Provides a facility for obtaining non-symbolic traceback information, useful
14739 in various debugging situations.
14740
14741 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14742 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14743 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14744 @cindex Trace back facilities
14745
14746 @node GNAT.UTF_32 (g-utf_32.ads)
14747 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14748 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14749 @cindex Wide character codes
14750
14751 @noindent
14752 This is a package intended to be used in conjunction with the
14753 @code{Wide_Character} type in Ada 95 and the
14754 @code{Wide_Wide_Character} type in Ada 2005 (available
14755 in @code{GNAT} in Ada 2005 mode). This package contains
14756 Unicode categorization routines, as well as lexical
14757 categorization routines corresponding to the Ada 2005
14758 lexical rules for identifiers and strings, and also a
14759 lower case to upper case fold routine corresponding to
14760 the Ada 2005 rules for identifier equivalence.
14761
14762 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14763 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14764 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14765 @cindex Spell checking
14766
14767 @noindent
14768 Provides a function for determining whether one wide wide string is a plausible
14769 near misspelling of another wide wide string, where the strings are represented
14770 using the UTF_32_String type defined in System.Wch_Cnv.
14771
14772 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14773 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14774 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14775 @cindex Spell checking
14776
14777 @noindent
14778 Provides a function for determining whether one wide string is a plausible
14779 near misspelling of another wide string.
14780
14781 @node GNAT.Wide_String_Split (g-wistsp.ads)
14782 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14783 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14784 @cindex Wide_String splitter
14785
14786 @noindent
14787 Useful wide string manipulation routines: given a set of separators, split
14788 a wide string wherever the separators appear, and provide direct access
14789 to the resulting slices. This package is instantiated from
14790 @code{GNAT.Array_Split}.
14791
14792 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14793 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14794 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14795 @cindex Spell checking
14796
14797 @noindent
14798 Provides a function for determining whether one wide wide string is a plausible
14799 near misspelling of another wide wide string.
14800
14801 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14802 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14803 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14804 @cindex Wide_Wide_String splitter
14805
14806 @noindent
14807 Useful wide wide string manipulation routines: given a set of separators, split
14808 a wide wide string wherever the separators appear, and provide direct access
14809 to the resulting slices. This package is instantiated from
14810 @code{GNAT.Array_Split}.
14811
14812 @node Interfaces.C.Extensions (i-cexten.ads)
14813 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14814 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14815
14816 @noindent
14817 This package contains additional C-related definitions, intended
14818 for use with either manually or automatically generated bindings
14819 to C libraries.
14820
14821 @node Interfaces.C.Streams (i-cstrea.ads)
14822 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14823 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14824 @cindex  C streams, interfacing
14825
14826 @noindent
14827 This package is a binding for the most commonly used operations
14828 on C streams.
14829
14830 @node Interfaces.CPP (i-cpp.ads)
14831 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14832 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14833 @cindex  C++ interfacing
14834 @cindex  Interfacing, to C++
14835
14836 @noindent
14837 This package provides facilities for use in interfacing to C++.  It
14838 is primarily intended to be used in connection with automated tools
14839 for the generation of C++ interfaces.
14840
14841 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14842 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14843 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14844 @cindex  IBM Packed Format
14845 @cindex  Packed Decimal
14846
14847 @noindent
14848 This package provides a set of routines for conversions to and
14849 from a packed decimal format compatible with that used on IBM
14850 mainframes.
14851
14852 @node Interfaces.VxWorks (i-vxwork.ads)
14853 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14854 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14855 @cindex Interfacing to VxWorks
14856 @cindex VxWorks, interfacing
14857
14858 @noindent
14859 This package provides a limited binding to the VxWorks API.
14860 In particular, it interfaces with the
14861 VxWorks hardware interrupt facilities.
14862
14863 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14864 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14865 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14866 @cindex Interfacing to VxWorks' I/O
14867 @cindex VxWorks, I/O interfacing
14868 @cindex VxWorks, Get_Immediate
14869 @cindex Get_Immediate, VxWorks
14870
14871 @noindent
14872 This package provides a binding to the ioctl (IO/Control)
14873 function of VxWorks, defining a set of option values and
14874 function codes. A particular use of this package is
14875 to enable the use of Get_Immediate under VxWorks.
14876
14877 @node System.Address_Image (s-addima.ads)
14878 @section @code{System.Address_Image} (@file{s-addima.ads})
14879 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14880 @cindex Address image
14881 @cindex Image, of an address
14882
14883 @noindent
14884 This function provides a useful debugging
14885 function that gives an (implementation dependent)
14886 string which identifies an address.
14887
14888 @node System.Assertions (s-assert.ads)
14889 @section @code{System.Assertions} (@file{s-assert.ads})
14890 @cindex @code{System.Assertions} (@file{s-assert.ads})
14891 @cindex Assertions
14892 @cindex Assert_Failure, exception
14893
14894 @noindent
14895 This package provides the declaration of the exception raised
14896 by an run-time assertion failure, as well as the routine that
14897 is used internally to raise this assertion.
14898
14899 @node System.Memory (s-memory.ads)
14900 @section @code{System.Memory} (@file{s-memory.ads})
14901 @cindex @code{System.Memory} (@file{s-memory.ads})
14902 @cindex Memory allocation
14903
14904 @noindent
14905 This package provides the interface to the low level routines used
14906 by the generated code for allocation and freeing storage for the
14907 default storage pool (analogous to the C routines malloc and free.
14908 It also provides a reallocation interface analogous to the C routine
14909 realloc. The body of this unit may be modified to provide alternative
14910 allocation mechanisms for the default pool, and in addition, direct
14911 calls to this unit may be made for low level allocation uses (for
14912 example see the body of @code{GNAT.Tables}).
14913
14914 @node System.Partition_Interface (s-parint.ads)
14915 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14916 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14917 @cindex Partition interfacing functions
14918
14919 @noindent
14920 This package provides facilities for partition interfacing.  It
14921 is used primarily in a distribution context when using Annex E
14922 with @code{GLADE}.
14923
14924 @node System.Pool_Global (s-pooglo.ads)
14925 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14926 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14927 @cindex Storage pool, global
14928 @cindex Global storage pool
14929
14930 @noindent
14931 This package provides a storage pool that is equivalent to the default
14932 storage pool used for access types for which no pool is specifically
14933 declared. It uses malloc/free to allocate/free and does not attempt to
14934 do any automatic reclamation.
14935
14936 @node System.Pool_Local (s-pooloc.ads)
14937 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14938 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14939 @cindex Storage pool, local
14940 @cindex Local storage pool
14941
14942 @noindent
14943 This package provides a storage pool that is intended for use with locally
14944 defined access types. It uses malloc/free for allocate/free, and maintains
14945 a list of allocated blocks, so that all storage allocated for the pool can
14946 be freed automatically when the pool is finalized.
14947
14948 @node System.Restrictions (s-restri.ads)
14949 @section @code{System.Restrictions} (@file{s-restri.ads})
14950 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14951 @cindex Run-time restrictions access
14952
14953 @noindent
14954 This package provides facilities for accessing at run time
14955 the status of restrictions specified at compile time for
14956 the partition. Information is available both with regard
14957 to actual restrictions specified, and with regard to
14958 compiler determined information on which restrictions
14959 are violated by one or more packages in the partition.
14960
14961 @node System.Rident (s-rident.ads)
14962 @section @code{System.Rident} (@file{s-rident.ads})
14963 @cindex @code{System.Rident} (@file{s-rident.ads})
14964 @cindex Restrictions definitions
14965
14966 @noindent
14967 This package provides definitions of the restrictions
14968 identifiers supported by GNAT, and also the format of
14969 the restrictions provided in package System.Restrictions.
14970 It is not normally necessary to @code{with} this generic package
14971 since the necessary instantiation is included in
14972 package System.Restrictions.
14973
14974 @node System.Strings.Stream_Ops (s-ststop.ads)
14975 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
14976 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
14977 @cindex Stream operations
14978 @cindex String stream operations
14979
14980 @noindent
14981 This package provides a set of stream subprograms for standard string types.
14982 It is intended primarily to support implicit use of such subprograms when
14983 stream attributes are applied to string types, but the subprograms in this
14984 package can be used directly by application programs.
14985
14986 @node System.Task_Info (s-tasinf.ads)
14987 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14988 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14989 @cindex Task_Info pragma
14990
14991 @noindent
14992 This package provides target dependent functionality that is used
14993 to support the @code{Task_Info} pragma
14994
14995 @node System.Wch_Cnv (s-wchcnv.ads)
14996 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14997 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14998 @cindex Wide Character, Representation
14999 @cindex Wide String, Conversion
15000 @cindex Representation of wide characters
15001
15002 @noindent
15003 This package provides routines for converting between
15004 wide and wide wide characters and a representation as a value of type
15005 @code{Standard.String}, using a specified wide character
15006 encoding method.  It uses definitions in
15007 package @code{System.Wch_Con}.
15008
15009 @node System.Wch_Con (s-wchcon.ads)
15010 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15011 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15012
15013 @noindent
15014 This package provides definitions and descriptions of
15015 the various methods used for encoding wide characters
15016 in ordinary strings.  These definitions are used by
15017 the package @code{System.Wch_Cnv}.
15018
15019 @node Interfacing to Other Languages
15020 @chapter Interfacing to Other Languages
15021 @noindent
15022 The facilities in annex B of the Ada Reference Manual are fully
15023 implemented in GNAT, and in addition, a full interface to C++ is
15024 provided.
15025
15026 @menu
15027 * Interfacing to C::
15028 * Interfacing to C++::
15029 * Interfacing to COBOL::
15030 * Interfacing to Fortran::
15031 * Interfacing to non-GNAT Ada code::
15032 @end menu
15033
15034 @node Interfacing to C
15035 @section Interfacing to C
15036
15037 @noindent
15038 Interfacing to C with GNAT can use one of two approaches:
15039
15040 @itemize @bullet
15041 @item
15042 The types in the package @code{Interfaces.C} may be used.
15043 @item
15044 Standard Ada types may be used directly.  This may be less portable to
15045 other compilers, but will work on all GNAT compilers, which guarantee
15046 correspondence between the C and Ada types.
15047 @end itemize
15048
15049 @noindent
15050 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15051 effect, since this is the default.  The following table shows the
15052 correspondence between Ada scalar types and the corresponding C types.
15053
15054 @table @code
15055 @item Integer
15056 @code{int}
15057 @item Short_Integer
15058 @code{short}
15059 @item Short_Short_Integer
15060 @code{signed char}
15061 @item Long_Integer
15062 @code{long}
15063 @item Long_Long_Integer
15064 @code{long long}
15065 @item Short_Float
15066 @code{float}
15067 @item Float
15068 @code{float}
15069 @item Long_Float
15070 @code{double}
15071 @item Long_Long_Float
15072 This is the longest floating-point type supported by the hardware.
15073 @end table
15074
15075 @noindent
15076 Additionally, there are the following general correspondences between Ada
15077 and C types:
15078 @itemize @bullet
15079 @item
15080 Ada enumeration types map to C enumeration types directly if pragma
15081 @code{Convention C} is specified, which causes them to have int
15082 length.  Without pragma @code{Convention C}, Ada enumeration types map to
15083 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15084 @code{int}, respectively) depending on the number of values passed.
15085 This is the only case in which pragma @code{Convention C} affects the
15086 representation of an Ada type.
15087
15088 @item
15089 Ada access types map to C pointers, except for the case of pointers to
15090 unconstrained types in Ada, which have no direct C equivalent.
15091
15092 @item
15093 Ada arrays map directly to C arrays.
15094
15095 @item
15096 Ada records map directly to C structures.
15097
15098 @item
15099 Packed Ada records map to C structures where all members are bit fields
15100 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15101 @end itemize
15102
15103 @node Interfacing to C++
15104 @section Interfacing to C++
15105
15106 @noindent
15107 The interface to C++ makes use of the following pragmas, which are
15108 primarily intended to be constructed automatically using a binding generator
15109 tool, although it is possible to construct them by hand.  No suitable binding
15110 generator tool is supplied with GNAT though.
15111
15112 Using these pragmas it is possible to achieve complete
15113 inter-operability between Ada tagged types and C++ class definitions.
15114 See @ref{Implementation Defined Pragmas}, for more details.
15115
15116 @table @code
15117 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15118 The argument denotes an entity in the current declarative region that is
15119 declared as a tagged or untagged record type. It indicates that the type
15120 corresponds to an externally declared C++ class type, and is to be laid
15121 out the same way that C++ would lay out the type.
15122
15123 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15124 for backward compatibility but its functionality is available
15125 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15126
15127 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15128 This pragma identifies an imported function (imported in the usual way
15129 with pragma @code{Import}) as corresponding to a C++ constructor.
15130 @end table
15131
15132 @node Interfacing to COBOL
15133 @section Interfacing to COBOL
15134
15135 @noindent
15136 Interfacing to COBOL is achieved as described in section B.4 of
15137 the Ada Reference Manual.
15138
15139 @node Interfacing to Fortran
15140 @section Interfacing to Fortran
15141
15142 @noindent
15143 Interfacing to Fortran is achieved as described in section B.5 of the
15144 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15145 multi-dimensional array causes the array to be stored in column-major
15146 order as required for convenient interface to Fortran.
15147
15148 @node Interfacing to non-GNAT Ada code
15149 @section Interfacing to non-GNAT Ada code
15150
15151 It is possible to specify the convention @code{Ada} in a pragma
15152 @code{Import} or pragma @code{Export}.  However this refers to
15153 the calling conventions used by GNAT, which may or may not be
15154 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15155 compiler to allow interoperation.
15156
15157 If arguments types are kept simple, and if the foreign compiler generally
15158 follows system calling conventions, then it may be possible to integrate
15159 files compiled by other Ada compilers, provided that the elaboration
15160 issues are adequately addressed (for example by eliminating the
15161 need for any load time elaboration).
15162
15163 In particular, GNAT running on VMS is designed to
15164 be highly compatible with the DEC Ada 83 compiler, so this is one
15165 case in which it is possible to import foreign units of this type,
15166 provided that the data items passed are restricted to simple scalar
15167 values or simple record types without variants, or simple array
15168 types with fixed bounds.
15169
15170 @node Specialized Needs Annexes
15171 @chapter Specialized Needs Annexes
15172
15173 @noindent
15174 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15175 required in all implementations.  However, as described in this chapter,
15176 GNAT implements all of these annexes:
15177
15178 @table @asis
15179 @item Systems Programming (Annex C)
15180 The Systems Programming Annex is fully implemented.
15181
15182 @item Real-Time Systems (Annex D)
15183 The Real-Time Systems Annex is fully implemented.
15184
15185 @item Distributed Systems (Annex E)
15186 Stub generation is fully implemented in the GNAT compiler.  In addition,
15187 a complete compatible PCS is available as part of the GLADE system,
15188 a separate product.  When the two
15189 products are used in conjunction, this annex is fully implemented.
15190
15191 @item Information Systems (Annex F)
15192 The Information Systems annex is fully implemented.
15193
15194 @item Numerics (Annex G)
15195 The Numerics Annex is fully implemented.
15196
15197 @item Safety and Security / High-Integrity Systems (Annex H)
15198 The Safety and Security Annex (termed the High-Integrity Systems Annex
15199 in Ada 2005) is fully implemented.
15200 @end table
15201
15202 @node Implementation of Specific Ada Features
15203 @chapter Implementation of Specific Ada Features
15204
15205 @noindent
15206 This chapter describes the GNAT implementation of several Ada language
15207 facilities.
15208
15209 @menu
15210 * Machine Code Insertions::
15211 * GNAT Implementation of Tasking::
15212 * GNAT Implementation of Shared Passive Packages::
15213 * Code Generation for Array Aggregates::
15214 * The Size of Discriminated Records with Default Discriminants::
15215 * Strict Conformance to the Ada Reference Manual::
15216 @end menu
15217
15218 @node Machine Code Insertions
15219 @section Machine Code Insertions
15220 @cindex Machine Code insertions
15221
15222 @noindent
15223 Package @code{Machine_Code} provides machine code support as described
15224 in the Ada Reference Manual in two separate forms:
15225 @itemize @bullet
15226 @item
15227 Machine code statements, consisting of qualified expressions that
15228 fit the requirements of RM section 13.8.
15229 @item
15230 An intrinsic callable procedure, providing an alternative mechanism of
15231 including machine instructions in a subprogram.
15232 @end itemize
15233
15234 @noindent
15235 The two features are similar, and both are closely related to the mechanism
15236 provided by the asm instruction in the GNU C compiler.  Full understanding
15237 and use of the facilities in this package requires understanding the asm
15238 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15239 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15240
15241 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15242 semantic restrictions and effects as described below.  Both are provided so
15243 that the procedure call can be used as a statement, and the function call
15244 can be used to form a code_statement.
15245
15246 The first example given in the GCC documentation is the C @code{asm}
15247 instruction:
15248 @smallexample
15249    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15250 @end smallexample
15251
15252 @noindent
15253 The equivalent can be written for GNAT as:
15254
15255 @smallexample @c ada
15256 Asm ("fsinx %1 %0",
15257      My_Float'Asm_Output ("=f", result),
15258      My_Float'Asm_Input  ("f",  angle));
15259 @end smallexample
15260
15261 @noindent
15262 The first argument to @code{Asm} is the assembler template, and is
15263 identical to what is used in GNU C@.  This string must be a static
15264 expression.  The second argument is the output operand list.  It is
15265 either a single @code{Asm_Output} attribute reference, or a list of such
15266 references enclosed in parentheses (technically an array aggregate of
15267 such references).
15268
15269 The @code{Asm_Output} attribute denotes a function that takes two
15270 parameters.  The first is a string, the second is the name of a variable
15271 of the type designated by the attribute prefix.  The first (string)
15272 argument is required to be a static expression and designates the
15273 constraint for the parameter (e.g.@: what kind of register is
15274 required).  The second argument is the variable to be updated with the
15275 result.  The possible values for constraint are the same as those used in
15276 the RTL, and are dependent on the configuration file used to build the
15277 GCC back end.  If there are no output operands, then this argument may
15278 either be omitted, or explicitly given as @code{No_Output_Operands}.
15279
15280 The second argument of @code{@var{my_float}'Asm_Output} functions as
15281 though it were an @code{out} parameter, which is a little curious, but
15282 all names have the form of expressions, so there is no syntactic
15283 irregularity, even though normally functions would not be permitted
15284 @code{out} parameters.  The third argument is the list of input
15285 operands.  It is either a single @code{Asm_Input} attribute reference, or
15286 a list of such references enclosed in parentheses (technically an array
15287 aggregate of such references).
15288
15289 The @code{Asm_Input} attribute denotes a function that takes two
15290 parameters.  The first is a string, the second is an expression of the
15291 type designated by the prefix.  The first (string) argument is required
15292 to be a static expression, and is the constraint for the parameter,
15293 (e.g.@: what kind of register is required).  The second argument is the
15294 value to be used as the input argument.  The possible values for the
15295 constant are the same as those used in the RTL, and are dependent on
15296 the configuration file used to built the GCC back end.
15297
15298 If there are no input operands, this argument may either be omitted, or
15299 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15300 present in the above example, is a list of register names, called the
15301 @dfn{clobber} argument.  This argument, if given, must be a static string
15302 expression, and is a space or comma separated list of names of registers
15303 that must be considered destroyed as a result of the @code{Asm} call.  If
15304 this argument is the null string (the default value), then the code
15305 generator assumes that no additional registers are destroyed.
15306
15307 The fifth argument, not present in the above example, called the
15308 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15309 the literal value @code{True} to indicate to the code generator that all
15310 optimizations with respect to the instruction specified should be
15311 suppressed, and that in particular, for an instruction that has outputs,
15312 the instruction will still be generated, even if none of the outputs are
15313 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15314 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15315 Generally it is strongly advisable to use Volatile for any ASM statement
15316 that is missing either input or output operands, or when two or more ASM
15317 statements appear in sequence, to avoid unwanted optimizations. A warning
15318 is generated if this advice is not followed.
15319
15320 The @code{Asm} subprograms may be used in two ways.  First the procedure
15321 forms can be used anywhere a procedure call would be valid, and
15322 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15323 be used to intersperse machine instructions with other Ada statements.
15324 Second, the function forms, which return a dummy value of the limited
15325 private type @code{Asm_Insn}, can be used in code statements, and indeed
15326 this is the only context where such calls are allowed.  Code statements
15327 appear as aggregates of the form:
15328
15329 @smallexample @c ada
15330 Asm_Insn'(Asm (@dots{}));
15331 Asm_Insn'(Asm_Volatile (@dots{}));
15332 @end smallexample
15333
15334 @noindent
15335 In accordance with RM rules, such code statements are allowed only
15336 within subprograms whose entire body consists of such statements.  It is
15337 not permissible to intermix such statements with other Ada statements.
15338
15339 Typically the form using intrinsic procedure calls is more convenient
15340 and more flexible.  The code statement form is provided to meet the RM
15341 suggestion that such a facility should be made available.  The following
15342 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15343 is used, the arguments may be given in arbitrary order, following the
15344 normal rules for use of positional and named arguments)
15345
15346 @smallexample
15347 ASM_CALL ::= Asm (
15348                  [Template =>] static_string_EXPRESSION
15349                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15350                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15351                [,[Clobber  =>] static_string_EXPRESSION ]
15352                [,[Volatile =>] static_boolean_EXPRESSION] )
15353
15354 OUTPUT_OPERAND_LIST ::=
15355   [PREFIX.]No_Output_Operands
15356 | OUTPUT_OPERAND_ATTRIBUTE
15357 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15358
15359 OUTPUT_OPERAND_ATTRIBUTE ::=
15360   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15361
15362 INPUT_OPERAND_LIST ::=
15363   [PREFIX.]No_Input_Operands
15364 | INPUT_OPERAND_ATTRIBUTE
15365 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15366
15367 INPUT_OPERAND_ATTRIBUTE ::=
15368   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15369 @end smallexample
15370
15371 @noindent
15372 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15373 are declared in the package @code{Machine_Code} and must be referenced
15374 according to normal visibility rules. In particular if there is no
15375 @code{use} clause for this package, then appropriate package name
15376 qualification is required.
15377
15378 @node GNAT Implementation of Tasking
15379 @section GNAT Implementation of Tasking
15380
15381 @noindent
15382 This chapter outlines the basic GNAT approach to tasking (in particular,
15383 a multi-layered library for portability) and discusses issues related
15384 to compliance with the Real-Time Systems Annex.
15385
15386 @menu
15387 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15388 * Ensuring Compliance with the Real-Time Annex::
15389 @end menu
15390
15391 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15392 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15393
15394 @noindent
15395 GNAT's run-time support comprises two layers:
15396
15397 @itemize @bullet
15398 @item GNARL (GNAT Run-time Layer)
15399 @item GNULL (GNAT Low-level Library)
15400 @end itemize
15401
15402 @noindent
15403 In GNAT, Ada's tasking services rely on a platform and OS independent
15404 layer known as GNARL@.  This code is responsible for implementing the
15405 correct semantics of Ada's task creation, rendezvous, protected
15406 operations etc.
15407
15408 GNARL decomposes Ada's tasking semantics into simpler lower level
15409 operations such as create a thread, set the priority of a thread,
15410 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15411 operations constitutes GNULLI, the GNULL Interface.  This interface is
15412 directly inspired from the POSIX real-time API@.
15413
15414 If the underlying executive or OS implements the POSIX standard
15415 faithfully, the GNULL Interface maps as is to the services offered by
15416 the underlying kernel.  Otherwise, some target dependent glue code maps
15417 the services offered by the underlying kernel to the semantics expected
15418 by GNARL@.
15419
15420 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15421 key point is that each Ada task is mapped on a thread in the underlying
15422 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15423
15424 In addition Ada task priorities map onto the underlying thread priorities.
15425 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15426
15427 @itemize @bullet
15428 @item
15429 The underlying scheduler is used to schedule the Ada tasks.  This
15430 makes Ada tasks as efficient as kernel threads from a scheduling
15431 standpoint.
15432
15433 @item
15434 Interaction with code written in C containing threads is eased
15435 since at the lowest level Ada tasks and C threads map onto the same
15436 underlying kernel concept.
15437
15438 @item
15439 When an Ada task is blocked during I/O the remaining Ada tasks are
15440 able to proceed.
15441
15442 @item
15443 On multiprocessor systems Ada tasks can execute in parallel.
15444 @end itemize
15445
15446 @noindent
15447 Some threads libraries offer a mechanism to fork a new process, with the
15448 child process duplicating the threads from the parent.
15449 GNAT does not
15450 support this functionality when the parent contains more than one task.
15451 @cindex Forking a new process
15452
15453 @node Ensuring Compliance with the Real-Time Annex
15454 @subsection Ensuring Compliance with the Real-Time Annex
15455 @cindex Real-Time Systems Annex compliance
15456
15457 @noindent
15458 Although mapping Ada tasks onto
15459 the underlying threads has significant advantages, it does create some
15460 complications when it comes to respecting the scheduling semantics
15461 specified in the real-time annex (Annex D).
15462
15463 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15464 scheduling policy states:
15465
15466 @quotation
15467 @emph{When the active priority of a ready task that is not running
15468 changes, or the setting of its base priority takes effect, the
15469 task is removed from the ready queue for its old active priority
15470 and is added at the tail of the ready queue for its new active
15471 priority, except in the case where the active priority is lowered
15472 due to the loss of inherited priority, in which case the task is
15473 added at the head of the ready queue for its new active priority.}
15474 @end quotation
15475
15476 @noindent
15477 While most kernels do put tasks at the end of the priority queue when
15478 a task changes its priority, (which respects the main
15479 FIFO_Within_Priorities requirement), almost none keep a thread at the
15480 beginning of its priority queue when its priority drops from the loss
15481 of inherited priority.
15482
15483 As a result most vendors have provided incomplete Annex D implementations.
15484
15485 The GNAT run-time, has a nice cooperative solution to this problem
15486 which ensures that accurate FIFO_Within_Priorities semantics are
15487 respected.
15488
15489 The principle is as follows.  When an Ada task T is about to start
15490 running, it checks whether some other Ada task R with the same
15491 priority as T has been suspended due to the loss of priority
15492 inheritance.  If this is the case, T yields and is placed at the end of
15493 its priority queue.  When R arrives at the front of the queue it
15494 executes.
15495
15496 Note that this simple scheme preserves the relative order of the tasks
15497 that were ready to execute in the priority queue where R has been
15498 placed at the end.
15499
15500 @node GNAT Implementation of Shared Passive Packages
15501 @section GNAT Implementation of Shared Passive Packages
15502 @cindex Shared passive packages
15503
15504 @noindent
15505 GNAT fully implements the pragma @code{Shared_Passive} for
15506 @cindex pragma @code{Shared_Passive}
15507 the purpose of designating shared passive packages.
15508 This allows the use of passive partitions in the
15509 context described in the Ada Reference Manual; i.e., for communication
15510 between separate partitions of a distributed application using the
15511 features in Annex E.
15512 @cindex Annex E
15513 @cindex Distribution Systems Annex
15514
15515 However, the implementation approach used by GNAT provides for more
15516 extensive usage as follows:
15517
15518 @table @emph
15519 @item Communication between separate programs
15520
15521 This allows separate programs to access the data in passive
15522 partitions, using protected objects for synchronization where
15523 needed. The only requirement is that the two programs have a
15524 common shared file system. It is even possible for programs
15525 running on different machines with different architectures
15526 (e.g.@: different endianness) to communicate via the data in
15527 a passive partition.
15528
15529 @item Persistence between program runs
15530
15531 The data in a passive package can persist from one run of a
15532 program to another, so that a later program sees the final
15533 values stored by a previous run of the same program.
15534
15535 @end table
15536
15537 @noindent
15538 The implementation approach used is to store the data in files. A
15539 separate stream file is created for each object in the package, and
15540 an access to an object causes the corresponding file to be read or
15541 written.
15542
15543 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15544 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15545 set to the directory to be used for these files.
15546 The files in this directory
15547 have names that correspond to their fully qualified names. For
15548 example, if we have the package
15549
15550 @smallexample @c ada
15551 package X is
15552   pragma Shared_Passive (X);
15553   Y : Integer;
15554   Z : Float;
15555 end X;
15556 @end smallexample
15557
15558 @noindent
15559 and the environment variable is set to @code{/stemp/}, then the files created
15560 will have the names:
15561
15562 @smallexample
15563 /stemp/x.y
15564 /stemp/x.z
15565 @end smallexample
15566
15567 @noindent
15568 These files are created when a value is initially written to the object, and
15569 the files are retained until manually deleted. This provides the persistence
15570 semantics. If no file exists, it means that no partition has assigned a value
15571 to the variable; in this case the initial value declared in the package
15572 will be used. This model ensures that there are no issues in synchronizing
15573 the elaboration process, since elaboration of passive packages elaborates the
15574 initial values, but does not create the files.
15575
15576 The files are written using normal @code{Stream_IO} access.
15577 If you want to be able
15578 to communicate between programs or partitions running on different
15579 architectures, then you should use the XDR versions of the stream attribute
15580 routines, since these are architecture independent.
15581
15582 If active synchronization is required for access to the variables in the
15583 shared passive package, then as described in the Ada Reference Manual, the
15584 package may contain protected objects used for this purpose. In this case
15585 a lock file (whose name is @file{___lock} (three underscores)
15586 is created in the shared memory directory.
15587 @cindex @file{___lock} file (for shared passive packages)
15588 This is used to provide the required locking
15589 semantics for proper protected object synchronization.
15590
15591 As of January 2003, GNAT supports shared passive packages on all platforms
15592 except for OpenVMS.
15593
15594 @node Code Generation for Array Aggregates
15595 @section Code Generation for Array Aggregates
15596
15597 @menu
15598 * Static constant aggregates with static bounds::
15599 * Constant aggregates with unconstrained nominal types::
15600 * Aggregates with static bounds::
15601 * Aggregates with non-static bounds::
15602 * Aggregates in assignment statements::
15603 @end menu
15604
15605 @noindent
15606 Aggregates have a rich syntax and allow the user to specify the values of
15607 complex data structures by means of a single construct.  As a result, the
15608 code generated for aggregates can be quite complex and involve loops, case
15609 statements and multiple assignments.  In the simplest cases, however, the
15610 compiler will recognize aggregates whose components and constraints are
15611 fully static, and in those cases the compiler will generate little or no
15612 executable code.  The following is an outline of the code that GNAT generates
15613 for various aggregate constructs.  For further details, you will find it
15614 useful to examine the output produced by the -gnatG flag to see the expanded
15615 source that is input to the code generator.  You may also want to examine
15616 the assembly code generated at various levels of optimization.
15617
15618 The code generated for aggregates depends on the context, the component values,
15619 and the type.  In the context of an object declaration the code generated is
15620 generally simpler than in the case of an assignment.  As a general rule, static
15621 component values and static subtypes also lead to simpler code.
15622
15623 @node Static constant aggregates with static bounds
15624 @subsection Static constant aggregates with static bounds
15625
15626 @noindent
15627 For the declarations:
15628 @smallexample @c ada
15629     type One_Dim is array (1..10) of integer;
15630     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15631 @end smallexample
15632
15633 @noindent
15634 GNAT generates no executable code: the constant ar0 is placed in static memory.
15635 The same is true for constant aggregates with named associations:
15636
15637 @smallexample @c ada
15638     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15639     Cr3 : constant One_Dim := (others => 7777);
15640 @end smallexample
15641
15642 @noindent
15643 The same is true for multidimensional constant arrays such as:
15644
15645 @smallexample @c ada
15646     type two_dim is array (1..3, 1..3) of integer;
15647     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15648 @end smallexample
15649
15650 @noindent
15651 The same is true for arrays of one-dimensional arrays: the following are
15652 static:
15653
15654 @smallexample @c ada
15655 type ar1b  is array (1..3) of boolean;
15656 type ar_ar is array (1..3) of ar1b;
15657 None  : constant ar1b := (others => false);     --  fully static
15658 None2 : constant ar_ar := (1..3 => None);       --  fully static
15659 @end smallexample
15660
15661 @noindent
15662 However, for multidimensional aggregates with named associations, GNAT will
15663 generate assignments and loops, even if all associations are static.  The
15664 following two declarations generate a loop for the first dimension, and
15665 individual component assignments for the second dimension:
15666
15667 @smallexample @c ada
15668 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15669 Zero2: constant two_dim := (others => (others => 0));
15670 @end smallexample
15671
15672 @node Constant aggregates with unconstrained nominal types
15673 @subsection Constant aggregates with unconstrained nominal types
15674
15675 @noindent
15676 In such cases the aggregate itself establishes the subtype, so that
15677 associations with @code{others} cannot be used.  GNAT determines the
15678 bounds for the actual subtype of the aggregate, and allocates the
15679 aggregate statically as well.  No code is generated for the following:
15680
15681 @smallexample @c ada
15682     type One_Unc is array (natural range <>) of integer;
15683     Cr_Unc : constant One_Unc := (12,24,36);
15684 @end smallexample
15685
15686 @node Aggregates with static bounds
15687 @subsection Aggregates with static bounds
15688
15689 @noindent
15690 In all previous examples the aggregate was the initial (and immutable) value
15691 of a constant.  If the aggregate initializes a variable, then code is generated
15692 for it as a combination of individual assignments and loops over the target
15693 object.  The declarations
15694
15695 @smallexample @c ada
15696        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15697        Cr_Var2 : One_Dim := (others > -1);
15698 @end smallexample
15699
15700 @noindent
15701 generate the equivalent of
15702
15703 @smallexample @c ada
15704        Cr_Var1 (1) := 2;
15705        Cr_Var1 (2) := 3;
15706        Cr_Var1 (3) := 5;
15707        Cr_Var1 (4) := 11;
15708
15709        for I in Cr_Var2'range loop
15710           Cr_Var2 (I) := -1;
15711        end loop;
15712 @end smallexample
15713
15714 @node Aggregates with non-static bounds
15715 @subsection Aggregates with non-static bounds
15716
15717 @noindent
15718 If the bounds of the aggregate are not statically compatible with the bounds
15719 of the nominal subtype  of the target, then constraint checks have to be
15720 generated on the bounds.  For a multidimensional array, constraint checks may
15721 have to be applied to sub-arrays individually, if they do not have statically
15722 compatible subtypes.
15723
15724 @node Aggregates in assignment statements
15725 @subsection Aggregates in assignment statements
15726
15727 @noindent
15728 In general, aggregate assignment requires the construction of a temporary,
15729 and a copy from the temporary to the target of the assignment.  This is because
15730 it is not always possible to convert the assignment into a series of individual
15731 component assignments.  For example, consider the simple case:
15732
15733 @smallexample @c ada
15734         A := (A(2), A(1));
15735 @end smallexample
15736
15737 @noindent
15738 This cannot be converted into:
15739
15740 @smallexample @c ada
15741         A(1) := A(2);
15742         A(2) := A(1);
15743 @end smallexample
15744
15745 @noindent
15746 So the aggregate has to be built first in a separate location, and then
15747 copied into the target.  GNAT recognizes simple cases where this intermediate
15748 step is not required, and the assignments can be performed in place, directly
15749 into the target.  The following sufficient criteria are applied:
15750
15751 @itemize @bullet
15752 @item
15753 The bounds of the aggregate are static, and the associations are static.
15754 @item
15755 The components of the aggregate are static constants, names of
15756 simple variables that are not renamings, or expressions not involving
15757 indexed components whose operands obey these rules.
15758 @end itemize
15759
15760 @noindent
15761 If any of these conditions are violated, the aggregate will be built in
15762 a temporary (created either by the front-end or the code generator) and then
15763 that temporary will be copied onto the target.
15764
15765
15766 @node The Size of Discriminated Records with Default Discriminants
15767 @section The Size of Discriminated Records with Default Discriminants
15768
15769 @noindent
15770 If a discriminated type @code{T} has discriminants with default values, it is
15771 possible to declare an object of this type without providing an explicit
15772 constraint:
15773
15774 @smallexample @c ada
15775 @group
15776 type Size is range 1..100;
15777
15778 type Rec (D : Size := 15) is record
15779    Name : String (1..D);
15780 end T;
15781
15782 Word : Rec;
15783 @end group
15784 @end smallexample
15785
15786 @noindent
15787 Such an object is said to be @emph{unconstrained}.
15788 The discriminant of the object
15789 can be modified by a full assignment to the object, as long as it preserves the
15790 relation between the value of the discriminant, and the value of the components
15791 that depend on it:
15792
15793 @smallexample @c ada
15794 @group
15795 Word := (3, "yes");
15796
15797 Word := (5, "maybe");
15798
15799 Word := (5, "no"); -- raises Constraint_Error
15800 @end group
15801 @end smallexample
15802
15803 @noindent
15804 In order to support this behavior efficiently, an unconstrained object is
15805 given the maximum size that any value of the type requires. In the case
15806 above, @code{Word} has storage for the discriminant and for
15807 a @code{String} of length 100.
15808 It is important to note that unconstrained objects do not require dynamic
15809 allocation. It would be an improper implementation to place on the heap those
15810 components whose size depends on discriminants. (This improper implementation
15811 was used by some Ada83 compilers, where the @code{Name} component above
15812 would have
15813 been stored as a pointer to a dynamic string). Following the principle that
15814 dynamic storage management should never be introduced implicitly,
15815 an Ada compiler should reserve the full size for an unconstrained declared
15816 object, and place it on the stack.
15817
15818 This maximum size approach
15819 has been a source of surprise to some users, who expect the default
15820 values of the discriminants to determine the size reserved for an
15821 unconstrained object: ``If the default is 15, why should the object occupy
15822 a larger size?''
15823 The answer, of course, is that the discriminant may be later modified,
15824 and its full range of values must be taken into account. This is why the
15825 declaration:
15826
15827 @smallexample
15828 @group
15829 type Rec (D : Positive := 15) is record
15830    Name : String (1..D);
15831 end record;
15832
15833 Too_Large : Rec;
15834 @end group
15835 @end smallexample
15836
15837 @noindent
15838 is flagged by the compiler with a warning:
15839 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15840 because the required size includes @code{Positive'Last}
15841 bytes. As the first example indicates, the proper approach is to declare an
15842 index type of ``reasonable'' range so that unconstrained objects are not too
15843 large.
15844
15845 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15846 created in the heap by means of an allocator, then it is @emph{not}
15847 unconstrained:
15848 it is constrained by the default values of the discriminants, and those values
15849 cannot be modified by full assignment. This is because in the presence of
15850 aliasing all views of the object (which may be manipulated by different tasks,
15851 say) must be consistent, so it is imperative that the object, once created,
15852 remain invariant.
15853
15854 @node Strict Conformance to the Ada Reference Manual
15855 @section Strict Conformance to the Ada Reference Manual
15856
15857 @noindent
15858 The dynamic semantics defined by the Ada Reference Manual impose a set of
15859 run-time checks to be generated. By default, the GNAT compiler will insert many
15860 run-time checks into the compiled code, including most of those required by the
15861 Ada Reference Manual. However, there are three checks that are not enabled
15862 in the default mode for efficiency reasons: arithmetic overflow checking for
15863 integer operations (including division by zero), checks for access before
15864 elaboration on subprogram calls, and stack overflow checking (most operating
15865 systems do not perform this check by default).
15866
15867 Strict conformance to the Ada Reference Manual can be achieved by adding
15868 three compiler options for overflow checking for integer operations
15869 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15870 calls and generic instantiations (@option{-gnatE}), and stack overflow
15871 checking (@option{-fstack-check}).
15872
15873 Note that the result of a floating point arithmetic operation in overflow and
15874 invalid situations, when the @code{Machine_Overflows} attribute of the result
15875 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15876 case for machines compliant with the IEEE floating-point standard, but on
15877 machines that are not fully compliant with this standard, such as Alpha, the
15878 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15879 behavior (although at the cost of a significant performance penalty), so
15880 infinite and and NaN values are properly generated.
15881
15882
15883 @node Project File Reference
15884 @chapter Project File Reference
15885
15886 @noindent
15887 This chapter describes the syntax and semantics of project files.
15888 Project files specify the options to be used when building a system.
15889 Project files can specify global settings for all tools,
15890 as well as tool-specific settings.
15891 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15892 for examples of use.
15893
15894 @menu
15895 * Reserved Words::
15896 * Lexical Elements::
15897 * Declarations::
15898 * Empty declarations::
15899 * Typed string declarations::
15900 * Variables::
15901 * Expressions::
15902 * Attributes::
15903 * Project Attributes::
15904 * Attribute References::
15905 * External Values::
15906 * Case Construction::
15907 * Packages::
15908 * Package Renamings::
15909 * Projects::
15910 * Project Extensions::
15911 * Project File Elaboration::
15912 @end menu
15913
15914 @node Reserved Words
15915 @section Reserved Words
15916
15917 @noindent
15918 All Ada reserved words are reserved in project files, and cannot be used
15919 as variable names or project names. In addition, the following are
15920 also reserved in project files:
15921
15922 @itemize
15923 @item @code{extends}
15924
15925 @item @code{external}
15926
15927 @item @code{project}
15928
15929 @end itemize
15930
15931 @node Lexical Elements
15932 @section Lexical Elements
15933
15934 @noindent
15935 Rules for identifiers are the same as in Ada. Identifiers
15936 are case-insensitive.  Strings are case sensitive, except where noted.
15937 Comments have the same form as in Ada.
15938
15939 @noindent
15940 Syntax:
15941
15942 @smallexample
15943 simple_name ::=
15944   identifier
15945
15946 name ::=
15947   simple_name @{. simple_name@}
15948 @end smallexample
15949
15950 @node Declarations
15951 @section Declarations
15952
15953 @noindent
15954 Declarations introduce new entities that denote types, variables, attributes,
15955 and packages. Some declarations can only appear immediately within a project
15956 declaration. Others can appear within a project or within a package.
15957
15958 Syntax:
15959 @smallexample
15960 declarative_item ::=
15961   simple_declarative_item |
15962   typed_string_declaration |
15963   package_declaration
15964
15965 simple_declarative_item ::=
15966   variable_declaration |
15967   typed_variable_declaration |
15968   attribute_declaration |
15969   case_construction |
15970   empty_declaration
15971 @end smallexample
15972
15973 @node Empty declarations
15974 @section Empty declarations
15975
15976 @smallexample
15977 empty_declaration ::=
15978   @b{null} ;
15979 @end smallexample
15980
15981 An empty declaration is allowed anywhere a declaration is allowed.
15982 It has no effect.
15983
15984 @node Typed string declarations
15985 @section Typed string declarations
15986
15987 @noindent
15988 Typed strings are sequences of string literals. Typed strings are the only
15989 named types in project files. They are used in case constructions, where they
15990 provide support for conditional attribute definitions.
15991
15992 Syntax:
15993 @smallexample
15994 typed_string_declaration ::=
15995   @b{type} <typed_string_>_simple_name @b{is}
15996    ( string_literal @{, string_literal@} );
15997 @end smallexample
15998
15999 @noindent
16000 A typed string declaration can only appear immediately within a project
16001 declaration.
16002
16003 All the string literals in a typed string declaration must be distinct.
16004
16005 @node Variables
16006 @section Variables
16007
16008 @noindent
16009 Variables denote values, and appear as constituents of expressions.
16010
16011 @smallexample
16012 typed_variable_declaration ::=
16013   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
16014
16015 variable_declaration ::=
16016   <variable_>simple_name := expression;
16017 @end smallexample
16018
16019 @noindent
16020 The elaboration of a variable declaration introduces the variable and
16021 assigns to it the value of the expression. The name of the variable is
16022 available after the assignment symbol.
16023
16024 @noindent
16025 A typed_variable can only be declare once.
16026
16027 @noindent
16028 a non-typed variable can be declared multiple times.
16029
16030 @noindent
16031 Before the completion of its first declaration, the value of variable
16032 is the null string.
16033
16034 @node Expressions
16035 @section Expressions
16036
16037 @noindent
16038 An expression is a formula that defines a computation or retrieval of a value.
16039 In a project file the value of an expression is either a string or a list
16040 of strings. A string value in an expression is either a literal, the current
16041 value of a variable, an external value, an attribute reference, or a
16042 concatenation operation.
16043
16044 Syntax:
16045
16046 @smallexample
16047 expression ::=
16048   term @{& term@}
16049
16050 term ::=
16051   string_literal |
16052   string_list |
16053   <variable_>name |
16054   external_value |
16055   attribute_reference
16056
16057 string_literal ::=
16058   (same as Ada)
16059
16060 string_list ::=
16061   ( <string_>expression @{ , <string_>expression @} )
16062 @end smallexample
16063
16064 @subsection Concatenation
16065 @noindent
16066 The following concatenation functions are defined:
16067
16068 @smallexample @c ada
16069   function "&" (X : String;      Y : String)      return String;
16070   function "&" (X : String_List; Y : String)      return String_List;
16071   function "&" (X : String_List; Y : String_List) return String_List;
16072 @end smallexample
16073
16074 @node Attributes
16075 @section Attributes
16076
16077 @noindent
16078 An attribute declaration defines a property of a project or package. This
16079 property can later be queried by means of an attribute reference.
16080 Attribute values are strings or string lists.
16081
16082 Some attributes are associative arrays. These attributes are mappings whose
16083 domain is a set of strings. These attributes are declared one association
16084 at a time, by specifying a point in the domain and the corresponding image
16085 of the attribute. They may also be declared as a full associative array,
16086 getting the same associations as the corresponding attribute in an imported
16087 or extended project.
16088
16089 Attributes that are not associative arrays are called simple attributes.
16090
16091 Syntax:
16092 @smallexample
16093 attribute_declaration ::=
16094   full_associative_array_declaration |
16095   @b{for} attribute_designator @b{use} expression ;
16096
16097 full_associative_array_declaration ::=
16098   @b{for} <associative_array_attribute_>simple_name @b{use}
16099   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16100
16101 attribute_designator ::=
16102   <simple_attribute_>simple_name |
16103   <associative_array_attribute_>simple_name ( string_literal )
16104 @end smallexample
16105
16106 @noindent
16107 Some attributes are project-specific, and can only appear immediately within
16108 a project declaration. Others are package-specific, and can only appear within
16109 the proper package.
16110
16111 The expression in an attribute definition must be a string or a string_list.
16112 The string literal appearing in the attribute_designator of an associative
16113 array attribute is case-insensitive.
16114
16115 @node Project Attributes
16116 @section Project Attributes
16117
16118 @noindent
16119 The following attributes apply to a project. All of them are simple
16120 attributes.
16121
16122 @table @code
16123 @item   Object_Dir
16124 Expression must be a path name. The attribute defines the
16125 directory in which the object files created by the build are to be placed. If
16126 not specified, object files are placed in the project directory.
16127
16128 @item   Exec_Dir
16129 Expression must be a path name. The attribute defines the
16130 directory in which the executables created by the build are to be placed.
16131 If not specified, executables are placed in the object directory.
16132
16133 @item  Source_Dirs
16134 Expression must be a list of path names. The attribute
16135 defines the directories in which the source files for the project are to be
16136 found. If not specified, source files are found in the project directory.
16137 If a string in the list ends with "/**", then the directory that precedes
16138 "/**" and all of its subdirectories (recursively) are included in the list
16139 of source directories.
16140
16141 @item  Excluded_Source_Dirs
16142 Expression must be a list of strings. Each entry designates a directory that
16143 is not to be included in the list of source directories of the project.
16144 This is normally used when there are strings ending with "/**" in the value
16145 of attribute Source_Dirs.
16146
16147 @item  Source_Files
16148 Expression must be a list of file names. The attribute
16149 defines the individual files, in the project directory, which are to be used
16150 as sources for the project. File names are path_names that contain no directory
16151 information. If the project has no sources the attribute must be declared
16152 explicitly with an empty list.
16153
16154 @item  Excluded_Source_Files (Locally_Removed_Files)
16155 Expression must be a list of strings that are legal file names.
16156 Each file name must designate a source that would normally be a source file
16157 in the source directories of the project or, if the project file is an
16158 extending project file, inherited by the current project file. It cannot
16159 designate an immediate source that is not inherited. Each of the source files
16160 in the list are not considered to be sources of the project file: they are not
16161 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16162 Excluded_Source_Files is preferred.
16163
16164 @item  Source_List_File
16165 Expression must a single path name. The attribute
16166 defines a text file that contains a list of source file names to be used
16167 as sources for the project
16168
16169 @item  Library_Dir
16170 Expression must be a path name. The attribute defines the
16171 directory in which a  library is to be built.  The directory must exist, must
16172 be distinct from the project's object directory, and must be writable.
16173
16174 @item  Library_Name
16175 Expression must be a string that is a legal file name,
16176 without extension. The attribute defines a string that is used to generate
16177 the name of the library to be built by the project.
16178
16179 @item  Library_Kind
16180 Argument must be a string value that must be one of the
16181 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16182 string is case-insensitive. If this attribute is not specified, the library is
16183 a static library. Otherwise, the library may be dynamic or relocatable. This
16184 distinction is operating-system dependent.
16185
16186 @item  Library_Version
16187 Expression must be a string value whose interpretation
16188 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16189 libraries as the internal name of the library (the @code{"soname"}). If the
16190 library file name (built from the @code{Library_Name}) is different from the
16191 @code{Library_Version}, then the library file will be a symbolic link to the
16192 actual file whose name will be @code{Library_Version}.
16193
16194 @item Library_Interface
16195 Expression must be a string list. Each element of the string list
16196 must designate a unit of the project.
16197 If this attribute is present in a Library Project File, then the project
16198 file is a Stand-alone Library_Project_File.
16199
16200 @item Library_Auto_Init
16201 Expression must be a single string "true" or "false", case-insensitive.
16202 If this attribute is present in a Stand-alone Library Project File,
16203 it indicates if initialization is automatic when the dynamic library
16204 is loaded.
16205
16206 @item Library_Options
16207 Expression must be a string list. Indicates additional switches that
16208 are to be used when building a shared library.
16209
16210 @item Library_GCC
16211 Expression must be a single string. Designates an alternative to "gcc"
16212 for building shared libraries.
16213
16214 @item  Library_Src_Dir
16215 Expression must be a path name. The attribute defines the
16216 directory in which the sources of the interfaces of a Stand-alone Library will
16217 be copied.  The directory must exist, must be distinct from the project's
16218 object directory and source directories of all projects in the project tree,
16219 and must be writable.
16220
16221 @item  Library_Src_Dir
16222 Expression must be a path name. The attribute defines the
16223 directory in which the ALI files of a Library will
16224 be copied.  The directory must exist, must be distinct from the project's
16225 object directory and source directories of all projects in the project tree,
16226 and must be writable.
16227
16228 @item  Library_Symbol_File
16229 Expression must be a single string. Its value is the single file name of a
16230 symbol file to be created when building a stand-alone library when the
16231 symbol policy is either "compliant", "controlled" or "restricted",
16232 on platforms that support symbol control, such as VMS. When symbol policy
16233 is "direct", then a file with this name must exist in the object directory.
16234
16235 @item   Library_Reference_Symbol_File
16236 Expression must be a single string. Its value is the path name of a
16237 reference symbol file that is read when the symbol policy is either
16238 "compliant" or "controlled", on platforms that support symbol control,
16239 such as VMS, when building a stand-alone library. The path may be an absolute
16240 path or a path relative to the project directory.
16241
16242 @item  Library_Symbol_Policy
16243 Expression must be a single string. Its case-insensitive value can only be
16244 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16245
16246 This attribute is not taken into account on all platforms. It controls the
16247 policy for exported symbols and, on some platforms (like VMS) that have the
16248 notions of major and minor IDs built in the library files, it controls
16249 the setting of these IDs.
16250
16251 "autonomous" or "default": exported symbols are not controlled.
16252
16253 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16254 it is equivalent to policy "autonomous". If there are exported symbols in
16255 the reference symbol file that are not in the object files of the interfaces,
16256 the major ID of the library is increased. If there are symbols in the
16257 object files of the interfaces that are not in the reference symbol file,
16258 these symbols are put at the end of the list in the newly created symbol file
16259 and the minor ID is increased.
16260
16261 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16262 The library will fail to build if the exported symbols in the object files of
16263 the interfaces do not match exactly the symbol in the symbol file.
16264
16265 "restricted": The attribute Library_Symbol_File must be defined. The library
16266 will fail to build if there are symbols in the symbol file that are not in
16267 the exported symbols of the object files of the interfaces. Additional symbols
16268 in the object files are not added to the symbol file.
16269
16270 "direct": The attribute Library_Symbol_File must be defined and must designate
16271 an existing file in the object directory. This symbol file is passed directly
16272 to the underlying linker without any symbol processing.
16273
16274 @item  Main
16275 Expression must be a list of strings that are legal file names.
16276 These file names designate existing compilation units in the source directory
16277 that are legal main subprograms.
16278
16279 When a project file is elaborated, as part of the execution of a gnatmake
16280 command, one or several executables are built and placed in the Exec_Dir.
16281 If the gnatmake command does not include explicit file names, the executables
16282 that are built correspond to the files specified by this attribute.
16283
16284 @item  Externally_Built
16285 Expression must be a single string. Its value must be either "true" of "false",
16286 case-insensitive. The default is "false". When the value of this attribute is
16287 "true", no attempt is made to compile the sources or to build the library,
16288 when the project is a library project.
16289
16290 @item Main_Language
16291 This is a simple attribute. Its value is a string that specifies the
16292 language of the main program.
16293
16294 @item  Languages
16295 Expression must be a string list. Each string designates
16296 a programming language that is known to GNAT. The strings are case-insensitive.
16297
16298 @end table
16299
16300 @node Attribute References
16301 @section Attribute References
16302
16303 @noindent
16304 Attribute references are used to retrieve the value of previously defined
16305 attribute for a package or project.
16306 Syntax:
16307 @smallexample
16308 attribute_reference ::=
16309   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16310
16311 attribute_prefix ::=
16312   @b{project} |
16313   <project_simple_name | package_identifier |
16314   <project_>simple_name . package_identifier
16315 @end smallexample
16316
16317 @noindent
16318 If an attribute has not been specified for a given package or project, its
16319 value is the null string or the empty list.
16320
16321 @node External Values
16322 @section External Values
16323
16324 @noindent
16325 An external value is an expression whose value is obtained from the command
16326 that invoked the processing of the current project file (typically a
16327 gnatmake command).
16328
16329 Syntax:
16330 @smallexample
16331 external_value ::=
16332   @b{external} ( string_literal [, string_literal] )
16333 @end smallexample
16334
16335 @noindent
16336 The first string_literal is the string to be used on the command line or
16337 in the environment to specify the external value. The second string_literal,
16338 if present, is the default to use if there is no specification for this
16339 external value either on the command line or in the environment.
16340
16341 @node Case Construction
16342 @section Case Construction
16343
16344 @noindent
16345 A case construction supports attribute and variable declarations that depend
16346 on the value of a previously declared variable.
16347
16348 Syntax:
16349 @smallexample
16350 case_construction ::=
16351   @b{case} <typed_variable_>name @b{is}
16352     @{case_item@}
16353   @b{end case} ;
16354
16355 case_item ::=
16356   @b{when} discrete_choice_list =>
16357     @{case_construction |
16358       attribute_declaration |
16359       variable_declaration |
16360       empty_declaration@}
16361
16362 discrete_choice_list ::=
16363   string_literal @{| string_literal@} |
16364     @b{others}
16365 @end smallexample
16366
16367 @noindent
16368 Inside a case construction, variable declarations must be for variables that
16369 have already been declared before the case construction.
16370
16371 All choices in a choice list must be distinct. The choice lists of two
16372 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16373 alternatives do not need to include all values of the type. An @code{others}
16374 choice must appear last in the list of alternatives.
16375
16376 @node Packages
16377 @section Packages
16378
16379 @noindent
16380 A package provides a grouping of variable declarations and attribute
16381 declarations to be used when invoking various GNAT tools. The name of
16382 the package indicates the tool(s) to which it applies.
16383 Syntax:
16384
16385 @smallexample
16386 package_declaration ::=
16387   package_spec | package_renaming
16388
16389 package_spec ::=
16390   @b{package} package_identifier @b{is}
16391     @{simple_declarative_item@}
16392   @b{end} package_identifier ;
16393
16394 package_identifier ::=
16395   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16396   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16397   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16398 @end smallexample
16399
16400 @subsection Package Naming
16401
16402 @noindent
16403 The attributes of a @code{Naming} package specifies the naming conventions
16404 that apply to the source files in a project. When invoking other GNAT tools,
16405 they will use the sources in the source directories that satisfy these
16406 naming conventions.
16407
16408 The following attributes apply to a @code{Naming} package:
16409
16410 @table @code
16411 @item Casing
16412 This is a simple attribute whose value is a string. Legal values of this
16413 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16414 These strings are themselves case insensitive.
16415
16416 @noindent
16417 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16418
16419 @item Dot_Replacement
16420 This is a simple attribute whose string value satisfies the following
16421 requirements:
16422
16423 @itemize @bullet
16424 @item It must not be empty
16425 @item It cannot start or end with an alphanumeric character
16426 @item It cannot be a single underscore
16427 @item It cannot start with an underscore followed by an alphanumeric
16428 @item It cannot contain a dot @code{'.'} if longer than one character
16429 @end itemize
16430
16431 @noindent
16432 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16433
16434 @item Spec_Suffix
16435 This is an associative array attribute, defined on language names,
16436 whose image is a string that must satisfy the following
16437 conditions:
16438
16439 @itemize @bullet
16440 @item It must not be empty
16441 @item It cannot start with an alphanumeric character
16442 @item It cannot start with an underscore followed by an alphanumeric character
16443 @end itemize
16444
16445 @noindent
16446 For Ada, the attribute denotes the suffix used in file names that contain
16447 library unit declarations, that is to say units that are package and
16448 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16449 specified, then the default is @code{".ads"}.
16450
16451 For C and C++, the attribute denotes the suffix used in file names that
16452 contain prototypes.
16453
16454 @item Body_Suffix
16455 This is an associative array attribute defined on language names,
16456 whose image is a string that must satisfy the following
16457 conditions:
16458
16459 @itemize @bullet
16460 @item It must not be empty
16461 @item It cannot start with an alphanumeric character
16462 @item It cannot start with an underscore followed by an alphanumeric character
16463 @item It cannot be a suffix of @code{Spec_Suffix}
16464 @end itemize
16465
16466 @noindent
16467 For Ada, the attribute denotes the suffix used in file names that contain
16468 library bodies, that is to say units that are package and subprogram bodies.
16469 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16470 @code{".adb"}.
16471
16472 For C and C++, the attribute denotes the suffix used in file names that contain
16473 source code.
16474
16475 @item Separate_Suffix
16476 This is a simple attribute whose value satisfies the same conditions as
16477 @code{Body_Suffix}.
16478
16479 This attribute is specific to Ada. It denotes the suffix used in file names
16480 that contain separate bodies. If it is not specified, then it defaults to same
16481 value as @code{Body_Suffix ("Ada")}.
16482
16483 @item Spec
16484 This is an associative array attribute, specific to Ada, defined over
16485 compilation unit names. The image is a string that is the name of the file
16486 that contains that library unit. The file name is case sensitive if the
16487 conventions of the host operating system require it.
16488
16489 @item Body
16490 This is an associative array attribute, specific to Ada, defined over
16491 compilation unit names. The image is a string that is the name of the file
16492 that contains the library unit body for the named unit. The file name is case
16493 sensitive if the conventions of the host operating system require it.
16494
16495 @item Specification_Exceptions
16496 This is an associative array attribute defined on language names,
16497 whose value is a list of strings.
16498
16499 This attribute is not significant for Ada.
16500
16501 For C and C++, each string in the list denotes the name of a file that
16502 contains prototypes, but whose suffix is not necessarily the
16503 @code{Spec_Suffix} for the language.
16504
16505 @item Implementation_Exceptions
16506 This is an associative array attribute defined on language names,
16507 whose value is a list of strings.
16508
16509 This attribute is not significant for Ada.
16510
16511 For C and C++, each string in the list denotes the name of a file that
16512 contains source code, but whose suffix is not necessarily the
16513 @code{Body_Suffix} for the language.
16514 @end table
16515
16516 The following attributes of package @code{Naming} are obsolescent. They are
16517 kept as synonyms of other attributes for compatibility with previous versions
16518 of the Project Manager.
16519
16520 @table @code
16521 @item Specification_Suffix
16522 This is a synonym of @code{Spec_Suffix}.
16523
16524 @item Implementation_Suffix
16525 This is a synonym of @code{Body_Suffix}.
16526
16527 @item Specification
16528 This is a synonym of @code{Spec}.
16529
16530 @item Implementation
16531 This is a synonym of @code{Body}.
16532 @end table
16533
16534 @subsection package Compiler
16535
16536 @noindent
16537 The attributes of the @code{Compiler} package specify the compilation options
16538 to be used by the underlying compiler.
16539
16540 @table @code
16541 @item  Default_Switches
16542 This is an associative array attribute. Its
16543 domain is a set of language names. Its range is a string list that
16544 specifies the compilation options to be used when compiling a component
16545 written in that language, for which no file-specific switches have been
16546 specified.
16547
16548 @item  Switches
16549 This is an associative array attribute. Its domain is
16550 a set of file names. Its range is a string list that specifies the
16551 compilation options to be used when compiling the named file. If a file
16552 is not specified in the Switches attribute, it is compiled with the
16553 options specified by Default_Switches of its language, if defined.
16554
16555 @item  Local_Configuration_Pragmas.
16556 This is a simple attribute, whose
16557 value is a path name that designates a file containing configuration pragmas
16558 to be used for all invocations of the compiler for immediate sources of the
16559 project.
16560 @end table
16561
16562 @subsection package Builder
16563
16564 @noindent
16565 The attributes of package @code{Builder} specify the compilation, binding, and
16566 linking options to be used when building an executable for a project. The
16567 following attributes apply to package @code{Builder}:
16568
16569 @table @code
16570 @item Default_Switches
16571 This is an associative array attribute. Its
16572 domain is a set of language names. Its range is a string list that
16573 specifies options to be used when building a main
16574 written in that language, for which no file-specific switches have been
16575 specified.
16576
16577 @item Switches
16578 This is an associative array attribute. Its domain is
16579 a set of file names. Its range is a string list that specifies
16580 options to be used when building the named main file. If a main file
16581 is not specified in the Switches attribute, it is built with the
16582 options specified by Default_Switches of its language, if defined.
16583
16584 @item Global_Configuration_Pragmas
16585 This is a simple attribute, whose
16586 value is a path name that designates a file that contains configuration pragmas
16587 to be used in every build of an executable. If both local and global
16588 configuration pragmas are specified, a compilation makes use of both sets.
16589
16590
16591 @item Executable
16592 This is an associative array attribute. Its domain is
16593 a set of main source file names. Its range is a simple string that specifies
16594 the executable file name to be used when linking the specified main source.
16595 If a main source is not specified in the Executable attribute, the executable
16596 file name is deducted from the main source file name.
16597 This attribute has no effect if its value is the empty string.
16598
16599 @item Executable_Suffix
16600 This is a simple attribute whose value is the suffix to be added to
16601 the executables that don't have an attribute Executable specified.
16602 @end table
16603
16604 @subsection package Gnatls
16605
16606 @noindent
16607 The attributes of package @code{Gnatls} specify the tool options to be used
16608 when invoking the library browser @command{gnatls}.
16609 The following attributes apply to package @code{Gnatls}:
16610
16611 @table @code
16612 @item Switches
16613 This is a single attribute with a string list value. Each nonempty string
16614 in the list is an option when invoking @code{gnatls}.
16615 @end table
16616
16617 @subsection package Binder
16618
16619 @noindent
16620 The attributes of package @code{Binder} specify the options to be used
16621 when invoking the binder in the construction of an executable.
16622 The following attributes apply to package @code{Binder}:
16623
16624 @table @code
16625 @item     Default_Switches
16626 This is an associative array attribute. Its
16627 domain is a set of language names. Its range is a string list that
16628 specifies options to be used when binding a main
16629 written in that language, for which no file-specific switches have been
16630 specified.
16631
16632 @item Switches
16633 This is an associative array attribute. Its domain is
16634 a set of file names. Its range is a string list that specifies
16635 options to be used when binding the named main file. If a main file
16636 is not specified in the Switches attribute, it is bound with the
16637 options specified by Default_Switches of its language, if defined.
16638 @end table
16639
16640 @subsection package Linker
16641
16642 @noindent
16643 The attributes of package @code{Linker} specify the options to be used when
16644 invoking the linker in the construction of an executable.
16645 The following attributes apply to package @code{Linker}:
16646
16647 @table @code
16648 @item     Default_Switches
16649 This is an associative array attribute. Its
16650 domain is a set of language names. Its range is a string list that
16651 specifies options to be used when linking a main
16652 written in that language, for which no file-specific switches have been
16653 specified.
16654
16655 @item Switches
16656 This is an associative array attribute. Its domain is
16657 a set of file names. Its range is a string list that specifies
16658 options to be used when linking the named main file. If a main file
16659 is not specified in the Switches attribute, it is linked with the
16660 options specified by Default_Switches of its language, if defined.
16661
16662 @item  Linker_Options
16663 This is a string list attribute. Its value specifies additional options that
16664 be given to the linker when linking an executable. This attribute is not
16665 used in the main project, only in projects imported directly or indirectly.
16666
16667 @end table
16668
16669 @subsection package Cross_Reference
16670
16671 @noindent
16672 The attributes of package @code{Cross_Reference} specify the tool options
16673 to be used
16674 when invoking the library tool @command{gnatxref}.
16675 The following attributes apply to package @code{Cross_Reference}:
16676
16677 @table @code
16678 @item     Default_Switches
16679 This is an associative array attribute. Its
16680 domain is a set of language names. Its range is a string list that
16681 specifies options to be used when calling @command{gnatxref} on a source
16682 written in that language, for which no file-specific switches have been
16683 specified.
16684
16685 @item Switches
16686 This is an associative array attribute. Its domain is
16687 a set of file names. Its range is a string list that specifies
16688 options to be used when calling @command{gnatxref} on the named main source.
16689 If a source is not specified in the Switches attribute, @command{gnatxref} will
16690 be called with the options specified by Default_Switches of its language,
16691 if defined.
16692 @end table
16693
16694 @subsection package   Finder
16695
16696 @noindent
16697 The attributes of package @code{Finder} specify the tool options to be used
16698 when invoking the search tool @command{gnatfind}.
16699 The following attributes apply to package @code{Finder}:
16700
16701 @table @code
16702 @item     Default_Switches
16703 This is an associative array attribute. Its
16704 domain is a set of language names. Its range is a string list that
16705 specifies options to be used when calling @command{gnatfind} on a source
16706 written in that language, for which no file-specific switches have been
16707 specified.
16708
16709 @item Switches
16710 This is an associative array attribute. Its domain is
16711 a set of file names. Its range is a string list that specifies
16712 options to be used when calling @command{gnatfind} on the named main source.
16713 If a source is not specified in the Switches attribute, @command{gnatfind} will
16714 be called with the options specified by Default_Switches of its language,
16715 if defined.
16716 @end table
16717
16718 @subsection package Pretty_Printer
16719
16720 @noindent
16721 The attributes of package @code{Pretty_Printer}
16722 specify the tool options to be used
16723 when invoking the formatting tool @command{gnatpp}.
16724 The following attributes apply to package @code{Pretty_Printer}:
16725
16726 @table @code
16727 @item     Default_switches
16728 This is an associative array attribute. Its
16729 domain is a set of language names. Its range is a string list that
16730 specifies options to be used when calling @command{gnatpp} on a source
16731 written in that language, for which no file-specific switches have been
16732 specified.
16733
16734 @item Switches
16735 This is an associative array attribute. Its domain is
16736 a set of file names. Its range is a string list that specifies
16737 options to be used when calling @command{gnatpp} on the named main source.
16738 If a source is not specified in the Switches attribute, @command{gnatpp} will
16739 be called with the options specified by Default_Switches of its language,
16740 if defined.
16741 @end table
16742
16743 @subsection package gnatstub
16744
16745 @noindent
16746 The attributes of package @code{gnatstub}
16747 specify the tool options to be used
16748 when invoking the tool @command{gnatstub}.
16749 The following attributes apply to package @code{gnatstub}:
16750
16751 @table @code
16752 @item     Default_switches
16753 This is an associative array attribute. Its
16754 domain is a set of language names. Its range is a string list that
16755 specifies options to be used when calling @command{gnatstub} on a source
16756 written in that language, for which no file-specific switches have been
16757 specified.
16758
16759 @item Switches
16760 This is an associative array attribute. Its domain is
16761 a set of file names. Its range is a string list that specifies
16762 options to be used when calling @command{gnatstub} on the named main source.
16763 If a source is not specified in the Switches attribute, @command{gnatpp} will
16764 be called with the options specified by Default_Switches of its language,
16765 if defined.
16766 @end table
16767
16768 @subsection package Eliminate
16769
16770 @noindent
16771 The attributes of package @code{Eliminate}
16772 specify the tool options to be used
16773 when invoking the tool @command{gnatelim}.
16774 The following attributes apply to package @code{Eliminate}:
16775
16776 @table @code
16777 @item     Default_switches
16778 This is an associative array attribute. Its
16779 domain is a set of language names. Its range is a string list that
16780 specifies options to be used when calling @command{gnatelim} on a source
16781 written in that language, for which no file-specific switches have been
16782 specified.
16783
16784 @item Switches
16785 This is an associative array attribute. Its domain is
16786 a set of file names. Its range is a string list that specifies
16787 options to be used when calling @command{gnatelim} on the named main source.
16788 If a source is not specified in the Switches attribute, @command{gnatelim} will
16789 be called with the options specified by Default_Switches of its language,
16790 if defined.
16791 @end table
16792
16793 @subsection package Metrics
16794
16795 @noindent
16796 The attributes of package @code{Metrics}
16797 specify the tool options to be used
16798 when invoking the tool @command{gnatmetric}.
16799 The following attributes apply to package @code{Metrics}:
16800
16801 @table @code
16802 @item     Default_switches
16803 This is an associative array attribute. Its
16804 domain is a set of language names. Its range is a string list that
16805 specifies options to be used when calling @command{gnatmetric} on a source
16806 written in that language, for which no file-specific switches have been
16807 specified.
16808
16809 @item Switches
16810 This is an associative array attribute. Its domain is
16811 a set of file names. Its range is a string list that specifies
16812 options to be used when calling @command{gnatmetric} on the named main source.
16813 If a source is not specified in the Switches attribute, @command{gnatmetric}
16814 will be called with the options specified by Default_Switches of its language,
16815 if defined.
16816 @end table
16817
16818 @subsection  package IDE
16819
16820 @noindent
16821 The attributes of package @code{IDE} specify the options to be used when using
16822 an Integrated Development Environment such as @command{GPS}.
16823
16824 @table @code
16825 @item Remote_Host
16826 This is a simple attribute. Its value is a string that designates the remote
16827 host in a cross-compilation environment, to be used for remote compilation and
16828 debugging. This field should not be specified when running on the local
16829 machine.
16830
16831 @item Program_Host
16832 This is a simple attribute. Its value is a string that specifies the
16833 name of IP address of the embedded target in a cross-compilation environment,
16834 on which the program should execute.
16835
16836 @item Communication_Protocol
16837 This is a simple string attribute. Its value is the name of the protocol
16838 to use to communicate with the target in a cross-compilation environment,
16839 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16840
16841 @item Compiler_Command
16842 This is an associative array attribute, whose domain is a language name. Its
16843 value is  string that denotes the command to be used to invoke the compiler.
16844 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16845 gnatmake, in particular in the handling of switches.
16846
16847 @item Debugger_Command
16848 This is simple attribute, Its value is a string that specifies the name of
16849 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16850
16851 @item Default_Switches
16852 This is an associative array attribute. Its indexes are the name of the
16853 external tools that the GNAT Programming System (GPS) is supporting. Its
16854 value is a list of switches to use when invoking that tool.
16855
16856 @item  Gnatlist
16857 This is a simple attribute.  Its value is a string that specifies the name
16858 of the @command{gnatls} utility to be used to retrieve information about the
16859 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16860
16861 @item VCS_Kind
16862 This is a simple attribute. Its value is a string used to specify the
16863 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16864 ClearCase or Perforce.
16865
16866 @item VCS_File_Check
16867 This is a simple attribute. Its value is a string that specifies the
16868 command used by the VCS to check the validity of a file, either
16869 when the user explicitly asks for a check, or as a sanity check before
16870 doing the check-in.
16871
16872 @item VCS_Log_Check
16873 This is a simple attribute. Its value is a string that specifies
16874 the command used by the VCS to check the validity of a log file.
16875
16876 @item VCS_Repository_Root
16877 The VCS repository root path. This is used to create tags or branches
16878 of the repository. For subversion the value should be the @code{URL}
16879 as specified to check-out the working copy of the repository.
16880
16881 @item VCS_Patch_Root
16882 The local root directory to use for building patch file. All patch chunks
16883 will be relative to this path. The root project directory is used if
16884 this value is not defined.
16885
16886 @end table
16887
16888 @node Package Renamings
16889 @section Package Renamings
16890
16891 @noindent
16892 A package can be defined by a renaming declaration. The new package renames
16893 a package declared in a different project file, and has the same attributes
16894 as the package it renames.
16895 Syntax:
16896 @smallexample
16897 package_renaming ::==
16898   @b{package} package_identifier @b{renames}
16899        <project_>simple_name.package_identifier ;
16900 @end smallexample
16901
16902 @noindent
16903 The package_identifier of the renamed package must be the same as the
16904 package_identifier. The project whose name is the prefix of the renamed
16905 package must contain a package declaration with this name. This project
16906 must appear in the context_clause of the enclosing project declaration,
16907 or be the parent project of the enclosing child project.
16908
16909 @node Projects
16910 @section Projects
16911
16912 @noindent
16913 A project file specifies a set of rules for constructing a software system.
16914 A project file can be self-contained, or depend on other project files.
16915 Dependencies are expressed through a context clause that names other projects.
16916
16917 Syntax:
16918
16919 @smallexample
16920 project ::=
16921   context_clause project_declaration
16922
16923 project_declaration ::=
16924   simple_project_declaration | project_extension
16925
16926 simple_project_declaration ::=
16927   @b{project} <project_>simple_name @b{is}
16928     @{declarative_item@}
16929   @b{end} <project_>simple_name;
16930
16931 context_clause ::=
16932   @{with_clause@}
16933
16934 with_clause ::=
16935   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16936
16937 path_name ::=
16938    string_literal
16939 @end smallexample
16940
16941 @noindent
16942 A path name denotes a project file. A path name can be absolute or relative.
16943 An absolute path name includes a sequence of directories, in the syntax of
16944 the host operating system, that identifies uniquely the project file in the
16945 file system. A relative path name identifies the project file, relative
16946 to the directory that contains the current project, or relative to a
16947 directory listed in the environment variable ADA_PROJECT_PATH.
16948 Path names are case sensitive if file names in the host operating system
16949 are case sensitive.
16950
16951 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16952 directory names separated by colons (semicolons on Windows).
16953
16954 A given project name can appear only once in a context_clause.
16955
16956 It is illegal for a project imported by a context clause to refer, directly
16957 or indirectly, to the project in which this context clause appears (the
16958 dependency graph cannot contain cycles), except when one of the with_clause
16959 in the cycle is a @code{limited with}.
16960
16961 @node Project Extensions
16962 @section Project Extensions
16963
16964 @noindent
16965 A project extension introduces a new project, which inherits the declarations
16966 of another project.
16967 Syntax:
16968 @smallexample
16969
16970 project_extension ::=
16971   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16972     @{declarative_item@}
16973   @b{end} <project_>simple_name;
16974 @end smallexample
16975
16976 @noindent
16977 The project extension declares a child project. The child project inherits
16978 all the declarations and all the files of the parent project, These inherited
16979 declaration can be overridden in the child project, by means of suitable
16980 declarations.
16981
16982 @node Project File Elaboration
16983 @section Project File Elaboration
16984
16985 @noindent
16986 A project file is processed as part of the invocation of a gnat tool that
16987 uses the project option. Elaboration of the process file consists in the
16988 sequential elaboration of all its declarations. The computed values of
16989 attributes and variables in the project are then used to establish the
16990 environment in which the gnat tool will execute.
16991
16992 @node Obsolescent Features
16993 @chapter Obsolescent Features
16994
16995 @noindent
16996 This chapter describes features that are provided by GNAT, but are
16997 considered obsolescent since there are preferred ways of achieving
16998 the same effect. These features are provided solely for historical
16999 compatibility purposes.
17000
17001 @menu
17002 * pragma No_Run_Time::
17003 * pragma Ravenscar::
17004 * pragma Restricted_Run_Time::
17005 @end menu
17006
17007 @node pragma No_Run_Time
17008 @section pragma No_Run_Time
17009
17010 The pragma @code{No_Run_Time} is used to achieve an affect similar
17011 to the use of the "Zero Foot Print" configurable run time, but without
17012 requiring a specially configured run time. The result of using this
17013 pragma, which must be used for all units in a partition, is to restrict
17014 the use of any language features requiring run-time support code. The
17015 preferred usage is to use an appropriately configured run-time that
17016 includes just those features that are to be made accessible.
17017
17018 @node pragma Ravenscar
17019 @section pragma Ravenscar
17020
17021 The pragma @code{Ravenscar} has exactly the same effect as pragma
17022 @code{Profile (Ravenscar)}. The latter usage is preferred since it
17023 is part of the new Ada 2005 standard.
17024
17025 @node pragma Restricted_Run_Time
17026 @section pragma Restricted_Run_Time
17027
17028 The pragma @code{Restricted_Run_Time} has exactly the same effect as
17029 pragma @code{Profile (Restricted)}. The latter usage is
17030 preferred since the Ada 2005 pragma @code{Profile} is intended for
17031 this kind of implementation dependent addition.
17032
17033 @include fdl.texi
17034 @c GNU Free Documentation License
17035
17036 @node Index,,GNU Free Documentation License, Top
17037 @unnumbered Index
17038
17039 @printindex cp
17040
17041 @contents
17042
17043 @bye