OSDN Git Service

2009-07-07 Gary Dismukes <dismukes@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.Strings (g-string.ads)::
385 * GNAT.String_Split (g-strspl.ads)::
386 * GNAT.Table (g-table.ads)::
387 * GNAT.Task_Lock (g-tasloc.ads)::
388 * GNAT.Threads (g-thread.ads)::
389 * GNAT.Time_Stamp (g-timsta.ads)::
390 * GNAT.Traceback (g-traceb.ads)::
391 * GNAT.Traceback.Symbolic (g-trasym.ads)::
392 * GNAT.UTF_32 (g-utf_32.ads)::
393 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
394 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
395 * GNAT.Wide_String_Split (g-wistsp.ads)::
396 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
397 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
398 * Interfaces.C.Extensions (i-cexten.ads)::
399 * Interfaces.C.Streams (i-cstrea.ads)::
400 * Interfaces.CPP (i-cpp.ads)::
401 * Interfaces.Packed_Decimal (i-pacdec.ads)::
402 * Interfaces.VxWorks (i-vxwork.ads)::
403 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
404 * System.Address_Image (s-addima.ads)::
405 * System.Assertions (s-assert.ads)::
406 * System.Memory (s-memory.ads)::
407 * System.Partition_Interface (s-parint.ads)::
408 * System.Pool_Global (s-pooglo.ads)::
409 * System.Pool_Local (s-pooloc.ads)::
410 * System.Restrictions (s-restri.ads)::
411 * System.Rident (s-rident.ads)::
412 * System.Task_Info (s-tasinf.ads)::
413 * System.Wch_Cnv (s-wchcnv.ads)::
414 * System.Wch_Con (s-wchcon.ads)::
415
416 Text_IO
417
418 * Text_IO Stream Pointer Positioning::
419 * Text_IO Reading and Writing Non-Regular Files::
420 * Get_Immediate::
421 * Treating Text_IO Files as Streams::
422 * Text_IO Extensions::
423 * Text_IO Facilities for Unbounded Strings::
424
425 Wide_Text_IO
426
427 * Wide_Text_IO Stream Pointer Positioning::
428 * Wide_Text_IO Reading and Writing Non-Regular Files::
429
430 Wide_Wide_Text_IO
431
432 * Wide_Wide_Text_IO Stream Pointer Positioning::
433 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
434
435 Interfacing to Other Languages
436
437 * Interfacing to C::
438 * Interfacing to C++::
439 * Interfacing to COBOL::
440 * Interfacing to Fortran::
441 * Interfacing to non-GNAT Ada code::
442
443 Specialized Needs Annexes
444
445 Implementation of Specific Ada Features
446 * Machine Code Insertions::
447 * GNAT Implementation of Tasking::
448 * GNAT Implementation of Shared Passive Packages::
449 * Code Generation for Array Aggregates::
450 * The Size of Discriminated Records with Default Discriminants::
451 * Strict Conformance to the Ada Reference Manual::
452
453 Project File Reference
454
455 Obsolescent Features
456
457 GNU Free Documentation License
458
459 Index
460 @end menu
461
462 @end ifnottex
463
464 @node About This Guide
465 @unnumbered About This Guide
466
467 @noindent
468 This manual contains useful information in writing programs using the
469 @value{EDITION} compiler.  It includes information on implementation dependent
470 characteristics of @value{EDITION}, including all the information required by
471 Annex M of the Ada language standard.
472
473 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
474 Ada 83 compatibility mode.
475 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
476 but you can override with a compiler switch
477 to explicitly specify the language version.
478 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
479 @value{EDITION} User's Guide}, for details on these switches.)
480 Throughout this manual, references to ``Ada'' without a year suffix
481 apply to both the Ada 95 and Ada 2005 versions of the language.
482
483 Ada is designed to be highly portable.
484 In general, a program will have the same effect even when compiled by
485 different compilers on different platforms.
486 However, since Ada is designed to be used in a
487 wide variety of applications, it also contains a number of system
488 dependent features to be used in interfacing to the external world.
489 @cindex Implementation-dependent features
490 @cindex Portability
491
492 Note: Any program that makes use of implementation-dependent features
493 may be non-portable.  You should follow good programming practice and
494 isolate and clearly document any sections of your program that make use
495 of these features in a non-portable manner.
496
497 @ifset PROEDITION
498 For ease of exposition, ``GNAT Pro'' will be referred to simply as
499 ``GNAT'' in the remainder of this document.
500 @end ifset
501
502 @menu
503 * What This Reference Manual Contains::
504 * Conventions::
505 * Related Information::
506 @end menu
507
508 @node What This Reference Manual Contains
509 @unnumberedsec What This Reference Manual Contains
510
511 @noindent
512 This reference manual contains the following chapters:
513
514 @itemize @bullet
515 @item
516 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
517 pragmas, which can be used to extend and enhance the functionality of the
518 compiler.
519
520 @item
521 @ref{Implementation Defined Attributes}, lists GNAT
522 implementation-dependent attributes which can be used to extend and
523 enhance the functionality of the compiler.
524
525 @item
526 @ref{Implementation Advice}, provides information on generally
527 desirable behavior which are not requirements that all compilers must
528 follow since it cannot be provided on all systems, or which may be
529 undesirable on some systems.
530
531 @item
532 @ref{Implementation Defined Characteristics}, provides a guide to
533 minimizing implementation dependent features.
534
535 @item
536 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
537 implemented by GNAT, and how they can be imported into user
538 application programs.
539
540 @item
541 @ref{Representation Clauses and Pragmas}, describes in detail the
542 way that GNAT represents data, and in particular the exact set
543 of representation clauses and pragmas that is accepted.
544
545 @item
546 @ref{Standard Library Routines}, provides a listing of packages and a
547 brief description of the functionality that is provided by Ada's
548 extensive set of standard library routines as implemented by GNAT@.
549
550 @item
551 @ref{The Implementation of Standard I/O}, details how the GNAT
552 implementation of the input-output facilities.
553
554 @item
555 @ref{The GNAT Library}, is a catalog of packages that complement
556 the Ada predefined library.
557
558 @item
559 @ref{Interfacing to Other Languages}, describes how programs
560 written in Ada using GNAT can be interfaced to other programming
561 languages.
562
563 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
564 of the specialized needs annexes.
565
566 @item
567 @ref{Implementation of Specific Ada Features}, discusses issues related
568 to GNAT's implementation of machine code insertions, tasking, and several
569 other features.
570
571 @item
572 @ref{Project File Reference}, presents the syntax and semantics
573 of project files.
574
575 @item
576 @ref{Obsolescent Features} documents implementation dependent features,
577 including pragmas and attributes, which are considered obsolescent, since
578 there are other preferred ways of achieving the same results. These
579 obsolescent forms are retained for backwards compatibility.
580
581 @end itemize
582
583 @cindex Ada 95 Language Reference Manual
584 @cindex Ada 2005 Language Reference Manual
585 @noindent
586 This reference manual assumes a basic familiarity with the Ada 95 language, as
587 described in the International Standard ANSI/ISO/IEC-8652:1995,
588 January 1995.
589 It does not require knowledge of the new features introduced by Ada 2005,
590 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
591 and Amendment 1).
592 Both reference manuals are included in the GNAT documentation
593 package.
594
595 @node Conventions
596 @unnumberedsec Conventions
597 @cindex Conventions, typographical
598 @cindex Typographical conventions
599
600 @noindent
601 Following are examples of the typographical and graphic conventions used
602 in this guide:
603
604 @itemize @bullet
605 @item
606 @code{Functions}, @code{utility program names}, @code{standard names},
607 and @code{classes}.
608
609 @item
610 @code{Option flags}
611
612 @item
613 @file{File names}, @samp{button names}, and @samp{field names}.
614
615 @item
616 @code{Variables}, @env{environment variables}, and @var{metasyntactic
617 variables}.
618
619 @item
620 @emph{Emphasis}.
621
622 @item
623 [optional information or parameters]
624
625 @item
626 Examples are described by text
627 @smallexample
628 and then shown this way.
629 @end smallexample
630 @end itemize
631
632 @noindent
633 Commands that are entered by the user are preceded in this manual by the
634 characters @samp{$ } (dollar sign followed by space).  If your system uses this
635 sequence as a prompt, then the commands will appear exactly as you see them
636 in the manual.  If your system uses some other prompt, then the command will
637 appear with the @samp{$} replaced by whatever prompt character you are using.
638
639 @node Related Information
640 @unnumberedsec Related Information
641 @noindent
642 See the following documents for further information on GNAT:
643
644 @itemize @bullet
645 @item
646 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
647 @value{EDITION} User's Guide}, which provides information on how to use the
648 GNAT compiler system.
649
650 @item
651 @cite{Ada 95 Reference Manual}, which contains all reference
652 material for the Ada 95 programming language.
653
654 @item
655 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
656 of the Ada 95 standard.  The annotations describe
657 detailed aspects of the design decision, and in particular contain useful
658 sections on Ada 83 compatibility.
659
660 @item
661 @cite{Ada 2005 Reference Manual}, which contains all reference
662 material for the Ada 2005 programming language.
663
664 @item
665 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
666 of the Ada 2005 standard.  The annotations describe
667 detailed aspects of the design decision, and in particular contain useful
668 sections on Ada 83 and Ada 95 compatibility.
669
670 @item
671 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
672 which contains specific information on compatibility between GNAT and
673 DEC Ada 83 systems.
674
675 @item
676 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
677 describes in detail the pragmas and attributes provided by the DEC Ada 83
678 compiler system.
679
680 @end itemize
681
682 @node Implementation Defined Pragmas
683 @chapter Implementation Defined Pragmas
684
685 @noindent
686 Ada defines a set of pragmas that can be used to supply additional
687 information to the compiler.  These language defined pragmas are
688 implemented in GNAT and work as described in the Ada Reference Manual.
689
690 In addition, Ada allows implementations to define additional pragmas
691 whose meaning is defined by the implementation.  GNAT provides a number
692 of these implementation-defined pragmas, which can be used to extend
693 and enhance the functionality of the compiler.  This section of the GNAT
694 Reference Manual describes these additional pragmas.
695
696 Note that any program using these pragmas might not be portable to other
697 compilers (although GNAT implements this set of pragmas on all
698 platforms).  Therefore if portability to other compilers is an important
699 consideration, the use of these pragmas should be minimized.
700
701 @menu
702 * Pragma Abort_Defer::
703 * Pragma Ada_83::
704 * Pragma Ada_95::
705 * Pragma Ada_05::
706 * Pragma Ada_2005::
707 * Pragma Annotate::
708 * Pragma Assert::
709 * Pragma Assume_No_Invalid_Values::
710 * Pragma Ast_Entry::
711 * Pragma C_Pass_By_Copy::
712 * Pragma Check::
713 * Pragma Check_Name::
714 * Pragma Check_Policy::
715 * Pragma Comment::
716 * Pragma Common_Object::
717 * Pragma Compile_Time_Error::
718 * Pragma Compile_Time_Warning::
719 * Pragma Complete_Representation::
720 * Pragma Complex_Representation::
721 * Pragma Component_Alignment::
722 * Pragma Convention_Identifier::
723 * Pragma CPP_Class::
724 * Pragma CPP_Constructor::
725 * Pragma CPP_Virtual::
726 * Pragma CPP_Vtable::
727 * Pragma Debug::
728 * Pragma Debug_Policy::
729 * Pragma Detect_Blocking::
730 * Pragma Elaboration_Checks::
731 * Pragma Eliminate::
732 * Pragma Export_Exception::
733 * Pragma Export_Function::
734 * Pragma Export_Object::
735 * Pragma Export_Procedure::
736 * Pragma Export_Value::
737 * Pragma Export_Valued_Procedure::
738 * Pragma Extend_System::
739 * Pragma External::
740 * Pragma External_Name_Casing::
741 * Pragma Fast_Math::
742 * Pragma Favor_Top_Level::
743 * Pragma Finalize_Storage_Only::
744 * Pragma Float_Representation::
745 * Pragma Ident::
746 * Pragma Implemented_By_Entry::
747 * Pragma Implicit_Packing::
748 * Pragma Import_Exception::
749 * Pragma Import_Function::
750 * Pragma Import_Object::
751 * Pragma Import_Procedure::
752 * Pragma Import_Valued_Procedure::
753 * Pragma Initialize_Scalars::
754 * Pragma Inline_Always::
755 * Pragma Inline_Generic::
756 * Pragma Interface::
757 * Pragma Interface_Name::
758 * Pragma Interrupt_Handler::
759 * Pragma Interrupt_State::
760 * Pragma Keep_Names::
761 * Pragma License::
762 * Pragma Link_With::
763 * Pragma Linker_Alias::
764 * Pragma Linker_Constructor::
765 * Pragma Linker_Destructor::
766 * Pragma Linker_Section::
767 * Pragma Long_Float::
768 * Pragma Machine_Attribute::
769 * Pragma Main::
770 * Pragma Main_Storage::
771 * Pragma No_Body::
772 * Pragma No_Return::
773 * Pragma No_Strict_Aliasing::
774 * Pragma Normalize_Scalars::
775 * Pragma Obsolescent::
776 * Pragma Optimize_Alignment::
777 * Pragma Passive::
778 * Pragma Persistent_BSS::
779 * Pragma Polling::
780 * Pragma Postcondition::
781 * Pragma Precondition::
782 * Pragma Profile (Ravenscar)::
783 * Pragma Profile (Restricted)::
784 * Pragma Psect_Object::
785 * Pragma Pure_Function::
786 * Pragma Restriction_Warnings::
787 * Pragma Shared::
788 * Pragma Source_File_Name::
789 * Pragma Source_File_Name_Project::
790 * Pragma Source_Reference::
791 * Pragma Stream_Convert::
792 * Pragma Style_Checks::
793 * Pragma Subtitle::
794 * Pragma Suppress::
795 * Pragma Suppress_All::
796 * Pragma Suppress_Exception_Locations::
797 * Pragma Suppress_Initialization::
798 * Pragma Task_Info::
799 * Pragma Task_Name::
800 * Pragma Task_Storage::
801 * Pragma Thread_Local_Storage::
802 * Pragma Time_Slice::
803 * Pragma Title::
804 * Pragma Unchecked_Union::
805 * Pragma Unimplemented_Unit::
806 * Pragma Universal_Aliasing ::
807 * Pragma Universal_Data::
808 * Pragma Unmodified::
809 * Pragma Unreferenced::
810 * Pragma Unreferenced_Objects::
811 * Pragma Unreserve_All_Interrupts::
812 * Pragma Unsuppress::
813 * Pragma Use_VADS_Size::
814 * Pragma Validity_Checks::
815 * Pragma Volatile::
816 * Pragma Warnings::
817 * Pragma Weak_External::
818 * Pragma Wide_Character_Encoding::
819 @end menu
820
821 @node Pragma Abort_Defer
822 @unnumberedsec Pragma Abort_Defer
823 @findex Abort_Defer
824 @cindex Deferring aborts
825 @noindent
826 Syntax:
827 @smallexample
828 pragma Abort_Defer;
829 @end smallexample
830
831 @noindent
832 This pragma must appear at the start of the statement sequence of a
833 handled sequence of statements (right after the @code{begin}).  It has
834 the effect of deferring aborts for the sequence of statements (but not
835 for the declarations or handlers, if any, associated with this statement
836 sequence).
837
838 @node Pragma Ada_83
839 @unnumberedsec Pragma Ada_83
840 @findex Ada_83
841 @noindent
842 Syntax:
843 @smallexample @c ada
844 pragma Ada_83;
845 @end smallexample
846
847 @noindent
848 A configuration pragma that establishes Ada 83 mode for the unit to
849 which it applies, regardless of the mode set by the command line
850 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
851 the syntax and semantics of Ada 83, as defined in the original Ada
852 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
853 and Ada 2005 are not recognized, optional package bodies are allowed,
854 and generics may name types with unknown discriminants without using
855 the @code{(<>)} notation.  In addition, some but not all of the additional
856 restrictions of Ada 83 are enforced.
857
858 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
859 Ada 83 code to be compiled and adapted to GNAT with less effort.
860 Secondly, it aids in keeping code backwards compatible with Ada 83.
861 However, there is no guarantee that code that is processed correctly
862 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
863 83 compiler, since GNAT does not enforce all the additional checks
864 required by Ada 83.
865
866 @node Pragma Ada_95
867 @unnumberedsec Pragma Ada_95
868 @findex Ada_95
869 @noindent
870 Syntax:
871 @smallexample @c ada
872 pragma Ada_95;
873 @end smallexample
874
875 @noindent
876 A configuration pragma that establishes Ada 95 mode for the unit to which
877 it applies, regardless of the mode set by the command line switches.
878 This mode is set automatically for the @code{Ada} and @code{System}
879 packages and their children, so you need not specify it in these
880 contexts.  This pragma is useful when writing a reusable component that
881 itself uses Ada 95 features, but which is intended to be usable from
882 either Ada 83 or Ada 95 programs.
883
884 @node Pragma Ada_05
885 @unnumberedsec Pragma Ada_05
886 @findex Ada_05
887 @noindent
888 Syntax:
889 @smallexample @c ada
890 pragma Ada_05;
891 @end smallexample
892
893 @noindent
894 A configuration pragma that establishes Ada 2005 mode for the unit to which
895 it applies, regardless of the mode set by the command line switches.
896 This mode is set automatically for the @code{Ada} and @code{System}
897 packages and their children, so you need not specify it in these
898 contexts.  This pragma is useful when writing a reusable component that
899 itself uses Ada 2005 features, but which is intended to be usable from
900 either Ada 83 or Ada 95 programs.
901
902 @node Pragma Ada_2005
903 @unnumberedsec Pragma Ada_2005
904 @findex Ada_2005
905 @noindent
906 Syntax:
907 @smallexample @c ada
908 pragma Ada_2005;
909 @end smallexample
910
911 @noindent
912 This configuration pragma is a synonym for pragma Ada_05 and has the
913 same syntax and effect.
914
915 @node Pragma Annotate
916 @unnumberedsec Pragma Annotate
917 @findex Annotate
918 @noindent
919 Syntax:
920 @smallexample @c ada
921 pragma Annotate (IDENTIFIER @{, ARG@});
922
923 ARG ::= NAME | EXPRESSION
924 @end smallexample
925
926 @noindent
927 This pragma is used to annotate programs.  @var{identifier} identifies
928 the type of annotation.  GNAT verifies that it is an identifier, but does
929 not otherwise analyze it.  The @var{arg} argument
930 can be either a string literal or an
931 expression.  String literals are assumed to be of type
932 @code{Standard.String}.  Names of entities are simply analyzed as entity
933 names.  All other expressions are analyzed as expressions, and must be
934 unambiguous.
935
936 The analyzed pragma is retained in the tree, but not otherwise processed
937 by any part of the GNAT compiler.  This pragma is intended for use by
938 external tools, including ASIS@.
939
940 @node Pragma Assert
941 @unnumberedsec Pragma Assert
942 @findex Assert
943 @noindent
944 Syntax:
945 @smallexample @c ada
946 pragma Assert (
947   boolean_EXPRESSION
948   [, string_EXPRESSION]);
949 @end smallexample
950
951 @noindent
952 The effect of this pragma depends on whether the corresponding command
953 line switch is set to activate assertions.  The pragma expands into code
954 equivalent to the following:
955
956 @smallexample @c ada
957 if assertions-enabled then
958    if not boolean_EXPRESSION then
959       System.Assertions.Raise_Assert_Failure
960         (string_EXPRESSION);
961    end if;
962 end if;
963 @end smallexample
964
965 @noindent
966 The string argument, if given, is the message that will be associated
967 with the exception occurrence if the exception is raised.  If no second
968 argument is given, the default message is @samp{@var{file}:@var{nnn}},
969 where @var{file} is the name of the source file containing the assert,
970 and @var{nnn} is the line number of the assert.  A pragma is not a
971 statement, so if a statement sequence contains nothing but a pragma
972 assert, then a null statement is required in addition, as in:
973
974 @smallexample @c ada
975 @dots{}
976 if J > 3 then
977    pragma Assert (K > 3, "Bad value for K");
978    null;
979 end if;
980 @end smallexample
981
982 @noindent
983 Note that, as with the @code{if} statement to which it is equivalent, the
984 type of the expression is either @code{Standard.Boolean}, or any type derived
985 from this standard type.
986
987 If assertions are disabled (switch @option{-gnata} not used), then there
988 is no run-time effect (and in particular, any side effects from the
989 expression will not occur at run time).  (The expression is still
990 analyzed at compile time, and may cause types to be frozen if they are
991 mentioned here for the first time).
992
993 If assertions are enabled, then the given expression is tested, and if
994 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
995 which results in the raising of @code{Assert_Failure} with the given message.
996
997 You should generally avoid side effects in the expression arguments of
998 this pragma, because these side effects will turn on and off with the
999 setting of the assertions mode, resulting in assertions that have an
1000 effect on the program.  However, the expressions are analyzed for
1001 semantic correctness whether or not assertions are enabled, so turning
1002 assertions on and off cannot affect the legality of a program.
1003
1004 @node Pragma Assume_No_Invalid_Values
1005 @unnumberedsec Pragma Assume_No_Invalid_Values
1006 @findex Assume_No_Invalid_Values
1007 @cindex Invalid representations
1008 @cindex Invalid values
1009 @noindent
1010 Syntax:
1011 @smallexample @c ada
1012 pragma Assume_No_Invalid_Values (On | Off);
1013 @end smallexample
1014
1015 @noindent
1016 This is a configuration pragma that controls the assumptions made by the
1017 compiler about the occurrence of invalid representations (invalid values)
1018 in the code.
1019
1020 The default behavior (corresponding to an Off argument for this pragma), is
1021 to assume that values may in general be invalid unless the compiler can
1022 prove they are valid. Consider the following example:
1023
1024 @smallexample @c ada
1025 V1 : Integer range 1 .. 10;
1026 V2 : Integer range 11 .. 20;
1027 ...
1028 for J in V2 .. V1 loop
1029    ...
1030 end loop;
1031 @end smallexample
1032
1033 @noindent
1034 if V1 and V2 have valid values, then the loop is known at compile
1035 time not to execute since the lower bound must be greater than the
1036 upper bound. However in default mode, no such assumption is made,
1037 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1038 is given, the compiler will assume that any occurrence of a variable
1039 other than in an explicit @code{'Valid} test always has a valid
1040 value, and the loop above will be optimized away.
1041
1042 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1043 you know your code is free of uninitialized variables and other
1044 possible sources of invalid representations, and may result in
1045 more efficient code. A program that accesses an invalid representation
1046 with this pragma in effect is erroneous, so no guarantees can be made
1047 about its behavior.
1048
1049 It is peculiar though permissible to use this pragma in conjunction
1050 with validity checking (-gnatVa). In such cases, accessing invalid
1051 values will generally give an exception, though formally the program
1052 is erroneous so there are no guarantees that this will always be the
1053 case, and it is recommended that these two options not be used together.
1054
1055 @node Pragma Ast_Entry
1056 @unnumberedsec Pragma Ast_Entry
1057 @cindex OpenVMS
1058 @findex Ast_Entry
1059 @noindent
1060 Syntax:
1061 @smallexample @c ada
1062 pragma AST_Entry (entry_IDENTIFIER);
1063 @end smallexample
1064
1065 @noindent
1066 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1067 argument is the simple name of a single entry; at most one @code{AST_Entry}
1068 pragma is allowed for any given entry.  This pragma must be used in
1069 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1070 the entry declaration and in the same task type specification or single task
1071 as the entry to which it applies.  This pragma specifies that the given entry
1072 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1073 resulting from an OpenVMS system service call.  The pragma does not affect
1074 normal use of the entry.  For further details on this pragma, see the
1075 DEC Ada Language Reference Manual, section 9.12a.
1076
1077 @node Pragma C_Pass_By_Copy
1078 @unnumberedsec Pragma C_Pass_By_Copy
1079 @cindex Passing by copy
1080 @findex C_Pass_By_Copy
1081 @noindent
1082 Syntax:
1083 @smallexample @c ada
1084 pragma C_Pass_By_Copy
1085   ([Max_Size =>] static_integer_EXPRESSION);
1086 @end smallexample
1087
1088 @noindent
1089 Normally the default mechanism for passing C convention records to C
1090 convention subprograms is to pass them by reference, as suggested by RM
1091 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1092 this default, by requiring that record formal parameters be passed by
1093 copy if all of the following conditions are met:
1094
1095 @itemize @bullet
1096 @item
1097 The size of the record type does not exceed the value specified for
1098 @code{Max_Size}.
1099 @item
1100 The record type has @code{Convention C}.
1101 @item
1102 The formal parameter has this record type, and the subprogram has a
1103 foreign (non-Ada) convention.
1104 @end itemize
1105
1106 @noindent
1107 If these conditions are met the argument is passed by copy, i.e.@: in a
1108 manner consistent with what C expects if the corresponding formal in the
1109 C prototype is a struct (rather than a pointer to a struct).
1110
1111 You can also pass records by copy by specifying the convention
1112 @code{C_Pass_By_Copy} for the record type, or by using the extended
1113 @code{Import} and @code{Export} pragmas, which allow specification of
1114 passing mechanisms on a parameter by parameter basis.
1115
1116 @node Pragma Check
1117 @unnumberedsec Pragma Check
1118 @cindex Assertions
1119 @cindex Named assertions
1120 @findex Check
1121 @noindent
1122 Syntax:
1123 @smallexample @c ada
1124 pragma Check (
1125      [Name    =>] Identifier,
1126      [Check   =>] Boolean_EXPRESSION
1127   [, [Message =>] string_EXPRESSION] );
1128 @end smallexample
1129
1130 @noindent
1131 This pragma is similar to the predefined pragma @code{Assert} except that an
1132 extra identifier argument is present. In conjunction with pragma
1133 @code{Check_Policy}, this can be used to define groups of assertions that can
1134 be independently controlled. The identifier @code{Assertion} is special, it
1135 refers to the normal set of pragma @code{Assert} statements. The identifiers
1136 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1137 names, so these three names would normally not be used directly in a pragma
1138 @code{Check}.
1139
1140 Checks introduced by this pragma are normally deactivated by default. They can
1141 be activated either by the command line option @option{-gnata}, which turns on
1142 all checks, or individually controlled using pragma @code{Check_Policy}.
1143
1144 @node Pragma Check_Name
1145 @unnumberedsec Pragma Check_Name
1146 @cindex Defining check names
1147 @cindex Check names, defining
1148 @findex Check_Name
1149 @noindent
1150 Syntax:
1151 @smallexample @c ada
1152 pragma Check_Name (check_name_IDENTIFIER);
1153 @end smallexample
1154
1155 @noindent
1156 This is a configuration pragma that defines a new implementation
1157 defined check name (unless IDENTIFIER matches one of the predefined
1158 check names, in which case the pragma has no effect). Check names
1159 are global to a partition, so if two or more configuration pragmas
1160 are present in a partition mentioning the same name, only one new
1161 check name is introduced.
1162
1163 An implementation defined check name introduced with this pragma may
1164 be used in only three contexts: @code{pragma Suppress},
1165 @code{pragma Unsuppress},
1166 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1167 any of these three cases, the check name must be visible. A check
1168 name is visible if it is in the configuration pragmas applying to
1169 the current unit, or if it appears at the start of any unit that
1170 is part of the dependency set of the current unit (e.g., units that
1171 are mentioned in @code{with} clauses).
1172
1173 @node Pragma Check_Policy
1174 @unnumberedsec Pragma Check_Policy
1175 @cindex Controlling assertions
1176 @cindex Assertions, control
1177 @cindex Check pragma control
1178 @cindex Named assertions
1179 @findex Check
1180 @noindent
1181 Syntax:
1182 @smallexample @c ada
1183 pragma Check_Policy
1184  ([Name   =>] Identifier,
1185   [Policy =>] POLICY_IDENTIFIER);
1186
1187 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1188 @end smallexample
1189
1190 @noindent
1191 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1192 except that it controls sets of named assertions introduced using the
1193 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1194 @code{Assertion_Policy}) can be used within a declarative part, in which case
1195 it controls the status to the end of the corresponding construct (in a manner
1196 identical to pragma @code{Suppress)}.
1197
1198 The identifier given as the first argument corresponds to a name used in
1199 associated @code{Check} pragmas. For example, if the pragma:
1200
1201 @smallexample @c ada
1202 pragma Check_Policy (Critical_Error, Off);
1203 @end smallexample
1204
1205 @noindent
1206 is given, then subsequent @code{Check} pragmas whose first argument is also
1207 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1208 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1209 @code{Check_Policy} with this identifier is similar to the normal
1210 @code{Assertion_Policy} pragma except that it can appear within a
1211 declarative part).
1212
1213 The special identifiers @code{Precondition} and @code{Postcondition} control
1214 the status of preconditions and postconditions. If a @code{Precondition} pragma
1215 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1216 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1217 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1218 are recognized.
1219
1220 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1221 to turn on corresponding checks. The default for a set of checks for which no
1222 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1223 @option{-gnata} is given, which turns on all checks by default.
1224
1225 The check policy settings @code{Check} and @code{Ignore} are also recognized
1226 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1227 compatibility with the standard @code{Assertion_Policy} pragma.
1228
1229 @node Pragma Comment
1230 @unnumberedsec Pragma Comment
1231 @findex Comment
1232 @noindent
1233 Syntax:
1234
1235 @smallexample @c ada
1236 pragma Comment (static_string_EXPRESSION);
1237 @end smallexample
1238
1239 @noindent
1240 This is almost identical in effect to pragma @code{Ident}.  It allows the
1241 placement of a comment into the object file and hence into the
1242 executable file if the operating system permits such usage.  The
1243 difference is that @code{Comment}, unlike @code{Ident}, has
1244 no limitations on placement of the pragma (it can be placed
1245 anywhere in the main source unit), and if more than one pragma
1246 is used, all comments are retained.
1247
1248 @node Pragma Common_Object
1249 @unnumberedsec Pragma Common_Object
1250 @findex Common_Object
1251 @noindent
1252 Syntax:
1253
1254 @smallexample @c ada
1255 pragma Common_Object (
1256      [Internal =>] LOCAL_NAME
1257   [, [External =>] EXTERNAL_SYMBOL]
1258   [, [Size     =>] EXTERNAL_SYMBOL] );
1259
1260 EXTERNAL_SYMBOL ::=
1261   IDENTIFIER
1262 | static_string_EXPRESSION
1263 @end smallexample
1264
1265 @noindent
1266 This pragma enables the shared use of variables stored in overlaid
1267 linker areas corresponding to the use of @code{COMMON}
1268 in Fortran.  The single
1269 object @var{LOCAL_NAME} is assigned to the area designated by
1270 the @var{External} argument.
1271 You may define a record to correspond to a series
1272 of fields.  The @var{Size} argument
1273 is syntax checked in GNAT, but otherwise ignored.
1274
1275 @code{Common_Object} is not supported on all platforms.  If no
1276 support is available, then the code generator will issue a message
1277 indicating that the necessary attribute for implementation of this
1278 pragma is not available.
1279
1280 @node Pragma Compile_Time_Error
1281 @unnumberedsec Pragma Compile_Time_Error
1282 @findex Compile_Time_Error
1283 @noindent
1284 Syntax:
1285
1286 @smallexample @c ada
1287 pragma Compile_Time_Error
1288          (boolean_EXPRESSION, static_string_EXPRESSION);
1289 @end smallexample
1290
1291 @noindent
1292 This pragma can be used to generate additional compile time
1293 error messages. It
1294 is particularly useful in generics, where errors can be issued for
1295 specific problematic instantiations. The first parameter is a boolean
1296 expression. The pragma is effective only if the value of this expression
1297 is known at compile time, and has the value True. The set of expressions
1298 whose values are known at compile time includes all static boolean
1299 expressions, and also other values which the compiler can determine
1300 at compile time (e.g., the size of a record type set by an explicit
1301 size representation clause, or the value of a variable which was
1302 initialized to a constant and is known not to have been modified).
1303 If these conditions are met, an error message is generated using
1304 the value given as the second argument. This string value may contain
1305 embedded ASCII.LF characters to break the message into multiple lines.
1306
1307 @node Pragma Compile_Time_Warning
1308 @unnumberedsec Pragma Compile_Time_Warning
1309 @findex Compile_Time_Warning
1310 @noindent
1311 Syntax:
1312
1313 @smallexample @c ada
1314 pragma Compile_Time_Warning
1315          (boolean_EXPRESSION, static_string_EXPRESSION);
1316 @end smallexample
1317
1318 @noindent
1319 Same as pragma Compile_Time_Error, except a warning is issued instead
1320 of an error message. Note that if this pragma is used in a package that
1321 is with'ed by a client, the client will get the warning even though it
1322 is issued by a with'ed package (normally warnings in with'ed units are
1323 suppressed, but this is a special exception to that rule).
1324
1325 One typical use is within a generic where compile time known characteristics
1326 of formal parameters are tested, and warnings given appropriately. Another use
1327 with a first parameter of True is to warn a client about use of a package,
1328 for example that it is not fully implemented.
1329
1330 @node Pragma Complete_Representation
1331 @unnumberedsec Pragma Complete_Representation
1332 @findex Complete_Representation
1333 @noindent
1334 Syntax:
1335
1336 @smallexample @c ada
1337 pragma Complete_Representation;
1338 @end smallexample
1339
1340 @noindent
1341 This pragma must appear immediately within a record representation
1342 clause. Typical placements are before the first component clause
1343 or after the last component clause. The effect is to give an error
1344 message if any component is missing a component clause. This pragma
1345 may be used to ensure that a record representation clause is
1346 complete, and that this invariant is maintained if fields are
1347 added to the record in the future.
1348
1349 @node Pragma Complex_Representation
1350 @unnumberedsec Pragma Complex_Representation
1351 @findex Complex_Representation
1352 @noindent
1353 Syntax:
1354
1355 @smallexample @c ada
1356 pragma Complex_Representation
1357         ([Entity =>] LOCAL_NAME);
1358 @end smallexample
1359
1360 @noindent
1361 The @var{Entity} argument must be the name of a record type which has
1362 two fields of the same floating-point type.  The effect of this pragma is
1363 to force gcc to use the special internal complex representation form for
1364 this record, which may be more efficient.  Note that this may result in
1365 the code for this type not conforming to standard ABI (application
1366 binary interface) requirements for the handling of record types.  For
1367 example, in some environments, there is a requirement for passing
1368 records by pointer, and the use of this pragma may result in passing
1369 this type in floating-point registers.
1370
1371 @node Pragma Component_Alignment
1372 @unnumberedsec Pragma Component_Alignment
1373 @cindex Alignments of components
1374 @findex Component_Alignment
1375 @noindent
1376 Syntax:
1377
1378 @smallexample @c ada
1379 pragma Component_Alignment (
1380      [Form =>] ALIGNMENT_CHOICE
1381   [, [Name =>] type_LOCAL_NAME]);
1382
1383 ALIGNMENT_CHOICE ::=
1384   Component_Size
1385 | Component_Size_4
1386 | Storage_Unit
1387 | Default
1388 @end smallexample
1389
1390 @noindent
1391 Specifies the alignment of components in array or record types.
1392 The meaning of the @var{Form} argument is as follows:
1393
1394 @table @code
1395 @findex Component_Size
1396 @item Component_Size
1397 Aligns scalar components and subcomponents of the array or record type
1398 on boundaries appropriate to their inherent size (naturally
1399 aligned).  For example, 1-byte components are aligned on byte boundaries,
1400 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1401 integer components are aligned on 4-byte boundaries and so on.  These
1402 alignment rules correspond to the normal rules for C compilers on all
1403 machines except the VAX@.
1404
1405 @findex Component_Size_4
1406 @item Component_Size_4
1407 Naturally aligns components with a size of four or fewer
1408 bytes.  Components that are larger than 4 bytes are placed on the next
1409 4-byte boundary.
1410
1411 @findex Storage_Unit
1412 @item Storage_Unit
1413 Specifies that array or record components are byte aligned, i.e.@:
1414 aligned on boundaries determined by the value of the constant
1415 @code{System.Storage_Unit}.
1416
1417 @cindex OpenVMS
1418 @item Default
1419 Specifies that array or record components are aligned on default
1420 boundaries, appropriate to the underlying hardware or operating system or
1421 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1422 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1423 the @code{Default} choice is the same as @code{Component_Size} (natural
1424 alignment).
1425 @end table
1426
1427 @noindent
1428 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1429 refer to a local record or array type, and the specified alignment
1430 choice applies to the specified type.  The use of
1431 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1432 @code{Component_Alignment} pragma to be ignored.  The use of
1433 @code{Component_Alignment} together with a record representation clause
1434 is only effective for fields not specified by the representation clause.
1435
1436 If the @code{Name} parameter is absent, the pragma can be used as either
1437 a configuration pragma, in which case it applies to one or more units in
1438 accordance with the normal rules for configuration pragmas, or it can be
1439 used within a declarative part, in which case it applies to types that
1440 are declared within this declarative part, or within any nested scope
1441 within this declarative part.  In either case it specifies the alignment
1442 to be applied to any record or array type which has otherwise standard
1443 representation.
1444
1445 If the alignment for a record or array type is not specified (using
1446 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1447 clause), the GNAT uses the default alignment as described previously.
1448
1449 @node Pragma Convention_Identifier
1450 @unnumberedsec Pragma Convention_Identifier
1451 @findex Convention_Identifier
1452 @cindex Conventions, synonyms
1453 @noindent
1454 Syntax:
1455
1456 @smallexample @c ada
1457 pragma Convention_Identifier (
1458          [Name =>]       IDENTIFIER,
1459          [Convention =>] convention_IDENTIFIER);
1460 @end smallexample
1461
1462 @noindent
1463 This pragma provides a mechanism for supplying synonyms for existing
1464 convention identifiers. The @code{Name} identifier can subsequently
1465 be used as a synonym for the given convention in other pragmas (including
1466 for example pragma @code{Import} or another @code{Convention_Identifier}
1467 pragma). As an example of the use of this, suppose you had legacy code
1468 which used Fortran77 as the identifier for Fortran. Then the pragma:
1469
1470 @smallexample @c ada
1471 pragma Convention_Identifier (Fortran77, Fortran);
1472 @end smallexample
1473
1474 @noindent
1475 would allow the use of the convention identifier @code{Fortran77} in
1476 subsequent code, avoiding the need to modify the sources. As another
1477 example, you could use this to parametrize convention requirements
1478 according to systems. Suppose you needed to use @code{Stdcall} on
1479 windows systems, and @code{C} on some other system, then you could
1480 define a convention identifier @code{Library} and use a single
1481 @code{Convention_Identifier} pragma to specify which convention
1482 would be used system-wide.
1483
1484 @node Pragma CPP_Class
1485 @unnumberedsec Pragma CPP_Class
1486 @findex CPP_Class
1487 @cindex Interfacing with C++
1488 @noindent
1489 Syntax:
1490
1491 @smallexample @c ada
1492 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1493 @end smallexample
1494
1495 @noindent
1496 The argument denotes an entity in the current declarative region that is
1497 declared as a tagged record type. It indicates that the type corresponds
1498 to an externally declared C++ class type, and is to be laid out the same
1499 way that C++ would lay out the type.
1500
1501 Types for which @code{CPP_Class} is specified do not have assignment or
1502 equality operators defined (such operations can be imported or declared
1503 as subprograms as required). Initialization is allowed only by constructor
1504 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1505 limited if not explicitly declared as limited or derived from a limited
1506 type, and an error is issued in that case.
1507
1508 Pragma @code{CPP_Class} is intended primarily for automatic generation
1509 using an automatic binding generator tool.
1510 See @ref{Interfacing to C++} for related information.
1511
1512 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1513 for backward compatibility but its functionality is available
1514 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1515
1516 @node Pragma CPP_Constructor
1517 @unnumberedsec Pragma CPP_Constructor
1518 @cindex Interfacing with C++
1519 @findex CPP_Constructor
1520 @noindent
1521 Syntax:
1522
1523 @smallexample @c ada
1524 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1525   [, [External_Name =>] static_string_EXPRESSION ]
1526   [, [Link_Name     =>] static_string_EXPRESSION ]);
1527 @end smallexample
1528
1529 @noindent
1530 This pragma identifies an imported function (imported in the usual way
1531 with pragma @code{Import}) as corresponding to a C++ constructor. If
1532 @code{External_Name} and @code{Link_Name} are not specified then the
1533 @code{Entity} argument is a name that must have been previously mentioned
1534 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1535 must be of one of the following forms:
1536
1537 @itemize @bullet
1538 @item
1539 @code{function @var{Fname} return @var{T}'Class}
1540
1541 @item
1542 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1543 @end itemize
1544
1545 @noindent
1546 where @var{T} is a tagged limited type imported from C++ with pragma
1547 @code{Import} and @code{Convention} = @code{CPP}.
1548
1549 The first form is the default constructor, used when an object of type
1550 @var{T} is created on the Ada side with no explicit constructor.  The
1551 second form covers all the non-default constructors of the type. See
1552 the GNAT users guide for details.
1553
1554 If no constructors are imported, it is impossible to create any objects
1555 on the Ada side and the type is implicitly declared abstract.
1556
1557 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1558 using an automatic binding generator tool.
1559 See @ref{Interfacing to C++} for more related information.
1560
1561 @node Pragma CPP_Virtual
1562 @unnumberedsec Pragma CPP_Virtual
1563 @cindex Interfacing to C++
1564 @findex CPP_Virtual
1565 @noindent
1566 This pragma is now obsolete has has no effect because GNAT generates
1567 the same object layout than the G++ compiler.
1568
1569 See @ref{Interfacing to C++} for related information.
1570
1571 @node Pragma CPP_Vtable
1572 @unnumberedsec Pragma CPP_Vtable
1573 @cindex Interfacing with C++
1574 @findex CPP_Vtable
1575 @noindent
1576 This pragma is now obsolete has has no effect because GNAT generates
1577 the same object layout than the G++ compiler.
1578
1579 See @ref{Interfacing to C++} for related information.
1580
1581 @node Pragma Debug
1582 @unnumberedsec Pragma Debug
1583 @findex Debug
1584 @noindent
1585 Syntax:
1586
1587 @smallexample @c ada
1588 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1589
1590 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1591   PROCEDURE_NAME
1592 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1593 @end smallexample
1594
1595 @noindent
1596 The procedure call argument has the syntactic form of an expression, meeting
1597 the syntactic requirements for pragmas.
1598
1599 If debug pragmas are not enabled or if the condition is present and evaluates
1600 to False, this pragma has no effect. If debug pragmas are enabled, the
1601 semantics of the pragma is exactly equivalent to the procedure call statement
1602 corresponding to the argument with a terminating semicolon. Pragmas are
1603 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1604 intersperse calls to debug procedures in the middle of declarations. Debug
1605 pragmas can be enabled either by use of the command line switch @option{-gnata}
1606 or by use of the configuration pragma @code{Debug_Policy}.
1607
1608 @node Pragma Debug_Policy
1609 @unnumberedsec Pragma Debug_Policy
1610 @findex Debug_Policy
1611 @noindent
1612 Syntax:
1613
1614 @smallexample @c ada
1615 pragma Debug_Policy (CHECK | IGNORE);
1616 @end smallexample
1617
1618 @noindent
1619 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1620 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1621 This pragma overrides the effect of the @option{-gnata} switch on the
1622 command line.
1623
1624 @node Pragma Detect_Blocking
1625 @unnumberedsec Pragma Detect_Blocking
1626 @findex Detect_Blocking
1627 @noindent
1628 Syntax:
1629
1630 @smallexample @c ada
1631 pragma Detect_Blocking;
1632 @end smallexample
1633
1634 @noindent
1635 This is a configuration pragma that forces the detection of potentially
1636 blocking operations within a protected operation, and to raise Program_Error
1637 if that happens.
1638
1639 @node Pragma Elaboration_Checks
1640 @unnumberedsec Pragma Elaboration_Checks
1641 @cindex Elaboration control
1642 @findex Elaboration_Checks
1643 @noindent
1644 Syntax:
1645
1646 @smallexample @c ada
1647 pragma Elaboration_Checks (Dynamic | Static);
1648 @end smallexample
1649
1650 @noindent
1651 This is a configuration pragma that provides control over the
1652 elaboration model used by the compilation affected by the
1653 pragma.  If the parameter is @code{Dynamic},
1654 then the dynamic elaboration
1655 model described in the Ada Reference Manual is used, as though
1656 the @option{-gnatE} switch had been specified on the command
1657 line.  If the parameter is @code{Static}, then the default GNAT static
1658 model is used.  This configuration pragma overrides the setting
1659 of the command line.  For full details on the elaboration models
1660 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1661 gnat_ugn, @value{EDITION} User's Guide}.
1662
1663 @node Pragma Eliminate
1664 @unnumberedsec Pragma Eliminate
1665 @cindex Elimination of unused subprograms
1666 @findex Eliminate
1667 @noindent
1668 Syntax:
1669
1670 @smallexample @c ada
1671 pragma Eliminate (
1672     [Unit_Name =>] IDENTIFIER |
1673                    SELECTED_COMPONENT);
1674
1675 pragma Eliminate (
1676     [Unit_Name       =>]  IDENTIFIER |
1677                           SELECTED_COMPONENT,
1678     [Entity          =>]  IDENTIFIER |
1679                           SELECTED_COMPONENT |
1680                           STRING_LITERAL
1681     [,OVERLOADING_RESOLUTION]);
1682
1683 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1684                            SOURCE_LOCATION
1685
1686 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1687                                       FUNCTION_PROFILE
1688
1689 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1690
1691 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1692                       Result_Type => result_SUBTYPE_NAME]
1693
1694 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1695 SUBTYPE_NAME    ::= STRING_VALUE
1696
1697 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1698 SOURCE_TRACE    ::= STRING_VALUE
1699
1700 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1701 @end smallexample
1702
1703 @noindent
1704 This pragma indicates that the given entity is not used outside the
1705 compilation unit it is defined in. The entity must be an explicitly declared
1706 subprogram; this includes  generic subprogram instances and
1707 subprograms declared in generic package instances.
1708
1709 If the entity to be eliminated is a library level subprogram, then
1710 the first form of pragma @code{Eliminate} is used with only a single argument.
1711 In this form, the @code{Unit_Name} argument specifies the name of the
1712 library  level unit to be eliminated.
1713
1714 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1715 are required. If item is an entity of a library package, then the first
1716 argument specifies the unit name, and the second argument specifies
1717 the particular entity.  If the second argument is in string form, it must
1718 correspond to the internal manner in which GNAT stores entity names (see
1719 compilation unit Namet in the compiler sources for details).
1720
1721 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1722 to distinguish between overloaded subprograms. If a pragma does not contain
1723 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1724 subprograms denoted by the first two parameters.
1725
1726 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1727 to be eliminated in a manner similar to that used for the extended
1728 @code{Import} and @code{Export} pragmas, except that the subtype names are
1729 always given as strings. At the moment, this form of distinguishing
1730 overloaded subprograms is implemented only partially, so we do not recommend
1731 using it for practical subprogram elimination.
1732
1733 Note that in case of a parameterless procedure its profile is represented
1734 as @code{Parameter_Types => ("")}
1735
1736 Alternatively, the @code{Source_Location} parameter is used to specify
1737 which overloaded alternative is to be eliminated by pointing to the
1738 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1739 source text. The string literal (or concatenation of string literals)
1740 given as SOURCE_TRACE must have the following format:
1741
1742 @smallexample @c ada
1743 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1744
1745 LBRACKET ::= [
1746 RBRACKET ::= ]
1747
1748 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1749 FILE_NAME       ::= STRING_LITERAL
1750 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1751 @end smallexample
1752
1753 SOURCE_TRACE should be the short name of the source file (with no directory
1754 information), and LINE_NUMBER is supposed to point to the line where the
1755 defining name of the subprogram is located.
1756
1757 For the subprograms that are not a part of generic instantiations, only one
1758 SOURCE_LOCATION is used. If a subprogram is declared in a package
1759 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1760 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1761 second one denotes the declaration of the corresponding subprogram in the
1762 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1763 in case of nested instantiations.
1764
1765 The effect of the pragma is to allow the compiler to eliminate
1766 the code or data associated with the named entity.  Any reference to
1767 an eliminated entity outside the compilation unit it is defined in,
1768 causes a compile time or link time error.
1769
1770 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1771 in a system independent manner, with unused entities eliminated, without
1772 the requirement of modifying the source text.  Normally the required set
1773 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1774 tool. Elimination of unused entities local to a compilation unit is
1775 automatic, without requiring the use of pragma @code{Eliminate}.
1776
1777 Note that the reason this pragma takes string literals where names might
1778 be expected is that a pragma @code{Eliminate} can appear in a context where the
1779 relevant names are not visible.
1780
1781 Note that any change in the source files that includes removing, splitting of
1782 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1783 parameter illegal.
1784
1785 It is legal to use pragma Eliminate where the referenced entity is a
1786 dispatching operation, but it is not clear what this would mean, since
1787 in general the call does not know which entity is actually being called.
1788 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1789
1790 @node Pragma Export_Exception
1791 @unnumberedsec Pragma Export_Exception
1792 @cindex OpenVMS
1793 @findex Export_Exception
1794 @noindent
1795 Syntax:
1796
1797 @smallexample @c ada
1798 pragma Export_Exception (
1799      [Internal =>] LOCAL_NAME
1800   [, [External =>] EXTERNAL_SYMBOL]
1801   [, [Form     =>] Ada | VMS]
1802   [, [Code     =>] static_integer_EXPRESSION]);
1803
1804 EXTERNAL_SYMBOL ::=
1805   IDENTIFIER
1806 | static_string_EXPRESSION
1807 @end smallexample
1808
1809 @noindent
1810 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1811 causes the specified exception to be propagated outside of the Ada program,
1812 so that it can be handled by programs written in other OpenVMS languages.
1813 This pragma establishes an external name for an Ada exception and makes the
1814 name available to the OpenVMS Linker as a global symbol.  For further details
1815 on this pragma, see the
1816 DEC Ada Language Reference Manual, section 13.9a3.2.
1817
1818 @node Pragma Export_Function
1819 @unnumberedsec Pragma Export_Function
1820 @cindex Argument passing mechanisms
1821 @findex Export_Function
1822
1823 @noindent
1824 Syntax:
1825
1826 @smallexample @c ada
1827 pragma Export_Function (
1828      [Internal         =>] LOCAL_NAME
1829   [, [External         =>] EXTERNAL_SYMBOL]
1830   [, [Parameter_Types  =>] PARAMETER_TYPES]
1831   [, [Result_Type      =>] result_SUBTYPE_MARK]
1832   [, [Mechanism        =>] MECHANISM]
1833   [, [Result_Mechanism =>] MECHANISM_NAME]);
1834
1835 EXTERNAL_SYMBOL ::=
1836   IDENTIFIER
1837 | static_string_EXPRESSION
1838 | ""
1839
1840 PARAMETER_TYPES ::=
1841   null
1842 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1843
1844 TYPE_DESIGNATOR ::=
1845   subtype_NAME
1846 | subtype_Name ' Access
1847
1848 MECHANISM ::=
1849   MECHANISM_NAME
1850 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1851
1852 MECHANISM_ASSOCIATION ::=
1853   [formal_parameter_NAME =>] MECHANISM_NAME
1854
1855 MECHANISM_NAME ::=
1856   Value
1857 | Reference
1858 | Descriptor [([Class =>] CLASS_NAME)]
1859 | Short_Descriptor [([Class =>] CLASS_NAME)]
1860
1861 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1862 @end smallexample
1863
1864 @noindent
1865 Use this pragma to make a function externally callable and optionally
1866 provide information on mechanisms to be used for passing parameter and
1867 result values.  We recommend, for the purposes of improving portability,
1868 this pragma always be used in conjunction with a separate pragma
1869 @code{Export}, which must precede the pragma @code{Export_Function}.
1870 GNAT does not require a separate pragma @code{Export}, but if none is
1871 present, @code{Convention Ada} is assumed, which is usually
1872 not what is wanted, so it is usually appropriate to use this
1873 pragma in conjunction with a @code{Export} or @code{Convention}
1874 pragma that specifies the desired foreign convention.
1875 Pragma @code{Export_Function}
1876 (and @code{Export}, if present) must appear in the same declarative
1877 region as the function to which they apply.
1878
1879 @var{internal_name} must uniquely designate the function to which the
1880 pragma applies.  If more than one function name exists of this name in
1881 the declarative part you must use the @code{Parameter_Types} and
1882 @code{Result_Type} parameters is mandatory to achieve the required
1883 unique designation.  @var{subtype_mark}s in these parameters must
1884 exactly match the subtypes in the corresponding function specification,
1885 using positional notation to match parameters with subtype marks.
1886 The form with an @code{'Access} attribute can be used to match an
1887 anonymous access parameter.
1888
1889 @cindex OpenVMS
1890 @cindex Passing by descriptor
1891 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1892 The default behavior for Export_Function is to accept either 64bit or
1893 32bit descriptors unless short_descriptor is specified, then only 32bit
1894 descriptors are accepted.
1895
1896 @cindex Suppressing external name
1897 Special treatment is given if the EXTERNAL is an explicit null
1898 string or a static string expressions that evaluates to the null
1899 string. In this case, no external name is generated. This form
1900 still allows the specification of parameter mechanisms.
1901
1902 @node Pragma Export_Object
1903 @unnumberedsec Pragma Export_Object
1904 @findex Export_Object
1905 @noindent
1906 Syntax:
1907
1908 @smallexample @c ada
1909 pragma Export_Object
1910       [Internal =>] LOCAL_NAME
1911    [, [External =>] EXTERNAL_SYMBOL]
1912    [, [Size     =>] EXTERNAL_SYMBOL]
1913
1914 EXTERNAL_SYMBOL ::=
1915   IDENTIFIER
1916 | static_string_EXPRESSION
1917 @end smallexample
1918
1919 @noindent
1920 This pragma designates an object as exported, and apart from the
1921 extended rules for external symbols, is identical in effect to the use of
1922 the normal @code{Export} pragma applied to an object.  You may use a
1923 separate Export pragma (and you probably should from the point of view
1924 of portability), but it is not required.  @var{Size} is syntax checked,
1925 but otherwise ignored by GNAT@.
1926
1927 @node Pragma Export_Procedure
1928 @unnumberedsec Pragma Export_Procedure
1929 @findex Export_Procedure
1930 @noindent
1931 Syntax:
1932
1933 @smallexample @c ada
1934 pragma Export_Procedure (
1935      [Internal        =>] LOCAL_NAME
1936   [, [External        =>] EXTERNAL_SYMBOL]
1937   [, [Parameter_Types =>] PARAMETER_TYPES]
1938   [, [Mechanism       =>] MECHANISM]);
1939
1940 EXTERNAL_SYMBOL ::=
1941   IDENTIFIER
1942 | static_string_EXPRESSION
1943 | ""
1944
1945 PARAMETER_TYPES ::=
1946   null
1947 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1948
1949 TYPE_DESIGNATOR ::=
1950   subtype_NAME
1951 | subtype_Name ' Access
1952
1953 MECHANISM ::=
1954   MECHANISM_NAME
1955 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1956
1957 MECHANISM_ASSOCIATION ::=
1958   [formal_parameter_NAME =>] MECHANISM_NAME
1959
1960 MECHANISM_NAME ::=
1961   Value
1962 | Reference
1963 | Descriptor [([Class =>] CLASS_NAME)]
1964 | Short_Descriptor [([Class =>] CLASS_NAME)]
1965
1966 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1967 @end smallexample
1968
1969 @noindent
1970 This pragma is identical to @code{Export_Function} except that it
1971 applies to a procedure rather than a function and the parameters
1972 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1973 GNAT does not require a separate pragma @code{Export}, but if none is
1974 present, @code{Convention Ada} is assumed, which is usually
1975 not what is wanted, so it is usually appropriate to use this
1976 pragma in conjunction with a @code{Export} or @code{Convention}
1977 pragma that specifies the desired foreign convention.
1978
1979 @cindex OpenVMS
1980 @cindex Passing by descriptor
1981 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1982 The default behavior for Export_Procedure is to accept either 64bit or
1983 32bit descriptors unless short_descriptor is specified, then only 32bit
1984 descriptors are accepted.
1985
1986 @cindex Suppressing external name
1987 Special treatment is given if the EXTERNAL is an explicit null
1988 string or a static string expressions that evaluates to the null
1989 string. In this case, no external name is generated. This form
1990 still allows the specification of parameter mechanisms.
1991
1992 @node Pragma Export_Value
1993 @unnumberedsec Pragma Export_Value
1994 @findex Export_Value
1995 @noindent
1996 Syntax:
1997
1998 @smallexample @c ada
1999 pragma Export_Value (
2000   [Value     =>] static_integer_EXPRESSION,
2001   [Link_Name =>] static_string_EXPRESSION);
2002 @end smallexample
2003
2004 @noindent
2005 This pragma serves to export a static integer value for external use.
2006 The first argument specifies the value to be exported. The Link_Name
2007 argument specifies the symbolic name to be associated with the integer
2008 value. This pragma is useful for defining a named static value in Ada
2009 that can be referenced in assembly language units to be linked with
2010 the application. This pragma is currently supported only for the
2011 AAMP target and is ignored for other targets.
2012
2013 @node Pragma Export_Valued_Procedure
2014 @unnumberedsec Pragma Export_Valued_Procedure
2015 @findex Export_Valued_Procedure
2016 @noindent
2017 Syntax:
2018
2019 @smallexample @c ada
2020 pragma Export_Valued_Procedure (
2021      [Internal        =>] LOCAL_NAME
2022   [, [External        =>] EXTERNAL_SYMBOL]
2023   [, [Parameter_Types =>] PARAMETER_TYPES]
2024   [, [Mechanism       =>] MECHANISM]);
2025
2026 EXTERNAL_SYMBOL ::=
2027   IDENTIFIER
2028 | static_string_EXPRESSION
2029 | ""
2030
2031 PARAMETER_TYPES ::=
2032   null
2033 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2034
2035 TYPE_DESIGNATOR ::=
2036   subtype_NAME
2037 | subtype_Name ' Access
2038
2039 MECHANISM ::=
2040   MECHANISM_NAME
2041 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2042
2043 MECHANISM_ASSOCIATION ::=
2044   [formal_parameter_NAME =>] MECHANISM_NAME
2045
2046 MECHANISM_NAME ::=
2047   Value
2048 | Reference
2049 | Descriptor [([Class =>] CLASS_NAME)]
2050 | Short_Descriptor [([Class =>] CLASS_NAME)]
2051
2052 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2053 @end smallexample
2054
2055 @noindent
2056 This pragma is identical to @code{Export_Procedure} except that the
2057 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2058 mode @code{OUT}, and externally the subprogram is treated as a function
2059 with this parameter as the result of the function.  GNAT provides for
2060 this capability to allow the use of @code{OUT} and @code{IN OUT}
2061 parameters in interfacing to external functions (which are not permitted
2062 in Ada functions).
2063 GNAT does not require a separate pragma @code{Export}, but if none is
2064 present, @code{Convention Ada} is assumed, which is almost certainly
2065 not what is wanted since the whole point of this pragma is to interface
2066 with foreign language functions, so it is usually appropriate to use this
2067 pragma in conjunction with a @code{Export} or @code{Convention}
2068 pragma that specifies the desired foreign convention.
2069
2070 @cindex OpenVMS
2071 @cindex Passing by descriptor
2072 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2073 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2074 32bit descriptors unless short_descriptor is specified, then only 32bit
2075 descriptors are accepted.
2076
2077 @cindex Suppressing external name
2078 Special treatment is given if the EXTERNAL is an explicit null
2079 string or a static string expressions that evaluates to the null
2080 string. In this case, no external name is generated. This form
2081 still allows the specification of parameter mechanisms.
2082
2083 @node Pragma Extend_System
2084 @unnumberedsec Pragma Extend_System
2085 @cindex @code{system}, extending
2086 @cindex Dec Ada 83
2087 @findex Extend_System
2088 @noindent
2089 Syntax:
2090
2091 @smallexample @c ada
2092 pragma Extend_System ([Name =>] IDENTIFIER);
2093 @end smallexample
2094
2095 @noindent
2096 This pragma is used to provide backwards compatibility with other
2097 implementations that extend the facilities of package @code{System}.  In
2098 GNAT, @code{System} contains only the definitions that are present in
2099 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2100 implementation, provide many extensions to package @code{System}.
2101
2102 For each such implementation accommodated by this pragma, GNAT provides a
2103 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2104 implementation, which provides the required additional definitions.  You
2105 can use this package in two ways.  You can @code{with} it in the normal
2106 way and access entities either by selection or using a @code{use}
2107 clause.  In this case no special processing is required.
2108
2109 However, if existing code contains references such as
2110 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2111 definitions provided in package @code{System}, you may use this pragma
2112 to extend visibility in @code{System} in a non-standard way that
2113 provides greater compatibility with the existing code.  Pragma
2114 @code{Extend_System} is a configuration pragma whose single argument is
2115 the name of the package containing the extended definition
2116 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2117 control of this pragma will be processed using special visibility
2118 processing that looks in package @code{System.Aux_@var{xxx}} where
2119 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2120 package @code{System}, but not found in package @code{System}.
2121
2122 You can use this pragma either to access a predefined @code{System}
2123 extension supplied with the compiler, for example @code{Aux_DEC} or
2124 you can construct your own extension unit following the above
2125 definition.  Note that such a package is a child of @code{System}
2126 and thus is considered part of the implementation.  To compile
2127 it you will have to use the appropriate switch for compiling
2128 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2129 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2130
2131 @node Pragma External
2132 @unnumberedsec Pragma External
2133 @findex External
2134 @noindent
2135 Syntax:
2136
2137 @smallexample @c ada
2138 pragma External (
2139   [   Convention    =>] convention_IDENTIFIER,
2140   [   Entity        =>] LOCAL_NAME
2141   [, [External_Name =>] static_string_EXPRESSION ]
2142   [, [Link_Name     =>] static_string_EXPRESSION ]);
2143 @end smallexample
2144
2145 @noindent
2146 This pragma is identical in syntax and semantics to pragma
2147 @code{Export} as defined in the Ada Reference Manual.  It is
2148 provided for compatibility with some Ada 83 compilers that
2149 used this pragma for exactly the same purposes as pragma
2150 @code{Export} before the latter was standardized.
2151
2152 @node Pragma External_Name_Casing
2153 @unnumberedsec Pragma External_Name_Casing
2154 @cindex Dec Ada 83 casing compatibility
2155 @cindex External Names, casing
2156 @cindex Casing of External names
2157 @findex External_Name_Casing
2158 @noindent
2159 Syntax:
2160
2161 @smallexample @c ada
2162 pragma External_Name_Casing (
2163   Uppercase | Lowercase
2164   [, Uppercase | Lowercase | As_Is]);
2165 @end smallexample
2166
2167 @noindent
2168 This pragma provides control over the casing of external names associated
2169 with Import and Export pragmas.  There are two cases to consider:
2170
2171 @table @asis
2172 @item Implicit external names
2173 Implicit external names are derived from identifiers.  The most common case
2174 arises when a standard Ada Import or Export pragma is used with only two
2175 arguments, as in:
2176
2177 @smallexample @c ada
2178    pragma Import (C, C_Routine);
2179 @end smallexample
2180
2181 @noindent
2182 Since Ada is a case-insensitive language, the spelling of the identifier in
2183 the Ada source program does not provide any information on the desired
2184 casing of the external name, and so a convention is needed.  In GNAT the
2185 default treatment is that such names are converted to all lower case
2186 letters.  This corresponds to the normal C style in many environments.
2187 The first argument of pragma @code{External_Name_Casing} can be used to
2188 control this treatment.  If @code{Uppercase} is specified, then the name
2189 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2190 then the normal default of all lower case letters will be used.
2191
2192 This same implicit treatment is also used in the case of extended DEC Ada 83
2193 compatible Import and Export pragmas where an external name is explicitly
2194 specified using an identifier rather than a string.
2195
2196 @item Explicit external names
2197 Explicit external names are given as string literals.  The most common case
2198 arises when a standard Ada Import or Export pragma is used with three
2199 arguments, as in:
2200
2201 @smallexample @c ada
2202 pragma Import (C, C_Routine, "C_routine");
2203 @end smallexample
2204
2205 @noindent
2206 In this case, the string literal normally provides the exact casing required
2207 for the external name.  The second argument of pragma
2208 @code{External_Name_Casing} may be used to modify this behavior.
2209 If @code{Uppercase} is specified, then the name
2210 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2211 then the name will be forced to all lowercase letters.  A specification of
2212 @code{As_Is} provides the normal default behavior in which the casing is
2213 taken from the string provided.
2214 @end table
2215
2216 @noindent
2217 This pragma may appear anywhere that a pragma is valid.  In particular, it
2218 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2219 case it applies to all subsequent compilations, or it can be used as a program
2220 unit pragma, in which case it only applies to the current unit, or it can
2221 be used more locally to control individual Import/Export pragmas.
2222
2223 It is primarily intended for use with OpenVMS systems, where many
2224 compilers convert all symbols to upper case by default.  For interfacing to
2225 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2226 the pragma:
2227
2228 @smallexample @c ada
2229 pragma External_Name_Casing (Uppercase, Uppercase);
2230 @end smallexample
2231
2232 @noindent
2233 to enforce the upper casing of all external symbols.
2234
2235 @node Pragma Fast_Math
2236 @unnumberedsec Pragma Fast_Math
2237 @findex Fast_Math
2238 @noindent
2239 Syntax:
2240
2241 @smallexample @c ada
2242 pragma Fast_Math;
2243 @end smallexample
2244
2245 @noindent
2246 This is a configuration pragma which activates a mode in which speed is
2247 considered more important for floating-point operations than absolutely
2248 accurate adherence to the requirements of the standard. Currently the
2249 following operations are affected:
2250
2251 @table @asis
2252 @item Complex Multiplication
2253 The normal simple formula for complex multiplication can result in intermediate
2254 overflows for numbers near the end of the range. The Ada standard requires that
2255 this situation be detected and corrected by scaling, but in Fast_Math mode such
2256 cases will simply result in overflow. Note that to take advantage of this you
2257 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2258 under control of the pragma, rather than use the preinstantiated versions.
2259 @end table
2260
2261 @node Pragma Favor_Top_Level
2262 @unnumberedsec Pragma Favor_Top_Level
2263 @findex Favor_Top_Level
2264 @noindent
2265 Syntax:
2266
2267 @smallexample @c ada
2268 pragma Favor_Top_Level (type_NAME);
2269 @end smallexample
2270
2271 @noindent
2272 The named type must be an access-to-subprogram type. This pragma is an
2273 efficiency hint to the compiler, regarding the use of 'Access or
2274 'Unrestricted_Access on nested (non-library-level) subprograms. The
2275 pragma means that nested subprograms are not used with this type, or
2276 are rare, so that the generated code should be efficient in the
2277 top-level case. When this pragma is used, dynamically generated
2278 trampolines may be used on some targets for nested subprograms.
2279 See also the No_Implicit_Dynamic_Code restriction.
2280
2281 @node Pragma Finalize_Storage_Only
2282 @unnumberedsec Pragma Finalize_Storage_Only
2283 @findex Finalize_Storage_Only
2284 @noindent
2285 Syntax:
2286
2287 @smallexample @c ada
2288 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2289 @end smallexample
2290
2291 @noindent
2292 This pragma allows the compiler not to emit a Finalize call for objects
2293 defined at the library level.  This is mostly useful for types where
2294 finalization is only used to deal with storage reclamation since in most
2295 environments it is not necessary to reclaim memory just before terminating
2296 execution, hence the name.
2297
2298 @node Pragma Float_Representation
2299 @unnumberedsec Pragma Float_Representation
2300 @cindex OpenVMS
2301 @findex Float_Representation
2302 @noindent
2303 Syntax:
2304
2305 @smallexample @c ada
2306 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2307
2308 FLOAT_REP ::= VAX_Float | IEEE_Float
2309 @end smallexample
2310
2311 @noindent
2312 In the one argument form, this pragma is a configuration pragma which
2313 allows control over the internal representation chosen for the predefined
2314 floating point types declared in the packages @code{Standard} and
2315 @code{System}. On all systems other than OpenVMS, the argument must
2316 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2317 argument may be @code{VAX_Float} to specify the use of the VAX float
2318 format for the floating-point types in Standard. This requires that
2319 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2320 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2321 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2322
2323 The two argument form specifies the representation to be used for
2324 the specified floating-point type. On all systems other than OpenVMS,
2325 the argument must
2326 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2327 argument may be @code{VAX_Float} to specify the use of the VAX float
2328 format, as follows:
2329
2330 @itemize @bullet
2331 @item
2332 For digits values up to 6, F float format will be used.
2333 @item
2334 For digits values from 7 to 9, G float format will be used.
2335 @item
2336 For digits values from 10 to 15, F float format will be used.
2337 @item
2338 Digits values above 15 are not allowed.
2339 @end itemize
2340
2341 @node Pragma Ident
2342 @unnumberedsec Pragma Ident
2343 @findex Ident
2344 @noindent
2345 Syntax:
2346
2347 @smallexample @c ada
2348 pragma Ident (static_string_EXPRESSION);
2349 @end smallexample
2350
2351 @noindent
2352 This pragma provides a string identification in the generated object file,
2353 if the system supports the concept of this kind of identification string.
2354 This pragma is allowed only in the outermost declarative part or
2355 declarative items of a compilation unit. If more than one @code{Ident}
2356 pragma is given, only the last one processed is effective.
2357 @cindex OpenVMS
2358 On OpenVMS systems, the effect of the pragma is identical to the effect of
2359 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2360 maximum allowed length is 31 characters, so if it is important to
2361 maintain compatibility with this compiler, you should obey this length
2362 limit.
2363
2364 @node Pragma Implemented_By_Entry
2365 @unnumberedsec Pragma Implemented_By_Entry
2366 @findex Implemented_By_Entry
2367 @noindent
2368 Syntax:
2369
2370 @smallexample @c ada
2371 pragma Implemented_By_Entry (LOCAL_NAME);
2372 @end smallexample
2373
2374 @noindent
2375 This is a representation pragma which applies to protected, synchronized and
2376 task interface primitives. If the pragma is applied to primitive operation Op
2377 of interface Iface, it is illegal to override Op in a type that implements
2378 Iface, with anything other than an entry.
2379
2380 @smallexample @c ada
2381 type Iface is protected interface;
2382 procedure Do_Something (Object : in out Iface) is abstract;
2383 pragma Implemented_By_Entry (Do_Something);
2384
2385 protected type P is new Iface with
2386    procedure Do_Something;  --  Illegal
2387 end P;
2388
2389 task type T is new Iface with
2390    entry Do_Something;      --  Legal
2391 end T;
2392 @end smallexample
2393
2394 @noindent
2395 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2396 is intended to be used in conjunction with dispatching requeue statements as
2397 described in AI05-0030. Should the ARG decide on an official name and syntax,
2398 this pragma will become language-defined rather than GNAT-specific.
2399
2400 @node Pragma Implicit_Packing
2401 @unnumberedsec Pragma Implicit_Packing
2402 @findex Implicit_Packing
2403 @noindent
2404 Syntax:
2405
2406 @smallexample @c ada
2407 pragma Implicit_Packing;
2408 @end smallexample
2409
2410 @noindent
2411 This is a configuration pragma that requests implicit packing for packed
2412 arrays for which a size clause is given but no explicit pragma Pack or
2413 specification of Component_Size is present. It also applies to records
2414 where no record representation clause is present. Consider this example:
2415
2416 @smallexample @c ada
2417 type R is array (0 .. 7) of Boolean;
2418 for R'Size use 8;
2419 @end smallexample
2420
2421 @noindent
2422 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2423 does not change the layout of a composite object. So the Size clause in the
2424 above example is normally rejected, since the default layout of the array uses
2425 8-bit components, and thus the array requires a minimum of 64 bits.
2426
2427 If this declaration is compiled in a region of code covered by an occurrence
2428 of the configuration pragma Implicit_Packing, then the Size clause in this
2429 and similar examples will cause implicit packing and thus be accepted. For
2430 this implicit packing to occur, the type in question must be an array of small
2431 components whose size is known at compile time, and the Size clause must
2432 specify the exact size that corresponds to the length of the array multiplied
2433 by the size in bits of the component type.
2434 @cindex Array packing
2435
2436 Similarly, the following example shows the use in the record case
2437
2438 @smallexample @c ada
2439 type r is record
2440    a, b, c, d, e, f, g, h : boolean;
2441    chr                    : character;
2442 end record;
2443 for r'size use 16;
2444 @end smallexample
2445
2446 @noindent
2447 Without a pragma Pack, each Boolean field requires 8 bits, so the
2448 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2449 sufficient. The use of pragma Implciit_Packing allows this record
2450 declaration to compile without an explicit pragma Pack.
2451 @node Pragma Import_Exception
2452 @unnumberedsec Pragma Import_Exception
2453 @cindex OpenVMS
2454 @findex Import_Exception
2455 @noindent
2456 Syntax:
2457
2458 @smallexample @c ada
2459 pragma Import_Exception (
2460      [Internal =>] LOCAL_NAME
2461   [, [External =>] EXTERNAL_SYMBOL]
2462   [, [Form     =>] Ada | VMS]
2463   [, [Code     =>] static_integer_EXPRESSION]);
2464
2465 EXTERNAL_SYMBOL ::=
2466   IDENTIFIER
2467 | static_string_EXPRESSION
2468 @end smallexample
2469
2470 @noindent
2471 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2472 It allows OpenVMS conditions (for example, from OpenVMS system services or
2473 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2474 The pragma specifies that the exception associated with an exception
2475 declaration in an Ada program be defined externally (in non-Ada code).
2476 For further details on this pragma, see the
2477 DEC Ada Language Reference Manual, section 13.9a.3.1.
2478
2479 @node Pragma Import_Function
2480 @unnumberedsec Pragma Import_Function
2481 @findex Import_Function
2482 @noindent
2483 Syntax:
2484
2485 @smallexample @c ada
2486 pragma Import_Function (
2487      [Internal                 =>] LOCAL_NAME,
2488   [, [External                 =>] EXTERNAL_SYMBOL]
2489   [, [Parameter_Types          =>] PARAMETER_TYPES]
2490   [, [Result_Type              =>] SUBTYPE_MARK]
2491   [, [Mechanism                =>] MECHANISM]
2492   [, [Result_Mechanism         =>] MECHANISM_NAME]
2493   [, [First_Optional_Parameter =>] IDENTIFIER]);
2494
2495 EXTERNAL_SYMBOL ::=
2496   IDENTIFIER
2497 | static_string_EXPRESSION
2498
2499 PARAMETER_TYPES ::=
2500   null
2501 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2502
2503 TYPE_DESIGNATOR ::=
2504   subtype_NAME
2505 | subtype_Name ' Access
2506
2507 MECHANISM ::=
2508   MECHANISM_NAME
2509 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2510
2511 MECHANISM_ASSOCIATION ::=
2512   [formal_parameter_NAME =>] MECHANISM_NAME
2513
2514 MECHANISM_NAME ::=
2515   Value
2516 | Reference
2517 | Descriptor [([Class =>] CLASS_NAME)]
2518 | Short_Descriptor [([Class =>] CLASS_NAME)]
2519
2520 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2521 @end smallexample
2522
2523 @noindent
2524 This pragma is used in conjunction with a pragma @code{Import} to
2525 specify additional information for an imported function.  The pragma
2526 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2527 @code{Import_Function} pragma and both must appear in the same
2528 declarative part as the function specification.
2529
2530 The @var{Internal} argument must uniquely designate
2531 the function to which the
2532 pragma applies.  If more than one function name exists of this name in
2533 the declarative part you must use the @code{Parameter_Types} and
2534 @var{Result_Type} parameters to achieve the required unique
2535 designation.  Subtype marks in these parameters must exactly match the
2536 subtypes in the corresponding function specification, using positional
2537 notation to match parameters with subtype marks.
2538 The form with an @code{'Access} attribute can be used to match an
2539 anonymous access parameter.
2540
2541 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2542 parameters to specify passing mechanisms for the
2543 parameters and result.  If you specify a single mechanism name, it
2544 applies to all parameters.  Otherwise you may specify a mechanism on a
2545 parameter by parameter basis using either positional or named
2546 notation.  If the mechanism is not specified, the default mechanism
2547 is used.
2548
2549 @cindex OpenVMS
2550 @cindex Passing by descriptor
2551 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2552 The default behavior for Import_Function is to pass a 64bit descriptor
2553 unless short_descriptor is specified, then a 32bit descriptor is passed.
2554
2555 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2556 It specifies that the designated parameter and all following parameters
2557 are optional, meaning that they are not passed at the generated code
2558 level (this is distinct from the notion of optional parameters in Ada
2559 where the parameters are passed anyway with the designated optional
2560 parameters).  All optional parameters must be of mode @code{IN} and have
2561 default parameter values that are either known at compile time
2562 expressions, or uses of the @code{'Null_Parameter} attribute.
2563
2564 @node Pragma Import_Object
2565 @unnumberedsec Pragma Import_Object
2566 @findex Import_Object
2567 @noindent
2568 Syntax:
2569
2570 @smallexample @c ada
2571 pragma Import_Object
2572      [Internal =>] LOCAL_NAME
2573   [, [External =>] EXTERNAL_SYMBOL]
2574   [, [Size     =>] EXTERNAL_SYMBOL]);
2575
2576 EXTERNAL_SYMBOL ::=
2577   IDENTIFIER
2578 | static_string_EXPRESSION
2579 @end smallexample
2580
2581 @noindent
2582 This pragma designates an object as imported, and apart from the
2583 extended rules for external symbols, is identical in effect to the use of
2584 the normal @code{Import} pragma applied to an object.  Unlike the
2585 subprogram case, you need not use a separate @code{Import} pragma,
2586 although you may do so (and probably should do so from a portability
2587 point of view).  @var{size} is syntax checked, but otherwise ignored by
2588 GNAT@.
2589
2590 @node Pragma Import_Procedure
2591 @unnumberedsec Pragma Import_Procedure
2592 @findex Import_Procedure
2593 @noindent
2594 Syntax:
2595
2596 @smallexample @c ada
2597 pragma Import_Procedure (
2598      [Internal                 =>] LOCAL_NAME
2599   [, [External                 =>] EXTERNAL_SYMBOL]
2600   [, [Parameter_Types          =>] PARAMETER_TYPES]
2601   [, [Mechanism                =>] MECHANISM]
2602   [, [First_Optional_Parameter =>] IDENTIFIER]);
2603
2604 EXTERNAL_SYMBOL ::=
2605   IDENTIFIER
2606 | static_string_EXPRESSION
2607
2608 PARAMETER_TYPES ::=
2609   null
2610 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2611
2612 TYPE_DESIGNATOR ::=
2613   subtype_NAME
2614 | subtype_Name ' Access
2615
2616 MECHANISM ::=
2617   MECHANISM_NAME
2618 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2619
2620 MECHANISM_ASSOCIATION ::=
2621   [formal_parameter_NAME =>] MECHANISM_NAME
2622
2623 MECHANISM_NAME ::=
2624   Value
2625 | Reference
2626 | Descriptor [([Class =>] CLASS_NAME)]
2627 | Short_Descriptor [([Class =>] CLASS_NAME)]
2628
2629 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2630 @end smallexample
2631
2632 @noindent
2633 This pragma is identical to @code{Import_Function} except that it
2634 applies to a procedure rather than a function and the parameters
2635 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2636
2637 @node Pragma Import_Valued_Procedure
2638 @unnumberedsec Pragma Import_Valued_Procedure
2639 @findex Import_Valued_Procedure
2640 @noindent
2641 Syntax:
2642
2643 @smallexample @c ada
2644 pragma Import_Valued_Procedure (
2645      [Internal                 =>] LOCAL_NAME
2646   [, [External                 =>] EXTERNAL_SYMBOL]
2647   [, [Parameter_Types          =>] PARAMETER_TYPES]
2648   [, [Mechanism                =>] MECHANISM]
2649   [, [First_Optional_Parameter =>] IDENTIFIER]);
2650
2651 EXTERNAL_SYMBOL ::=
2652   IDENTIFIER
2653 | static_string_EXPRESSION
2654
2655 PARAMETER_TYPES ::=
2656   null
2657 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2658
2659 TYPE_DESIGNATOR ::=
2660   subtype_NAME
2661 | subtype_Name ' Access
2662
2663 MECHANISM ::=
2664   MECHANISM_NAME
2665 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2666
2667 MECHANISM_ASSOCIATION ::=
2668   [formal_parameter_NAME =>] MECHANISM_NAME
2669
2670 MECHANISM_NAME ::=
2671   Value
2672 | Reference
2673 | Descriptor [([Class =>] CLASS_NAME)]
2674 | Short_Descriptor [([Class =>] CLASS_NAME)]
2675
2676 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2677 @end smallexample
2678
2679 @noindent
2680 This pragma is identical to @code{Import_Procedure} except that the
2681 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2682 mode @code{OUT}, and externally the subprogram is treated as a function
2683 with this parameter as the result of the function.  The purpose of this
2684 capability is to allow the use of @code{OUT} and @code{IN OUT}
2685 parameters in interfacing to external functions (which are not permitted
2686 in Ada functions).  You may optionally use the @code{Mechanism}
2687 parameters to specify passing mechanisms for the parameters.
2688 If you specify a single mechanism name, it applies to all parameters.
2689 Otherwise you may specify a mechanism on a parameter by parameter
2690 basis using either positional or named notation.  If the mechanism is not
2691 specified, the default mechanism is used.
2692
2693 Note that it is important to use this pragma in conjunction with a separate
2694 pragma Import that specifies the desired convention, since otherwise the
2695 default convention is Ada, which is almost certainly not what is required.
2696
2697 @node Pragma Initialize_Scalars
2698 @unnumberedsec Pragma Initialize_Scalars
2699 @findex Initialize_Scalars
2700 @cindex debugging with Initialize_Scalars
2701 @noindent
2702 Syntax:
2703
2704 @smallexample @c ada
2705 pragma Initialize_Scalars;
2706 @end smallexample
2707
2708 @noindent
2709 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2710 two important differences.  First, there is no requirement for the pragma
2711 to be used uniformly in all units of a partition, in particular, it is fine
2712 to use this just for some or all of the application units of a partition,
2713 without needing to recompile the run-time library.
2714
2715 In the case where some units are compiled with the pragma, and some without,
2716 then a declaration of a variable where the type is defined in package
2717 Standard or is locally declared will always be subject to initialization,
2718 as will any declaration of a scalar variable.  For composite variables,
2719 whether the variable is initialized may also depend on whether the package
2720 in which the type of the variable is declared is compiled with the pragma.
2721
2722 The other important difference is that you can control the value used
2723 for initializing scalar objects.  At bind time, you can select several
2724 options for initialization. You can
2725 initialize with invalid values (similar to Normalize_Scalars, though for
2726 Initialize_Scalars it is not always possible to determine the invalid
2727 values in complex cases like signed component fields with non-standard
2728 sizes). You can also initialize with high or
2729 low values, or with a specified bit pattern.  See the users guide for binder
2730 options for specifying these cases.
2731
2732 This means that you can compile a program, and then without having to
2733 recompile the program, you can run it with different values being used
2734 for initializing otherwise uninitialized values, to test if your program
2735 behavior depends on the choice.  Of course the behavior should not change,
2736 and if it does, then most likely you have an erroneous reference to an
2737 uninitialized value.
2738
2739 It is even possible to change the value at execution time eliminating even
2740 the need to rebind with a different switch using an environment variable.
2741 See the GNAT users guide for details.
2742
2743 Note that pragma @code{Initialize_Scalars} is particularly useful in
2744 conjunction with the enhanced validity checking that is now provided
2745 in GNAT, which checks for invalid values under more conditions.
2746 Using this feature (see description of the @option{-gnatV} flag in the
2747 users guide) in conjunction with pragma @code{Initialize_Scalars}
2748 provides a powerful new tool to assist in the detection of problems
2749 caused by uninitialized variables.
2750
2751 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2752 effect on the generated code. This may cause your code to be
2753 substantially larger. It may also cause an increase in the amount
2754 of stack required, so it is probably a good idea to turn on stack
2755 checking (see description of stack checking in the GNAT users guide)
2756 when using this pragma.
2757
2758 @node Pragma Inline_Always
2759 @unnumberedsec Pragma Inline_Always
2760 @findex Inline_Always
2761 @noindent
2762 Syntax:
2763
2764 @smallexample @c ada
2765 pragma Inline_Always (NAME [, NAME]);
2766 @end smallexample
2767
2768 @noindent
2769 Similar to pragma @code{Inline} except that inlining is not subject to
2770 the use of option @option{-gnatn} and the inlining happens regardless of
2771 whether this option is used.
2772
2773 @node Pragma Inline_Generic
2774 @unnumberedsec Pragma Inline_Generic
2775 @findex Inline_Generic
2776 @noindent
2777 Syntax:
2778
2779 @smallexample @c ada
2780 pragma Inline_Generic (generic_package_NAME);
2781 @end smallexample
2782
2783 @noindent
2784 This is implemented for compatibility with DEC Ada 83 and is recognized,
2785 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2786 by default when using GNAT@.
2787
2788 @node Pragma Interface
2789 @unnumberedsec Pragma Interface
2790 @findex Interface
2791 @noindent
2792 Syntax:
2793
2794 @smallexample @c ada
2795 pragma Interface (
2796      [Convention    =>] convention_identifier,
2797      [Entity        =>] local_NAME
2798   [, [External_Name =>] static_string_expression]
2799   [, [Link_Name     =>] static_string_expression]);
2800 @end smallexample
2801
2802 @noindent
2803 This pragma is identical in syntax and semantics to
2804 the standard Ada pragma @code{Import}.  It is provided for compatibility
2805 with Ada 83.  The definition is upwards compatible both with pragma
2806 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2807 with some extended implementations of this pragma in certain Ada 83
2808 implementations.
2809
2810 @node Pragma Interface_Name
2811 @unnumberedsec Pragma Interface_Name
2812 @findex Interface_Name
2813 @noindent
2814 Syntax:
2815
2816 @smallexample @c ada
2817 pragma Interface_Name (
2818      [Entity        =>] LOCAL_NAME
2819   [, [External_Name =>] static_string_EXPRESSION]
2820   [, [Link_Name     =>] static_string_EXPRESSION]);
2821 @end smallexample
2822
2823 @noindent
2824 This pragma provides an alternative way of specifying the interface name
2825 for an interfaced subprogram, and is provided for compatibility with Ada
2826 83 compilers that use the pragma for this purpose.  You must provide at
2827 least one of @var{External_Name} or @var{Link_Name}.
2828
2829 @node Pragma Interrupt_Handler
2830 @unnumberedsec Pragma Interrupt_Handler
2831 @findex Interrupt_Handler
2832 @noindent
2833 Syntax:
2834
2835 @smallexample @c ada
2836 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2837 @end smallexample
2838
2839 @noindent
2840 This program unit pragma is supported for parameterless protected procedures
2841 as described in Annex C of the Ada Reference Manual. On the AAMP target
2842 the pragma can also be specified for nonprotected parameterless procedures
2843 that are declared at the library level (which includes procedures
2844 declared at the top level of a library package). In the case of AAMP,
2845 when this pragma is applied to a nonprotected procedure, the instruction
2846 @code{IERET} is generated for returns from the procedure, enabling
2847 maskable interrupts, in place of the normal return instruction.
2848
2849 @node Pragma Interrupt_State
2850 @unnumberedsec Pragma Interrupt_State
2851 @findex Interrupt_State
2852 @noindent
2853 Syntax:
2854
2855 @smallexample @c ada
2856 pragma Interrupt_State
2857  ([Name  =>] value,
2858   [State =>] SYSTEM | RUNTIME | USER);
2859 @end smallexample
2860
2861 @noindent
2862 Normally certain interrupts are reserved to the implementation.  Any attempt
2863 to attach an interrupt causes Program_Error to be raised, as described in
2864 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2865 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2866 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2867 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2868 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2869 Ada exceptions, or used to implement run-time functions such as the
2870 @code{abort} statement and stack overflow checking.
2871
2872 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2873 such uses of interrupts.  It subsumes the functionality of pragma
2874 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2875 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2876 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2877 and may be used to mark interrupts required by the board support package
2878 as reserved.
2879
2880 Interrupts can be in one of three states:
2881 @itemize @bullet
2882 @item System
2883
2884 The interrupt is reserved (no Ada handler can be installed), and the
2885 Ada run-time may not install a handler. As a result you are guaranteed
2886 standard system default action if this interrupt is raised.
2887
2888 @item Runtime
2889
2890 The interrupt is reserved (no Ada handler can be installed). The run time
2891 is allowed to install a handler for internal control purposes, but is
2892 not required to do so.
2893
2894 @item User
2895
2896 The interrupt is unreserved.  The user may install a handler to provide
2897 some other action.
2898 @end itemize
2899
2900 @noindent
2901 These states are the allowed values of the @code{State} parameter of the
2902 pragma.  The @code{Name} parameter is a value of the type
2903 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2904 @code{Ada.Interrupts.Names}.
2905
2906 This is a configuration pragma, and the binder will check that there
2907 are no inconsistencies between different units in a partition in how a
2908 given interrupt is specified. It may appear anywhere a pragma is legal.
2909
2910 The effect is to move the interrupt to the specified state.
2911
2912 By declaring interrupts to be SYSTEM, you guarantee the standard system
2913 action, such as a core dump.
2914
2915 By declaring interrupts to be USER, you guarantee that you can install
2916 a handler.
2917
2918 Note that certain signals on many operating systems cannot be caught and
2919 handled by applications.  In such cases, the pragma is ignored.  See the
2920 operating system documentation, or the value of the array @code{Reserved}
2921 declared in the spec of package @code{System.OS_Interface}.
2922
2923 Overriding the default state of signals used by the Ada runtime may interfere
2924 with an application's runtime behavior in the cases of the synchronous signals,
2925 and in the case of the signal used to implement the @code{abort} statement.
2926
2927 @node Pragma Keep_Names
2928 @unnumberedsec Pragma Keep_Names
2929 @findex Keep_Names
2930 @noindent
2931 Syntax:
2932
2933 @smallexample @c ada
2934 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2935 @end smallexample
2936
2937 @noindent
2938 The @var{LOCAL_NAME} argument
2939 must refer to an enumeration first subtype
2940 in the current declarative part. The effect is to retain the enumeration
2941 literal names for use by @code{Image} and @code{Value} even if a global
2942 @code{Discard_Names} pragma applies. This is useful when you want to
2943 generally suppress enumeration literal names and for example you therefore
2944 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2945 want to retain the names for specific enumeration types.
2946
2947 @node Pragma License
2948 @unnumberedsec Pragma License
2949 @findex License
2950 @cindex License checking
2951 @noindent
2952 Syntax:
2953
2954 @smallexample @c ada
2955 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2956 @end smallexample
2957
2958 @noindent
2959 This pragma is provided to allow automated checking for appropriate license
2960 conditions with respect to the standard and modified GPL@.  A pragma
2961 @code{License}, which is a configuration pragma that typically appears at
2962 the start of a source file or in a separate @file{gnat.adc} file, specifies
2963 the licensing conditions of a unit as follows:
2964
2965 @itemize @bullet
2966 @item Unrestricted
2967 This is used for a unit that can be freely used with no license restrictions.
2968 Examples of such units are public domain units, and units from the Ada
2969 Reference Manual.
2970
2971 @item GPL
2972 This is used for a unit that is licensed under the unmodified GPL, and which
2973 therefore cannot be @code{with}'ed by a restricted unit.
2974
2975 @item Modified_GPL
2976 This is used for a unit licensed under the GNAT modified GPL that includes
2977 a special exception paragraph that specifically permits the inclusion of
2978 the unit in programs without requiring the entire program to be released
2979 under the GPL@.
2980
2981 @item Restricted
2982 This is used for a unit that is restricted in that it is not permitted to
2983 depend on units that are licensed under the GPL@.  Typical examples are
2984 proprietary code that is to be released under more restrictive license
2985 conditions.  Note that restricted units are permitted to @code{with} units
2986 which are licensed under the modified GPL (this is the whole point of the
2987 modified GPL).
2988
2989 @end itemize
2990
2991 @noindent
2992 Normally a unit with no @code{License} pragma is considered to have an
2993 unknown license, and no checking is done.  However, standard GNAT headers
2994 are recognized, and license information is derived from them as follows.
2995
2996 @itemize @bullet
2997
2998 A GNAT license header starts with a line containing 78 hyphens.  The following
2999 comment text is searched for the appearance of any of the following strings.
3000
3001 If the string ``GNU General Public License'' is found, then the unit is assumed
3002 to have GPL license, unless the string ``As a special exception'' follows, in
3003 which case the license is assumed to be modified GPL@.
3004
3005 If one of the strings
3006 ``This specification is adapted from the Ada Semantic Interface'' or
3007 ``This specification is derived from the Ada Reference Manual'' is found
3008 then the unit is assumed to be unrestricted.
3009 @end itemize
3010
3011 @noindent
3012 These default actions means that a program with a restricted license pragma
3013 will automatically get warnings if a GPL unit is inappropriately
3014 @code{with}'ed.  For example, the program:
3015
3016 @smallexample @c ada
3017 with Sem_Ch3;
3018 with GNAT.Sockets;
3019 procedure Secret_Stuff is
3020   @dots{}
3021 end Secret_Stuff
3022 @end smallexample
3023
3024 @noindent
3025 if compiled with pragma @code{License} (@code{Restricted}) in a
3026 @file{gnat.adc} file will generate the warning:
3027
3028 @smallexample
3029 1.  with Sem_Ch3;
3030         |
3031    >>> license of withed unit "Sem_Ch3" is incompatible
3032
3033 2.  with GNAT.Sockets;
3034 3.  procedure Secret_Stuff is
3035 @end smallexample
3036
3037 @noindent
3038 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3039 compiler and is licensed under the
3040 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3041 run time, and is therefore licensed under the modified GPL@.
3042
3043 @node Pragma Link_With
3044 @unnumberedsec Pragma Link_With
3045 @findex Link_With
3046 @noindent
3047 Syntax:
3048
3049 @smallexample @c ada
3050 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3051 @end smallexample
3052
3053 @noindent
3054 This pragma is provided for compatibility with certain Ada 83 compilers.
3055 It has exactly the same effect as pragma @code{Linker_Options} except
3056 that spaces occurring within one of the string expressions are treated
3057 as separators. For example, in the following case:
3058
3059 @smallexample @c ada
3060 pragma Link_With ("-labc -ldef");
3061 @end smallexample
3062
3063 @noindent
3064 results in passing the strings @code{-labc} and @code{-ldef} as two
3065 separate arguments to the linker. In addition pragma Link_With allows
3066 multiple arguments, with the same effect as successive pragmas.
3067
3068 @node Pragma Linker_Alias
3069 @unnumberedsec Pragma Linker_Alias
3070 @findex Linker_Alias
3071 @noindent
3072 Syntax:
3073
3074 @smallexample @c ada
3075 pragma Linker_Alias (
3076   [Entity =>] LOCAL_NAME,
3077   [Target =>] static_string_EXPRESSION);
3078 @end smallexample
3079
3080 @noindent
3081 @var{LOCAL_NAME} must refer to an object that is declared at the library
3082 level. This pragma establishes the given entity as a linker alias for the
3083 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3084 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3085 @var{static_string_EXPRESSION} in the object file, that is to say no space
3086 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3087 to the same address as @var{static_string_EXPRESSION} by the linker.
3088
3089 The actual linker name for the target must be used (e.g.@: the fully
3090 encoded name with qualification in Ada, or the mangled name in C++),
3091 or it must be declared using the C convention with @code{pragma Import}
3092 or @code{pragma Export}.
3093
3094 Not all target machines support this pragma. On some of them it is accepted
3095 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3096
3097 @smallexample @c ada
3098 --  Example of the use of pragma Linker_Alias
3099
3100 package p is
3101   i : Integer := 1;
3102   pragma Export (C, i);
3103
3104   new_name_for_i : Integer;
3105   pragma Linker_Alias (new_name_for_i, "i");
3106 end p;
3107 @end smallexample
3108
3109 @node Pragma Linker_Constructor
3110 @unnumberedsec Pragma Linker_Constructor
3111 @findex Linker_Constructor
3112 @noindent
3113 Syntax:
3114
3115 @smallexample @c ada
3116 pragma Linker_Constructor (procedure_LOCAL_NAME);
3117 @end smallexample
3118
3119 @noindent
3120 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3121 is declared at the library level. A procedure to which this pragma is
3122 applied will be treated as an initialization routine by the linker.
3123 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3124 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3125 of the executable is called (or immediately after the shared library is
3126 loaded if the procedure is linked in a shared library), in particular
3127 before the Ada run-time environment is set up.
3128
3129 Because of these specific contexts, the set of operations such a procedure
3130 can perform is very limited and the type of objects it can manipulate is
3131 essentially restricted to the elementary types. In particular, it must only
3132 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3133
3134 This pragma is used by GNAT to implement auto-initialization of shared Stand
3135 Alone Libraries, which provides a related capability without the restrictions
3136 listed above. Where possible, the use of Stand Alone Libraries is preferable
3137 to the use of this pragma.
3138
3139 @node Pragma Linker_Destructor
3140 @unnumberedsec Pragma Linker_Destructor
3141 @findex Linker_Destructor
3142 @noindent
3143 Syntax:
3144
3145 @smallexample @c ada
3146 pragma Linker_Destructor (procedure_LOCAL_NAME);
3147 @end smallexample
3148
3149 @noindent
3150 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3151 is declared at the library level. A procedure to which this pragma is
3152 applied will be treated as a finalization routine by the linker.
3153 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3154 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3155 of the executable has exited (or immediately before the shared library
3156 is unloaded if the procedure is linked in a shared library), in particular
3157 after the Ada run-time environment is shut down.
3158
3159 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3160 because of these specific contexts.
3161
3162 @node Pragma Linker_Section
3163 @unnumberedsec Pragma Linker_Section
3164 @findex Linker_Section
3165 @noindent
3166 Syntax:
3167
3168 @smallexample @c ada
3169 pragma Linker_Section (
3170   [Entity  =>] LOCAL_NAME,
3171   [Section =>] static_string_EXPRESSION);
3172 @end smallexample
3173
3174 @noindent
3175 @var{LOCAL_NAME} must refer to an object that is declared at the library
3176 level. This pragma specifies the name of the linker section for the given
3177 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3178 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3179 section of the executable (assuming the linker doesn't rename the section).
3180
3181 The compiler normally places library-level objects in standard sections
3182 depending on their type: procedures and functions generally go in the
3183 @code{.text} section, initialized variables in the @code{.data} section
3184 and uninitialized variables in the @code{.bss} section.
3185
3186 Other, special sections may exist on given target machines to map special
3187 hardware, for example I/O ports or flash memory. This pragma is a means to
3188 defer the final layout of the executable to the linker, thus fully working
3189 at the symbolic level with the compiler.
3190
3191 Some file formats do not support arbitrary sections so not all target
3192 machines support this pragma. The use of this pragma may cause a program
3193 execution to be erroneous if it is used to place an entity into an
3194 inappropriate section (e.g.@: a modified variable into the @code{.text}
3195 section). See also @code{pragma Persistent_BSS}.
3196
3197 @smallexample @c ada
3198 --  Example of the use of pragma Linker_Section
3199
3200 package IO_Card is
3201   Port_A : Integer;
3202   pragma Volatile (Port_A);
3203   pragma Linker_Section (Port_A, ".bss.port_a");
3204
3205   Port_B : Integer;
3206   pragma Volatile (Port_B);
3207   pragma Linker_Section (Port_B, ".bss.port_b");
3208 end IO_Card;
3209 @end smallexample
3210
3211 @node Pragma Long_Float
3212 @unnumberedsec Pragma Long_Float
3213 @cindex OpenVMS
3214 @findex Long_Float
3215 @noindent
3216 Syntax:
3217
3218 @smallexample @c ada
3219 pragma Long_Float (FLOAT_FORMAT);
3220
3221 FLOAT_FORMAT ::= D_Float | G_Float
3222 @end smallexample
3223
3224 @noindent
3225 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3226 It allows control over the internal representation chosen for the predefined
3227 type @code{Long_Float} and for floating point type representations with
3228 @code{digits} specified in the range 7 through 15.
3229 For further details on this pragma, see the
3230 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3231 this pragma, the standard runtime libraries must be recompiled.
3232 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3233 @value{EDITION} User's Guide OpenVMS}, for a description of the
3234 @code{GNAT LIBRARY} command.
3235
3236 @node Pragma Machine_Attribute
3237 @unnumberedsec Pragma Machine_Attribute
3238 @findex Machine_Attribute
3239 @noindent
3240 Syntax:
3241
3242 @smallexample @c ada
3243 pragma Machine_Attribute (
3244      [Entity         =>] LOCAL_NAME,
3245      [Attribute_Name =>] static_string_EXPRESSION
3246   [, [Info           =>] static_EXPRESSION] );
3247 @end smallexample
3248
3249 @noindent
3250 Machine-dependent attributes can be specified for types and/or
3251 declarations.  This pragma is semantically equivalent to
3252 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3253 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3254 in GNU C, where @code{@var{attribute_name}} is recognized by the
3255 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3256 specific macro.  A string literal for the optional parameter @var{info}
3257 is transformed into an identifier, which may make this pragma unusable
3258 for some attributes.  @xref{Target Attributes,, Defining target-specific
3259 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3260 Internals}, further information.
3261
3262 @node Pragma Main
3263 @unnumberedsec Pragma Main
3264 @cindex OpenVMS
3265 @findex Main
3266 @noindent
3267 Syntax:
3268
3269 @smallexample @c ada
3270 pragma Main
3271  (MAIN_OPTION [, MAIN_OPTION]);
3272
3273 MAIN_OPTION ::=
3274   [Stack_Size              =>] static_integer_EXPRESSION
3275 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3276 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3277 @end smallexample
3278
3279 @noindent
3280 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3281 no effect in GNAT, other than being syntax checked.
3282
3283 @node Pragma Main_Storage
3284 @unnumberedsec Pragma Main_Storage
3285 @cindex OpenVMS
3286 @findex Main_Storage
3287 @noindent
3288 Syntax:
3289
3290 @smallexample @c ada
3291 pragma Main_Storage
3292   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3293
3294 MAIN_STORAGE_OPTION ::=
3295   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3296 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3297 @end smallexample
3298
3299 @noindent
3300 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3301 no effect in GNAT, other than being syntax checked.  Note that the pragma
3302 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3303
3304 @node Pragma No_Body
3305 @unnumberedsec Pragma No_Body
3306 @findex No_Body
3307 @noindent
3308 Syntax:
3309
3310 @smallexample @c ada
3311 pragma No_Body;
3312 @end smallexample
3313
3314 @noindent
3315 There are a number of cases in which a package spec does not require a body,
3316 and in fact a body is not permitted. GNAT will not permit the spec to be
3317 compiled if there is a body around. The pragma No_Body allows you to provide
3318 a body file, even in a case where no body is allowed. The body file must
3319 contain only comments and a single No_Body pragma. This is recognized by
3320 the compiler as indicating that no body is logically present.
3321
3322 This is particularly useful during maintenance when a package is modified in
3323 such a way that a body needed before is no longer needed. The provision of a
3324 dummy body with a No_Body pragma ensures that there is no interference from
3325 earlier versions of the package body.
3326
3327 @node Pragma No_Return
3328 @unnumberedsec Pragma No_Return
3329 @findex No_Return
3330 @noindent
3331 Syntax:
3332
3333 @smallexample @c ada
3334 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3335 @end smallexample
3336
3337 @noindent
3338 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3339 declarations in the current declarative part.  A procedure to which this
3340 pragma is applied may not contain any explicit @code{return} statements.
3341 In addition, if the procedure contains any implicit returns from falling
3342 off the end of a statement sequence, then execution of that implicit
3343 return will cause Program_Error to be raised.
3344
3345 One use of this pragma is to identify procedures whose only purpose is to raise
3346 an exception. Another use of this pragma is to suppress incorrect warnings
3347 about missing returns in functions, where the last statement of a function
3348 statement sequence is a call to such a procedure.
3349
3350 Note that in Ada 2005 mode, this pragma is part of the language, and is
3351 identical in effect to the pragma as implemented in Ada 95 mode.
3352
3353 @node Pragma No_Strict_Aliasing
3354 @unnumberedsec Pragma No_Strict_Aliasing
3355 @findex No_Strict_Aliasing
3356 @noindent
3357 Syntax:
3358
3359 @smallexample @c ada
3360 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3361 @end smallexample
3362
3363 @noindent
3364 @var{type_LOCAL_NAME} must refer to an access type
3365 declaration in the current declarative part.  The effect is to inhibit
3366 strict aliasing optimization for the given type.  The form with no
3367 arguments is a configuration pragma which applies to all access types
3368 declared in units to which the pragma applies. For a detailed
3369 description of the strict aliasing optimization, and the situations
3370 in which it must be suppressed, see @ref{Optimization and Strict
3371 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3372
3373 @node Pragma Normalize_Scalars
3374 @unnumberedsec Pragma Normalize_Scalars
3375 @findex Normalize_Scalars
3376 @noindent
3377 Syntax:
3378
3379 @smallexample @c ada
3380 pragma Normalize_Scalars;
3381 @end smallexample
3382
3383 @noindent
3384 This is a language defined pragma which is fully implemented in GNAT@.  The
3385 effect is to cause all scalar objects that are not otherwise initialized
3386 to be initialized.  The initial values are implementation dependent and
3387 are as follows:
3388
3389 @table @code
3390 @item Standard.Character
3391 @noindent
3392 Objects whose root type is Standard.Character are initialized to
3393 Character'Last unless the subtype range excludes NUL (in which case
3394 NUL is used). This choice will always generate an invalid value if
3395 one exists.
3396
3397 @item Standard.Wide_Character
3398 @noindent
3399 Objects whose root type is Standard.Wide_Character are initialized to
3400 Wide_Character'Last unless the subtype range excludes NUL (in which case
3401 NUL is used). This choice will always generate an invalid value if
3402 one exists.
3403
3404 @item Standard.Wide_Wide_Character
3405 @noindent
3406 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3407 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3408 which case NUL is used). This choice will always generate an invalid value if
3409 one exists.
3410
3411 @item Integer types
3412 @noindent
3413 Objects of an integer type are treated differently depending on whether
3414 negative values are present in the subtype. If no negative values are
3415 present, then all one bits is used as the initial value except in the
3416 special case where zero is excluded from the subtype, in which case
3417 all zero bits are used. This choice will always generate an invalid
3418 value if one exists.
3419
3420 For subtypes with negative values present, the largest negative number
3421 is used, except in the unusual case where this largest negative number
3422 is in the subtype, and the largest positive number is not, in which case
3423 the largest positive value is used. This choice will always generate
3424 an invalid value if one exists.
3425
3426 @item Floating-Point Types
3427 Objects of all floating-point types are initialized to all 1-bits. For
3428 standard IEEE format, this corresponds to a NaN (not a number) which is
3429 indeed an invalid value.
3430
3431 @item Fixed-Point Types
3432 Objects of all fixed-point types are treated as described above for integers,
3433 with the rules applying to the underlying integer value used to represent
3434 the fixed-point value.
3435
3436 @item Modular types
3437 Objects of a modular type are initialized to all one bits, except in
3438 the special case where zero is excluded from the subtype, in which
3439 case all zero bits are used. This choice will always generate an
3440 invalid value if one exists.
3441
3442 @item Enumeration types
3443 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3444 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3445 whose Pos value is zero, in which case a code of zero is used. This choice
3446 will always generate an invalid value if one exists.
3447
3448 @end table
3449
3450 @node Pragma Obsolescent
3451 @unnumberedsec Pragma Obsolescent
3452 @findex Obsolescent
3453 @noindent
3454 Syntax:
3455
3456 @smallexample @c ada
3457 pragma Obsolescent;
3458
3459 pragma Obsolescent (
3460   [Message =>] static_string_EXPRESSION
3461 [,[Version =>] Ada_05]]);
3462
3463 pragma Obsolescent (
3464   [Entity  =>] NAME
3465 [,[Message =>] static_string_EXPRESSION
3466 [,[Version =>] Ada_05]] );
3467 @end smallexample
3468
3469 @noindent
3470 This pragma can occur immediately following a declaration of an entity,
3471 including the case of a record component. If no Entity argument is present,
3472 then this declaration is the one to which the pragma applies. If an Entity
3473 parameter is present, it must either match the name of the entity in this
3474 declaration, or alternatively, the pragma can immediately follow an enumeration
3475 type declaration, where the Entity argument names one of the enumeration
3476 literals.
3477
3478 This pragma is used to indicate that the named entity
3479 is considered obsolescent and should not be used. Typically this is
3480 used when an API must be modified by eventually removing or modifying
3481 existing subprograms or other entities. The pragma can be used at an
3482 intermediate stage when the entity is still present, but will be
3483 removed later.
3484
3485 The effect of this pragma is to output a warning message on a reference to
3486 an entity thus marked that the subprogram is obsolescent if the appropriate
3487 warning option in the compiler is activated. If the Message parameter is
3488 present, then a second warning message is given containing this text. In
3489 addition, a reference to the eneity is considered to be a violation of pragma
3490 Restrictions (No_Obsolescent_Features).
3491
3492 This pragma can also be used as a program unit pragma for a package,
3493 in which case the entity name is the name of the package, and the
3494 pragma indicates that the entire package is considered
3495 obsolescent. In this case a client @code{with}'ing such a package
3496 violates the restriction, and the @code{with} statement is
3497 flagged with warnings if the warning option is set.
3498
3499 If the Version parameter is present (which must be exactly
3500 the identifier Ada_05, no other argument is allowed), then the
3501 indication of obsolescence applies only when compiling in Ada 2005
3502 mode. This is primarily intended for dealing with the situations
3503 in the predefined library where subprograms or packages
3504 have become defined as obsolescent in Ada 2005
3505 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3506
3507 The following examples show typical uses of this pragma:
3508
3509 @smallexample @c ada
3510 package p is
3511    pragma Obsolescent (p, Message => "use pp instead of p");
3512 end p;
3513
3514 package q is
3515    procedure q2;
3516    pragma Obsolescent ("use q2new instead");
3517
3518    type R is new integer;
3519    pragma Obsolescent
3520      (Entity  => R,
3521       Message => "use RR in Ada 2005",
3522       Version => Ada_05);
3523
3524    type M is record
3525       F1 : Integer;
3526       F2 : Integer;
3527       pragma Obsolescent;
3528       F3 : Integer;
3529    end record;
3530
3531    type E is (a, bc, 'd', quack);
3532    pragma Obsolescent (Entity => bc)
3533    pragma Obsolescent (Entity => 'd')
3534
3535    function "+"
3536      (a, b : character) return character;
3537    pragma Obsolescent (Entity => "+");
3538 end;
3539 @end smallexample
3540
3541 @noindent
3542 Note that, as for all pragmas, if you use a pragma argument identifier,
3543 then all subsequent parameters must also use a pragma argument identifier.
3544 So if you specify "Entity =>" for the Entity argument, and a Message
3545 argument is present, it must be preceded by "Message =>".
3546
3547 @node Pragma Optimize_Alignment
3548 @unnumberedsec Pragma Optimize_Alignment
3549 @findex Optimize_Alignment
3550 @cindex Alignment, default settings
3551 @noindent
3552 Syntax:
3553
3554 @smallexample @c ada
3555 pragma Optimize_Alignment (TIME | SPACE | OFF);
3556 @end smallexample
3557
3558 @noindent
3559 This is a configuration pragma which affects the choice of default alignments
3560 for types where no alignment is explicitly specified. There is a time/space
3561 trade-off in the selection of these values. Large alignments result in more
3562 efficient code, at the expense of larger data space, since sizes have to be
3563 increased to match these alignments. Smaller alignments save space, but the
3564 access code is slower. The normal choice of default alignments (which is what
3565 you get if you do not use this pragma, or if you use an argument of OFF),
3566 tries to balance these two requirements.
3567
3568 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3569 First any packed record is given an alignment of 1. Second, if a size is given
3570 for the type, then the alignment is chosen to avoid increasing this size. For
3571 example, consider:
3572
3573 @smallexample @c ada
3574    type R is record
3575       X : Integer;
3576       Y : Character;
3577    end record;
3578
3579    for R'Size use 5*8;
3580 @end smallexample
3581
3582 @noindent
3583 In the default mode, this type gets an alignment of 4, so that access to the
3584 Integer field X are efficient. But this means that objects of the type end up
3585 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3586 allowed to be bigger than the size of the type, but it can waste space if for
3587 example fields of type R appear in an enclosing record. If the above type is
3588 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3589
3590 Specifying TIME causes larger default alignments to be chosen in the case of
3591 small types with sizes that are not a power of 2. For example, consider:
3592
3593 @smallexample @c ada
3594    type R is record
3595       A : Character;
3596       B : Character;
3597       C : Boolean;
3598    end record;
3599
3600    pragma Pack (R);
3601    for R'Size use 17;
3602 @end smallexample
3603
3604 @noindent
3605 The default alignment for this record is normally 1, but if this type is
3606 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3607 to 4, which wastes space for objects of the type, since they are now 4 bytes
3608 long, but results in more efficient access when the whole record is referenced.
3609
3610 As noted above, this is a configuration pragma, and there is a requirement
3611 that all units in a partition be compiled with a consistent setting of the
3612 optimization setting. This would normally be achieved by use of a configuration
3613 pragma file containing the appropriate setting. The exception to this rule is
3614 that units with an explicit configuration pragma in the same file as the source
3615 unit are excluded from the consistency check, as are all predefined units. The
3616 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3617 pragma appears at the start of the file.
3618
3619 @node Pragma Passive
3620 @unnumberedsec Pragma Passive
3621 @findex Passive
3622 @noindent
3623 Syntax:
3624
3625 @smallexample @c ada
3626 pragma Passive [(Semaphore | No)];
3627 @end smallexample
3628
3629 @noindent
3630 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3631 compatibility with DEC Ada 83 implementations, where it is used within a
3632 task definition to request that a task be made passive.  If the argument
3633 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3634 treats the pragma as an assertion that the containing task is passive
3635 and that optimization of context switch with this task is permitted and
3636 desired.  If the argument @code{No} is present, the task must not be
3637 optimized.  GNAT does not attempt to optimize any tasks in this manner
3638 (since protected objects are available in place of passive tasks).
3639
3640 @node Pragma Persistent_BSS
3641 @unnumberedsec Pragma Persistent_BSS
3642 @findex Persistent_BSS
3643 @noindent
3644 Syntax:
3645
3646 @smallexample @c ada
3647 pragma Persistent_BSS [(LOCAL_NAME)]
3648 @end smallexample
3649
3650 @noindent
3651 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3652 section. On some targets the linker and loader provide for special
3653 treatment of this section, allowing a program to be reloaded without
3654 affecting the contents of this data (hence the name persistent).
3655
3656 There are two forms of usage. If an argument is given, it must be the
3657 local name of a library level object, with no explicit initialization
3658 and whose type is potentially persistent. If no argument is given, then
3659 the pragma is a configuration pragma, and applies to all library level
3660 objects with no explicit initialization of potentially persistent types.
3661
3662 A potentially persistent type is a scalar type, or a non-tagged,
3663 non-discriminated record, all of whose components have no explicit
3664 initialization and are themselves of a potentially persistent type,
3665 or an array, all of whose constraints are static, and whose component
3666 type is potentially persistent.
3667
3668 If this pragma is used on a target where this feature is not supported,
3669 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3670
3671 @node Pragma Polling
3672 @unnumberedsec Pragma Polling
3673 @findex Polling
3674 @noindent
3675 Syntax:
3676
3677 @smallexample @c ada
3678 pragma Polling (ON | OFF);
3679 @end smallexample
3680
3681 @noindent
3682 This pragma controls the generation of polling code.  This is normally off.
3683 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3684 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3685 runtime library, and can be found in file @file{a-excpol.adb}.
3686
3687 Pragma @code{Polling} can appear as a configuration pragma (for example it
3688 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3689 can be used in the statement or declaration sequence to control polling
3690 more locally.
3691
3692 A call to the polling routine is generated at the start of every loop and
3693 at the start of every subprogram call.  This guarantees that the @code{Poll}
3694 routine is called frequently, and places an upper bound (determined by
3695 the complexity of the code) on the period between two @code{Poll} calls.
3696
3697 The primary purpose of the polling interface is to enable asynchronous
3698 aborts on targets that cannot otherwise support it (for example Windows
3699 NT), but it may be used for any other purpose requiring periodic polling.
3700 The standard version is null, and can be replaced by a user program.  This
3701 will require re-compilation of the @code{Ada.Exceptions} package that can
3702 be found in files @file{a-except.ads} and @file{a-except.adb}.
3703
3704 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3705 distribution) is used to enable the asynchronous abort capability on
3706 targets that do not normally support the capability.  The version of
3707 @code{Poll} in this file makes a call to the appropriate runtime routine
3708 to test for an abort condition.
3709
3710 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3711 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3712 details.
3713
3714 @node Pragma Postcondition
3715 @unnumberedsec Pragma Postcondition
3716 @cindex Postconditions
3717 @cindex Checks, postconditions
3718 @findex Postconditions
3719 @noindent
3720 Syntax:
3721
3722 @smallexample @c ada
3723 pragma Postcondition (
3724    [Check   =>] Boolean_Expression
3725  [,[Message =>] String_Expression]);
3726 @end smallexample
3727
3728 @noindent
3729 The @code{Postcondition} pragma allows specification of automatic
3730 postcondition checks for subprograms. These checks are similar to
3731 assertions, but are automatically inserted just prior to the return
3732 statements of the subprogram with which they are associated (including
3733 implicit returns at the end of procedure bodies and associated
3734 exception handlers).
3735
3736 In addition, the boolean expression which is the condition which
3737 must be true may contain references to function'Result in the case
3738 of a function to refer to the returned value.
3739
3740 @code{Postcondition} pragmas may appear either immediate following the
3741 (separate) declaration of a subprogram, or at the start of the
3742 declarations of a subprogram body. Only other pragmas may intervene
3743 (that is appear between the subprogram declaration and its
3744 postconditions, or appear before the postcondition in the
3745 declaration sequence in a subprogram body). In the case of a
3746 postcondition appearing after a subprogram declaration, the
3747 formal arguments of the subprogram are visible, and can be
3748 referenced in the postcondition expressions.
3749
3750 The postconditions are collected and automatically tested just
3751 before any return (implicit or explicit) in the subprogram body.
3752 A postcondition is only recognized if postconditions are active
3753 at the time the pragma is encountered. The compiler switch @option{gnata}
3754 turns on all postconditions by default, and pragma @code{Check_Policy}
3755 with an identifier of @code{Postcondition} can also be used to
3756 control whether postconditions are active.
3757
3758 The general approach is that postconditions are placed in the spec
3759 if they represent functional aspects which make sense to the client.
3760 For example we might have:
3761
3762 @smallexample @c ada
3763    function Direction return Integer;
3764    pragma Postcondition
3765     (Direction'Result = +1
3766        or else
3767      Direction'Result = -1);
3768 @end smallexample
3769
3770 @noindent
3771 which serves to document that the result must be +1 or -1, and
3772 will test that this is the case at run time if postcondition
3773 checking is active.
3774
3775 Postconditions within the subprogram body can be used to
3776 check that some internal aspect of the implementation,
3777 not visible to the client, is operating as expected.
3778 For instance if a square root routine keeps an internal
3779 counter of the number of times it is called, then we
3780 might have the following postcondition:
3781
3782 @smallexample @c ada
3783    Sqrt_Calls : Natural := 0;
3784
3785    function Sqrt (Arg : Float) return Float is
3786      pragma Postcondition
3787        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3788      ...
3789    end Sqrt
3790 @end smallexample
3791
3792 @noindent
3793 As this example, shows, the use of the @code{Old} attribute
3794 is often useful in postconditions to refer to the state on
3795 entry to the subprogram.
3796
3797 Note that postconditions are only checked on normal returns
3798 from the subprogram. If an abnormal return results from
3799 raising an exception, then the postconditions are not checked.
3800
3801 If a postcondition fails, then the exception
3802 @code{System.Assertions.Assert_Failure} is raised. If
3803 a message argument was supplied, then the given string
3804 will be used as the exception message. If no message
3805 argument was supplied, then the default message has
3806 the form "Postcondition failed at file:line". The
3807 exception is raised in the context of the subprogram
3808 body, so it is possible to catch postcondition failures
3809 within the subprogram body itself.
3810
3811 Within a package spec, normal visibility rules
3812 in Ada would prevent forward references within a
3813 postcondition pragma to functions defined later in
3814 the same package. This would introduce undesirable
3815 ordering constraints. To avoid this problem, all
3816 postcondition pragmas are analyzed at the end of
3817 the package spec, allowing forward references.
3818
3819 The following example shows that this even allows
3820 mutually recursive postconditions as in:
3821
3822 @smallexample @c ada
3823 package Parity_Functions is
3824    function Odd  (X : Natural) return Boolean;
3825    pragma Postcondition
3826      (Odd'Result =
3827         (x = 1
3828           or else
3829         (x /= 0 and then Even (X - 1))));
3830
3831    function Even (X : Natural) return Boolean;
3832    pragma Postcondition
3833      (Even'Result =
3834         (x = 0
3835           or else
3836         (x /= 1 and then Odd (X - 1))));
3837
3838 end Parity_Functions;
3839 @end smallexample
3840
3841 @noindent
3842 There are no restrictions on the complexity or form of
3843 conditions used within @code{Postcondition} pragmas.
3844 The following example shows that it is even possible
3845 to verify performance behavior.
3846
3847 @smallexample @c ada
3848 package Sort is
3849
3850    Performance : constant Float;
3851    --  Performance constant set by implementation
3852    --  to match target architecture behavior.
3853
3854    procedure Treesort (Arg : String);
3855    --  Sorts characters of argument using N*logN sort
3856    pragma Postcondition
3857      (Float (Clock - Clock'Old) <=
3858         Float (Arg'Length) *
3859         log (Float (Arg'Length)) *
3860         Performance);
3861 end Sort;
3862 @end smallexample
3863
3864 @noindent
3865 Note: postcondition pragmas associated with subprograms that are
3866 marked as Inline_Always, or those marked as Inline with front-end
3867 inlining (-gnatN option set) are accepted and legality-checked
3868 by the compiler, but are ignored at run-time even if postcondition
3869 checking is enabled.
3870
3871 @node Pragma Precondition
3872 @unnumberedsec Pragma Precondition
3873 @cindex Preconditions
3874 @cindex Checks, preconditions
3875 @findex Preconditions
3876 @noindent
3877 Syntax:
3878
3879 @smallexample @c ada
3880 pragma Precondition (
3881    [Check   =>] Boolean_Expression
3882  [,[Message =>] String_Expression]);
3883 @end smallexample
3884
3885 @noindent
3886 The @code{Precondition} pragma is similar to @code{Postcondition}
3887 except that the corresponding checks take place immediately upon
3888 entry to the subprogram, and if a precondition fails, the exception
3889 is raised in the context of the caller, and the attribute 'Result
3890 cannot be used within the precondition expression.
3891
3892 Otherwise, the placement and visibility rules are identical to those
3893 described for postconditions. The following is an example of use
3894 within a package spec:
3895
3896 @smallexample @c ada
3897 package Math_Functions is
3898    ...
3899    function Sqrt (Arg : Float) return Float;
3900    pragma Precondition (Arg >= 0.0)
3901    ...
3902 end Math_Functions;
3903 @end smallexample
3904
3905 @noindent
3906 @code{Precondition} pragmas may appear either immediate following the
3907 (separate) declaration of a subprogram, or at the start of the
3908 declarations of a subprogram body. Only other pragmas may intervene
3909 (that is appear between the subprogram declaration and its
3910 postconditions, or appear before the postcondition in the
3911 declaration sequence in a subprogram body).
3912
3913 Note: postcondition pragmas associated with subprograms that are
3914 marked as Inline_Always, or those marked as Inline with front-end
3915 inlining (-gnatN option set) are accepted and legality-checked
3916 by the compiler, but are ignored at run-time even if postcondition
3917 checking is enabled.
3918
3919
3920
3921 @node Pragma Profile (Ravenscar)
3922 @unnumberedsec Pragma Profile (Ravenscar)
3923 @findex Ravenscar
3924 @noindent
3925 Syntax:
3926
3927 @smallexample @c ada
3928 pragma Profile (Ravenscar);
3929 @end smallexample
3930
3931 @noindent
3932 A configuration pragma that establishes the following set of configuration
3933 pragmas:
3934
3935 @table @code
3936 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3937 [RM D.2.2] Tasks are dispatched following a preemptive
3938 priority-ordered scheduling policy.
3939
3940 @item Locking_Policy (Ceiling_Locking)
3941 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3942 the ceiling priority of the corresponding protected object.
3943 @c
3944 @c @item Detect_Blocking
3945 @c This pragma forces the detection of potentially blocking operations within a
3946 @c protected operation, and to raise Program_Error if that happens.
3947 @end table
3948 @noindent
3949
3950 plus the following set of restrictions:
3951
3952 @table @code
3953 @item Max_Entry_Queue_Length = 1
3954 Defines the maximum number of calls that are queued on a (protected) entry.
3955 Note that this restrictions is checked at run time. Violation of this
3956 restriction results in the raising of Program_Error exception at the point of
3957 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3958 always 1 and hence no task can be queued on a protected entry.
3959
3960 @item Max_Protected_Entries = 1
3961 [RM D.7] Specifies the maximum number of entries per protected type. The
3962 bounds of every entry family of a protected unit shall be static, or shall be
3963 defined by a discriminant of a subtype whose corresponding bound is static.
3964 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3965
3966 @item Max_Task_Entries = 0
3967 [RM D.7] Specifies the maximum number of entries
3968 per task.  The bounds of every entry family
3969 of a task unit shall be static, or shall be
3970 defined by a discriminant of a subtype whose
3971 corresponding bound is static.  A value of zero
3972 indicates that no rendezvous are possible.  For
3973 the Profile (Ravenscar), the value of Max_Task_Entries is always
3974 0 (zero).
3975
3976 @item No_Abort_Statements
3977 [RM D.7] There are no abort_statements, and there are
3978 no calls to Task_Identification.Abort_Task.
3979
3980 @item No_Asynchronous_Control
3981 There are no semantic dependences on the package
3982 Asynchronous_Task_Control.
3983
3984 @item No_Calendar
3985 There are no semantic dependencies on the package Ada.Calendar.
3986
3987 @item No_Dynamic_Attachment
3988 There is no call to any of the operations defined in package Ada.Interrupts
3989 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3990 Detach_Handler, and Reference).
3991
3992 @item No_Dynamic_Priorities
3993 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3994
3995 @item No_Implicit_Heap_Allocations
3996 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3997
3998 @item No_Local_Protected_Objects
3999 Protected objects and access types that designate
4000 such objects shall be declared only at library level.
4001
4002 @item No_Local_Timing_Events
4003 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4004 declared at the library level.
4005
4006 @item No_Protected_Type_Allocators
4007 There are no allocators for protected types or
4008 types containing protected subcomponents.
4009
4010 @item No_Relative_Delay
4011 There are no delay_relative statements.
4012
4013 @item No_Requeue_Statements
4014 Requeue statements are not allowed.
4015
4016 @item No_Select_Statements
4017 There are no select_statements.
4018
4019 @item No_Specific_Termination_Handlers
4020 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4021 or to Ada.Task_Termination.Specific_Handler.
4022
4023 @item No_Task_Allocators
4024 [RM D.7] There are no allocators for task types
4025 or types containing task subcomponents.
4026
4027 @item No_Task_Attributes_Package
4028 There are no semantic dependencies on the Ada.Task_Attributes package.
4029
4030 @item No_Task_Hierarchy
4031 [RM D.7] All (non-environment) tasks depend
4032 directly on the environment task of the partition.
4033
4034 @item No_Task_Termination
4035 Tasks which terminate are erroneous.
4036
4037 @item No_Unchecked_Conversion
4038 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4039
4040 @item No_Unchecked_Deallocation
4041 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4042
4043 @item Simple_Barriers
4044 Entry barrier condition expressions shall be either static
4045 boolean expressions or boolean objects which are declared in
4046 the protected type which contains the entry.
4047 @end table
4048
4049 @noindent
4050 This set of configuration pragmas and restrictions correspond to the
4051 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4052 published by the @cite{International Real-Time Ada Workshop}, 1997,
4053 and whose most recent description is available at
4054 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4055
4056 The original definition of the profile was revised at subsequent IRTAW
4057 meetings. It has been included in the ISO
4058 @cite{Guide for the Use of the Ada Programming Language in High
4059 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4060 the next revision of the standard. The formal definition given by
4061 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4062 AI-305) available at
4063 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4064 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4065 respectively.
4066
4067 The above set is a superset of the restrictions provided by pragma
4068 @code{Profile (Restricted)}, it includes six additional restrictions
4069 (@code{Simple_Barriers}, @code{No_Select_Statements},
4070 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4071 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4072 that pragma @code{Profile (Ravenscar)}, like the pragma
4073 @code{Profile (Restricted)},
4074 automatically causes the use of a simplified,
4075 more efficient version of the tasking run-time system.
4076
4077 @node Pragma Profile (Restricted)
4078 @unnumberedsec Pragma Profile (Restricted)
4079 @findex Restricted Run Time
4080 @noindent
4081 Syntax:
4082
4083 @smallexample @c ada
4084 pragma Profile (Restricted);
4085 @end smallexample
4086
4087 @noindent
4088 A configuration pragma that establishes the following set of restrictions:
4089
4090 @itemize @bullet
4091 @item No_Abort_Statements
4092 @item No_Entry_Queue
4093 @item No_Task_Hierarchy
4094 @item No_Task_Allocators
4095 @item No_Dynamic_Priorities
4096 @item No_Terminate_Alternatives
4097 @item No_Dynamic_Attachment
4098 @item No_Protected_Type_Allocators
4099 @item No_Local_Protected_Objects
4100 @item No_Requeue_Statements
4101 @item No_Task_Attributes_Package
4102 @item Max_Asynchronous_Select_Nesting =  0
4103 @item Max_Task_Entries =  0
4104 @item Max_Protected_Entries = 1
4105 @item Max_Select_Alternatives = 0
4106 @end itemize
4107
4108 @noindent
4109 This set of restrictions causes the automatic selection of a simplified
4110 version of the run time that provides improved performance for the
4111 limited set of tasking functionality permitted by this set of restrictions.
4112
4113 @node Pragma Psect_Object
4114 @unnumberedsec Pragma Psect_Object
4115 @findex Psect_Object
4116 @noindent
4117 Syntax:
4118
4119 @smallexample @c ada
4120 pragma Psect_Object (
4121      [Internal =>] LOCAL_NAME,
4122   [, [External =>] EXTERNAL_SYMBOL]
4123   [, [Size     =>] EXTERNAL_SYMBOL]);
4124
4125 EXTERNAL_SYMBOL ::=
4126   IDENTIFIER
4127 | static_string_EXPRESSION
4128 @end smallexample
4129
4130 @noindent
4131 This pragma is identical in effect to pragma @code{Common_Object}.
4132
4133 @node Pragma Pure_Function
4134 @unnumberedsec Pragma Pure_Function
4135 @findex Pure_Function
4136 @noindent
4137 Syntax:
4138
4139 @smallexample @c ada
4140 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4141 @end smallexample
4142
4143 @noindent
4144 This pragma appears in the same declarative part as a function
4145 declaration (or a set of function declarations if more than one
4146 overloaded declaration exists, in which case the pragma applies
4147 to all entities).  It specifies that the function @code{Entity} is
4148 to be considered pure for the purposes of code generation.  This means
4149 that the compiler can assume that there are no side effects, and
4150 in particular that two calls with identical arguments produce the
4151 same result.  It also means that the function can be used in an
4152 address clause.
4153
4154 Note that, quite deliberately, there are no static checks to try
4155 to ensure that this promise is met, so @code{Pure_Function} can be used
4156 with functions that are conceptually pure, even if they do modify
4157 global variables.  For example, a square root function that is
4158 instrumented to count the number of times it is called is still
4159 conceptually pure, and can still be optimized, even though it
4160 modifies a global variable (the count).  Memo functions are another
4161 example (where a table of previous calls is kept and consulted to
4162 avoid re-computation).
4163
4164 @findex Pure
4165 Note: Most functions in a @code{Pure} package are automatically pure, and
4166 there is no need to use pragma @code{Pure_Function} for such functions.  One
4167 exception is any function that has at least one formal of type
4168 @code{System.Address} or a type derived from it.  Such functions are not
4169 considered pure by default, since the compiler assumes that the
4170 @code{Address} parameter may be functioning as a pointer and that the
4171 referenced data may change even if the address value does not.
4172 Similarly, imported functions are not considered to be pure by default,
4173 since there is no way of checking that they are in fact pure.  The use
4174 of pragma @code{Pure_Function} for such a function will override these default
4175 assumption, and cause the compiler to treat a designated subprogram as pure
4176 in these cases.
4177
4178 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4179 applies to the underlying renamed function.  This can be used to
4180 disambiguate cases of overloading where some but not all functions
4181 in a set of overloaded functions are to be designated as pure.
4182
4183 If pragma @code{Pure_Function} is applied to a library level function, the
4184 function is also considered pure from an optimization point of view, but the
4185 unit is not a Pure unit in the categorization sense. So for example, a function
4186 thus marked is free to @code{with} non-pure units.
4187
4188 @node Pragma Restriction_Warnings
4189 @unnumberedsec Pragma Restriction_Warnings
4190 @findex Restriction_Warnings
4191 @noindent
4192 Syntax:
4193
4194 @smallexample @c ada
4195 pragma Restriction_Warnings
4196   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4197 @end smallexample
4198
4199 @noindent
4200 This pragma allows a series of restriction identifiers to be
4201 specified (the list of allowed identifiers is the same as for
4202 pragma @code{Restrictions}). For each of these identifiers
4203 the compiler checks for violations of the restriction, but
4204 generates a warning message rather than an error message
4205 if the restriction is violated.
4206
4207 @node Pragma Shared
4208 @unnumberedsec Pragma Shared
4209 @findex Shared
4210
4211 @noindent
4212 This pragma is provided for compatibility with Ada 83. The syntax and
4213 semantics are identical to pragma Atomic.
4214
4215 @node Pragma Source_File_Name
4216 @unnumberedsec Pragma Source_File_Name
4217 @findex Source_File_Name
4218 @noindent
4219 Syntax:
4220
4221 @smallexample @c ada
4222 pragma Source_File_Name (
4223   [Unit_Name   =>] unit_NAME,
4224   Spec_File_Name =>  STRING_LITERAL,
4225   [Index => INTEGER_LITERAL]);
4226
4227 pragma Source_File_Name (
4228   [Unit_Name   =>] unit_NAME,
4229   Body_File_Name =>  STRING_LITERAL,
4230   [Index => INTEGER_LITERAL]);
4231 @end smallexample
4232
4233 @noindent
4234 Use this to override the normal naming convention.  It is a configuration
4235 pragma, and so has the usual applicability of configuration pragmas
4236 (i.e.@: it applies to either an entire partition, or to all units in a
4237 compilation, or to a single unit, depending on how it is used.
4238 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4239 the second argument is required, and indicates whether this is the file
4240 name for the spec or for the body.
4241
4242 The optional Index argument should be used when a file contains multiple
4243 units, and when you do not want to use @code{gnatchop} to separate then
4244 into multiple files (which is the recommended procedure to limit the
4245 number of recompilation that are needed when some sources change).
4246 For instance, if the source file @file{source.ada} contains
4247
4248 @smallexample @c ada
4249 package B is
4250 ...
4251 end B;
4252
4253 with B;
4254 procedure A is
4255 begin
4256    ..
4257 end A;
4258 @end smallexample
4259
4260 you could use the following configuration pragmas:
4261
4262 @smallexample @c ada
4263 pragma Source_File_Name
4264   (B, Spec_File_Name => "source.ada", Index => 1);
4265 pragma Source_File_Name
4266   (A, Body_File_Name => "source.ada", Index => 2);
4267 @end smallexample
4268
4269 Note that the @code{gnatname} utility can also be used to generate those
4270 configuration pragmas.
4271
4272 Another form of the @code{Source_File_Name} pragma allows
4273 the specification of patterns defining alternative file naming schemes
4274 to apply to all files.
4275
4276 @smallexample @c ada
4277 pragma Source_File_Name
4278   (  [Spec_File_Name  =>] STRING_LITERAL
4279    [,[Casing          =>] CASING_SPEC]
4280    [,[Dot_Replacement =>] STRING_LITERAL]);
4281
4282 pragma Source_File_Name
4283   (  [Body_File_Name  =>] STRING_LITERAL
4284    [,[Casing          =>] CASING_SPEC]
4285    [,[Dot_Replacement =>] STRING_LITERAL]);
4286
4287 pragma Source_File_Name
4288   (  [Subunit_File_Name =>] STRING_LITERAL
4289    [,[Casing            =>] CASING_SPEC]
4290    [,[Dot_Replacement   =>] STRING_LITERAL]);
4291
4292 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4293 @end smallexample
4294
4295 @noindent
4296 The first argument is a pattern that contains a single asterisk indicating
4297 the point at which the unit name is to be inserted in the pattern string
4298 to form the file name.  The second argument is optional.  If present it
4299 specifies the casing of the unit name in the resulting file name string.
4300 The default is lower case.  Finally the third argument allows for systematic
4301 replacement of any dots in the unit name by the specified string literal.
4302
4303 A pragma Source_File_Name cannot appear after a
4304 @ref{Pragma Source_File_Name_Project}.
4305
4306 For more details on the use of the @code{Source_File_Name} pragma,
4307 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4308 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4309 User's Guide}.
4310
4311 @node Pragma Source_File_Name_Project
4312 @unnumberedsec Pragma Source_File_Name_Project
4313 @findex Source_File_Name_Project
4314 @noindent
4315
4316 This pragma has the same syntax and semantics as pragma Source_File_Name.
4317 It is only allowed as a stand alone configuration pragma.
4318 It cannot appear after a @ref{Pragma Source_File_Name}, and
4319 most importantly, once pragma Source_File_Name_Project appears,
4320 no further Source_File_Name pragmas are allowed.
4321
4322 The intention is that Source_File_Name_Project pragmas are always
4323 generated by the Project Manager in a manner consistent with the naming
4324 specified in a project file, and when naming is controlled in this manner,
4325 it is not permissible to attempt to modify this naming scheme using
4326 Source_File_Name pragmas (which would not be known to the project manager).
4327
4328 @node Pragma Source_Reference
4329 @unnumberedsec Pragma Source_Reference
4330 @findex Source_Reference
4331 @noindent
4332 Syntax:
4333
4334 @smallexample @c ada
4335 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4336 @end smallexample
4337
4338 @noindent
4339 This pragma must appear as the first line of a source file.
4340 @var{integer_literal} is the logical line number of the line following
4341 the pragma line (for use in error messages and debugging
4342 information).  @var{string_literal} is a static string constant that
4343 specifies the file name to be used in error messages and debugging
4344 information.  This is most notably used for the output of @code{gnatchop}
4345 with the @option{-r} switch, to make sure that the original unchopped
4346 source file is the one referred to.
4347
4348 The second argument must be a string literal, it cannot be a static
4349 string expression other than a string literal.  This is because its value
4350 is needed for error messages issued by all phases of the compiler.
4351
4352 @node Pragma Stream_Convert
4353 @unnumberedsec Pragma Stream_Convert
4354 @findex Stream_Convert
4355 @noindent
4356 Syntax:
4357
4358 @smallexample @c ada
4359 pragma Stream_Convert (
4360   [Entity =>] type_LOCAL_NAME,
4361   [Read   =>] function_NAME,
4362   [Write  =>] function_NAME);
4363 @end smallexample
4364
4365 @noindent
4366 This pragma provides an efficient way of providing stream functions for
4367 types defined in packages.  Not only is it simpler to use than declaring
4368 the necessary functions with attribute representation clauses, but more
4369 significantly, it allows the declaration to made in such a way that the
4370 stream packages are not loaded unless they are needed.  The use of
4371 the Stream_Convert pragma adds no overhead at all, unless the stream
4372 attributes are actually used on the designated type.
4373
4374 The first argument specifies the type for which stream functions are
4375 provided.  The second parameter provides a function used to read values
4376 of this type.  It must name a function whose argument type may be any
4377 subtype, and whose returned type must be the type given as the first
4378 argument to the pragma.
4379
4380 The meaning of the @var{Read}
4381 parameter is that if a stream attribute directly
4382 or indirectly specifies reading of the type given as the first parameter,
4383 then a value of the type given as the argument to the Read function is
4384 read from the stream, and then the Read function is used to convert this
4385 to the required target type.
4386
4387 Similarly the @var{Write} parameter specifies how to treat write attributes
4388 that directly or indirectly apply to the type given as the first parameter.
4389 It must have an input parameter of the type specified by the first parameter,
4390 and the return type must be the same as the input type of the Read function.
4391 The effect is to first call the Write function to convert to the given stream
4392 type, and then write the result type to the stream.
4393
4394 The Read and Write functions must not be overloaded subprograms.  If necessary
4395 renamings can be supplied to meet this requirement.
4396 The usage of this attribute is best illustrated by a simple example, taken
4397 from the GNAT implementation of package Ada.Strings.Unbounded:
4398
4399 @smallexample @c ada
4400 function To_Unbounded (S : String)
4401            return Unbounded_String
4402   renames To_Unbounded_String;
4403
4404 pragma Stream_Convert
4405   (Unbounded_String, To_Unbounded, To_String);
4406 @end smallexample
4407
4408 @noindent
4409 The specifications of the referenced functions, as given in the Ada
4410 Reference Manual are:
4411
4412 @smallexample @c ada
4413 function To_Unbounded_String (Source : String)
4414   return Unbounded_String;
4415
4416 function To_String (Source : Unbounded_String)
4417   return String;
4418 @end smallexample
4419
4420 @noindent
4421 The effect is that if the value of an unbounded string is written to a stream,
4422 then the representation of the item in the stream is in the same format that
4423 would be used for @code{Standard.String'Output}, and this same representation
4424 is expected when a value of this type is read from the stream. Note that the
4425 value written always includes the bounds, even for Unbounded_String'Write,
4426 since Unbounded_String is not an array type.
4427
4428 @node Pragma Style_Checks
4429 @unnumberedsec Pragma Style_Checks
4430 @findex Style_Checks
4431 @noindent
4432 Syntax:
4433
4434 @smallexample @c ada
4435 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4436                      On | Off [, LOCAL_NAME]);
4437 @end smallexample
4438
4439 @noindent
4440 This pragma is used in conjunction with compiler switches to control the
4441 built in style checking provided by GNAT@.  The compiler switches, if set,
4442 provide an initial setting for the switches, and this pragma may be used
4443 to modify these settings, or the settings may be provided entirely by
4444 the use of the pragma.  This pragma can be used anywhere that a pragma
4445 is legal, including use as a configuration pragma (including use in
4446 the @file{gnat.adc} file).
4447
4448 The form with a string literal specifies which style options are to be
4449 activated.  These are additive, so they apply in addition to any previously
4450 set style check options.  The codes for the options are the same as those
4451 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4452 For example the following two methods can be used to enable
4453 layout checking:
4454
4455 @itemize @bullet
4456 @item
4457 @smallexample @c ada
4458 pragma Style_Checks ("l");
4459 @end smallexample
4460
4461 @item
4462 @smallexample
4463 gcc -c -gnatyl @dots{}
4464 @end smallexample
4465 @end itemize
4466
4467 @noindent
4468 The form ALL_CHECKS activates all standard checks (its use is equivalent
4469 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4470 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4471 @value{EDITION} User's Guide}, for details.
4472
4473 The forms with @code{Off} and @code{On}
4474 can be used to temporarily disable style checks
4475 as shown in the following example:
4476
4477 @smallexample @c ada
4478 @iftex
4479 @leftskip=0cm
4480 @end iftex
4481 pragma Style_Checks ("k"); -- requires keywords in lower case
4482 pragma Style_Checks (Off); -- turn off style checks
4483 NULL;                      -- this will not generate an error message
4484 pragma Style_Checks (On);  -- turn style checks back on
4485 NULL;                      -- this will generate an error message
4486 @end smallexample
4487
4488 @noindent
4489 Finally the two argument form is allowed only if the first argument is
4490 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4491 for the specified entity, as shown in the following example:
4492
4493 @smallexample @c ada
4494 @iftex
4495 @leftskip=0cm
4496 @end iftex
4497 pragma Style_Checks ("r"); -- require consistency of identifier casing
4498 Arg : Integer;
4499 Rf1 : Integer := ARG;      -- incorrect, wrong case
4500 pragma Style_Checks (Off, Arg);
4501 Rf2 : Integer := ARG;      -- OK, no error
4502 @end smallexample
4503
4504 @node Pragma Subtitle
4505 @unnumberedsec Pragma Subtitle
4506 @findex Subtitle
4507 @noindent
4508 Syntax:
4509
4510 @smallexample @c ada
4511 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4512 @end smallexample
4513
4514 @noindent
4515 This pragma is recognized for compatibility with other Ada compilers
4516 but is ignored by GNAT@.
4517
4518 @node Pragma Suppress
4519 @unnumberedsec Pragma Suppress
4520 @findex Suppress
4521 @noindent
4522 Syntax:
4523
4524 @smallexample @c ada
4525 pragma Suppress (Identifier [, [On =>] Name]);
4526 @end smallexample
4527
4528 @noindent
4529 This is a standard pragma, and supports all the check names required in
4530 the RM. It is included here because GNAT recognizes one additional check
4531 name: @code{Alignment_Check} which can be used to suppress alignment checks
4532 on addresses used in address clauses. Such checks can also be suppressed
4533 by suppressing range checks, but the specific use of @code{Alignment_Check}
4534 allows suppression of alignment checks without suppressing other range checks.
4535
4536 Note that pragma Suppress gives the compiler permission to omit
4537 checks, but does not require the compiler to omit checks. The compiler
4538 will generate checks if they are essentially free, even when they are
4539 suppressed. In particular, if the compiler can prove that a certain
4540 check will necessarily fail, it will generate code to do an
4541 unconditional ``raise'', even if checks are suppressed. The compiler
4542 warns in this case.
4543
4544 Of course, run-time checks are omitted whenever the compiler can prove
4545 that they will not fail, whether or not checks are suppressed.
4546
4547 @node Pragma Suppress_All
4548 @unnumberedsec Pragma Suppress_All
4549 @findex Suppress_All
4550 @noindent
4551 Syntax:
4552
4553 @smallexample @c ada
4554 pragma Suppress_All;
4555 @end smallexample
4556
4557 @noindent
4558 This pragma can only appear immediately following a compilation
4559 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4560 which it follows.  This pragma is implemented for compatibility with DEC
4561 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4562 configuration pragma is the preferred usage in GNAT@.
4563
4564 @node Pragma Suppress_Exception_Locations
4565 @unnumberedsec Pragma Suppress_Exception_Locations
4566 @findex Suppress_Exception_Locations
4567 @noindent
4568 Syntax:
4569
4570 @smallexample @c ada
4571 pragma Suppress_Exception_Locations;
4572 @end smallexample
4573
4574 @noindent
4575 In normal mode, a raise statement for an exception by default generates
4576 an exception message giving the file name and line number for the location
4577 of the raise. This is useful for debugging and logging purposes, but this
4578 entails extra space for the strings for the messages. The configuration
4579 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4580 generation of these strings, with the result that space is saved, but the
4581 exception message for such raises is null. This configuration pragma may
4582 appear in a global configuration pragma file, or in a specific unit as
4583 usual. It is not required that this pragma be used consistently within
4584 a partition, so it is fine to have some units within a partition compiled
4585 with this pragma and others compiled in normal mode without it.
4586
4587 @node Pragma Suppress_Initialization
4588 @unnumberedsec Pragma Suppress_Initialization
4589 @findex Suppress_Initialization
4590 @cindex Suppressing initialization
4591 @cindex Initialization, suppression of
4592 @noindent
4593 Syntax:
4594
4595 @smallexample @c ada
4596 pragma Suppress_Initialization ([Entity =>] type_Name);
4597 @end smallexample
4598
4599 @noindent
4600 This pragma suppresses any implicit or explicit initialization
4601 associated with the given type name for all variables of this type.
4602
4603 @node Pragma Task_Info
4604 @unnumberedsec Pragma Task_Info
4605 @findex Task_Info
4606 @noindent
4607 Syntax
4608
4609 @smallexample @c ada
4610 pragma Task_Info (EXPRESSION);
4611 @end smallexample
4612
4613 @noindent
4614 This pragma appears within a task definition (like pragma
4615 @code{Priority}) and applies to the task in which it appears.  The
4616 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4617 The @code{Task_Info} pragma provides system dependent control over
4618 aspects of tasking implementation, for example, the ability to map
4619 tasks to specific processors.  For details on the facilities available
4620 for the version of GNAT that you are using, see the documentation
4621 in the spec of package System.Task_Info in the runtime
4622 library.
4623
4624 @node Pragma Task_Name
4625 @unnumberedsec Pragma Task_Name
4626 @findex Task_Name
4627 @noindent
4628 Syntax
4629
4630 @smallexample @c ada
4631 pragma Task_Name (string_EXPRESSION);
4632 @end smallexample
4633
4634 @noindent
4635 This pragma appears within a task definition (like pragma
4636 @code{Priority}) and applies to the task in which it appears.  The
4637 argument must be of type String, and provides a name to be used for
4638 the task instance when the task is created.  Note that this expression
4639 is not required to be static, and in particular, it can contain
4640 references to task discriminants.  This facility can be used to
4641 provide different names for different tasks as they are created,
4642 as illustrated in the example below.
4643
4644 The task name is recorded internally in the run-time structures
4645 and is accessible to tools like the debugger.  In addition the
4646 routine @code{Ada.Task_Identification.Image} will return this
4647 string, with a unique task address appended.
4648
4649 @smallexample @c ada
4650 --  Example of the use of pragma Task_Name
4651
4652 with Ada.Task_Identification;
4653 use Ada.Task_Identification;
4654 with Text_IO; use Text_IO;
4655 procedure t3 is
4656
4657    type Astring is access String;
4658
4659    task type Task_Typ (Name : access String) is
4660       pragma Task_Name (Name.all);
4661    end Task_Typ;
4662
4663    task body Task_Typ is
4664       Nam : constant String := Image (Current_Task);
4665    begin
4666       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4667    end Task_Typ;
4668
4669    type Ptr_Task is access Task_Typ;
4670    Task_Var : Ptr_Task;
4671
4672 begin
4673    Task_Var :=
4674      new Task_Typ (new String'("This is task 1"));
4675    Task_Var :=
4676      new Task_Typ (new String'("This is task 2"));
4677 end;
4678 @end smallexample
4679
4680 @node Pragma Task_Storage
4681 @unnumberedsec Pragma Task_Storage
4682 @findex Task_Storage
4683 Syntax:
4684
4685 @smallexample @c ada
4686 pragma Task_Storage (
4687   [Task_Type =>] LOCAL_NAME,
4688   [Top_Guard =>] static_integer_EXPRESSION);
4689 @end smallexample
4690
4691 @noindent
4692 This pragma specifies the length of the guard area for tasks.  The guard
4693 area is an additional storage area allocated to a task.  A value of zero
4694 means that either no guard area is created or a minimal guard area is
4695 created, depending on the target.  This pragma can appear anywhere a
4696 @code{Storage_Size} attribute definition clause is allowed for a task
4697 type.
4698
4699 @node Pragma Thread_Local_Storage
4700 @unnumberedsec Pragma Thread_Local_Storage
4701 @findex Thread_Local_Storage
4702 @cindex Task specific storage
4703 @cindex TLS (Thread Local Storage)
4704 Syntax:
4705
4706 @smallexample @c ada
4707 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4708 @end smallexample
4709
4710 @noindent
4711 This pragma specifies that the specified entity, which must be
4712 a variable declared in a library level package, is to be marked as
4713 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4714 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4715 (and hence each Ada task) to see a distinct copy of the variable.
4716
4717 The variable may not have default initialization, and if there is
4718 an explicit initialization, it must be either @code{null} for an
4719 access variable, or a static expression for a scalar variable.
4720 This provides a low level mechanism similar to that provided by
4721 the @code{Ada.Task_Attributes} package, but much more efficient
4722 and is also useful in writing interface code that will interact
4723 with foreign threads.
4724
4725 If this pragma is used on a system where @code{TLS} is not supported,
4726 then an error message will be generated and the program will be rejected.
4727
4728 @node Pragma Time_Slice
4729 @unnumberedsec Pragma Time_Slice
4730 @findex Time_Slice
4731 @noindent
4732 Syntax:
4733
4734 @smallexample @c ada
4735 pragma Time_Slice (static_duration_EXPRESSION);
4736 @end smallexample
4737
4738 @noindent
4739 For implementations of GNAT on operating systems where it is possible
4740 to supply a time slice value, this pragma may be used for this purpose.
4741 It is ignored if it is used in a system that does not allow this control,
4742 or if it appears in other than the main program unit.
4743 @cindex OpenVMS
4744 Note that the effect of this pragma is identical to the effect of the
4745 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4746
4747 @node Pragma Title
4748 @unnumberedsec Pragma Title
4749 @findex Title
4750 @noindent
4751 Syntax:
4752
4753 @smallexample @c ada
4754 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4755
4756 TITLING_OPTION ::=
4757   [Title    =>] STRING_LITERAL,
4758 | [Subtitle =>] STRING_LITERAL
4759 @end smallexample
4760
4761 @noindent
4762 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4763 pragma used in DEC Ada 83 implementations to provide a title and/or
4764 subtitle for the program listing.  The program listing generated by GNAT
4765 does not have titles or subtitles.
4766
4767 Unlike other pragmas, the full flexibility of named notation is allowed
4768 for this pragma, i.e.@: the parameters may be given in any order if named
4769 notation is used, and named and positional notation can be mixed
4770 following the normal rules for procedure calls in Ada.
4771
4772 @node Pragma Unchecked_Union
4773 @unnumberedsec Pragma Unchecked_Union
4774 @cindex Unions in C
4775 @findex Unchecked_Union
4776 @noindent
4777 Syntax:
4778
4779 @smallexample @c ada
4780 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4781 @end smallexample
4782
4783 @noindent
4784 This pragma is used to specify a representation of a record type that is
4785 equivalent to a C union. It was introduced as a GNAT implementation defined
4786 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4787 pragma, making it language defined, and GNAT fully implements this extended
4788 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4789 details, consult the Ada 2005 Reference Manual, section B.3.3.
4790
4791 @node Pragma Unimplemented_Unit
4792 @unnumberedsec Pragma Unimplemented_Unit
4793 @findex Unimplemented_Unit
4794 @noindent
4795 Syntax:
4796
4797 @smallexample @c ada
4798 pragma Unimplemented_Unit;
4799 @end smallexample
4800
4801 @noindent
4802 If this pragma occurs in a unit that is processed by the compiler, GNAT
4803 aborts with the message @samp{@var{xxx} not implemented}, where
4804 @var{xxx} is the name of the current compilation unit.  This pragma is
4805 intended to allow the compiler to handle unimplemented library units in
4806 a clean manner.
4807
4808 The abort only happens if code is being generated.  Thus you can use
4809 specs of unimplemented packages in syntax or semantic checking mode.
4810
4811 @node Pragma Universal_Aliasing
4812 @unnumberedsec Pragma Universal_Aliasing
4813 @findex Universal_Aliasing
4814 @noindent
4815 Syntax:
4816
4817 @smallexample @c ada
4818 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4819 @end smallexample
4820
4821 @noindent
4822 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4823 declarative part.  The effect is to inhibit strict type-based aliasing
4824 optimization for the given type.  In other words, the effect is as though
4825 access types designating this type were subject to pragma No_Strict_Aliasing.
4826 For a detailed description of the strict aliasing optimization, and the
4827 situations in which it must be suppressed, @xref{Optimization and Strict
4828 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4829
4830 @node Pragma Universal_Data
4831 @unnumberedsec Pragma Universal_Data
4832 @findex Universal_Data
4833 @noindent
4834 Syntax:
4835
4836 @smallexample @c ada
4837 pragma Universal_Data [(library_unit_Name)];
4838 @end smallexample
4839
4840 @noindent
4841 This pragma is supported only for the AAMP target and is ignored for
4842 other targets. The pragma specifies that all library-level objects
4843 (Counter 0 data) associated with the library unit are to be accessed
4844 and updated using universal addressing (24-bit addresses for AAMP5)
4845 rather than the default of 16-bit Data Environment (DENV) addressing.
4846 Use of this pragma will generally result in less efficient code for
4847 references to global data associated with the library unit, but
4848 allows such data to be located anywhere in memory. This pragma is
4849 a library unit pragma, but can also be used as a configuration pragma
4850 (including use in the @file{gnat.adc} file). The functionality
4851 of this pragma is also available by applying the -univ switch on the
4852 compilations of units where universal addressing of the data is desired.
4853
4854 @node Pragma Unmodified
4855 @unnumberedsec Pragma Unmodified
4856 @findex Unmodified
4857 @cindex Warnings, unmodified
4858 @noindent
4859 Syntax:
4860
4861 @smallexample @c ada
4862 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4863 @end smallexample
4864
4865 @noindent
4866 This pragma signals that the assignable entities (variables,
4867 @code{out} parameters, @code{in out} parameters) whose names are listed are
4868 deliberately not assigned in the current source unit. This
4869 suppresses warnings about the
4870 entities being referenced but not assigned, and in addition a warning will be
4871 generated if one of these entities is in fact assigned in the
4872 same unit as the pragma (or in the corresponding body, or one
4873 of its subunits).
4874
4875 This is particularly useful for clearly signaling that a particular
4876 parameter is not modified, even though the spec suggests that it might
4877 be.
4878
4879 @node Pragma Unreferenced
4880 @unnumberedsec Pragma Unreferenced
4881 @findex Unreferenced
4882 @cindex Warnings, unreferenced
4883 @noindent
4884 Syntax:
4885
4886 @smallexample @c ada
4887 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4888 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4889 @end smallexample
4890
4891 @noindent
4892 This pragma signals that the entities whose names are listed are
4893 deliberately not referenced in the current source unit. This
4894 suppresses warnings about the
4895 entities being unreferenced, and in addition a warning will be
4896 generated if one of these entities is in fact referenced in the
4897 same unit as the pragma (or in the corresponding body, or one
4898 of its subunits).
4899
4900 This is particularly useful for clearly signaling that a particular
4901 parameter is not referenced in some particular subprogram implementation
4902 and that this is deliberate. It can also be useful in the case of
4903 objects declared only for their initialization or finalization side
4904 effects.
4905
4906 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4907 current scope, then the entity most recently declared is the one to which
4908 the pragma applies. Note that in the case of accept formals, the pragma
4909 Unreferenced may appear immediately after the keyword @code{do} which
4910 allows the indication of whether or not accept formals are referenced
4911 or not to be given individually for each accept statement.
4912
4913 The left hand side of an assignment does not count as a reference for the
4914 purpose of this pragma. Thus it is fine to assign to an entity for which
4915 pragma Unreferenced is given.
4916
4917 Note that if a warning is desired for all calls to a given subprogram,
4918 regardless of whether they occur in the same unit as the subprogram
4919 declaration, then this pragma should not be used (calls from another
4920 unit would not be flagged); pragma Obsolescent can be used instead
4921 for this purpose, see @xref{Pragma Obsolescent}.
4922
4923 The second form of pragma @code{Unreferenced} is used within a context
4924 clause. In this case the arguments must be unit names of units previously
4925 mentioned in @code{with} clauses (similar to the usage of pragma
4926 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4927 units and unreferenced entities within these units.
4928
4929 @node Pragma Unreferenced_Objects
4930 @unnumberedsec Pragma Unreferenced_Objects
4931 @findex Unreferenced_Objects
4932 @cindex Warnings, unreferenced
4933 @noindent
4934 Syntax:
4935
4936 @smallexample @c ada
4937 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4938 @end smallexample
4939
4940 @noindent
4941 This pragma signals that for the types or subtypes whose names are
4942 listed, objects which are declared with one of these types or subtypes may
4943 not be referenced, and if no references appear, no warnings are given.
4944
4945 This is particularly useful for objects which are declared solely for their
4946 initialization and finalization effect. Such variables are sometimes referred
4947 to as RAII variables (Resource Acquisition Is Initialization). Using this
4948 pragma on the relevant type (most typically a limited controlled type), the
4949 compiler will automatically suppress unwanted warnings about these variables
4950 not being referenced.
4951
4952 @node Pragma Unreserve_All_Interrupts
4953 @unnumberedsec Pragma Unreserve_All_Interrupts
4954 @findex Unreserve_All_Interrupts
4955 @noindent
4956 Syntax:
4957
4958 @smallexample @c ada
4959 pragma Unreserve_All_Interrupts;
4960 @end smallexample
4961
4962 @noindent
4963 Normally certain interrupts are reserved to the implementation.  Any attempt
4964 to attach an interrupt causes Program_Error to be raised, as described in
4965 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4966 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4967 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4968 interrupt execution.
4969
4970 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4971 a program, then all such interrupts are unreserved.  This allows the
4972 program to handle these interrupts, but disables their standard
4973 functions.  For example, if this pragma is used, then pressing
4974 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4975 a program can then handle the @code{SIGINT} interrupt as it chooses.
4976
4977 For a full list of the interrupts handled in a specific implementation,
4978 see the source code for the spec of @code{Ada.Interrupts.Names} in
4979 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4980 list of interrupts recognized for a given target.  The documentation in
4981 this file also specifies what interrupts are affected by the use of
4982 the @code{Unreserve_All_Interrupts} pragma.
4983
4984 For a more general facility for controlling what interrupts can be
4985 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4986 of the @code{Unreserve_All_Interrupts} pragma.
4987
4988 @node Pragma Unsuppress
4989 @unnumberedsec Pragma Unsuppress
4990 @findex Unsuppress
4991 @noindent
4992 Syntax:
4993
4994 @smallexample @c ada
4995 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4996 @end smallexample
4997
4998 @noindent
4999 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5000 there is no corresponding pragma @code{Suppress} in effect, it has no
5001 effect.  The range of the effect is the same as for pragma
5002 @code{Suppress}.  The meaning of the arguments is identical to that used
5003 in pragma @code{Suppress}.
5004
5005 One important application is to ensure that checks are on in cases where
5006 code depends on the checks for its correct functioning, so that the code
5007 will compile correctly even if the compiler switches are set to suppress
5008 checks.
5009
5010 @node Pragma Use_VADS_Size
5011 @unnumberedsec Pragma Use_VADS_Size
5012 @cindex @code{Size}, VADS compatibility
5013 @findex Use_VADS_Size
5014 @noindent
5015 Syntax:
5016
5017 @smallexample @c ada
5018 pragma Use_VADS_Size;
5019 @end smallexample
5020
5021 @noindent
5022 This is a configuration pragma.  In a unit to which it applies, any use
5023 of the 'Size attribute is automatically interpreted as a use of the
5024 'VADS_Size attribute.  Note that this may result in incorrect semantic
5025 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5026 the handling of existing code which depends on the interpretation of Size
5027 as implemented in the VADS compiler.  See description of the VADS_Size
5028 attribute for further details.
5029
5030 @node Pragma Validity_Checks
5031 @unnumberedsec Pragma Validity_Checks
5032 @findex Validity_Checks
5033 @noindent
5034 Syntax:
5035
5036 @smallexample @c ada
5037 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5038 @end smallexample
5039
5040 @noindent
5041 This pragma is used in conjunction with compiler switches to control the
5042 built-in validity checking provided by GNAT@.  The compiler switches, if set
5043 provide an initial setting for the switches, and this pragma may be used
5044 to modify these settings, or the settings may be provided entirely by
5045 the use of the pragma.  This pragma can be used anywhere that a pragma
5046 is legal, including use as a configuration pragma (including use in
5047 the @file{gnat.adc} file).
5048
5049 The form with a string literal specifies which validity options are to be
5050 activated.  The validity checks are first set to include only the default
5051 reference manual settings, and then a string of letters in the string
5052 specifies the exact set of options required.  The form of this string
5053 is exactly as described for the @option{-gnatVx} compiler switch (see the
5054 GNAT users guide for details).  For example the following two methods
5055 can be used to enable validity checking for mode @code{in} and
5056 @code{in out} subprogram parameters:
5057
5058 @itemize @bullet
5059 @item
5060 @smallexample @c ada
5061 pragma Validity_Checks ("im");
5062 @end smallexample
5063
5064 @item
5065 @smallexample
5066 gcc -c -gnatVim @dots{}
5067 @end smallexample
5068 @end itemize
5069
5070 @noindent
5071 The form ALL_CHECKS activates all standard checks (its use is equivalent
5072 to the use of the @code{gnatva} switch.
5073
5074 The forms with @code{Off} and @code{On}
5075 can be used to temporarily disable validity checks
5076 as shown in the following example:
5077
5078 @smallexample @c ada
5079 @iftex
5080 @leftskip=0cm
5081 @end iftex
5082 pragma Validity_Checks ("c"); -- validity checks for copies
5083 pragma Validity_Checks (Off); -- turn off validity checks
5084 A := B;                       -- B will not be validity checked
5085 pragma Validity_Checks (On);  -- turn validity checks back on
5086 A := C;                       -- C will be validity checked
5087 @end smallexample
5088
5089 @node Pragma Volatile
5090 @unnumberedsec Pragma Volatile
5091 @findex Volatile
5092 @noindent
5093 Syntax:
5094
5095 @smallexample @c ada
5096 pragma Volatile (LOCAL_NAME);
5097 @end smallexample
5098
5099 @noindent
5100 This pragma is defined by the Ada Reference Manual, and the GNAT
5101 implementation is fully conformant with this definition.  The reason it
5102 is mentioned in this section is that a pragma of the same name was supplied
5103 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5104 implementation of pragma Volatile is upwards compatible with the
5105 implementation in DEC Ada 83.
5106
5107 @node Pragma Warnings
5108 @unnumberedsec Pragma Warnings
5109 @findex Warnings
5110 @noindent
5111 Syntax:
5112
5113 @smallexample @c ada
5114 pragma Warnings (On | Off);
5115 pragma Warnings (On | Off, LOCAL_NAME);
5116 pragma Warnings (static_string_EXPRESSION);
5117 pragma Warnings (On | Off, static_string_EXPRESSION);
5118 @end smallexample
5119
5120 @noindent
5121 Normally warnings are enabled, with the output being controlled by
5122 the command line switch.  Warnings (@code{Off}) turns off generation of
5123 warnings until a Warnings (@code{On}) is encountered or the end of the
5124 current unit.  If generation of warnings is turned off using this
5125 pragma, then no warning messages are output, regardless of the
5126 setting of the command line switches.
5127
5128 The form with a single argument may be used as a configuration pragma.
5129
5130 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5131 the specified entity.  This suppression is effective from the point where
5132 it occurs till the end of the extended scope of the variable (similar to
5133 the scope of @code{Suppress}).
5134
5135 The form with a single static_string_EXPRESSION argument provides more precise
5136 control over which warnings are active. The string is a list of letters
5137 specifying which warnings are to be activated and which deactivated. The
5138 code for these letters is the same as the string used in the command
5139 line switch controlling warnings. The following is a brief summary. For
5140 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5141 User's Guide}.
5142
5143 @smallexample
5144 a    turn on all optional warnings (except d h l .o)
5145 A    turn off all optional warnings
5146 .a*  turn on warnings for failing assertions
5147 .A   turn off warnings for failing assertions
5148 b    turn on warnings for bad fixed value (not multiple of small)
5149 B*   turn off warnings for bad fixed value (not multiple of small)
5150 .b*  turn on warnings for biased representation
5151 .B   turn off warnings for biased representation
5152 c    turn on warnings for constant conditional
5153 C*   turn off warnings for constant conditional
5154 .c   turn on warnings for unrepped components
5155 .C*  turn off warnings for unrepped components
5156 d    turn on warnings for implicit dereference
5157 D*   turn off warnings for implicit dereference
5158 e    treat all warnings as errors
5159 .e   turn on every optional warning
5160 f    turn on warnings for unreferenced formal
5161 F*   turn off warnings for unreferenced formal
5162 g*   turn on warnings for unrecognized pragma
5163 G    turn off warnings for unrecognized pragma
5164 h    turn on warnings for hiding variable
5165 H*   turn off warnings for hiding variable
5166 i*   turn on warnings for implementation unit
5167 I    turn off warnings for implementation unit
5168 j    turn on warnings for obsolescent (annex J) feature
5169 J*   turn off warnings for obsolescent (annex J) feature
5170 k    turn on warnings on constant variable
5171 K*   turn off warnings on constant variable
5172 l    turn on warnings for missing elaboration pragma
5173 L*   turn off warnings for missing elaboration pragma
5174 m    turn on warnings for variable assigned but not read
5175 M*   turn off warnings for variable assigned but not read
5176 n*   normal warning mode (cancels -gnatws/-gnatwe)
5177 o*   turn on warnings for address clause overlay
5178 O    turn off warnings for address clause overlay
5179 .o   turn on warnings for out parameters assigned but not read
5180 .O*  turn off warnings for out parameters assigned but not read
5181 p    turn on warnings for ineffective pragma Inline in frontend
5182 P*   turn off warnings for ineffective pragma Inline in frontend
5183 .p   turn on warnings for parameter ordering
5184 .P*  turn off warnings for parameter ordering
5185 q*   turn on warnings for questionable missing parentheses
5186 Q    turn off warnings for questionable missing parentheses
5187 r    turn on warnings for redundant construct
5188 R*   turn off warnings for redundant construct
5189 .r   turn on warnings for object renaming function
5190 .R*  turn off warnings for object renaming function
5191 s    suppress all warnings
5192 t    turn on warnings for tracking deleted code
5193 T*   turn off warnings for tracking deleted code
5194 u    turn on warnings for unused entity
5195 U*   turn off warnings for unused entity
5196 v*   turn on warnings for unassigned variable
5197 V    turn off warnings for unassigned variable
5198 w*   turn on warnings for wrong low bound assumption
5199 W    turn off warnings for wrong low bound assumption
5200 .w   turn on warnings for unnecessary Warnings Off pragmas
5201 .W*  turn off warnings for unnecessary Warnings Off pragmas
5202 x*   turn on warnings for export/import
5203 X    turn off warnings for export/import
5204 .x   turn on warnings for non-local exceptions
5205 .X*  turn off warnings for non-local exceptions
5206 y*   turn on warnings for Ada 2005 incompatibility
5207 Y    turn off warnings for Ada 2005 incompatibility
5208 z*   turn on convention/size/align warnings for unchecked conversion
5209 Z    turn off convention/size/align warnings for unchecked conversion
5210 *    indicates default in above list
5211 @end smallexample
5212
5213 @noindent
5214 The specified warnings will be in effect until the end of the program
5215 or another pragma Warnings is encountered. The effect of the pragma is
5216 cumulative. Initially the set of warnings is the standard default set
5217 as possibly modified by compiler switches. Then each pragma Warning
5218 modifies this set of warnings as specified. This form of the pragma may
5219 also be used as a configuration pragma.
5220
5221 The fourth form, with an On|Off parameter and a string, is used to
5222 control individual messages, based on their text. The string argument
5223 is a pattern that is used to match against the text of individual
5224 warning messages (not including the initial "warning: " tag).
5225
5226 The pattern may contain asterisks, which match zero or more characters in
5227 the message. For example, you can use
5228 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5229 message @code{warning: 960 bits of "a" unused}. No other regular
5230 expression notations are permitted. All characters other than asterisk in
5231 these three specific cases are treated as literal characters in the match.
5232
5233 There are two ways to use this pragma. The OFF form can be used as a
5234 configuration pragma. The effect is to suppress all warnings (if any)
5235 that match the pattern string throughout the compilation.
5236
5237 The second usage is to suppress a warning locally, and in this case, two
5238 pragmas must appear in sequence:
5239
5240 @smallexample @c ada
5241 pragma Warnings (Off, Pattern);
5242 @dots{} code where given warning is to be suppressed
5243 pragma Warnings (On, Pattern);
5244 @end smallexample
5245
5246 @noindent
5247 In this usage, the pattern string must match in the Off and On pragmas,
5248 and at least one matching warning must be suppressed.
5249
5250 @node Pragma Weak_External
5251 @unnumberedsec Pragma Weak_External
5252 @findex Weak_External
5253 @noindent
5254 Syntax:
5255
5256 @smallexample @c ada
5257 pragma Weak_External ([Entity =>] LOCAL_NAME);
5258 @end smallexample
5259
5260 @noindent
5261 @var{LOCAL_NAME} must refer to an object that is declared at the library
5262 level. This pragma specifies that the given entity should be marked as a
5263 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5264 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5265 of a regular symbol, that is to say a symbol that does not have to be
5266 resolved by the linker if used in conjunction with a pragma Import.
5267
5268 When a weak symbol is not resolved by the linker, its address is set to
5269 zero. This is useful in writing interfaces to external modules that may
5270 or may not be linked in the final executable, for example depending on
5271 configuration settings.
5272
5273 If a program references at run time an entity to which this pragma has been
5274 applied, and the corresponding symbol was not resolved at link time, then
5275 the execution of the program is erroneous. It is not erroneous to take the
5276 Address of such an entity, for example to guard potential references,
5277 as shown in the example below.
5278
5279 Some file formats do not support weak symbols so not all target machines
5280 support this pragma.
5281
5282 @smallexample @c ada
5283 --  Example of the use of pragma Weak_External
5284
5285 package External_Module is
5286   key : Integer;
5287   pragma Import (C, key);
5288   pragma Weak_External (key);
5289   function Present return boolean;
5290 end External_Module;
5291
5292 with System; use System;
5293 package body External_Module is
5294   function Present return boolean is
5295   begin
5296     return key'Address /= System.Null_Address;
5297   end Present;
5298 end External_Module;
5299 @end smallexample
5300
5301 @node Pragma Wide_Character_Encoding
5302 @unnumberedsec Pragma Wide_Character_Encoding
5303 @findex Wide_Character_Encoding
5304 @noindent
5305 Syntax:
5306
5307 @smallexample @c ada
5308 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5309 @end smallexample
5310
5311 @noindent
5312 This pragma specifies the wide character encoding to be used in program
5313 source text appearing subsequently. It is a configuration pragma, but may
5314 also be used at any point that a pragma is allowed, and it is permissible
5315 to have more than one such pragma in a file, allowing multiple encodings
5316 to appear within the same file.
5317
5318 The argument can be an identifier or a character literal. In the identifier
5319 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5320 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5321 case it is correspondingly one of the characters @samp{h}, @samp{u},
5322 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5323
5324 Note that when the pragma is used within a file, it affects only the
5325 encoding within that file, and does not affect withed units, specs,
5326 or subunits.
5327
5328 @node Implementation Defined Attributes
5329 @chapter Implementation Defined Attributes
5330 Ada defines (throughout the Ada reference manual,
5331 summarized in Annex K),
5332 a set of attributes that provide useful additional functionality in all
5333 areas of the language.  These language defined attributes are implemented
5334 in GNAT and work as described in the Ada Reference Manual.
5335
5336 In addition, Ada allows implementations to define additional
5337 attributes whose meaning is defined by the implementation.  GNAT provides
5338 a number of these implementation-dependent attributes which can be used
5339 to extend and enhance the functionality of the compiler.  This section of
5340 the GNAT reference manual describes these additional attributes.
5341
5342 Note that any program using these attributes may not be portable to
5343 other compilers (although GNAT implements this set of attributes on all
5344 platforms).  Therefore if portability to other compilers is an important
5345 consideration, you should minimize the use of these attributes.
5346
5347 @menu
5348 * Abort_Signal::
5349 * Address_Size::
5350 * Asm_Input::
5351 * Asm_Output::
5352 * AST_Entry::
5353 * Bit::
5354 * Bit_Position::
5355 * Compiler_Version::
5356 * Code_Address::
5357 * Default_Bit_Order::
5358 * Elaborated::
5359 * Elab_Body::
5360 * Elab_Spec::
5361 * Emax::
5362 * Enabled::
5363 * Enum_Rep::
5364 * Enum_Val::
5365 * Epsilon::
5366 * Fixed_Value::
5367 * Has_Access_Values::
5368 * Has_Discriminants::
5369 * Img::
5370 * Integer_Value::
5371 * Invalid_Value::
5372 * Large::
5373 * Machine_Size::
5374 * Mantissa::
5375 * Max_Interrupt_Priority::
5376 * Max_Priority::
5377 * Maximum_Alignment::
5378 * Mechanism_Code::
5379 * Null_Parameter::
5380 * Object_Size::
5381 * Old::
5382 * Passed_By_Reference::
5383 * Pool_Address::
5384 * Range_Length::
5385 * Safe_Emax::
5386 * Safe_Large::
5387 * Small::
5388 * Storage_Unit::
5389 * Stub_Type::
5390 * Target_Name::
5391 * Tick::
5392 * To_Address::
5393 * Type_Class::
5394 * UET_Address::
5395 * Unconstrained_Array::
5396 * Universal_Literal_String::
5397 * Unrestricted_Access::
5398 * VADS_Size::
5399 * Value_Size::
5400 * Wchar_T_Size::
5401 * Word_Size::
5402 @end menu
5403
5404 @node Abort_Signal
5405 @unnumberedsec Abort_Signal
5406 @findex Abort_Signal
5407 @noindent
5408 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5409 prefix) provides the entity for the special exception used to signal
5410 task abort or asynchronous transfer of control.  Normally this attribute
5411 should only be used in the tasking runtime (it is highly peculiar, and
5412 completely outside the normal semantics of Ada, for a user program to
5413 intercept the abort exception).
5414
5415 @node Address_Size
5416 @unnumberedsec Address_Size
5417 @cindex Size of @code{Address}
5418 @findex Address_Size
5419 @noindent
5420 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5421 prefix) is a static constant giving the number of bits in an
5422 @code{Address}. It is the same value as System.Address'Size,
5423 but has the advantage of being static, while a direct
5424 reference to System.Address'Size is non-static because Address
5425 is a private type.
5426
5427 @node Asm_Input
5428 @unnumberedsec Asm_Input
5429 @findex Asm_Input
5430 @noindent
5431 The @code{Asm_Input} attribute denotes a function that takes two
5432 parameters.  The first is a string, the second is an expression of the
5433 type designated by the prefix.  The first (string) argument is required
5434 to be a static expression, and is the constraint for the parameter,
5435 (e.g.@: what kind of register is required).  The second argument is the
5436 value to be used as the input argument.  The possible values for the
5437 constant are the same as those used in the RTL, and are dependent on
5438 the configuration file used to built the GCC back end.
5439 @ref{Machine Code Insertions}
5440
5441 @node Asm_Output
5442 @unnumberedsec Asm_Output
5443 @findex Asm_Output
5444 @noindent
5445 The @code{Asm_Output} attribute denotes a function that takes two
5446 parameters.  The first is a string, the second is the name of a variable
5447 of the type designated by the attribute prefix.  The first (string)
5448 argument is required to be a static expression and designates the
5449 constraint for the parameter (e.g.@: what kind of register is
5450 required).  The second argument is the variable to be updated with the
5451 result.  The possible values for constraint are the same as those used in
5452 the RTL, and are dependent on the configuration file used to build the
5453 GCC back end.  If there are no output operands, then this argument may
5454 either be omitted, or explicitly given as @code{No_Output_Operands}.
5455 @ref{Machine Code Insertions}
5456
5457 @node AST_Entry
5458 @unnumberedsec AST_Entry
5459 @cindex OpenVMS
5460 @findex AST_Entry
5461 @noindent
5462 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5463 the name of an entry, it yields a value of the predefined type AST_Handler
5464 (declared in the predefined package System, as extended by the use of
5465 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5466 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5467 Language Reference Manual}, section 9.12a.
5468
5469 @node Bit
5470 @unnumberedsec Bit
5471 @findex Bit
5472 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5473 offset within the storage unit (byte) that contains the first bit of
5474 storage allocated for the object.  The value of this attribute is of the
5475 type @code{Universal_Integer}, and is always a non-negative number not
5476 exceeding the value of @code{System.Storage_Unit}.
5477
5478 For an object that is a variable or a constant allocated in a register,
5479 the value is zero.  (The use of this attribute does not force the
5480 allocation of a variable to memory).
5481
5482 For an object that is a formal parameter, this attribute applies
5483 to either the matching actual parameter or to a copy of the
5484 matching actual parameter.
5485
5486 For an access object the value is zero.  Note that
5487 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5488 designated object.  Similarly for a record component
5489 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5490 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5491 are subject to index checks.
5492
5493 This attribute is designed to be compatible with the DEC Ada 83 definition
5494 and implementation of the @code{Bit} attribute.
5495
5496 @node Bit_Position
5497 @unnumberedsec Bit_Position
5498 @findex Bit_Position
5499 @noindent
5500 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5501 of the fields of the record type, yields the bit
5502 offset within the record contains the first bit of
5503 storage allocated for the object.  The value of this attribute is of the
5504 type @code{Universal_Integer}.  The value depends only on the field
5505 @var{C} and is independent of the alignment of
5506 the containing record @var{R}.
5507
5508 @node Compiler_Version
5509 @unnumberedsec Compiler_Version
5510 @findex Compiler_Version
5511 @noindent
5512 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5513 prefix) yields a static string identifying the version of the compiler
5514 being used to compile the unit containing the attribute reference. A
5515 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5516
5517 @node Code_Address
5518 @unnumberedsec Code_Address
5519 @findex Code_Address
5520 @cindex Subprogram address
5521 @cindex Address of subprogram code
5522 @noindent
5523 The @code{'Address}
5524 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5525 intended effect seems to be to provide
5526 an address value which can be used to call the subprogram by means of
5527 an address clause as in the following example:
5528
5529 @smallexample @c ada
5530 procedure K is @dots{}
5531
5532 procedure L;
5533 for L'Address use K'Address;
5534 pragma Import (Ada, L);
5535 @end smallexample
5536
5537 @noindent
5538 A call to @code{L} is then expected to result in a call to @code{K}@.
5539 In Ada 83, where there were no access-to-subprogram values, this was
5540 a common work-around for getting the effect of an indirect call.
5541 GNAT implements the above use of @code{Address} and the technique
5542 illustrated by the example code works correctly.
5543
5544 However, for some purposes, it is useful to have the address of the start
5545 of the generated code for the subprogram.  On some architectures, this is
5546 not necessarily the same as the @code{Address} value described above.
5547 For example, the @code{Address} value may reference a subprogram
5548 descriptor rather than the subprogram itself.
5549
5550 The @code{'Code_Address} attribute, which can only be applied to
5551 subprogram entities, always returns the address of the start of the
5552 generated code of the specified subprogram, which may or may not be
5553 the same value as is returned by the corresponding @code{'Address}
5554 attribute.
5555
5556 @node Default_Bit_Order
5557 @unnumberedsec Default_Bit_Order
5558 @cindex Big endian
5559 @cindex Little endian
5560 @findex Default_Bit_Order
5561 @noindent
5562 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5563 permissible prefix), provides the value @code{System.Default_Bit_Order}
5564 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5565 @code{Low_Order_First}).  This is used to construct the definition of
5566 @code{Default_Bit_Order} in package @code{System}.
5567
5568 @node Elaborated
5569 @unnumberedsec Elaborated
5570 @findex Elaborated
5571 @noindent
5572 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5573 value is a Boolean which indicates whether or not the given unit has been
5574 elaborated.  This attribute is primarily intended for internal use by the
5575 generated code for dynamic elaboration checking, but it can also be used
5576 in user programs.  The value will always be True once elaboration of all
5577 units has been completed.  An exception is for units which need no
5578 elaboration, the value is always False for such units.
5579
5580 @node Elab_Body
5581 @unnumberedsec Elab_Body
5582 @findex Elab_Body
5583 @noindent
5584 This attribute can only be applied to a program unit name.  It returns
5585 the entity for the corresponding elaboration procedure for elaborating
5586 the body of the referenced unit.  This is used in the main generated
5587 elaboration procedure by the binder and is not normally used in any
5588 other context.  However, there may be specialized situations in which it
5589 is useful to be able to call this elaboration procedure from Ada code,
5590 e.g.@: if it is necessary to do selective re-elaboration to fix some
5591 error.
5592
5593 @node Elab_Spec
5594 @unnumberedsec Elab_Spec
5595 @findex Elab_Spec
5596 @noindent
5597 This attribute can only be applied to a program unit name.  It returns
5598 the entity for the corresponding elaboration procedure for elaborating
5599 the spec of the referenced unit.  This is used in the main
5600 generated elaboration procedure by the binder and is not normally used
5601 in any other context.  However, there may be specialized situations in
5602 which it is useful to be able to call this elaboration procedure from
5603 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5604 some error.
5605
5606 @node Emax
5607 @unnumberedsec Emax
5608 @cindex Ada 83 attributes
5609 @findex Emax
5610 @noindent
5611 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5612 the Ada 83 reference manual for an exact description of the semantics of
5613 this attribute.
5614
5615 @node Enabled
5616 @unnumberedsec Enabled
5617 @findex Enabled
5618 @noindent
5619 The @code{Enabled} attribute allows an application program to check at compile
5620 time to see if the designated check is currently enabled. The prefix is a
5621 simple identifier, referencing any predefined check name (other than
5622 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5623 no argument is given for the attribute, the check is for the general state
5624 of the check, if an argument is given, then it is an entity name, and the
5625 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5626 given naming the entity (if not, then the argument is ignored).
5627
5628 Note that instantiations inherit the check status at the point of the
5629 instantiation, so a useful idiom is to have a library package that
5630 introduces a check name with @code{pragma Check_Name}, and then contains
5631 generic packages or subprograms which use the @code{Enabled} attribute
5632 to see if the check is enabled. A user of this package can then issue
5633 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5634 the package or subprogram, controlling whether the check will be present.
5635
5636 @node Enum_Rep
5637 @unnumberedsec Enum_Rep
5638 @cindex Representation of enums
5639 @findex Enum_Rep
5640 @noindent
5641 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5642 function with the following spec:
5643
5644 @smallexample @c ada
5645 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5646   return @i{Universal_Integer};
5647 @end smallexample
5648
5649 @noindent
5650 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5651 enumeration type or to a non-overloaded enumeration
5652 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5653 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5654 enumeration literal or object.
5655
5656 The function returns the representation value for the given enumeration
5657 value.  This will be equal to value of the @code{Pos} attribute in the
5658 absence of an enumeration representation clause.  This is a static
5659 attribute (i.e.@: the result is static if the argument is static).
5660
5661 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5662 in which case it simply returns the integer value.  The reason for this
5663 is to allow it to be used for @code{(<>)} discrete formal arguments in
5664 a generic unit that can be instantiated with either enumeration types
5665 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5666 type whose upper bound exceeds the upper bound of the largest signed
5667 integer type, and the argument is a variable, so that the universal
5668 integer calculation is done at run time, then the call to @code{Enum_Rep}
5669 may raise @code{Constraint_Error}.
5670
5671 @node Enum_Val
5672 @unnumberedsec Enum_Val
5673 @cindex Representation of enums
5674 @findex Enum_Val
5675 @noindent
5676 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5677 function with the following spec:
5678
5679 @smallexample @c ada
5680 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5681   return @var{S}'Base};
5682 @end smallexample
5683
5684 @noindent
5685 The function returns the enumeration value whose representation matches the
5686 argument, or raises Constraint_Error if no enumeration literal of the type
5687 has the matching value.
5688 This will be equal to value of the @code{Val} attribute in the
5689 absence of an enumeration representation clause.  This is a static
5690 attribute (i.e.@: the result is static if the argument is static).
5691
5692 @node Epsilon
5693 @unnumberedsec Epsilon
5694 @cindex Ada 83 attributes
5695 @findex Epsilon
5696 @noindent
5697 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5698 the Ada 83 reference manual for an exact description of the semantics of
5699 this attribute.
5700
5701 @node Fixed_Value
5702 @unnumberedsec Fixed_Value
5703 @findex Fixed_Value
5704 @noindent
5705 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5706 function with the following specification:
5707
5708 @smallexample @c ada
5709 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5710   return @var{S};
5711 @end smallexample
5712
5713 @noindent
5714 The value returned is the fixed-point value @var{V} such that
5715
5716 @smallexample @c ada
5717 @var{V} = Arg * @var{S}'Small
5718 @end smallexample
5719
5720 @noindent
5721 The effect is thus similar to first converting the argument to the
5722 integer type used to represent @var{S}, and then doing an unchecked
5723 conversion to the fixed-point type.  The difference is
5724 that there are full range checks, to ensure that the result is in range.
5725 This attribute is primarily intended for use in implementation of the
5726 input-output functions for fixed-point values.
5727
5728 @node Has_Access_Values
5729 @unnumberedsec Has_Access_Values
5730 @cindex Access values, testing for
5731 @findex Has_Access_Values
5732 @noindent
5733 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5734 is a Boolean value which is True if the is an access type, or is a composite
5735 type with a component (at any nesting depth) that is an access type, and is
5736 False otherwise.
5737 The intended use of this attribute is in conjunction with generic
5738 definitions.  If the attribute is applied to a generic private type, it
5739 indicates whether or not the corresponding actual type has access values.
5740
5741 @node Has_Discriminants
5742 @unnumberedsec Has_Discriminants
5743 @cindex Discriminants, testing for
5744 @findex Has_Discriminants
5745 @noindent
5746 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5747 is a Boolean value which is True if the type has discriminants, and False
5748 otherwise.  The intended use of this attribute is in conjunction with generic
5749 definitions.  If the attribute is applied to a generic private type, it
5750 indicates whether or not the corresponding actual type has discriminants.
5751
5752 @node Img
5753 @unnumberedsec Img
5754 @findex Img
5755 @noindent
5756 The @code{Img} attribute differs from @code{Image} in that it may be
5757 applied to objects as well as types, in which case it gives the
5758 @code{Image} for the subtype of the object.  This is convenient for
5759 debugging:
5760
5761 @smallexample @c ada
5762 Put_Line ("X = " & X'Img);
5763 @end smallexample
5764
5765 @noindent
5766 has the same meaning as the more verbose:
5767
5768 @smallexample @c ada
5769 Put_Line ("X = " & @var{T}'Image (X));
5770 @end smallexample
5771
5772 @noindent
5773 where @var{T} is the (sub)type of the object @code{X}.
5774
5775 @node Integer_Value
5776 @unnumberedsec Integer_Value
5777 @findex Integer_Value
5778 @noindent
5779 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5780 function with the following spec:
5781
5782 @smallexample @c ada
5783 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5784   return @var{S};
5785 @end smallexample
5786
5787 @noindent
5788 The value returned is the integer value @var{V}, such that
5789
5790 @smallexample @c ada
5791 Arg = @var{V} * @var{T}'Small
5792 @end smallexample
5793
5794 @noindent
5795 where @var{T} is the type of @code{Arg}.
5796 The effect is thus similar to first doing an unchecked conversion from
5797 the fixed-point type to its corresponding implementation type, and then
5798 converting the result to the target integer type.  The difference is
5799 that there are full range checks, to ensure that the result is in range.
5800 This attribute is primarily intended for use in implementation of the
5801 standard input-output functions for fixed-point values.
5802
5803 @node Invalid_Value
5804 @unnumberedsec Invalid_Value
5805 @findex Invalid_Value
5806 @noindent
5807 For every scalar type S, S'Invalid_Value returns an undefined value of the
5808 type. If possible this value is an invalid representation for the type. The
5809 value returned is identical to the value used to initialize an otherwise
5810 uninitialized value of the type if pragma Initialize_Scalars is used,
5811 including the ability to modify the value with the binder -Sxx flag and
5812 relevant environment variables at run time.
5813
5814 @node Large
5815 @unnumberedsec Large
5816 @cindex Ada 83 attributes
5817 @findex Large
5818 @noindent
5819 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5820 the Ada 83 reference manual for an exact description of the semantics of
5821 this attribute.
5822
5823 @node Machine_Size
5824 @unnumberedsec Machine_Size
5825 @findex Machine_Size
5826 @noindent
5827 This attribute is identical to the @code{Object_Size} attribute.  It is
5828 provided for compatibility with the DEC Ada 83 attribute of this name.
5829
5830 @node Mantissa
5831 @unnumberedsec Mantissa
5832 @cindex Ada 83 attributes
5833 @findex Mantissa
5834 @noindent
5835 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5836 the Ada 83 reference manual for an exact description of the semantics of
5837 this attribute.
5838
5839 @node Max_Interrupt_Priority
5840 @unnumberedsec Max_Interrupt_Priority
5841 @cindex Interrupt priority, maximum
5842 @findex Max_Interrupt_Priority
5843 @noindent
5844 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5845 permissible prefix), provides the same value as
5846 @code{System.Max_Interrupt_Priority}.
5847
5848 @node Max_Priority
5849 @unnumberedsec Max_Priority
5850 @cindex Priority, maximum
5851 @findex Max_Priority
5852 @noindent
5853 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5854 prefix) provides the same value as @code{System.Max_Priority}.
5855
5856 @node Maximum_Alignment
5857 @unnumberedsec Maximum_Alignment
5858 @cindex Alignment, maximum
5859 @findex Maximum_Alignment
5860 @noindent
5861 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5862 permissible prefix) provides the maximum useful alignment value for the
5863 target.  This is a static value that can be used to specify the alignment
5864 for an object, guaranteeing that it is properly aligned in all
5865 cases.
5866
5867 @node Mechanism_Code
5868 @unnumberedsec Mechanism_Code
5869 @cindex Return values, passing mechanism
5870 @cindex Parameters, passing mechanism
5871 @findex Mechanism_Code
5872 @noindent
5873 @code{@var{function}'Mechanism_Code} yields an integer code for the
5874 mechanism used for the result of function, and
5875 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5876 used for formal parameter number @var{n} (a static integer value with 1
5877 meaning the first parameter) of @var{subprogram}.  The code returned is:
5878
5879 @table @asis
5880 @item 1
5881 by copy (value)
5882 @item 2
5883 by reference
5884 @item 3
5885 by descriptor (default descriptor class)
5886 @item 4
5887 by descriptor (UBS: unaligned bit string)
5888 @item 5
5889 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5890 @item 6
5891 by descriptor (UBA: unaligned bit array)
5892 @item 7
5893 by descriptor (S: string, also scalar access type parameter)
5894 @item 8
5895 by descriptor (SB: string with arbitrary bounds)
5896 @item 9
5897 by descriptor (A: contiguous array)
5898 @item 10
5899 by descriptor (NCA: non-contiguous array)
5900 @end table
5901
5902 @noindent
5903 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5904 @cindex OpenVMS
5905
5906 @node Null_Parameter
5907 @unnumberedsec Null_Parameter
5908 @cindex Zero address, passing
5909 @findex Null_Parameter
5910 @noindent
5911 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5912 type or subtype @var{T} allocated at machine address zero.  The attribute
5913 is allowed only as the default expression of a formal parameter, or as
5914 an actual expression of a subprogram call.  In either case, the
5915 subprogram must be imported.
5916
5917 The identity of the object is represented by the address zero in the
5918 argument list, independent of the passing mechanism (explicit or
5919 default).
5920
5921 This capability is needed to specify that a zero address should be
5922 passed for a record or other composite object passed by reference.
5923 There is no way of indicating this without the @code{Null_Parameter}
5924 attribute.
5925
5926 @node Object_Size
5927 @unnumberedsec Object_Size
5928 @cindex Size, used for objects
5929 @findex Object_Size
5930 @noindent
5931 The size of an object is not necessarily the same as the size of the type
5932 of an object.  This is because by default object sizes are increased to be
5933 a multiple of the alignment of the object.  For example,
5934 @code{Natural'Size} is
5935 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5936 Similarly, a record containing an integer and a character:
5937
5938 @smallexample @c ada
5939 type Rec is record
5940    I : Integer;
5941    C : Character;
5942 end record;
5943 @end smallexample
5944
5945 @noindent
5946 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5947 alignment will be 4, because of the
5948 integer field, and so the default size of record objects for this type
5949 will be 64 (8 bytes).
5950
5951 @node Old
5952 @unnumberedsec Old
5953 @cindex Capturing Old values
5954 @cindex Postconditions
5955 @noindent
5956 The attribute Prefix'Old can be used within a
5957 subprogram to refer to the value of the prefix on entry. So for
5958 example if you have an argument of a record type X called Arg1,
5959 you can refer to Arg1.Field'Old which yields the value of
5960 Arg1.Field on entry. The implementation simply involves generating
5961 an object declaration which captures the value on entry. Any
5962 prefix is allowed except one of a limited type (since limited
5963 types cannot be copied to capture their values) or a local variable
5964 (since it does not exist at subprogram entry time).
5965
5966 The following example shows the use of 'Old to implement
5967 a test of a postcondition:
5968
5969 @smallexample @c ada
5970 with Old_Pkg;
5971 procedure Old is
5972 begin
5973    Old_Pkg.Incr;
5974 end Old;
5975
5976 package Old_Pkg is
5977    procedure Incr;
5978 end Old_Pkg;
5979
5980 package body Old_Pkg is
5981    Count : Natural := 0;
5982
5983    procedure Incr is
5984    begin
5985       ... code manipulating the value of Count
5986
5987       pragma Assert (Count = Count'Old + 1);
5988    end Incr;
5989 end Old_Pkg;
5990 @end smallexample
5991
5992 @noindent
5993 Note that it is allowed to apply 'Old to a constant entity, but this will
5994 result in a warning, since the old and new values will always be the same.
5995
5996 @node Passed_By_Reference
5997 @unnumberedsec Passed_By_Reference
5998 @cindex Parameters, when passed by reference
5999 @findex Passed_By_Reference
6000 @noindent
6001 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6002 a value of type @code{Boolean} value that is @code{True} if the type is
6003 normally passed by reference and @code{False} if the type is normally
6004 passed by copy in calls.  For scalar types, the result is always @code{False}
6005 and is static.  For non-scalar types, the result is non-static.
6006
6007 @node Pool_Address
6008 @unnumberedsec Pool_Address
6009 @cindex Parameters, when passed by reference
6010 @findex Pool_Address
6011 @noindent
6012 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6013 of X within its storage pool. This is the same as
6014 @code{@var{X}'Address}, except that for an unconstrained array whose
6015 bounds are allocated just before the first component,
6016 @code{@var{X}'Pool_Address} returns the address of those bounds,
6017 whereas @code{@var{X}'Address} returns the address of the first
6018 component.
6019
6020 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6021 the object is allocated'', which could be a user-defined storage pool,
6022 the global heap, on the stack, or in a static memory area. For an
6023 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6024 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6025
6026 @node Range_Length
6027 @unnumberedsec Range_Length
6028 @findex Range_Length
6029 @noindent
6030 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6031 the number of values represented by the subtype (zero for a null
6032 range).  The result is static for static subtypes.  @code{Range_Length}
6033 applied to the index subtype of a one dimensional array always gives the
6034 same result as @code{Range} applied to the array itself.
6035
6036 @node Safe_Emax
6037 @unnumberedsec Safe_Emax
6038 @cindex Ada 83 attributes
6039 @findex Safe_Emax
6040 @noindent
6041 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6042 the Ada 83 reference manual for an exact description of the semantics of
6043 this attribute.
6044
6045 @node Safe_Large
6046 @unnumberedsec Safe_Large
6047 @cindex Ada 83 attributes
6048 @findex Safe_Large
6049 @noindent
6050 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6051 the Ada 83 reference manual for an exact description of the semantics of
6052 this attribute.
6053
6054 @node Small
6055 @unnumberedsec Small
6056 @cindex Ada 83 attributes
6057 @findex Small
6058 @noindent
6059 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6060 fixed-point types.
6061 GNAT also allows this attribute to be applied to floating-point types
6062 for compatibility with Ada 83.  See
6063 the Ada 83 reference manual for an exact description of the semantics of
6064 this attribute when applied to floating-point types.
6065
6066 @node Storage_Unit
6067 @unnumberedsec Storage_Unit
6068 @findex Storage_Unit
6069 @noindent
6070 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6071 prefix) provides the same value as @code{System.Storage_Unit}.
6072
6073 @node Stub_Type
6074 @unnumberedsec Stub_Type
6075 @findex Stub_Type
6076 @noindent
6077 The GNAT implementation of remote access-to-classwide types is
6078 organized as described in AARM section E.4 (20.t): a value of an RACW type
6079 (designating a remote object) is represented as a normal access
6080 value, pointing to a "stub" object which in turn contains the
6081 necessary information to contact the designated remote object. A
6082 call on any dispatching operation of such a stub object does the
6083 remote call, if necessary, using the information in the stub object
6084 to locate the target partition, etc.
6085
6086 For a prefix @code{T} that denotes a remote access-to-classwide type,
6087 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6088
6089 By construction, the layout of @code{T'Stub_Type} is identical to that of
6090 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6091 unit @code{System.Partition_Interface}. Use of this attribute will create
6092 an implicit dependency on this unit.
6093
6094 @node Target_Name
6095 @unnumberedsec Target_Name
6096 @findex Target_Name
6097 @noindent
6098 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6099 prefix) provides a static string value that identifies the target
6100 for the current compilation. For GCC implementations, this is the
6101 standard gcc target name without the terminating slash (for
6102 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6103
6104 @node Tick
6105 @unnumberedsec Tick
6106 @findex Tick
6107 @noindent
6108 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6109 provides the same value as @code{System.Tick},
6110
6111 @node To_Address
6112 @unnumberedsec To_Address
6113 @findex To_Address
6114 @noindent
6115 The @code{System'To_Address}
6116 (@code{System} is the only permissible prefix)
6117 denotes a function identical to
6118 @code{System.Storage_Elements.To_Address} except that
6119 it is a static attribute.  This means that if its argument is
6120 a static expression, then the result of the attribute is a
6121 static expression.  The result is that such an expression can be
6122 used in contexts (e.g.@: preelaborable packages) which require a
6123 static expression and where the function call could not be used
6124 (since the function call is always non-static, even if its
6125 argument is static).
6126
6127 @node Type_Class
6128 @unnumberedsec Type_Class
6129 @findex Type_Class
6130 @noindent
6131 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6132 the value of the type class for the full type of @var{type}.  If
6133 @var{type} is a generic formal type, the value is the value for the
6134 corresponding actual subtype.  The value of this attribute is of type
6135 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6136
6137 @smallexample @c ada
6138   type Type_Class is
6139     (Type_Class_Enumeration,
6140      Type_Class_Integer,
6141      Type_Class_Fixed_Point,
6142      Type_Class_Floating_Point,
6143      Type_Class_Array,
6144      Type_Class_Record,
6145      Type_Class_Access,
6146      Type_Class_Task,
6147      Type_Class_Address);
6148 @end smallexample
6149
6150 @noindent
6151 Protected types yield the value @code{Type_Class_Task}, which thus
6152 applies to all concurrent types.  This attribute is designed to
6153 be compatible with the DEC Ada 83 attribute of the same name.
6154
6155 @node UET_Address
6156 @unnumberedsec UET_Address
6157 @findex UET_Address
6158 @noindent
6159 The @code{UET_Address} attribute can only be used for a prefix which
6160 denotes a library package.  It yields the address of the unit exception
6161 table when zero cost exception handling is used.  This attribute is
6162 intended only for use within the GNAT implementation.  See the unit
6163 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6164 for details on how this attribute is used in the implementation.
6165
6166 @node Unconstrained_Array
6167 @unnumberedsec Unconstrained_Array
6168 @findex Unconstrained_Array
6169 @noindent
6170 The @code{Unconstrained_Array} attribute can be used with a prefix that
6171 denotes any type or subtype. It is a static attribute that yields
6172 @code{True} if the prefix designates an unconstrained array,
6173 and @code{False} otherwise. In a generic instance, the result is
6174 still static, and yields the result of applying this test to the
6175 generic actual.
6176
6177 @node Universal_Literal_String
6178 @unnumberedsec Universal_Literal_String
6179 @cindex Named numbers, representation of
6180 @findex Universal_Literal_String
6181 @noindent
6182 The prefix of @code{Universal_Literal_String} must be a named
6183 number.  The static result is the string consisting of the characters of
6184 the number as defined in the original source.  This allows the user
6185 program to access the actual text of named numbers without intermediate
6186 conversions and without the need to enclose the strings in quotes (which
6187 would preclude their use as numbers).  This is used internally for the
6188 construction of values of the floating-point attributes from the file
6189 @file{ttypef.ads}, but may also be used by user programs.
6190
6191 For example, the following program prints the first 50 digits of pi:
6192
6193 @smallexample @c ada
6194 with Text_IO; use Text_IO;
6195 with Ada.Numerics;
6196 procedure Pi is
6197 begin
6198    Put (Ada.Numerics.Pi'Universal_Literal_String);
6199 end;
6200 @end smallexample
6201
6202 @node Unrestricted_Access
6203 @unnumberedsec Unrestricted_Access
6204 @cindex @code{Access}, unrestricted
6205 @findex Unrestricted_Access
6206 @noindent
6207 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6208 except that all accessibility and aliased view checks are omitted.  This
6209 is a user-beware attribute.  It is similar to
6210 @code{Address}, for which it is a desirable replacement where the value
6211 desired is an access type.  In other words, its effect is identical to
6212 first applying the @code{Address} attribute and then doing an unchecked
6213 conversion to a desired access type.  In GNAT, but not necessarily in
6214 other implementations, the use of static chains for inner level
6215 subprograms means that @code{Unrestricted_Access} applied to a
6216 subprogram yields a value that can be called as long as the subprogram
6217 is in scope (normal Ada accessibility rules restrict this usage).
6218
6219 It is possible to use @code{Unrestricted_Access} for any type, but care
6220 must be exercised if it is used to create pointers to unconstrained
6221 objects. In this case, the resulting pointer has the same scope as the
6222 context of the attribute, and may not be returned to some enclosing
6223 scope. For instance, a function cannot use @code{Unrestricted_Access}
6224 to create a unconstrained pointer and then return that value to the
6225 caller.
6226
6227 @node VADS_Size
6228 @unnumberedsec VADS_Size
6229 @cindex @code{Size}, VADS compatibility
6230 @findex VADS_Size
6231 @noindent
6232 The @code{'VADS_Size} attribute is intended to make it easier to port
6233 legacy code which relies on the semantics of @code{'Size} as implemented
6234 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6235 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6236 to a predefined or other primitive type with no Size clause yields the
6237 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6238 typical machines).  In addition @code{'VADS_Size} applied to an object
6239 gives the result that would be obtained by applying the attribute to
6240 the corresponding type.
6241
6242 @node Value_Size
6243 @unnumberedsec Value_Size
6244 @cindex @code{Size}, setting for not-first subtype
6245 @findex Value_Size
6246 @code{@var{type}'Value_Size} is the number of bits required to represent
6247 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6248 but, unlike @code{Size}, may be set for non-first subtypes.
6249
6250 @node Wchar_T_Size
6251 @unnumberedsec Wchar_T_Size
6252 @findex Wchar_T_Size
6253 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6254 prefix) provides the size in bits of the C @code{wchar_t} type
6255 primarily for constructing the definition of this type in
6256 package @code{Interfaces.C}.
6257
6258 @node Word_Size
6259 @unnumberedsec Word_Size
6260 @findex Word_Size
6261 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6262 prefix) provides the value @code{System.Word_Size}.
6263
6264 @c ------------------------
6265 @node Implementation Advice
6266 @chapter Implementation Advice
6267 @noindent
6268 The main text of the Ada Reference Manual describes the required
6269 behavior of all Ada compilers, and the GNAT compiler conforms to
6270 these requirements.
6271
6272 In addition, there are sections throughout the Ada Reference Manual headed
6273 by the phrase ``Implementation advice''.  These sections are not normative,
6274 i.e., they do not specify requirements that all compilers must
6275 follow.  Rather they provide advice on generally desirable behavior.  You
6276 may wonder why they are not requirements.  The most typical answer is
6277 that they describe behavior that seems generally desirable, but cannot
6278 be provided on all systems, or which may be undesirable on some systems.
6279
6280 As far as practical, GNAT follows the implementation advice sections in
6281 the Ada Reference Manual.  This chapter contains a table giving the
6282 reference manual section number, paragraph number and several keywords
6283 for each advice.  Each entry consists of the text of the advice followed
6284 by the GNAT interpretation of this advice.  Most often, this simply says
6285 ``followed'', which means that GNAT follows the advice.  However, in a
6286 number of cases, GNAT deliberately deviates from this advice, in which
6287 case the text describes what GNAT does and why.
6288
6289 @cindex Error detection
6290 @unnumberedsec 1.1.3(20): Error Detection
6291 @sp 1
6292 @cartouche
6293 If an implementation detects the use of an unsupported Specialized Needs
6294 Annex feature at run time, it should raise @code{Program_Error} if
6295 feasible.
6296 @end cartouche
6297 Not relevant.  All specialized needs annex features are either supported,
6298 or diagnosed at compile time.
6299
6300 @cindex Child Units
6301 @unnumberedsec 1.1.3(31): Child Units
6302 @sp 1
6303 @cartouche
6304 If an implementation wishes to provide implementation-defined
6305 extensions to the functionality of a language-defined library unit, it
6306 should normally do so by adding children to the library unit.
6307 @end cartouche
6308 Followed.
6309
6310 @cindex Bounded errors
6311 @unnumberedsec 1.1.5(12): Bounded Errors
6312 @sp 1
6313 @cartouche
6314 If an implementation detects a bounded error or erroneous
6315 execution, it should raise @code{Program_Error}.
6316 @end cartouche
6317 Followed in all cases in which the implementation detects a bounded
6318 error or erroneous execution.  Not all such situations are detected at
6319 runtime.
6320
6321 @cindex Pragmas
6322 @unnumberedsec 2.8(16): Pragmas
6323 @sp 1
6324 @cartouche
6325 Normally, implementation-defined pragmas should have no semantic effect
6326 for error-free programs; that is, if the implementation-defined pragmas
6327 are removed from a working program, the program should still be legal,
6328 and should still have the same semantics.
6329 @end cartouche
6330 The following implementation defined pragmas are exceptions to this
6331 rule:
6332
6333 @table @code
6334 @item Abort_Defer
6335 Affects semantics
6336 @item Ada_83
6337 Affects legality
6338 @item Assert
6339 Affects semantics
6340 @item CPP_Class
6341 Affects semantics
6342 @item CPP_Constructor
6343 Affects semantics
6344 @item Debug
6345 Affects semantics
6346 @item Interface_Name
6347 Affects semantics
6348 @item Machine_Attribute
6349 Affects semantics
6350 @item Unimplemented_Unit
6351 Affects legality
6352 @item Unchecked_Union
6353 Affects semantics
6354 @end table
6355
6356 @noindent
6357 In each of the above cases, it is essential to the purpose of the pragma
6358 that this advice not be followed.  For details see the separate section
6359 on implementation defined pragmas.
6360
6361 @unnumberedsec 2.8(17-19): Pragmas
6362 @sp 1
6363 @cartouche
6364 Normally, an implementation should not define pragmas that can
6365 make an illegal program legal, except as follows:
6366 @end cartouche
6367 @sp 1
6368 @cartouche
6369 A pragma used to complete a declaration, such as a pragma @code{Import};
6370 @end cartouche
6371 @sp 1
6372 @cartouche
6373 A pragma used to configure the environment by adding, removing, or
6374 replacing @code{library_items}.
6375 @end cartouche
6376 See response to paragraph 16 of this same section.
6377
6378 @cindex Character Sets
6379 @cindex Alternative Character Sets
6380 @unnumberedsec 3.5.2(5): Alternative Character Sets
6381 @sp 1
6382 @cartouche
6383 If an implementation supports a mode with alternative interpretations
6384 for @code{Character} and @code{Wide_Character}, the set of graphic
6385 characters of @code{Character} should nevertheless remain a proper
6386 subset of the set of graphic characters of @code{Wide_Character}.  Any
6387 character set ``localizations'' should be reflected in the results of
6388 the subprograms defined in the language-defined package
6389 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6390 an alternative interpretation of @code{Character}, the implementation should
6391 also support a corresponding change in what is a legal
6392 @code{identifier_letter}.
6393 @end cartouche
6394 Not all wide character modes follow this advice, in particular the JIS
6395 and IEC modes reflect standard usage in Japan, and in these encoding,
6396 the upper half of the Latin-1 set is not part of the wide-character
6397 subset, since the most significant bit is used for wide character
6398 encoding.  However, this only applies to the external forms.  Internally
6399 there is no such restriction.
6400
6401 @cindex Integer types
6402 @unnumberedsec 3.5.4(28): Integer Types
6403
6404 @sp 1
6405 @cartouche
6406 An implementation should support @code{Long_Integer} in addition to
6407 @code{Integer} if the target machine supports 32-bit (or longer)
6408 arithmetic.  No other named integer subtypes are recommended for package
6409 @code{Standard}.  Instead, appropriate named integer subtypes should be
6410 provided in the library package @code{Interfaces} (see B.2).
6411 @end cartouche
6412 @code{Long_Integer} is supported.  Other standard integer types are supported
6413 so this advice is not fully followed.  These types
6414 are supported for convenient interface to C, and so that all hardware
6415 types of the machine are easily available.
6416 @unnumberedsec 3.5.4(29): Integer Types
6417
6418 @sp 1
6419 @cartouche
6420 An implementation for a two's complement machine should support
6421 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6422 implementation should support a non-binary modules up to @code{Integer'Last}.
6423 @end cartouche
6424 Followed.
6425
6426 @cindex Enumeration values
6427 @unnumberedsec 3.5.5(8): Enumeration Values
6428 @sp 1
6429 @cartouche
6430 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6431 subtype, if the value of the operand does not correspond to the internal
6432 code for any enumeration literal of its type (perhaps due to an
6433 un-initialized variable), then the implementation should raise
6434 @code{Program_Error}.  This is particularly important for enumeration
6435 types with noncontiguous internal codes specified by an
6436 enumeration_representation_clause.
6437 @end cartouche
6438 Followed.
6439
6440 @cindex Float types
6441 @unnumberedsec 3.5.7(17): Float Types
6442 @sp 1
6443 @cartouche
6444 An implementation should support @code{Long_Float} in addition to
6445 @code{Float} if the target machine supports 11 or more digits of
6446 precision.  No other named floating point subtypes are recommended for
6447 package @code{Standard}.  Instead, appropriate named floating point subtypes
6448 should be provided in the library package @code{Interfaces} (see B.2).
6449 @end cartouche
6450 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6451 former provides improved compatibility with other implementations
6452 supporting this type.  The latter corresponds to the highest precision
6453 floating-point type supported by the hardware.  On most machines, this
6454 will be the same as @code{Long_Float}, but on some machines, it will
6455 correspond to the IEEE extended form.  The notable case is all ia32
6456 (x86) implementations, where @code{Long_Long_Float} corresponds to
6457 the 80-bit extended precision format supported in hardware on this
6458 processor.  Note that the 128-bit format on SPARC is not supported,
6459 since this is a software rather than a hardware format.
6460
6461 @cindex Multidimensional arrays
6462 @cindex Arrays, multidimensional
6463 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6464 @sp 1
6465 @cartouche
6466 An implementation should normally represent multidimensional arrays in
6467 row-major order, consistent with the notation used for multidimensional
6468 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6469 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6470 column-major order should be used instead (see B.5, ``Interfacing with
6471 Fortran'').
6472 @end cartouche
6473 Followed.
6474
6475 @findex Duration'Small
6476 @unnumberedsec 9.6(30-31): Duration'Small
6477 @sp 1
6478 @cartouche
6479 Whenever possible in an implementation, the value of @code{Duration'Small}
6480 should be no greater than 100 microseconds.
6481 @end cartouche
6482 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6483
6484 @sp 1
6485 @cartouche
6486 The time base for @code{delay_relative_statements} should be monotonic;
6487 it need not be the same time base as used for @code{Calendar.Clock}.
6488 @end cartouche
6489 Followed.
6490
6491 @unnumberedsec 10.2.1(12): Consistent Representation
6492 @sp 1
6493 @cartouche
6494 In an implementation, a type declared in a pre-elaborated package should
6495 have the same representation in every elaboration of a given version of
6496 the package, whether the elaborations occur in distinct executions of
6497 the same program, or in executions of distinct programs or partitions
6498 that include the given version.
6499 @end cartouche
6500 Followed, except in the case of tagged types.  Tagged types involve
6501 implicit pointers to a local copy of a dispatch table, and these pointers
6502 have representations which thus depend on a particular elaboration of the
6503 package.  It is not easy to see how it would be possible to follow this
6504 advice without severely impacting efficiency of execution.
6505
6506 @cindex Exception information
6507 @unnumberedsec 11.4.1(19): Exception Information
6508 @sp 1
6509 @cartouche
6510 @code{Exception_Message} by default and @code{Exception_Information}
6511 should produce information useful for
6512 debugging.  @code{Exception_Message} should be short, about one
6513 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6514 should not include the
6515 @code{Exception_Name}.  @code{Exception_Information} should include both
6516 the @code{Exception_Name} and the @code{Exception_Message}.
6517 @end cartouche
6518 Followed.  For each exception that doesn't have a specified
6519 @code{Exception_Message}, the compiler generates one containing the location
6520 of the raise statement.  This location has the form ``file:line'', where
6521 file is the short file name (without path information) and line is the line
6522 number in the file.  Note that in the case of the Zero Cost Exception
6523 mechanism, these messages become redundant with the Exception_Information that
6524 contains a full backtrace of the calling sequence, so they are disabled.
6525 To disable explicitly the generation of the source location message, use the
6526 Pragma @code{Discard_Names}.
6527
6528 @cindex Suppression of checks
6529 @cindex Checks, suppression of
6530 @unnumberedsec 11.5(28): Suppression of Checks
6531 @sp 1
6532 @cartouche
6533 The implementation should minimize the code executed for checks that
6534 have been suppressed.
6535 @end cartouche
6536 Followed.
6537
6538 @cindex Representation clauses
6539 @unnumberedsec 13.1 (21-24): Representation Clauses
6540 @sp 1
6541 @cartouche
6542 The recommended level of support for all representation items is
6543 qualified as follows:
6544 @end cartouche
6545 @sp 1
6546 @cartouche
6547 An implementation need not support representation items containing
6548 non-static expressions, except that an implementation should support a
6549 representation item for a given entity if each non-static expression in
6550 the representation item is a name that statically denotes a constant
6551 declared before the entity.
6552 @end cartouche
6553 Followed.  In fact, GNAT goes beyond the recommended level of support
6554 by allowing nonstatic expressions in some representation clauses even
6555 without the need to declare constants initialized with the values of
6556 such expressions.
6557 For example:
6558
6559 @smallexample @c ada
6560   X : Integer;
6561   Y : Float;
6562   for Y'Address use X'Address;>>
6563 @end smallexample
6564
6565
6566 @sp 1
6567 @cartouche
6568 An implementation need not support a specification for the @code{Size}
6569 for a given composite subtype, nor the size or storage place for an
6570 object (including a component) of a given composite subtype, unless the
6571 constraints on the subtype and its composite subcomponents (if any) are
6572 all static constraints.
6573 @end cartouche
6574 Followed.  Size Clauses are not permitted on non-static components, as
6575 described above.
6576
6577 @sp 1
6578 @cartouche
6579 An aliased component, or a component whose type is by-reference, should
6580 always be allocated at an addressable location.
6581 @end cartouche
6582 Followed.
6583
6584 @cindex Packed types
6585 @unnumberedsec 13.2(6-8): Packed Types
6586 @sp 1
6587 @cartouche
6588 If a type is packed, then the implementation should try to minimize
6589 storage allocated to objects of the type, possibly at the expense of
6590 speed of accessing components, subject to reasonable complexity in
6591 addressing calculations.
6592 @end cartouche
6593 @sp 1
6594 @cartouche
6595 The recommended level of support pragma @code{Pack} is:
6596
6597 For a packed record type, the components should be packed as tightly as
6598 possible subject to the Sizes of the component subtypes, and subject to
6599 any @code{record_representation_clause} that applies to the type; the
6600 implementation may, but need not, reorder components or cross aligned
6601 word boundaries to improve the packing.  A component whose @code{Size} is
6602 greater than the word size may be allocated an integral number of words.
6603 @end cartouche
6604 Followed.  Tight packing of arrays is supported for all component sizes
6605 up to 64-bits. If the array component size is 1 (that is to say, if
6606 the component is a boolean type or an enumeration type with two values)
6607 then values of the type are implicitly initialized to zero. This
6608 happens both for objects of the packed type, and for objects that have a
6609 subcomponent of the packed type.
6610
6611 @sp 1
6612 @cartouche
6613 An implementation should support Address clauses for imported
6614 subprograms.
6615 @end cartouche
6616 Followed.
6617 @cindex @code{Address} clauses
6618 @unnumberedsec 13.3(14-19): Address Clauses
6619
6620 @sp 1
6621 @cartouche
6622 For an array @var{X}, @code{@var{X}'Address} should point at the first
6623 component of the array, and not at the array bounds.
6624 @end cartouche
6625 Followed.
6626
6627 @sp 1
6628 @cartouche
6629 The recommended level of support for the @code{Address} attribute is:
6630
6631 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6632 object that is aliased or of a by-reference type, or is an entity whose
6633 @code{Address} has been specified.
6634 @end cartouche
6635 Followed.  A valid address will be produced even if none of those
6636 conditions have been met.  If necessary, the object is forced into
6637 memory to ensure the address is valid.
6638
6639 @sp 1
6640 @cartouche
6641 An implementation should support @code{Address} clauses for imported
6642 subprograms.
6643 @end cartouche
6644 Followed.
6645
6646 @sp 1
6647 @cartouche
6648 Objects (including subcomponents) that are aliased or of a by-reference
6649 type should be allocated on storage element boundaries.
6650 @end cartouche
6651 Followed.
6652
6653 @sp 1
6654 @cartouche
6655 If the @code{Address} of an object is specified, or it is imported or exported,
6656 then the implementation should not perform optimizations based on
6657 assumptions of no aliases.
6658 @end cartouche
6659 Followed.
6660
6661 @cindex @code{Alignment} clauses
6662 @unnumberedsec 13.3(29-35): Alignment Clauses
6663 @sp 1
6664 @cartouche
6665 The recommended level of support for the @code{Alignment} attribute for
6666 subtypes is:
6667
6668 An implementation should support specified Alignments that are factors
6669 and multiples of the number of storage elements per word, subject to the
6670 following:
6671 @end cartouche
6672 Followed.
6673
6674 @sp 1
6675 @cartouche
6676 An implementation need not support specified @code{Alignment}s for
6677 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6678 loaded and stored by available machine instructions.
6679 @end cartouche
6680 Followed.
6681
6682 @sp 1
6683 @cartouche
6684 An implementation need not support specified @code{Alignment}s that are
6685 greater than the maximum @code{Alignment} the implementation ever returns by
6686 default.
6687 @end cartouche
6688 Followed.
6689
6690 @sp 1
6691 @cartouche
6692 The recommended level of support for the @code{Alignment} attribute for
6693 objects is:
6694
6695 Same as above, for subtypes, but in addition:
6696 @end cartouche
6697 Followed.
6698
6699 @sp 1
6700 @cartouche
6701 For stand-alone library-level objects of statically constrained
6702 subtypes, the implementation should support all @code{Alignment}s
6703 supported by the target linker.  For example, page alignment is likely to
6704 be supported for such objects, but not for subtypes.
6705 @end cartouche
6706 Followed.
6707
6708 @cindex @code{Size} clauses
6709 @unnumberedsec 13.3(42-43): Size Clauses
6710 @sp 1
6711 @cartouche
6712 The recommended level of support for the @code{Size} attribute of
6713 objects is:
6714
6715 A @code{Size} clause should be supported for an object if the specified
6716 @code{Size} is at least as large as its subtype's @code{Size}, and
6717 corresponds to a size in storage elements that is a multiple of the
6718 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6719 @end cartouche
6720 Followed.
6721
6722 @unnumberedsec 13.3(50-56): Size Clauses
6723 @sp 1
6724 @cartouche
6725 If the @code{Size} of a subtype is specified, and allows for efficient
6726 independent addressability (see 9.10) on the target architecture, then
6727 the @code{Size} of the following objects of the subtype should equal the
6728 @code{Size} of the subtype:
6729
6730 Aliased objects (including components).
6731 @end cartouche
6732 Followed.
6733
6734 @sp 1
6735 @cartouche
6736 @code{Size} clause on a composite subtype should not affect the
6737 internal layout of components.
6738 @end cartouche
6739 Followed. But note that this can be overridden by use of the implementation
6740 pragma Implicit_Packing in the case of packed arrays.
6741
6742 @sp 1
6743 @cartouche
6744 The recommended level of support for the @code{Size} attribute of subtypes is:
6745 @end cartouche
6746 @sp 1
6747 @cartouche
6748 The @code{Size} (if not specified) of a static discrete or fixed point
6749 subtype should be the number of bits needed to represent each value
6750 belonging to the subtype using an unbiased representation, leaving space
6751 for a sign bit only if the subtype contains negative values.  If such a
6752 subtype is a first subtype, then an implementation should support a
6753 specified @code{Size} for it that reflects this representation.
6754 @end cartouche
6755 Followed.
6756
6757 @sp 1
6758 @cartouche
6759 For a subtype implemented with levels of indirection, the @code{Size}
6760 should include the size of the pointers, but not the size of what they
6761 point at.
6762 @end cartouche
6763 Followed.
6764
6765 @cindex @code{Component_Size} clauses
6766 @unnumberedsec 13.3(71-73): Component Size Clauses
6767 @sp 1
6768 @cartouche
6769 The recommended level of support for the @code{Component_Size}
6770 attribute is:
6771 @end cartouche
6772 @sp 1
6773 @cartouche
6774 An implementation need not support specified @code{Component_Sizes} that are
6775 less than the @code{Size} of the component subtype.
6776 @end cartouche
6777 Followed.
6778
6779 @sp 1
6780 @cartouche
6781 An implementation should support specified @code{Component_Size}s that
6782 are factors and multiples of the word size.  For such
6783 @code{Component_Size}s, the array should contain no gaps between
6784 components.  For other @code{Component_Size}s (if supported), the array
6785 should contain no gaps between components when packing is also
6786 specified; the implementation should forbid this combination in cases
6787 where it cannot support a no-gaps representation.
6788 @end cartouche
6789 Followed.
6790
6791 @cindex Enumeration representation clauses
6792 @cindex Representation clauses, enumeration
6793 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6794 @sp 1
6795 @cartouche
6796 The recommended level of support for enumeration representation clauses
6797 is:
6798
6799 An implementation need not support enumeration representation clauses
6800 for boolean types, but should at minimum support the internal codes in
6801 the range @code{System.Min_Int.System.Max_Int}.
6802 @end cartouche
6803 Followed.
6804
6805 @cindex Record representation clauses
6806 @cindex Representation clauses, records
6807 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6808 @sp 1
6809 @cartouche
6810 The recommended level of support for
6811 @*@code{record_representation_clauses} is:
6812
6813 An implementation should support storage places that can be extracted
6814 with a load, mask, shift sequence of machine code, and set with a load,
6815 shift, mask, store sequence, given the available machine instructions
6816 and run-time model.
6817 @end cartouche
6818 Followed.
6819
6820 @sp 1
6821 @cartouche
6822 A storage place should be supported if its size is equal to the
6823 @code{Size} of the component subtype, and it starts and ends on a
6824 boundary that obeys the @code{Alignment} of the component subtype.
6825 @end cartouche
6826 Followed.
6827
6828 @sp 1
6829 @cartouche
6830 If the default bit ordering applies to the declaration of a given type,
6831 then for a component whose subtype's @code{Size} is less than the word
6832 size, any storage place that does not cross an aligned word boundary
6833 should be supported.
6834 @end cartouche
6835 Followed.
6836
6837 @sp 1
6838 @cartouche
6839 An implementation may reserve a storage place for the tag field of a
6840 tagged type, and disallow other components from overlapping that place.
6841 @end cartouche
6842 Followed.  The storage place for the tag field is the beginning of the tagged
6843 record, and its size is Address'Size.  GNAT will reject an explicit component
6844 clause for the tag field.
6845
6846 @sp 1
6847 @cartouche
6848 An implementation need not support a @code{component_clause} for a
6849 component of an extension part if the storage place is not after the
6850 storage places of all components of the parent type, whether or not
6851 those storage places had been specified.
6852 @end cartouche
6853 Followed.  The above advice on record representation clauses is followed,
6854 and all mentioned features are implemented.
6855
6856 @cindex Storage place attributes
6857 @unnumberedsec 13.5.2(5): Storage Place Attributes
6858 @sp 1
6859 @cartouche
6860 If a component is represented using some form of pointer (such as an
6861 offset) to the actual data of the component, and this data is contiguous
6862 with the rest of the object, then the storage place attributes should
6863 reflect the place of the actual data, not the pointer.  If a component is
6864 allocated discontinuously from the rest of the object, then a warning
6865 should be generated upon reference to one of its storage place
6866 attributes.
6867 @end cartouche
6868 Followed.  There are no such components in GNAT@.
6869
6870 @cindex Bit ordering
6871 @unnumberedsec 13.5.3(7-8): Bit Ordering
6872 @sp 1
6873 @cartouche
6874 The recommended level of support for the non-default bit ordering is:
6875 @end cartouche
6876 @sp 1
6877 @cartouche
6878 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6879 should support the non-default bit ordering in addition to the default
6880 bit ordering.
6881 @end cartouche
6882 Followed.  Word size does not equal storage size in this implementation.
6883 Thus non-default bit ordering is not supported.
6884
6885 @cindex @code{Address}, as private type
6886 @unnumberedsec 13.7(37): Address as Private
6887 @sp 1
6888 @cartouche
6889 @code{Address} should be of a private type.
6890 @end cartouche
6891 Followed.
6892
6893 @cindex Operations, on @code{Address}
6894 @cindex @code{Address}, operations of
6895 @unnumberedsec 13.7.1(16): Address Operations
6896 @sp 1
6897 @cartouche
6898 Operations in @code{System} and its children should reflect the target
6899 environment semantics as closely as is reasonable.  For example, on most
6900 machines, it makes sense for address arithmetic to ``wrap around''.
6901 Operations that do not make sense should raise @code{Program_Error}.
6902 @end cartouche
6903 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6904 operation raises @code{Program_Error}, since all operations make sense.
6905
6906 @cindex Unchecked conversion
6907 @unnumberedsec 13.9(14-17): Unchecked Conversion
6908 @sp 1
6909 @cartouche
6910 The @code{Size} of an array object should not include its bounds; hence,
6911 the bounds should not be part of the converted data.
6912 @end cartouche
6913 Followed.
6914
6915 @sp 1
6916 @cartouche
6917 The implementation should not generate unnecessary run-time checks to
6918 ensure that the representation of @var{S} is a representation of the
6919 target type.  It should take advantage of the permission to return by
6920 reference when possible.  Restrictions on unchecked conversions should be
6921 avoided unless required by the target environment.
6922 @end cartouche
6923 Followed.  There are no restrictions on unchecked conversion.  A warning is
6924 generated if the source and target types do not have the same size since
6925 the semantics in this case may be target dependent.
6926
6927 @sp 1
6928 @cartouche
6929 The recommended level of support for unchecked conversions is:
6930 @end cartouche
6931 @sp 1
6932 @cartouche
6933 Unchecked conversions should be supported and should be reversible in
6934 the cases where this clause defines the result.  To enable meaningful use
6935 of unchecked conversion, a contiguous representation should be used for
6936 elementary subtypes, for statically constrained array subtypes whose
6937 component subtype is one of the subtypes described in this paragraph,
6938 and for record subtypes without discriminants whose component subtypes
6939 are described in this paragraph.
6940 @end cartouche
6941 Followed.
6942
6943 @cindex Heap usage, implicit
6944 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6945 @sp 1
6946 @cartouche
6947 An implementation should document any cases in which it dynamically
6948 allocates heap storage for a purpose other than the evaluation of an
6949 allocator.
6950 @end cartouche
6951 Followed, the only other points at which heap storage is dynamically
6952 allocated are as follows:
6953
6954 @itemize @bullet
6955 @item
6956 At initial elaboration time, to allocate dynamically sized global
6957 objects.
6958
6959 @item
6960 To allocate space for a task when a task is created.
6961
6962 @item
6963 To extend the secondary stack dynamically when needed.  The secondary
6964 stack is used for returning variable length results.
6965 @end itemize
6966
6967 @sp 1
6968 @cartouche
6969 A default (implementation-provided) storage pool for an
6970 access-to-constant type should not have overhead to support deallocation of
6971 individual objects.
6972 @end cartouche
6973 Followed.
6974
6975 @sp 1
6976 @cartouche
6977 A storage pool for an anonymous access type should be created at the
6978 point of an allocator for the type, and be reclaimed when the designated
6979 object becomes inaccessible.
6980 @end cartouche
6981 Followed.
6982
6983 @cindex Unchecked deallocation
6984 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6985 @sp 1
6986 @cartouche
6987 For a standard storage pool, @code{Free} should actually reclaim the
6988 storage.
6989 @end cartouche
6990 Followed.
6991
6992 @cindex Stream oriented attributes
6993 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6994 @sp 1
6995 @cartouche
6996 If a stream element is the same size as a storage element, then the
6997 normal in-memory representation should be used by @code{Read} and
6998 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6999 should use the smallest number of stream elements needed to represent
7000 all values in the base range of the scalar type.
7001 @end cartouche
7002
7003 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7004 which specifies using the size of the first subtype.
7005 However, such an implementation is based on direct binary
7006 representations and is therefore target- and endianness-dependent.
7007 To address this issue, GNAT also supplies an alternate implementation
7008 of the stream attributes @code{Read} and @code{Write},
7009 which uses the target-independent XDR standard representation
7010 for scalar types.
7011 @cindex XDR representation
7012 @cindex @code{Read} attribute
7013 @cindex @code{Write} attribute
7014 @cindex Stream oriented attributes
7015 The XDR implementation is provided as an alternative body of the
7016 @code{System.Stream_Attributes} package, in the file
7017 @file{s-strxdr.adb} in the GNAT library.
7018 There is no @file{s-strxdr.ads} file.
7019 In order to install the XDR implementation, do the following:
7020 @enumerate
7021 @item Replace the default implementation of the
7022 @code{System.Stream_Attributes} package with the XDR implementation.
7023 For example on a Unix platform issue the commands:
7024 @smallexample
7025 $ mv s-stratt.adb s-strold.adb
7026 $ mv s-strxdr.adb s-stratt.adb
7027 @end smallexample
7028
7029 @item
7030 Rebuild the GNAT run-time library as documented in
7031 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7032 @end enumerate
7033
7034 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7035 @sp 1
7036 @cartouche
7037 If an implementation provides additional named predefined integer types,
7038 then the names should end with @samp{Integer} as in
7039 @samp{Long_Integer}.  If an implementation provides additional named
7040 predefined floating point types, then the names should end with
7041 @samp{Float} as in @samp{Long_Float}.
7042 @end cartouche
7043 Followed.
7044
7045 @findex Ada.Characters.Handling
7046 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7047 @sp 1
7048 @cartouche
7049 If an implementation provides a localized definition of @code{Character}
7050 or @code{Wide_Character}, then the effects of the subprograms in
7051 @code{Characters.Handling} should reflect the localizations.  See also
7052 3.5.2.
7053 @end cartouche
7054 Followed.  GNAT provides no such localized definitions.
7055
7056 @cindex Bounded-length strings
7057 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7058 @sp 1
7059 @cartouche
7060 Bounded string objects should not be implemented by implicit pointers
7061 and dynamic allocation.
7062 @end cartouche
7063 Followed.  No implicit pointers or dynamic allocation are used.
7064
7065 @cindex Random number generation
7066 @unnumberedsec A.5.2(46-47): Random Number Generation
7067 @sp 1
7068 @cartouche
7069 Any storage associated with an object of type @code{Generator} should be
7070 reclaimed on exit from the scope of the object.
7071 @end cartouche
7072 Followed.
7073
7074 @sp 1
7075 @cartouche
7076 If the generator period is sufficiently long in relation to the number
7077 of distinct initiator values, then each possible value of
7078 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7079 random numbers that does not, in a practical sense, overlap the sequence
7080 initiated by any other value.  If this is not possible, then the mapping
7081 between initiator values and generator states should be a rapidly
7082 varying function of the initiator value.
7083 @end cartouche
7084 Followed.  The generator period is sufficiently long for the first
7085 condition here to hold true.
7086
7087 @findex Get_Immediate
7088 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7089 @sp 1
7090 @cartouche
7091 The @code{Get_Immediate} procedures should be implemented with
7092 unbuffered input.  For a device such as a keyboard, input should be
7093 @dfn{available} if a key has already been typed, whereas for a disk
7094 file, input should always be available except at end of file.  For a file
7095 associated with a keyboard-like device, any line-editing features of the
7096 underlying operating system should be disabled during the execution of
7097 @code{Get_Immediate}.
7098 @end cartouche
7099 Followed on all targets except VxWorks. For VxWorks, there is no way to
7100 provide this functionality that does not result in the input buffer being
7101 flushed before the @code{Get_Immediate} call. A special unit
7102 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7103 this functionality.
7104
7105 @findex Export
7106 @unnumberedsec B.1(39-41): Pragma @code{Export}
7107 @sp 1
7108 @cartouche
7109 If an implementation supports pragma @code{Export} to a given language,
7110 then it should also allow the main subprogram to be written in that
7111 language.  It should support some mechanism for invoking the elaboration
7112 of the Ada library units included in the system, and for invoking the
7113 finalization of the environment task.  On typical systems, the
7114 recommended mechanism is to provide two subprograms whose link names are
7115 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7116 elaboration code for library units.  @code{adafinal} should contain the
7117 finalization code.  These subprograms should have no effect the second
7118 and subsequent time they are called.
7119 @end cartouche
7120 Followed.
7121
7122 @sp 1
7123 @cartouche
7124 Automatic elaboration of pre-elaborated packages should be
7125 provided when pragma @code{Export} is supported.
7126 @end cartouche
7127 Followed when the main program is in Ada.  If the main program is in a
7128 foreign language, then
7129 @code{adainit} must be called to elaborate pre-elaborated
7130 packages.
7131
7132 @sp 1
7133 @cartouche
7134 For each supported convention @var{L} other than @code{Intrinsic}, an
7135 implementation should support @code{Import} and @code{Export} pragmas
7136 for objects of @var{L}-compatible types and for subprograms, and pragma
7137 @code{Convention} for @var{L}-eligible types and for subprograms,
7138 presuming the other language has corresponding features.  Pragma
7139 @code{Convention} need not be supported for scalar types.
7140 @end cartouche
7141 Followed.
7142
7143 @cindex Package @code{Interfaces}
7144 @findex Interfaces
7145 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7146 @sp 1
7147 @cartouche
7148 For each implementation-defined convention identifier, there should be a
7149 child package of package Interfaces with the corresponding name.  This
7150 package should contain any declarations that would be useful for
7151 interfacing to the language (implementation) represented by the
7152 convention.  Any declarations useful for interfacing to any language on
7153 the given hardware architecture should be provided directly in
7154 @code{Interfaces}.
7155 @end cartouche
7156 Followed. An additional package not defined
7157 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7158 for interfacing to C++.
7159
7160 @sp 1
7161 @cartouche
7162 An implementation supporting an interface to C, COBOL, or Fortran should
7163 provide the corresponding package or packages described in the following
7164 clauses.
7165 @end cartouche
7166 Followed.  GNAT provides all the packages described in this section.
7167
7168 @cindex C, interfacing with
7169 @unnumberedsec B.3(63-71): Interfacing with C
7170 @sp 1
7171 @cartouche
7172 An implementation should support the following interface correspondences
7173 between Ada and C@.
7174 @end cartouche
7175 Followed.
7176
7177 @sp 1
7178 @cartouche
7179 An Ada procedure corresponds to a void-returning C function.
7180 @end cartouche
7181 Followed.
7182
7183 @sp 1
7184 @cartouche
7185 An Ada function corresponds to a non-void C function.
7186 @end cartouche
7187 Followed.
7188
7189 @sp 1
7190 @cartouche
7191 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7192 function.
7193 @end cartouche
7194 Followed.
7195
7196 @sp 1
7197 @cartouche
7198 An Ada @code{in} parameter of an access-to-object type with designated
7199 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7200 where @var{t} is the C type corresponding to the Ada type @var{T}.
7201 @end cartouche
7202 Followed.
7203
7204 @sp 1
7205 @cartouche
7206 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7207 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7208 argument to a C function, where @var{t} is the C type corresponding to
7209 the Ada type @var{T}.  In the case of an elementary @code{out} or
7210 @code{in out} parameter, a pointer to a temporary copy is used to
7211 preserve by-copy semantics.
7212 @end cartouche
7213 Followed.
7214
7215 @sp 1
7216 @cartouche
7217 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7218 @code{@var{t}*} argument to a C function, where @var{t} is the C
7219 structure corresponding to the Ada type @var{T}.
7220 @end cartouche
7221 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7222 pragma, or Convention, or by explicitly specifying the mechanism for a given
7223 call using an extended import or export pragma.
7224
7225 @sp 1
7226 @cartouche
7227 An Ada parameter of an array type with component type @var{T}, of any
7228 mode, is passed as a @code{@var{t}*} argument to a C function, where
7229 @var{t} is the C type corresponding to the Ada type @var{T}.
7230 @end cartouche
7231 Followed.
7232
7233 @sp 1
7234 @cartouche
7235 An Ada parameter of an access-to-subprogram type is passed as a pointer
7236 to a C function whose prototype corresponds to the designated
7237 subprogram's specification.
7238 @end cartouche
7239 Followed.
7240
7241 @cindex COBOL, interfacing with
7242 @unnumberedsec B.4(95-98): Interfacing with COBOL
7243 @sp 1
7244 @cartouche
7245 An Ada implementation should support the following interface
7246 correspondences between Ada and COBOL@.
7247 @end cartouche
7248 Followed.
7249
7250 @sp 1
7251 @cartouche
7252 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7253 the COBOL type corresponding to @var{T}.
7254 @end cartouche
7255 Followed.
7256
7257 @sp 1
7258 @cartouche
7259 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7260 the corresponding COBOL type.
7261 @end cartouche
7262 Followed.
7263
7264 @sp 1
7265 @cartouche
7266 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7267 COBOL type corresponding to the Ada parameter type; for scalars, a local
7268 copy is used if necessary to ensure by-copy semantics.
7269 @end cartouche
7270 Followed.
7271
7272 @cindex Fortran, interfacing with
7273 @unnumberedsec B.5(22-26): Interfacing with Fortran
7274 @sp 1
7275 @cartouche
7276 An Ada implementation should support the following interface
7277 correspondences between Ada and Fortran:
7278 @end cartouche
7279 Followed.
7280
7281 @sp 1
7282 @cartouche
7283 An Ada procedure corresponds to a Fortran subroutine.
7284 @end cartouche
7285 Followed.
7286
7287 @sp 1
7288 @cartouche
7289 An Ada function corresponds to a Fortran function.
7290 @end cartouche
7291 Followed.
7292
7293 @sp 1
7294 @cartouche
7295 An Ada parameter of an elementary, array, or record type @var{T} is
7296 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7297 the Fortran type corresponding to the Ada type @var{T}, and where the
7298 INTENT attribute of the corresponding dummy argument matches the Ada
7299 formal parameter mode; the Fortran implementation's parameter passing
7300 conventions are used.  For elementary types, a local copy is used if
7301 necessary to ensure by-copy semantics.
7302 @end cartouche
7303 Followed.
7304
7305 @sp 1
7306 @cartouche
7307 An Ada parameter of an access-to-subprogram type is passed as a
7308 reference to a Fortran procedure whose interface corresponds to the
7309 designated subprogram's specification.
7310 @end cartouche
7311 Followed.
7312
7313 @cindex Machine operations
7314 @unnumberedsec C.1(3-5): Access to Machine Operations
7315 @sp 1
7316 @cartouche
7317 The machine code or intrinsic support should allow access to all
7318 operations normally available to assembly language programmers for the
7319 target environment, including privileged instructions, if any.
7320 @end cartouche
7321 Followed.
7322
7323 @sp 1
7324 @cartouche
7325 The interfacing pragmas (see Annex B) should support interface to
7326 assembler; the default assembler should be associated with the
7327 convention identifier @code{Assembler}.
7328 @end cartouche
7329 Followed.
7330
7331 @sp 1
7332 @cartouche
7333 If an entity is exported to assembly language, then the implementation
7334 should allocate it at an addressable location, and should ensure that it
7335 is retained by the linking process, even if not otherwise referenced
7336 from the Ada code.  The implementation should assume that any call to a
7337 machine code or assembler subprogram is allowed to read or update every
7338 object that is specified as exported.
7339 @end cartouche
7340 Followed.
7341
7342 @unnumberedsec C.1(10-16): Access to Machine Operations
7343 @sp 1
7344 @cartouche
7345 The implementation should ensure that little or no overhead is
7346 associated with calling intrinsic and machine-code subprograms.
7347 @end cartouche
7348 Followed for both intrinsics and machine-code subprograms.
7349
7350 @sp 1
7351 @cartouche
7352 It is recommended that intrinsic subprograms be provided for convenient
7353 access to any machine operations that provide special capabilities or
7354 efficiency and that are not otherwise available through the language
7355 constructs.
7356 @end cartouche
7357 Followed.  A full set of machine operation intrinsic subprograms is provided.
7358
7359 @sp 1
7360 @cartouche
7361 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7362 swap, decrement and test, enqueue/dequeue.
7363 @end cartouche
7364 Followed on any target supporting such operations.
7365
7366 @sp 1
7367 @cartouche
7368 Standard numeric functions---e.g.@:, sin, log.
7369 @end cartouche
7370 Followed on any target supporting such operations.
7371
7372 @sp 1
7373 @cartouche
7374 String manipulation operations---e.g.@:, translate and test.
7375 @end cartouche
7376 Followed on any target supporting such operations.
7377
7378 @sp 1
7379 @cartouche
7380 Vector operations---e.g.@:, compare vector against thresholds.
7381 @end cartouche
7382 Followed on any target supporting such operations.
7383
7384 @sp 1
7385 @cartouche
7386 Direct operations on I/O ports.
7387 @end cartouche
7388 Followed on any target supporting such operations.
7389
7390 @cindex Interrupt support
7391 @unnumberedsec C.3(28): Interrupt Support
7392 @sp 1
7393 @cartouche
7394 If the @code{Ceiling_Locking} policy is not in effect, the
7395 implementation should provide means for the application to specify which
7396 interrupts are to be blocked during protected actions, if the underlying
7397 system allows for a finer-grain control of interrupt blocking.
7398 @end cartouche
7399 Followed.  The underlying system does not allow for finer-grain control
7400 of interrupt blocking.
7401
7402 @cindex Protected procedure handlers
7403 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7404 @sp 1
7405 @cartouche
7406 Whenever possible, the implementation should allow interrupt handlers to
7407 be called directly by the hardware.
7408 @end cartouche
7409 @c SGI info:
7410 @ignore
7411 This is never possible under IRIX, so this is followed by default.
7412 @end ignore
7413 Followed on any target where the underlying operating system permits
7414 such direct calls.
7415
7416 @sp 1
7417 @cartouche
7418 Whenever practical, violations of any
7419 implementation-defined restrictions should be detected before run time.
7420 @end cartouche
7421 Followed.  Compile time warnings are given when possible.
7422
7423 @cindex Package @code{Interrupts}
7424 @findex Interrupts
7425 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7426
7427 @sp 1
7428 @cartouche
7429 If implementation-defined forms of interrupt handler procedures are
7430 supported, such as protected procedures with parameters, then for each
7431 such form of a handler, a type analogous to @code{Parameterless_Handler}
7432 should be specified in a child package of @code{Interrupts}, with the
7433 same operations as in the predefined package Interrupts.
7434 @end cartouche
7435 Followed.
7436
7437 @cindex Pre-elaboration requirements
7438 @unnumberedsec C.4(14): Pre-elaboration Requirements
7439 @sp 1
7440 @cartouche
7441 It is recommended that pre-elaborated packages be implemented in such a
7442 way that there should be little or no code executed at run time for the
7443 elaboration of entities not already covered by the Implementation
7444 Requirements.
7445 @end cartouche
7446 Followed.  Executable code is generated in some cases, e.g.@: loops
7447 to initialize large arrays.
7448
7449 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7450
7451 @sp 1
7452 @cartouche
7453 If the pragma applies to an entity, then the implementation should
7454 reduce the amount of storage used for storing names associated with that
7455 entity.
7456 @end cartouche
7457 Followed.
7458
7459 @cindex Package @code{Task_Attributes}
7460 @findex Task_Attributes
7461 @unnumberedsec C.7.2(30): The Package Task_Attributes
7462 @sp 1
7463 @cartouche
7464 Some implementations are targeted to domains in which memory use at run
7465 time must be completely deterministic.  For such implementations, it is
7466 recommended that the storage for task attributes will be pre-allocated
7467 statically and not from the heap.  This can be accomplished by either
7468 placing restrictions on the number and the size of the task's
7469 attributes, or by using the pre-allocated storage for the first @var{N}
7470 attribute objects, and the heap for the others.  In the latter case,
7471 @var{N} should be documented.
7472 @end cartouche
7473 Not followed.  This implementation is not targeted to such a domain.
7474
7475 @cindex Locking Policies
7476 @unnumberedsec D.3(17): Locking Policies
7477
7478 @sp 1
7479 @cartouche
7480 The implementation should use names that end with @samp{_Locking} for
7481 locking policies defined by the implementation.
7482 @end cartouche
7483 Followed.  A single implementation-defined locking policy is defined,
7484 whose name (@code{Inheritance_Locking}) follows this suggestion.
7485
7486 @cindex Entry queuing policies
7487 @unnumberedsec D.4(16): Entry Queuing Policies
7488 @sp 1
7489 @cartouche
7490 Names that end with @samp{_Queuing} should be used
7491 for all implementation-defined queuing policies.
7492 @end cartouche
7493 Followed.  No such implementation-defined queuing policies exist.
7494
7495 @cindex Preemptive abort
7496 @unnumberedsec D.6(9-10): Preemptive Abort
7497 @sp 1
7498 @cartouche
7499 Even though the @code{abort_statement} is included in the list of
7500 potentially blocking operations (see 9.5.1), it is recommended that this
7501 statement be implemented in a way that never requires the task executing
7502 the @code{abort_statement} to block.
7503 @end cartouche
7504 Followed.
7505
7506 @sp 1
7507 @cartouche
7508 On a multi-processor, the delay associated with aborting a task on
7509 another processor should be bounded; the implementation should use
7510 periodic polling, if necessary, to achieve this.
7511 @end cartouche
7512 Followed.
7513
7514 @cindex Tasking restrictions
7515 @unnumberedsec D.7(21): Tasking Restrictions
7516 @sp 1
7517 @cartouche
7518 When feasible, the implementation should take advantage of the specified
7519 restrictions to produce a more efficient implementation.
7520 @end cartouche
7521 GNAT currently takes advantage of these restrictions by providing an optimized
7522 run time when the Ravenscar profile and the GNAT restricted run time set
7523 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7524 pragma @code{Profile (Restricted)} for more details.
7525
7526 @cindex Time, monotonic
7527 @unnumberedsec D.8(47-49): Monotonic Time
7528 @sp 1
7529 @cartouche
7530 When appropriate, implementations should provide configuration
7531 mechanisms to change the value of @code{Tick}.
7532 @end cartouche
7533 Such configuration mechanisms are not appropriate to this implementation
7534 and are thus not supported.
7535
7536 @sp 1
7537 @cartouche
7538 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7539 be implemented as transformations of the same time base.
7540 @end cartouche
7541 Followed.
7542
7543 @sp 1
7544 @cartouche
7545 It is recommended that the @dfn{best} time base which exists in
7546 the underlying system be available to the application through
7547 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7548 @end cartouche
7549 Followed.
7550
7551 @cindex Partition communication subsystem
7552 @cindex PCS
7553 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7554 @sp 1
7555 @cartouche
7556 Whenever possible, the PCS on the called partition should allow for
7557 multiple tasks to call the RPC-receiver with different messages and
7558 should allow them to block until the corresponding subprogram body
7559 returns.
7560 @end cartouche
7561 Followed by GLADE, a separately supplied PCS that can be used with
7562 GNAT.
7563
7564 @sp 1
7565 @cartouche
7566 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7567 should raise @code{Storage_Error} if it runs out of space trying to
7568 write the @code{Item} into the stream.
7569 @end cartouche
7570 Followed by GLADE, a separately supplied PCS that can be used with
7571 GNAT@.
7572
7573 @cindex COBOL support
7574 @unnumberedsec F(7): COBOL Support
7575 @sp 1
7576 @cartouche
7577 If COBOL (respectively, C) is widely supported in the target
7578 environment, implementations supporting the Information Systems Annex
7579 should provide the child package @code{Interfaces.COBOL} (respectively,
7580 @code{Interfaces.C}) specified in Annex B and should support a
7581 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7582 pragmas (see Annex B), thus allowing Ada programs to interface with
7583 programs written in that language.
7584 @end cartouche
7585 Followed.
7586
7587 @cindex Decimal radix support
7588 @unnumberedsec F.1(2): Decimal Radix Support
7589 @sp 1
7590 @cartouche
7591 Packed decimal should be used as the internal representation for objects
7592 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7593 @end cartouche
7594 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7595 representations.
7596
7597 @cindex Numerics
7598 @unnumberedsec G: Numerics
7599 @sp 2
7600 @cartouche
7601 If Fortran (respectively, C) is widely supported in the target
7602 environment, implementations supporting the Numerics Annex
7603 should provide the child package @code{Interfaces.Fortran} (respectively,
7604 @code{Interfaces.C}) specified in Annex B and should support a
7605 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7606 pragmas (see Annex B), thus allowing Ada programs to interface with
7607 programs written in that language.
7608 @end cartouche
7609 Followed.
7610
7611 @cindex Complex types
7612 @unnumberedsec G.1.1(56-58): Complex Types
7613 @sp 2
7614 @cartouche
7615 Because the usual mathematical meaning of multiplication of a complex
7616 operand and a real operand is that of the scaling of both components of
7617 the former by the latter, an implementation should not perform this
7618 operation by first promoting the real operand to complex type and then
7619 performing a full complex multiplication.  In systems that, in the
7620 future, support an Ada binding to IEC 559:1989, the latter technique
7621 will not generate the required result when one of the components of the
7622 complex operand is infinite.  (Explicit multiplication of the infinite
7623 component by the zero component obtained during promotion yields a NaN
7624 that propagates into the final result.) Analogous advice applies in the
7625 case of multiplication of a complex operand and a pure-imaginary
7626 operand, and in the case of division of a complex operand by a real or
7627 pure-imaginary operand.
7628 @end cartouche
7629 Not followed.
7630
7631 @sp 1
7632 @cartouche
7633 Similarly, because the usual mathematical meaning of addition of a
7634 complex operand and a real operand is that the imaginary operand remains
7635 unchanged, an implementation should not perform this operation by first
7636 promoting the real operand to complex type and then performing a full
7637 complex addition.  In implementations in which the @code{Signed_Zeros}
7638 attribute of the component type is @code{True} (and which therefore
7639 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7640 predefined arithmetic operations), the latter technique will not
7641 generate the required result when the imaginary component of the complex
7642 operand is a negatively signed zero.  (Explicit addition of the negative
7643 zero to the zero obtained during promotion yields a positive zero.)
7644 Analogous advice applies in the case of addition of a complex operand
7645 and a pure-imaginary operand, and in the case of subtraction of a
7646 complex operand and a real or pure-imaginary operand.
7647 @end cartouche
7648 Not followed.
7649
7650 @sp 1
7651 @cartouche
7652 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7653 attempt to provide a rational treatment of the signs of zero results and
7654 result components.  As one example, the result of the @code{Argument}
7655 function should have the sign of the imaginary component of the
7656 parameter @code{X} when the point represented by that parameter lies on
7657 the positive real axis; as another, the sign of the imaginary component
7658 of the @code{Compose_From_Polar} function should be the same as
7659 (respectively, the opposite of) that of the @code{Argument} parameter when that
7660 parameter has a value of zero and the @code{Modulus} parameter has a
7661 nonnegative (respectively, negative) value.
7662 @end cartouche
7663 Followed.
7664
7665 @cindex Complex elementary functions
7666 @unnumberedsec G.1.2(49): Complex Elementary Functions
7667 @sp 1
7668 @cartouche
7669 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7670 @code{True} should attempt to provide a rational treatment of the signs
7671 of zero results and result components.  For example, many of the complex
7672 elementary functions have components that are odd functions of one of
7673 the parameter components; in these cases, the result component should
7674 have the sign of the parameter component at the origin.  Other complex
7675 elementary functions have zero components whose sign is opposite that of
7676 a parameter component at the origin, or is always positive or always
7677 negative.
7678 @end cartouche
7679 Followed.
7680
7681 @cindex Accuracy requirements
7682 @unnumberedsec G.2.4(19): Accuracy Requirements
7683 @sp 1
7684 @cartouche
7685 The versions of the forward trigonometric functions without a
7686 @code{Cycle} parameter should not be implemented by calling the
7687 corresponding version with a @code{Cycle} parameter of
7688 @code{2.0*Numerics.Pi}, since this will not provide the required
7689 accuracy in some portions of the domain.  For the same reason, the
7690 version of @code{Log} without a @code{Base} parameter should not be
7691 implemented by calling the corresponding version with a @code{Base}
7692 parameter of @code{Numerics.e}.
7693 @end cartouche
7694 Followed.
7695
7696 @cindex Complex arithmetic accuracy
7697 @cindex Accuracy, complex arithmetic
7698 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7699
7700 @sp 1
7701 @cartouche
7702 The version of the @code{Compose_From_Polar} function without a
7703 @code{Cycle} parameter should not be implemented by calling the
7704 corresponding version with a @code{Cycle} parameter of
7705 @code{2.0*Numerics.Pi}, since this will not provide the required
7706 accuracy in some portions of the domain.
7707 @end cartouche
7708 Followed.
7709
7710 @c -----------------------------------------
7711 @node Implementation Defined Characteristics
7712 @chapter Implementation Defined Characteristics
7713
7714 @noindent
7715 In addition to the implementation dependent pragmas and attributes, and
7716 the implementation advice, there are a number of other Ada features
7717 that are potentially implementation dependent.  These are mentioned
7718 throughout the Ada Reference Manual, and are summarized in annex M@.
7719
7720 A requirement for conforming Ada compilers is that they provide
7721 documentation describing how the implementation deals with each of these
7722 issues.  In this chapter, you will find each point in annex M listed
7723 followed by a description in italic font of how GNAT
7724 @c SGI info:
7725 @ignore
7726 in the ProDev Ada
7727 implementation on IRIX 5.3 operating system or greater
7728 @end ignore
7729 handles the implementation dependence.
7730
7731 You can use this chapter as a guide to minimizing implementation
7732 dependent features in your programs if portability to other compilers
7733 and other operating systems is an important consideration.  The numbers
7734 in each section below correspond to the paragraph number in the Ada
7735 Reference Manual.
7736
7737 @sp 1
7738 @cartouche
7739 @noindent
7740 @strong{2}.  Whether or not each recommendation given in Implementation
7741 Advice is followed.  See 1.1.2(37).
7742 @end cartouche
7743 @noindent
7744 @xref{Implementation Advice}.
7745
7746 @sp 1
7747 @cartouche
7748 @noindent
7749 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7750 @end cartouche
7751 @noindent
7752 The complexity of programs that can be processed is limited only by the
7753 total amount of available virtual memory, and disk space for the
7754 generated object files.
7755
7756 @sp 1
7757 @cartouche
7758 @noindent
7759 @strong{4}.  Variations from the standard that are impractical to avoid
7760 given the implementation's execution environment.  See 1.1.3(6).
7761 @end cartouche
7762 @noindent
7763 There are no variations from the standard.
7764
7765 @sp 1
7766 @cartouche
7767 @noindent
7768 @strong{5}.  Which @code{code_statement}s cause external
7769 interactions.  See 1.1.3(10).
7770 @end cartouche
7771 @noindent
7772 Any @code{code_statement} can potentially cause external interactions.
7773
7774 @sp 1
7775 @cartouche
7776 @noindent
7777 @strong{6}.  The coded representation for the text of an Ada
7778 program.  See 2.1(4).
7779 @end cartouche
7780 @noindent
7781 See separate section on source representation.
7782
7783 @sp 1
7784 @cartouche
7785 @noindent
7786 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7787 @end cartouche
7788 @noindent
7789 See separate section on source representation.
7790
7791 @sp 1
7792 @cartouche
7793 @noindent
7794 @strong{8}.  The representation for an end of line.  See 2.2(2).
7795 @end cartouche
7796 @noindent
7797 See separate section on source representation.
7798
7799 @sp 1
7800 @cartouche
7801 @noindent
7802 @strong{9}.  Maximum supported line length and lexical element
7803 length.  See 2.2(15).
7804 @end cartouche
7805 @noindent
7806 The maximum line length is 255 characters and the maximum length of a
7807 lexical element is also 255 characters.
7808
7809 @sp 1
7810 @cartouche
7811 @noindent
7812 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7813 @end cartouche
7814 @noindent
7815
7816 @xref{Implementation Defined Pragmas}.
7817
7818 @sp 1
7819 @cartouche
7820 @noindent
7821 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7822 @end cartouche
7823 @noindent
7824 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7825 parameter, checks that the optimization flag is set, and aborts if it is
7826 not.
7827
7828 @sp 1
7829 @cartouche
7830 @noindent
7831 @strong{12}.  The sequence of characters of the value returned by
7832 @code{@var{S}'Image} when some of the graphic characters of
7833 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7834 3.5(37).
7835 @end cartouche
7836 @noindent
7837 The sequence of characters is as defined by the wide character encoding
7838 method used for the source.  See section on source representation for
7839 further details.
7840
7841 @sp 1
7842 @cartouche
7843 @noindent
7844 @strong{13}.  The predefined integer types declared in
7845 @code{Standard}.  See 3.5.4(25).
7846 @end cartouche
7847 @noindent
7848 @table @code
7849 @item Short_Short_Integer
7850 8 bit signed
7851 @item Short_Integer
7852 (Short) 16 bit signed
7853 @item Integer
7854 32 bit signed
7855 @item Long_Integer
7856 64 bit signed (Alpha OpenVMS only)
7857 32 bit signed (all other targets)
7858 @item Long_Long_Integer
7859 64 bit signed
7860 @end table
7861
7862 @sp 1
7863 @cartouche
7864 @noindent
7865 @strong{14}.  Any nonstandard integer types and the operators defined
7866 for them.  See 3.5.4(26).
7867 @end cartouche
7868 @noindent
7869 There are no nonstandard integer types.
7870
7871 @sp 1
7872 @cartouche
7873 @noindent
7874 @strong{15}.  Any nonstandard real types and the operators defined for
7875 them.  See 3.5.6(8).
7876 @end cartouche
7877 @noindent
7878 There are no nonstandard real types.
7879
7880 @sp 1
7881 @cartouche
7882 @noindent
7883 @strong{16}.  What combinations of requested decimal precision and range
7884 are supported for floating point types.  See 3.5.7(7).
7885 @end cartouche
7886 @noindent
7887 The precision and range is as defined by the IEEE standard.
7888
7889 @sp 1
7890 @cartouche
7891 @noindent
7892 @strong{17}.  The predefined floating point types declared in
7893 @code{Standard}.  See 3.5.7(16).
7894 @end cartouche
7895 @noindent
7896 @table @code
7897 @item Short_Float
7898 32 bit IEEE short
7899 @item Float
7900 (Short) 32 bit IEEE short
7901 @item Long_Float
7902 64 bit IEEE long
7903 @item Long_Long_Float
7904 64 bit IEEE long (80 bit IEEE long on x86 processors)
7905 @end table
7906
7907 @sp 1
7908 @cartouche
7909 @noindent
7910 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7911 @end cartouche
7912 @noindent
7913 @code{Fine_Delta} is 2**(@minus{}63)
7914
7915 @sp 1
7916 @cartouche
7917 @noindent
7918 @strong{19}.  What combinations of small, range, and digits are
7919 supported for fixed point types.  See 3.5.9(10).
7920 @end cartouche
7921 @noindent
7922 Any combinations are permitted that do not result in a small less than
7923 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7924 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7925 is 64 bits (true of all architectures except ia32), then the output from
7926 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7927 is because floating-point conversions are used to convert fixed point.
7928
7929 @sp 1
7930 @cartouche
7931 @noindent
7932 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7933 within an unnamed @code{block_statement}.  See 3.9(10).
7934 @end cartouche
7935 @noindent
7936 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7937 decimal integer are allocated.
7938
7939 @sp 1
7940 @cartouche
7941 @noindent
7942 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7943 @end cartouche
7944 @noindent
7945 @xref{Implementation Defined Attributes}.
7946
7947 @sp 1
7948 @cartouche
7949 @noindent
7950 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7951 @end cartouche
7952 @noindent
7953 There are no implementation-defined time types.
7954
7955 @sp 1
7956 @cartouche
7957 @noindent
7958 @strong{23}.  The time base associated with relative delays.
7959 @end cartouche
7960 @noindent
7961 See 9.6(20).  The time base used is that provided by the C library
7962 function @code{gettimeofday}.
7963
7964 @sp 1
7965 @cartouche
7966 @noindent
7967 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7968 9.6(23).
7969 @end cartouche
7970 @noindent
7971 The time base used is that provided by the C library function
7972 @code{gettimeofday}.
7973
7974 @sp 1
7975 @cartouche
7976 @noindent
7977 @strong{25}.  The time zone used for package @code{Calendar}
7978 operations.  See 9.6(24).
7979 @end cartouche
7980 @noindent
7981 The time zone used by package @code{Calendar} is the current system time zone
7982 setting for local time, as accessed by the C library function
7983 @code{localtime}.
7984
7985 @sp 1
7986 @cartouche
7987 @noindent
7988 @strong{26}.  Any limit on @code{delay_until_statements} of
7989 @code{select_statements}.  See 9.6(29).
7990 @end cartouche
7991 @noindent
7992 There are no such limits.
7993
7994 @sp 1
7995 @cartouche
7996 @noindent
7997 @strong{27}.  Whether or not two non-overlapping parts of a composite
7998 object are independently addressable, in the case where packing, record
7999 layout, or @code{Component_Size} is specified for the object.  See
8000 9.10(1).
8001 @end cartouche
8002 @noindent
8003 Separate components are independently addressable if they do not share
8004 overlapping storage units.
8005
8006 @sp 1
8007 @cartouche
8008 @noindent
8009 @strong{28}.  The representation for a compilation.  See 10.1(2).
8010 @end cartouche
8011 @noindent
8012 A compilation is represented by a sequence of files presented to the
8013 compiler in a single invocation of the @command{gcc} command.
8014
8015 @sp 1
8016 @cartouche
8017 @noindent
8018 @strong{29}.  Any restrictions on compilations that contain multiple
8019 compilation_units.  See 10.1(4).
8020 @end cartouche
8021 @noindent
8022 No single file can contain more than one compilation unit, but any
8023 sequence of files can be presented to the compiler as a single
8024 compilation.
8025
8026 @sp 1
8027 @cartouche
8028 @noindent
8029 @strong{30}.  The mechanisms for creating an environment and for adding
8030 and replacing compilation units.  See 10.1.4(3).
8031 @end cartouche
8032 @noindent
8033 See separate section on compilation model.
8034
8035 @sp 1
8036 @cartouche
8037 @noindent
8038 @strong{31}.  The manner of explicitly assigning library units to a
8039 partition.  See 10.2(2).
8040 @end cartouche
8041 @noindent
8042 If a unit contains an Ada main program, then the Ada units for the partition
8043 are determined by recursive application of the rules in the Ada Reference
8044 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8045 are needed by the main program, and then this definition of need is applied
8046 recursively to those units, and the partition contains the transitive
8047 closure determined by this relationship.  In short, all the necessary units
8048 are included, with no need to explicitly specify the list.  If additional
8049 units are required, e.g.@: by foreign language units, then all units must be
8050 mentioned in the context clause of one of the needed Ada units.
8051
8052 If the partition contains no main program, or if the main program is in
8053 a language other than Ada, then GNAT
8054 provides the binder options @option{-z} and @option{-n} respectively, and in
8055 this case a list of units can be explicitly supplied to the binder for
8056 inclusion in the partition (all units needed by these units will also
8057 be included automatically).  For full details on the use of these
8058 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8059 @value{EDITION} User's Guide}.
8060
8061 @sp 1
8062 @cartouche
8063 @noindent
8064 @strong{32}.  The implementation-defined means, if any, of specifying
8065 which compilation units are needed by a given compilation unit.  See
8066 10.2(2).
8067 @end cartouche
8068 @noindent
8069 The units needed by a given compilation unit are as defined in
8070 the Ada Reference Manual section 10.2(2-6).  There are no
8071 implementation-defined pragmas or other implementation-defined
8072 means for specifying needed units.
8073
8074 @sp 1
8075 @cartouche
8076 @noindent
8077 @strong{33}.  The manner of designating the main subprogram of a
8078 partition.  See 10.2(7).
8079 @end cartouche
8080 @noindent
8081 The main program is designated by providing the name of the
8082 corresponding @file{ALI} file as the input parameter to the binder.
8083
8084 @sp 1
8085 @cartouche
8086 @noindent
8087 @strong{34}.  The order of elaboration of @code{library_items}.  See
8088 10.2(18).
8089 @end cartouche
8090 @noindent
8091 The first constraint on ordering is that it meets the requirements of
8092 Chapter 10 of the Ada Reference Manual.  This still leaves some
8093 implementation dependent choices, which are resolved by first
8094 elaborating bodies as early as possible (i.e., in preference to specs
8095 where there is a choice), and second by evaluating the immediate with
8096 clauses of a unit to determine the probably best choice, and
8097 third by elaborating in alphabetical order of unit names
8098 where a choice still remains.
8099
8100 @sp 1
8101 @cartouche
8102 @noindent
8103 @strong{35}.  Parameter passing and function return for the main
8104 subprogram.  See 10.2(21).
8105 @end cartouche
8106 @noindent
8107 The main program has no parameters.  It may be a procedure, or a function
8108 returning an integer type.  In the latter case, the returned integer
8109 value is the return code of the program (overriding any value that
8110 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8111
8112 @sp 1
8113 @cartouche
8114 @noindent
8115 @strong{36}.  The mechanisms for building and running partitions.  See
8116 10.2(24).
8117 @end cartouche
8118 @noindent
8119 GNAT itself supports programs with only a single partition.  The GNATDIST
8120 tool provided with the GLADE package (which also includes an implementation
8121 of the PCS) provides a completely flexible method for building and running
8122 programs consisting of multiple partitions.  See the separate GLADE manual
8123 for details.
8124
8125 @sp 1
8126 @cartouche
8127 @noindent
8128 @strong{37}.  The details of program execution, including program
8129 termination.  See 10.2(25).
8130 @end cartouche
8131 @noindent
8132 See separate section on compilation model.
8133
8134 @sp 1
8135 @cartouche
8136 @noindent
8137 @strong{38}.  The semantics of any non-active partitions supported by the
8138 implementation.  See 10.2(28).
8139 @end cartouche
8140 @noindent
8141 Passive partitions are supported on targets where shared memory is
8142 provided by the operating system.  See the GLADE reference manual for
8143 further details.
8144
8145 @sp 1
8146 @cartouche
8147 @noindent
8148 @strong{39}.  The information returned by @code{Exception_Message}.  See
8149 11.4.1(10).
8150 @end cartouche
8151 @noindent
8152 Exception message returns the null string unless a specific message has
8153 been passed by the program.
8154
8155 @sp 1
8156 @cartouche
8157 @noindent
8158 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8159 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8160 @end cartouche
8161 @noindent
8162 Blocks have implementation defined names of the form @code{B@var{nnn}}
8163 where @var{nnn} is an integer.
8164
8165 @sp 1
8166 @cartouche
8167 @noindent
8168 @strong{41}.  The information returned by
8169 @code{Exception_Information}.  See 11.4.1(13).
8170 @end cartouche
8171 @noindent
8172 @code{Exception_Information} returns a string in the following format:
8173
8174 @smallexample
8175 @emph{Exception_Name:} nnnnn
8176 @emph{Message:} mmmmm
8177 @emph{PID:} ppp
8178 @emph{Call stack traceback locations:}
8179 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8180 @end smallexample
8181
8182 @noindent
8183 where
8184
8185 @itemize @bullet
8186 @item
8187 @code{nnnn} is the fully qualified name of the exception in all upper
8188 case letters. This line is always present.
8189
8190 @item
8191 @code{mmmm} is the message (this line present only if message is non-null)
8192
8193 @item
8194 @code{ppp} is the Process Id value as a decimal integer (this line is
8195 present only if the Process Id is nonzero). Currently we are
8196 not making use of this field.
8197
8198 @item
8199 The Call stack traceback locations line and the following values
8200 are present only if at least one traceback location was recorded.
8201 The values are given in C style format, with lower case letters
8202 for a-f, and only as many digits present as are necessary.
8203 @end itemize
8204
8205 @noindent
8206 The line terminator sequence at the end of each line, including
8207 the last line is a single @code{LF} character (@code{16#0A#}).
8208
8209 @sp 1
8210 @cartouche
8211 @noindent
8212 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8213 @end cartouche
8214 @noindent
8215 The implementation defined check name Alignment_Check controls checking of
8216 address clause values for proper alignment (that is, the address supplied
8217 must be consistent with the alignment of the type).
8218
8219 In addition, a user program can add implementation-defined check names
8220 by means of the pragma Check_Name.
8221
8222 @sp 1
8223 @cartouche
8224 @noindent
8225 @strong{43}.  The interpretation of each aspect of representation.  See
8226 13.1(20).
8227 @end cartouche
8228 @noindent
8229 See separate section on data representations.
8230
8231 @sp 1
8232 @cartouche
8233 @noindent
8234 @strong{44}.  Any restrictions placed upon representation items.  See
8235 13.1(20).
8236 @end cartouche
8237 @noindent
8238 See separate section on data representations.
8239
8240 @sp 1
8241 @cartouche
8242 @noindent
8243 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8244 13.3(48).
8245 @end cartouche
8246 @noindent
8247 Size for an indefinite subtype is the maximum possible size, except that
8248 for the case of a subprogram parameter, the size of the parameter object
8249 is the actual size.
8250
8251 @sp 1
8252 @cartouche
8253 @noindent
8254 @strong{46}.  The default external representation for a type tag.  See
8255 13.3(75).
8256 @end cartouche
8257 @noindent
8258 The default external representation for a type tag is the fully expanded
8259 name of the type in upper case letters.
8260
8261 @sp 1
8262 @cartouche
8263 @noindent
8264 @strong{47}.  What determines whether a compilation unit is the same in
8265 two different partitions.  See 13.3(76).
8266 @end cartouche
8267 @noindent
8268 A compilation unit is the same in two different partitions if and only
8269 if it derives from the same source file.
8270
8271 @sp 1
8272 @cartouche
8273 @noindent
8274 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8275 @end cartouche
8276 @noindent
8277 The only implementation defined component is the tag for a tagged type,
8278 which contains a pointer to the dispatching table.
8279
8280 @sp 1
8281 @cartouche
8282 @noindent
8283 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8284 ordering.  See 13.5.3(5).
8285 @end cartouche
8286 @noindent
8287 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8288 implementation, so no non-default bit ordering is supported.  The default
8289 bit ordering corresponds to the natural endianness of the target architecture.
8290
8291 @sp 1
8292 @cartouche
8293 @noindent
8294 @strong{50}.  The contents of the visible part of package @code{System}
8295 and its language-defined children.  See 13.7(2).
8296 @end cartouche
8297 @noindent
8298 See the definition of these packages in files @file{system.ads} and
8299 @file{s-stoele.ads}.
8300
8301 @sp 1
8302 @cartouche
8303 @noindent
8304 @strong{51}.  The contents of the visible part of package
8305 @code{System.Machine_Code}, and the meaning of
8306 @code{code_statements}.  See 13.8(7).
8307 @end cartouche
8308 @noindent
8309 See the definition and documentation in file @file{s-maccod.ads}.
8310
8311 @sp 1
8312 @cartouche
8313 @noindent
8314 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8315 @end cartouche
8316 @noindent
8317 Unchecked conversion between types of the same size
8318 results in an uninterpreted transmission of the bits from one type
8319 to the other.  If the types are of unequal sizes, then in the case of
8320 discrete types, a shorter source is first zero or sign extended as
8321 necessary, and a shorter target is simply truncated on the left.
8322 For all non-discrete types, the source is first copied if necessary
8323 to ensure that the alignment requirements of the target are met, then
8324 a pointer is constructed to the source value, and the result is obtained
8325 by dereferencing this pointer after converting it to be a pointer to the
8326 target type. Unchecked conversions where the target subtype is an
8327 unconstrained array are not permitted. If the target alignment is
8328 greater than the source alignment, then a copy of the result is
8329 made with appropriate alignment
8330
8331 @sp 1
8332 @cartouche
8333 @noindent
8334 @strong{53}.  The manner of choosing a storage pool for an access type
8335 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8336 @end cartouche
8337 @noindent
8338 There are 3 different standard pools used by the compiler when
8339 @code{Storage_Pool} is not specified depending whether the type is local
8340 to a subprogram or defined at the library level and whether
8341 @code{Storage_Size}is specified or not.  See documentation in the runtime
8342 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8343 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8344 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8345 default pools used.
8346
8347 @sp 1
8348 @cartouche
8349 @noindent
8350 @strong{54}.  Whether or not the implementation provides user-accessible
8351 names for the standard pool type(s).  See 13.11(17).
8352 @end cartouche
8353 @noindent
8354
8355 See documentation in the sources of the run time mentioned in paragraph
8356 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8357 these units.
8358
8359 @sp 1
8360 @cartouche
8361 @noindent
8362 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8363 @end cartouche
8364 @noindent
8365 @code{Storage_Size} is measured in storage units, and refers to the
8366 total space available for an access type collection, or to the primary
8367 stack space for a task.
8368
8369 @sp 1
8370 @cartouche
8371 @noindent
8372 @strong{56}.  Implementation-defined aspects of storage pools.  See
8373 13.11(22).
8374 @end cartouche
8375 @noindent
8376 See documentation in the sources of the run time mentioned in paragraph
8377 @strong{53} for details on GNAT-defined aspects of storage pools.
8378
8379 @sp 1
8380 @cartouche
8381 @noindent
8382 @strong{57}.  The set of restrictions allowed in a pragma
8383 @code{Restrictions}.  See 13.12(7).
8384 @end cartouche
8385 @noindent
8386 All RM defined Restriction identifiers are implemented.  The following
8387 additional restriction identifiers are provided.  There are two separate
8388 lists of implementation dependent restriction identifiers.  The first
8389 set requires consistency throughout a partition (in other words, if the
8390 restriction identifier is used for any compilation unit in the partition,
8391 then all compilation units in the partition must obey the restriction.
8392
8393 @table @code
8394
8395 @item Simple_Barriers
8396 @findex Simple_Barriers
8397 This restriction ensures at compile time that barriers in entry declarations
8398 for protected types are restricted to either static boolean expressions or
8399 references to simple boolean variables defined in the private part of the
8400 protected type.  No other form of entry barriers is permitted.  This is one
8401 of the restrictions of the Ravenscar profile for limited tasking (see also
8402 pragma @code{Profile (Ravenscar)}).
8403
8404 @item Max_Entry_Queue_Length => Expr
8405 @findex Max_Entry_Queue_Length
8406 This restriction is a declaration that any protected entry compiled in
8407 the scope of the restriction has at most the specified number of
8408 tasks waiting on the entry
8409 at any one time, and so no queue is required.  This restriction is not
8410 checked at compile time.  A program execution is erroneous if an attempt
8411 is made to queue more than the specified number of tasks on such an entry.
8412
8413 @item No_Calendar
8414 @findex No_Calendar
8415 This restriction ensures at compile time that there is no implicit or
8416 explicit dependence on the package @code{Ada.Calendar}.
8417
8418 @item No_Default_Initialization
8419 @findex No_Default_Initialization
8420
8421 This restriction prohibits any instance of default initialization of variables.
8422 The binder implements a consistency rule which prevents any unit compiled
8423 without the restriction from with'ing a unit with the restriction (this allows
8424 the generation of initialization procedures to be skipped, since you can be
8425 sure that no call is ever generated to an initialization procedure in a unit
8426 with the restriction active). If used in conjunction with Initialize_Scalars or
8427 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8428 without a specific initializer (including the case of OUT scalar parameters).
8429
8430 @item No_Direct_Boolean_Operators
8431 @findex No_Direct_Boolean_Operators
8432 This restriction ensures that no logical (and/or/xor) or comparison
8433 operators are used on operands of type Boolean (or any type derived
8434 from Boolean). This is intended for use in safety critical programs
8435 where the certification protocol requires the use of short-circuit
8436 (and then, or else) forms for all composite boolean operations. An
8437 exception is that an explicit equality test with True or False as the
8438 right operand is not considered to violate this restriction.
8439
8440 @item No_Dispatching_Calls
8441 @findex No_Dispatching_Calls
8442 This restriction ensures at compile time that the code generated by the
8443 compiler involves no dispatching calls. The use of this restriction allows the
8444 safe use of record extensions, classwide membership tests and other classwide
8445 features not involving implicit dispatching. This restriction ensures that
8446 the code contains no indirect calls through a dispatching mechanism. Note that
8447 this includes internally-generated calls created by the compiler, for example
8448 in the implementation of class-wide objects assignments. The
8449 membership test is allowed in the presence of this restriction, because its
8450 implementation requires no dispatching.
8451 This restriction is comparable to the official Ada restriction
8452 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8453 all classwide constructs that do not imply dispatching.
8454 The following example indicates constructs that violate this restriction.
8455
8456 @smallexample
8457 package Pkg is
8458   type T is tagged record
8459     Data : Natural;
8460   end record;
8461   procedure P (X : T);
8462
8463   type DT is new T with record
8464     More_Data : Natural;
8465   end record;
8466   procedure Q (X : DT);
8467 end Pkg;
8468
8469 with Pkg; use Pkg;
8470 procedure Example is
8471   procedure Test (O : T'Class) is
8472     N : Natural  := O'Size;--  Error: Dispatching call
8473     C : T'Class := O;      --  Error: implicit Dispatching Call
8474   begin
8475     if O in DT'Class then  --  OK   : Membership test
8476        Q (DT (O));         --  OK   : Type conversion plus direct call
8477     else
8478        P (O);              --  Error: Dispatching call
8479     end if;
8480   end Test;
8481
8482   Obj : DT;
8483 begin
8484   P (Obj);                 --  OK   : Direct call
8485   P (T (Obj));             --  OK   : Type conversion plus direct call
8486   P (T'Class (Obj));       --  Error: Dispatching call
8487
8488   Test (Obj);              --  OK   : Type conversion
8489
8490   if Obj in T'Class then   --  OK   : Membership test
8491      null;
8492   end if;
8493 end Example;
8494 @end smallexample
8495
8496 @item No_Dynamic_Attachment
8497 @findex No_Dynamic_Attachment
8498 This restriction ensures that there is no call to any of the operations
8499 defined in package Ada.Interrupts.
8500
8501 @item No_Enumeration_Maps
8502 @findex No_Enumeration_Maps
8503 This restriction ensures at compile time that no operations requiring
8504 enumeration maps are used (that is Image and Value attributes applied
8505 to enumeration types).
8506
8507 @item No_Entry_Calls_In_Elaboration_Code
8508 @findex No_Entry_Calls_In_Elaboration_Code
8509 This restriction ensures at compile time that no task or protected entry
8510 calls are made during elaboration code.  As a result of the use of this
8511 restriction, the compiler can assume that no code past an accept statement
8512 in a task can be executed at elaboration time.
8513
8514 @item No_Exception_Handlers
8515 @findex No_Exception_Handlers
8516 This restriction ensures at compile time that there are no explicit
8517 exception handlers. It also indicates that no exception propagation will
8518 be provided. In this mode, exceptions may be raised but will result in
8519 an immediate call to the last chance handler, a routine that the user
8520 must define with the following profile:
8521
8522 @smallexample @c ada
8523 procedure Last_Chance_Handler
8524   (Source_Location : System.Address; Line : Integer);
8525 pragma Export (C, Last_Chance_Handler,
8526                "__gnat_last_chance_handler");
8527 @end smallexample
8528
8529 The parameter is a C null-terminated string representing a message to be
8530 associated with the exception (typically the source location of the raise
8531 statement generated by the compiler). The Line parameter when nonzero
8532 represents the line number in the source program where the raise occurs.
8533
8534 @item No_Exception_Propagation
8535 @findex No_Exception_Propagation
8536 This restriction guarantees that exceptions are never propagated to an outer
8537 subprogram scope). The only case in which an exception may be raised is when
8538 the handler is statically in the same subprogram, so that the effect of a raise
8539 is essentially like a goto statement. Any other raise statement (implicit or
8540 explicit) will be considered unhandled. Exception handlers are allowed, but may
8541 not contain an exception occurrence identifier (exception choice). In addition
8542 use of the package GNAT.Current_Exception is not permitted, and reraise
8543 statements (raise with no operand) are not permitted.
8544
8545 @item No_Exception_Registration
8546 @findex No_Exception_Registration
8547 This restriction ensures at compile time that no stream operations for
8548 types Exception_Id or Exception_Occurrence are used. This also makes it
8549 impossible to pass exceptions to or from a partition with this restriction
8550 in a distributed environment. If this exception is active, then the generated
8551 code is simplified by omitting the otherwise-required global registration
8552 of exceptions when they are declared.
8553
8554 @item No_Implicit_Conditionals
8555 @findex No_Implicit_Conditionals
8556 This restriction ensures that the generated code does not contain any
8557 implicit conditionals, either by modifying the generated code where possible,
8558 or by rejecting any construct that would otherwise generate an implicit
8559 conditional. Note that this check does not include run time constraint
8560 checks, which on some targets may generate implicit conditionals as
8561 well. To control the latter, constraint checks can be suppressed in the
8562 normal manner. Constructs generating implicit conditionals include comparisons
8563 of composite objects and the Max/Min attributes.
8564
8565 @item No_Implicit_Dynamic_Code
8566 @findex No_Implicit_Dynamic_Code
8567 @cindex trampoline
8568 This restriction prevents the compiler from building ``trampolines''.
8569 This is a structure that is built on the stack and contains dynamic
8570 code to be executed at run time. On some targets, a trampoline is
8571 built for the following features: @code{Access},
8572 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8573 nested task bodies; primitive operations of nested tagged types.
8574 Trampolines do not work on machines that prevent execution of stack
8575 data. For example, on windows systems, enabling DEP (data execution
8576 protection) will cause trampolines to raise an exception.
8577 Trampolines are also quite slow at run time.
8578
8579 On many targets, trampolines have been largely eliminated. Look at the
8580 version of system.ads for your target --- if it has
8581 Always_Compatible_Rep equal to False, then trampolines are largely
8582 eliminated. In particular, a trampoline is built for the following
8583 features: @code{Address} of a nested subprogram;
8584 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8585 but only if pragma Favor_Top_Level applies, or the access type has a
8586 foreign-language convention; primitive operations of nested tagged
8587 types.
8588
8589 @item No_Implicit_Loops
8590 @findex No_Implicit_Loops
8591 This restriction ensures that the generated code does not contain any
8592 implicit @code{for} loops, either by modifying
8593 the generated code where possible,
8594 or by rejecting any construct that would otherwise generate an implicit
8595 @code{for} loop. If this restriction is active, it is possible to build
8596 large array aggregates with all static components without generating an
8597 intermediate temporary, and without generating a loop to initialize individual
8598 components. Otherwise, a loop is created for arrays larger than about 5000
8599 scalar components.
8600
8601 @item No_Initialize_Scalars
8602 @findex No_Initialize_Scalars
8603 This restriction ensures that no unit in the partition is compiled with
8604 pragma Initialize_Scalars. This allows the generation of more efficient
8605 code, and in particular eliminates dummy null initialization routines that
8606 are otherwise generated for some record and array types.
8607
8608 @item No_Local_Protected_Objects
8609 @findex No_Local_Protected_Objects
8610 This restriction ensures at compile time that protected objects are
8611 only declared at the library level.
8612
8613 @item No_Protected_Type_Allocators
8614 @findex No_Protected_Type_Allocators
8615 This restriction ensures at compile time that there are no allocator
8616 expressions that attempt to allocate protected objects.
8617
8618 @item No_Secondary_Stack
8619 @findex No_Secondary_Stack
8620 This restriction ensures at compile time that the generated code does not
8621 contain any reference to the secondary stack.  The secondary stack is used
8622 to implement functions returning unconstrained objects (arrays or records)
8623 on some targets.
8624
8625 @item No_Select_Statements
8626 @findex No_Select_Statements
8627 This restriction ensures at compile time no select statements of any kind
8628 are permitted, that is the keyword @code{select} may not appear.
8629 This is one of the restrictions of the Ravenscar
8630 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8631
8632 @item No_Standard_Storage_Pools
8633 @findex No_Standard_Storage_Pools
8634 This restriction ensures at compile time that no access types
8635 use the standard default storage pool.  Any access type declared must
8636 have an explicit Storage_Pool attribute defined specifying a
8637 user-defined storage pool.
8638
8639 @item No_Streams
8640 @findex No_Streams
8641 This restriction ensures at compile/bind time that there are no
8642 stream objects created and no use of stream attributes.
8643 This restriction does not forbid dependences on the package
8644 @code{Ada.Streams}. So it is permissible to with
8645 @code{Ada.Streams} (or another package that does so itself)
8646 as long as no actual stream objects are created and no
8647 stream attributes are used.
8648
8649 Note that the use of restriction allows optimization of tagged types,
8650 since they do not need to worry about dispatching stream operations.
8651 To take maximum advantage of this space-saving optimization, any
8652 unit declaring a tagged type should be compiled with the restriction,
8653 though this is not required.
8654
8655 @item No_Task_Attributes_Package
8656 @findex No_Task_Attributes_Package
8657 This restriction ensures at compile time that there are no implicit or
8658 explicit dependencies on the package @code{Ada.Task_Attributes}.
8659
8660 @item No_Task_Termination
8661 @findex No_Task_Termination
8662 This restriction ensures at compile time that no terminate alternatives
8663 appear in any task body.
8664
8665 @item No_Tasking
8666 @findex No_Tasking
8667 This restriction prevents the declaration of tasks or task types throughout
8668 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8669 except that violations are caught at compile time and cause an error message
8670 to be output either by the compiler or binder.
8671
8672 @item Static_Priorities
8673 @findex Static_Priorities
8674 This restriction ensures at compile time that all priority expressions
8675 are static, and that there are no dependencies on the package
8676 @code{Ada.Dynamic_Priorities}.
8677
8678 @item Static_Storage_Size
8679 @findex Static_Storage_Size
8680 This restriction ensures at compile time that any expression appearing
8681 in a Storage_Size pragma or attribute definition clause is static.
8682
8683 @end table
8684
8685 @noindent
8686 The second set of implementation dependent restriction identifiers
8687 does not require partition-wide consistency.
8688 The restriction may be enforced for a single
8689 compilation unit without any effect on any of the
8690 other compilation units in the partition.
8691
8692 @table @code
8693
8694 @item No_Elaboration_Code
8695 @findex No_Elaboration_Code
8696 This restriction ensures at compile time that no elaboration code is
8697 generated.  Note that this is not the same condition as is enforced
8698 by pragma @code{Preelaborate}.  There are cases in which pragma
8699 @code{Preelaborate} still permits code to be generated (e.g.@: code
8700 to initialize a large array to all zeroes), and there are cases of units
8701 which do not meet the requirements for pragma @code{Preelaborate},
8702 but for which no elaboration code is generated.  Generally, it is
8703 the case that preelaborable units will meet the restrictions, with
8704 the exception of large aggregates initialized with an others_clause,
8705 and exception declarations (which generate calls to a run-time
8706 registry procedure).  This restriction is enforced on
8707 a unit by unit basis, it need not be obeyed consistently
8708 throughout a partition.
8709
8710 In the case of aggregates with others, if the aggregate has a dynamic
8711 size, there is no way to eliminate the elaboration code (such dynamic
8712 bounds would be incompatible with @code{Preelaborate} in any case). If
8713 the bounds are static, then use of this restriction actually modifies
8714 the code choice of the compiler to avoid generating a loop, and instead
8715 generate the aggregate statically if possible, no matter how many times
8716 the data for the others clause must be repeatedly generated.
8717
8718 It is not possible to precisely document
8719 the constructs which are compatible with this restriction, since,
8720 unlike most other restrictions, this is not a restriction on the
8721 source code, but a restriction on the generated object code. For
8722 example, if the source contains a declaration:
8723
8724 @smallexample
8725    Val : constant Integer := X;
8726 @end smallexample
8727
8728 @noindent
8729 where X is not a static constant, it may be possible, depending
8730 on complex optimization circuitry, for the compiler to figure
8731 out the value of X at compile time, in which case this initialization
8732 can be done by the loader, and requires no initialization code. It
8733 is not possible to document the precise conditions under which the
8734 optimizer can figure this out.
8735
8736 Note that this the implementation of this restriction requires full
8737 code generation. If it is used in conjunction with "semantics only"
8738 checking, then some cases of violations may be missed.
8739
8740 @item No_Entry_Queue
8741 @findex No_Entry_Queue
8742 This restriction is a declaration that any protected entry compiled in
8743 the scope of the restriction has at most one task waiting on the entry
8744 at any one time, and so no queue is required.  This restriction is not
8745 checked at compile time.  A program execution is erroneous if an attempt
8746 is made to queue a second task on such an entry.
8747
8748 @item No_Implementation_Attributes
8749 @findex No_Implementation_Attributes
8750 This restriction checks at compile time that no GNAT-defined attributes
8751 are present.  With this restriction, the only attributes that can be used
8752 are those defined in the Ada Reference Manual.
8753
8754 @item No_Implementation_Pragmas
8755 @findex No_Implementation_Pragmas
8756 This restriction checks at compile time that no GNAT-defined pragmas
8757 are present.  With this restriction, the only pragmas that can be used
8758 are those defined in the Ada Reference Manual.
8759
8760 @item No_Implementation_Restrictions
8761 @findex No_Implementation_Restrictions
8762 This restriction checks at compile time that no GNAT-defined restriction
8763 identifiers (other than @code{No_Implementation_Restrictions} itself)
8764 are present.  With this restriction, the only other restriction identifiers
8765 that can be used are those defined in the Ada Reference Manual.
8766
8767 @item No_Wide_Characters
8768 @findex No_Wide_Characters
8769 This restriction ensures at compile time that no uses of the types
8770 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8771 wide types
8772 appear, and that no wide or wide wide string or character literals
8773 appear in the program (that is literals representing characters not in
8774 type @code{Character}.
8775
8776 @end table
8777
8778 @sp 1
8779 @cartouche
8780 @noindent
8781 @strong{58}.  The consequences of violating limitations on
8782 @code{Restrictions} pragmas.  See 13.12(9).
8783 @end cartouche
8784 @noindent
8785 Restrictions that can be checked at compile time result in illegalities
8786 if violated.  Currently there are no other consequences of violating
8787 restrictions.
8788
8789 @sp 1
8790 @cartouche
8791 @noindent
8792 @strong{59}.  The representation used by the @code{Read} and
8793 @code{Write} attributes of elementary types in terms of stream
8794 elements.  See 13.13.2(9).
8795 @end cartouche
8796 @noindent
8797 The representation is the in-memory representation of the base type of
8798 the type, using the number of bits corresponding to the
8799 @code{@var{type}'Size} value, and the natural ordering of the machine.
8800
8801 @sp 1
8802 @cartouche
8803 @noindent
8804 @strong{60}.  The names and characteristics of the numeric subtypes
8805 declared in the visible part of package @code{Standard}.  See A.1(3).
8806 @end cartouche
8807 @noindent
8808 See items describing the integer and floating-point types supported.
8809
8810 @sp 1
8811 @cartouche
8812 @noindent
8813 @strong{61}.  The accuracy actually achieved by the elementary
8814 functions.  See A.5.1(1).
8815 @end cartouche
8816 @noindent
8817 The elementary functions correspond to the functions available in the C
8818 library.  Only fast math mode is implemented.
8819
8820 @sp 1
8821 @cartouche
8822 @noindent
8823 @strong{62}.  The sign of a zero result from some of the operators or
8824 functions in @code{Numerics.Generic_Elementary_Functions}, when
8825 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8826 @end cartouche
8827 @noindent
8828 The sign of zeroes follows the requirements of the IEEE 754 standard on
8829 floating-point.
8830
8831 @sp 1
8832 @cartouche
8833 @noindent
8834 @strong{63}.  The value of
8835 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8836 @end cartouche
8837 @noindent
8838 Maximum image width is 649, see library file @file{a-numran.ads}.
8839
8840 @sp 1
8841 @cartouche
8842 @noindent
8843 @strong{64}.  The value of
8844 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8845 @end cartouche
8846 @noindent
8847 Maximum image width is 80, see library file @file{a-nudira.ads}.
8848
8849 @sp 1
8850 @cartouche
8851 @noindent
8852 @strong{65}.  The algorithms for random number generation.  See
8853 A.5.2(32).
8854 @end cartouche
8855 @noindent
8856 The algorithm is documented in the source files @file{a-numran.ads} and
8857 @file{a-numran.adb}.
8858
8859 @sp 1
8860 @cartouche
8861 @noindent
8862 @strong{66}.  The string representation of a random number generator's
8863 state.  See A.5.2(38).
8864 @end cartouche
8865 @noindent
8866 See the documentation contained in the file @file{a-numran.adb}.
8867
8868 @sp 1
8869 @cartouche
8870 @noindent
8871 @strong{67}.  The minimum time interval between calls to the
8872 time-dependent Reset procedure that are guaranteed to initiate different
8873 random number sequences.  See A.5.2(45).
8874 @end cartouche
8875 @noindent
8876 The minimum period between reset calls to guarantee distinct series of
8877 random numbers is one microsecond.
8878
8879 @sp 1
8880 @cartouche
8881 @noindent
8882 @strong{68}.  The values of the @code{Model_Mantissa},
8883 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8884 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8885 Annex is not supported.  See A.5.3(72).
8886 @end cartouche
8887 @noindent
8888 See the source file @file{ttypef.ads} for the values of all numeric
8889 attributes.
8890
8891 @sp 1
8892 @cartouche
8893 @noindent
8894 @strong{69}.  Any implementation-defined characteristics of the
8895 input-output packages.  See A.7(14).
8896 @end cartouche
8897 @noindent
8898 There are no special implementation defined characteristics for these
8899 packages.
8900
8901 @sp 1
8902 @cartouche
8903 @noindent
8904 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8905 A.9(10).
8906 @end cartouche
8907 @noindent
8908 All type representations are contiguous, and the @code{Buffer_Size} is
8909 the value of @code{@var{type}'Size} rounded up to the next storage unit
8910 boundary.
8911
8912 @sp 1
8913 @cartouche
8914 @noindent
8915 @strong{71}.  External files for standard input, standard output, and
8916 standard error See A.10(5).
8917 @end cartouche
8918 @noindent
8919 These files are mapped onto the files provided by the C streams
8920 libraries.  See source file @file{i-cstrea.ads} for further details.
8921
8922 @sp 1
8923 @cartouche
8924 @noindent
8925 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8926 A.10.9(36).
8927 @end cartouche
8928 @noindent
8929 If more digits are requested in the output than are represented by the
8930 precision of the value, zeroes are output in the corresponding least
8931 significant digit positions.
8932
8933 @sp 1
8934 @cartouche
8935 @noindent
8936 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8937 @code{Command_Name}.  See A.15(1).
8938 @end cartouche
8939 @noindent
8940 These are mapped onto the @code{argv} and @code{argc} parameters of the
8941 main program in the natural manner.
8942
8943 @sp 1
8944 @cartouche
8945 @noindent
8946 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8947 @end cartouche
8948 @noindent
8949 The following convention names are supported
8950
8951 @table @code
8952 @item  Ada
8953 Ada
8954 @item Assembler
8955 Assembly language
8956 @item Asm
8957 Synonym for Assembler
8958 @item Assembly
8959 Synonym for Assembler
8960 @item C
8961 C
8962 @item C_Pass_By_Copy
8963 Allowed only for record types, like C, but also notes that record
8964 is to be passed by copy rather than reference.
8965 @item COBOL
8966 COBOL
8967 @item C_Plus_Plus (or CPP)
8968 C++
8969 @item Default
8970 Treated the same as C
8971 @item External
8972 Treated the same as C
8973 @item Fortran
8974 Fortran
8975 @item Intrinsic
8976 For support of pragma @code{Import} with convention Intrinsic, see
8977 separate section on Intrinsic Subprograms.
8978 @item Stdcall
8979 Stdcall (used for Windows implementations only).  This convention correspond
8980 to the WINAPI (previously called Pascal convention) C/C++ convention under
8981 Windows.  A function with this convention cleans the stack before exit.
8982 @item DLL
8983 Synonym for Stdcall
8984 @item Win32
8985 Synonym for Stdcall
8986 @item Stubbed
8987 Stubbed is a special convention used to indicate that the body of the
8988 subprogram will be entirely ignored.  Any call to the subprogram
8989 is converted into a raise of the @code{Program_Error} exception.  If a
8990 pragma @code{Import} specifies convention @code{stubbed} then no body need
8991 be present at all.  This convention is useful during development for the
8992 inclusion of subprograms whose body has not yet been written.
8993
8994 @end table
8995 @noindent
8996 In addition, all otherwise unrecognized convention names are also
8997 treated as being synonymous with convention C@.  In all implementations
8998 except for VMS, use of such other names results in a warning.  In VMS
8999 implementations, these names are accepted silently.
9000
9001 @sp 1
9002 @cartouche
9003 @noindent
9004 @strong{75}.  The meaning of link names.  See B.1(36).
9005 @end cartouche
9006 @noindent
9007 Link names are the actual names used by the linker.
9008
9009 @sp 1
9010 @cartouche
9011 @noindent
9012 @strong{76}.  The manner of choosing link names when neither the link
9013 name nor the address of an imported or exported entity is specified.  See
9014 B.1(36).
9015 @end cartouche
9016 @noindent
9017 The default linker name is that which would be assigned by the relevant
9018 external language, interpreting the Ada name as being in all lower case
9019 letters.
9020
9021 @sp 1
9022 @cartouche
9023 @noindent
9024 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9025 @end cartouche
9026 @noindent
9027 The string passed to @code{Linker_Options} is presented uninterpreted as
9028 an argument to the link command, unless it contains ASCII.NUL characters.
9029 NUL characters if they appear act as argument separators, so for example
9030
9031 @smallexample @c ada
9032 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9033 @end smallexample
9034
9035 @noindent
9036 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9037 linker. The order of linker options is preserved for a given unit. The final
9038 list of options passed to the linker is in reverse order of the elaboration
9039 order. For example, linker options for a body always appear before the options
9040 from the corresponding package spec.
9041
9042 @sp 1
9043 @cartouche
9044 @noindent
9045 @strong{78}.  The contents of the visible part of package
9046 @code{Interfaces} and its language-defined descendants.  See B.2(1).
9047 @end cartouche
9048 @noindent
9049 See files with prefix @file{i-} in the distributed library.
9050
9051 @sp 1
9052 @cartouche
9053 @noindent
9054 @strong{79}.  Implementation-defined children of package
9055 @code{Interfaces}.  The contents of the visible part of package
9056 @code{Interfaces}.  See B.2(11).
9057 @end cartouche
9058 @noindent
9059 See files with prefix @file{i-} in the distributed library.
9060
9061 @sp 1
9062 @cartouche
9063 @noindent
9064 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
9065 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9066 @code{COBOL_Character}; and the initialization of the variables
9067 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9068 @code{Interfaces.COBOL}.  See B.4(50).
9069 @end cartouche
9070 @noindent
9071 @table @code
9072 @item Floating
9073 Float
9074 @item Long_Floating
9075 (Floating) Long_Float
9076 @item Binary
9077 Integer
9078 @item Long_Binary
9079 Long_Long_Integer
9080 @item Decimal_Element
9081 Character
9082 @item COBOL_Character
9083 Character
9084 @end table
9085
9086 @noindent
9087 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9088
9089 @sp 1
9090 @cartouche
9091 @noindent
9092 @strong{81}.  Support for access to machine instructions.  See C.1(1).
9093 @end cartouche
9094 @noindent
9095 See documentation in file @file{s-maccod.ads} in the distributed library.
9096
9097 @sp 1
9098 @cartouche
9099 @noindent
9100 @strong{82}.  Implementation-defined aspects of access to machine
9101 operations.  See C.1(9).
9102 @end cartouche
9103 @noindent
9104 See documentation in file @file{s-maccod.ads} in the distributed library.
9105
9106 @sp 1
9107 @cartouche
9108 @noindent
9109 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
9110 @end cartouche
9111 @noindent
9112 Interrupts are mapped to signals or conditions as appropriate.  See
9113 definition of unit
9114 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9115 on the interrupts supported on a particular target.
9116
9117 @sp 1
9118 @cartouche
9119 @noindent
9120 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
9121 C.4(13).
9122 @end cartouche
9123 @noindent
9124 GNAT does not permit a partition to be restarted without reloading,
9125 except under control of the debugger.
9126
9127 @sp 1
9128 @cartouche
9129 @noindent
9130 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9131 @end cartouche
9132 @noindent
9133 Pragma @code{Discard_Names} causes names of enumeration literals to
9134 be suppressed.  In the presence of this pragma, the Image attribute
9135 provides the image of the Pos of the literal, and Value accepts
9136 Pos values.
9137
9138 @sp 1
9139 @cartouche
9140 @noindent
9141 @strong{86}.  The result of the @code{Task_Identification.Image}
9142 attribute.  See C.7.1(7).
9143 @end cartouche
9144 @noindent
9145 The result of this attribute is a string that identifies
9146 the object or component that denotes a given task. If a variable @code{Var}
9147 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9148 where the suffix
9149 is the hexadecimal representation of the virtual address of the corresponding
9150 task control block. If the variable is an array of tasks, the image of each
9151 task will have the form of an indexed component indicating the position of a
9152 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9153 component of a record, the image of the task will have the form of a selected
9154 component. These rules are fully recursive, so that the image of a task that
9155 is a subcomponent of a composite object corresponds to the expression that
9156 designates this task.
9157 @noindent
9158 If a task is created by an allocator, its image depends on the context. If the
9159 allocator is part of an object declaration, the rules described above are used
9160 to construct its image, and this image is not affected by subsequent
9161 assignments. If the allocator appears within an expression, the image
9162 includes only the name of the task type.
9163 @noindent
9164 If the configuration pragma Discard_Names is present, or if the restriction
9165 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9166 the numeric suffix, that is to say the hexadecimal representation of the
9167 virtual address of the control block of the task.
9168 @sp 1
9169 @cartouche
9170 @noindent
9171 @strong{87}.  The value of @code{Current_Task} when in a protected entry
9172 or interrupt handler.  See C.7.1(17).
9173 @end cartouche
9174 @noindent
9175 Protected entries or interrupt handlers can be executed by any
9176 convenient thread, so the value of @code{Current_Task} is undefined.
9177
9178 @sp 1
9179 @cartouche
9180 @noindent
9181 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9182 body or interrupt handler.  See C.7.1(19).
9183 @end cartouche
9184 @noindent
9185 The effect of calling @code{Current_Task} from an entry body or
9186 interrupt handler is to return the identification of the task currently
9187 executing the code.
9188
9189 @sp 1
9190 @cartouche
9191 @noindent
9192 @strong{89}.  Implementation-defined aspects of
9193 @code{Task_Attributes}.  See C.7.2(19).
9194 @end cartouche
9195 @noindent
9196 There are no implementation-defined aspects of @code{Task_Attributes}.
9197
9198 @sp 1
9199 @cartouche
9200 @noindent
9201 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9202 @end cartouche
9203 @noindent
9204 The metrics information for GNAT depends on the performance of the
9205 underlying operating system.  The sources of the run-time for tasking
9206 implementation, together with the output from @option{-gnatG} can be
9207 used to determine the exact sequence of operating systems calls made
9208 to implement various tasking constructs.  Together with appropriate
9209 information on the performance of the underlying operating system,
9210 on the exact target in use, this information can be used to determine
9211 the required metrics.
9212
9213 @sp 1
9214 @cartouche
9215 @noindent
9216 @strong{91}.  The declarations of @code{Any_Priority} and
9217 @code{Priority}.  See D.1(11).
9218 @end cartouche
9219 @noindent
9220 See declarations in file @file{system.ads}.
9221
9222 @sp 1
9223 @cartouche
9224 @noindent
9225 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9226 @end cartouche
9227 @noindent
9228 There are no implementation-defined execution resources.
9229
9230 @sp 1
9231 @cartouche
9232 @noindent
9233 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9234 access to a protected object keeps its processor busy.  See D.2.1(3).
9235 @end cartouche
9236 @noindent
9237 On a multi-processor, a task that is waiting for access to a protected
9238 object does not keep its processor busy.
9239
9240 @sp 1
9241 @cartouche
9242 @noindent
9243 @strong{94}.  The affect of implementation defined execution resources
9244 on task dispatching.  See D.2.1(9).
9245 @end cartouche
9246 @noindent
9247 @c SGI info
9248 @ignore
9249 Tasks map to IRIX threads, and the dispatching policy is as defined by
9250 the IRIX implementation of threads.
9251 @end ignore
9252 Tasks map to threads in the threads package used by GNAT@.  Where possible
9253 and appropriate, these threads correspond to native threads of the
9254 underlying operating system.
9255
9256 @sp 1
9257 @cartouche
9258 @noindent
9259 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9260 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9261 @end cartouche
9262 @noindent
9263 There are no implementation-defined policy-identifiers allowed in this
9264 pragma.
9265
9266 @sp 1
9267 @cartouche
9268 @noindent
9269 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9270 D.2.2(16).
9271 @end cartouche
9272 @noindent
9273 Execution of a task cannot be preempted by the implementation processing
9274 of delay expirations for lower priority tasks.
9275
9276 @sp 1
9277 @cartouche
9278 @noindent
9279 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9280 @end cartouche
9281 @noindent
9282 @c SGI info:
9283 @ignore
9284 Tasks map to IRIX threads, and the dispatching policy is as defined by
9285 the IRIX implementation of threads.
9286 @end ignore
9287 The policy is the same as that of the underlying threads implementation.
9288
9289 @sp 1
9290 @cartouche
9291 @noindent
9292 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9293 in a pragma @code{Locking_Policy}.  See D.3(4).
9294 @end cartouche
9295 @noindent
9296 The only implementation defined policy permitted in GNAT is
9297 @code{Inheritance_Locking}.  On targets that support this policy, locking
9298 is implemented by inheritance, i.e.@: the task owning the lock operates
9299 at a priority equal to the highest priority of any task currently
9300 requesting the lock.
9301
9302 @sp 1
9303 @cartouche
9304 @noindent
9305 @strong{99}.  Default ceiling priorities.  See D.3(10).
9306 @end cartouche
9307 @noindent
9308 The ceiling priority of protected objects of the type
9309 @code{System.Interrupt_Priority'Last} as described in the Ada
9310 Reference Manual D.3(10),
9311
9312 @sp 1
9313 @cartouche
9314 @noindent
9315 @strong{100}.  The ceiling of any protected object used internally by
9316 the implementation.  See D.3(16).
9317 @end cartouche
9318 @noindent
9319 The ceiling priority of internal protected objects is
9320 @code{System.Priority'Last}.
9321
9322 @sp 1
9323 @cartouche
9324 @noindent
9325 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9326 @end cartouche
9327 @noindent
9328 There are no implementation-defined queuing policies.
9329
9330 @sp 1
9331 @cartouche
9332 @noindent
9333 @strong{102}.  On a multiprocessor, any conditions that cause the
9334 completion of an aborted construct to be delayed later than what is
9335 specified for a single processor.  See D.6(3).
9336 @end cartouche
9337 @noindent
9338 The semantics for abort on a multi-processor is the same as on a single
9339 processor, there are no further delays.
9340
9341 @sp 1
9342 @cartouche
9343 @noindent
9344 @strong{103}.  Any operations that implicitly require heap storage
9345 allocation.  See D.7(8).
9346 @end cartouche
9347 @noindent
9348 The only operation that implicitly requires heap storage allocation is
9349 task creation.
9350
9351 @sp 1
9352 @cartouche
9353 @noindent
9354 @strong{104}.  Implementation-defined aspects of pragma
9355 @code{Restrictions}.  See D.7(20).
9356 @end cartouche
9357 @noindent
9358 There are no such implementation-defined aspects.
9359
9360 @sp 1
9361 @cartouche
9362 @noindent
9363 @strong{105}.  Implementation-defined aspects of package
9364 @code{Real_Time}.  See D.8(17).
9365 @end cartouche
9366 @noindent
9367 There are no implementation defined aspects of package @code{Real_Time}.
9368
9369 @sp 1
9370 @cartouche
9371 @noindent
9372 @strong{106}.  Implementation-defined aspects of
9373 @code{delay_statements}.  See D.9(8).
9374 @end cartouche
9375 @noindent
9376 Any difference greater than one microsecond will cause the task to be
9377 delayed (see D.9(7)).
9378
9379 @sp 1
9380 @cartouche
9381 @noindent
9382 @strong{107}.  The upper bound on the duration of interrupt blocking
9383 caused by the implementation.  See D.12(5).
9384 @end cartouche
9385 @noindent
9386 The upper bound is determined by the underlying operating system.  In
9387 no cases is it more than 10 milliseconds.
9388
9389 @sp 1
9390 @cartouche
9391 @noindent
9392 @strong{108}.  The means for creating and executing distributed
9393 programs.  See E(5).
9394 @end cartouche
9395 @noindent
9396 The GLADE package provides a utility GNATDIST for creating and executing
9397 distributed programs.  See the GLADE reference manual for further details.
9398
9399 @sp 1
9400 @cartouche
9401 @noindent
9402 @strong{109}.  Any events that can result in a partition becoming
9403 inaccessible.  See E.1(7).
9404 @end cartouche
9405 @noindent
9406 See the GLADE reference manual for full details on such events.
9407
9408 @sp 1
9409 @cartouche
9410 @noindent
9411 @strong{110}.  The scheduling policies, treatment of priorities, and
9412 management of shared resources between partitions in certain cases.  See
9413 E.1(11).
9414 @end cartouche
9415 @noindent
9416 See the GLADE reference manual for full details on these aspects of
9417 multi-partition execution.
9418
9419 @sp 1
9420 @cartouche
9421 @noindent
9422 @strong{111}.  Events that cause the version of a compilation unit to
9423 change.  See E.3(5).
9424 @end cartouche
9425 @noindent
9426 Editing the source file of a compilation unit, or the source files of
9427 any units on which it is dependent in a significant way cause the version
9428 to change.  No other actions cause the version number to change.  All changes
9429 are significant except those which affect only layout, capitalization or
9430 comments.
9431
9432 @sp 1
9433 @cartouche
9434 @noindent
9435 @strong{112}.  Whether the execution of the remote subprogram is
9436 immediately aborted as a result of cancellation.  See E.4(13).
9437 @end cartouche
9438 @noindent
9439 See the GLADE reference manual for details on the effect of abort in
9440 a distributed application.
9441
9442 @sp 1
9443 @cartouche
9444 @noindent
9445 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9446 @end cartouche
9447 @noindent
9448 See the GLADE reference manual for a full description of all implementation
9449 defined aspects of the PCS@.
9450
9451 @sp 1
9452 @cartouche
9453 @noindent
9454 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9455 E.5(26).
9456 @end cartouche
9457 @noindent
9458 See the GLADE reference manual for a full description of all
9459 implementation defined interfaces.
9460
9461 @sp 1
9462 @cartouche
9463 @noindent
9464 @strong{115}.  The values of named numbers in the package
9465 @code{Decimal}.  See F.2(7).
9466 @end cartouche
9467 @noindent
9468 @table @code
9469 @item Max_Scale
9470 +18
9471 @item Min_Scale
9472 -18
9473 @item Min_Delta
9474 1.0E-18
9475 @item Max_Delta
9476 1.0E+18
9477 @item Max_Decimal_Digits
9478 18
9479 @end table
9480
9481 @sp 1
9482 @cartouche
9483 @noindent
9484 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9485 @code{Text_IO.Editing}.  See F.3.3(16).
9486 @end cartouche
9487 @noindent
9488 64
9489
9490 @sp 1
9491 @cartouche
9492 @noindent
9493 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9494 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9495 @end cartouche
9496 @noindent
9497 64
9498
9499 @sp 1
9500 @cartouche
9501 @noindent
9502 @strong{118}.  The accuracy actually achieved by the complex elementary
9503 functions and by other complex arithmetic operations.  See G.1(1).
9504 @end cartouche
9505 @noindent
9506 Standard library functions are used for the complex arithmetic
9507 operations.  Only fast math mode is currently supported.
9508
9509 @sp 1
9510 @cartouche
9511 @noindent
9512 @strong{119}.  The sign of a zero result (or a component thereof) from
9513 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9514 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9515 @end cartouche
9516 @noindent
9517 The signs of zero values are as recommended by the relevant
9518 implementation advice.
9519
9520 @sp 1
9521 @cartouche
9522 @noindent
9523 @strong{120}.  The sign of a zero result (or a component thereof) from
9524 any operator or function in
9525 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9526 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9527 @end cartouche
9528 @noindent
9529 The signs of zero values are as recommended by the relevant
9530 implementation advice.
9531
9532 @sp 1
9533 @cartouche
9534 @noindent
9535 @strong{121}.  Whether the strict mode or the relaxed mode is the
9536 default.  See G.2(2).
9537 @end cartouche
9538 @noindent
9539 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9540 provides a highly efficient implementation of strict mode.
9541
9542 @sp 1
9543 @cartouche
9544 @noindent
9545 @strong{122}.  The result interval in certain cases of fixed-to-float
9546 conversion.  See G.2.1(10).
9547 @end cartouche
9548 @noindent
9549 For cases where the result interval is implementation dependent, the
9550 accuracy is that provided by performing all operations in 64-bit IEEE
9551 floating-point format.
9552
9553 @sp 1
9554 @cartouche
9555 @noindent
9556 @strong{123}.  The result of a floating point arithmetic operation in
9557 overflow situations, when the @code{Machine_Overflows} attribute of the
9558 result type is @code{False}.  See G.2.1(13).
9559 @end cartouche
9560 @noindent
9561 Infinite and NaN values are produced as dictated by the IEEE
9562 floating-point standard.
9563
9564 Note that on machines that are not fully compliant with the IEEE
9565 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9566 must be used for achieving IEEE confirming behavior (although at the cost
9567 of a significant performance penalty), so infinite and NaN values are
9568 properly generated.
9569
9570 @sp 1
9571 @cartouche
9572 @noindent
9573 @strong{124}.  The result interval for division (or exponentiation by a
9574 negative exponent), when the floating point hardware implements division
9575 as multiplication by a reciprocal.  See G.2.1(16).
9576 @end cartouche
9577 @noindent
9578 Not relevant, division is IEEE exact.
9579
9580 @sp 1
9581 @cartouche
9582 @noindent
9583 @strong{125}.  The definition of close result set, which determines the
9584 accuracy of certain fixed point multiplications and divisions.  See
9585 G.2.3(5).
9586 @end cartouche
9587 @noindent
9588 Operations in the close result set are performed using IEEE long format
9589 floating-point arithmetic.  The input operands are converted to
9590 floating-point, the operation is done in floating-point, and the result
9591 is converted to the target type.
9592
9593 @sp 1
9594 @cartouche
9595 @noindent
9596 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9597 point multiplication or division for which the result shall be in the
9598 perfect result set.  See G.2.3(22).
9599 @end cartouche
9600 @noindent
9601 The result is only defined to be in the perfect result set if the result
9602 can be computed by a single scaling operation involving a scale factor
9603 representable in 64-bits.
9604
9605 @sp 1
9606 @cartouche
9607 @noindent
9608 @strong{127}.  The result of a fixed point arithmetic operation in
9609 overflow situations, when the @code{Machine_Overflows} attribute of the
9610 result type is @code{False}.  See G.2.3(27).
9611 @end cartouche
9612 @noindent
9613 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9614 types.
9615
9616 @sp 1
9617 @cartouche
9618 @noindent
9619 @strong{128}.  The result of an elementary function reference in
9620 overflow situations, when the @code{Machine_Overflows} attribute of the
9621 result type is @code{False}.  See G.2.4(4).
9622 @end cartouche
9623 @noindent
9624 IEEE infinite and Nan values are produced as appropriate.
9625
9626 @sp 1
9627 @cartouche
9628 @noindent
9629 @strong{129}.  The value of the angle threshold, within which certain
9630 elementary functions, complex arithmetic operations, and complex
9631 elementary functions yield results conforming to a maximum relative
9632 error bound.  See G.2.4(10).
9633 @end cartouche
9634 @noindent
9635 Information on this subject is not yet available.
9636
9637 @sp 1
9638 @cartouche
9639 @noindent
9640 @strong{130}.  The accuracy of certain elementary functions for
9641 parameters beyond the angle threshold.  See G.2.4(10).
9642 @end cartouche
9643 @noindent
9644 Information on this subject is not yet available.
9645
9646 @sp 1
9647 @cartouche
9648 @noindent
9649 @strong{131}.  The result of a complex arithmetic operation or complex
9650 elementary function reference in overflow situations, when the
9651 @code{Machine_Overflows} attribute of the corresponding real type is
9652 @code{False}.  See G.2.6(5).
9653 @end cartouche
9654 @noindent
9655 IEEE infinite and Nan values are produced as appropriate.
9656
9657 @sp 1
9658 @cartouche
9659 @noindent
9660 @strong{132}.  The accuracy of certain complex arithmetic operations and
9661 certain complex elementary functions for parameters (or components
9662 thereof) beyond the angle threshold.  See G.2.6(8).
9663 @end cartouche
9664 @noindent
9665 Information on those subjects is not yet available.
9666
9667 @sp 1
9668 @cartouche
9669 @noindent
9670 @strong{133}.  Information regarding bounded errors and erroneous
9671 execution.  See H.2(1).
9672 @end cartouche
9673 @noindent
9674 Information on this subject is not yet available.
9675
9676 @sp 1
9677 @cartouche
9678 @noindent
9679 @strong{134}.  Implementation-defined aspects of pragma
9680 @code{Inspection_Point}.  See H.3.2(8).
9681 @end cartouche
9682 @noindent
9683 Pragma @code{Inspection_Point} ensures that the variable is live and can
9684 be examined by the debugger at the inspection point.
9685
9686 @sp 1
9687 @cartouche
9688 @noindent
9689 @strong{135}.  Implementation-defined aspects of pragma
9690 @code{Restrictions}.  See H.4(25).
9691 @end cartouche
9692 @noindent
9693 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9694 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9695 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9696
9697 @sp 1
9698 @cartouche
9699 @noindent
9700 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9701 H.4(27).
9702 @end cartouche
9703 @noindent
9704 There are no restrictions on pragma @code{Restrictions}.
9705
9706 @node Intrinsic Subprograms
9707 @chapter Intrinsic Subprograms
9708 @cindex Intrinsic Subprograms
9709
9710 @menu
9711 * Intrinsic Operators::
9712 * Enclosing_Entity::
9713 * Exception_Information::
9714 * Exception_Message::
9715 * Exception_Name::
9716 * File::
9717 * Line::
9718 * Rotate_Left::
9719 * Rotate_Right::
9720 * Shift_Left::
9721 * Shift_Right::
9722 * Shift_Right_Arithmetic::
9723 * Source_Location::
9724 @end menu
9725
9726 @noindent
9727 GNAT allows a user application program to write the declaration:
9728
9729 @smallexample @c ada
9730    pragma Import (Intrinsic, name);
9731 @end smallexample
9732
9733 @noindent
9734 providing that the name corresponds to one of the implemented intrinsic
9735 subprograms in GNAT, and that the parameter profile of the referenced
9736 subprogram meets the requirements.  This chapter describes the set of
9737 implemented intrinsic subprograms, and the requirements on parameter profiles.
9738 Note that no body is supplied; as with other uses of pragma Import, the
9739 body is supplied elsewhere (in this case by the compiler itself).  Note
9740 that any use of this feature is potentially non-portable, since the
9741 Ada standard does not require Ada compilers to implement this feature.
9742
9743 @node Intrinsic Operators
9744 @section Intrinsic Operators
9745 @cindex Intrinsic operator
9746
9747 @noindent
9748 All the predefined numeric operators in package Standard
9749 in @code{pragma Import (Intrinsic,..)}
9750 declarations.  In the binary operator case, the operands must have the same
9751 size.  The operand or operands must also be appropriate for
9752 the operator.  For example, for addition, the operands must
9753 both be floating-point or both be fixed-point, and the
9754 right operand for @code{"**"} must have a root type of
9755 @code{Standard.Integer'Base}.
9756 You can use an intrinsic operator declaration as in the following example:
9757
9758 @smallexample @c ada
9759    type Int1 is new Integer;
9760    type Int2 is new Integer;
9761
9762    function "+" (X1 : Int1; X2 : Int2) return Int1;
9763    function "+" (X1 : Int1; X2 : Int2) return Int2;
9764    pragma Import (Intrinsic, "+");
9765 @end smallexample
9766
9767 @noindent
9768 This declaration would permit ``mixed mode'' arithmetic on items
9769 of the differing types @code{Int1} and @code{Int2}.
9770 It is also possible to specify such operators for private types, if the
9771 full views are appropriate arithmetic types.
9772
9773 @node Enclosing_Entity
9774 @section Enclosing_Entity
9775 @cindex Enclosing_Entity
9776 @noindent
9777 This intrinsic subprogram is used in the implementation of the
9778 library routine @code{GNAT.Source_Info}.  The only useful use of the
9779 intrinsic import in this case is the one in this unit, so an
9780 application program should simply call the function
9781 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9782 the current subprogram, package, task, entry, or protected subprogram.
9783
9784 @node Exception_Information
9785 @section Exception_Information
9786 @cindex Exception_Information'
9787 @noindent
9788 This intrinsic subprogram is used in the implementation of the
9789 library routine @code{GNAT.Current_Exception}.  The only useful
9790 use of the intrinsic import in this case is the one in this unit,
9791 so an application program should simply call the function
9792 @code{GNAT.Current_Exception.Exception_Information} to obtain
9793 the exception information associated with the current exception.
9794
9795 @node Exception_Message
9796 @section Exception_Message
9797 @cindex Exception_Message
9798 @noindent
9799 This intrinsic subprogram is used in the implementation of the
9800 library routine @code{GNAT.Current_Exception}.  The only useful
9801 use of the intrinsic import in this case is the one in this unit,
9802 so an application program should simply call the function
9803 @code{GNAT.Current_Exception.Exception_Message} to obtain
9804 the message associated with the current exception.
9805
9806 @node Exception_Name
9807 @section Exception_Name
9808 @cindex Exception_Name
9809 @noindent
9810 This intrinsic subprogram is used in the implementation of the
9811 library routine @code{GNAT.Current_Exception}.  The only useful
9812 use of the intrinsic import in this case is the one in this unit,
9813 so an application program should simply call the function
9814 @code{GNAT.Current_Exception.Exception_Name} to obtain
9815 the name of the current exception.
9816
9817 @node File
9818 @section File
9819 @cindex File
9820 @noindent
9821 This intrinsic subprogram is used in the implementation of the
9822 library routine @code{GNAT.Source_Info}.  The only useful use of the
9823 intrinsic import in this case is the one in this unit, so an
9824 application program should simply call the function
9825 @code{GNAT.Source_Info.File} to obtain the name of the current
9826 file.
9827
9828 @node Line
9829 @section Line
9830 @cindex Line
9831 @noindent
9832 This intrinsic subprogram is used in the implementation of the
9833 library routine @code{GNAT.Source_Info}.  The only useful use of the
9834 intrinsic import in this case is the one in this unit, so an
9835 application program should simply call the function
9836 @code{GNAT.Source_Info.Line} to obtain the number of the current
9837 source line.
9838
9839 @node Rotate_Left
9840 @section Rotate_Left
9841 @cindex Rotate_Left
9842 @noindent
9843 In standard Ada, the @code{Rotate_Left} function is available only
9844 for the predefined modular types in package @code{Interfaces}.  However, in
9845 GNAT it is possible to define a Rotate_Left function for a user
9846 defined modular type or any signed integer type as in this example:
9847
9848 @smallexample @c ada
9849    function Shift_Left
9850      (Value  : My_Modular_Type;
9851       Amount : Natural)
9852       return   My_Modular_Type;
9853 @end smallexample
9854
9855 @noindent
9856 The requirements are that the profile be exactly as in the example
9857 above.  The only modifications allowed are in the formal parameter
9858 names, and in the type of @code{Value} and the return type, which
9859 must be the same, and must be either a signed integer type, or
9860 a modular integer type with a binary modulus, and the size must
9861 be 8.  16, 32 or 64 bits.
9862
9863 @node Rotate_Right
9864 @section Rotate_Right
9865 @cindex Rotate_Right
9866 @noindent
9867 A @code{Rotate_Right} function can be defined for any user defined
9868 binary modular integer type, or signed integer type, as described
9869 above for @code{Rotate_Left}.
9870
9871 @node Shift_Left
9872 @section Shift_Left
9873 @cindex Shift_Left
9874 @noindent
9875 A @code{Shift_Left} function can be defined for any user defined
9876 binary modular integer type, or signed integer type, as described
9877 above for @code{Rotate_Left}.
9878
9879 @node Shift_Right
9880 @section Shift_Right
9881 @cindex Shift_Right
9882 @noindent
9883 A @code{Shift_Right} function can be defined for any user defined
9884 binary modular integer type, or signed integer type, as described
9885 above for @code{Rotate_Left}.
9886
9887 @node Shift_Right_Arithmetic
9888 @section Shift_Right_Arithmetic
9889 @cindex Shift_Right_Arithmetic
9890 @noindent
9891 A @code{Shift_Right_Arithmetic} function can be defined for any user
9892 defined binary modular integer type, or signed integer type, as described
9893 above for @code{Rotate_Left}.
9894
9895 @node Source_Location
9896 @section Source_Location
9897 @cindex Source_Location
9898 @noindent
9899 This intrinsic subprogram is used in the implementation of the
9900 library routine @code{GNAT.Source_Info}.  The only useful use of the
9901 intrinsic import in this case is the one in this unit, so an
9902 application program should simply call the function
9903 @code{GNAT.Source_Info.Source_Location} to obtain the current
9904 source file location.
9905
9906 @node Representation Clauses and Pragmas
9907 @chapter Representation Clauses and Pragmas
9908 @cindex Representation Clauses
9909
9910 @menu
9911 * Alignment Clauses::
9912 * Size Clauses::
9913 * Storage_Size Clauses::
9914 * Size of Variant Record Objects::
9915 * Biased Representation ::
9916 * Value_Size and Object_Size Clauses::
9917 * Component_Size Clauses::
9918 * Bit_Order Clauses::
9919 * Effect of Bit_Order on Byte Ordering::
9920 * Pragma Pack for Arrays::
9921 * Pragma Pack for Records::
9922 * Record Representation Clauses::
9923 * Enumeration Clauses::
9924 * Address Clauses::
9925 * Effect of Convention on Representation::
9926 * Determining the Representations chosen by GNAT::
9927 @end menu
9928
9929 @noindent
9930 @cindex Representation Clause
9931 @cindex Representation Pragma
9932 @cindex Pragma, representation
9933 This section describes the representation clauses accepted by GNAT, and
9934 their effect on the representation of corresponding data objects.
9935
9936 GNAT fully implements Annex C (Systems Programming).  This means that all
9937 the implementation advice sections in chapter 13 are fully implemented.
9938 However, these sections only require a minimal level of support for
9939 representation clauses.  GNAT provides much more extensive capabilities,
9940 and this section describes the additional capabilities provided.
9941
9942 @node Alignment Clauses
9943 @section Alignment Clauses
9944 @cindex Alignment Clause
9945
9946 @noindent
9947 GNAT requires that all alignment clauses specify a power of 2, and all
9948 default alignments are always a power of 2.  The default alignment
9949 values are as follows:
9950
9951 @itemize @bullet
9952 @item @emph{Primitive Types}.
9953 For primitive types, the alignment is the minimum of the actual size of
9954 objects of the type divided by @code{Storage_Unit},
9955 and the maximum alignment supported by the target.
9956 (This maximum alignment is given by the GNAT-specific attribute
9957 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9958 @cindex @code{Maximum_Alignment} attribute
9959 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9960 default alignment will be 8 on any target that supports alignments
9961 this large, but on some targets, the maximum alignment may be smaller
9962 than 8, in which case objects of type @code{Long_Float} will be maximally
9963 aligned.
9964
9965 @item @emph{Arrays}.
9966 For arrays, the alignment is equal to the alignment of the component type
9967 for the normal case where no packing or component size is given.  If the
9968 array is packed, and the packing is effective (see separate section on
9969 packed arrays), then the alignment will be one for long packed arrays,
9970 or arrays whose length is not known at compile time.  For short packed
9971 arrays, which are handled internally as modular types, the alignment
9972 will be as described for primitive types, e.g.@: a packed array of length
9973 31 bits will have an object size of four bytes, and an alignment of 4.
9974
9975 @item @emph{Records}.
9976 For the normal non-packed case, the alignment of a record is equal to
9977 the maximum alignment of any of its components.  For tagged records, this
9978 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9979 is used and all components are packable (see separate section on pragma
9980 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9981 record makes it profitable to increase it.
9982
9983 A special case is when:
9984 @itemize @bullet
9985 @item
9986 the size of the record is given explicitly, or a
9987 full record representation clause is given, and
9988 @item
9989 the size of the record is 2, 4, or 8 bytes.
9990 @end itemize
9991 @noindent
9992 In this case, an alignment is chosen to match the
9993 size of the record. For example, if we have:
9994
9995 @smallexample @c ada
9996    type Small is record
9997       A, B : Character;
9998    end record;
9999    for Small'Size use 16;
10000 @end smallexample
10001
10002 @noindent
10003 then the default alignment of the record type @code{Small} is 2, not 1. This
10004 leads to more efficient code when the record is treated as a unit, and also
10005 allows the type to specified as @code{Atomic} on architectures requiring
10006 strict alignment.
10007
10008 @end itemize
10009
10010 @noindent
10011 An alignment clause may specify a larger alignment than the default value
10012 up to some maximum value dependent on the target (obtainable by using the
10013 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10014 a smaller alignment than the default value for enumeration, integer and
10015 fixed point types, as well as for record types, for example
10016
10017 @smallexample @c ada
10018   type V is record
10019      A : Integer;
10020   end record;
10021
10022   for V'alignment use 1;
10023 @end smallexample
10024
10025 @noindent
10026 @cindex Alignment, default
10027 The default alignment for the type @code{V} is 4, as a result of the
10028 Integer field in the record, but it is permissible, as shown, to
10029 override the default alignment of the record with a smaller value.
10030
10031 @node Size Clauses
10032 @section Size Clauses
10033 @cindex Size Clause
10034
10035 @noindent
10036 The default size for a type @code{T} is obtainable through the
10037 language-defined attribute @code{T'Size} and also through the
10038 equivalent GNAT-defined attribute @code{T'Value_Size}.
10039 For objects of type @code{T}, GNAT will generally increase the type size
10040 so that the object size (obtainable through the GNAT-defined attribute
10041 @code{T'Object_Size})
10042 is a multiple of @code{T'Alignment * Storage_Unit}.
10043 For example
10044
10045 @smallexample @c ada
10046    type Smallint is range 1 .. 6;
10047
10048    type Rec is record
10049       Y1 : integer;
10050       Y2 : boolean;
10051    end record;
10052 @end smallexample
10053
10054 @noindent
10055 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10056 as specified by the RM rules,
10057 but objects of this type will have a size of 8
10058 (@code{Smallint'Object_Size} = 8),
10059 since objects by default occupy an integral number
10060 of storage units.  On some targets, notably older
10061 versions of the Digital Alpha, the size of stand
10062 alone objects of this type may be 32, reflecting
10063 the inability of the hardware to do byte load/stores.
10064
10065 Similarly, the size of type @code{Rec} is 40 bits
10066 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10067 the alignment is 4, so objects of this type will have
10068 their size increased to 64 bits so that it is a multiple
10069 of the alignment (in bits).  This decision is
10070 in accordance with the specific Implementation Advice in RM 13.3(43):
10071
10072 @quotation
10073 A @code{Size} clause should be supported for an object if the specified
10074 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10075 to a size in storage elements that is a multiple of the object's
10076 @code{Alignment} (if the @code{Alignment} is nonzero).
10077 @end quotation
10078
10079 @noindent
10080 An explicit size clause may be used to override the default size by
10081 increasing it.  For example, if we have:
10082
10083 @smallexample @c ada
10084    type My_Boolean is new Boolean;
10085    for My_Boolean'Size use 32;
10086 @end smallexample
10087
10088 @noindent
10089 then values of this type will always be 32 bits long.  In the case of
10090 discrete types, the size can be increased up to 64 bits, with the effect
10091 that the entire specified field is used to hold the value, sign- or
10092 zero-extended as appropriate.  If more than 64 bits is specified, then
10093 padding space is allocated after the value, and a warning is issued that
10094 there are unused bits.
10095
10096 Similarly the size of records and arrays may be increased, and the effect
10097 is to add padding bits after the value.  This also causes a warning message
10098 to be generated.
10099
10100 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10101 Size in bits, this corresponds to an object of size 256 megabytes (minus
10102 one).  This limitation is true on all targets.  The reason for this
10103 limitation is that it improves the quality of the code in many cases
10104 if it is known that a Size value can be accommodated in an object of
10105 type Integer.
10106
10107 @node Storage_Size Clauses
10108 @section Storage_Size Clauses
10109 @cindex Storage_Size Clause
10110
10111 @noindent
10112 For tasks, the @code{Storage_Size} clause specifies the amount of space
10113 to be allocated for the task stack.  This cannot be extended, and if the
10114 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10115 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10116 or a @code{Storage_Size} pragma in the task definition to set the
10117 appropriate required size.  A useful technique is to include in every
10118 task definition a pragma of the form:
10119
10120 @smallexample @c ada
10121    pragma Storage_Size (Default_Stack_Size);
10122 @end smallexample
10123
10124 @noindent
10125 Then @code{Default_Stack_Size} can be defined in a global package, and
10126 modified as required. Any tasks requiring stack sizes different from the
10127 default can have an appropriate alternative reference in the pragma.
10128
10129 You can also use the @option{-d} binder switch to modify the default stack
10130 size.
10131
10132 For access types, the @code{Storage_Size} clause specifies the maximum
10133 space available for allocation of objects of the type.  If this space is
10134 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10135 In the case where the access type is declared local to a subprogram, the
10136 use of a @code{Storage_Size} clause triggers automatic use of a special
10137 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10138 space for the pool is automatically reclaimed on exit from the scope in
10139 which the type is declared.
10140
10141 A special case recognized by the compiler is the specification of a
10142 @code{Storage_Size} of zero for an access type.  This means that no
10143 items can be allocated from the pool, and this is recognized at compile
10144 time, and all the overhead normally associated with maintaining a fixed
10145 size storage pool is eliminated.  Consider the following example:
10146
10147 @smallexample @c ada
10148    procedure p is
10149       type R is array (Natural) of Character;
10150       type P is access all R;
10151       for P'Storage_Size use 0;
10152       --  Above access type intended only for interfacing purposes
10153
10154       y : P;
10155
10156       procedure g (m : P);
10157       pragma Import (C, g);
10158
10159       --  @dots{}
10160
10161    begin
10162       --  @dots{}
10163       y := new R;
10164    end;
10165 @end smallexample
10166
10167 @noindent
10168 As indicated in this example, these dummy storage pools are often useful in
10169 connection with interfacing where no object will ever be allocated.  If you
10170 compile the above example, you get the warning:
10171
10172 @smallexample
10173    p.adb:16:09: warning: allocation from empty storage pool
10174    p.adb:16:09: warning: Storage_Error will be raised at run time
10175 @end smallexample
10176
10177 @noindent
10178 Of course in practice, there will not be any explicit allocators in the
10179 case of such an access declaration.
10180
10181 @node Size of Variant Record Objects
10182 @section Size of Variant Record Objects
10183 @cindex Size, variant record objects
10184 @cindex Variant record objects, size
10185
10186 @noindent
10187 In the case of variant record objects, there is a question whether Size gives
10188 information about a particular variant, or the maximum size required
10189 for any variant.  Consider the following program
10190
10191 @smallexample @c ada
10192 with Text_IO; use Text_IO;
10193 procedure q is
10194    type R1 (A : Boolean := False) is record
10195      case A is
10196        when True  => X : Character;
10197        when False => null;
10198      end case;
10199    end record;
10200
10201    V1 : R1 (False);
10202    V2 : R1;
10203
10204 begin
10205    Put_Line (Integer'Image (V1'Size));
10206    Put_Line (Integer'Image (V2'Size));
10207 end q;
10208 @end smallexample
10209
10210 @noindent
10211 Here we are dealing with a variant record, where the True variant
10212 requires 16 bits, and the False variant requires 8 bits.
10213 In the above example, both V1 and V2 contain the False variant,
10214 which is only 8 bits long.  However, the result of running the
10215 program is:
10216
10217 @smallexample
10218 8
10219 16
10220 @end smallexample
10221
10222 @noindent
10223 The reason for the difference here is that the discriminant value of
10224 V1 is fixed, and will always be False.  It is not possible to assign
10225 a True variant value to V1, therefore 8 bits is sufficient.  On the
10226 other hand, in the case of V2, the initial discriminant value is
10227 False (from the default), but it is possible to assign a True
10228 variant value to V2, therefore 16 bits must be allocated for V2
10229 in the general case, even fewer bits may be needed at any particular
10230 point during the program execution.
10231
10232 As can be seen from the output of this program, the @code{'Size}
10233 attribute applied to such an object in GNAT gives the actual allocated
10234 size of the variable, which is the largest size of any of the variants.
10235 The Ada Reference Manual is not completely clear on what choice should
10236 be made here, but the GNAT behavior seems most consistent with the
10237 language in the RM@.
10238
10239 In some cases, it may be desirable to obtain the size of the current
10240 variant, rather than the size of the largest variant.  This can be
10241 achieved in GNAT by making use of the fact that in the case of a
10242 subprogram parameter, GNAT does indeed return the size of the current
10243 variant (because a subprogram has no way of knowing how much space
10244 is actually allocated for the actual).
10245
10246 Consider the following modified version of the above program:
10247
10248 @smallexample @c ada
10249 with Text_IO; use Text_IO;
10250 procedure q is
10251    type R1 (A : Boolean := False) is record
10252      case A is
10253        when True  => X : Character;
10254        when False => null;
10255      end case;
10256    end record;
10257
10258    V2 : R1;
10259
10260    function Size (V : R1) return Integer is
10261    begin
10262       return V'Size;
10263    end Size;
10264
10265 begin
10266    Put_Line (Integer'Image (V2'Size));
10267    Put_Line (Integer'IMage (Size (V2)));
10268    V2 := (True, 'x');
10269    Put_Line (Integer'Image (V2'Size));
10270    Put_Line (Integer'IMage (Size (V2)));
10271 end q;
10272 @end smallexample
10273
10274 @noindent
10275 The output from this program is
10276
10277 @smallexample
10278 16
10279 8
10280 16
10281 16
10282 @end smallexample
10283
10284 @noindent
10285 Here we see that while the @code{'Size} attribute always returns
10286 the maximum size, regardless of the current variant value, the
10287 @code{Size} function does indeed return the size of the current
10288 variant value.
10289
10290 @node Biased Representation
10291 @section Biased Representation
10292 @cindex Size for biased representation
10293 @cindex Biased representation
10294
10295 @noindent
10296 In the case of scalars with a range starting at other than zero, it is
10297 possible in some cases to specify a size smaller than the default minimum
10298 value, and in such cases, GNAT uses an unsigned biased representation,
10299 in which zero is used to represent the lower bound, and successive values
10300 represent successive values of the type.
10301
10302 For example, suppose we have the declaration:
10303
10304 @smallexample @c ada
10305    type Small is range -7 .. -4;
10306    for Small'Size use 2;
10307 @end smallexample
10308
10309 @noindent
10310 Although the default size of type @code{Small} is 4, the @code{Size}
10311 clause is accepted by GNAT and results in the following representation
10312 scheme:
10313
10314 @smallexample
10315   -7 is represented as 2#00#
10316   -6 is represented as 2#01#
10317   -5 is represented as 2#10#
10318   -4 is represented as 2#11#
10319 @end smallexample
10320
10321 @noindent
10322 Biased representation is only used if the specified @code{Size} clause
10323 cannot be accepted in any other manner.  These reduced sizes that force
10324 biased representation can be used for all discrete types except for
10325 enumeration types for which a representation clause is given.
10326
10327 @node Value_Size and Object_Size Clauses
10328 @section Value_Size and Object_Size Clauses
10329 @findex Value_Size
10330 @findex Object_Size
10331 @cindex Size, of objects
10332
10333 @noindent
10334 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10335 number of bits required to hold values of type @code{T}.
10336 Although this interpretation was allowed in Ada 83, it was not required,
10337 and this requirement in practice can cause some significant difficulties.
10338 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10339 However, in Ada 95 and Ada 2005,
10340 @code{Natural'Size} is
10341 typically 31.  This means that code may change in behavior when moving
10342 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10343
10344 @smallexample @c ada
10345    type Rec is record;
10346       A : Natural;
10347       B : Natural;
10348    end record;
10349
10350    for Rec use record
10351       at 0  range 0 .. Natural'Size - 1;
10352       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10353    end record;
10354 @end smallexample
10355
10356 @noindent
10357 In the above code, since the typical size of @code{Natural} objects
10358 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10359 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10360 there are cases where the fact that the object size can exceed the
10361 size of the type causes surprises.
10362
10363 To help get around this problem GNAT provides two implementation
10364 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10365 applied to a type, these attributes yield the size of the type
10366 (corresponding to the RM defined size attribute), and the size of
10367 objects of the type respectively.
10368
10369 The @code{Object_Size} is used for determining the default size of
10370 objects and components.  This size value can be referred to using the
10371 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10372 the basis of the determination of the size.  The backend is free to
10373 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10374 character might be stored in 32 bits on a machine with no efficient
10375 byte access instructions such as the Alpha.
10376
10377 The default rules for the value of @code{Object_Size} for
10378 discrete types are as follows:
10379
10380 @itemize @bullet
10381 @item
10382 The @code{Object_Size} for base subtypes reflect the natural hardware
10383 size in bits (run the compiler with @option{-gnatS} to find those values
10384 for numeric types). Enumeration types and fixed-point base subtypes have
10385 8, 16, 32 or 64 bits for this size, depending on the range of values
10386 to be stored.
10387
10388 @item
10389 The @code{Object_Size} of a subtype is the same as the
10390 @code{Object_Size} of
10391 the type from which it is obtained.
10392
10393 @item
10394 The @code{Object_Size} of a derived base type is copied from the parent
10395 base type, and the @code{Object_Size} of a derived first subtype is copied
10396 from the parent first subtype.
10397 @end itemize
10398
10399 @noindent
10400 The @code{Value_Size} attribute
10401 is the (minimum) number of bits required to store a value
10402 of the type.
10403 This value is used to determine how tightly to pack
10404 records or arrays with components of this type, and also affects
10405 the semantics of unchecked conversion (unchecked conversions where
10406 the @code{Value_Size} values differ generate a warning, and are potentially
10407 target dependent).
10408
10409 The default rules for the value of @code{Value_Size} are as follows:
10410
10411 @itemize @bullet
10412 @item
10413 The @code{Value_Size} for a base subtype is the minimum number of bits
10414 required to store all values of the type (including the sign bit
10415 only if negative values are possible).
10416
10417 @item
10418 If a subtype statically matches the first subtype of a given type, then it has
10419 by default the same @code{Value_Size} as the first subtype.  This is a
10420 consequence of RM 13.1(14) (``if two subtypes statically match,
10421 then their subtype-specific aspects are the same''.)
10422
10423 @item
10424 All other subtypes have a @code{Value_Size} corresponding to the minimum
10425 number of bits required to store all values of the subtype.  For
10426 dynamic bounds, it is assumed that the value can range down or up
10427 to the corresponding bound of the ancestor
10428 @end itemize
10429
10430 @noindent
10431 The RM defined attribute @code{Size} corresponds to the
10432 @code{Value_Size} attribute.
10433
10434 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10435 the @code{Value_Size} of
10436 the first-named subtype to the given value, and the
10437 @code{Object_Size} of this first-named subtype to the given value padded up
10438 to an appropriate boundary.  It is a consequence of the default rules
10439 above that this @code{Object_Size} will apply to all further subtypes.  On the
10440 other hand, @code{Value_Size} is affected only for the first subtype, any
10441 dynamic subtypes obtained from it directly, and any statically matching
10442 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10443
10444 @code{Value_Size} and
10445 @code{Object_Size} may be explicitly set for any subtype using
10446 an attribute definition clause.  Note that the use of these attributes
10447 can cause the RM 13.1(14) rule to be violated.  If two access types
10448 reference aliased objects whose subtypes have differing @code{Object_Size}
10449 values as a result of explicit attribute definition clauses, then it
10450 is erroneous to convert from one access subtype to the other.
10451
10452 At the implementation level, Esize stores the Object_Size and the
10453 RM_Size field stores the @code{Value_Size} (and hence the value of the
10454 @code{Size} attribute,
10455 which, as noted above, is equivalent to @code{Value_Size}).
10456
10457 To get a feel for the difference, consider the following examples (note
10458 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10459
10460 @smallexample
10461                                        Object_Size     Value_Size
10462
10463 type x1 is range 0 .. 5;                    8               3
10464
10465 type x2 is range 0 .. 5;
10466 for x2'size use 12;                        16              12
10467
10468 subtype x3 is x2 range 0 .. 3;             16               2
10469
10470 subtype x4 is x2'base range 0 .. 10;        8               4
10471
10472 subtype x5 is x2 range 0 .. dynamic;       16               3*
10473
10474 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10475
10476 @end smallexample
10477
10478 @noindent
10479 Note: the entries marked ``3*'' are not actually specified by the Ada
10480 Reference Manual, but it seems in the spirit of the RM rules to allocate
10481 the minimum number of bits (here 3, given the range for @code{x2})
10482 known to be large enough to hold the given range of values.
10483
10484 So far, so good, but GNAT has to obey the RM rules, so the question is
10485 under what conditions must the RM @code{Size} be used.
10486 The following is a list
10487 of the occasions on which the RM @code{Size} must be used:
10488
10489 @itemize @bullet
10490 @item
10491 Component size for packed arrays or records
10492
10493 @item
10494 Value of the attribute @code{Size} for a type
10495
10496 @item
10497 Warning about sizes not matching for unchecked conversion
10498 @end itemize
10499
10500 @noindent
10501 For record types, the @code{Object_Size} is always a multiple of the
10502 alignment of the type (this is true for all types). In some cases the
10503 @code{Value_Size} can be smaller. Consider:
10504
10505 @smallexample
10506    type R is record
10507      X : Integer;
10508      Y : Character;
10509    end record;
10510 @end smallexample
10511
10512 @noindent
10513 On a typical 32-bit architecture, the X component will be four bytes, and
10514 require four-byte alignment, and the Y component will be one byte. In this
10515 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10516 required to store a value of this type, and for example, it is permissible
10517 to have a component of type R in an outer array whose component size is
10518 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10519 since it must be rounded up so that this value is a multiple of the
10520 alignment (4 bytes = 32 bits).
10521
10522 @noindent
10523 For all other types, the @code{Object_Size}
10524 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10525 Only @code{Size} may be specified for such types.
10526
10527 @node Component_Size Clauses
10528 @section Component_Size Clauses
10529 @cindex Component_Size Clause
10530
10531 @noindent
10532 Normally, the value specified in a component size clause must be consistent
10533 with the subtype of the array component with regard to size and alignment.
10534 In other words, the value specified must be at least equal to the size
10535 of this subtype, and must be a multiple of the alignment value.
10536
10537 In addition, component size clauses are allowed which cause the array
10538 to be packed, by specifying a smaller value.  A first case is for
10539 component size values in the range 1 through 63.  The value specified
10540 must not be smaller than the Size of the subtype.  GNAT will accurately
10541 honor all packing requests in this range.  For example, if we have:
10542
10543 @smallexample @c ada
10544 type r is array (1 .. 8) of Natural;
10545 for r'Component_Size use 31;
10546 @end smallexample
10547
10548 @noindent
10549 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10550 Of course access to the components of such an array is considerably
10551 less efficient than if the natural component size of 32 is used.
10552 A second case is when the subtype of the component is a record type
10553 padded because of its default alignment.  For example, if we have:
10554
10555 @smallexample @c ada
10556 type r is record
10557   i : Integer;
10558   j : Integer;
10559   b : Boolean;
10560 end record;
10561
10562 type a is array (1 .. 8) of r;
10563 for a'Component_Size use 72;
10564 @end smallexample
10565
10566 @noindent
10567 then the resulting array has a length of 72 bytes, instead of 96 bytes
10568 if the alignment of the record (4) was obeyed.
10569
10570 Note that there is no point in giving both a component size clause
10571 and a pragma Pack for the same array type. if such duplicate
10572 clauses are given, the pragma Pack will be ignored.
10573
10574 @node Bit_Order Clauses
10575 @section Bit_Order Clauses
10576 @cindex Bit_Order Clause
10577 @cindex bit ordering
10578 @cindex ordering, of bits
10579
10580 @noindent
10581 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10582 attribute.  The specification may either correspond to the default bit
10583 order for the target, in which case the specification has no effect and
10584 places no additional restrictions, or it may be for the non-standard
10585 setting (that is the opposite of the default).
10586
10587 In the case where the non-standard value is specified, the effect is
10588 to renumber bits within each byte, but the ordering of bytes is not
10589 affected.  There are certain
10590 restrictions placed on component clauses as follows:
10591
10592 @itemize @bullet
10593
10594 @item Components fitting within a single storage unit.
10595 @noindent
10596 These are unrestricted, and the effect is merely to renumber bits.  For
10597 example if we are on a little-endian machine with @code{Low_Order_First}
10598 being the default, then the following two declarations have exactly
10599 the same effect:
10600
10601 @smallexample @c ada
10602    type R1 is record
10603       A : Boolean;
10604       B : Integer range 1 .. 120;
10605    end record;
10606
10607    for R1 use record
10608       A at 0 range 0 .. 0;
10609       B at 0 range 1 .. 7;
10610    end record;
10611
10612    type R2 is record
10613       A : Boolean;
10614       B : Integer range 1 .. 120;
10615    end record;
10616
10617    for R2'Bit_Order use High_Order_First;
10618
10619    for R2 use record
10620       A at 0 range 7 .. 7;
10621       B at 0 range 0 .. 6;
10622    end record;
10623 @end smallexample
10624
10625 @noindent
10626 The useful application here is to write the second declaration with the
10627 @code{Bit_Order} attribute definition clause, and know that it will be treated
10628 the same, regardless of whether the target is little-endian or big-endian.
10629
10630 @item Components occupying an integral number of bytes.
10631 @noindent
10632 These are components that exactly fit in two or more bytes.  Such component
10633 declarations are allowed, but have no effect, since it is important to realize
10634 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10635 In particular, the following attempt at getting an endian-independent integer
10636 does not work:
10637
10638 @smallexample @c ada
10639    type R2 is record
10640       A : Integer;
10641    end record;
10642
10643    for R2'Bit_Order use High_Order_First;
10644
10645    for R2 use record
10646       A at 0 range 0 .. 31;
10647    end record;
10648 @end smallexample
10649
10650 @noindent
10651 This declaration will result in a little-endian integer on a
10652 little-endian machine, and a big-endian integer on a big-endian machine.
10653 If byte flipping is required for interoperability between big- and
10654 little-endian machines, this must be explicitly programmed.  This capability
10655 is not provided by @code{Bit_Order}.
10656
10657 @item Components that are positioned across byte boundaries
10658 @noindent
10659 but do not occupy an integral number of bytes.  Given that bytes are not
10660 reordered, such fields would occupy a non-contiguous sequence of bits
10661 in memory, requiring non-trivial code to reassemble.  They are for this
10662 reason not permitted, and any component clause specifying such a layout
10663 will be flagged as illegal by GNAT@.
10664
10665 @end itemize
10666
10667 @noindent
10668 Since the misconception that Bit_Order automatically deals with all
10669 endian-related incompatibilities is a common one, the specification of
10670 a component field that is an integral number of bytes will always
10671 generate a warning.  This warning may be suppressed using @code{pragma
10672 Warnings (Off)} if desired.  The following section contains additional
10673 details regarding the issue of byte ordering.
10674
10675 @node Effect of Bit_Order on Byte Ordering
10676 @section Effect of Bit_Order on Byte Ordering
10677 @cindex byte ordering
10678 @cindex ordering, of bytes
10679
10680 @noindent
10681 In this section we will review the effect of the @code{Bit_Order} attribute
10682 definition clause on byte ordering.  Briefly, it has no effect at all, but
10683 a detailed example will be helpful.  Before giving this
10684 example, let us review the precise
10685 definition of the effect of defining @code{Bit_Order}.  The effect of a
10686 non-standard bit order is described in section 15.5.3 of the Ada
10687 Reference Manual:
10688
10689 @quotation
10690 2   A bit ordering is a method of interpreting the meaning of
10691 the storage place attributes.
10692 @end quotation
10693
10694 @noindent
10695 To understand the precise definition of storage place attributes in
10696 this context, we visit section 13.5.1 of the manual:
10697
10698 @quotation
10699 13   A record_representation_clause (without the mod_clause)
10700 specifies the layout.  The storage place attributes (see 13.5.2)
10701 are taken from the values of the position, first_bit, and last_bit
10702 expressions after normalizing those values so that first_bit is
10703 less than Storage_Unit.
10704 @end quotation
10705
10706 @noindent
10707 The critical point here is that storage places are taken from
10708 the values after normalization, not before.  So the @code{Bit_Order}
10709 interpretation applies to normalized values.  The interpretation
10710 is described in the later part of the 15.5.3 paragraph:
10711
10712 @quotation
10713 2   A bit ordering is a method of interpreting the meaning of
10714 the storage place attributes.  High_Order_First (known in the
10715 vernacular as ``big endian'') means that the first bit of a
10716 storage element (bit 0) is the most significant bit (interpreting
10717 the sequence of bits that represent a component as an unsigned
10718 integer value).  Low_Order_First (known in the vernacular as
10719 ``little endian'') means the opposite: the first bit is the
10720 least significant.
10721 @end quotation
10722
10723 @noindent
10724 Note that the numbering is with respect to the bits of a storage
10725 unit.  In other words, the specification affects only the numbering
10726 of bits within a single storage unit.
10727
10728 We can make the effect clearer by giving an example.
10729
10730 Suppose that we have an external device which presents two bytes, the first
10731 byte presented, which is the first (low addressed byte) of the two byte
10732 record is called Master, and the second byte is called Slave.
10733
10734 The left most (most significant bit is called Control for each byte, and
10735 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10736 (least significant) bit.
10737
10738 On a big-endian machine, we can write the following representation clause
10739
10740 @smallexample @c ada
10741    type Data is record
10742       Master_Control : Bit;
10743       Master_V1      : Bit;
10744       Master_V2      : Bit;
10745       Master_V3      : Bit;
10746       Master_V4      : Bit;
10747       Master_V5      : Bit;
10748       Master_V6      : Bit;
10749       Master_V7      : Bit;
10750       Slave_Control  : Bit;
10751       Slave_V1       : Bit;
10752       Slave_V2       : Bit;
10753       Slave_V3       : Bit;
10754       Slave_V4       : Bit;
10755       Slave_V5       : Bit;
10756       Slave_V6       : Bit;
10757       Slave_V7       : Bit;
10758    end record;
10759
10760    for Data use record
10761       Master_Control at 0 range 0 .. 0;
10762       Master_V1      at 0 range 1 .. 1;
10763       Master_V2      at 0 range 2 .. 2;
10764       Master_V3      at 0 range 3 .. 3;
10765       Master_V4      at 0 range 4 .. 4;
10766       Master_V5      at 0 range 5 .. 5;
10767       Master_V6      at 0 range 6 .. 6;
10768       Master_V7      at 0 range 7 .. 7;
10769       Slave_Control  at 1 range 0 .. 0;
10770       Slave_V1       at 1 range 1 .. 1;
10771       Slave_V2       at 1 range 2 .. 2;
10772       Slave_V3       at 1 range 3 .. 3;
10773       Slave_V4       at 1 range 4 .. 4;
10774       Slave_V5       at 1 range 5 .. 5;
10775       Slave_V6       at 1 range 6 .. 6;
10776       Slave_V7       at 1 range 7 .. 7;
10777    end record;
10778 @end smallexample
10779
10780 @noindent
10781 Now if we move this to a little endian machine, then the bit ordering within
10782 the byte is backwards, so we have to rewrite the record rep clause as:
10783
10784 @smallexample @c ada
10785    for Data use record
10786       Master_Control at 0 range 7 .. 7;
10787       Master_V1      at 0 range 6 .. 6;
10788       Master_V2      at 0 range 5 .. 5;
10789       Master_V3      at 0 range 4 .. 4;
10790       Master_V4      at 0 range 3 .. 3;
10791       Master_V5      at 0 range 2 .. 2;
10792       Master_V6      at 0 range 1 .. 1;
10793       Master_V7      at 0 range 0 .. 0;
10794       Slave_Control  at 1 range 7 .. 7;
10795       Slave_V1       at 1 range 6 .. 6;
10796       Slave_V2       at 1 range 5 .. 5;
10797       Slave_V3       at 1 range 4 .. 4;
10798       Slave_V4       at 1 range 3 .. 3;
10799       Slave_V5       at 1 range 2 .. 2;
10800       Slave_V6       at 1 range 1 .. 1;
10801       Slave_V7       at 1 range 0 .. 0;
10802    end record;
10803 @end smallexample
10804
10805 @noindent
10806 It is a nuisance to have to rewrite the clause, especially if
10807 the code has to be maintained on both machines.  However,
10808 this is a case that we can handle with the
10809 @code{Bit_Order} attribute if it is implemented.
10810 Note that the implementation is not required on byte addressed
10811 machines, but it is indeed implemented in GNAT.
10812 This means that we can simply use the
10813 first record clause, together with the declaration
10814
10815 @smallexample @c ada
10816    for Data'Bit_Order use High_Order_First;
10817 @end smallexample
10818
10819 @noindent
10820 and the effect is what is desired, namely the layout is exactly the same,
10821 independent of whether the code is compiled on a big-endian or little-endian
10822 machine.
10823
10824 The important point to understand is that byte ordering is not affected.
10825 A @code{Bit_Order} attribute definition never affects which byte a field
10826 ends up in, only where it ends up in that byte.
10827 To make this clear, let us rewrite the record rep clause of the previous
10828 example as:
10829
10830 @smallexample @c ada
10831    for Data'Bit_Order use High_Order_First;
10832    for Data use record
10833       Master_Control at 0 range  0 .. 0;
10834       Master_V1      at 0 range  1 .. 1;
10835       Master_V2      at 0 range  2 .. 2;
10836       Master_V3      at 0 range  3 .. 3;
10837       Master_V4      at 0 range  4 .. 4;
10838       Master_V5      at 0 range  5 .. 5;
10839       Master_V6      at 0 range  6 .. 6;
10840       Master_V7      at 0 range  7 .. 7;
10841       Slave_Control  at 0 range  8 .. 8;
10842       Slave_V1       at 0 range  9 .. 9;
10843       Slave_V2       at 0 range 10 .. 10;
10844       Slave_V3       at 0 range 11 .. 11;
10845       Slave_V4       at 0 range 12 .. 12;
10846       Slave_V5       at 0 range 13 .. 13;
10847       Slave_V6       at 0 range 14 .. 14;
10848       Slave_V7       at 0 range 15 .. 15;
10849    end record;
10850 @end smallexample
10851
10852 @noindent
10853 This is exactly equivalent to saying (a repeat of the first example):
10854
10855 @smallexample @c ada
10856    for Data'Bit_Order use High_Order_First;
10857    for Data use record
10858       Master_Control at 0 range 0 .. 0;
10859       Master_V1      at 0 range 1 .. 1;
10860       Master_V2      at 0 range 2 .. 2;
10861       Master_V3      at 0 range 3 .. 3;
10862       Master_V4      at 0 range 4 .. 4;
10863       Master_V5      at 0 range 5 .. 5;
10864       Master_V6      at 0 range 6 .. 6;
10865       Master_V7      at 0 range 7 .. 7;
10866       Slave_Control  at 1 range 0 .. 0;
10867       Slave_V1       at 1 range 1 .. 1;
10868       Slave_V2       at 1 range 2 .. 2;
10869       Slave_V3       at 1 range 3 .. 3;
10870       Slave_V4       at 1 range 4 .. 4;
10871       Slave_V5       at 1 range 5 .. 5;
10872       Slave_V6       at 1 range 6 .. 6;
10873       Slave_V7       at 1 range 7 .. 7;
10874    end record;
10875 @end smallexample
10876
10877 @noindent
10878 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10879 field.  The storage place attributes are obtained by normalizing the
10880 values given so that the @code{First_Bit} value is less than 8.  After
10881 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10882 we specified in the other case.
10883
10884 Now one might expect that the @code{Bit_Order} attribute might affect
10885 bit numbering within the entire record component (two bytes in this
10886 case, thus affecting which byte fields end up in), but that is not
10887 the way this feature is defined, it only affects numbering of bits,
10888 not which byte they end up in.
10889
10890 Consequently it never makes sense to specify a starting bit number
10891 greater than 7 (for a byte addressable field) if an attribute
10892 definition for @code{Bit_Order} has been given, and indeed it
10893 may be actively confusing to specify such a value, so the compiler
10894 generates a warning for such usage.
10895
10896 If you do need to control byte ordering then appropriate conditional
10897 values must be used.  If in our example, the slave byte came first on
10898 some machines we might write:
10899
10900 @smallexample @c ada
10901    Master_Byte_First constant Boolean := @dots{};
10902
10903    Master_Byte : constant Natural :=
10904                    1 - Boolean'Pos (Master_Byte_First);
10905    Slave_Byte  : constant Natural :=
10906                    Boolean'Pos (Master_Byte_First);
10907
10908    for Data'Bit_Order use High_Order_First;
10909    for Data use record
10910       Master_Control at Master_Byte range 0 .. 0;
10911       Master_V1      at Master_Byte range 1 .. 1;
10912       Master_V2      at Master_Byte range 2 .. 2;
10913       Master_V3      at Master_Byte range 3 .. 3;
10914       Master_V4      at Master_Byte range 4 .. 4;
10915       Master_V5      at Master_Byte range 5 .. 5;
10916       Master_V6      at Master_Byte range 6 .. 6;
10917       Master_V7      at Master_Byte range 7 .. 7;
10918       Slave_Control  at Slave_Byte  range 0 .. 0;
10919       Slave_V1       at Slave_Byte  range 1 .. 1;
10920       Slave_V2       at Slave_Byte  range 2 .. 2;
10921       Slave_V3       at Slave_Byte  range 3 .. 3;
10922       Slave_V4       at Slave_Byte  range 4 .. 4;
10923       Slave_V5       at Slave_Byte  range 5 .. 5;
10924       Slave_V6       at Slave_Byte  range 6 .. 6;
10925       Slave_V7       at Slave_Byte  range 7 .. 7;
10926    end record;
10927 @end smallexample
10928
10929 @noindent
10930 Now to switch between machines, all that is necessary is
10931 to set the boolean constant @code{Master_Byte_First} in
10932 an appropriate manner.
10933
10934 @node Pragma Pack for Arrays
10935 @section Pragma Pack for Arrays
10936 @cindex Pragma Pack (for arrays)
10937
10938 @noindent
10939 Pragma @code{Pack} applied to an array has no effect unless the component type
10940 is packable.  For a component type to be packable, it must be one of the
10941 following cases:
10942
10943 @itemize @bullet
10944 @item
10945 Any scalar type
10946 @item
10947 Any type whose size is specified with a size clause
10948 @item
10949 Any packed array type with a static size
10950 @item
10951 Any record type padded because of its default alignment
10952 @end itemize
10953
10954 @noindent
10955 For all these cases, if the component subtype size is in the range
10956 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10957 component size were specified giving the component subtype size.
10958 For example if we have:
10959
10960 @smallexample @c ada
10961    type r is range 0 .. 17;
10962
10963    type ar is array (1 .. 8) of r;
10964    pragma Pack (ar);
10965 @end smallexample
10966
10967 @noindent
10968 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10969 and the size of the array @code{ar} will be exactly 40 bits.
10970
10971 Note that in some cases this rather fierce approach to packing can produce
10972 unexpected effects.  For example, in Ada 95 and Ada 2005,
10973 subtype @code{Natural} typically has a size of 31, meaning that if you
10974 pack an array of @code{Natural}, you get 31-bit
10975 close packing, which saves a few bits, but results in far less efficient
10976 access.  Since many other Ada compilers will ignore such a packing request,
10977 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10978 might not be what is intended.  You can easily remove this warning by
10979 using an explicit @code{Component_Size} setting instead, which never generates
10980 a warning, since the intention of the programmer is clear in this case.
10981
10982 GNAT treats packed arrays in one of two ways.  If the size of the array is
10983 known at compile time and is less than 64 bits, then internally the array
10984 is represented as a single modular type, of exactly the appropriate number
10985 of bits.  If the length is greater than 63 bits, or is not known at compile
10986 time, then the packed array is represented as an array of bytes, and the
10987 length is always a multiple of 8 bits.
10988
10989 Note that to represent a packed array as a modular type, the alignment must
10990 be suitable for the modular type involved. For example, on typical machines
10991 a 32-bit packed array will be represented by a 32-bit modular integer with
10992 an alignment of four bytes. If you explicitly override the default alignment
10993 with an alignment clause that is too small, the modular representation
10994 cannot be used. For example, consider the following set of declarations:
10995
10996 @smallexample @c ada
10997    type R is range 1 .. 3;
10998    type S is array (1 .. 31) of R;
10999    for S'Component_Size use 2;
11000    for S'Size use 62;
11001    for S'Alignment use 1;
11002 @end smallexample
11003
11004 @noindent
11005 If the alignment clause were not present, then a 62-bit modular
11006 representation would be chosen (typically with an alignment of 4 or 8
11007 bytes depending on the target). But the default alignment is overridden
11008 with the explicit alignment clause. This means that the modular
11009 representation cannot be used, and instead the array of bytes
11010 representation must be used, meaning that the length must be a multiple
11011 of 8. Thus the above set of declarations will result in a diagnostic
11012 rejecting the size clause and noting that the minimum size allowed is 64.
11013
11014 @cindex Pragma Pack (for type Natural)
11015 @cindex Pragma Pack warning
11016
11017 One special case that is worth noting occurs when the base type of the
11018 component size is 8/16/32 and the subtype is one bit less. Notably this
11019 occurs with subtype @code{Natural}. Consider:
11020
11021 @smallexample @c ada
11022    type Arr is array (1 .. 32) of Natural;
11023    pragma Pack (Arr);
11024 @end smallexample
11025
11026 @noindent
11027 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11028 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11029 Ada 83 compilers did not attempt 31 bit packing.
11030
11031 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11032 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11033 substantial unintended performance penalty when porting legacy Ada 83 code.
11034 To help prevent this, GNAT generates a warning in such cases. If you really
11035 want 31 bit packing in a case like this, you can set the component size
11036 explicitly:
11037
11038 @smallexample @c ada
11039    type Arr is array (1 .. 32) of Natural;
11040    for Arr'Component_Size use 31;
11041 @end smallexample
11042
11043 @noindent
11044 Here 31-bit packing is achieved as required, and no warning is generated,
11045 since in this case the programmer intention is clear.
11046
11047 @node Pragma Pack for Records
11048 @section Pragma Pack for Records
11049 @cindex Pragma Pack (for records)
11050
11051 @noindent
11052 Pragma @code{Pack} applied to a record will pack the components to reduce
11053 wasted space from alignment gaps and by reducing the amount of space
11054 taken by components.  We distinguish between @emph{packable} components and
11055 @emph{non-packable} components.
11056 Components of the following types are considered packable:
11057 @itemize @bullet
11058 @item
11059 All primitive types are packable.
11060
11061 @item
11062 Small packed arrays, whose size does not exceed 64 bits, and where the
11063 size is statically known at compile time, are represented internally
11064 as modular integers, and so they are also packable.
11065
11066 @end itemize
11067
11068 @noindent
11069 All packable components occupy the exact number of bits corresponding to
11070 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11071 can start on an arbitrary bit boundary.
11072
11073 All other types are non-packable, they occupy an integral number of
11074 storage units, and
11075 are placed at a boundary corresponding to their alignment requirements.
11076
11077 For example, consider the record
11078
11079 @smallexample @c ada
11080    type Rb1 is array (1 .. 13) of Boolean;
11081    pragma Pack (rb1);
11082
11083    type Rb2 is array (1 .. 65) of Boolean;
11084    pragma Pack (rb2);
11085
11086    type x2 is record
11087       l1 : Boolean;
11088       l2 : Duration;
11089       l3 : Float;
11090       l4 : Boolean;
11091       l5 : Rb1;
11092       l6 : Rb2;
11093    end record;
11094    pragma Pack (x2);
11095 @end smallexample
11096
11097 @noindent
11098 The representation for the record x2 is as follows:
11099
11100 @smallexample @c ada
11101 for x2'Size use 224;
11102 for x2 use record
11103    l1 at  0 range  0 .. 0;
11104    l2 at  0 range  1 .. 64;
11105    l3 at 12 range  0 .. 31;
11106    l4 at 16 range  0 .. 0;
11107    l5 at 16 range  1 .. 13;
11108    l6 at 18 range  0 .. 71;
11109 end record;
11110 @end smallexample
11111
11112 @noindent
11113 Studying this example, we see that the packable fields @code{l1}
11114 and @code{l2} are
11115 of length equal to their sizes, and placed at specific bit boundaries (and
11116 not byte boundaries) to
11117 eliminate padding.  But @code{l3} is of a non-packable float type, so
11118 it is on the next appropriate alignment boundary.
11119
11120 The next two fields are fully packable, so @code{l4} and @code{l5} are
11121 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11122 array that is longer than 64 bits, so it is itself non-packable.  Thus
11123 the @code{l6} field is aligned to the next byte boundary, and takes an
11124 integral number of bytes, i.e.@: 72 bits.
11125
11126 @node Record Representation Clauses
11127 @section Record Representation Clauses
11128 @cindex Record Representation Clause
11129
11130 @noindent
11131 Record representation clauses may be given for all record types, including
11132 types obtained by record extension.  Component clauses are allowed for any
11133 static component.  The restrictions on component clauses depend on the type
11134 of the component.
11135
11136 @cindex Component Clause
11137 For all components of an elementary type, the only restriction on component
11138 clauses is that the size must be at least the 'Size value of the type
11139 (actually the Value_Size).  There are no restrictions due to alignment,
11140 and such components may freely cross storage boundaries.
11141
11142 Packed arrays with a size up to and including 64 bits are represented
11143 internally using a modular type with the appropriate number of bits, and
11144 thus the same lack of restriction applies.  For example, if you declare:
11145
11146 @smallexample @c ada
11147    type R is array (1 .. 49) of Boolean;
11148    pragma Pack (R);
11149    for R'Size use 49;
11150 @end smallexample
11151
11152 @noindent
11153 then a component clause for a component of type R may start on any
11154 specified bit boundary, and may specify a value of 49 bits or greater.
11155
11156 For packed bit arrays that are longer than 64 bits, there are two
11157 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11158 including the important case of single bits or boolean values, then
11159 there are no limitations on placement of such components, and they
11160 may start and end at arbitrary bit boundaries.
11161
11162 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11163 an array of this type longer than 64 bits must always be placed on
11164 on a storage unit (byte) boundary and occupy an integral number
11165 of storage units (bytes). Any component clause that does not
11166 meet this requirement will be rejected.
11167
11168 Any aliased component, or component of an aliased type, must
11169 have its normal alignment and size. A component clause that
11170 does not meet this requirement will be rejected.
11171
11172 The tag field of a tagged type always occupies an address sized field at
11173 the start of the record.  No component clause may attempt to overlay this
11174 tag. When a tagged type appears as a component, the tag field must have
11175 proper alignment
11176
11177 In the case of a record extension T1, of a type T, no component clause applied
11178 to the type T1 can specify a storage location that would overlap the first
11179 T'Size bytes of the record.
11180
11181 For all other component types, including non-bit-packed arrays,
11182 the component can be placed at an arbitrary bit boundary,
11183 so for example, the following is permitted:
11184
11185 @smallexample @c ada
11186    type R is array (1 .. 10) of Boolean;
11187    for R'Size use 80;
11188
11189    type Q is record
11190       G, H : Boolean;
11191       L, M : R;
11192    end record;
11193
11194    for Q use record
11195       G at 0 range  0 ..   0;
11196       H at 0 range  1 ..   1;
11197       L at 0 range  2 ..  81;
11198       R at 0 range 82 .. 161;
11199    end record;
11200 @end smallexample
11201
11202 @noindent
11203 Note: the above rules apply to recent releases of GNAT 5.
11204 In GNAT 3, there are more severe restrictions on larger components.
11205 For non-primitive types, including packed arrays with a size greater than
11206 64 bits, component clauses must respect the alignment requirement of the
11207 type, in particular, always starting on a byte boundary, and the length
11208 must be a multiple of the storage unit.
11209
11210 @node Enumeration Clauses
11211 @section Enumeration Clauses
11212
11213 The only restriction on enumeration clauses is that the range of values
11214 must be representable.  For the signed case, if one or more of the
11215 representation values are negative, all values must be in the range:
11216
11217 @smallexample @c ada
11218    System.Min_Int .. System.Max_Int
11219 @end smallexample
11220
11221 @noindent
11222 For the unsigned case, where all values are nonnegative, the values must
11223 be in the range:
11224
11225 @smallexample @c ada
11226    0 .. System.Max_Binary_Modulus;
11227 @end smallexample
11228
11229 @noindent
11230 A @emph{confirming} representation clause is one in which the values range
11231 from 0 in sequence, i.e.@: a clause that confirms the default representation
11232 for an enumeration type.
11233 Such a confirming representation
11234 is permitted by these rules, and is specially recognized by the compiler so
11235 that no extra overhead results from the use of such a clause.
11236
11237 If an array has an index type which is an enumeration type to which an
11238 enumeration clause has been applied, then the array is stored in a compact
11239 manner.  Consider the declarations:
11240
11241 @smallexample @c ada
11242    type r is (A, B, C);
11243    for r use (A => 1, B => 5, C => 10);
11244    type t is array (r) of Character;
11245 @end smallexample
11246
11247 @noindent
11248 The array type t corresponds to a vector with exactly three elements and
11249 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11250 use of space, but means that accesses to elements of the array will incur
11251 the overhead of converting representation values to the corresponding
11252 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11253
11254 @node Address Clauses
11255 @section Address Clauses
11256 @cindex Address Clause
11257
11258 The reference manual allows a general restriction on representation clauses,
11259 as found in RM 13.1(22):
11260
11261 @quotation
11262 An implementation need not support representation
11263 items containing nonstatic expressions, except that
11264 an implementation should support a representation item
11265 for a given entity if each nonstatic expression in the
11266 representation item is a name that statically denotes
11267 a constant declared before the entity.
11268 @end quotation
11269
11270 @noindent
11271 In practice this is applicable only to address clauses, since this is the
11272 only case in which a non-static expression is permitted by the syntax.  As
11273 the AARM notes in sections 13.1 (22.a-22.h):
11274
11275 @display
11276   22.a   Reason: This is to avoid the following sort of thing:
11277
11278   22.b        X : Integer := F(@dots{});
11279               Y : Address := G(@dots{});
11280               for X'Address use Y;
11281
11282   22.c   In the above, we have to evaluate the
11283          initialization expression for X before we
11284          know where to put the result.  This seems
11285          like an unreasonable implementation burden.
11286
11287   22.d   The above code should instead be written
11288          like this:
11289
11290   22.e        Y : constant Address := G(@dots{});
11291               X : Integer := F(@dots{});
11292               for X'Address use Y;
11293
11294   22.f   This allows the expression ``Y'' to be safely
11295          evaluated before X is created.
11296
11297   22.g   The constant could be a formal parameter of mode in.
11298
11299   22.h   An implementation can support other nonstatic
11300          expressions if it wants to.  Expressions of type
11301          Address are hardly ever static, but their value
11302          might be known at compile time anyway in many
11303          cases.
11304 @end display
11305
11306 @noindent
11307 GNAT does indeed permit many additional cases of non-static expressions.  In
11308 particular, if the type involved is elementary there are no restrictions
11309 (since in this case, holding a temporary copy of the initialization value,
11310 if one is present, is inexpensive).  In addition, if there is no implicit or
11311 explicit initialization, then there are no restrictions.  GNAT will reject
11312 only the case where all three of these conditions hold:
11313
11314 @itemize @bullet
11315
11316 @item
11317 The type of the item is non-elementary (e.g.@: a record or array).
11318
11319 @item
11320 There is explicit or implicit initialization required for the object.
11321 Note that access values are always implicitly initialized, and also
11322 in GNAT, certain bit-packed arrays (those having a dynamic length or
11323 a length greater than 64) will also be implicitly initialized to zero.
11324
11325 @item
11326 The address value is non-static.  Here GNAT is more permissive than the
11327 RM, and allows the address value to be the address of a previously declared
11328 stand-alone variable, as long as it does not itself have an address clause.
11329
11330 @smallexample @c ada
11331            Anchor  : Some_Initialized_Type;
11332            Overlay : Some_Initialized_Type;
11333            for Overlay'Address use Anchor'Address;
11334 @end smallexample
11335
11336 @noindent
11337 However, the prefix of the address clause cannot be an array component, or
11338 a component of a discriminated record.
11339
11340 @end itemize
11341
11342 @noindent
11343 As noted above in section 22.h, address values are typically non-static.  In
11344 particular the To_Address function, even if applied to a literal value, is
11345 a non-static function call.  To avoid this minor annoyance, GNAT provides
11346 the implementation defined attribute 'To_Address.  The following two
11347 expressions have identical values:
11348
11349 @findex Attribute
11350 @findex To_Address
11351 @smallexample @c ada
11352    To_Address (16#1234_0000#)
11353    System'To_Address (16#1234_0000#);
11354 @end smallexample
11355
11356 @noindent
11357 except that the second form is considered to be a static expression, and
11358 thus when used as an address clause value is always permitted.
11359
11360 @noindent
11361 Additionally, GNAT treats as static an address clause that is an
11362 unchecked_conversion of a static integer value.  This simplifies the porting
11363 of legacy code, and provides a portable equivalent to the GNAT attribute
11364 @code{To_Address}.
11365
11366 Another issue with address clauses is the interaction with alignment
11367 requirements.  When an address clause is given for an object, the address
11368 value must be consistent with the alignment of the object (which is usually
11369 the same as the alignment of the type of the object).  If an address clause
11370 is given that specifies an inappropriately aligned address value, then the
11371 program execution is erroneous.
11372
11373 Since this source of erroneous behavior can have unfortunate effects, GNAT
11374 checks (at compile time if possible, generating a warning, or at execution
11375 time with a run-time check) that the alignment is appropriate.  If the
11376 run-time check fails, then @code{Program_Error} is raised.  This run-time
11377 check is suppressed if range checks are suppressed, or if the special GNAT
11378 check Alignment_Check is suppressed, or if
11379 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11380
11381 Finally, GNAT does not permit overlaying of objects of controlled types or
11382 composite types containing a controlled component. In most cases, the compiler
11383 can detect an attempt at such overlays and will generate a warning at compile
11384 time and a Program_Error exception at run time.
11385
11386 @findex Export
11387 An address clause cannot be given for an exported object.  More
11388 understandably the real restriction is that objects with an address
11389 clause cannot be exported.  This is because such variables are not
11390 defined by the Ada program, so there is no external object to export.
11391
11392 @findex Import
11393 It is permissible to give an address clause and a pragma Import for the
11394 same object.  In this case, the variable is not really defined by the
11395 Ada program, so there is no external symbol to be linked.  The link name
11396 and the external name are ignored in this case.  The reason that we allow this
11397 combination is that it provides a useful idiom to avoid unwanted
11398 initializations on objects with address clauses.
11399
11400 When an address clause is given for an object that has implicit or
11401 explicit initialization, then by default initialization takes place.  This
11402 means that the effect of the object declaration is to overwrite the
11403 memory at the specified address.  This is almost always not what the
11404 programmer wants, so GNAT will output a warning:
11405
11406 @smallexample
11407   with System;
11408   package G is
11409      type R is record
11410         M : Integer := 0;
11411      end record;
11412
11413      Ext : R;
11414      for Ext'Address use System'To_Address (16#1234_1234#);
11415          |
11416   >>> warning: implicit initialization of "Ext" may
11417       modify overlaid storage
11418   >>> warning: use pragma Import for "Ext" to suppress
11419       initialization (RM B(24))
11420
11421   end G;
11422 @end smallexample
11423
11424 @noindent
11425 As indicated by the warning message, the solution is to use a (dummy) pragma
11426 Import to suppress this initialization.  The pragma tell the compiler that the
11427 object is declared and initialized elsewhere.  The following package compiles
11428 without warnings (and the initialization is suppressed):
11429
11430 @smallexample @c ada
11431    with System;
11432    package G is
11433       type R is record
11434          M : Integer := 0;
11435       end record;
11436
11437       Ext : R;
11438       for Ext'Address use System'To_Address (16#1234_1234#);
11439       pragma Import (Ada, Ext);
11440    end G;
11441 @end smallexample
11442
11443 @noindent
11444 A final issue with address clauses involves their use for overlaying
11445 variables, as in the following example:
11446 @cindex Overlaying of objects
11447
11448 @smallexample @c ada
11449   A : Integer;
11450   B : Integer;
11451   for B'Address use A'Address;
11452 @end smallexample
11453
11454 @noindent
11455 or alternatively, using the form recommended by the RM:
11456
11457 @smallexample @c ada
11458   A    : Integer;
11459   Addr : constant Address := A'Address;
11460   B    : Integer;
11461   for B'Address use Addr;
11462 @end smallexample
11463
11464 @noindent
11465 In both of these cases, @code{A}
11466 and @code{B} become aliased to one another via the
11467 address clause. This use of address clauses to overlay
11468 variables, achieving an effect similar to unchecked
11469 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11470 the effect is implementation defined. Furthermore, the
11471 Ada RM specifically recommends that in a situation
11472 like this, @code{B} should be subject to the following
11473 implementation advice (RM 13.3(19)):
11474
11475 @quotation
11476 19  If the Address of an object is specified, or it is imported
11477     or exported, then the implementation should not perform
11478     optimizations based on assumptions of no aliases.
11479 @end quotation
11480
11481 @noindent
11482 GNAT follows this recommendation, and goes further by also applying
11483 this recommendation to the overlaid variable (@code{A}
11484 in the above example) in this case. This means that the overlay
11485 works "as expected", in that a modification to one of the variables
11486 will affect the value of the other.
11487
11488 @node Effect of Convention on Representation
11489 @section Effect of Convention on Representation
11490 @cindex Convention, effect on representation
11491
11492 @noindent
11493 Normally the specification of a foreign language convention for a type or
11494 an object has no effect on the chosen representation.  In particular, the
11495 representation chosen for data in GNAT generally meets the standard system
11496 conventions, and for example records are laid out in a manner that is
11497 consistent with C@.  This means that specifying convention C (for example)
11498 has no effect.
11499
11500 There are four exceptions to this general rule:
11501
11502 @itemize @bullet
11503
11504 @item Convention Fortran and array subtypes
11505 If pragma Convention Fortran is specified for an array subtype, then in
11506 accordance with the implementation advice in section 3.6.2(11) of the
11507 Ada Reference Manual, the array will be stored in a Fortran-compatible
11508 column-major manner, instead of the normal default row-major order.
11509
11510 @item Convention C and enumeration types
11511 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11512 to accommodate all values of the type.  For example, for the enumeration
11513 type declared by:
11514
11515 @smallexample @c ada
11516    type Color is (Red, Green, Blue);
11517 @end smallexample
11518
11519 @noindent
11520 8 bits is sufficient to store all values of the type, so by default, objects
11521 of type @code{Color} will be represented using 8 bits.  However, normal C
11522 convention is to use 32 bits for all enum values in C, since enum values
11523 are essentially of type int.  If pragma @code{Convention C} is specified for an
11524 Ada enumeration type, then the size is modified as necessary (usually to
11525 32 bits) to be consistent with the C convention for enum values.
11526
11527 Note that this treatment applies only to types. If Convention C is given for
11528 an enumeration object, where the enumeration type is not Convention C, then
11529 Object_Size bits are allocated. For example, for a normal enumeration type,
11530 with less than 256 elements, only 8 bits will be allocated for the object.
11531 Since this may be a surprise in terms of what C expects, GNAT will issue a
11532 warning in this situation. The warning can be suppressed by giving an explicit
11533 size clause specifying the desired size.
11534
11535 @item Convention C/Fortran and Boolean types
11536 In C, the usual convention for boolean values, that is values used for
11537 conditions, is that zero represents false, and nonzero values represent
11538 true.  In Ada, the normal convention is that two specific values, typically
11539 0/1, are used to represent false/true respectively.
11540
11541 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11542 value represents true).
11543
11544 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11545 C or Fortran convention for a derived Boolean, as in the following example:
11546
11547 @smallexample @c ada
11548    type C_Switch is new Boolean;
11549    pragma Convention (C, C_Switch);
11550 @end smallexample
11551
11552 @noindent
11553 then the GNAT generated code will treat any nonzero value as true.  For truth
11554 values generated by GNAT, the conventional value 1 will be used for True, but
11555 when one of these values is read, any nonzero value is treated as True.
11556
11557 @item Access types on OpenVMS
11558 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11559 arrays) are 64-bits long. An exception to this rule is for the case of
11560 C-convention access types where there is no explicit size clause present (or
11561 inherited for derived types). In this case, GNAT chooses to make these
11562 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11563 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11564
11565 @end itemize
11566
11567 @node Determining the Representations chosen by GNAT
11568 @section Determining the Representations chosen by GNAT
11569 @cindex Representation, determination of
11570 @cindex @option{-gnatR} switch
11571
11572 @noindent
11573 Although the descriptions in this section are intended to be complete, it is
11574 often easier to simply experiment to see what GNAT accepts and what the
11575 effect is on the layout of types and objects.
11576
11577 As required by the Ada RM, if a representation clause is not accepted, then
11578 it must be rejected as illegal by the compiler.  However, when a
11579 representation clause or pragma is accepted, there can still be questions
11580 of what the compiler actually does.  For example, if a partial record
11581 representation clause specifies the location of some components and not
11582 others, then where are the non-specified components placed? Or if pragma
11583 @code{Pack} is used on a record, then exactly where are the resulting
11584 fields placed? The section on pragma @code{Pack} in this chapter can be
11585 used to answer the second question, but it is often easier to just see
11586 what the compiler does.
11587
11588 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11589 with this option, then the compiler will output information on the actual
11590 representations chosen, in a format similar to source representation
11591 clauses.  For example, if we compile the package:
11592
11593 @smallexample @c ada
11594 package q is
11595    type r (x : boolean) is tagged record
11596       case x is
11597          when True => S : String (1 .. 100);
11598          when False => null;
11599       end case;
11600    end record;
11601
11602    type r2 is new r (false) with record
11603       y2 : integer;
11604    end record;
11605
11606    for r2 use record
11607       y2 at 16 range 0 .. 31;
11608    end record;
11609
11610    type x is record
11611       y : character;
11612    end record;
11613
11614    type x1 is array (1 .. 10) of x;
11615    for x1'component_size use 11;
11616
11617    type ia is access integer;
11618
11619    type Rb1 is array (1 .. 13) of Boolean;
11620    pragma Pack (rb1);
11621
11622    type Rb2 is array (1 .. 65) of Boolean;
11623    pragma Pack (rb2);
11624
11625    type x2 is record
11626       l1 : Boolean;
11627       l2 : Duration;
11628       l3 : Float;
11629       l4 : Boolean;
11630       l5 : Rb1;
11631       l6 : Rb2;
11632    end record;
11633    pragma Pack (x2);
11634 end q;
11635 @end smallexample
11636
11637 @noindent
11638 using the switch @option{-gnatR} we obtain the following output:
11639
11640 @smallexample
11641 Representation information for unit q
11642 -------------------------------------
11643
11644 for r'Size use ??;
11645 for r'Alignment use 4;
11646 for r use record
11647    x    at 4 range  0 .. 7;
11648    _tag at 0 range  0 .. 31;
11649    s    at 5 range  0 .. 799;
11650 end record;
11651
11652 for r2'Size use 160;
11653 for r2'Alignment use 4;
11654 for r2 use record
11655    x       at  4 range  0 .. 7;
11656    _tag    at  0 range  0 .. 31;
11657    _parent at  0 range  0 .. 63;
11658    y2      at 16 range  0 .. 31;
11659 end record;
11660
11661 for x'Size use 8;
11662 for x'Alignment use 1;
11663 for x use record
11664    y at 0 range  0 .. 7;
11665 end record;
11666
11667 for x1'Size use 112;
11668 for x1'Alignment use 1;
11669 for x1'Component_Size use 11;
11670
11671 for rb1'Size use 13;
11672 for rb1'Alignment use 2;
11673 for rb1'Component_Size use 1;
11674
11675 for rb2'Size use 72;
11676 for rb2'Alignment use 1;
11677 for rb2'Component_Size use 1;
11678
11679 for x2'Size use 224;
11680 for x2'Alignment use 4;
11681 for x2 use record
11682    l1 at  0 range  0 .. 0;
11683    l2 at  0 range  1 .. 64;
11684    l3 at 12 range  0 .. 31;
11685    l4 at 16 range  0 .. 0;
11686    l5 at 16 range  1 .. 13;
11687    l6 at 18 range  0 .. 71;
11688 end record;
11689 @end smallexample
11690
11691 @noindent
11692 The Size values are actually the Object_Size, i.e.@: the default size that
11693 will be allocated for objects of the type.
11694 The ?? size for type r indicates that we have a variant record, and the
11695 actual size of objects will depend on the discriminant value.
11696
11697 The Alignment values show the actual alignment chosen by the compiler
11698 for each record or array type.
11699
11700 The record representation clause for type r shows where all fields
11701 are placed, including the compiler generated tag field (whose location
11702 cannot be controlled by the programmer).
11703
11704 The record representation clause for the type extension r2 shows all the
11705 fields present, including the parent field, which is a copy of the fields
11706 of the parent type of r2, i.e.@: r1.
11707
11708 The component size and size clauses for types rb1 and rb2 show
11709 the exact effect of pragma @code{Pack} on these arrays, and the record
11710 representation clause for type x2 shows how pragma @code{Pack} affects
11711 this record type.
11712
11713 In some cases, it may be useful to cut and paste the representation clauses
11714 generated by the compiler into the original source to fix and guarantee
11715 the actual representation to be used.
11716
11717 @node Standard Library Routines
11718 @chapter Standard Library Routines
11719
11720 @noindent
11721 The Ada Reference Manual contains in Annex A a full description of an
11722 extensive set of standard library routines that can be used in any Ada
11723 program, and which must be provided by all Ada compilers.  They are
11724 analogous to the standard C library used by C programs.
11725
11726 GNAT implements all of the facilities described in annex A, and for most
11727 purposes the description in the Ada Reference Manual, or appropriate Ada
11728 text book, will be sufficient for making use of these facilities.
11729
11730 In the case of the input-output facilities,
11731 @xref{The Implementation of Standard I/O},
11732 gives details on exactly how GNAT interfaces to the
11733 file system.  For the remaining packages, the Ada Reference Manual
11734 should be sufficient.  The following is a list of the packages included,
11735 together with a brief description of the functionality that is provided.
11736
11737 For completeness, references are included to other predefined library
11738 routines defined in other sections of the Ada Reference Manual (these are
11739 cross-indexed from Annex A).
11740
11741 @table @code
11742 @item Ada (A.2)
11743 This is a parent package for all the standard library packages.  It is
11744 usually included implicitly in your program, and itself contains no
11745 useful data or routines.
11746
11747 @item Ada.Calendar (9.6)
11748 @code{Calendar} provides time of day access, and routines for
11749 manipulating times and durations.
11750
11751 @item Ada.Characters (A.3.1)
11752 This is a dummy parent package that contains no useful entities
11753
11754 @item Ada.Characters.Handling (A.3.2)
11755 This package provides some basic character handling capabilities,
11756 including classification functions for classes of characters (e.g.@: test
11757 for letters, or digits).
11758
11759 @item Ada.Characters.Latin_1 (A.3.3)
11760 This package includes a complete set of definitions of the characters
11761 that appear in type CHARACTER@.  It is useful for writing programs that
11762 will run in international environments.  For example, if you want an
11763 upper case E with an acute accent in a string, it is often better to use
11764 the definition of @code{UC_E_Acute} in this package.  Then your program
11765 will print in an understandable manner even if your environment does not
11766 support these extended characters.
11767
11768 @item Ada.Command_Line (A.15)
11769 This package provides access to the command line parameters and the name
11770 of the current program (analogous to the use of @code{argc} and @code{argv}
11771 in C), and also allows the exit status for the program to be set in a
11772 system-independent manner.
11773
11774 @item Ada.Decimal (F.2)
11775 This package provides constants describing the range of decimal numbers
11776 implemented, and also a decimal divide routine (analogous to the COBOL
11777 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11778
11779 @item Ada.Direct_IO (A.8.4)
11780 This package provides input-output using a model of a set of records of
11781 fixed-length, containing an arbitrary definite Ada type, indexed by an
11782 integer record number.
11783
11784 @item Ada.Dynamic_Priorities (D.5)
11785 This package allows the priorities of a task to be adjusted dynamically
11786 as the task is running.
11787
11788 @item Ada.Exceptions (11.4.1)
11789 This package provides additional information on exceptions, and also
11790 contains facilities for treating exceptions as data objects, and raising
11791 exceptions with associated messages.
11792
11793 @item Ada.Finalization (7.6)
11794 This package contains the declarations and subprograms to support the
11795 use of controlled types, providing for automatic initialization and
11796 finalization (analogous to the constructors and destructors of C++)
11797
11798 @item Ada.Interrupts (C.3.2)
11799 This package provides facilities for interfacing to interrupts, which
11800 includes the set of signals or conditions that can be raised and
11801 recognized as interrupts.
11802
11803 @item Ada.Interrupts.Names (C.3.2)
11804 This package provides the set of interrupt names (actually signal
11805 or condition names) that can be handled by GNAT@.
11806
11807 @item Ada.IO_Exceptions (A.13)
11808 This package defines the set of exceptions that can be raised by use of
11809 the standard IO packages.
11810
11811 @item Ada.Numerics
11812 This package contains some standard constants and exceptions used
11813 throughout the numerics packages.  Note that the constants pi and e are
11814 defined here, and it is better to use these definitions than rolling
11815 your own.
11816
11817 @item Ada.Numerics.Complex_Elementary_Functions
11818 Provides the implementation of standard elementary functions (such as
11819 log and trigonometric functions) operating on complex numbers using the
11820 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11821 created by the package @code{Numerics.Complex_Types}.
11822
11823 @item Ada.Numerics.Complex_Types
11824 This is a predefined instantiation of
11825 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11826 build the type @code{Complex} and @code{Imaginary}.
11827
11828 @item Ada.Numerics.Discrete_Random
11829 This package provides a random number generator suitable for generating
11830 random integer values from a specified range.
11831
11832 @item Ada.Numerics.Float_Random
11833 This package provides a random number generator suitable for generating
11834 uniformly distributed floating point values.
11835
11836 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11837 This is a generic version of the package that provides the
11838 implementation of standard elementary functions (such as log and
11839 trigonometric functions) for an arbitrary complex type.
11840
11841 The following predefined instantiations of this package are provided:
11842
11843 @table @code
11844 @item Short_Float
11845 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11846 @item Float
11847 @code{Ada.Numerics.Complex_Elementary_Functions}
11848 @item Long_Float
11849 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11850 @end table
11851
11852 @item Ada.Numerics.Generic_Complex_Types
11853 This is a generic package that allows the creation of complex types,
11854 with associated complex arithmetic operations.
11855
11856 The following predefined instantiations of this package exist
11857 @table @code
11858 @item Short_Float
11859 @code{Ada.Numerics.Short_Complex_Complex_Types}
11860 @item Float
11861 @code{Ada.Numerics.Complex_Complex_Types}
11862 @item Long_Float
11863 @code{Ada.Numerics.Long_Complex_Complex_Types}
11864 @end table
11865
11866 @item Ada.Numerics.Generic_Elementary_Functions
11867 This is a generic package that provides the implementation of standard
11868 elementary functions (such as log an trigonometric functions) for an
11869 arbitrary float type.
11870
11871 The following predefined instantiations of this package exist
11872
11873 @table @code
11874 @item Short_Float
11875 @code{Ada.Numerics.Short_Elementary_Functions}
11876 @item Float
11877 @code{Ada.Numerics.Elementary_Functions}
11878 @item Long_Float
11879 @code{Ada.Numerics.Long_Elementary_Functions}
11880 @end table
11881
11882 @item Ada.Real_Time (D.8)
11883 This package provides facilities similar to those of @code{Calendar}, but
11884 operating with a finer clock suitable for real time control. Note that
11885 annex D requires that there be no backward clock jumps, and GNAT generally
11886 guarantees this behavior, but of course if the external clock on which
11887 the GNAT runtime depends is deliberately reset by some external event,
11888 then such a backward jump may occur.
11889
11890 @item Ada.Sequential_IO (A.8.1)
11891 This package provides input-output facilities for sequential files,
11892 which can contain a sequence of values of a single type, which can be
11893 any Ada type, including indefinite (unconstrained) types.
11894
11895 @item Ada.Storage_IO (A.9)
11896 This package provides a facility for mapping arbitrary Ada types to and
11897 from a storage buffer.  It is primarily intended for the creation of new
11898 IO packages.
11899
11900 @item Ada.Streams (13.13.1)
11901 This is a generic package that provides the basic support for the
11902 concept of streams as used by the stream attributes (@code{Input},
11903 @code{Output}, @code{Read} and @code{Write}).
11904
11905 @item Ada.Streams.Stream_IO (A.12.1)
11906 This package is a specialization of the type @code{Streams} defined in
11907 package @code{Streams} together with a set of operations providing
11908 Stream_IO capability.  The Stream_IO model permits both random and
11909 sequential access to a file which can contain an arbitrary set of values
11910 of one or more Ada types.
11911
11912 @item Ada.Strings (A.4.1)
11913 This package provides some basic constants used by the string handling
11914 packages.
11915
11916 @item Ada.Strings.Bounded (A.4.4)
11917 This package provides facilities for handling variable length
11918 strings.  The bounded model requires a maximum length.  It is thus
11919 somewhat more limited than the unbounded model, but avoids the use of
11920 dynamic allocation or finalization.
11921
11922 @item Ada.Strings.Fixed (A.4.3)
11923 This package provides facilities for handling fixed length strings.
11924
11925 @item Ada.Strings.Maps (A.4.2)
11926 This package provides facilities for handling character mappings and
11927 arbitrarily defined subsets of characters.  For instance it is useful in
11928 defining specialized translation tables.
11929
11930 @item Ada.Strings.Maps.Constants (A.4.6)
11931 This package provides a standard set of predefined mappings and
11932 predefined character sets.  For example, the standard upper to lower case
11933 conversion table is found in this package.  Note that upper to lower case
11934 conversion is non-trivial if you want to take the entire set of
11935 characters, including extended characters like E with an acute accent,
11936 into account.  You should use the mappings in this package (rather than
11937 adding 32 yourself) to do case mappings.
11938
11939 @item Ada.Strings.Unbounded (A.4.5)
11940 This package provides facilities for handling variable length
11941 strings.  The unbounded model allows arbitrary length strings, but
11942 requires the use of dynamic allocation and finalization.
11943
11944 @item Ada.Strings.Wide_Bounded (A.4.7)
11945 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11946 @itemx Ada.Strings.Wide_Maps (A.4.7)
11947 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11948 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11949 These packages provide analogous capabilities to the corresponding
11950 packages without @samp{Wide_} in the name, but operate with the types
11951 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11952 and @code{Character}.
11953
11954 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11955 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11956 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11957 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11958 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11959 These packages provide analogous capabilities to the corresponding
11960 packages without @samp{Wide_} in the name, but operate with the types
11961 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11962 of @code{String} and @code{Character}.
11963
11964 @item Ada.Synchronous_Task_Control (D.10)
11965 This package provides some standard facilities for controlling task
11966 communication in a synchronous manner.
11967
11968 @item Ada.Tags
11969 This package contains definitions for manipulation of the tags of tagged
11970 values.
11971
11972 @item Ada.Task_Attributes
11973 This package provides the capability of associating arbitrary
11974 task-specific data with separate tasks.
11975
11976 @item Ada.Text_IO
11977 This package provides basic text input-output capabilities for
11978 character, string and numeric data.  The subpackages of this
11979 package are listed next.
11980
11981 @item Ada.Text_IO.Decimal_IO
11982 Provides input-output facilities for decimal fixed-point types
11983
11984 @item Ada.Text_IO.Enumeration_IO
11985 Provides input-output facilities for enumeration types.
11986
11987 @item Ada.Text_IO.Fixed_IO
11988 Provides input-output facilities for ordinary fixed-point types.
11989
11990 @item Ada.Text_IO.Float_IO
11991 Provides input-output facilities for float types.  The following
11992 predefined instantiations of this generic package are available:
11993
11994 @table @code
11995 @item Short_Float
11996 @code{Short_Float_Text_IO}
11997 @item Float
11998 @code{Float_Text_IO}
11999 @item Long_Float
12000 @code{Long_Float_Text_IO}
12001 @end table
12002
12003 @item Ada.Text_IO.Integer_IO
12004 Provides input-output facilities for integer types.  The following
12005 predefined instantiations of this generic package are available:
12006
12007 @table @code
12008 @item Short_Short_Integer
12009 @code{Ada.Short_Short_Integer_Text_IO}
12010 @item Short_Integer
12011 @code{Ada.Short_Integer_Text_IO}
12012 @item Integer
12013 @code{Ada.Integer_Text_IO}
12014 @item Long_Integer
12015 @code{Ada.Long_Integer_Text_IO}
12016 @item Long_Long_Integer
12017 @code{Ada.Long_Long_Integer_Text_IO}
12018 @end table
12019
12020 @item Ada.Text_IO.Modular_IO
12021 Provides input-output facilities for modular (unsigned) types
12022
12023 @item Ada.Text_IO.Complex_IO (G.1.3)
12024 This package provides basic text input-output capabilities for complex
12025 data.
12026
12027 @item Ada.Text_IO.Editing (F.3.3)
12028 This package contains routines for edited output, analogous to the use
12029 of pictures in COBOL@.  The picture formats used by this package are a
12030 close copy of the facility in COBOL@.
12031
12032 @item Ada.Text_IO.Text_Streams (A.12.2)
12033 This package provides a facility that allows Text_IO files to be treated
12034 as streams, so that the stream attributes can be used for writing
12035 arbitrary data, including binary data, to Text_IO files.
12036
12037 @item Ada.Unchecked_Conversion (13.9)
12038 This generic package allows arbitrary conversion from one type to
12039 another of the same size, providing for breaking the type safety in
12040 special circumstances.
12041
12042 If the types have the same Size (more accurately the same Value_Size),
12043 then the effect is simply to transfer the bits from the source to the
12044 target type without any modification.  This usage is well defined, and
12045 for simple types whose representation is typically the same across
12046 all implementations, gives a portable method of performing such
12047 conversions.
12048
12049 If the types do not have the same size, then the result is implementation
12050 defined, and thus may be non-portable.  The following describes how GNAT
12051 handles such unchecked conversion cases.
12052
12053 If the types are of different sizes, and are both discrete types, then
12054 the effect is of a normal type conversion without any constraint checking.
12055 In particular if the result type has a larger size, the result will be
12056 zero or sign extended.  If the result type has a smaller size, the result
12057 will be truncated by ignoring high order bits.
12058
12059 If the types are of different sizes, and are not both discrete types,
12060 then the conversion works as though pointers were created to the source
12061 and target, and the pointer value is converted.  The effect is that bits
12062 are copied from successive low order storage units and bits of the source
12063 up to the length of the target type.
12064
12065 A warning is issued if the lengths differ, since the effect in this
12066 case is implementation dependent, and the above behavior may not match
12067 that of some other compiler.
12068
12069 A pointer to one type may be converted to a pointer to another type using
12070 unchecked conversion.  The only case in which the effect is undefined is
12071 when one or both pointers are pointers to unconstrained array types.  In
12072 this case, the bounds information may get incorrectly transferred, and in
12073 particular, GNAT uses double size pointers for such types, and it is
12074 meaningless to convert between such pointer types.  GNAT will issue a
12075 warning if the alignment of the target designated type is more strict
12076 than the alignment of the source designated type (since the result may
12077 be unaligned in this case).
12078
12079 A pointer other than a pointer to an unconstrained array type may be
12080 converted to and from System.Address.  Such usage is common in Ada 83
12081 programs, but note that Ada.Address_To_Access_Conversions is the
12082 preferred method of performing such conversions in Ada 95 and Ada 2005.
12083 Neither
12084 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12085 used in conjunction with pointers to unconstrained objects, since
12086 the bounds information cannot be handled correctly in this case.
12087
12088 @item Ada.Unchecked_Deallocation (13.11.2)
12089 This generic package allows explicit freeing of storage previously
12090 allocated by use of an allocator.
12091
12092 @item Ada.Wide_Text_IO (A.11)
12093 This package is similar to @code{Ada.Text_IO}, except that the external
12094 file supports wide character representations, and the internal types are
12095 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12096 and @code{String}.  It contains generic subpackages listed next.
12097
12098 @item Ada.Wide_Text_IO.Decimal_IO
12099 Provides input-output facilities for decimal fixed-point types
12100
12101 @item Ada.Wide_Text_IO.Enumeration_IO
12102 Provides input-output facilities for enumeration types.
12103
12104 @item Ada.Wide_Text_IO.Fixed_IO
12105 Provides input-output facilities for ordinary fixed-point types.
12106
12107 @item Ada.Wide_Text_IO.Float_IO
12108 Provides input-output facilities for float types.  The following
12109 predefined instantiations of this generic package are available:
12110
12111 @table @code
12112 @item Short_Float
12113 @code{Short_Float_Wide_Text_IO}
12114 @item Float
12115 @code{Float_Wide_Text_IO}
12116 @item Long_Float
12117 @code{Long_Float_Wide_Text_IO}
12118 @end table
12119
12120 @item Ada.Wide_Text_IO.Integer_IO
12121 Provides input-output facilities for integer types.  The following
12122 predefined instantiations of this generic package are available:
12123
12124 @table @code
12125 @item Short_Short_Integer
12126 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12127 @item Short_Integer
12128 @code{Ada.Short_Integer_Wide_Text_IO}
12129 @item Integer
12130 @code{Ada.Integer_Wide_Text_IO}
12131 @item Long_Integer
12132 @code{Ada.Long_Integer_Wide_Text_IO}
12133 @item Long_Long_Integer
12134 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12135 @end table
12136
12137 @item Ada.Wide_Text_IO.Modular_IO
12138 Provides input-output facilities for modular (unsigned) types
12139
12140 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12141 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12142 external file supports wide character representations.
12143
12144 @item Ada.Wide_Text_IO.Editing (F.3.4)
12145 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12146 types are @code{Wide_Character} and @code{Wide_String} instead of
12147 @code{Character} and @code{String}.
12148
12149 @item Ada.Wide_Text_IO.Streams (A.12.3)
12150 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12151 types are @code{Wide_Character} and @code{Wide_String} instead of
12152 @code{Character} and @code{String}.
12153
12154 @item Ada.Wide_Wide_Text_IO (A.11)
12155 This package is similar to @code{Ada.Text_IO}, except that the external
12156 file supports wide character representations, and the internal types are
12157 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12158 and @code{String}.  It contains generic subpackages listed next.
12159
12160 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12161 Provides input-output facilities for decimal fixed-point types
12162
12163 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12164 Provides input-output facilities for enumeration types.
12165
12166 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12167 Provides input-output facilities for ordinary fixed-point types.
12168
12169 @item Ada.Wide_Wide_Text_IO.Float_IO
12170 Provides input-output facilities for float types.  The following
12171 predefined instantiations of this generic package are available:
12172
12173 @table @code
12174 @item Short_Float
12175 @code{Short_Float_Wide_Wide_Text_IO}
12176 @item Float
12177 @code{Float_Wide_Wide_Text_IO}
12178 @item Long_Float
12179 @code{Long_Float_Wide_Wide_Text_IO}
12180 @end table
12181
12182 @item Ada.Wide_Wide_Text_IO.Integer_IO
12183 Provides input-output facilities for integer types.  The following
12184 predefined instantiations of this generic package are available:
12185
12186 @table @code
12187 @item Short_Short_Integer
12188 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12189 @item Short_Integer
12190 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12191 @item Integer
12192 @code{Ada.Integer_Wide_Wide_Text_IO}
12193 @item Long_Integer
12194 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12195 @item Long_Long_Integer
12196 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12197 @end table
12198
12199 @item Ada.Wide_Wide_Text_IO.Modular_IO
12200 Provides input-output facilities for modular (unsigned) types
12201
12202 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12203 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12204 external file supports wide character representations.
12205
12206 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12207 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12208 types are @code{Wide_Character} and @code{Wide_String} instead of
12209 @code{Character} and @code{String}.
12210
12211 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12212 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12213 types are @code{Wide_Character} and @code{Wide_String} instead of
12214 @code{Character} and @code{String}.
12215 @end table
12216
12217
12218
12219 @node The Implementation of Standard I/O
12220 @chapter The Implementation of Standard I/O
12221
12222 @noindent
12223 GNAT implements all the required input-output facilities described in
12224 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12225 required behavior of these packages from the Ada point of view, and if
12226 you are writing a portable Ada program that does not need to know the
12227 exact manner in which Ada maps to the outside world when it comes to
12228 reading or writing external files, then you do not need to read this
12229 chapter.  As long as your files are all regular files (not pipes or
12230 devices), and as long as you write and read the files only from Ada, the
12231 description in the Ada Reference Manual is sufficient.
12232
12233 However, if you want to do input-output to pipes or other devices, such
12234 as the keyboard or screen, or if the files you are dealing with are
12235 either generated by some other language, or to be read by some other
12236 language, then you need to know more about the details of how the GNAT
12237 implementation of these input-output facilities behaves.
12238
12239 In this chapter we give a detailed description of exactly how GNAT
12240 interfaces to the file system.  As always, the sources of the system are
12241 available to you for answering questions at an even more detailed level,
12242 but for most purposes the information in this chapter will suffice.
12243
12244 Another reason that you may need to know more about how input-output is
12245 implemented arises when you have a program written in mixed languages
12246 where, for example, files are shared between the C and Ada sections of
12247 the same program.  GNAT provides some additional facilities, in the form
12248 of additional child library packages, that facilitate this sharing, and
12249 these additional facilities are also described in this chapter.
12250
12251 @menu
12252 * Standard I/O Packages::
12253 * FORM Strings::
12254 * Direct_IO::
12255 * Sequential_IO::
12256 * Text_IO::
12257 * Wide_Text_IO::
12258 * Wide_Wide_Text_IO::
12259 * Stream_IO::
12260 * Text Translation::
12261 * Shared Files::
12262 * Filenames encoding::
12263 * Open Modes::
12264 * Operations on C Streams::
12265 * Interfacing to C Streams::
12266 @end menu
12267
12268 @node Standard I/O Packages
12269 @section Standard I/O Packages
12270
12271 @noindent
12272 The Standard I/O packages described in Annex A for
12273
12274 @itemize @bullet
12275 @item
12276 Ada.Text_IO
12277 @item
12278 Ada.Text_IO.Complex_IO
12279 @item
12280 Ada.Text_IO.Text_Streams
12281 @item
12282 Ada.Wide_Text_IO
12283 @item
12284 Ada.Wide_Text_IO.Complex_IO
12285 @item
12286 Ada.Wide_Text_IO.Text_Streams
12287 @item
12288 Ada.Wide_Wide_Text_IO
12289 @item
12290 Ada.Wide_Wide_Text_IO.Complex_IO
12291 @item
12292 Ada.Wide_Wide_Text_IO.Text_Streams
12293 @item
12294 Ada.Stream_IO
12295 @item
12296 Ada.Sequential_IO
12297 @item
12298 Ada.Direct_IO
12299 @end itemize
12300
12301 @noindent
12302 are implemented using the C
12303 library streams facility; where
12304
12305 @itemize @bullet
12306 @item
12307 All files are opened using @code{fopen}.
12308 @item
12309 All input/output operations use @code{fread}/@code{fwrite}.
12310 @end itemize
12311
12312 @noindent
12313 There is no internal buffering of any kind at the Ada library level. The only
12314 buffering is that provided at the system level in the implementation of the
12315 library routines that support streams. This facilitates shared use of these
12316 streams by mixed language programs. Note though that system level buffering is
12317 explicitly enabled at elaboration of the standard I/O packages and that can
12318 have an impact on mixed language programs, in particular those using I/O before
12319 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12320 the Ada elaboration routine before performing any I/O or when impractical,
12321 flush the common I/O streams and in particular Standard_Output before
12322 elaborating the Ada code.
12323
12324 @node FORM Strings
12325 @section FORM Strings
12326
12327 @noindent
12328 The format of a FORM string in GNAT is:
12329
12330 @smallexample
12331 "keyword=value,keyword=value,@dots{},keyword=value"
12332 @end smallexample
12333
12334 @noindent
12335 where letters may be in upper or lower case, and there are no spaces
12336 between values.  The order of the entries is not important.  Currently
12337 the following keywords defined.
12338
12339 @smallexample
12340 TEXT_TRANSLATION=[YES|NO]
12341 SHARED=[YES|NO]
12342 WCEM=[n|h|u|s|e|8|b]
12343 ENCODING=[UTF8|8BITS]
12344 @end smallexample
12345
12346 @noindent
12347 The use of these parameters is described later in this section.
12348
12349 @node Direct_IO
12350 @section Direct_IO
12351
12352 @noindent
12353 Direct_IO can only be instantiated for definite types.  This is a
12354 restriction of the Ada language, which means that the records are fixed
12355 length (the length being determined by @code{@var{type}'Size}, rounded
12356 up to the next storage unit boundary if necessary).
12357
12358 The records of a Direct_IO file are simply written to the file in index
12359 sequence, with the first record starting at offset zero, and subsequent
12360 records following.  There is no control information of any kind.  For
12361 example, if 32-bit integers are being written, each record takes
12362 4-bytes, so the record at index @var{K} starts at offset
12363 (@var{K}@minus{}1)*4.
12364
12365 There is no limit on the size of Direct_IO files, they are expanded as
12366 necessary to accommodate whatever records are written to the file.
12367
12368 @node Sequential_IO
12369 @section Sequential_IO
12370
12371 @noindent
12372 Sequential_IO may be instantiated with either a definite (constrained)
12373 or indefinite (unconstrained) type.
12374
12375 For the definite type case, the elements written to the file are simply
12376 the memory images of the data values with no control information of any
12377 kind.  The resulting file should be read using the same type, no validity
12378 checking is performed on input.
12379
12380 For the indefinite type case, the elements written consist of two
12381 parts.  First is the size of the data item, written as the memory image
12382 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12383 the data value.  The resulting file can only be read using the same
12384 (unconstrained) type.  Normal assignment checks are performed on these
12385 read operations, and if these checks fail, @code{Data_Error} is
12386 raised.  In particular, in the array case, the lengths must match, and in
12387 the variant record case, if the variable for a particular read operation
12388 is constrained, the discriminants must match.
12389
12390 Note that it is not possible to use Sequential_IO to write variable
12391 length array items, and then read the data back into different length
12392 arrays.  For example, the following will raise @code{Data_Error}:
12393
12394 @smallexample @c ada
12395  package IO is new Sequential_IO (String);
12396  F : IO.File_Type;
12397  S : String (1..4);
12398  @dots{}
12399  IO.Create (F)
12400  IO.Write (F, "hello!")
12401  IO.Reset (F, Mode=>In_File);
12402  IO.Read (F, S);
12403  Put_Line (S);
12404
12405 @end smallexample
12406
12407 @noindent
12408 On some Ada implementations, this will print @code{hell}, but the program is
12409 clearly incorrect, since there is only one element in the file, and that
12410 element is the string @code{hello!}.
12411
12412 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12413 using Stream_IO, and this is the preferred mechanism.  In particular, the
12414 above program fragment rewritten to use Stream_IO will work correctly.
12415
12416 @node Text_IO
12417 @section Text_IO
12418
12419 @noindent
12420 Text_IO files consist of a stream of characters containing the following
12421 special control characters:
12422
12423 @smallexample
12424 LF (line feed, 16#0A#) Line Mark
12425 FF (form feed, 16#0C#) Page Mark
12426 @end smallexample
12427
12428 @noindent
12429 A canonical Text_IO file is defined as one in which the following
12430 conditions are met:
12431
12432 @itemize @bullet
12433 @item
12434 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12435 of the line.
12436
12437 @item
12438 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12439 end of a page and consequently can appear only immediately following a
12440 @code{LF} (line mark) character.
12441
12442 @item
12443 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12444 (line mark, page mark).  In the former case, the page mark is implicitly
12445 assumed to be present.
12446 @end itemize
12447
12448 @noindent
12449 A file written using Text_IO will be in canonical form provided that no
12450 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12451 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12452 the file unless an explicit @code{New_Page} operation was performed
12453 before closing the file.
12454
12455 A canonical Text_IO file that is a regular file (i.e., not a device or a
12456 pipe) can be read using any of the routines in Text_IO@.  The
12457 semantics in this case will be exactly as defined in the Ada Reference
12458 Manual, and all the routines in Text_IO are fully implemented.
12459
12460 A text file that does not meet the requirements for a canonical Text_IO
12461 file has one of the following:
12462
12463 @itemize @bullet
12464 @item
12465 The file contains @code{FF} characters not immediately following a
12466 @code{LF} character.
12467
12468 @item
12469 The file contains @code{LF} or @code{FF} characters written by
12470 @code{Put} or @code{Put_Line}, which are not logically considered to be
12471 line marks or page marks.
12472
12473 @item
12474 The file ends in a character other than @code{LF} or @code{FF},
12475 i.e.@: there is no explicit line mark or page mark at the end of the file.
12476 @end itemize
12477
12478 @noindent
12479 Text_IO can be used to read such non-standard text files but subprograms
12480 to do with line or page numbers do not have defined meanings.  In
12481 particular, a @code{FF} character that does not follow a @code{LF}
12482 character may or may not be treated as a page mark from the point of
12483 view of page and line numbering.  Every @code{LF} character is considered
12484 to end a line, and there is an implied @code{LF} character at the end of
12485 the file.
12486
12487 @menu
12488 * Text_IO Stream Pointer Positioning::
12489 * Text_IO Reading and Writing Non-Regular Files::
12490 * Get_Immediate::
12491 * Treating Text_IO Files as Streams::
12492 * Text_IO Extensions::
12493 * Text_IO Facilities for Unbounded Strings::
12494 @end menu
12495
12496 @node Text_IO Stream Pointer Positioning
12497 @subsection Stream Pointer Positioning
12498
12499 @noindent
12500 @code{Ada.Text_IO} has a definition of current position for a file that
12501 is being read.  No internal buffering occurs in Text_IO, and usually the
12502 physical position in the stream used to implement the file corresponds
12503 to this logical position defined by Text_IO@.  There are two exceptions:
12504
12505 @itemize @bullet
12506 @item
12507 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12508 is positioned past the @code{LF} (line mark) that precedes the page
12509 mark.  Text_IO maintains an internal flag so that subsequent read
12510 operations properly handle the logical position which is unchanged by
12511 the @code{End_Of_Page} call.
12512
12513 @item
12514 After a call to @code{End_Of_File} that returns @code{True}, if the
12515 Text_IO file was positioned before the line mark at the end of file
12516 before the call, then the logical position is unchanged, but the stream
12517 is physically positioned right at the end of file (past the line mark,
12518 and past a possible page mark following the line mark.  Again Text_IO
12519 maintains internal flags so that subsequent read operations properly
12520 handle the logical position.
12521 @end itemize
12522
12523 @noindent
12524 These discrepancies have no effect on the observable behavior of
12525 Text_IO, but if a single Ada stream is shared between a C program and
12526 Ada program, or shared (using @samp{shared=yes} in the form string)
12527 between two Ada files, then the difference may be observable in some
12528 situations.
12529
12530 @node Text_IO Reading and Writing Non-Regular Files
12531 @subsection Reading and Writing Non-Regular Files
12532
12533 @noindent
12534 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12535 can be used for reading and writing.  Writing is not affected and the
12536 sequence of characters output is identical to the normal file case, but
12537 for reading, the behavior of Text_IO is modified to avoid undesirable
12538 look-ahead as follows:
12539
12540 An input file that is not a regular file is considered to have no page
12541 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12542 page mark) appearing in the file are considered to be data
12543 characters.  In particular:
12544
12545 @itemize @bullet
12546 @item
12547 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12548 following a line mark.  If a page mark appears, it will be treated as a
12549 data character.
12550
12551 @item
12552 This avoids the need to wait for an extra character to be typed or
12553 entered from the pipe to complete one of these operations.
12554
12555 @item
12556 @code{End_Of_Page} always returns @code{False}
12557
12558 @item
12559 @code{End_Of_File} will return @code{False} if there is a page mark at
12560 the end of the file.
12561 @end itemize
12562
12563 @noindent
12564 Output to non-regular files is the same as for regular files.  Page marks
12565 may be written to non-regular files using @code{New_Page}, but as noted
12566 above they will not be treated as page marks on input if the output is
12567 piped to another Ada program.
12568
12569 Another important discrepancy when reading non-regular files is that the end
12570 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12571 pressing the @key{EOT} key,
12572 then end of file
12573 is signaled once (i.e.@: the test @code{End_Of_File}
12574 will yield @code{True}, or a read will
12575 raise @code{End_Error}), but then reading can resume
12576 to read data past that end of
12577 file indication, until another end of file indication is entered.
12578
12579 @node Get_Immediate
12580 @subsection Get_Immediate
12581 @cindex Get_Immediate
12582
12583 @noindent
12584 Get_Immediate returns the next character (including control characters)
12585 from the input file.  In particular, Get_Immediate will return LF or FF
12586 characters used as line marks or page marks.  Such operations leave the
12587 file positioned past the control character, and it is thus not treated
12588 as having its normal function.  This means that page, line and column
12589 counts after this kind of Get_Immediate call are set as though the mark
12590 did not occur.  In the case where a Get_Immediate leaves the file
12591 positioned between the line mark and page mark (which is not normally
12592 possible), it is undefined whether the FF character will be treated as a
12593 page mark.
12594
12595 @node Treating Text_IO Files as Streams
12596 @subsection Treating Text_IO Files as Streams
12597 @cindex Stream files
12598
12599 @noindent
12600 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12601 as a stream.  Data written to a Text_IO file in this stream mode is
12602 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12603 16#0C# (@code{FF}), the resulting file may have non-standard
12604 format.  Similarly if read operations are used to read from a Text_IO
12605 file treated as a stream, then @code{LF} and @code{FF} characters may be
12606 skipped and the effect is similar to that described above for
12607 @code{Get_Immediate}.
12608
12609 @node Text_IO Extensions
12610 @subsection Text_IO Extensions
12611 @cindex Text_IO extensions
12612
12613 @noindent
12614 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12615 to the standard @code{Text_IO} package:
12616
12617 @itemize @bullet
12618 @item function File_Exists (Name : String) return Boolean;
12619 Determines if a file of the given name exists.
12620
12621 @item function Get_Line return String;
12622 Reads a string from the standard input file.  The value returned is exactly
12623 the length of the line that was read.
12624
12625 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12626 Similar, except that the parameter File specifies the file from which
12627 the string is to be read.
12628
12629 @end itemize
12630
12631 @node Text_IO Facilities for Unbounded Strings
12632 @subsection Text_IO Facilities for Unbounded Strings
12633 @cindex Text_IO for unbounded strings
12634 @cindex Unbounded_String, Text_IO operations
12635
12636 @noindent
12637 The package @code{Ada.Strings.Unbounded.Text_IO}
12638 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12639 subprograms useful for Text_IO operations on unbounded strings:
12640
12641 @itemize @bullet
12642
12643 @item function Get_Line (File : File_Type) return Unbounded_String;
12644 Reads a line from the specified file
12645 and returns the result as an unbounded string.
12646
12647 @item procedure Put (File : File_Type; U : Unbounded_String);
12648 Writes the value of the given unbounded string to the specified file
12649 Similar to the effect of
12650 @code{Put (To_String (U))} except that an extra copy is avoided.
12651
12652 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12653 Writes the value of the given unbounded string to the specified file,
12654 followed by a @code{New_Line}.
12655 Similar to the effect of @code{Put_Line (To_String (U))} except
12656 that an extra copy is avoided.
12657 @end itemize
12658
12659 @noindent
12660 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12661 and is optional.  If the parameter is omitted, then the standard input or
12662 output file is referenced as appropriate.
12663
12664 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12665 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12666 @code{Wide_Text_IO} functionality for unbounded wide strings.
12667
12668 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12669 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12670 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12671
12672 @node Wide_Text_IO
12673 @section Wide_Text_IO
12674
12675 @noindent
12676 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12677 both input and output files may contain special sequences that represent
12678 wide character values.  The encoding scheme for a given file may be
12679 specified using a FORM parameter:
12680
12681 @smallexample
12682 WCEM=@var{x}
12683 @end smallexample
12684
12685 @noindent
12686 as part of the FORM string (WCEM = wide character encoding method),
12687 where @var{x} is one of the following characters
12688
12689 @table @samp
12690 @item h
12691 Hex ESC encoding
12692 @item u
12693 Upper half encoding
12694 @item s
12695 Shift-JIS encoding
12696 @item e
12697 EUC Encoding
12698 @item 8
12699 UTF-8 encoding
12700 @item b
12701 Brackets encoding
12702 @end table
12703
12704 @noindent
12705 The encoding methods match those that
12706 can be used in a source
12707 program, but there is no requirement that the encoding method used for
12708 the source program be the same as the encoding method used for files,
12709 and different files may use different encoding methods.
12710
12711 The default encoding method for the standard files, and for opened files
12712 for which no WCEM parameter is given in the FORM string matches the
12713 wide character encoding specified for the main program (the default
12714 being brackets encoding if no coding method was specified with -gnatW).
12715
12716 @table @asis
12717 @item Hex Coding
12718 In this encoding, a wide character is represented by a five character
12719 sequence:
12720
12721 @smallexample
12722 ESC a b c d
12723 @end smallexample
12724
12725 @noindent
12726 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12727 characters (using upper case letters) of the wide character code.  For
12728 example, ESC A345 is used to represent the wide character with code
12729 16#A345#.  This scheme is compatible with use of the full
12730 @code{Wide_Character} set.
12731
12732 @item Upper Half Coding
12733 The wide character with encoding 16#abcd#, where the upper bit is on
12734 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12735 16#cd#.  The second byte may never be a format control character, but is
12736 not required to be in the upper half.  This method can be also used for
12737 shift-JIS or EUC where the internal coding matches the external coding.
12738
12739 @item Shift JIS Coding
12740 A wide character is represented by a two character sequence 16#ab# and
12741 16#cd#, with the restrictions described for upper half encoding as
12742 described above.  The internal character code is the corresponding JIS
12743 character according to the standard algorithm for Shift-JIS
12744 conversion.  Only characters defined in the JIS code set table can be
12745 used with this encoding method.
12746
12747 @item EUC Coding
12748 A wide character is represented by a two character sequence 16#ab# and
12749 16#cd#, with both characters being in the upper half.  The internal
12750 character code is the corresponding JIS character according to the EUC
12751 encoding algorithm.  Only characters defined in the JIS code set table
12752 can be used with this encoding method.
12753
12754 @item UTF-8 Coding
12755 A wide character is represented using
12756 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12757 10646-1/Am.2.  Depending on the character value, the representation
12758 is a one, two, or three byte sequence:
12759
12760 @smallexample
12761 16#0000#-16#007f#: 2#0xxxxxxx#
12762 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12763 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12764 @end smallexample
12765
12766 @noindent
12767 where the @var{xxx} bits correspond to the left-padded bits of the
12768 16-bit character value.  Note that all lower half ASCII characters
12769 are represented as ASCII bytes and all upper half characters and
12770 other wide characters are represented as sequences of upper-half
12771 (The full UTF-8 scheme allows for encoding 31-bit characters as
12772 6-byte sequences, but in this implementation, all UTF-8 sequences
12773 of four or more bytes length will raise a Constraint_Error, as
12774 will all invalid UTF-8 sequences.)
12775
12776 @item Brackets Coding
12777 In this encoding, a wide character is represented by the following eight
12778 character sequence:
12779
12780 @smallexample
12781 [ " a b c d " ]
12782 @end smallexample
12783
12784 @noindent
12785 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12786 characters (using uppercase letters) of the wide character code.  For
12787 example, @code{["A345"]} is used to represent the wide character with code
12788 @code{16#A345#}.
12789 This scheme is compatible with use of the full Wide_Character set.
12790 On input, brackets coding can also be used for upper half characters,
12791 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12792 is only used for wide characters with a code greater than @code{16#FF#}.
12793
12794 Note that brackets coding is not normally used in the context of
12795 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12796 a portable way of encoding source files. In the context of Wide_Text_IO
12797 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12798 any instance of the left bracket character other than to encode wide
12799 character values using the brackets encoding method. In practice it is
12800 expected that some standard wide character encoding method such
12801 as UTF-8 will be used for text input output.
12802
12803 If brackets notation is used, then any occurrence of a left bracket
12804 in the input file which is not the start of a valid wide character
12805 sequence will cause Constraint_Error to be raised. It is possible to
12806 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12807 input will interpret this as a left bracket.
12808
12809 However, when a left bracket is output, it will be output as a left bracket
12810 and not as ["5B"]. We make this decision because for normal use of
12811 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12812 brackets. For example, if we write:
12813
12814 @smallexample
12815    Put_Line ("Start of output [first run]");
12816 @end smallexample
12817
12818 @noindent
12819 we really do not want to have the left bracket in this message clobbered so
12820 that the output reads:
12821
12822 @smallexample
12823    Start of output ["5B"]first run]
12824 @end smallexample
12825
12826 @noindent
12827 In practice brackets encoding is reasonably useful for normal Put_Line use
12828 since we won't get confused between left brackets and wide character
12829 sequences in the output. But for input, or when files are written out
12830 and read back in, it really makes better sense to use one of the standard
12831 encoding methods such as UTF-8.
12832
12833 @end table
12834
12835 @noindent
12836 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12837 not all wide character
12838 values can be represented.  An attempt to output a character that cannot
12839 be represented using the encoding scheme for the file causes
12840 Constraint_Error to be raised.  An invalid wide character sequence on
12841 input also causes Constraint_Error to be raised.
12842
12843 @menu
12844 * Wide_Text_IO Stream Pointer Positioning::
12845 * Wide_Text_IO Reading and Writing Non-Regular Files::
12846 @end menu
12847
12848 @node Wide_Text_IO Stream Pointer Positioning
12849 @subsection Stream Pointer Positioning
12850
12851 @noindent
12852 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12853 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12854 case:
12855
12856 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12857 normal lower ASCII set (i.e.@: a character in the range:
12858
12859 @smallexample @c ada
12860 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12861 @end smallexample
12862
12863 @noindent
12864 then although the logical position of the file pointer is unchanged by
12865 the @code{Look_Ahead} call, the stream is physically positioned past the
12866 wide character sequence.  Again this is to avoid the need for buffering
12867 or backup, and all @code{Wide_Text_IO} routines check the internal
12868 indication that this situation has occurred so that this is not visible
12869 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12870 can be observed if the wide text file shares a stream with another file.
12871
12872 @node Wide_Text_IO Reading and Writing Non-Regular Files
12873 @subsection Reading and Writing Non-Regular Files
12874
12875 @noindent
12876 As in the case of Text_IO, when a non-regular file is read, it is
12877 assumed that the file contains no page marks (any form characters are
12878 treated as data characters), and @code{End_Of_Page} always returns
12879 @code{False}.  Similarly, the end of file indication is not sticky, so
12880 it is possible to read beyond an end of file.
12881
12882 @node Wide_Wide_Text_IO
12883 @section Wide_Wide_Text_IO
12884
12885 @noindent
12886 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12887 both input and output files may contain special sequences that represent
12888 wide wide character values.  The encoding scheme for a given file may be
12889 specified using a FORM parameter:
12890
12891 @smallexample
12892 WCEM=@var{x}
12893 @end smallexample
12894
12895 @noindent
12896 as part of the FORM string (WCEM = wide character encoding method),
12897 where @var{x} is one of the following characters
12898
12899 @table @samp
12900 @item h
12901 Hex ESC encoding
12902 @item u
12903 Upper half encoding
12904 @item s
12905 Shift-JIS encoding
12906 @item e
12907 EUC Encoding
12908 @item 8
12909 UTF-8 encoding
12910 @item b
12911 Brackets encoding
12912 @end table
12913
12914 @noindent
12915 The encoding methods match those that
12916 can be used in a source
12917 program, but there is no requirement that the encoding method used for
12918 the source program be the same as the encoding method used for files,
12919 and different files may use different encoding methods.
12920
12921 The default encoding method for the standard files, and for opened files
12922 for which no WCEM parameter is given in the FORM string matches the
12923 wide character encoding specified for the main program (the default
12924 being brackets encoding if no coding method was specified with -gnatW).
12925
12926 @table @asis
12927
12928 @item UTF-8 Coding
12929 A wide character is represented using
12930 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12931 10646-1/Am.2.  Depending on the character value, the representation
12932 is a one, two, three, or four byte sequence:
12933
12934 @smallexample
12935 16#000000#-16#00007f#: 2#0xxxxxxx#
12936 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12937 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12938 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12939 @end smallexample
12940
12941 @noindent
12942 where the @var{xxx} bits correspond to the left-padded bits of the
12943 21-bit character value.  Note that all lower half ASCII characters
12944 are represented as ASCII bytes and all upper half characters and
12945 other wide characters are represented as sequences of upper-half
12946 characters.
12947
12948 @item Brackets Coding
12949 In this encoding, a wide wide character is represented by the following eight
12950 character sequence if is in wide character range
12951
12952 @smallexample
12953 [ " a b c d " ]
12954 @end smallexample
12955
12956 and by the following ten character sequence if not
12957
12958 @smallexample
12959 [ " a b c d e f " ]
12960 @end smallexample
12961
12962 @noindent
12963 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12964 are the four or six hexadecimal
12965 characters (using uppercase letters) of the wide wide character code.  For
12966 example, @code{["01A345"]} is used to represent the wide wide character
12967 with code @code{16#01A345#}.
12968
12969 This scheme is compatible with use of the full Wide_Wide_Character set.
12970 On input, brackets coding can also be used for upper half characters,
12971 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12972 is only used for wide characters with a code greater than @code{16#FF#}.
12973
12974 @end table
12975
12976 @noindent
12977 If is also possible to use the other Wide_Character encoding methods,
12978 such as Shift-JIS, but the other schemes cannot support the full range
12979 of wide wide characters.
12980 An attempt to output a character that cannot
12981 be represented using the encoding scheme for the file causes
12982 Constraint_Error to be raised.  An invalid wide character sequence on
12983 input also causes Constraint_Error to be raised.
12984
12985 @menu
12986 * Wide_Wide_Text_IO Stream Pointer Positioning::
12987 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12988 @end menu
12989
12990 @node Wide_Wide_Text_IO Stream Pointer Positioning
12991 @subsection Stream Pointer Positioning
12992
12993 @noindent
12994 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12995 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12996 case:
12997
12998 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12999 normal lower ASCII set (i.e.@: a character in the range:
13000
13001 @smallexample @c ada
13002 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13003 @end smallexample
13004
13005 @noindent
13006 then although the logical position of the file pointer is unchanged by
13007 the @code{Look_Ahead} call, the stream is physically positioned past the
13008 wide character sequence.  Again this is to avoid the need for buffering
13009 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13010 indication that this situation has occurred so that this is not visible
13011 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13012 can be observed if the wide text file shares a stream with another file.
13013
13014 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13015 @subsection Reading and Writing Non-Regular Files
13016
13017 @noindent
13018 As in the case of Text_IO, when a non-regular file is read, it is
13019 assumed that the file contains no page marks (any form characters are
13020 treated as data characters), and @code{End_Of_Page} always returns
13021 @code{False}.  Similarly, the end of file indication is not sticky, so
13022 it is possible to read beyond an end of file.
13023
13024 @node Stream_IO
13025 @section Stream_IO
13026
13027 @noindent
13028 A stream file is a sequence of bytes, where individual elements are
13029 written to the file as described in the Ada Reference Manual.  The type
13030 @code{Stream_Element} is simply a byte.  There are two ways to read or
13031 write a stream file.
13032
13033 @itemize @bullet
13034 @item
13035 The operations @code{Read} and @code{Write} directly read or write a
13036 sequence of stream elements with no control information.
13037
13038 @item
13039 The stream attributes applied to a stream file transfer data in the
13040 manner described for stream attributes.
13041 @end itemize
13042
13043 @node Text Translation
13044 @section Text Translation
13045
13046 @noindent
13047 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13048 passed to Text_IO.Create and Text_IO.Open:
13049 @samp{Text_Translation=@var{Yes}} is the default, which means to
13050 translate LF to/from CR/LF on Windows systems.
13051 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13052 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13053 may be used to create Unix-style files on
13054 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13055 systems.
13056
13057 @node Shared Files
13058 @section Shared Files
13059
13060 @noindent
13061 Section A.14 of the Ada Reference Manual allows implementations to
13062 provide a wide variety of behavior if an attempt is made to access the
13063 same external file with two or more internal files.
13064
13065 To provide a full range of functionality, while at the same time
13066 minimizing the problems of portability caused by this implementation
13067 dependence, GNAT handles file sharing as follows:
13068
13069 @itemize @bullet
13070 @item
13071 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13072 to open two or more files with the same full name is considered an error
13073 and is not supported.  The exception @code{Use_Error} will be
13074 raised.  Note that a file that is not explicitly closed by the program
13075 remains open until the program terminates.
13076
13077 @item
13078 If the form parameter @samp{shared=no} appears in the form string, the
13079 file can be opened or created with its own separate stream identifier,
13080 regardless of whether other files sharing the same external file are
13081 opened.  The exact effect depends on how the C stream routines handle
13082 multiple accesses to the same external files using separate streams.
13083
13084 @item
13085 If the form parameter @samp{shared=yes} appears in the form string for
13086 each of two or more files opened using the same full name, the same
13087 stream is shared between these files, and the semantics are as described
13088 in Ada Reference Manual, Section A.14.
13089 @end itemize
13090
13091 @noindent
13092 When a program that opens multiple files with the same name is ported
13093 from another Ada compiler to GNAT, the effect will be that
13094 @code{Use_Error} is raised.
13095
13096 The documentation of the original compiler and the documentation of the
13097 program should then be examined to determine if file sharing was
13098 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13099 and @code{Create} calls as required.
13100
13101 When a program is ported from GNAT to some other Ada compiler, no
13102 special attention is required unless the @samp{shared=@var{xxx}} form
13103 parameter is used in the program.  In this case, you must examine the
13104 documentation of the new compiler to see if it supports the required
13105 file sharing semantics, and form strings modified appropriately.  Of
13106 course it may be the case that the program cannot be ported if the
13107 target compiler does not support the required functionality.  The best
13108 approach in writing portable code is to avoid file sharing (and hence
13109 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13110 completely.
13111
13112 One common use of file sharing in Ada 83 is the use of instantiations of
13113 Sequential_IO on the same file with different types, to achieve
13114 heterogeneous input-output.  Although this approach will work in GNAT if
13115 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13116 for this purpose (using the stream attributes)
13117
13118 @node Filenames encoding
13119 @section Filenames encoding
13120
13121 @noindent
13122 An encoding form parameter can be used to specify the filename
13123 encoding @samp{encoding=@var{xxx}}.
13124
13125 @itemize @bullet
13126 @item
13127 If the form parameter @samp{encoding=utf8} appears in the form string, the
13128 filename must be encoded in UTF-8.
13129
13130 @item
13131 If the form parameter @samp{encoding=8bits} appears in the form
13132 string, the filename must be a standard 8bits string.
13133 @end itemize
13134
13135 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13136 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13137 variable. And if not set @samp{utf8} is assumed.
13138
13139 @table @samp
13140 @item CP_ACP
13141 The current system Windows ANSI code page.
13142 @item CP_UTF8
13143 UTF-8 encoding
13144 @end table
13145
13146 This encoding form parameter is only supported on the Windows
13147 platform. On the other Operating Systems the run-time is supporting
13148 UTF-8 natively.
13149
13150 @node Open Modes
13151 @section Open Modes
13152
13153 @noindent
13154 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13155 using the mode shown in the following table:
13156
13157 @sp 2
13158 @center @code{Open} and @code{Create} Call Modes
13159 @smallexample
13160                                @b{OPEN }           @b{CREATE}
13161 Append_File                    "r+"             "w+"
13162 In_File                        "r"              "w+"
13163 Out_File (Direct_IO)           "r+"             "w"
13164 Out_File (all other cases)     "w"              "w"
13165 Inout_File                     "r+"             "w+"
13166 @end smallexample
13167
13168 @noindent
13169 If text file translation is required, then either @samp{b} or @samp{t}
13170 is added to the mode, depending on the setting of Text.  Text file
13171 translation refers to the mapping of CR/LF sequences in an external file
13172 to LF characters internally.  This mapping only occurs in DOS and
13173 DOS-like systems, and is not relevant to other systems.
13174
13175 A special case occurs with Stream_IO@.  As shown in the above table, the
13176 file is initially opened in @samp{r} or @samp{w} mode for the
13177 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13178 subsequently requires switching from reading to writing or vice-versa,
13179 then the file is reopened in @samp{r+} mode to permit the required operation.
13180
13181 @node Operations on C Streams
13182 @section Operations on C Streams
13183 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13184 access to the C library functions for operations on C streams:
13185
13186 @smallexample @c adanocomment
13187 package Interfaces.C_Streams is
13188   -- Note: the reason we do not use the types that are in
13189   -- Interfaces.C is that we want to avoid dragging in the
13190   -- code in this unit if possible.
13191   subtype chars is System.Address;
13192   -- Pointer to null-terminated array of characters
13193   subtype FILEs is System.Address;
13194   -- Corresponds to the C type FILE*
13195   subtype voids is System.Address;
13196   -- Corresponds to the C type void*
13197   subtype int is Integer;
13198   subtype long is Long_Integer;
13199   -- Note: the above types are subtypes deliberately, and it
13200   -- is part of this spec that the above correspondences are
13201   -- guaranteed.  This means that it is legitimate to, for
13202   -- example, use Integer instead of int.  We provide these
13203   -- synonyms for clarity, but in some cases it may be
13204   -- convenient to use the underlying types (for example to
13205   -- avoid an unnecessary dependency of a spec on the spec
13206   -- of this unit).
13207   type size_t is mod 2 ** Standard'Address_Size;
13208   NULL_Stream : constant FILEs;
13209   -- Value returned (NULL in C) to indicate an
13210   -- fdopen/fopen/tmpfile error
13211   ----------------------------------
13212   -- Constants Defined in stdio.h --
13213   ----------------------------------
13214   EOF : constant int;
13215   -- Used by a number of routines to indicate error or
13216   -- end of file
13217   IOFBF : constant int;
13218   IOLBF : constant int;
13219   IONBF : constant int;
13220   -- Used to indicate buffering mode for setvbuf call
13221   SEEK_CUR : constant int;
13222   SEEK_END : constant int;
13223   SEEK_SET : constant int;
13224   -- Used to indicate origin for fseek call
13225   function stdin return FILEs;
13226   function stdout return FILEs;
13227   function stderr return FILEs;
13228   -- Streams associated with standard files
13229   --------------------------
13230   -- Standard C functions --
13231   --------------------------
13232   -- The functions selected below are ones that are
13233   -- available in DOS, OS/2, UNIX and Xenix (but not
13234   -- necessarily in ANSI C).  These are very thin interfaces
13235   -- which copy exactly the C headers.  For more
13236   -- documentation on these functions, see the Microsoft C
13237   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13238   -- ISBN 1-55615-225-6), which includes useful information
13239   -- on system compatibility.
13240   procedure clearerr (stream : FILEs);
13241   function fclose (stream : FILEs) return int;
13242   function fdopen (handle : int; mode : chars) return FILEs;
13243   function feof (stream : FILEs) return int;
13244   function ferror (stream : FILEs) return int;
13245   function fflush (stream : FILEs) return int;
13246   function fgetc (stream : FILEs) return int;
13247   function fgets (strng : chars; n : int; stream : FILEs)
13248       return chars;
13249   function fileno (stream : FILEs) return int;
13250   function fopen (filename : chars; Mode : chars)
13251       return FILEs;
13252   -- Note: to maintain target independence, use
13253   -- text_translation_required, a boolean variable defined in
13254   -- a-sysdep.c to deal with the target dependent text
13255   -- translation requirement.  If this variable is set,
13256   -- then  b/t should be appended to the standard mode
13257   -- argument to set the text translation mode off or on
13258   -- as required.
13259   function fputc (C : int; stream : FILEs) return int;
13260   function fputs (Strng : chars; Stream : FILEs) return int;
13261   function fread
13262      (buffer : voids;
13263       size : size_t;
13264       count : size_t;
13265       stream : FILEs)
13266       return size_t;
13267   function freopen
13268      (filename : chars;
13269       mode : chars;
13270       stream : FILEs)
13271       return FILEs;
13272   function fseek
13273      (stream : FILEs;
13274       offset : long;
13275       origin : int)
13276       return int;
13277   function ftell (stream : FILEs) return long;
13278   function fwrite
13279      (buffer : voids;
13280       size : size_t;
13281       count : size_t;
13282       stream : FILEs)
13283       return size_t;
13284   function isatty (handle : int) return int;
13285   procedure mktemp (template : chars);
13286   -- The return value (which is just a pointer to template)
13287   -- is discarded
13288   procedure rewind (stream : FILEs);
13289   function rmtmp return int;
13290   function setvbuf
13291      (stream : FILEs;
13292       buffer : chars;
13293       mode : int;
13294       size : size_t)
13295       return int;
13296
13297   function tmpfile return FILEs;
13298   function ungetc (c : int; stream : FILEs) return int;
13299   function unlink (filename : chars) return int;
13300   ---------------------
13301   -- Extra functions --
13302   ---------------------
13303   -- These functions supply slightly thicker bindings than
13304   -- those above.  They are derived from functions in the
13305   -- C Run-Time Library, but may do a bit more work than
13306   -- just directly calling one of the Library functions.
13307   function is_regular_file (handle : int) return int;
13308   -- Tests if given handle is for a regular file (result 1)
13309   -- or for a non-regular file (pipe or device, result 0).
13310   ---------------------------------
13311   -- Control of Text/Binary Mode --
13312   ---------------------------------
13313   -- If text_translation_required is true, then the following
13314   -- functions may be used to dynamically switch a file from
13315   -- binary to text mode or vice versa.  These functions have
13316   -- no effect if text_translation_required is false (i.e.@: in
13317   -- normal UNIX mode).  Use fileno to get a stream handle.
13318   procedure set_binary_mode (handle : int);
13319   procedure set_text_mode (handle : int);
13320   ----------------------------
13321   -- Full Path Name support --
13322   ----------------------------
13323   procedure full_name (nam : chars; buffer : chars);
13324   -- Given a NUL terminated string representing a file
13325   -- name, returns in buffer a NUL terminated string
13326   -- representing the full path name for the file name.
13327   -- On systems where it is relevant the   drive is also
13328   -- part of the full path name.  It is the responsibility
13329   -- of the caller to pass an actual parameter for buffer
13330   -- that is big enough for any full path name.  Use
13331   -- max_path_len given below as the size of buffer.
13332   max_path_len : integer;
13333   -- Maximum length of an allowable full path name on the
13334   -- system, including a terminating NUL character.
13335 end Interfaces.C_Streams;
13336 @end smallexample
13337
13338 @node Interfacing to C Streams
13339 @section Interfacing to C Streams
13340
13341 @noindent
13342 The packages in this section permit interfacing Ada files to C Stream
13343 operations.
13344
13345 @smallexample @c ada
13346  with Interfaces.C_Streams;
13347  package Ada.Sequential_IO.C_Streams is
13348     function C_Stream (F : File_Type)
13349        return Interfaces.C_Streams.FILEs;
13350     procedure Open
13351       (File : in out File_Type;
13352        Mode : in File_Mode;
13353        C_Stream : in Interfaces.C_Streams.FILEs;
13354        Form : in String := "");
13355  end Ada.Sequential_IO.C_Streams;
13356
13357   with Interfaces.C_Streams;
13358   package Ada.Direct_IO.C_Streams is
13359      function C_Stream (F : File_Type)
13360         return Interfaces.C_Streams.FILEs;
13361      procedure Open
13362        (File : in out File_Type;
13363         Mode : in File_Mode;
13364         C_Stream : in Interfaces.C_Streams.FILEs;
13365         Form : in String := "");
13366   end Ada.Direct_IO.C_Streams;
13367
13368   with Interfaces.C_Streams;
13369   package Ada.Text_IO.C_Streams is
13370      function C_Stream (F : File_Type)
13371         return Interfaces.C_Streams.FILEs;
13372      procedure Open
13373        (File : in out File_Type;
13374         Mode : in File_Mode;
13375         C_Stream : in Interfaces.C_Streams.FILEs;
13376         Form : in String := "");
13377   end Ada.Text_IO.C_Streams;
13378
13379   with Interfaces.C_Streams;
13380   package Ada.Wide_Text_IO.C_Streams is
13381      function C_Stream (F : File_Type)
13382         return Interfaces.C_Streams.FILEs;
13383      procedure Open
13384        (File : in out File_Type;
13385         Mode : in File_Mode;
13386         C_Stream : in Interfaces.C_Streams.FILEs;
13387         Form : in String := "");
13388  end Ada.Wide_Text_IO.C_Streams;
13389
13390   with Interfaces.C_Streams;
13391   package Ada.Wide_Wide_Text_IO.C_Streams is
13392      function C_Stream (F : File_Type)
13393         return Interfaces.C_Streams.FILEs;
13394      procedure Open
13395        (File : in out File_Type;
13396         Mode : in File_Mode;
13397         C_Stream : in Interfaces.C_Streams.FILEs;
13398         Form : in String := "");
13399  end Ada.Wide_Wide_Text_IO.C_Streams;
13400
13401  with Interfaces.C_Streams;
13402  package Ada.Stream_IO.C_Streams is
13403     function C_Stream (F : File_Type)
13404        return Interfaces.C_Streams.FILEs;
13405     procedure Open
13406       (File : in out File_Type;
13407        Mode : in File_Mode;
13408        C_Stream : in Interfaces.C_Streams.FILEs;
13409        Form : in String := "");
13410  end Ada.Stream_IO.C_Streams;
13411 @end smallexample
13412
13413 @noindent
13414 In each of these six packages, the @code{C_Stream} function obtains the
13415 @code{FILE} pointer from a currently opened Ada file.  It is then
13416 possible to use the @code{Interfaces.C_Streams} package to operate on
13417 this stream, or the stream can be passed to a C program which can
13418 operate on it directly.  Of course the program is responsible for
13419 ensuring that only appropriate sequences of operations are executed.
13420
13421 One particular use of relevance to an Ada program is that the
13422 @code{setvbuf} function can be used to control the buffering of the
13423 stream used by an Ada file.  In the absence of such a call the standard
13424 default buffering is used.
13425
13426 The @code{Open} procedures in these packages open a file giving an
13427 existing C Stream instead of a file name.  Typically this stream is
13428 imported from a C program, allowing an Ada file to operate on an
13429 existing C file.
13430
13431 @node The GNAT Library
13432 @chapter The GNAT Library
13433
13434 @noindent
13435 The GNAT library contains a number of general and special purpose packages.
13436 It represents functionality that the GNAT developers have found useful, and
13437 which is made available to GNAT users.  The packages described here are fully
13438 supported, and upwards compatibility will be maintained in future releases,
13439 so you can use these facilities with the confidence that the same functionality
13440 will be available in future releases.
13441
13442 The chapter here simply gives a brief summary of the facilities available.
13443 The full documentation is found in the spec file for the package.  The full
13444 sources of these library packages, including both spec and body, are provided
13445 with all GNAT releases.  For example, to find out the full specifications of
13446 the SPITBOL pattern matching capability, including a full tutorial and
13447 extensive examples, look in the @file{g-spipat.ads} file in the library.
13448
13449 For each entry here, the package name (as it would appear in a @code{with}
13450 clause) is given, followed by the name of the corresponding spec file in
13451 parentheses.  The packages are children in four hierarchies, @code{Ada},
13452 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13453 GNAT-specific hierarchy.
13454
13455 Note that an application program should only use packages in one of these
13456 four hierarchies if the package is defined in the Ada Reference Manual,
13457 or is listed in this section of the GNAT Programmers Reference Manual.
13458 All other units should be considered internal implementation units and
13459 should not be directly @code{with}'ed by application code.  The use of
13460 a @code{with} statement that references one of these internal implementation
13461 units makes an application potentially dependent on changes in versions
13462 of GNAT, and will generate a warning message.
13463
13464 @menu
13465 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13466 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13467 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13468 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13469 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13470 * Ada.Command_Line.Environment (a-colien.ads)::
13471 * Ada.Command_Line.Remove (a-colire.ads)::
13472 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13473 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13474 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13475 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13476 * Ada.Exceptions.Traceback (a-exctra.ads)::
13477 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13478 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13479 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13480 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13481 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13482 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13483 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13484 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13485 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13486 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13487 * GNAT.Altivec (g-altive.ads)::
13488 * GNAT.Altivec.Conversions (g-altcon.ads)::
13489 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13490 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13491 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13492 * GNAT.Array_Split (g-arrspl.ads)::
13493 * GNAT.AWK (g-awk.ads)::
13494 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13495 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13496 * GNAT.Bubble_Sort (g-bubsor.ads)::
13497 * GNAT.Bubble_Sort_A (g-busora.ads)::
13498 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13499 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13500 * GNAT.Byte_Swapping (g-bytswa.ads)::
13501 * GNAT.Calendar (g-calend.ads)::
13502 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13503 * GNAT.Case_Util (g-casuti.ads)::
13504 * GNAT.CGI (g-cgi.ads)::
13505 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13506 * GNAT.CGI.Debug (g-cgideb.ads)::
13507 * GNAT.Command_Line (g-comlin.ads)::
13508 * GNAT.Compiler_Version (g-comver.ads)::
13509 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13510 * GNAT.CRC32 (g-crc32.ads)::
13511 * GNAT.Current_Exception (g-curexc.ads)::
13512 * GNAT.Debug_Pools (g-debpoo.ads)::
13513 * GNAT.Debug_Utilities (g-debuti.ads)::
13514 * GNAT.Decode_String (g-decstr.ads)::
13515 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13516 * GNAT.Directory_Operations (g-dirope.ads)::
13517 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13518 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13519 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13520 * GNAT.Encode_String (g-encstr.ads)::
13521 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13522 * GNAT.Exception_Actions (g-excact.ads)::
13523 * GNAT.Exception_Traces (g-exctra.ads)::
13524 * GNAT.Exceptions (g-except.ads)::
13525 * GNAT.Expect (g-expect.ads)::
13526 * GNAT.Float_Control (g-flocon.ads)::
13527 * GNAT.Heap_Sort (g-heasor.ads)::
13528 * GNAT.Heap_Sort_A (g-hesora.ads)::
13529 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13530 * GNAT.HTable (g-htable.ads)::
13531 * GNAT.IO (g-io.ads)::
13532 * GNAT.IO_Aux (g-io_aux.ads)::
13533 * GNAT.Lock_Files (g-locfil.ads)::
13534 * GNAT.MD5 (g-md5.ads)::
13535 * GNAT.Memory_Dump (g-memdum.ads)::
13536 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13537 * GNAT.OS_Lib (g-os_lib.ads)::
13538 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13539 * GNAT.Random_Numbers (g-rannum.ads)::
13540 * GNAT.Regexp (g-regexp.ads)::
13541 * GNAT.Registry (g-regist.ads)::
13542 * GNAT.Regpat (g-regpat.ads)::
13543 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13544 * GNAT.Semaphores (g-semaph.ads)::
13545 * GNAT.Serial_Communications (g-sercom.ads)::
13546 * GNAT.SHA1 (g-sha1.ads)::
13547 * GNAT.Signals (g-signal.ads)::
13548 * GNAT.Sockets (g-socket.ads)::
13549 * GNAT.Source_Info (g-souinf.ads)::
13550 * GNAT.Spelling_Checker (g-speche.ads)::
13551 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13552 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13553 * GNAT.Spitbol (g-spitbo.ads)::
13554 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13555 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13556 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13557 * GNAT.Strings (g-string.ads)::
13558 * GNAT.String_Split (g-strspl.ads)::
13559 * GNAT.Table (g-table.ads)::
13560 * GNAT.Task_Lock (g-tasloc.ads)::
13561 * GNAT.Threads (g-thread.ads)::
13562 * GNAT.Time_Stamp (g-timsta.ads)::
13563 * GNAT.Traceback (g-traceb.ads)::
13564 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13565 * GNAT.UTF_32 (g-utf_32.ads)::
13566 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13567 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13568 * GNAT.Wide_String_Split (g-wistsp.ads)::
13569 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13570 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13571 * Interfaces.C.Extensions (i-cexten.ads)::
13572 * Interfaces.C.Streams (i-cstrea.ads)::
13573 * Interfaces.CPP (i-cpp.ads)::
13574 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13575 * Interfaces.VxWorks (i-vxwork.ads)::
13576 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13577 * System.Address_Image (s-addima.ads)::
13578 * System.Assertions (s-assert.ads)::
13579 * System.Memory (s-memory.ads)::
13580 * System.Partition_Interface (s-parint.ads)::
13581 * System.Pool_Global (s-pooglo.ads)::
13582 * System.Pool_Local (s-pooloc.ads)::
13583 * System.Restrictions (s-restri.ads)::
13584 * System.Rident (s-rident.ads)::
13585 * System.Task_Info (s-tasinf.ads)::
13586 * System.Wch_Cnv (s-wchcnv.ads)::
13587 * System.Wch_Con (s-wchcon.ads)::
13588 @end menu
13589
13590 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13591 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13592 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13593 @cindex Latin_9 constants for Character
13594
13595 @noindent
13596 This child of @code{Ada.Characters}
13597 provides a set of definitions corresponding to those in the
13598 RM-defined package @code{Ada.Characters.Latin_1} but with the
13599 few modifications required for @code{Latin-9}
13600 The provision of such a package
13601 is specifically authorized by the Ada Reference Manual
13602 (RM A.3.3(27)).
13603
13604 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13605 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13606 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13607 @cindex Latin_1 constants for Wide_Character
13608
13609 @noindent
13610 This child of @code{Ada.Characters}
13611 provides a set of definitions corresponding to those in the
13612 RM-defined package @code{Ada.Characters.Latin_1} but with the
13613 types of the constants being @code{Wide_Character}
13614 instead of @code{Character}.  The provision of such a package
13615 is specifically authorized by the Ada Reference Manual
13616 (RM A.3.3(27)).
13617
13618 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13619 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13620 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13621 @cindex Latin_9 constants for Wide_Character
13622
13623 @noindent
13624 This child of @code{Ada.Characters}
13625 provides a set of definitions corresponding to those in the
13626 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13627 types of the constants being @code{Wide_Character}
13628 instead of @code{Character}.  The provision of such a package
13629 is specifically authorized by the Ada Reference Manual
13630 (RM A.3.3(27)).
13631
13632 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13633 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13634 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13635 @cindex Latin_1 constants for Wide_Wide_Character
13636
13637 @noindent
13638 This child of @code{Ada.Characters}
13639 provides a set of definitions corresponding to those in the
13640 RM-defined package @code{Ada.Characters.Latin_1} but with the
13641 types of the constants being @code{Wide_Wide_Character}
13642 instead of @code{Character}.  The provision of such a package
13643 is specifically authorized by the Ada Reference Manual
13644 (RM A.3.3(27)).
13645
13646 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13647 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13648 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13649 @cindex Latin_9 constants for Wide_Wide_Character
13650
13651 @noindent
13652 This child of @code{Ada.Characters}
13653 provides a set of definitions corresponding to those in the
13654 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13655 types of the constants being @code{Wide_Wide_Character}
13656 instead of @code{Character}.  The provision of such a package
13657 is specifically authorized by the Ada Reference Manual
13658 (RM A.3.3(27)).
13659
13660 @node Ada.Command_Line.Environment (a-colien.ads)
13661 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13662 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13663 @cindex Environment entries
13664
13665 @noindent
13666 This child of @code{Ada.Command_Line}
13667 provides a mechanism for obtaining environment values on systems
13668 where this concept makes sense.
13669
13670 @node Ada.Command_Line.Remove (a-colire.ads)
13671 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13672 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13673 @cindex Removing command line arguments
13674 @cindex Command line, argument removal
13675
13676 @noindent
13677 This child of @code{Ada.Command_Line}
13678 provides a mechanism for logically removing
13679 arguments from the argument list.  Once removed, an argument is not visible
13680 to further calls on the subprograms in @code{Ada.Command_Line} will not
13681 see the removed argument.
13682
13683 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13684 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13685 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13686 @cindex Response file for command line
13687 @cindex Command line, response file
13688 @cindex Command line, handling long command lines
13689
13690 @noindent
13691 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13692 getting command line arguments from a text file, called a "response file".
13693 Using a response file allow passing a set of arguments to an executable longer
13694 than the maximum allowed by the system on the command line.
13695
13696 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13697 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13698 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13699 @cindex C Streams, Interfacing with Direct_IO
13700
13701 @noindent
13702 This package provides subprograms that allow interfacing between
13703 C streams and @code{Direct_IO}.  The stream identifier can be
13704 extracted from a file opened on the Ada side, and an Ada file
13705 can be constructed from a stream opened on the C side.
13706
13707 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13708 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13709 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13710 @cindex Null_Occurrence, testing for
13711
13712 @noindent
13713 This child subprogram provides a way of testing for the null
13714 exception occurrence (@code{Null_Occurrence}) without raising
13715 an exception.
13716
13717 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13718 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13719 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13720 @cindex Null_Occurrence, testing for
13721
13722 @noindent
13723 This child subprogram is used for handling otherwise unhandled
13724 exceptions (hence the name last chance), and perform clean ups before
13725 terminating the program. Note that this subprogram never returns.
13726
13727 @node Ada.Exceptions.Traceback (a-exctra.ads)
13728 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13729 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13730 @cindex Traceback for Exception Occurrence
13731
13732 @noindent
13733 This child package provides the subprogram (@code{Tracebacks}) to
13734 give a traceback array of addresses based on an exception
13735 occurrence.
13736
13737 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13738 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13739 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13740 @cindex C Streams, Interfacing with Sequential_IO
13741
13742 @noindent
13743 This package provides subprograms that allow interfacing between
13744 C streams and @code{Sequential_IO}.  The stream identifier can be
13745 extracted from a file opened on the Ada side, and an Ada file
13746 can be constructed from a stream opened on the C side.
13747
13748 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13749 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13750 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13751 @cindex C Streams, Interfacing with Stream_IO
13752
13753 @noindent
13754 This package provides subprograms that allow interfacing between
13755 C streams and @code{Stream_IO}.  The stream identifier can be
13756 extracted from a file opened on the Ada side, and an Ada file
13757 can be constructed from a stream opened on the C side.
13758
13759 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13760 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13761 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13762 @cindex @code{Unbounded_String}, IO support
13763 @cindex @code{Text_IO}, extensions for unbounded strings
13764
13765 @noindent
13766 This package provides subprograms for Text_IO for unbounded
13767 strings, avoiding the necessity for an intermediate operation
13768 with ordinary strings.
13769
13770 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13771 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13772 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13773 @cindex @code{Unbounded_Wide_String}, IO support
13774 @cindex @code{Text_IO}, extensions for unbounded wide strings
13775
13776 @noindent
13777 This package provides subprograms for Text_IO for unbounded
13778 wide strings, avoiding the necessity for an intermediate operation
13779 with ordinary wide strings.
13780
13781 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13782 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13783 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13784 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13785 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13786
13787 @noindent
13788 This package provides subprograms for Text_IO for unbounded
13789 wide wide strings, avoiding the necessity for an intermediate operation
13790 with ordinary wide wide strings.
13791
13792 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13793 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13794 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13795 @cindex C Streams, Interfacing with @code{Text_IO}
13796
13797 @noindent
13798 This package provides subprograms that allow interfacing between
13799 C streams and @code{Text_IO}.  The stream identifier can be
13800 extracted from a file opened on the Ada side, and an Ada file
13801 can be constructed from a stream opened on the C side.
13802
13803 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13804 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13805 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13806 @cindex Unicode categorization, Wide_Character
13807
13808 @noindent
13809 This package provides subprograms that allow categorization of
13810 Wide_Character values according to Unicode categories.
13811
13812 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13813 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13814 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13815 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13816
13817 @noindent
13818 This package provides subprograms that allow interfacing between
13819 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13820 extracted from a file opened on the Ada side, and an Ada file
13821 can be constructed from a stream opened on the C side.
13822
13823 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13824 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13825 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13826 @cindex Unicode categorization, Wide_Wide_Character
13827
13828 @noindent
13829 This package provides subprograms that allow categorization of
13830 Wide_Wide_Character values according to Unicode categories.
13831
13832 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13833 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13834 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13835 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13836
13837 @noindent
13838 This package provides subprograms that allow interfacing between
13839 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13840 extracted from a file opened on the Ada side, and an Ada file
13841 can be constructed from a stream opened on the C side.
13842
13843 @node GNAT.Altivec (g-altive.ads)
13844 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13845 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13846 @cindex AltiVec
13847
13848 @noindent
13849 This is the root package of the GNAT AltiVec binding. It provides
13850 definitions of constants and types common to all the versions of the
13851 binding.
13852
13853 @node GNAT.Altivec.Conversions (g-altcon.ads)
13854 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13855 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13856 @cindex AltiVec
13857
13858 @noindent
13859 This package provides the Vector/View conversion routines.
13860
13861 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13862 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13863 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13864 @cindex AltiVec
13865
13866 @noindent
13867 This package exposes the Ada interface to the AltiVec operations on
13868 vector objects. A soft emulation is included by default in the GNAT
13869 library. The hard binding is provided as a separate package. This unit
13870 is common to both bindings.
13871
13872 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13873 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13874 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13875 @cindex AltiVec
13876
13877 @noindent
13878 This package exposes the various vector types part of the Ada binding
13879 to AltiVec facilities.
13880
13881 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13882 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13883 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13884 @cindex AltiVec
13885
13886 @noindent
13887 This package provides public 'View' data types from/to which private
13888 vector representations can be converted via
13889 GNAT.Altivec.Conversions. This allows convenient access to individual
13890 vector elements and provides a simple way to initialize vector
13891 objects.
13892
13893 @node GNAT.Array_Split (g-arrspl.ads)
13894 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13895 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13896 @cindex Array splitter
13897
13898 @noindent
13899 Useful array-manipulation routines: given a set of separators, split
13900 an array wherever the separators appear, and provide direct access
13901 to the resulting slices.
13902
13903 @node GNAT.AWK (g-awk.ads)
13904 @section @code{GNAT.AWK} (@file{g-awk.ads})
13905 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13906 @cindex Parsing
13907 @cindex AWK
13908
13909 @noindent
13910 Provides AWK-like parsing functions, with an easy interface for parsing one
13911 or more files containing formatted data.  The file is viewed as a database
13912 where each record is a line and a field is a data element in this line.
13913
13914 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13915 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13916 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13917 @cindex Parsing
13918 @cindex Bounded Buffers
13919
13920 @noindent
13921 Provides a concurrent generic bounded buffer abstraction.  Instances are
13922 useful directly or as parts of the implementations of other abstractions,
13923 such as mailboxes.
13924
13925 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13926 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13927 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13928 @cindex Parsing
13929 @cindex Mailboxes
13930
13931 @noindent
13932 Provides a thread-safe asynchronous intertask mailbox communication facility.
13933
13934 @node GNAT.Bubble_Sort (g-bubsor.ads)
13935 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13936 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13937 @cindex Sorting
13938 @cindex Bubble sort
13939
13940 @noindent
13941 Provides a general implementation of bubble sort usable for sorting arbitrary
13942 data items.  Exchange and comparison procedures are provided by passing
13943 access-to-procedure values.
13944
13945 @node GNAT.Bubble_Sort_A (g-busora.ads)
13946 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13947 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13948 @cindex Sorting
13949 @cindex Bubble sort
13950
13951 @noindent
13952 Provides a general implementation of bubble sort usable for sorting arbitrary
13953 data items.  Move and comparison procedures are provided by passing
13954 access-to-procedure values. This is an older version, retained for
13955 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13956
13957 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13958 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13959 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13960 @cindex Sorting
13961 @cindex Bubble sort
13962
13963 @noindent
13964 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13965 are provided as generic parameters, this improves efficiency, especially
13966 if the procedures can be inlined, at the expense of duplicating code for
13967 multiple instantiations.
13968
13969 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13970 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13971 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13972 @cindex UTF-8 representation
13973 @cindex Wide characte representations
13974
13975 @noindent
13976 Provides a routine which given a string, reads the start of the string to
13977 see whether it is one of the standard byte order marks (BOM's) which signal
13978 the encoding of the string. The routine includes detection of special XML
13979 sequences for various UCS input formats.
13980
13981 @node GNAT.Byte_Swapping (g-bytswa.ads)
13982 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13983 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13984 @cindex Byte swapping
13985 @cindex Endian
13986
13987 @noindent
13988 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13989 Machine-specific implementations are available in some cases.
13990
13991 @node GNAT.Calendar (g-calend.ads)
13992 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13993 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13994 @cindex @code{Calendar}
13995
13996 @noindent
13997 Extends the facilities provided by @code{Ada.Calendar} to include handling
13998 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13999 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14000 C @code{timeval} format.
14001
14002 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14003 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14004 @cindex @code{Calendar}
14005 @cindex Time
14006 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14007
14008 @node GNAT.CRC32 (g-crc32.ads)
14009 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14010 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14011 @cindex CRC32
14012 @cindex Cyclic Redundancy Check
14013
14014 @noindent
14015 This package implements the CRC-32 algorithm.  For a full description
14016 of this algorithm see
14017 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14018 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14019 Aug.@: 1988.  Sarwate, D.V@.
14020
14021 @node GNAT.Case_Util (g-casuti.ads)
14022 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14023 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14024 @cindex Casing utilities
14025 @cindex Character handling (@code{GNAT.Case_Util})
14026
14027 @noindent
14028 A set of simple routines for handling upper and lower casing of strings
14029 without the overhead of the full casing tables
14030 in @code{Ada.Characters.Handling}.
14031
14032 @node GNAT.CGI (g-cgi.ads)
14033 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14034 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14035 @cindex CGI (Common Gateway Interface)
14036
14037 @noindent
14038 This is a package for interfacing a GNAT program with a Web server via the
14039 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14040 parameters, which are a set of key/value pairs sent by the Web server.  It
14041 builds a table whose index is the key and provides some services to deal
14042 with this table.
14043
14044 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14045 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14046 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14047 @cindex CGI (Common Gateway Interface) cookie support
14048 @cindex Cookie support in CGI
14049
14050 @noindent
14051 This is a package to interface a GNAT program with a Web server via the
14052 Common Gateway Interface (CGI).  It exports services to deal with Web
14053 cookies (piece of information kept in the Web client software).
14054
14055 @node GNAT.CGI.Debug (g-cgideb.ads)
14056 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14057 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14058 @cindex CGI (Common Gateway Interface) debugging
14059
14060 @noindent
14061 This is a package to help debugging CGI (Common Gateway Interface)
14062 programs written in Ada.
14063
14064 @node GNAT.Command_Line (g-comlin.ads)
14065 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14066 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14067 @cindex Command line
14068
14069 @noindent
14070 Provides a high level interface to @code{Ada.Command_Line} facilities,
14071 including the ability to scan for named switches with optional parameters
14072 and expand file names using wild card notations.
14073
14074 @node GNAT.Compiler_Version (g-comver.ads)
14075 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14076 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14077 @cindex Compiler Version
14078 @cindex Version, of compiler
14079
14080 @noindent
14081 Provides a routine for obtaining the version of the compiler used to
14082 compile the program. More accurately this is the version of the binder
14083 used to bind the program (this will normally be the same as the version
14084 of the compiler if a consistent tool set is used to compile all units
14085 of a partition).
14086
14087 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14088 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14089 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14090 @cindex Interrupt
14091
14092 @noindent
14093 Provides a simple interface to handle Ctrl-C keyboard events.
14094
14095 @node GNAT.Current_Exception (g-curexc.ads)
14096 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14097 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14098 @cindex Current exception
14099 @cindex Exception retrieval
14100
14101 @noindent
14102 Provides access to information on the current exception that has been raised
14103 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14104 specification syntax.
14105 This is particularly useful in simulating typical facilities for
14106 obtaining information about exceptions provided by Ada 83 compilers.
14107
14108 @node GNAT.Debug_Pools (g-debpoo.ads)
14109 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14110 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14111 @cindex Debugging
14112 @cindex Debug pools
14113 @cindex Memory corruption debugging
14114
14115 @noindent
14116 Provide a debugging storage pools that helps tracking memory corruption
14117 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14118 @value{EDITION} User's Guide}.
14119
14120 @node GNAT.Debug_Utilities (g-debuti.ads)
14121 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14122 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14123 @cindex Debugging
14124
14125 @noindent
14126 Provides a few useful utilities for debugging purposes, including conversion
14127 to and from string images of address values. Supports both C and Ada formats
14128 for hexadecimal literals.
14129
14130 @node GNAT.Decode_String (g-decstr.ads)
14131 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14132 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14133 @cindex Decoding strings
14134 @cindex String decoding
14135 @cindex Wide character encoding
14136 @cindex UTF-8
14137 @cindex Unicode
14138
14139 @noindent
14140 A generic package providing routines for decoding wide character and wide wide
14141 character strings encoded as sequences of 8-bit characters using a specified
14142 encoding method. Includes validation routines, and also routines for stepping
14143 to next or previous encoded character in an encoded string.
14144 Useful in conjunction with Unicode character coding. Note there is a
14145 preinstantiation for UTF-8. See next entry.
14146
14147 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14148 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14149 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14150 @cindex Decoding strings
14151 @cindex Decoding UTF-8 strings
14152 @cindex UTF-8 string decoding
14153 @cindex Wide character decoding
14154 @cindex UTF-8
14155 @cindex Unicode
14156
14157 @noindent
14158 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14159
14160 @node GNAT.Directory_Operations (g-dirope.ads)
14161 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14162 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14163 @cindex Directory operations
14164
14165 @noindent
14166 Provides a set of routines for manipulating directories, including changing
14167 the current directory, making new directories, and scanning the files in a
14168 directory.
14169
14170 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14171 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14172 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14173 @cindex Directory operations iteration
14174
14175 @noindent
14176 A child unit of GNAT.Directory_Operations providing additional operations
14177 for iterating through directories.
14178
14179 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14180 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14181 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14182 @cindex Hash tables
14183
14184 @noindent
14185 A generic implementation of hash tables that can be used to hash arbitrary
14186 data.  Provided in two forms, a simple form with built in hash functions,
14187 and a more complex form in which the hash function is supplied.
14188
14189 @noindent
14190 This package provides a facility similar to that of @code{GNAT.HTable},
14191 except that this package declares a type that can be used to define
14192 dynamic instances of the hash table, while an instantiation of
14193 @code{GNAT.HTable} creates a single instance of the hash table.
14194
14195 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14196 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14197 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14198 @cindex Table implementation
14199 @cindex Arrays, extendable
14200
14201 @noindent
14202 A generic package providing a single dimension array abstraction where the
14203 length of the array can be dynamically modified.
14204
14205 @noindent
14206 This package provides a facility similar to that of @code{GNAT.Table},
14207 except that this package declares a type that can be used to define
14208 dynamic instances of the table, while an instantiation of
14209 @code{GNAT.Table} creates a single instance of the table type.
14210
14211 @node GNAT.Encode_String (g-encstr.ads)
14212 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14213 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14214 @cindex Encoding strings
14215 @cindex String encoding
14216 @cindex Wide character encoding
14217 @cindex UTF-8
14218 @cindex Unicode
14219
14220 @noindent
14221 A generic package providing routines for encoding wide character and wide
14222 wide character strings as sequences of 8-bit characters using a specified
14223 encoding method. Useful in conjunction with Unicode character coding.
14224 Note there is a preinstantiation for UTF-8. See next entry.
14225
14226 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14227 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14228 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14229 @cindex Encoding strings
14230 @cindex Encoding UTF-8 strings
14231 @cindex UTF-8 string encoding
14232 @cindex Wide character encoding
14233 @cindex UTF-8
14234 @cindex Unicode
14235
14236 @noindent
14237 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14238
14239 @node GNAT.Exception_Actions (g-excact.ads)
14240 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14241 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14242 @cindex Exception actions
14243
14244 @noindent
14245 Provides callbacks when an exception is raised. Callbacks can be registered
14246 for specific exceptions, or when any exception is raised. This
14247 can be used for instance to force a core dump to ease debugging.
14248
14249 @node GNAT.Exception_Traces (g-exctra.ads)
14250 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14251 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14252 @cindex Exception traces
14253 @cindex Debugging
14254
14255 @noindent
14256 Provides an interface allowing to control automatic output upon exception
14257 occurrences.
14258
14259 @node GNAT.Exceptions (g-except.ads)
14260 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14261 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14262 @cindex Exceptions, Pure
14263 @cindex Pure packages, exceptions
14264
14265 @noindent
14266 Normally it is not possible to raise an exception with
14267 a message from a subprogram in a pure package, since the
14268 necessary types and subprograms are in @code{Ada.Exceptions}
14269 which is not a pure unit. @code{GNAT.Exceptions} provides a
14270 facility for getting around this limitation for a few
14271 predefined exceptions, and for example allow raising
14272 @code{Constraint_Error} with a message from a pure subprogram.
14273
14274 @node GNAT.Expect (g-expect.ads)
14275 @section @code{GNAT.Expect} (@file{g-expect.ads})
14276 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14277
14278 @noindent
14279 Provides a set of subprograms similar to what is available
14280 with the standard Tcl Expect tool.
14281 It allows you to easily spawn and communicate with an external process.
14282 You can send commands or inputs to the process, and compare the output
14283 with some expected regular expression. Currently @code{GNAT.Expect}
14284 is implemented on all native GNAT ports except for OpenVMS@.
14285 It is not implemented for cross ports, and in particular is not
14286 implemented for VxWorks or LynxOS@.
14287
14288 @node GNAT.Float_Control (g-flocon.ads)
14289 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14290 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14291 @cindex Floating-Point Processor
14292
14293 @noindent
14294 Provides an interface for resetting the floating-point processor into the
14295 mode required for correct semantic operation in Ada.  Some third party
14296 library calls may cause this mode to be modified, and the Reset procedure
14297 in this package can be used to reestablish the required mode.
14298
14299 @node GNAT.Heap_Sort (g-heasor.ads)
14300 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14301 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14302 @cindex Sorting
14303
14304 @noindent
14305 Provides a general implementation of heap sort usable for sorting arbitrary
14306 data items. Exchange and comparison procedures are provided by passing
14307 access-to-procedure values.  The algorithm used is a modified heap sort
14308 that performs approximately N*log(N) comparisons in the worst case.
14309
14310 @node GNAT.Heap_Sort_A (g-hesora.ads)
14311 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14312 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14313 @cindex Sorting
14314
14315 @noindent
14316 Provides a general implementation of heap sort usable for sorting arbitrary
14317 data items. Move and comparison procedures are provided by passing
14318 access-to-procedure values.  The algorithm used is a modified heap sort
14319 that performs approximately N*log(N) comparisons in the worst case.
14320 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14321 interface, but may be slightly more efficient.
14322
14323 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14324 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14325 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14326 @cindex Sorting
14327
14328 @noindent
14329 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14330 are provided as generic parameters, this improves efficiency, especially
14331 if the procedures can be inlined, at the expense of duplicating code for
14332 multiple instantiations.
14333
14334 @node GNAT.HTable (g-htable.ads)
14335 @section @code{GNAT.HTable} (@file{g-htable.ads})
14336 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14337 @cindex Hash tables
14338
14339 @noindent
14340 A generic implementation of hash tables that can be used to hash arbitrary
14341 data.  Provides two approaches, one a simple static approach, and the other
14342 allowing arbitrary dynamic hash tables.
14343
14344 @node GNAT.IO (g-io.ads)
14345 @section @code{GNAT.IO} (@file{g-io.ads})
14346 @cindex @code{GNAT.IO} (@file{g-io.ads})
14347 @cindex Simple I/O
14348 @cindex Input/Output facilities
14349
14350 @noindent
14351 A simple preelaborable input-output package that provides a subset of
14352 simple Text_IO functions for reading characters and strings from
14353 Standard_Input, and writing characters, strings and integers to either
14354 Standard_Output or Standard_Error.
14355
14356 @node GNAT.IO_Aux (g-io_aux.ads)
14357 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14358 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14359 @cindex Text_IO
14360 @cindex Input/Output facilities
14361
14362 Provides some auxiliary functions for use with Text_IO, including a test
14363 for whether a file exists, and functions for reading a line of text.
14364
14365 @node GNAT.Lock_Files (g-locfil.ads)
14366 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14367 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14368 @cindex File locking
14369 @cindex Locking using files
14370
14371 @noindent
14372 Provides a general interface for using files as locks.  Can be used for
14373 providing program level synchronization.
14374
14375 @node GNAT.MD5 (g-md5.ads)
14376 @section @code{GNAT.MD5} (@file{g-md5.ads})
14377 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14378 @cindex Message Digest MD5
14379
14380 @noindent
14381 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14382
14383 @node GNAT.Memory_Dump (g-memdum.ads)
14384 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14385 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14386 @cindex Dump Memory
14387
14388 @noindent
14389 Provides a convenient routine for dumping raw memory to either the
14390 standard output or standard error files. Uses GNAT.IO for actual
14391 output.
14392
14393 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14394 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14395 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14396 @cindex Exception, obtaining most recent
14397
14398 @noindent
14399 Provides access to the most recently raised exception.  Can be used for
14400 various logging purposes, including duplicating functionality of some
14401 Ada 83 implementation dependent extensions.
14402
14403 @node GNAT.OS_Lib (g-os_lib.ads)
14404 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14405 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14406 @cindex Operating System interface
14407 @cindex Spawn capability
14408
14409 @noindent
14410 Provides a range of target independent operating system interface functions,
14411 including time/date management, file operations, subprocess management,
14412 including a portable spawn procedure, and access to environment variables
14413 and error return codes.
14414
14415 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14416 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14417 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14418 @cindex Hash functions
14419
14420 @noindent
14421 Provides a generator of static minimal perfect hash functions. No
14422 collisions occur and each item can be retrieved from the table in one
14423 probe (perfect property). The hash table size corresponds to the exact
14424 size of the key set and no larger (minimal property). The key set has to
14425 be know in advance (static property). The hash functions are also order
14426 preserving. If w2 is inserted after w1 in the generator, their
14427 hashcode are in the same order. These hashing functions are very
14428 convenient for use with realtime applications.
14429
14430 @node GNAT.Random_Numbers (g-rannum.ads)
14431 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14432 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14433 @cindex Random number generation
14434
14435 @noindent
14436 Provides random number capabilities which extend those available in the
14437 standard Ada library and are more convenient to use.
14438
14439 @node GNAT.Regexp (g-regexp.ads)
14440 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14441 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14442 @cindex Regular expressions
14443 @cindex Pattern matching
14444
14445 @noindent
14446 A simple implementation of regular expressions, using a subset of regular
14447 expression syntax copied from familiar Unix style utilities.  This is the
14448 simples of the three pattern matching packages provided, and is particularly
14449 suitable for ``file globbing'' applications.
14450
14451 @node GNAT.Registry (g-regist.ads)
14452 @section @code{GNAT.Registry} (@file{g-regist.ads})
14453 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14454 @cindex Windows Registry
14455
14456 @noindent
14457 This is a high level binding to the Windows registry.  It is possible to
14458 do simple things like reading a key value, creating a new key.  For full
14459 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14460 package provided with the Win32Ada binding
14461
14462 @node GNAT.Regpat (g-regpat.ads)
14463 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14464 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14465 @cindex Regular expressions
14466 @cindex Pattern matching
14467
14468 @noindent
14469 A complete implementation of Unix-style regular expression matching, copied
14470 from the original V7 style regular expression library written in C by
14471 Henry Spencer (and binary compatible with this C library).
14472
14473 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14474 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14475 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14476 @cindex Secondary Stack Info
14477
14478 @noindent
14479 Provide the capability to query the high water mark of the current task's
14480 secondary stack.
14481
14482 @node GNAT.Semaphores (g-semaph.ads)
14483 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14484 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14485 @cindex Semaphores
14486
14487 @noindent
14488 Provides classic counting and binary semaphores using protected types.
14489
14490 @node GNAT.Serial_Communications (g-sercom.ads)
14491 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14492 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14493 @cindex Serial_Communications
14494
14495 @noindent
14496 Provides a simple interface to send and receive data over a serial
14497 port. This is only supported on GNU/Linux and Windows.
14498
14499 @node GNAT.SHA1 (g-sha1.ads)
14500 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14501 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14502 @cindex Secure Hash Algorithm SHA-1
14503
14504 @noindent
14505 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14506
14507 @node GNAT.Signals (g-signal.ads)
14508 @section @code{GNAT.Signals} (@file{g-signal.ads})
14509 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14510 @cindex Signals
14511
14512 @noindent
14513 Provides the ability to manipulate the blocked status of signals on supported
14514 targets.
14515
14516 @node GNAT.Sockets (g-socket.ads)
14517 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14518 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14519 @cindex Sockets
14520
14521 @noindent
14522 A high level and portable interface to develop sockets based applications.
14523 This package is based on the sockets thin binding found in
14524 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14525 on all native GNAT ports except for OpenVMS@.  It is not implemented
14526 for the LynxOS@ cross port.
14527
14528 @node GNAT.Source_Info (g-souinf.ads)
14529 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14530 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14531 @cindex Source Information
14532
14533 @noindent
14534 Provides subprograms that give access to source code information known at
14535 compile time, such as the current file name and line number.
14536
14537 @node GNAT.Spelling_Checker (g-speche.ads)
14538 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14539 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14540 @cindex Spell checking
14541
14542 @noindent
14543 Provides a function for determining whether one string is a plausible
14544 near misspelling of another string.
14545
14546 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14547 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14548 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14549 @cindex Spell checking
14550
14551 @noindent
14552 Provides a generic function that can be instantiated with a string type for
14553 determining whether one string is a plausible near misspelling of another
14554 string.
14555
14556 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14557 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14558 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14559 @cindex SPITBOL pattern matching
14560 @cindex Pattern matching
14561
14562 @noindent
14563 A complete implementation of SNOBOL4 style pattern matching.  This is the
14564 most elaborate of the pattern matching packages provided.  It fully duplicates
14565 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14566 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14567
14568 @node GNAT.Spitbol (g-spitbo.ads)
14569 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14570 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14571 @cindex SPITBOL interface
14572
14573 @noindent
14574 The top level package of the collection of SPITBOL-style functionality, this
14575 package provides basic SNOBOL4 string manipulation functions, such as
14576 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14577 useful for constructing arbitrary mappings from strings in the style of
14578 the SNOBOL4 TABLE function.
14579
14580 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14581 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14582 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14583 @cindex Sets of strings
14584 @cindex SPITBOL Tables
14585
14586 @noindent
14587 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14588 for type @code{Standard.Boolean}, giving an implementation of sets of
14589 string values.
14590
14591 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14592 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14593 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14594 @cindex Integer maps
14595 @cindex Maps
14596 @cindex SPITBOL Tables
14597
14598 @noindent
14599 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14600 for type @code{Standard.Integer}, giving an implementation of maps
14601 from string to integer values.
14602
14603 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14604 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14605 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14606 @cindex String maps
14607 @cindex Maps
14608 @cindex SPITBOL Tables
14609
14610 @noindent
14611 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14612 a variable length string type, giving an implementation of general
14613 maps from strings to strings.
14614
14615 @node GNAT.Strings (g-string.ads)
14616 @section @code{GNAT.Strings} (@file{g-string.ads})
14617 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14618
14619 @noindent
14620 Common String access types and related subprograms. Basically it
14621 defines a string access and an array of string access types.
14622
14623 @node GNAT.String_Split (g-strspl.ads)
14624 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14625 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14626 @cindex String splitter
14627
14628 @noindent
14629 Useful string manipulation routines: given a set of separators, split
14630 a string wherever the separators appear, and provide direct access
14631 to the resulting slices. This package is instantiated from
14632 @code{GNAT.Array_Split}.
14633
14634 @node GNAT.Table (g-table.ads)
14635 @section @code{GNAT.Table} (@file{g-table.ads})
14636 @cindex @code{GNAT.Table} (@file{g-table.ads})
14637 @cindex Table implementation
14638 @cindex Arrays, extendable
14639
14640 @noindent
14641 A generic package providing a single dimension array abstraction where the
14642 length of the array can be dynamically modified.
14643
14644 @noindent
14645 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14646 except that this package declares a single instance of the table type,
14647 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14648 used to define dynamic instances of the table.
14649
14650 @node GNAT.Task_Lock (g-tasloc.ads)
14651 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14652 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14653 @cindex Task synchronization
14654 @cindex Task locking
14655 @cindex Locking
14656
14657 @noindent
14658 A very simple facility for locking and unlocking sections of code using a
14659 single global task lock.  Appropriate for use in situations where contention
14660 between tasks is very rarely expected.
14661
14662 @node GNAT.Time_Stamp (g-timsta.ads)
14663 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14664 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14665 @cindex Time stamp
14666 @cindex Current time
14667
14668 @noindent
14669 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14670 represents the current date and time in ISO 8601 format. This is a very simple
14671 routine with minimal code and there are no dependencies on any other unit.
14672
14673 @node GNAT.Threads (g-thread.ads)
14674 @section @code{GNAT.Threads} (@file{g-thread.ads})
14675 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14676 @cindex Foreign threads
14677 @cindex Threads, foreign
14678
14679 @noindent
14680 Provides facilities for dealing with foreign threads which need to be known
14681 by the GNAT run-time system. Consult the documentation of this package for
14682 further details if your program has threads that are created by a non-Ada
14683 environment which then accesses Ada code.
14684
14685 @node GNAT.Traceback (g-traceb.ads)
14686 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14687 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14688 @cindex Trace back facilities
14689
14690 @noindent
14691 Provides a facility for obtaining non-symbolic traceback information, useful
14692 in various debugging situations.
14693
14694 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14695 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14696 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14697 @cindex Trace back facilities
14698
14699 @node GNAT.UTF_32 (g-utf_32.ads)
14700 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14701 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14702 @cindex Wide character codes
14703
14704 @noindent
14705 This is a package intended to be used in conjunction with the
14706 @code{Wide_Character} type in Ada 95 and the
14707 @code{Wide_Wide_Character} type in Ada 2005 (available
14708 in @code{GNAT} in Ada 2005 mode). This package contains
14709 Unicode categorization routines, as well as lexical
14710 categorization routines corresponding to the Ada 2005
14711 lexical rules for identifiers and strings, and also a
14712 lower case to upper case fold routine corresponding to
14713 the Ada 2005 rules for identifier equivalence.
14714
14715 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14716 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14717 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14718 @cindex Spell checking
14719
14720 @noindent
14721 Provides a function for determining whether one wide wide string is a plausible
14722 near misspelling of another wide wide string, where the strings are represented
14723 using the UTF_32_String type defined in System.Wch_Cnv.
14724
14725 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14726 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14727 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14728 @cindex Spell checking
14729
14730 @noindent
14731 Provides a function for determining whether one wide string is a plausible
14732 near misspelling of another wide string.
14733
14734 @node GNAT.Wide_String_Split (g-wistsp.ads)
14735 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14736 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14737 @cindex Wide_String splitter
14738
14739 @noindent
14740 Useful wide string manipulation routines: given a set of separators, split
14741 a wide string wherever the separators appear, and provide direct access
14742 to the resulting slices. This package is instantiated from
14743 @code{GNAT.Array_Split}.
14744
14745 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14746 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14747 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14748 @cindex Spell checking
14749
14750 @noindent
14751 Provides a function for determining whether one wide wide string is a plausible
14752 near misspelling of another wide wide string.
14753
14754 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14755 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14756 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14757 @cindex Wide_Wide_String splitter
14758
14759 @noindent
14760 Useful wide wide string manipulation routines: given a set of separators, split
14761 a wide wide string wherever the separators appear, and provide direct access
14762 to the resulting slices. This package is instantiated from
14763 @code{GNAT.Array_Split}.
14764
14765 @node Interfaces.C.Extensions (i-cexten.ads)
14766 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14767 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14768
14769 @noindent
14770 This package contains additional C-related definitions, intended
14771 for use with either manually or automatically generated bindings
14772 to C libraries.
14773
14774 @node Interfaces.C.Streams (i-cstrea.ads)
14775 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14776 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14777 @cindex  C streams, interfacing
14778
14779 @noindent
14780 This package is a binding for the most commonly used operations
14781 on C streams.
14782
14783 @node Interfaces.CPP (i-cpp.ads)
14784 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14785 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14786 @cindex  C++ interfacing
14787 @cindex  Interfacing, to C++
14788
14789 @noindent
14790 This package provides facilities for use in interfacing to C++.  It
14791 is primarily intended to be used in connection with automated tools
14792 for the generation of C++ interfaces.
14793
14794 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14795 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14796 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14797 @cindex  IBM Packed Format
14798 @cindex  Packed Decimal
14799
14800 @noindent
14801 This package provides a set of routines for conversions to and
14802 from a packed decimal format compatible with that used on IBM
14803 mainframes.
14804
14805 @node Interfaces.VxWorks (i-vxwork.ads)
14806 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14807 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14808 @cindex Interfacing to VxWorks
14809 @cindex VxWorks, interfacing
14810
14811 @noindent
14812 This package provides a limited binding to the VxWorks API.
14813 In particular, it interfaces with the
14814 VxWorks hardware interrupt facilities.
14815
14816 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14817 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14818 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14819 @cindex Interfacing to VxWorks' I/O
14820 @cindex VxWorks, I/O interfacing
14821 @cindex VxWorks, Get_Immediate
14822 @cindex Get_Immediate, VxWorks
14823
14824 @noindent
14825 This package provides a binding to the ioctl (IO/Control)
14826 function of VxWorks, defining a set of option values and
14827 function codes. A particular use of this package is
14828 to enable the use of Get_Immediate under VxWorks.
14829
14830 @node System.Address_Image (s-addima.ads)
14831 @section @code{System.Address_Image} (@file{s-addima.ads})
14832 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14833 @cindex Address image
14834 @cindex Image, of an address
14835
14836 @noindent
14837 This function provides a useful debugging
14838 function that gives an (implementation dependent)
14839 string which identifies an address.
14840
14841 @node System.Assertions (s-assert.ads)
14842 @section @code{System.Assertions} (@file{s-assert.ads})
14843 @cindex @code{System.Assertions} (@file{s-assert.ads})
14844 @cindex Assertions
14845 @cindex Assert_Failure, exception
14846
14847 @noindent
14848 This package provides the declaration of the exception raised
14849 by an run-time assertion failure, as well as the routine that
14850 is used internally to raise this assertion.
14851
14852 @node System.Memory (s-memory.ads)
14853 @section @code{System.Memory} (@file{s-memory.ads})
14854 @cindex @code{System.Memory} (@file{s-memory.ads})
14855 @cindex Memory allocation
14856
14857 @noindent
14858 This package provides the interface to the low level routines used
14859 by the generated code for allocation and freeing storage for the
14860 default storage pool (analogous to the C routines malloc and free.
14861 It also provides a reallocation interface analogous to the C routine
14862 realloc. The body of this unit may be modified to provide alternative
14863 allocation mechanisms for the default pool, and in addition, direct
14864 calls to this unit may be made for low level allocation uses (for
14865 example see the body of @code{GNAT.Tables}).
14866
14867 @node System.Partition_Interface (s-parint.ads)
14868 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14869 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14870 @cindex Partition interfacing functions
14871
14872 @noindent
14873 This package provides facilities for partition interfacing.  It
14874 is used primarily in a distribution context when using Annex E
14875 with @code{GLADE}.
14876
14877 @node System.Pool_Global (s-pooglo.ads)
14878 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14879 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14880 @cindex Storage pool, global
14881 @cindex Global storage pool
14882
14883 @noindent
14884 This package provides a storage pool that is equivalent to the default
14885 storage pool used for access types for which no pool is specifically
14886 declared. It uses malloc/free to allocate/free and does not attempt to
14887 do any automatic reclamation.
14888
14889 @node System.Pool_Local (s-pooloc.ads)
14890 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14891 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14892 @cindex Storage pool, local
14893 @cindex Local storage pool
14894
14895 @noindent
14896 This package provides a storage pool that is intended for use with locally
14897 defined access types. It uses malloc/free for allocate/free, and maintains
14898 a list of allocated blocks, so that all storage allocated for the pool can
14899 be freed automatically when the pool is finalized.
14900
14901 @node System.Restrictions (s-restri.ads)
14902 @section @code{System.Restrictions} (@file{s-restri.ads})
14903 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14904 @cindex Run-time restrictions access
14905
14906 @noindent
14907 This package provides facilities for accessing at run time
14908 the status of restrictions specified at compile time for
14909 the partition. Information is available both with regard
14910 to actual restrictions specified, and with regard to
14911 compiler determined information on which restrictions
14912 are violated by one or more packages in the partition.
14913
14914 @node System.Rident (s-rident.ads)
14915 @section @code{System.Rident} (@file{s-rident.ads})
14916 @cindex @code{System.Rident} (@file{s-rident.ads})
14917 @cindex Restrictions definitions
14918
14919 @noindent
14920 This package provides definitions of the restrictions
14921 identifiers supported by GNAT, and also the format of
14922 the restrictions provided in package System.Restrictions.
14923 It is not normally necessary to @code{with} this generic package
14924 since the necessary instantiation is included in
14925 package System.Restrictions.
14926
14927 @node System.Task_Info (s-tasinf.ads)
14928 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14929 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14930 @cindex Task_Info pragma
14931
14932 @noindent
14933 This package provides target dependent functionality that is used
14934 to support the @code{Task_Info} pragma
14935
14936 @node System.Wch_Cnv (s-wchcnv.ads)
14937 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14938 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14939 @cindex Wide Character, Representation
14940 @cindex Wide String, Conversion
14941 @cindex Representation of wide characters
14942
14943 @noindent
14944 This package provides routines for converting between
14945 wide and wide wide characters and a representation as a value of type
14946 @code{Standard.String}, using a specified wide character
14947 encoding method.  It uses definitions in
14948 package @code{System.Wch_Con}.
14949
14950 @node System.Wch_Con (s-wchcon.ads)
14951 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14952 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14953
14954 @noindent
14955 This package provides definitions and descriptions of
14956 the various methods used for encoding wide characters
14957 in ordinary strings.  These definitions are used by
14958 the package @code{System.Wch_Cnv}.
14959
14960 @node Interfacing to Other Languages
14961 @chapter Interfacing to Other Languages
14962 @noindent
14963 The facilities in annex B of the Ada Reference Manual are fully
14964 implemented in GNAT, and in addition, a full interface to C++ is
14965 provided.
14966
14967 @menu
14968 * Interfacing to C::
14969 * Interfacing to C++::
14970 * Interfacing to COBOL::
14971 * Interfacing to Fortran::
14972 * Interfacing to non-GNAT Ada code::
14973 @end menu
14974
14975 @node Interfacing to C
14976 @section Interfacing to C
14977
14978 @noindent
14979 Interfacing to C with GNAT can use one of two approaches:
14980
14981 @itemize @bullet
14982 @item
14983 The types in the package @code{Interfaces.C} may be used.
14984 @item
14985 Standard Ada types may be used directly.  This may be less portable to
14986 other compilers, but will work on all GNAT compilers, which guarantee
14987 correspondence between the C and Ada types.
14988 @end itemize
14989
14990 @noindent
14991 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14992 effect, since this is the default.  The following table shows the
14993 correspondence between Ada scalar types and the corresponding C types.
14994
14995 @table @code
14996 @item Integer
14997 @code{int}
14998 @item Short_Integer
14999 @code{short}
15000 @item Short_Short_Integer
15001 @code{signed char}
15002 @item Long_Integer
15003 @code{long}
15004 @item Long_Long_Integer
15005 @code{long long}
15006 @item Short_Float
15007 @code{float}
15008 @item Float
15009 @code{float}
15010 @item Long_Float
15011 @code{double}
15012 @item Long_Long_Float
15013 This is the longest floating-point type supported by the hardware.
15014 @end table
15015
15016 @noindent
15017 Additionally, there are the following general correspondences between Ada
15018 and C types:
15019 @itemize @bullet
15020 @item
15021 Ada enumeration types map to C enumeration types directly if pragma
15022 @code{Convention C} is specified, which causes them to have int
15023 length.  Without pragma @code{Convention C}, Ada enumeration types map to
15024 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15025 @code{int}, respectively) depending on the number of values passed.
15026 This is the only case in which pragma @code{Convention C} affects the
15027 representation of an Ada type.
15028
15029 @item
15030 Ada access types map to C pointers, except for the case of pointers to
15031 unconstrained types in Ada, which have no direct C equivalent.
15032
15033 @item
15034 Ada arrays map directly to C arrays.
15035
15036 @item
15037 Ada records map directly to C structures.
15038
15039 @item
15040 Packed Ada records map to C structures where all members are bit fields
15041 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15042 @end itemize
15043
15044 @node Interfacing to C++
15045 @section Interfacing to C++
15046
15047 @noindent
15048 The interface to C++ makes use of the following pragmas, which are
15049 primarily intended to be constructed automatically using a binding generator
15050 tool, although it is possible to construct them by hand.  No suitable binding
15051 generator tool is supplied with GNAT though.
15052
15053 Using these pragmas it is possible to achieve complete
15054 inter-operability between Ada tagged types and C++ class definitions.
15055 See @ref{Implementation Defined Pragmas}, for more details.
15056
15057 @table @code
15058 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15059 The argument denotes an entity in the current declarative region that is
15060 declared as a tagged or untagged record type. It indicates that the type
15061 corresponds to an externally declared C++ class type, and is to be laid
15062 out the same way that C++ would lay out the type.
15063
15064 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15065 for backward compatibility but its functionality is available
15066 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15067
15068 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15069 This pragma identifies an imported function (imported in the usual way
15070 with pragma @code{Import}) as corresponding to a C++ constructor.
15071 @end table
15072
15073 @node Interfacing to COBOL
15074 @section Interfacing to COBOL
15075
15076 @noindent
15077 Interfacing to COBOL is achieved as described in section B.4 of
15078 the Ada Reference Manual.
15079
15080 @node Interfacing to Fortran
15081 @section Interfacing to Fortran
15082
15083 @noindent
15084 Interfacing to Fortran is achieved as described in section B.5 of the
15085 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15086 multi-dimensional array causes the array to be stored in column-major
15087 order as required for convenient interface to Fortran.
15088
15089 @node Interfacing to non-GNAT Ada code
15090 @section Interfacing to non-GNAT Ada code
15091
15092 It is possible to specify the convention @code{Ada} in a pragma
15093 @code{Import} or pragma @code{Export}.  However this refers to
15094 the calling conventions used by GNAT, which may or may not be
15095 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15096 compiler to allow interoperation.
15097
15098 If arguments types are kept simple, and if the foreign compiler generally
15099 follows system calling conventions, then it may be possible to integrate
15100 files compiled by other Ada compilers, provided that the elaboration
15101 issues are adequately addressed (for example by eliminating the
15102 need for any load time elaboration).
15103
15104 In particular, GNAT running on VMS is designed to
15105 be highly compatible with the DEC Ada 83 compiler, so this is one
15106 case in which it is possible to import foreign units of this type,
15107 provided that the data items passed are restricted to simple scalar
15108 values or simple record types without variants, or simple array
15109 types with fixed bounds.
15110
15111 @node Specialized Needs Annexes
15112 @chapter Specialized Needs Annexes
15113
15114 @noindent
15115 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15116 required in all implementations.  However, as described in this chapter,
15117 GNAT implements all of these annexes:
15118
15119 @table @asis
15120 @item Systems Programming (Annex C)
15121 The Systems Programming Annex is fully implemented.
15122
15123 @item Real-Time Systems (Annex D)
15124 The Real-Time Systems Annex is fully implemented.
15125
15126 @item Distributed Systems (Annex E)
15127 Stub generation is fully implemented in the GNAT compiler.  In addition,
15128 a complete compatible PCS is available as part of the GLADE system,
15129 a separate product.  When the two
15130 products are used in conjunction, this annex is fully implemented.
15131
15132 @item Information Systems (Annex F)
15133 The Information Systems annex is fully implemented.
15134
15135 @item Numerics (Annex G)
15136 The Numerics Annex is fully implemented.
15137
15138 @item Safety and Security / High-Integrity Systems (Annex H)
15139 The Safety and Security Annex (termed the High-Integrity Systems Annex
15140 in Ada 2005) is fully implemented.
15141 @end table
15142
15143 @node Implementation of Specific Ada Features
15144 @chapter Implementation of Specific Ada Features
15145
15146 @noindent
15147 This chapter describes the GNAT implementation of several Ada language
15148 facilities.
15149
15150 @menu
15151 * Machine Code Insertions::
15152 * GNAT Implementation of Tasking::
15153 * GNAT Implementation of Shared Passive Packages::
15154 * Code Generation for Array Aggregates::
15155 * The Size of Discriminated Records with Default Discriminants::
15156 * Strict Conformance to the Ada Reference Manual::
15157 @end menu
15158
15159 @node Machine Code Insertions
15160 @section Machine Code Insertions
15161 @cindex Machine Code insertions
15162
15163 @noindent
15164 Package @code{Machine_Code} provides machine code support as described
15165 in the Ada Reference Manual in two separate forms:
15166 @itemize @bullet
15167 @item
15168 Machine code statements, consisting of qualified expressions that
15169 fit the requirements of RM section 13.8.
15170 @item
15171 An intrinsic callable procedure, providing an alternative mechanism of
15172 including machine instructions in a subprogram.
15173 @end itemize
15174
15175 @noindent
15176 The two features are similar, and both are closely related to the mechanism
15177 provided by the asm instruction in the GNU C compiler.  Full understanding
15178 and use of the facilities in this package requires understanding the asm
15179 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15180 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15181
15182 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15183 semantic restrictions and effects as described below.  Both are provided so
15184 that the procedure call can be used as a statement, and the function call
15185 can be used to form a code_statement.
15186
15187 The first example given in the GCC documentation is the C @code{asm}
15188 instruction:
15189 @smallexample
15190    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15191 @end smallexample
15192
15193 @noindent
15194 The equivalent can be written for GNAT as:
15195
15196 @smallexample @c ada
15197 Asm ("fsinx %1 %0",
15198      My_Float'Asm_Output ("=f", result),
15199      My_Float'Asm_Input  ("f",  angle));
15200 @end smallexample
15201
15202 @noindent
15203 The first argument to @code{Asm} is the assembler template, and is
15204 identical to what is used in GNU C@.  This string must be a static
15205 expression.  The second argument is the output operand list.  It is
15206 either a single @code{Asm_Output} attribute reference, or a list of such
15207 references enclosed in parentheses (technically an array aggregate of
15208 such references).
15209
15210 The @code{Asm_Output} attribute denotes a function that takes two
15211 parameters.  The first is a string, the second is the name of a variable
15212 of the type designated by the attribute prefix.  The first (string)
15213 argument is required to be a static expression and designates the
15214 constraint for the parameter (e.g.@: what kind of register is
15215 required).  The second argument is the variable to be updated with the
15216 result.  The possible values for constraint are the same as those used in
15217 the RTL, and are dependent on the configuration file used to build the
15218 GCC back end.  If there are no output operands, then this argument may
15219 either be omitted, or explicitly given as @code{No_Output_Operands}.
15220
15221 The second argument of @code{@var{my_float}'Asm_Output} functions as
15222 though it were an @code{out} parameter, which is a little curious, but
15223 all names have the form of expressions, so there is no syntactic
15224 irregularity, even though normally functions would not be permitted
15225 @code{out} parameters.  The third argument is the list of input
15226 operands.  It is either a single @code{Asm_Input} attribute reference, or
15227 a list of such references enclosed in parentheses (technically an array
15228 aggregate of such references).
15229
15230 The @code{Asm_Input} attribute denotes a function that takes two
15231 parameters.  The first is a string, the second is an expression of the
15232 type designated by the prefix.  The first (string) argument is required
15233 to be a static expression, and is the constraint for the parameter,
15234 (e.g.@: what kind of register is required).  The second argument is the
15235 value to be used as the input argument.  The possible values for the
15236 constant are the same as those used in the RTL, and are dependent on
15237 the configuration file used to built the GCC back end.
15238
15239 If there are no input operands, this argument may either be omitted, or
15240 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15241 present in the above example, is a list of register names, called the
15242 @dfn{clobber} argument.  This argument, if given, must be a static string
15243 expression, and is a space or comma separated list of names of registers
15244 that must be considered destroyed as a result of the @code{Asm} call.  If
15245 this argument is the null string (the default value), then the code
15246 generator assumes that no additional registers are destroyed.
15247
15248 The fifth argument, not present in the above example, called the
15249 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15250 the literal value @code{True} to indicate to the code generator that all
15251 optimizations with respect to the instruction specified should be
15252 suppressed, and that in particular, for an instruction that has outputs,
15253 the instruction will still be generated, even if none of the outputs are
15254 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15255 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15256 Generally it is strongly advisable to use Volatile for any ASM statement
15257 that is missing either input or output operands, or when two or more ASM
15258 statements appear in sequence, to avoid unwanted optimizations. A warning
15259 is generated if this advice is not followed.
15260
15261 The @code{Asm} subprograms may be used in two ways.  First the procedure
15262 forms can be used anywhere a procedure call would be valid, and
15263 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15264 be used to intersperse machine instructions with other Ada statements.
15265 Second, the function forms, which return a dummy value of the limited
15266 private type @code{Asm_Insn}, can be used in code statements, and indeed
15267 this is the only context where such calls are allowed.  Code statements
15268 appear as aggregates of the form:
15269
15270 @smallexample @c ada
15271 Asm_Insn'(Asm (@dots{}));
15272 Asm_Insn'(Asm_Volatile (@dots{}));
15273 @end smallexample
15274
15275 @noindent
15276 In accordance with RM rules, such code statements are allowed only
15277 within subprograms whose entire body consists of such statements.  It is
15278 not permissible to intermix such statements with other Ada statements.
15279
15280 Typically the form using intrinsic procedure calls is more convenient
15281 and more flexible.  The code statement form is provided to meet the RM
15282 suggestion that such a facility should be made available.  The following
15283 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15284 is used, the arguments may be given in arbitrary order, following the
15285 normal rules for use of positional and named arguments)
15286
15287 @smallexample
15288 ASM_CALL ::= Asm (
15289                  [Template =>] static_string_EXPRESSION
15290                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15291                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15292                [,[Clobber  =>] static_string_EXPRESSION ]
15293                [,[Volatile =>] static_boolean_EXPRESSION] )
15294
15295 OUTPUT_OPERAND_LIST ::=
15296   [PREFIX.]No_Output_Operands
15297 | OUTPUT_OPERAND_ATTRIBUTE
15298 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15299
15300 OUTPUT_OPERAND_ATTRIBUTE ::=
15301   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15302
15303 INPUT_OPERAND_LIST ::=
15304   [PREFIX.]No_Input_Operands
15305 | INPUT_OPERAND_ATTRIBUTE
15306 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15307
15308 INPUT_OPERAND_ATTRIBUTE ::=
15309   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15310 @end smallexample
15311
15312 @noindent
15313 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15314 are declared in the package @code{Machine_Code} and must be referenced
15315 according to normal visibility rules. In particular if there is no
15316 @code{use} clause for this package, then appropriate package name
15317 qualification is required.
15318
15319 @node GNAT Implementation of Tasking
15320 @section GNAT Implementation of Tasking
15321
15322 @noindent
15323 This chapter outlines the basic GNAT approach to tasking (in particular,
15324 a multi-layered library for portability) and discusses issues related
15325 to compliance with the Real-Time Systems Annex.
15326
15327 @menu
15328 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15329 * Ensuring Compliance with the Real-Time Annex::
15330 @end menu
15331
15332 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15333 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15334
15335 @noindent
15336 GNAT's run-time support comprises two layers:
15337
15338 @itemize @bullet
15339 @item GNARL (GNAT Run-time Layer)
15340 @item GNULL (GNAT Low-level Library)
15341 @end itemize
15342
15343 @noindent
15344 In GNAT, Ada's tasking services rely on a platform and OS independent
15345 layer known as GNARL@.  This code is responsible for implementing the
15346 correct semantics of Ada's task creation, rendezvous, protected
15347 operations etc.
15348
15349 GNARL decomposes Ada's tasking semantics into simpler lower level
15350 operations such as create a thread, set the priority of a thread,
15351 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15352 operations constitutes GNULLI, the GNULL Interface.  This interface is
15353 directly inspired from the POSIX real-time API@.
15354
15355 If the underlying executive or OS implements the POSIX standard
15356 faithfully, the GNULL Interface maps as is to the services offered by
15357 the underlying kernel.  Otherwise, some target dependent glue code maps
15358 the services offered by the underlying kernel to the semantics expected
15359 by GNARL@.
15360
15361 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15362 key point is that each Ada task is mapped on a thread in the underlying
15363 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15364
15365 In addition Ada task priorities map onto the underlying thread priorities.
15366 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15367
15368 @itemize @bullet
15369 @item
15370 The underlying scheduler is used to schedule the Ada tasks.  This
15371 makes Ada tasks as efficient as kernel threads from a scheduling
15372 standpoint.
15373
15374 @item
15375 Interaction with code written in C containing threads is eased
15376 since at the lowest level Ada tasks and C threads map onto the same
15377 underlying kernel concept.
15378
15379 @item
15380 When an Ada task is blocked during I/O the remaining Ada tasks are
15381 able to proceed.
15382
15383 @item
15384 On multiprocessor systems Ada tasks can execute in parallel.
15385 @end itemize
15386
15387 @noindent
15388 Some threads libraries offer a mechanism to fork a new process, with the
15389 child process duplicating the threads from the parent.
15390 GNAT does not
15391 support this functionality when the parent contains more than one task.
15392 @cindex Forking a new process
15393
15394 @node Ensuring Compliance with the Real-Time Annex
15395 @subsection Ensuring Compliance with the Real-Time Annex
15396 @cindex Real-Time Systems Annex compliance
15397
15398 @noindent
15399 Although mapping Ada tasks onto
15400 the underlying threads has significant advantages, it does create some
15401 complications when it comes to respecting the scheduling semantics
15402 specified in the real-time annex (Annex D).
15403
15404 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15405 scheduling policy states:
15406
15407 @quotation
15408 @emph{When the active priority of a ready task that is not running
15409 changes, or the setting of its base priority takes effect, the
15410 task is removed from the ready queue for its old active priority
15411 and is added at the tail of the ready queue for its new active
15412 priority, except in the case where the active priority is lowered
15413 due to the loss of inherited priority, in which case the task is
15414 added at the head of the ready queue for its new active priority.}
15415 @end quotation
15416
15417 @noindent
15418 While most kernels do put tasks at the end of the priority queue when
15419 a task changes its priority, (which respects the main
15420 FIFO_Within_Priorities requirement), almost none keep a thread at the
15421 beginning of its priority queue when its priority drops from the loss
15422 of inherited priority.
15423
15424 As a result most vendors have provided incomplete Annex D implementations.
15425
15426 The GNAT run-time, has a nice cooperative solution to this problem
15427 which ensures that accurate FIFO_Within_Priorities semantics are
15428 respected.
15429
15430 The principle is as follows.  When an Ada task T is about to start
15431 running, it checks whether some other Ada task R with the same
15432 priority as T has been suspended due to the loss of priority
15433 inheritance.  If this is the case, T yields and is placed at the end of
15434 its priority queue.  When R arrives at the front of the queue it
15435 executes.
15436
15437 Note that this simple scheme preserves the relative order of the tasks
15438 that were ready to execute in the priority queue where R has been
15439 placed at the end.
15440
15441 @node GNAT Implementation of Shared Passive Packages
15442 @section GNAT Implementation of Shared Passive Packages
15443 @cindex Shared passive packages
15444
15445 @noindent
15446 GNAT fully implements the pragma @code{Shared_Passive} for
15447 @cindex pragma @code{Shared_Passive}
15448 the purpose of designating shared passive packages.
15449 This allows the use of passive partitions in the
15450 context described in the Ada Reference Manual; i.e., for communication
15451 between separate partitions of a distributed application using the
15452 features in Annex E.
15453 @cindex Annex E
15454 @cindex Distribution Systems Annex
15455
15456 However, the implementation approach used by GNAT provides for more
15457 extensive usage as follows:
15458
15459 @table @emph
15460 @item Communication between separate programs
15461
15462 This allows separate programs to access the data in passive
15463 partitions, using protected objects for synchronization where
15464 needed. The only requirement is that the two programs have a
15465 common shared file system. It is even possible for programs
15466 running on different machines with different architectures
15467 (e.g.@: different endianness) to communicate via the data in
15468 a passive partition.
15469
15470 @item Persistence between program runs
15471
15472 The data in a passive package can persist from one run of a
15473 program to another, so that a later program sees the final
15474 values stored by a previous run of the same program.
15475
15476 @end table
15477
15478 @noindent
15479 The implementation approach used is to store the data in files. A
15480 separate stream file is created for each object in the package, and
15481 an access to an object causes the corresponding file to be read or
15482 written.
15483
15484 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15485 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15486 set to the directory to be used for these files.
15487 The files in this directory
15488 have names that correspond to their fully qualified names. For
15489 example, if we have the package
15490
15491 @smallexample @c ada
15492 package X is
15493   pragma Shared_Passive (X);
15494   Y : Integer;
15495   Z : Float;
15496 end X;
15497 @end smallexample
15498
15499 @noindent
15500 and the environment variable is set to @code{/stemp/}, then the files created
15501 will have the names:
15502
15503 @smallexample
15504 /stemp/x.y
15505 /stemp/x.z
15506 @end smallexample
15507
15508 @noindent
15509 These files are created when a value is initially written to the object, and
15510 the files are retained until manually deleted. This provides the persistence
15511 semantics. If no file exists, it means that no partition has assigned a value
15512 to the variable; in this case the initial value declared in the package
15513 will be used. This model ensures that there are no issues in synchronizing
15514 the elaboration process, since elaboration of passive packages elaborates the
15515 initial values, but does not create the files.
15516
15517 The files are written using normal @code{Stream_IO} access.
15518 If you want to be able
15519 to communicate between programs or partitions running on different
15520 architectures, then you should use the XDR versions of the stream attribute
15521 routines, since these are architecture independent.
15522
15523 If active synchronization is required for access to the variables in the
15524 shared passive package, then as described in the Ada Reference Manual, the
15525 package may contain protected objects used for this purpose. In this case
15526 a lock file (whose name is @file{___lock} (three underscores)
15527 is created in the shared memory directory.
15528 @cindex @file{___lock} file (for shared passive packages)
15529 This is used to provide the required locking
15530 semantics for proper protected object synchronization.
15531
15532 As of January 2003, GNAT supports shared passive packages on all platforms
15533 except for OpenVMS.
15534
15535 @node Code Generation for Array Aggregates
15536 @section Code Generation for Array Aggregates
15537
15538 @menu
15539 * Static constant aggregates with static bounds::
15540 * Constant aggregates with unconstrained nominal types::
15541 * Aggregates with static bounds::
15542 * Aggregates with non-static bounds::
15543 * Aggregates in assignment statements::
15544 @end menu
15545
15546 @noindent
15547 Aggregates have a rich syntax and allow the user to specify the values of
15548 complex data structures by means of a single construct.  As a result, the
15549 code generated for aggregates can be quite complex and involve loops, case
15550 statements and multiple assignments.  In the simplest cases, however, the
15551 compiler will recognize aggregates whose components and constraints are
15552 fully static, and in those cases the compiler will generate little or no
15553 executable code.  The following is an outline of the code that GNAT generates
15554 for various aggregate constructs.  For further details, you will find it
15555 useful to examine the output produced by the -gnatG flag to see the expanded
15556 source that is input to the code generator.  You may also want to examine
15557 the assembly code generated at various levels of optimization.
15558
15559 The code generated for aggregates depends on the context, the component values,
15560 and the type.  In the context of an object declaration the code generated is
15561 generally simpler than in the case of an assignment.  As a general rule, static
15562 component values and static subtypes also lead to simpler code.
15563
15564 @node Static constant aggregates with static bounds
15565 @subsection Static constant aggregates with static bounds
15566
15567 @noindent
15568 For the declarations:
15569 @smallexample @c ada
15570     type One_Dim is array (1..10) of integer;
15571     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15572 @end smallexample
15573
15574 @noindent
15575 GNAT generates no executable code: the constant ar0 is placed in static memory.
15576 The same is true for constant aggregates with named associations:
15577
15578 @smallexample @c ada
15579     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15580     Cr3 : constant One_Dim := (others => 7777);
15581 @end smallexample
15582
15583 @noindent
15584 The same is true for multidimensional constant arrays such as:
15585
15586 @smallexample @c ada
15587     type two_dim is array (1..3, 1..3) of integer;
15588     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15589 @end smallexample
15590
15591 @noindent
15592 The same is true for arrays of one-dimensional arrays: the following are
15593 static:
15594
15595 @smallexample @c ada
15596 type ar1b  is array (1..3) of boolean;
15597 type ar_ar is array (1..3) of ar1b;
15598 None  : constant ar1b := (others => false);     --  fully static
15599 None2 : constant ar_ar := (1..3 => None);       --  fully static
15600 @end smallexample
15601
15602 @noindent
15603 However, for multidimensional aggregates with named associations, GNAT will
15604 generate assignments and loops, even if all associations are static.  The
15605 following two declarations generate a loop for the first dimension, and
15606 individual component assignments for the second dimension:
15607
15608 @smallexample @c ada
15609 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15610 Zero2: constant two_dim := (others => (others => 0));
15611 @end smallexample
15612
15613 @node Constant aggregates with unconstrained nominal types
15614 @subsection Constant aggregates with unconstrained nominal types
15615
15616 @noindent
15617 In such cases the aggregate itself establishes the subtype, so that
15618 associations with @code{others} cannot be used.  GNAT determines the
15619 bounds for the actual subtype of the aggregate, and allocates the
15620 aggregate statically as well.  No code is generated for the following:
15621
15622 @smallexample @c ada
15623     type One_Unc is array (natural range <>) of integer;
15624     Cr_Unc : constant One_Unc := (12,24,36);
15625 @end smallexample
15626
15627 @node Aggregates with static bounds
15628 @subsection Aggregates with static bounds
15629
15630 @noindent
15631 In all previous examples the aggregate was the initial (and immutable) value
15632 of a constant.  If the aggregate initializes a variable, then code is generated
15633 for it as a combination of individual assignments and loops over the target
15634 object.  The declarations
15635
15636 @smallexample @c ada
15637        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15638        Cr_Var2 : One_Dim := (others > -1);
15639 @end smallexample
15640
15641 @noindent
15642 generate the equivalent of
15643
15644 @smallexample @c ada
15645        Cr_Var1 (1) := 2;
15646        Cr_Var1 (2) := 3;
15647        Cr_Var1 (3) := 5;
15648        Cr_Var1 (4) := 11;
15649
15650        for I in Cr_Var2'range loop
15651           Cr_Var2 (I) := -1;
15652        end loop;
15653 @end smallexample
15654
15655 @node Aggregates with non-static bounds
15656 @subsection Aggregates with non-static bounds
15657
15658 @noindent
15659 If the bounds of the aggregate are not statically compatible with the bounds
15660 of the nominal subtype  of the target, then constraint checks have to be
15661 generated on the bounds.  For a multidimensional array, constraint checks may
15662 have to be applied to sub-arrays individually, if they do not have statically
15663 compatible subtypes.
15664
15665 @node Aggregates in assignment statements
15666 @subsection Aggregates in assignment statements
15667
15668 @noindent
15669 In general, aggregate assignment requires the construction of a temporary,
15670 and a copy from the temporary to the target of the assignment.  This is because
15671 it is not always possible to convert the assignment into a series of individual
15672 component assignments.  For example, consider the simple case:
15673
15674 @smallexample @c ada
15675         A := (A(2), A(1));
15676 @end smallexample
15677
15678 @noindent
15679 This cannot be converted into:
15680
15681 @smallexample @c ada
15682         A(1) := A(2);
15683         A(2) := A(1);
15684 @end smallexample
15685
15686 @noindent
15687 So the aggregate has to be built first in a separate location, and then
15688 copied into the target.  GNAT recognizes simple cases where this intermediate
15689 step is not required, and the assignments can be performed in place, directly
15690 into the target.  The following sufficient criteria are applied:
15691
15692 @itemize @bullet
15693 @item
15694 The bounds of the aggregate are static, and the associations are static.
15695 @item
15696 The components of the aggregate are static constants, names of
15697 simple variables that are not renamings, or expressions not involving
15698 indexed components whose operands obey these rules.
15699 @end itemize
15700
15701 @noindent
15702 If any of these conditions are violated, the aggregate will be built in
15703 a temporary (created either by the front-end or the code generator) and then
15704 that temporary will be copied onto the target.
15705
15706
15707 @node The Size of Discriminated Records with Default Discriminants
15708 @section The Size of Discriminated Records with Default Discriminants
15709
15710 @noindent
15711 If a discriminated type @code{T} has discriminants with default values, it is
15712 possible to declare an object of this type without providing an explicit
15713 constraint:
15714
15715 @smallexample @c ada
15716 @group
15717 type Size is range 1..100;
15718
15719 type Rec (D : Size := 15) is record
15720    Name : String (1..D);
15721 end T;
15722
15723 Word : Rec;
15724 @end group
15725 @end smallexample
15726
15727 @noindent
15728 Such an object is said to be @emph{unconstrained}.
15729 The discriminant of the object
15730 can be modified by a full assignment to the object, as long as it preserves the
15731 relation between the value of the discriminant, and the value of the components
15732 that depend on it:
15733
15734 @smallexample @c ada
15735 @group
15736 Word := (3, "yes");
15737
15738 Word := (5, "maybe");
15739
15740 Word := (5, "no"); -- raises Constraint_Error
15741 @end group
15742 @end smallexample
15743
15744 @noindent
15745 In order to support this behavior efficiently, an unconstrained object is
15746 given the maximum size that any value of the type requires. In the case
15747 above, @code{Word} has storage for the discriminant and for
15748 a @code{String} of length 100.
15749 It is important to note that unconstrained objects do not require dynamic
15750 allocation. It would be an improper implementation to place on the heap those
15751 components whose size depends on discriminants. (This improper implementation
15752 was used by some Ada83 compilers, where the @code{Name} component above
15753 would have
15754 been stored as a pointer to a dynamic string). Following the principle that
15755 dynamic storage management should never be introduced implicitly,
15756 an Ada compiler should reserve the full size for an unconstrained declared
15757 object, and place it on the stack.
15758
15759 This maximum size approach
15760 has been a source of surprise to some users, who expect the default
15761 values of the discriminants to determine the size reserved for an
15762 unconstrained object: ``If the default is 15, why should the object occupy
15763 a larger size?''
15764 The answer, of course, is that the discriminant may be later modified,
15765 and its full range of values must be taken into account. This is why the
15766 declaration:
15767
15768 @smallexample
15769 @group
15770 type Rec (D : Positive := 15) is record
15771    Name : String (1..D);
15772 end record;
15773
15774 Too_Large : Rec;
15775 @end group
15776 @end smallexample
15777
15778 @noindent
15779 is flagged by the compiler with a warning:
15780 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15781 because the required size includes @code{Positive'Last}
15782 bytes. As the first example indicates, the proper approach is to declare an
15783 index type of ``reasonable'' range so that unconstrained objects are not too
15784 large.
15785
15786 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15787 created in the heap by means of an allocator, then it is @emph{not}
15788 unconstrained:
15789 it is constrained by the default values of the discriminants, and those values
15790 cannot be modified by full assignment. This is because in the presence of
15791 aliasing all views of the object (which may be manipulated by different tasks,
15792 say) must be consistent, so it is imperative that the object, once created,
15793 remain invariant.
15794
15795 @node Strict Conformance to the Ada Reference Manual
15796 @section Strict Conformance to the Ada Reference Manual
15797
15798 @noindent
15799 The dynamic semantics defined by the Ada Reference Manual impose a set of
15800 run-time checks to be generated. By default, the GNAT compiler will insert many
15801 run-time checks into the compiled code, including most of those required by the
15802 Ada Reference Manual. However, there are three checks that are not enabled
15803 in the default mode for efficiency reasons: arithmetic overflow checking for
15804 integer operations (including division by zero), checks for access before
15805 elaboration on subprogram calls, and stack overflow checking (most operating
15806 systems do not perform this check by default).
15807
15808 Strict conformance to the Ada Reference Manual can be achieved by adding
15809 three compiler options for overflow checking for integer operations
15810 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15811 calls and generic instantiations (@option{-gnatE}), and stack overflow
15812 checking (@option{-fstack-check}).
15813
15814 Note that the result of a floating point arithmetic operation in overflow and
15815 invalid situations, when the @code{Machine_Overflows} attribute of the result
15816 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15817 case for machines compliant with the IEEE floating-point standard, but on
15818 machines that are not fully compliant with this standard, such as Alpha, the
15819 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15820 behavior (although at the cost of a significant performance penalty), so
15821 infinite and and NaN values are properly generated.
15822
15823
15824 @node Project File Reference
15825 @chapter Project File Reference
15826
15827 @noindent
15828 This chapter describes the syntax and semantics of project files.
15829 Project files specify the options to be used when building a system.
15830 Project files can specify global settings for all tools,
15831 as well as tool-specific settings.
15832 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15833 for examples of use.
15834
15835 @menu
15836 * Reserved Words::
15837 * Lexical Elements::
15838 * Declarations::
15839 * Empty declarations::
15840 * Typed string declarations::
15841 * Variables::
15842 * Expressions::
15843 * Attributes::
15844 * Project Attributes::
15845 * Attribute References::
15846 * External Values::
15847 * Case Construction::
15848 * Packages::
15849 * Package Renamings::
15850 * Projects::
15851 * Project Extensions::
15852 * Project File Elaboration::
15853 @end menu
15854
15855 @node Reserved Words
15856 @section Reserved Words
15857
15858 @noindent
15859 All Ada reserved words are reserved in project files, and cannot be used
15860 as variable names or project names. In addition, the following are
15861 also reserved in project files:
15862
15863 @itemize
15864 @item @code{extends}
15865
15866 @item @code{external}
15867
15868 @item @code{project}
15869
15870 @end itemize
15871
15872 @node Lexical Elements
15873 @section Lexical Elements
15874
15875 @noindent
15876 Rules for identifiers are the same as in Ada. Identifiers
15877 are case-insensitive.  Strings are case sensitive, except where noted.
15878 Comments have the same form as in Ada.
15879
15880 @noindent
15881 Syntax:
15882
15883 @smallexample
15884 simple_name ::=
15885   identifier
15886
15887 name ::=
15888   simple_name @{. simple_name@}
15889 @end smallexample
15890
15891 @node Declarations
15892 @section Declarations
15893
15894 @noindent
15895 Declarations introduce new entities that denote types, variables, attributes,
15896 and packages. Some declarations can only appear immediately within a project
15897 declaration. Others can appear within a project or within a package.
15898
15899 Syntax:
15900 @smallexample
15901 declarative_item ::=
15902   simple_declarative_item |
15903   typed_string_declaration |
15904   package_declaration
15905
15906 simple_declarative_item ::=
15907   variable_declaration |
15908   typed_variable_declaration |
15909   attribute_declaration |
15910   case_construction |
15911   empty_declaration
15912 @end smallexample
15913
15914 @node Empty declarations
15915 @section Empty declarations
15916
15917 @smallexample
15918 empty_declaration ::=
15919   @b{null} ;
15920 @end smallexample
15921
15922 An empty declaration is allowed anywhere a declaration is allowed.
15923 It has no effect.
15924
15925 @node Typed string declarations
15926 @section Typed string declarations
15927
15928 @noindent
15929 Typed strings are sequences of string literals. Typed strings are the only
15930 named types in project files. They are used in case constructions, where they
15931 provide support for conditional attribute definitions.
15932
15933 Syntax:
15934 @smallexample
15935 typed_string_declaration ::=
15936   @b{type} <typed_string_>_simple_name @b{is}
15937    ( string_literal @{, string_literal@} );
15938 @end smallexample
15939
15940 @noindent
15941 A typed string declaration can only appear immediately within a project
15942 declaration.
15943
15944 All the string literals in a typed string declaration must be distinct.
15945
15946 @node Variables
15947 @section Variables
15948
15949 @noindent
15950 Variables denote values, and appear as constituents of expressions.
15951
15952 @smallexample
15953 typed_variable_declaration ::=
15954   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15955
15956 variable_declaration ::=
15957   <variable_>simple_name := expression;
15958 @end smallexample
15959
15960 @noindent
15961 The elaboration of a variable declaration introduces the variable and
15962 assigns to it the value of the expression. The name of the variable is
15963 available after the assignment symbol.
15964
15965 @noindent
15966 A typed_variable can only be declare once.
15967
15968 @noindent
15969 a non-typed variable can be declared multiple times.
15970
15971 @noindent
15972 Before the completion of its first declaration, the value of variable
15973 is the null string.
15974
15975 @node Expressions
15976 @section Expressions
15977
15978 @noindent
15979 An expression is a formula that defines a computation or retrieval of a value.
15980 In a project file the value of an expression is either a string or a list
15981 of strings. A string value in an expression is either a literal, the current
15982 value of a variable, an external value, an attribute reference, or a
15983 concatenation operation.
15984
15985 Syntax:
15986
15987 @smallexample
15988 expression ::=
15989   term @{& term@}
15990
15991 term ::=
15992   string_literal |
15993   string_list |
15994   <variable_>name |
15995   external_value |
15996   attribute_reference
15997
15998 string_literal ::=
15999   (same as Ada)
16000
16001 string_list ::=
16002   ( <string_>expression @{ , <string_>expression @} )
16003 @end smallexample
16004
16005 @subsection Concatenation
16006 @noindent
16007 The following concatenation functions are defined:
16008
16009 @smallexample @c ada
16010   function "&" (X : String;      Y : String)      return String;
16011   function "&" (X : String_List; Y : String)      return String_List;
16012   function "&" (X : String_List; Y : String_List) return String_List;
16013 @end smallexample
16014
16015 @node Attributes
16016 @section Attributes
16017
16018 @noindent
16019 An attribute declaration defines a property of a project or package. This
16020 property can later be queried by means of an attribute reference.
16021 Attribute values are strings or string lists.
16022
16023 Some attributes are associative arrays. These attributes are mappings whose
16024 domain is a set of strings. These attributes are declared one association
16025 at a time, by specifying a point in the domain and the corresponding image
16026 of the attribute. They may also be declared as a full associative array,
16027 getting the same associations as the corresponding attribute in an imported
16028 or extended project.
16029
16030 Attributes that are not associative arrays are called simple attributes.
16031
16032 Syntax:
16033 @smallexample
16034 attribute_declaration ::=
16035   full_associative_array_declaration |
16036   @b{for} attribute_designator @b{use} expression ;
16037
16038 full_associative_array_declaration ::=
16039   @b{for} <associative_array_attribute_>simple_name @b{use}
16040   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16041
16042 attribute_designator ::=
16043   <simple_attribute_>simple_name |
16044   <associative_array_attribute_>simple_name ( string_literal )
16045 @end smallexample
16046
16047 @noindent
16048 Some attributes are project-specific, and can only appear immediately within
16049 a project declaration. Others are package-specific, and can only appear within
16050 the proper package.
16051
16052 The expression in an attribute definition must be a string or a string_list.
16053 The string literal appearing in the attribute_designator of an associative
16054 array attribute is case-insensitive.
16055
16056 @node Project Attributes
16057 @section Project Attributes
16058
16059 @noindent
16060 The following attributes apply to a project. All of them are simple
16061 attributes.
16062
16063 @table @code
16064 @item   Object_Dir
16065 Expression must be a path name. The attribute defines the
16066 directory in which the object files created by the build are to be placed. If
16067 not specified, object files are placed in the project directory.
16068
16069 @item   Exec_Dir
16070 Expression must be a path name. The attribute defines the
16071 directory in which the executables created by the build are to be placed.
16072 If not specified, executables are placed in the object directory.
16073
16074 @item  Source_Dirs
16075 Expression must be a list of path names. The attribute
16076 defines the directories in which the source files for the project are to be
16077 found. If not specified, source files are found in the project directory.
16078 If a string in the list ends with "/**", then the directory that precedes
16079 "/**" and all of its subdirectories (recursively) are included in the list
16080 of source directories.
16081
16082 @item  Excluded_Source_Dirs
16083 Expression must be a list of strings. Each entry designates a directory that
16084 is not to be included in the list of source directories of the project.
16085 This is normally used when there are strings ending with "/**" in the value
16086 of attribute Source_Dirs.
16087
16088 @item  Source_Files
16089 Expression must be a list of file names. The attribute
16090 defines the individual files, in the project directory, which are to be used
16091 as sources for the project. File names are path_names that contain no directory
16092 information. If the project has no sources the attribute must be declared
16093 explicitly with an empty list.
16094
16095 @item  Excluded_Source_Files (Locally_Removed_Files)
16096 Expression must be a list of strings that are legal file names.
16097 Each file name must designate a source that would normally be a source file
16098 in the source directories of the project or, if the project file is an
16099 extending project file, inherited by the current project file. It cannot
16100 designate an immediate source that is not inherited. Each of the source files
16101 in the list are not considered to be sources of the project file: they are not
16102 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16103 Excluded_Source_Files is preferred.
16104
16105 @item  Source_List_File
16106 Expression must a single path name. The attribute
16107 defines a text file that contains a list of source file names to be used
16108 as sources for the project
16109
16110 @item  Library_Dir
16111 Expression must be a path name. The attribute defines the
16112 directory in which a  library is to be built.  The directory must exist, must
16113 be distinct from the project's object directory, and must be writable.
16114
16115 @item  Library_Name
16116 Expression must be a string that is a legal file name,
16117 without extension. The attribute defines a string that is used to generate
16118 the name of the library to be built by the project.
16119
16120 @item  Library_Kind
16121 Argument must be a string value that must be one of the
16122 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16123 string is case-insensitive. If this attribute is not specified, the library is
16124 a static library. Otherwise, the library may be dynamic or relocatable. This
16125 distinction is operating-system dependent.
16126
16127 @item  Library_Version
16128 Expression must be a string value whose interpretation
16129 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16130 libraries as the internal name of the library (the @code{"soname"}). If the
16131 library file name (built from the @code{Library_Name}) is different from the
16132 @code{Library_Version}, then the library file will be a symbolic link to the
16133 actual file whose name will be @code{Library_Version}.
16134
16135 @item Library_Interface
16136 Expression must be a string list. Each element of the string list
16137 must designate a unit of the project.
16138 If this attribute is present in a Library Project File, then the project
16139 file is a Stand-alone Library_Project_File.
16140
16141 @item Library_Auto_Init
16142 Expression must be a single string "true" or "false", case-insensitive.
16143 If this attribute is present in a Stand-alone Library Project File,
16144 it indicates if initialization is automatic when the dynamic library
16145 is loaded.
16146
16147 @item Library_Options
16148 Expression must be a string list. Indicates additional switches that
16149 are to be used when building a shared library.
16150
16151 @item Library_GCC
16152 Expression must be a single string. Designates an alternative to "gcc"
16153 for building shared libraries.
16154
16155 @item  Library_Src_Dir
16156 Expression must be a path name. The attribute defines the
16157 directory in which the sources of the interfaces of a Stand-alone Library will
16158 be copied.  The directory must exist, must be distinct from the project's
16159 object directory and source directories of all projects in the project tree,
16160 and must be writable.
16161
16162 @item  Library_Src_Dir
16163 Expression must be a path name. The attribute defines the
16164 directory in which the ALI files of a Library will
16165 be copied.  The directory must exist, must be distinct from the project's
16166 object directory and source directories of all projects in the project tree,
16167 and must be writable.
16168
16169 @item  Library_Symbol_File
16170 Expression must be a single string. Its value is the single file name of a
16171 symbol file to be created when building a stand-alone library when the
16172 symbol policy is either "compliant", "controlled" or "restricted",
16173 on platforms that support symbol control, such as VMS. When symbol policy
16174 is "direct", then a file with this name must exist in the object directory.
16175
16176 @item   Library_Reference_Symbol_File
16177 Expression must be a single string. Its value is the path name of a
16178 reference symbol file that is read when the symbol policy is either
16179 "compliant" or "controlled", on platforms that support symbol control,
16180 such as VMS, when building a stand-alone library. The path may be an absolute
16181 path or a path relative to the project directory.
16182
16183 @item  Library_Symbol_Policy
16184 Expression must be a single string. Its case-insensitive value can only be
16185 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16186
16187 This attribute is not taken into account on all platforms. It controls the
16188 policy for exported symbols and, on some platforms (like VMS) that have the
16189 notions of major and minor IDs built in the library files, it controls
16190 the setting of these IDs.
16191
16192 "autonomous" or "default": exported symbols are not controlled.
16193
16194 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16195 it is equivalent to policy "autonomous". If there are exported symbols in
16196 the reference symbol file that are not in the object files of the interfaces,
16197 the major ID of the library is increased. If there are symbols in the
16198 object files of the interfaces that are not in the reference symbol file,
16199 these symbols are put at the end of the list in the newly created symbol file
16200 and the minor ID is increased.
16201
16202 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16203 The library will fail to build if the exported symbols in the object files of
16204 the interfaces do not match exactly the symbol in the symbol file.
16205
16206 "restricted": The attribute Library_Symbol_File must be defined. The library
16207 will fail to build if there are symbols in the symbol file that are not in
16208 the exported symbols of the object files of the interfaces. Additional symbols
16209 in the object files are not added to the symbol file.
16210
16211 "direct": The attribute Library_Symbol_File must be defined and must designate
16212 an existing file in the object directory. This symbol file is passed directly
16213 to the underlying linker without any symbol processing.
16214
16215 @item  Main
16216 Expression must be a list of strings that are legal file names.
16217 These file names designate existing compilation units in the source directory
16218 that are legal main subprograms.
16219
16220 When a project file is elaborated, as part of the execution of a gnatmake
16221 command, one or several executables are built and placed in the Exec_Dir.
16222 If the gnatmake command does not include explicit file names, the executables
16223 that are built correspond to the files specified by this attribute.
16224
16225 @item  Externally_Built
16226 Expression must be a single string. Its value must be either "true" of "false",
16227 case-insensitive. The default is "false". When the value of this attribute is
16228 "true", no attempt is made to compile the sources or to build the library,
16229 when the project is a library project.
16230
16231 @item Main_Language
16232 This is a simple attribute. Its value is a string that specifies the
16233 language of the main program.
16234
16235 @item  Languages
16236 Expression must be a string list. Each string designates
16237 a programming language that is known to GNAT. The strings are case-insensitive.
16238
16239 @end table
16240
16241 @node Attribute References
16242 @section Attribute References
16243
16244 @noindent
16245 Attribute references are used to retrieve the value of previously defined
16246 attribute for a package or project.
16247 Syntax:
16248 @smallexample
16249 attribute_reference ::=
16250   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16251
16252 attribute_prefix ::=
16253   @b{project} |
16254   <project_simple_name | package_identifier |
16255   <project_>simple_name . package_identifier
16256 @end smallexample
16257
16258 @noindent
16259 If an attribute has not been specified for a given package or project, its
16260 value is the null string or the empty list.
16261
16262 @node External Values
16263 @section External Values
16264
16265 @noindent
16266 An external value is an expression whose value is obtained from the command
16267 that invoked the processing of the current project file (typically a
16268 gnatmake command).
16269
16270 Syntax:
16271 @smallexample
16272 external_value ::=
16273   @b{external} ( string_literal [, string_literal] )
16274 @end smallexample
16275
16276 @noindent
16277 The first string_literal is the string to be used on the command line or
16278 in the environment to specify the external value. The second string_literal,
16279 if present, is the default to use if there is no specification for this
16280 external value either on the command line or in the environment.
16281
16282 @node Case Construction
16283 @section Case Construction
16284
16285 @noindent
16286 A case construction supports attribute and variable declarations that depend
16287 on the value of a previously declared variable.
16288
16289 Syntax:
16290 @smallexample
16291 case_construction ::=
16292   @b{case} <typed_variable_>name @b{is}
16293     @{case_item@}
16294   @b{end case} ;
16295
16296 case_item ::=
16297   @b{when} discrete_choice_list =>
16298     @{case_construction |
16299       attribute_declaration |
16300       variable_declaration |
16301       empty_declaration@}
16302
16303 discrete_choice_list ::=
16304   string_literal @{| string_literal@} |
16305     @b{others}
16306 @end smallexample
16307
16308 @noindent
16309 Inside a case construction, variable declarations must be for variables that
16310 have already been declared before the case construction.
16311
16312 All choices in a choice list must be distinct. The choice lists of two
16313 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16314 alternatives do not need to include all values of the type. An @code{others}
16315 choice must appear last in the list of alternatives.
16316
16317 @node Packages
16318 @section Packages
16319
16320 @noindent
16321 A package provides a grouping of variable declarations and attribute
16322 declarations to be used when invoking various GNAT tools. The name of
16323 the package indicates the tool(s) to which it applies.
16324 Syntax:
16325
16326 @smallexample
16327 package_declaration ::=
16328   package_spec | package_renaming
16329
16330 package_spec ::=
16331   @b{package} package_identifier @b{is}
16332     @{simple_declarative_item@}
16333   @b{end} package_identifier ;
16334
16335 package_identifier ::=
16336   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16337   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16338   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16339 @end smallexample
16340
16341 @subsection Package Naming
16342
16343 @noindent
16344 The attributes of a @code{Naming} package specifies the naming conventions
16345 that apply to the source files in a project. When invoking other GNAT tools,
16346 they will use the sources in the source directories that satisfy these
16347 naming conventions.
16348
16349 The following attributes apply to a @code{Naming} package:
16350
16351 @table @code
16352 @item Casing
16353 This is a simple attribute whose value is a string. Legal values of this
16354 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16355 These strings are themselves case insensitive.
16356
16357 @noindent
16358 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16359
16360 @item Dot_Replacement
16361 This is a simple attribute whose string value satisfies the following
16362 requirements:
16363
16364 @itemize @bullet
16365 @item It must not be empty
16366 @item It cannot start or end with an alphanumeric character
16367 @item It cannot be a single underscore
16368 @item It cannot start with an underscore followed by an alphanumeric
16369 @item It cannot contain a dot @code{'.'} if longer than one character
16370 @end itemize
16371
16372 @noindent
16373 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16374
16375 @item Spec_Suffix
16376 This is an associative array attribute, defined on language names,
16377 whose image is a string that must satisfy the following
16378 conditions:
16379
16380 @itemize @bullet
16381 @item It must not be empty
16382 @item It cannot start with an alphanumeric character
16383 @item It cannot start with an underscore followed by an alphanumeric character
16384 @end itemize
16385
16386 @noindent
16387 For Ada, the attribute denotes the suffix used in file names that contain
16388 library unit declarations, that is to say units that are package and
16389 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16390 specified, then the default is @code{".ads"}.
16391
16392 For C and C++, the attribute denotes the suffix used in file names that
16393 contain prototypes.
16394
16395 @item Body_Suffix
16396 This is an associative array attribute defined on language names,
16397 whose image is a string that must satisfy the following
16398 conditions:
16399
16400 @itemize @bullet
16401 @item It must not be empty
16402 @item It cannot start with an alphanumeric character
16403 @item It cannot start with an underscore followed by an alphanumeric character
16404 @item It cannot be a suffix of @code{Spec_Suffix}
16405 @end itemize
16406
16407 @noindent
16408 For Ada, the attribute denotes the suffix used in file names that contain
16409 library bodies, that is to say units that are package and subprogram bodies.
16410 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16411 @code{".adb"}.
16412
16413 For C and C++, the attribute denotes the suffix used in file names that contain
16414 source code.
16415
16416 @item Separate_Suffix
16417 This is a simple attribute whose value satisfies the same conditions as
16418 @code{Body_Suffix}.
16419
16420 This attribute is specific to Ada. It denotes the suffix used in file names
16421 that contain separate bodies. If it is not specified, then it defaults to same
16422 value as @code{Body_Suffix ("Ada")}.
16423
16424 @item Spec
16425 This is an associative array attribute, specific to Ada, defined over
16426 compilation unit names. The image is a string that is the name of the file
16427 that contains that library unit. The file name is case sensitive if the
16428 conventions of the host operating system require it.
16429
16430 @item Body
16431 This is an associative array attribute, specific to Ada, defined over
16432 compilation unit names. The image is a string that is the name of the file
16433 that contains the library unit body for the named unit. The file name is case
16434 sensitive if the conventions of the host operating system require it.
16435
16436 @item Specification_Exceptions
16437 This is an associative array attribute defined on language names,
16438 whose value is a list of strings.
16439
16440 This attribute is not significant for Ada.
16441
16442 For C and C++, each string in the list denotes the name of a file that
16443 contains prototypes, but whose suffix is not necessarily the
16444 @code{Spec_Suffix} for the language.
16445
16446 @item Implementation_Exceptions
16447 This is an associative array attribute defined on language names,
16448 whose value is a list of strings.
16449
16450 This attribute is not significant for Ada.
16451
16452 For C and C++, each string in the list denotes the name of a file that
16453 contains source code, but whose suffix is not necessarily the
16454 @code{Body_Suffix} for the language.
16455 @end table
16456
16457 The following attributes of package @code{Naming} are obsolescent. They are
16458 kept as synonyms of other attributes for compatibility with previous versions
16459 of the Project Manager.
16460
16461 @table @code
16462 @item Specification_Suffix
16463 This is a synonym of @code{Spec_Suffix}.
16464
16465 @item Implementation_Suffix
16466 This is a synonym of @code{Body_Suffix}.
16467
16468 @item Specification
16469 This is a synonym of @code{Spec}.
16470
16471 @item Implementation
16472 This is a synonym of @code{Body}.
16473 @end table
16474
16475 @subsection package Compiler
16476
16477 @noindent
16478 The attributes of the @code{Compiler} package specify the compilation options
16479 to be used by the underlying compiler.
16480
16481 @table @code
16482 @item  Default_Switches
16483 This is an associative array attribute. Its
16484 domain is a set of language names. Its range is a string list that
16485 specifies the compilation options to be used when compiling a component
16486 written in that language, for which no file-specific switches have been
16487 specified.
16488
16489 @item  Switches
16490 This is an associative array attribute. Its domain is
16491 a set of file names. Its range is a string list that specifies the
16492 compilation options to be used when compiling the named file. If a file
16493 is not specified in the Switches attribute, it is compiled with the
16494 options specified by Default_Switches of its language, if defined.
16495
16496 @item  Local_Configuration_Pragmas.
16497 This is a simple attribute, whose
16498 value is a path name that designates a file containing configuration pragmas
16499 to be used for all invocations of the compiler for immediate sources of the
16500 project.
16501 @end table
16502
16503 @subsection package Builder
16504
16505 @noindent
16506 The attributes of package @code{Builder} specify the compilation, binding, and
16507 linking options to be used when building an executable for a project. The
16508 following attributes apply to package @code{Builder}:
16509
16510 @table @code
16511 @item Default_Switches
16512 This is an associative array attribute. Its
16513 domain is a set of language names. Its range is a string list that
16514 specifies options to be used when building a main
16515 written in that language, for which no file-specific switches have been
16516 specified.
16517
16518 @item Switches
16519 This is an associative array attribute. Its domain is
16520 a set of file names. Its range is a string list that specifies
16521 options to be used when building the named main file. If a main file
16522 is not specified in the Switches attribute, it is built with the
16523 options specified by Default_Switches of its language, if defined.
16524
16525 @item Global_Configuration_Pragmas
16526 This is a simple attribute, whose
16527 value is a path name that designates a file that contains configuration pragmas
16528 to be used in every build of an executable. If both local and global
16529 configuration pragmas are specified, a compilation makes use of both sets.
16530
16531
16532 @item Executable
16533 This is an associative array attribute. Its domain is
16534 a set of main source file names. Its range is a simple string that specifies
16535 the executable file name to be used when linking the specified main source.
16536 If a main source is not specified in the Executable attribute, the executable
16537 file name is deducted from the main source file name.
16538 This attribute has no effect if its value is the empty string.
16539
16540 @item Executable_Suffix
16541 This is a simple attribute whose value is the suffix to be added to
16542 the executables that don't have an attribute Executable specified.
16543 @end table
16544
16545 @subsection package Gnatls
16546
16547 @noindent
16548 The attributes of package @code{Gnatls} specify the tool options to be used
16549 when invoking the library browser @command{gnatls}.
16550 The following attributes apply to package @code{Gnatls}:
16551
16552 @table @code
16553 @item Switches
16554 This is a single attribute with a string list value. Each nonempty string
16555 in the list is an option when invoking @code{gnatls}.
16556 @end table
16557
16558 @subsection package Binder
16559
16560 @noindent
16561 The attributes of package @code{Binder} specify the options to be used
16562 when invoking the binder in the construction of an executable.
16563 The following attributes apply to package @code{Binder}:
16564
16565 @table @code
16566 @item     Default_Switches
16567 This is an associative array attribute. Its
16568 domain is a set of language names. Its range is a string list that
16569 specifies options to be used when binding a main
16570 written in that language, for which no file-specific switches have been
16571 specified.
16572
16573 @item Switches
16574 This is an associative array attribute. Its domain is
16575 a set of file names. Its range is a string list that specifies
16576 options to be used when binding the named main file. If a main file
16577 is not specified in the Switches attribute, it is bound with the
16578 options specified by Default_Switches of its language, if defined.
16579 @end table
16580
16581 @subsection package Linker
16582
16583 @noindent
16584 The attributes of package @code{Linker} specify the options to be used when
16585 invoking the linker in the construction of an executable.
16586 The following attributes apply to package @code{Linker}:
16587
16588 @table @code
16589 @item     Default_Switches
16590 This is an associative array attribute. Its
16591 domain is a set of language names. Its range is a string list that
16592 specifies options to be used when linking a main
16593 written in that language, for which no file-specific switches have been
16594 specified.
16595
16596 @item Switches
16597 This is an associative array attribute. Its domain is
16598 a set of file names. Its range is a string list that specifies
16599 options to be used when linking the named main file. If a main file
16600 is not specified in the Switches attribute, it is linked with the
16601 options specified by Default_Switches of its language, if defined.
16602
16603 @item  Linker_Options
16604 This is a string list attribute. Its value specifies additional options that
16605 be given to the linker when linking an executable. This attribute is not
16606 used in the main project, only in projects imported directly or indirectly.
16607
16608 @end table
16609
16610 @subsection package Cross_Reference
16611
16612 @noindent
16613 The attributes of package @code{Cross_Reference} specify the tool options
16614 to be used
16615 when invoking the library tool @command{gnatxref}.
16616 The following attributes apply to package @code{Cross_Reference}:
16617
16618 @table @code
16619 @item     Default_Switches
16620 This is an associative array attribute. Its
16621 domain is a set of language names. Its range is a string list that
16622 specifies options to be used when calling @command{gnatxref} on a source
16623 written in that language, for which no file-specific switches have been
16624 specified.
16625
16626 @item Switches
16627 This is an associative array attribute. Its domain is
16628 a set of file names. Its range is a string list that specifies
16629 options to be used when calling @command{gnatxref} on the named main source.
16630 If a source is not specified in the Switches attribute, @command{gnatxref} will
16631 be called with the options specified by Default_Switches of its language,
16632 if defined.
16633 @end table
16634
16635 @subsection package   Finder
16636
16637 @noindent
16638 The attributes of package @code{Finder} specify the tool options to be used
16639 when invoking the search tool @command{gnatfind}.
16640 The following attributes apply to package @code{Finder}:
16641
16642 @table @code
16643 @item     Default_Switches
16644 This is an associative array attribute. Its
16645 domain is a set of language names. Its range is a string list that
16646 specifies options to be used when calling @command{gnatfind} on a source
16647 written in that language, for which no file-specific switches have been
16648 specified.
16649
16650 @item Switches
16651 This is an associative array attribute. Its domain is
16652 a set of file names. Its range is a string list that specifies
16653 options to be used when calling @command{gnatfind} on the named main source.
16654 If a source is not specified in the Switches attribute, @command{gnatfind} will
16655 be called with the options specified by Default_Switches of its language,
16656 if defined.
16657 @end table
16658
16659 @subsection package Pretty_Printer
16660
16661 @noindent
16662 The attributes of package @code{Pretty_Printer}
16663 specify the tool options to be used
16664 when invoking the formatting tool @command{gnatpp}.
16665 The following attributes apply to package @code{Pretty_Printer}:
16666
16667 @table @code
16668 @item     Default_switches
16669 This is an associative array attribute. Its
16670 domain is a set of language names. Its range is a string list that
16671 specifies options to be used when calling @command{gnatpp} on a source
16672 written in that language, for which no file-specific switches have been
16673 specified.
16674
16675 @item Switches
16676 This is an associative array attribute. Its domain is
16677 a set of file names. Its range is a string list that specifies
16678 options to be used when calling @command{gnatpp} on the named main source.
16679 If a source is not specified in the Switches attribute, @command{gnatpp} will
16680 be called with the options specified by Default_Switches of its language,
16681 if defined.
16682 @end table
16683
16684 @subsection package gnatstub
16685
16686 @noindent
16687 The attributes of package @code{gnatstub}
16688 specify the tool options to be used
16689 when invoking the tool @command{gnatstub}.
16690 The following attributes apply to package @code{gnatstub}:
16691
16692 @table @code
16693 @item     Default_switches
16694 This is an associative array attribute. Its
16695 domain is a set of language names. Its range is a string list that
16696 specifies options to be used when calling @command{gnatstub} on a source
16697 written in that language, for which no file-specific switches have been
16698 specified.
16699
16700 @item Switches
16701 This is an associative array attribute. Its domain is
16702 a set of file names. Its range is a string list that specifies
16703 options to be used when calling @command{gnatstub} on the named main source.
16704 If a source is not specified in the Switches attribute, @command{gnatpp} will
16705 be called with the options specified by Default_Switches of its language,
16706 if defined.
16707 @end table
16708
16709 @subsection package Eliminate
16710
16711 @noindent
16712 The attributes of package @code{Eliminate}
16713 specify the tool options to be used
16714 when invoking the tool @command{gnatelim}.
16715 The following attributes apply to package @code{Eliminate}:
16716
16717 @table @code
16718 @item     Default_switches
16719 This is an associative array attribute. Its
16720 domain is a set of language names. Its range is a string list that
16721 specifies options to be used when calling @command{gnatelim} on a source
16722 written in that language, for which no file-specific switches have been
16723 specified.
16724
16725 @item Switches
16726 This is an associative array attribute. Its domain is
16727 a set of file names. Its range is a string list that specifies
16728 options to be used when calling @command{gnatelim} on the named main source.
16729 If a source is not specified in the Switches attribute, @command{gnatelim} will
16730 be called with the options specified by Default_Switches of its language,
16731 if defined.
16732 @end table
16733
16734 @subsection package Metrics
16735
16736 @noindent
16737 The attributes of package @code{Metrics}
16738 specify the tool options to be used
16739 when invoking the tool @command{gnatmetric}.
16740 The following attributes apply to package @code{Metrics}:
16741
16742 @table @code
16743 @item     Default_switches
16744 This is an associative array attribute. Its
16745 domain is a set of language names. Its range is a string list that
16746 specifies options to be used when calling @command{gnatmetric} on a source
16747 written in that language, for which no file-specific switches have been
16748 specified.
16749
16750 @item Switches
16751 This is an associative array attribute. Its domain is
16752 a set of file names. Its range is a string list that specifies
16753 options to be used when calling @command{gnatmetric} on the named main source.
16754 If a source is not specified in the Switches attribute, @command{gnatmetric}
16755 will be called with the options specified by Default_Switches of its language,
16756 if defined.
16757 @end table
16758
16759 @subsection  package IDE
16760
16761 @noindent
16762 The attributes of package @code{IDE} specify the options to be used when using
16763 an Integrated Development Environment such as @command{GPS}.
16764
16765 @table @code
16766 @item Remote_Host
16767 This is a simple attribute. Its value is a string that designates the remote
16768 host in a cross-compilation environment, to be used for remote compilation and
16769 debugging. This field should not be specified when running on the local
16770 machine.
16771
16772 @item Program_Host
16773 This is a simple attribute. Its value is a string that specifies the
16774 name of IP address of the embedded target in a cross-compilation environment,
16775 on which the program should execute.
16776
16777 @item Communication_Protocol
16778 This is a simple string attribute. Its value is the name of the protocol
16779 to use to communicate with the target in a cross-compilation environment,
16780 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16781
16782 @item Compiler_Command
16783 This is an associative array attribute, whose domain is a language name. Its
16784 value is  string that denotes the command to be used to invoke the compiler.
16785 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16786 gnatmake, in particular in the handling of switches.
16787
16788 @item Debugger_Command
16789 This is simple attribute, Its value is a string that specifies the name of
16790 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16791
16792 @item Default_Switches
16793 This is an associative array attribute. Its indexes are the name of the
16794 external tools that the GNAT Programming System (GPS) is supporting. Its
16795 value is a list of switches to use when invoking that tool.
16796
16797 @item  Gnatlist
16798 This is a simple attribute.  Its value is a string that specifies the name
16799 of the @command{gnatls} utility to be used to retrieve information about the
16800 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16801
16802 @item VCS_Kind
16803 This is a simple attribute. Its value is a string used to specify the
16804 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16805 ClearCase or Perforce.
16806
16807 @item VCS_File_Check
16808 This is a simple attribute. Its value is a string that specifies the
16809 command used by the VCS to check the validity of a file, either
16810 when the user explicitly asks for a check, or as a sanity check before
16811 doing the check-in.
16812
16813 @item VCS_Log_Check
16814 This is a simple attribute. Its value is a string that specifies
16815 the command used by the VCS to check the validity of a log file.
16816
16817 @item VCS_Repository_Root
16818 The VCS repository root path. This is used to create tags or branches
16819 of the repository. For subversion the value should be the @code{URL}
16820 as specified to check-out the working copy of the repository.
16821
16822 @item VCS_Patch_Root
16823 The local root directory to use for building patch file. All patch chunks
16824 will be relative to this path. The root project directory is used if
16825 this value is not defined.
16826
16827 @end table
16828
16829 @node Package Renamings
16830 @section Package Renamings
16831
16832 @noindent
16833 A package can be defined by a renaming declaration. The new package renames
16834 a package declared in a different project file, and has the same attributes
16835 as the package it renames.
16836 Syntax:
16837 @smallexample
16838 package_renaming ::==
16839   @b{package} package_identifier @b{renames}
16840        <project_>simple_name.package_identifier ;
16841 @end smallexample
16842
16843 @noindent
16844 The package_identifier of the renamed package must be the same as the
16845 package_identifier. The project whose name is the prefix of the renamed
16846 package must contain a package declaration with this name. This project
16847 must appear in the context_clause of the enclosing project declaration,
16848 or be the parent project of the enclosing child project.
16849
16850 @node Projects
16851 @section Projects
16852
16853 @noindent
16854 A project file specifies a set of rules for constructing a software system.
16855 A project file can be self-contained, or depend on other project files.
16856 Dependencies are expressed through a context clause that names other projects.
16857
16858 Syntax:
16859
16860 @smallexample
16861 project ::=
16862   context_clause project_declaration
16863
16864 project_declaration ::=
16865   simple_project_declaration | project_extension
16866
16867 simple_project_declaration ::=
16868   @b{project} <project_>simple_name @b{is}
16869     @{declarative_item@}
16870   @b{end} <project_>simple_name;
16871
16872 context_clause ::=
16873   @{with_clause@}
16874
16875 with_clause ::=
16876   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16877
16878 path_name ::=
16879    string_literal
16880 @end smallexample
16881
16882 @noindent
16883 A path name denotes a project file. A path name can be absolute or relative.
16884 An absolute path name includes a sequence of directories, in the syntax of
16885 the host operating system, that identifies uniquely the project file in the
16886 file system. A relative path name identifies the project file, relative
16887 to the directory that contains the current project, or relative to a
16888 directory listed in the environment variable ADA_PROJECT_PATH.
16889 Path names are case sensitive if file names in the host operating system
16890 are case sensitive.
16891
16892 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16893 directory names separated by colons (semicolons on Windows).
16894
16895 A given project name can appear only once in a context_clause.
16896
16897 It is illegal for a project imported by a context clause to refer, directly
16898 or indirectly, to the project in which this context clause appears (the
16899 dependency graph cannot contain cycles), except when one of the with_clause
16900 in the cycle is a @code{limited with}.
16901
16902 @node Project Extensions
16903 @section Project Extensions
16904
16905 @noindent
16906 A project extension introduces a new project, which inherits the declarations
16907 of another project.
16908 Syntax:
16909 @smallexample
16910
16911 project_extension ::=
16912   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16913     @{declarative_item@}
16914   @b{end} <project_>simple_name;
16915 @end smallexample
16916
16917 @noindent
16918 The project extension declares a child project. The child project inherits
16919 all the declarations and all the files of the parent project, These inherited
16920 declaration can be overridden in the child project, by means of suitable
16921 declarations.
16922
16923 @node Project File Elaboration
16924 @section Project File Elaboration
16925
16926 @noindent
16927 A project file is processed as part of the invocation of a gnat tool that
16928 uses the project option. Elaboration of the process file consists in the
16929 sequential elaboration of all its declarations. The computed values of
16930 attributes and variables in the project are then used to establish the
16931 environment in which the gnat tool will execute.
16932
16933 @node Obsolescent Features
16934 @chapter Obsolescent Features
16935
16936 @noindent
16937 This chapter describes features that are provided by GNAT, but are
16938 considered obsolescent since there are preferred ways of achieving
16939 the same effect. These features are provided solely for historical
16940 compatibility purposes.
16941
16942 @menu
16943 * pragma No_Run_Time::
16944 * pragma Ravenscar::
16945 * pragma Restricted_Run_Time::
16946 @end menu
16947
16948 @node pragma No_Run_Time
16949 @section pragma No_Run_Time
16950
16951 The pragma @code{No_Run_Time} is used to achieve an affect similar
16952 to the use of the "Zero Foot Print" configurable run time, but without
16953 requiring a specially configured run time. The result of using this
16954 pragma, which must be used for all units in a partition, is to restrict
16955 the use of any language features requiring run-time support code. The
16956 preferred usage is to use an appropriately configured run-time that
16957 includes just those features that are to be made accessible.
16958
16959 @node pragma Ravenscar
16960 @section pragma Ravenscar
16961
16962 The pragma @code{Ravenscar} has exactly the same effect as pragma
16963 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16964 is part of the new Ada 2005 standard.
16965
16966 @node pragma Restricted_Run_Time
16967 @section pragma Restricted_Run_Time
16968
16969 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16970 pragma @code{Profile (Restricted)}. The latter usage is
16971 preferred since the Ada 2005 pragma @code{Profile} is intended for
16972 this kind of implementation dependent addition.
16973
16974 @include fdl.texi
16975 @c GNU Free Documentation License
16976
16977 @node Index,,GNU Free Documentation License, Top
16978 @unnumbered Index
16979
16980 @printindex cp
16981
16982 @contents
16983
16984 @bye