OSDN Git Service

2008-05-28 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c              Copyright (C) 1995-2008, Free Software Foundation             o
12 @c                                                                            o
13 @c                                                                            o
14 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
15 @c                                                                            o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
17
18 @setfilename gnat_rm.info
19
20 @set EDITION GNAT
21 @set DEFAULTLANGUAGEVERSION Ada 2005
22 @set NONDEFAULTLANGUAGEVERSION Ada 95
23
24 @settitle GNAT Reference Manual
25
26 @setchapternewpage odd
27 @syncodeindex fn cp
28
29 @include gcc-common.texi
30
31 @dircategory GNU Ada tools
32 @direntry
33 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
34 @end direntry
35
36 @copying
37 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
38
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the GNU Free Documentation License, Version 1.2
41 or any later version published by the Free Software Foundation;
42 with the Invariant Sections being ``GNU Free Documentation License'',
43 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
44 no Back-Cover Texts. A copy of the license is included in the section
45 entitled ``GNU Free Documentation License''.
46 @end copying
47
48 @titlepage
49 @title GNAT Reference Manual
50 @subtitle GNAT, The GNU Ada Compiler
51 @versionsubtitle
52 @author AdaCore
53 @page
54 @vskip 0pt plus 1filll
55
56 @insertcopying
57
58 @end titlepage
59
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
63
64 @noindent
65 GNAT Reference Manual
66
67 @noindent
68 GNAT, The GNU Ada Compiler@*
69 GCC version @value{version-GCC}@*
70
71 @noindent
72 AdaCore
73
74 @menu
75 * About This Guide::
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
84 * The GNAT Library::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
91 * Index::
92
93  --- The Detailed Node Listing ---
94
95 About This Guide
96
97 * What This Reference Manual Contains::
98 * Related Information::
99
100 Implementation Defined Pragmas
101
102 * Pragma Abort_Defer::
103 * Pragma Ada_83::
104 * Pragma Ada_95::
105 * Pragma Ada_05::
106 * Pragma Ada_2005::
107 * Pragma Annotate::
108 * Pragma Assert::
109 * Pragma Ast_Entry::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Check::
112 * Pragma Check_Name::
113 * Pragma Check_Policy::
114 * Pragma Comment::
115 * Pragma Common_Object::
116 * Pragma Compile_Time_Error::
117 * Pragma Compile_Time_Warning::
118 * Pragma Complete_Representation::
119 * Pragma Complex_Representation::
120 * Pragma Component_Alignment::
121 * Pragma Convention_Identifier::
122 * Pragma CPP_Class::
123 * Pragma CPP_Constructor::
124 * Pragma CPP_Virtual::
125 * Pragma CPP_Vtable::
126 * Pragma Debug::
127 * Pragma Debug_Policy::
128 * Pragma Detect_Blocking::
129 * Pragma Elaboration_Checks::
130 * Pragma Eliminate::
131 * Pragma Export_Exception::
132 * Pragma Export_Function::
133 * Pragma Export_Object::
134 * Pragma Export_Procedure::
135 * Pragma Export_Value::
136 * Pragma Export_Valued_Procedure::
137 * Pragma Extend_System::
138 * Pragma External::
139 * Pragma External_Name_Casing::
140 * Pragma Fast_Math::
141 * Pragma Favor_Top_Level::
142 * Pragma Finalize_Storage_Only::
143 * Pragma Float_Representation::
144 * Pragma Ident::
145 * Pragma Implemented_By_Entry::
146 * Pragma Implicit_Packing::
147 * Pragma Import_Exception::
148 * Pragma Import_Function::
149 * Pragma Import_Object::
150 * Pragma Import_Procedure::
151 * Pragma Import_Valued_Procedure::
152 * Pragma Initialize_Scalars::
153 * Pragma Inline_Always::
154 * Pragma Inline_Generic::
155 * Pragma Interface::
156 * Pragma Interface_Name::
157 * Pragma Interrupt_Handler::
158 * Pragma Interrupt_State::
159 * Pragma Keep_Names::
160 * Pragma License::
161 * Pragma Link_With::
162 * Pragma Linker_Alias::
163 * Pragma Linker_Constructor::
164 * Pragma Linker_Destructor::
165 * Pragma Linker_Section::
166 * Pragma Long_Float::
167 * Pragma Machine_Attribute::
168 * Pragma Main::
169 * Pragma Main_Storage::
170 * Pragma No_Body::
171 * Pragma No_Return::
172 * Pragma No_Strict_Aliasing ::
173 * Pragma Normalize_Scalars::
174 * Pragma Obsolescent::
175 * Pragma Optimize_Alignment::
176 * Pragma Passive::
177 * Pragma Persistent_BSS::
178 * Pragma Polling::
179 * Pragma Postcondition::
180 * Pragma Precondition::
181 * Pragma Profile (Ravenscar)::
182 * Pragma Profile (Restricted)::
183 * Pragma Psect_Object::
184 * Pragma Pure_Function::
185 * Pragma Restriction_Warnings::
186 * Pragma Shared::
187 * Pragma Source_File_Name::
188 * Pragma Source_File_Name_Project::
189 * Pragma Source_Reference::
190 * Pragma Stream_Convert::
191 * Pragma Style_Checks::
192 * Pragma Subtitle::
193 * Pragma Suppress::
194 * Pragma Suppress_All::
195 * Pragma Suppress_Exception_Locations::
196 * Pragma Suppress_Initialization::
197 * Pragma Task_Info::
198 * Pragma Task_Name::
199 * Pragma Task_Storage::
200 * Pragma Time_Slice::
201 * Pragma Title::
202 * Pragma Unchecked_Union::
203 * Pragma Unimplemented_Unit::
204 * Pragma Universal_Aliasing ::
205 * Pragma Universal_Data::
206 * Pragma Unmodified::
207 * Pragma Unreferenced::
208 * Pragma Unreferenced_Objects::
209 * Pragma Unreserve_All_Interrupts::
210 * Pragma Unsuppress::
211 * Pragma Use_VADS_Size::
212 * Pragma Validity_Checks::
213 * Pragma Volatile::
214 * Pragma Warnings::
215 * Pragma Weak_External::
216 * Pragma Wide_Character_Encoding::
217
218 Implementation Defined Attributes
219
220 * Abort_Signal::
221 * Address_Size::
222 * Asm_Input::
223 * Asm_Output::
224 * AST_Entry::
225 * Bit::
226 * Bit_Position::
227 * Code_Address::
228 * Default_Bit_Order::
229 * Elaborated::
230 * Elab_Body::
231 * Elab_Spec::
232 * Emax::
233 * Enabled::
234 * Enum_Rep::
235 * Enum_Val::
236 * Epsilon::
237 * Fixed_Value::
238 * Has_Access_Values::
239 * Has_Discriminants::
240 * Img::
241 * Integer_Value::
242 * Invalid_Value::
243 * Large::
244 * Machine_Size::
245 * Mantissa::
246 * Max_Interrupt_Priority::
247 * Max_Priority::
248 * Maximum_Alignment::
249 * Mechanism_Code::
250 * Null_Parameter::
251 * Object_Size::
252 * Old::
253 * Passed_By_Reference::
254 * Pool_Address::
255 * Range_Length::
256 * Safe_Emax::
257 * Safe_Large::
258 * Small::
259 * Storage_Unit::
260 * Stub_Type::
261 * Target_Name::
262 * Tick::
263 * To_Address::
264 * Type_Class::
265 * UET_Address::
266 * Unconstrained_Array::
267 * Universal_Literal_String::
268 * Unrestricted_Access::
269 * VADS_Size::
270 * Value_Size::
271 * Wchar_T_Size::
272 * Word_Size::
273
274 The Implementation of Standard I/O
275
276 * Standard I/O Packages::
277 * FORM Strings::
278 * Direct_IO::
279 * Sequential_IO::
280 * Text_IO::
281 * Wide_Text_IO::
282 * Wide_Wide_Text_IO::
283 * Stream_IO::
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
689 Manual.
690
691 In addition, Ada allows implementations to define additional pragmas
692 whose meaning is defined by the implementation.  GNAT provides a number
693 of these implementation-defined pragmas, which can be used to extend
694 and enhance the functionality of the compiler.  This section of the GNAT
695 Reference Manual describes these additional pragmas.
696
697 Note that any program using these pragmas might not be portable to other
698 compilers (although GNAT implements this set of pragmas on all
699 platforms).  Therefore if portability to other compilers is an important
700 consideration, the use of these pragmas should be minimized.
701
702 @menu
703 * Pragma Abort_Defer::
704 * Pragma Ada_83::
705 * Pragma Ada_95::
706 * Pragma Ada_05::
707 * Pragma Ada_2005::
708 * Pragma Annotate::
709 * Pragma Assert::
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 Time_Slice::
802 * Pragma Title::
803 * Pragma Unchecked_Union::
804 * Pragma Unimplemented_Unit::
805 * Pragma Universal_Aliasing ::
806 * Pragma Universal_Data::
807 * Pragma Unmodified::
808 * Pragma Unreferenced::
809 * Pragma Unreferenced_Objects::
810 * Pragma Unreserve_All_Interrupts::
811 * Pragma Unsuppress::
812 * Pragma Use_VADS_Size::
813 * Pragma Validity_Checks::
814 * Pragma Volatile::
815 * Pragma Warnings::
816 * Pragma Weak_External::
817 * Pragma Wide_Character_Encoding::
818 @end menu
819
820 @node Pragma Abort_Defer
821 @unnumberedsec Pragma Abort_Defer
822 @findex Abort_Defer
823 @cindex Deferring aborts
824 @noindent
825 Syntax:
826 @smallexample
827 pragma Abort_Defer;
828 @end smallexample
829
830 @noindent
831 This pragma must appear at the start of the statement sequence of a
832 handled sequence of statements (right after the @code{begin}).  It has
833 the effect of deferring aborts for the sequence of statements (but not
834 for the declarations or handlers, if any, associated with this statement
835 sequence).
836
837 @node Pragma Ada_83
838 @unnumberedsec Pragma Ada_83
839 @findex Ada_83
840 @noindent
841 Syntax:
842 @smallexample @c ada
843 pragma Ada_83;
844 @end smallexample
845
846 @noindent
847 A configuration pragma that establishes Ada 83 mode for the unit to
848 which it applies, regardless of the mode set by the command line
849 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
850 the syntax and semantics of Ada 83, as defined in the original Ada
851 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
852 and Ada 2005 are not recognized, optional package bodies are allowed,
853 and generics may name types with unknown discriminants without using
854 the @code{(<>)} notation.  In addition, some but not all of the additional
855 restrictions of Ada 83 are enforced.
856
857 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
858 Ada 83 code to be compiled and adapted to GNAT with less effort.
859 Secondly, it aids in keeping code backwards compatible with Ada 83.
860 However, there is no guarantee that code that is processed correctly
861 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
862 83 compiler, since GNAT does not enforce all the additional checks
863 required by Ada 83.
864
865 @node Pragma Ada_95
866 @unnumberedsec Pragma Ada_95
867 @findex Ada_95
868 @noindent
869 Syntax:
870 @smallexample @c ada
871 pragma Ada_95;
872 @end smallexample
873
874 @noindent
875 A configuration pragma that establishes Ada 95 mode for the unit to which
876 it applies, regardless of the mode set by the command line switches.
877 This mode is set automatically for the @code{Ada} and @code{System}
878 packages and their children, so you need not specify it in these
879 contexts.  This pragma is useful when writing a reusable component that
880 itself uses Ada 95 features, but which is intended to be usable from
881 either Ada 83 or Ada 95 programs.
882
883 @node Pragma Ada_05
884 @unnumberedsec Pragma Ada_05
885 @findex Ada_05
886 @noindent
887 Syntax:
888 @smallexample @c ada
889 pragma Ada_05;
890 @end smallexample
891
892 @noindent
893 A configuration pragma that establishes Ada 2005 mode for the unit to which
894 it applies, regardless of the mode set by the command line switches.
895 This mode is set automatically for the @code{Ada} and @code{System}
896 packages and their children, so you need not specify it in these
897 contexts.  This pragma is useful when writing a reusable component that
898 itself uses Ada 2005 features, but which is intended to be usable from
899 either Ada 83 or Ada 95 programs.
900
901 @node Pragma Ada_2005
902 @unnumberedsec Pragma Ada_2005
903 @findex Ada_2005
904 @noindent
905 Syntax:
906 @smallexample @c ada
907 pragma Ada_2005;
908 @end smallexample
909
910 @noindent
911 This configuration pragma is a synonym for pragma Ada_05 and has the
912 same syntax and effect.
913
914 @node Pragma Annotate
915 @unnumberedsec Pragma Annotate
916 @findex Annotate
917 @noindent
918 Syntax:
919 @smallexample @c ada
920 pragma Annotate (IDENTIFIER @{, ARG@});
921
922 ARG ::= NAME | EXPRESSION
923 @end smallexample
924
925 @noindent
926 This pragma is used to annotate programs.  @var{identifier} identifies
927 the type of annotation.  GNAT verifies that it is an identifier, but does
928 not otherwise analyze it.  The @var{arg} argument
929 can be either a string literal or an
930 expression.  String literals are assumed to be of type
931 @code{Standard.String}.  Names of entities are simply analyzed as entity
932 names.  All other expressions are analyzed as expressions, and must be
933 unambiguous.
934
935 The analyzed pragma is retained in the tree, but not otherwise processed
936 by any part of the GNAT compiler.  This pragma is intended for use by
937 external tools, including ASIS@.
938
939 @node Pragma Assert
940 @unnumberedsec Pragma Assert
941 @findex Assert
942 @noindent
943 Syntax:
944 @smallexample @c ada
945 pragma Assert (
946   boolean_EXPRESSION
947   [, string_EXPRESSION]);
948 @end smallexample
949
950 @noindent
951 The effect of this pragma depends on whether the corresponding command
952 line switch is set to activate assertions.  The pragma expands into code
953 equivalent to the following:
954
955 @smallexample @c ada
956 if assertions-enabled then
957    if not boolean_EXPRESSION then
958       System.Assertions.Raise_Assert_Failure
959         (string_EXPRESSION);
960    end if;
961 end if;
962 @end smallexample
963
964 @noindent
965 The string argument, if given, is the message that will be associated
966 with the exception occurrence if the exception is raised.  If no second
967 argument is given, the default message is @samp{@var{file}:@var{nnn}},
968 where @var{file} is the name of the source file containing the assert,
969 and @var{nnn} is the line number of the assert.  A pragma is not a
970 statement, so if a statement sequence contains nothing but a pragma
971 assert, then a null statement is required in addition, as in:
972
973 @smallexample @c ada
974 @dots{}
975 if J > 3 then
976    pragma Assert (K > 3, "Bad value for K");
977    null;
978 end if;
979 @end smallexample
980
981 @noindent
982 Note that, as with the @code{if} statement to which it is equivalent, the
983 type of the expression is either @code{Standard.Boolean}, or any type derived
984 from this standard type.
985
986 If assertions are disabled (switch @option{-gnata} not used), then there
987 is no run-time effect (and in particular, any side effects from the
988 expression will not occur at run time).  (The expression is still
989 analyzed at compile time, and may cause types to be frozen if they are
990 mentioned here for the first time).
991
992 If assertions are enabled, then the given expression is tested, and if
993 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
994 which results in the raising of @code{Assert_Failure} with the given message.
995
996 You should generally avoid side effects in the expression arguments of
997 this pragma, because these side effects will turn on and off with the
998 setting of the assertions mode, resulting in assertions that have an
999 effect on the program.  However, the expressions are analyzed for
1000 semantic correctness whether or not assertions are enabled, so turning
1001 assertions on and off cannot affect the legality of a program.
1002
1003 @node Pragma Ast_Entry
1004 @unnumberedsec Pragma Ast_Entry
1005 @cindex OpenVMS
1006 @findex Ast_Entry
1007 @noindent
1008 Syntax:
1009 @smallexample @c ada
1010 pragma AST_Entry (entry_IDENTIFIER);
1011 @end smallexample
1012
1013 @noindent
1014 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1015 argument is the simple name of a single entry; at most one @code{AST_Entry}
1016 pragma is allowed for any given entry.  This pragma must be used in
1017 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1018 the entry declaration and in the same task type specification or single task
1019 as the entry to which it applies.  This pragma specifies that the given entry
1020 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1021 resulting from an OpenVMS system service call.  The pragma does not affect
1022 normal use of the entry.  For further details on this pragma, see the
1023 DEC Ada Language Reference Manual, section 9.12a.
1024
1025 @node Pragma C_Pass_By_Copy
1026 @unnumberedsec Pragma C_Pass_By_Copy
1027 @cindex Passing by copy
1028 @findex C_Pass_By_Copy
1029 @noindent
1030 Syntax:
1031 @smallexample @c ada
1032 pragma C_Pass_By_Copy
1033   ([Max_Size =>] static_integer_EXPRESSION);
1034 @end smallexample
1035
1036 @noindent
1037 Normally the default mechanism for passing C convention records to C
1038 convention subprograms is to pass them by reference, as suggested by RM
1039 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1040 this default, by requiring that record formal parameters be passed by
1041 copy if all of the following conditions are met:
1042
1043 @itemize @bullet
1044 @item
1045 The size of the record type does not exceed the value specified for
1046 @code{Max_Size}.
1047 @item
1048 The record type has @code{Convention C}.
1049 @item
1050 The formal parameter has this record type, and the subprogram has a
1051 foreign (non-Ada) convention.
1052 @end itemize
1053
1054 @noindent
1055 If these conditions are met the argument is passed by copy, i.e.@: in a
1056 manner consistent with what C expects if the corresponding formal in the
1057 C prototype is a struct (rather than a pointer to a struct).
1058
1059 You can also pass records by copy by specifying the convention
1060 @code{C_Pass_By_Copy} for the record type, or by using the extended
1061 @code{Import} and @code{Export} pragmas, which allow specification of
1062 passing mechanisms on a parameter by parameter basis.
1063
1064 @node Pragma Check
1065 @unnumberedsec Pragma Check
1066 @cindex Assertions
1067 @cindex Named assertions
1068 @findex Check
1069 @noindent
1070 Syntax:
1071 @smallexample @c ada
1072 pragma Check (
1073      [Name    =>] Identifier,
1074      [Check   =>] Boolean_EXPRESSION
1075   [, [Message =>] string_EXPRESSION] );
1076 @end smallexample
1077
1078 @noindent
1079 This pragma is similar to the predefined pragma @code{Assert} except that an
1080 extra identifier argument is present. In conjunction with pragma
1081 @code{Check_Policy}, this can be used to define groups of assertions that can
1082 be independently controlled. The identifier @code{Assertion} is special, it
1083 refers to the normal set of pragma @code{Assert} statements. The identifiers
1084 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1085 names, so these three names would normally not be used directly in a pragma
1086 @code{Check}.
1087
1088 Checks introduced by this pragma are normally deactivated by default. They can
1089 be activated either by the command line option @option{-gnata}, which turns on
1090 all checks, or individually controlled using pragma @code{Check_Policy}.
1091
1092 @node Pragma Check_Name
1093 @unnumberedsec Pragma Check_Name
1094 @cindex Defining check names
1095 @cindex Check names, defining
1096 @findex Check_Name
1097 @noindent
1098 Syntax:
1099 @smallexample @c ada
1100 pragma Check_Name (check_name_IDENTIFIER);
1101 @end smallexample
1102
1103 @noindent
1104 This is a configuration pragma that defines a new implementation
1105 defined check name (unless IDENTIFIER matches one of the predefined
1106 check names, in which case the pragma has no effect). Check names
1107 are global to a partition, so if two or more configuration pragmas
1108 are present in a partition mentioning the same name, only one new
1109 check name is introduced.
1110
1111 An implementation defined check name introduced with this pragma may
1112 be used in only three contexts: @code{pragma Suppress},
1113 @code{pragma Unsuppress},
1114 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1115 any of these three cases, the check name must be visible. A check
1116 name is visible if it is in the configuration pragmas applying to
1117 the current unit, or if it appears at the start of any unit that
1118 is part of the dependency set of the current unit (e.g., units that
1119 are mentioned in @code{with} clauses).
1120
1121 @node Pragma Check_Policy
1122 @unnumberedsec Pragma Check_Policy
1123 @cindex Controlling assertions
1124 @cindex Assertions, control
1125 @cindex Check pragma control
1126 @cindex Named assertions
1127 @findex Check
1128 @noindent
1129 Syntax:
1130 @smallexample @c ada
1131 pragma Check_Policy ([Name =>] Identifier, POLICY_IDENTIFIER);
1132
1133 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1134 @end smallexample
1135
1136 @noindent
1137 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1138 except that it controls sets of named assertions introduced using the
1139 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1140 @code{Assertion_Policy}) can be used within a declarative part, in which case
1141 it controls the status to the end of the corresponding construct (in a manner
1142 identical to pragma @code{Suppress)}.
1143
1144 The identifier given as the first argument corresponds to a name used in
1145 associated @code{Check} pragmas. For example, if the pragma:
1146
1147 @smallexample @c ada
1148 pragma Check_Policy (Critical_Error, Off);
1149 @end smallexample
1150
1151 @noindent
1152 is given, then subsequent @code{Check} pragmas whose first argument is also
1153 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1154 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1155 @code{Check_Policy} with this identifier is similar to the normal
1156 @code{Assertion_Policy} pragma except that it can appear within a
1157 declarative part).
1158
1159 The special identifiers @code{Precondition} and @code{Postcondition} control
1160 the status of preconditions and postconditions. If a @code{Precondition} pragma
1161 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1162 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1163 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1164 are recognized.
1165
1166 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1167 to turn on corresponding checks. The default for a set of checks for which no
1168 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1169 @option{-gnata} is given, which turns on all checks by default.
1170
1171 The check policy settings @code{Check} and @code{Ignore} are also recognized
1172 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1173 compatibility with the standard @code{Assertion_Policy} pragma.
1174
1175 @node Pragma Comment
1176 @unnumberedsec Pragma Comment
1177 @findex Comment
1178 @noindent
1179 Syntax:
1180
1181 @smallexample @c ada
1182 pragma Comment (static_string_EXPRESSION);
1183 @end smallexample
1184
1185 @noindent
1186 This is almost identical in effect to pragma @code{Ident}.  It allows the
1187 placement of a comment into the object file and hence into the
1188 executable file if the operating system permits such usage.  The
1189 difference is that @code{Comment}, unlike @code{Ident}, has
1190 no limitations on placement of the pragma (it can be placed
1191 anywhere in the main source unit), and if more than one pragma
1192 is used, all comments are retained.
1193
1194 @node Pragma Common_Object
1195 @unnumberedsec Pragma Common_Object
1196 @findex Common_Object
1197 @noindent
1198 Syntax:
1199
1200 @smallexample @c ada
1201 pragma Common_Object (
1202      [Internal =>] LOCAL_NAME
1203   [, [External =>] EXTERNAL_SYMBOL]
1204   [, [Size     =>] EXTERNAL_SYMBOL] );
1205
1206 EXTERNAL_SYMBOL ::=
1207   IDENTIFIER
1208 | static_string_EXPRESSION
1209 @end smallexample
1210
1211 @noindent
1212 This pragma enables the shared use of variables stored in overlaid
1213 linker areas corresponding to the use of @code{COMMON}
1214 in Fortran.  The single
1215 object @var{LOCAL_NAME} is assigned to the area designated by
1216 the @var{External} argument.
1217 You may define a record to correspond to a series
1218 of fields.  The @var{Size} argument
1219 is syntax checked in GNAT, but otherwise ignored.
1220
1221 @code{Common_Object} is not supported on all platforms.  If no
1222 support is available, then the code generator will issue a message
1223 indicating that the necessary attribute for implementation of this
1224 pragma is not available.
1225
1226 @node Pragma Compile_Time_Error
1227 @unnumberedsec Pragma Compile_Time_Error
1228 @findex Compile_Time_Error
1229 @noindent
1230 Syntax:
1231
1232 @smallexample @c ada
1233 pragma Compile_Time_Error
1234          (boolean_EXPRESSION, static_string_EXPRESSION);
1235 @end smallexample
1236
1237 @noindent
1238 This pragma can be used to generate additional compile time
1239 error messages. It
1240 is particularly useful in generics, where errors can be issued for
1241 specific problematic instantiations. The first parameter is a boolean
1242 expression. The pragma is effective only if the value of this expression
1243 is known at compile time, and has the value True. The set of expressions
1244 whose values are known at compile time includes all static boolean
1245 expressions, and also other values which the compiler can determine
1246 at compile time (e.g., the size of a record type set by an explicit
1247 size representation clause, or the value of a variable which was
1248 initialized to a constant and is known not to have been modified).
1249 If these conditions are met, an error message is generated using
1250 the value given as the second argument. This string value may contain
1251 embedded ASCII.LF characters to break the message into multiple lines.
1252
1253 @node Pragma Compile_Time_Warning
1254 @unnumberedsec Pragma Compile_Time_Warning
1255 @findex Compile_Time_Warning
1256 @noindent
1257 Syntax:
1258
1259 @smallexample @c ada
1260 pragma Compile_Time_Warning
1261          (boolean_EXPRESSION, static_string_EXPRESSION);
1262 @end smallexample
1263
1264 @noindent
1265 Same as pragma Compile_Time_Error, except a warning is issued instead
1266 of an error message. Note that if this pragma is used in a package that
1267 is with'ed by a client, the client will get the warning even though it
1268 is issued by a with'ed package (normally warnings in with'ed units are
1269 suppressed, but this is a special exception to that rule).
1270
1271 One typical use is within a generic where compile time known characteristics
1272 of formal parameters are tested, and warnings given appropriately. Another use
1273 with a first parameter of True is to warn a client about use of a package,
1274 for example that it is not fully implemented.
1275
1276 @node Pragma Complete_Representation
1277 @unnumberedsec Pragma Complete_Representation
1278 @findex Complete_Representation
1279 @noindent
1280 Syntax:
1281
1282 @smallexample @c ada
1283 pragma Complete_Representation;
1284 @end smallexample
1285
1286 @noindent
1287 This pragma must appear immediately within a record representation
1288 clause. Typical placements are before the first component clause
1289 or after the last component clause. The effect is to give an error
1290 message if any component is missing a component clause. This pragma
1291 may be used to ensure that a record representation clause is
1292 complete, and that this invariant is maintained if fields are
1293 added to the record in the future.
1294
1295 @node Pragma Complex_Representation
1296 @unnumberedsec Pragma Complex_Representation
1297 @findex Complex_Representation
1298 @noindent
1299 Syntax:
1300
1301 @smallexample @c ada
1302 pragma Complex_Representation
1303         ([Entity =>] LOCAL_NAME);
1304 @end smallexample
1305
1306 @noindent
1307 The @var{Entity} argument must be the name of a record type which has
1308 two fields of the same floating-point type.  The effect of this pragma is
1309 to force gcc to use the special internal complex representation form for
1310 this record, which may be more efficient.  Note that this may result in
1311 the code for this type not conforming to standard ABI (application
1312 binary interface) requirements for the handling of record types.  For
1313 example, in some environments, there is a requirement for passing
1314 records by pointer, and the use of this pragma may result in passing
1315 this type in floating-point registers.
1316
1317 @node Pragma Component_Alignment
1318 @unnumberedsec Pragma Component_Alignment
1319 @cindex Alignments of components
1320 @findex Component_Alignment
1321 @noindent
1322 Syntax:
1323
1324 @smallexample @c ada
1325 pragma Component_Alignment (
1326      [Form =>] ALIGNMENT_CHOICE
1327   [, [Name =>] type_LOCAL_NAME]);
1328
1329 ALIGNMENT_CHOICE ::=
1330   Component_Size
1331 | Component_Size_4
1332 | Storage_Unit
1333 | Default
1334 @end smallexample
1335
1336 @noindent
1337 Specifies the alignment of components in array or record types.
1338 The meaning of the @var{Form} argument is as follows:
1339
1340 @table @code
1341 @findex Component_Size
1342 @item Component_Size
1343 Aligns scalar components and subcomponents of the array or record type
1344 on boundaries appropriate to their inherent size (naturally
1345 aligned).  For example, 1-byte components are aligned on byte boundaries,
1346 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1347 integer components are aligned on 4-byte boundaries and so on.  These
1348 alignment rules correspond to the normal rules for C compilers on all
1349 machines except the VAX@.
1350
1351 @findex Component_Size_4
1352 @item Component_Size_4
1353 Naturally aligns components with a size of four or fewer
1354 bytes.  Components that are larger than 4 bytes are placed on the next
1355 4-byte boundary.
1356
1357 @findex Storage_Unit
1358 @item Storage_Unit
1359 Specifies that array or record components are byte aligned, i.e.@:
1360 aligned on boundaries determined by the value of the constant
1361 @code{System.Storage_Unit}.
1362
1363 @cindex OpenVMS
1364 @item Default
1365 Specifies that array or record components are aligned on default
1366 boundaries, appropriate to the underlying hardware or operating system or
1367 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1368 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1369 the @code{Default} choice is the same as @code{Component_Size} (natural
1370 alignment).
1371 @end table
1372
1373 @noindent
1374 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1375 refer to a local record or array type, and the specified alignment
1376 choice applies to the specified type.  The use of
1377 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1378 @code{Component_Alignment} pragma to be ignored.  The use of
1379 @code{Component_Alignment} together with a record representation clause
1380 is only effective for fields not specified by the representation clause.
1381
1382 If the @code{Name} parameter is absent, the pragma can be used as either
1383 a configuration pragma, in which case it applies to one or more units in
1384 accordance with the normal rules for configuration pragmas, or it can be
1385 used within a declarative part, in which case it applies to types that
1386 are declared within this declarative part, or within any nested scope
1387 within this declarative part.  In either case it specifies the alignment
1388 to be applied to any record or array type which has otherwise standard
1389 representation.
1390
1391 If the alignment for a record or array type is not specified (using
1392 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1393 clause), the GNAT uses the default alignment as described previously.
1394
1395 @node Pragma Convention_Identifier
1396 @unnumberedsec Pragma Convention_Identifier
1397 @findex Convention_Identifier
1398 @cindex Conventions, synonyms
1399 @noindent
1400 Syntax:
1401
1402 @smallexample @c ada
1403 pragma Convention_Identifier (
1404          [Name =>]       IDENTIFIER,
1405          [Convention =>] convention_IDENTIFIER);
1406 @end smallexample
1407
1408 @noindent
1409 This pragma provides a mechanism for supplying synonyms for existing
1410 convention identifiers. The @code{Name} identifier can subsequently
1411 be used as a synonym for the given convention in other pragmas (including
1412 for example pragma @code{Import} or another @code{Convention_Identifier}
1413 pragma). As an example of the use of this, suppose you had legacy code
1414 which used Fortran77 as the identifier for Fortran. Then the pragma:
1415
1416 @smallexample @c ada
1417 pragma Convention_Identifier (Fortran77, Fortran);
1418 @end smallexample
1419
1420 @noindent
1421 would allow the use of the convention identifier @code{Fortran77} in
1422 subsequent code, avoiding the need to modify the sources. As another
1423 example, you could use this to parametrize convention requirements
1424 according to systems. Suppose you needed to use @code{Stdcall} on
1425 windows systems, and @code{C} on some other system, then you could
1426 define a convention identifier @code{Library} and use a single
1427 @code{Convention_Identifier} pragma to specify which convention
1428 would be used system-wide.
1429
1430 @node Pragma CPP_Class
1431 @unnumberedsec Pragma CPP_Class
1432 @findex CPP_Class
1433 @cindex Interfacing with C++
1434 @noindent
1435 Syntax:
1436
1437 @smallexample @c ada
1438 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1439 @end smallexample
1440
1441 @noindent
1442 The argument denotes an entity in the current declarative region that is
1443 declared as a tagged record type. It indicates that the type corresponds
1444 to an externally declared C++ class type, and is to be laid out the same
1445 way that C++ would lay out the type.
1446
1447 Types for which @code{CPP_Class} is specified do not have assignment or
1448 equality operators defined (such operations can be imported or declared
1449 as subprograms as required). Initialization is allowed only by constructor
1450 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1451 limited if not explicitly declared as limited or derived from a limited
1452 type, and a warning is issued in that case.
1453
1454 Pragma @code{CPP_Class} is intended primarily for automatic generation
1455 using an automatic binding generator tool.
1456 See @ref{Interfacing to C++} for related information.
1457
1458 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1459 for backward compatibility but its functionality is available
1460 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1461
1462 @node Pragma CPP_Constructor
1463 @unnumberedsec Pragma CPP_Constructor
1464 @cindex Interfacing with C++
1465 @findex CPP_Constructor
1466 @noindent
1467 Syntax:
1468
1469 @smallexample @c ada
1470 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1471   [, [External_Name =>] static_string_EXPRESSION ]
1472   [, [Link_Name     =>] static_string_EXPRESSION ]);
1473 @end smallexample
1474
1475 @noindent
1476 This pragma identifies an imported function (imported in the usual way
1477 with pragma @code{Import}) as corresponding to a C++ constructor. If
1478 @code{External_Name} and @code{Link_Name} are not specified then the
1479 @code{Entity} argument is a name that must have been previously mentioned
1480 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1481 must be of one of the following forms:
1482
1483 @itemize @bullet
1484 @item
1485 @code{function @var{Fname} return @var{T}'Class}
1486
1487 @item
1488 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1489 @end itemize
1490
1491 @noindent
1492 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1493
1494 The first form is the default constructor, used when an object of type
1495 @var{T} is created on the Ada side with no explicit constructor.  Other
1496 constructors (including the copy constructor, which is simply a special
1497 case of the second form in which the one and only argument is of type
1498 @var{T}), can only appear in two contexts:
1499
1500 @itemize @bullet
1501 @item
1502 On the right side of an initialization of an object of type @var{T}.
1503 @item
1504 In an extension aggregate for an object of a type derived from @var{T}.
1505 @end itemize
1506
1507 @noindent
1508 Although the constructor is described as a function that returns a value
1509 on the Ada side, it is typically a procedure with an extra implicit
1510 argument (the object being initialized) at the implementation
1511 level.  GNAT issues the appropriate call, whatever it is, to get the
1512 object properly initialized.
1513
1514 In the case of derived objects, you may use one of two possible forms
1515 for declaring and creating an object:
1516
1517 @itemize @bullet
1518 @item @code{New_Object : Derived_T}
1519 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1520 @end itemize
1521
1522 @noindent
1523 In the first case the default constructor is called and extension fields
1524 if any are initialized according to the default initialization
1525 expressions in the Ada declaration.  In the second case, the given
1526 constructor is called and the extension aggregate indicates the explicit
1527 values of the extension fields.
1528
1529 If no constructors are imported, it is impossible to create any objects
1530 on the Ada side.  If no default constructor is imported, only the
1531 initialization forms using an explicit call to a constructor are
1532 permitted.
1533
1534 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1535 using an automatic binding generator tool.
1536 See @ref{Interfacing to C++} for more related information.
1537
1538 @node Pragma CPP_Virtual
1539 @unnumberedsec Pragma CPP_Virtual
1540 @cindex Interfacing to C++
1541 @findex CPP_Virtual
1542 @noindent
1543 This pragma is now obsolete has has no effect because GNAT generates
1544 the same object layout than the G++ compiler.
1545
1546 See @ref{Interfacing to C++} for related information.
1547
1548 @node Pragma CPP_Vtable
1549 @unnumberedsec Pragma CPP_Vtable
1550 @cindex Interfacing with C++
1551 @findex CPP_Vtable
1552 @noindent
1553 This pragma is now obsolete has has no effect because GNAT generates
1554 the same object layout than the G++ compiler.
1555
1556 See @ref{Interfacing to C++} for related information.
1557
1558 @node Pragma Debug
1559 @unnumberedsec Pragma Debug
1560 @findex Debug
1561 @noindent
1562 Syntax:
1563
1564 @smallexample @c ada
1565 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1566
1567 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1568   PROCEDURE_NAME
1569 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1570 @end smallexample
1571
1572 @noindent
1573 The procedure call argument has the syntactic form of an expression, meeting
1574 the syntactic requirements for pragmas.
1575
1576 If debug pragmas are not enabled or if the condition is present and evaluates
1577 to False, this pragma has no effect. If debug pragmas are enabled, the
1578 semantics of the pragma is exactly equivalent to the procedure call statement
1579 corresponding to the argument with a terminating semicolon. Pragmas are
1580 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1581 intersperse calls to debug procedures in the middle of declarations. Debug
1582 pragmas can be enabled either by use of the command line switch @option{-gnata}
1583 or by use of the configuration pragma @code{Debug_Policy}.
1584
1585 @node Pragma Debug_Policy
1586 @unnumberedsec Pragma Debug_Policy
1587 @findex Debug_Policy
1588 @noindent
1589 Syntax:
1590
1591 @smallexample @c ada
1592 pragma Debug_Policy (CHECK | IGNORE);
1593 @end smallexample
1594
1595 @noindent
1596 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1597 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1598 This pragma overrides the effect of the @option{-gnata} switch on the
1599 command line.
1600
1601 @node Pragma Detect_Blocking
1602 @unnumberedsec Pragma Detect_Blocking
1603 @findex Detect_Blocking
1604 @noindent
1605 Syntax:
1606
1607 @smallexample @c ada
1608 pragma Detect_Blocking;
1609 @end smallexample
1610
1611 @noindent
1612 This is a configuration pragma that forces the detection of potentially
1613 blocking operations within a protected operation, and to raise Program_Error
1614 if that happens.
1615
1616 @node Pragma Elaboration_Checks
1617 @unnumberedsec Pragma Elaboration_Checks
1618 @cindex Elaboration control
1619 @findex Elaboration_Checks
1620 @noindent
1621 Syntax:
1622
1623 @smallexample @c ada
1624 pragma Elaboration_Checks (Dynamic | Static);
1625 @end smallexample
1626
1627 @noindent
1628 This is a configuration pragma that provides control over the
1629 elaboration model used by the compilation affected by the
1630 pragma.  If the parameter is @code{Dynamic},
1631 then the dynamic elaboration
1632 model described in the Ada Reference Manual is used, as though
1633 the @option{-gnatE} switch had been specified on the command
1634 line.  If the parameter is @code{Static}, then the default GNAT static
1635 model is used.  This configuration pragma overrides the setting
1636 of the command line.  For full details on the elaboration models
1637 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1638 gnat_ugn, @value{EDITION} User's Guide}.
1639
1640 @node Pragma Eliminate
1641 @unnumberedsec Pragma Eliminate
1642 @cindex Elimination of unused subprograms
1643 @findex Eliminate
1644 @noindent
1645 Syntax:
1646
1647 @smallexample @c ada
1648 pragma Eliminate (
1649     [Unit_Name =>] IDENTIFIER |
1650                    SELECTED_COMPONENT);
1651
1652 pragma Eliminate (
1653     [Unit_Name       =>]  IDENTIFIER |
1654                           SELECTED_COMPONENT,
1655     [Entity          =>]  IDENTIFIER |
1656                           SELECTED_COMPONENT |
1657                           STRING_LITERAL
1658     [,OVERLOADING_RESOLUTION]);
1659
1660 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1661                            SOURCE_LOCATION
1662
1663 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1664                                       FUNCTION_PROFILE
1665
1666 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1667
1668 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1669                       Result_Type => result_SUBTYPE_NAME]
1670
1671 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1672 SUBTYPE_NAME    ::= STRING_VALUE
1673
1674 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1675 SOURCE_TRACE    ::= STRING_VALUE
1676
1677 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1678 @end smallexample
1679
1680 @noindent
1681 This pragma indicates that the given entity is not used outside the
1682 compilation unit it is defined in. The entity must be an explicitly declared
1683 subprogram; this includes  generic subprogram instances and
1684 subprograms declared in generic package instances.
1685
1686 If the entity to be eliminated is a library level subprogram, then
1687 the first form of pragma @code{Eliminate} is used with only a single argument.
1688 In this form, the @code{Unit_Name} argument specifies the name of the
1689 library  level unit to be eliminated.
1690
1691 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1692 are required. If item is an entity of a library package, then the first
1693 argument specifies the unit name, and the second argument specifies
1694 the particular entity.  If the second argument is in string form, it must
1695 correspond to the internal manner in which GNAT stores entity names (see
1696 compilation unit Namet in the compiler sources for details).
1697
1698 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1699 to distinguish between overloaded subprograms. If a pragma does not contain
1700 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1701 subprograms denoted by the first two parameters.
1702
1703 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1704 to be eliminated in a manner similar to that used for the extended
1705 @code{Import} and @code{Export} pragmas, except that the subtype names are
1706 always given as strings. At the moment, this form of distinguishing
1707 overloaded subprograms is implemented only partially, so we do not recommend
1708 using it for practical subprogram elimination.
1709
1710 Note that in case of a parameterless procedure its profile is represented
1711 as @code{Parameter_Types => ("")}
1712
1713 Alternatively, the @code{Source_Location} parameter is used to specify
1714 which overloaded alternative is to be eliminated by pointing to the
1715 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1716 source text. The string literal (or concatenation of string literals)
1717 given as SOURCE_TRACE must have the following format:
1718
1719 @smallexample @c ada
1720 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1721
1722 LBRACKET ::= [
1723 RBRACKET ::= ]
1724
1725 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1726 FILE_NAME       ::= STRING_LITERAL
1727 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1728 @end smallexample
1729
1730 SOURCE_TRACE should be the short name of the source file (with no directory
1731 information), and LINE_NUMBER is supposed to point to the line where the
1732 defining name of the subprogram is located.
1733
1734 For the subprograms that are not a part of generic instantiations, only one
1735 SOURCE_LOCATION is used. If a subprogram is declared in a package
1736 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1737 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1738 second one denotes the declaration of the corresponding subprogram in the
1739 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1740 in case of nested instantiations.
1741
1742 The effect of the pragma is to allow the compiler to eliminate
1743 the code or data associated with the named entity.  Any reference to
1744 an eliminated entity outside the compilation unit it is defined in,
1745 causes a compile time or link time error.
1746
1747 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1748 in a system independent manner, with unused entities eliminated, without
1749 the requirement of modifying the source text.  Normally the required set
1750 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1751 tool. Elimination of unused entities local to a compilation unit is
1752 automatic, without requiring the use of pragma @code{Eliminate}.
1753
1754 Note that the reason this pragma takes string literals where names might
1755 be expected is that a pragma @code{Eliminate} can appear in a context where the
1756 relevant names are not visible.
1757
1758 Note that any change in the source files that includes removing, splitting of
1759 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1760 parameter illegal.
1761
1762 It is legal to use pragma Eliminate where the referenced entity is a
1763 dispatching operation, but it is not clear what this would mean, since
1764 in general the call does not know which entity is actually being called.
1765 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1766
1767 @node Pragma Export_Exception
1768 @unnumberedsec Pragma Export_Exception
1769 @cindex OpenVMS
1770 @findex Export_Exception
1771 @noindent
1772 Syntax:
1773
1774 @smallexample @c ada
1775 pragma Export_Exception (
1776      [Internal =>] LOCAL_NAME
1777   [, [External =>] EXTERNAL_SYMBOL]
1778   [, [Form     =>] Ada | VMS]
1779   [, [Code     =>] static_integer_EXPRESSION]);
1780
1781 EXTERNAL_SYMBOL ::=
1782   IDENTIFIER
1783 | static_string_EXPRESSION
1784 @end smallexample
1785
1786 @noindent
1787 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1788 causes the specified exception to be propagated outside of the Ada program,
1789 so that it can be handled by programs written in other OpenVMS languages.
1790 This pragma establishes an external name for an Ada exception and makes the
1791 name available to the OpenVMS Linker as a global symbol.  For further details
1792 on this pragma, see the
1793 DEC Ada Language Reference Manual, section 13.9a3.2.
1794
1795 @node Pragma Export_Function
1796 @unnumberedsec Pragma Export_Function
1797 @cindex Argument passing mechanisms
1798 @findex Export_Function
1799
1800 @noindent
1801 Syntax:
1802
1803 @smallexample @c ada
1804 pragma Export_Function (
1805      [Internal         =>] LOCAL_NAME
1806   [, [External         =>] EXTERNAL_SYMBOL]
1807   [, [Parameter_Types  =>] PARAMETER_TYPES]
1808   [, [Result_Type      =>] result_SUBTYPE_MARK]
1809   [, [Mechanism        =>] MECHANISM]
1810   [, [Result_Mechanism =>] MECHANISM_NAME]);
1811
1812 EXTERNAL_SYMBOL ::=
1813   IDENTIFIER
1814 | static_string_EXPRESSION
1815 | ""
1816
1817 PARAMETER_TYPES ::=
1818   null
1819 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1820
1821 TYPE_DESIGNATOR ::=
1822   subtype_NAME
1823 | subtype_Name ' Access
1824
1825 MECHANISM ::=
1826   MECHANISM_NAME
1827 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1828
1829 MECHANISM_ASSOCIATION ::=
1830   [formal_parameter_NAME =>] MECHANISM_NAME
1831
1832 MECHANISM_NAME ::=
1833   Value
1834 | Reference
1835 | Descriptor [([Class =>] CLASS_NAME)]
1836
1837 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1838 @end smallexample
1839
1840 @noindent
1841 Use this pragma to make a function externally callable and optionally
1842 provide information on mechanisms to be used for passing parameter and
1843 result values.  We recommend, for the purposes of improving portability,
1844 this pragma always be used in conjunction with a separate pragma
1845 @code{Export}, which must precede the pragma @code{Export_Function}.
1846 GNAT does not require a separate pragma @code{Export}, but if none is
1847 present, @code{Convention Ada} is assumed, which is usually
1848 not what is wanted, so it is usually appropriate to use this
1849 pragma in conjunction with a @code{Export} or @code{Convention}
1850 pragma that specifies the desired foreign convention.
1851 Pragma @code{Export_Function}
1852 (and @code{Export}, if present) must appear in the same declarative
1853 region as the function to which they apply.
1854
1855 @var{internal_name} must uniquely designate the function to which the
1856 pragma applies.  If more than one function name exists of this name in
1857 the declarative part you must use the @code{Parameter_Types} and
1858 @code{Result_Type} parameters is mandatory to achieve the required
1859 unique designation.  @var{subtype_mark}s in these parameters must
1860 exactly match the subtypes in the corresponding function specification,
1861 using positional notation to match parameters with subtype marks.
1862 The form with an @code{'Access} attribute can be used to match an
1863 anonymous access parameter.
1864
1865 @cindex OpenVMS
1866 @cindex Passing by descriptor
1867 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1868
1869 @cindex Suppressing external name
1870 Special treatment is given if the EXTERNAL is an explicit null
1871 string or a static string expressions that evaluates to the null
1872 string. In this case, no external name is generated. This form
1873 still allows the specification of parameter mechanisms.
1874
1875 @node Pragma Export_Object
1876 @unnumberedsec Pragma Export_Object
1877 @findex Export_Object
1878 @noindent
1879 Syntax:
1880
1881 @smallexample @c ada
1882 pragma Export_Object
1883       [Internal =>] LOCAL_NAME
1884    [, [External =>] EXTERNAL_SYMBOL]
1885    [, [Size     =>] EXTERNAL_SYMBOL]
1886
1887 EXTERNAL_SYMBOL ::=
1888   IDENTIFIER
1889 | static_string_EXPRESSION
1890 @end smallexample
1891
1892 @noindent
1893 This pragma designates an object as exported, and apart from the
1894 extended rules for external symbols, is identical in effect to the use of
1895 the normal @code{Export} pragma applied to an object.  You may use a
1896 separate Export pragma (and you probably should from the point of view
1897 of portability), but it is not required.  @var{Size} is syntax checked,
1898 but otherwise ignored by GNAT@.
1899
1900 @node Pragma Export_Procedure
1901 @unnumberedsec Pragma Export_Procedure
1902 @findex Export_Procedure
1903 @noindent
1904 Syntax:
1905
1906 @smallexample @c ada
1907 pragma Export_Procedure (
1908      [Internal        =>] LOCAL_NAME
1909   [, [External        =>] EXTERNAL_SYMBOL]
1910   [, [Parameter_Types =>] PARAMETER_TYPES]
1911   [, [Mechanism       =>] MECHANISM]);
1912
1913 EXTERNAL_SYMBOL ::=
1914   IDENTIFIER
1915 | static_string_EXPRESSION
1916 | ""
1917
1918 PARAMETER_TYPES ::=
1919   null
1920 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1921
1922 TYPE_DESIGNATOR ::=
1923   subtype_NAME
1924 | subtype_Name ' Access
1925
1926 MECHANISM ::=
1927   MECHANISM_NAME
1928 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1929
1930 MECHANISM_ASSOCIATION ::=
1931   [formal_parameter_NAME =>] MECHANISM_NAME
1932
1933 MECHANISM_NAME ::=
1934   Value
1935 | Reference
1936 | Descriptor [([Class =>] CLASS_NAME)]
1937
1938 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1939 @end smallexample
1940
1941 @noindent
1942 This pragma is identical to @code{Export_Function} except that it
1943 applies to a procedure rather than a function and the parameters
1944 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1945 GNAT does not require a separate pragma @code{Export}, but if none is
1946 present, @code{Convention Ada} is assumed, which is usually
1947 not what is wanted, so it is usually appropriate to use this
1948 pragma in conjunction with a @code{Export} or @code{Convention}
1949 pragma that specifies the desired foreign convention.
1950
1951 @cindex OpenVMS
1952 @cindex Passing by descriptor
1953 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1954
1955 @cindex Suppressing external name
1956 Special treatment is given if the EXTERNAL is an explicit null
1957 string or a static string expressions that evaluates to the null
1958 string. In this case, no external name is generated. This form
1959 still allows the specification of parameter mechanisms.
1960
1961 @node Pragma Export_Value
1962 @unnumberedsec Pragma Export_Value
1963 @findex Export_Value
1964 @noindent
1965 Syntax:
1966
1967 @smallexample @c ada
1968 pragma Export_Value (
1969   [Value     =>] static_integer_EXPRESSION,
1970   [Link_Name =>] static_string_EXPRESSION);
1971 @end smallexample
1972
1973 @noindent
1974 This pragma serves to export a static integer value for external use.
1975 The first argument specifies the value to be exported. The Link_Name
1976 argument specifies the symbolic name to be associated with the integer
1977 value. This pragma is useful for defining a named static value in Ada
1978 that can be referenced in assembly language units to be linked with
1979 the application. This pragma is currently supported only for the
1980 AAMP target and is ignored for other targets.
1981
1982 @node Pragma Export_Valued_Procedure
1983 @unnumberedsec Pragma Export_Valued_Procedure
1984 @findex Export_Valued_Procedure
1985 @noindent
1986 Syntax:
1987
1988 @smallexample @c ada
1989 pragma Export_Valued_Procedure (
1990      [Internal        =>] LOCAL_NAME
1991   [, [External        =>] EXTERNAL_SYMBOL]
1992   [, [Parameter_Types =>] PARAMETER_TYPES]
1993   [, [Mechanism       =>] MECHANISM]);
1994
1995 EXTERNAL_SYMBOL ::=
1996   IDENTIFIER
1997 | static_string_EXPRESSION
1998 | ""
1999
2000 PARAMETER_TYPES ::=
2001   null
2002 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2003
2004 TYPE_DESIGNATOR ::=
2005   subtype_NAME
2006 | subtype_Name ' Access
2007
2008 MECHANISM ::=
2009   MECHANISM_NAME
2010 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2011
2012 MECHANISM_ASSOCIATION ::=
2013   [formal_parameter_NAME =>] MECHANISM_NAME
2014
2015 MECHANISM_NAME ::=
2016   Value
2017 | Reference
2018 | Descriptor [([Class =>] CLASS_NAME)]
2019
2020 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2021 @end smallexample
2022
2023 @noindent
2024 This pragma is identical to @code{Export_Procedure} except that the
2025 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2026 mode @code{OUT}, and externally the subprogram is treated as a function
2027 with this parameter as the result of the function.  GNAT provides for
2028 this capability to allow the use of @code{OUT} and @code{IN OUT}
2029 parameters in interfacing to external functions (which are not permitted
2030 in Ada functions).
2031 GNAT does not require a separate pragma @code{Export}, but if none is
2032 present, @code{Convention Ada} is assumed, which is almost certainly
2033 not what is wanted since the whole point of this pragma is to interface
2034 with foreign language functions, so it is usually appropriate to use this
2035 pragma in conjunction with a @code{Export} or @code{Convention}
2036 pragma that specifies the desired foreign convention.
2037
2038 @cindex OpenVMS
2039 @cindex Passing by descriptor
2040 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2041
2042 @cindex Suppressing external name
2043 Special treatment is given if the EXTERNAL is an explicit null
2044 string or a static string expressions that evaluates to the null
2045 string. In this case, no external name is generated. This form
2046 still allows the specification of parameter mechanisms.
2047
2048 @node Pragma Extend_System
2049 @unnumberedsec Pragma Extend_System
2050 @cindex @code{system}, extending
2051 @cindex Dec Ada 83
2052 @findex Extend_System
2053 @noindent
2054 Syntax:
2055
2056 @smallexample @c ada
2057 pragma Extend_System ([Name =>] IDENTIFIER);
2058 @end smallexample
2059
2060 @noindent
2061 This pragma is used to provide backwards compatibility with other
2062 implementations that extend the facilities of package @code{System}.  In
2063 GNAT, @code{System} contains only the definitions that are present in
2064 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2065 implementation, provide many extensions to package @code{System}.
2066
2067 For each such implementation accommodated by this pragma, GNAT provides a
2068 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2069 implementation, which provides the required additional definitions.  You
2070 can use this package in two ways.  You can @code{with} it in the normal
2071 way and access entities either by selection or using a @code{use}
2072 clause.  In this case no special processing is required.
2073
2074 However, if existing code contains references such as
2075 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2076 definitions provided in package @code{System}, you may use this pragma
2077 to extend visibility in @code{System} in a non-standard way that
2078 provides greater compatibility with the existing code.  Pragma
2079 @code{Extend_System} is a configuration pragma whose single argument is
2080 the name of the package containing the extended definition
2081 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2082 control of this pragma will be processed using special visibility
2083 processing that looks in package @code{System.Aux_@var{xxx}} where
2084 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2085 package @code{System}, but not found in package @code{System}.
2086
2087 You can use this pragma either to access a predefined @code{System}
2088 extension supplied with the compiler, for example @code{Aux_DEC} or
2089 you can construct your own extension unit following the above
2090 definition.  Note that such a package is a child of @code{System}
2091 and thus is considered part of the implementation.  To compile
2092 it you will have to use the appropriate switch for compiling
2093 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2094 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2095
2096 @node Pragma External
2097 @unnumberedsec Pragma External
2098 @findex External
2099 @noindent
2100 Syntax:
2101
2102 @smallexample @c ada
2103 pragma External (
2104   [   Convention    =>] convention_IDENTIFIER,
2105   [   Entity        =>] LOCAL_NAME
2106   [, [External_Name =>] static_string_EXPRESSION ]
2107   [, [Link_Name     =>] static_string_EXPRESSION ]);
2108 @end smallexample
2109
2110 @noindent
2111 This pragma is identical in syntax and semantics to pragma
2112 @code{Export} as defined in the Ada Reference Manual.  It is
2113 provided for compatibility with some Ada 83 compilers that
2114 used this pragma for exactly the same purposes as pragma
2115 @code{Export} before the latter was standardized.
2116
2117 @node Pragma External_Name_Casing
2118 @unnumberedsec Pragma External_Name_Casing
2119 @cindex Dec Ada 83 casing compatibility
2120 @cindex External Names, casing
2121 @cindex Casing of External names
2122 @findex External_Name_Casing
2123 @noindent
2124 Syntax:
2125
2126 @smallexample @c ada
2127 pragma External_Name_Casing (
2128   Uppercase | Lowercase
2129   [, Uppercase | Lowercase | As_Is]);
2130 @end smallexample
2131
2132 @noindent
2133 This pragma provides control over the casing of external names associated
2134 with Import and Export pragmas.  There are two cases to consider:
2135
2136 @table @asis
2137 @item Implicit external names
2138 Implicit external names are derived from identifiers.  The most common case
2139 arises when a standard Ada Import or Export pragma is used with only two
2140 arguments, as in:
2141
2142 @smallexample @c ada
2143    pragma Import (C, C_Routine);
2144 @end smallexample
2145
2146 @noindent
2147 Since Ada is a case-insensitive language, the spelling of the identifier in
2148 the Ada source program does not provide any information on the desired
2149 casing of the external name, and so a convention is needed.  In GNAT the
2150 default treatment is that such names are converted to all lower case
2151 letters.  This corresponds to the normal C style in many environments.
2152 The first argument of pragma @code{External_Name_Casing} can be used to
2153 control this treatment.  If @code{Uppercase} is specified, then the name
2154 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2155 then the normal default of all lower case letters will be used.
2156
2157 This same implicit treatment is also used in the case of extended DEC Ada 83
2158 compatible Import and Export pragmas where an external name is explicitly
2159 specified using an identifier rather than a string.
2160
2161 @item Explicit external names
2162 Explicit external names are given as string literals.  The most common case
2163 arises when a standard Ada Import or Export pragma is used with three
2164 arguments, as in:
2165
2166 @smallexample @c ada
2167 pragma Import (C, C_Routine, "C_routine");
2168 @end smallexample
2169
2170 @noindent
2171 In this case, the string literal normally provides the exact casing required
2172 for the external name.  The second argument of pragma
2173 @code{External_Name_Casing} may be used to modify this behavior.
2174 If @code{Uppercase} is specified, then the name
2175 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2176 then the name will be forced to all lowercase letters.  A specification of
2177 @code{As_Is} provides the normal default behavior in which the casing is
2178 taken from the string provided.
2179 @end table
2180
2181 @noindent
2182 This pragma may appear anywhere that a pragma is valid.  In particular, it
2183 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2184 case it applies to all subsequent compilations, or it can be used as a program
2185 unit pragma, in which case it only applies to the current unit, or it can
2186 be used more locally to control individual Import/Export pragmas.
2187
2188 It is primarily intended for use with OpenVMS systems, where many
2189 compilers convert all symbols to upper case by default.  For interfacing to
2190 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2191 the pragma:
2192
2193 @smallexample @c ada
2194 pragma External_Name_Casing (Uppercase, Uppercase);
2195 @end smallexample
2196
2197 @noindent
2198 to enforce the upper casing of all external symbols.
2199
2200 @node Pragma Fast_Math
2201 @unnumberedsec Pragma Fast_Math
2202 @findex Fast_Math
2203 @noindent
2204 Syntax:
2205
2206 @smallexample @c ada
2207 pragma Fast_Math;
2208 @end smallexample
2209
2210 @noindent
2211 This is a configuration pragma which activates a mode in which speed is
2212 considered more important for floating-point operations than absolutely
2213 accurate adherence to the requirements of the standard. Currently the
2214 following operations are affected:
2215
2216 @table @asis
2217 @item Complex Multiplication
2218 The normal simple formula for complex multiplication can result in intermediate
2219 overflows for numbers near the end of the range. The Ada standard requires that
2220 this situation be detected and corrected by scaling, but in Fast_Math mode such
2221 cases will simply result in overflow. Note that to take advantage of this you
2222 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2223 under control of the pragma, rather than use the preinstantiated versions.
2224 @end table
2225
2226 @node Pragma Favor_Top_Level
2227 @unnumberedsec Pragma Favor_Top_Level
2228 @findex Favor_Top_Level
2229 @noindent
2230 Syntax:
2231
2232 @smallexample @c ada
2233 pragma Favor_Top_Level (type_NAME);
2234 @end smallexample
2235
2236 @noindent
2237 The named type must be an access-to-subprogram type. This pragma is an
2238 efficiency hint to the compiler, regarding the use of 'Access or
2239 'Unrestricted_Access on nested (non-library-level) subprograms. The
2240 pragma means that nested subprograms are not used with this type, or
2241 are rare, so that the generated code should be efficient in the
2242 top-level case. When this pragma is used, dynamically generated
2243 trampolines may be used on some targets for nested subprograms.
2244 See also the No_Implicit_Dynamic_Code restriction.
2245
2246 @node Pragma Finalize_Storage_Only
2247 @unnumberedsec Pragma Finalize_Storage_Only
2248 @findex Finalize_Storage_Only
2249 @noindent
2250 Syntax:
2251
2252 @smallexample @c ada
2253 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2254 @end smallexample
2255
2256 @noindent
2257 This pragma allows the compiler not to emit a Finalize call for objects
2258 defined at the library level.  This is mostly useful for types where
2259 finalization is only used to deal with storage reclamation since in most
2260 environments it is not necessary to reclaim memory just before terminating
2261 execution, hence the name.
2262
2263 @node Pragma Float_Representation
2264 @unnumberedsec Pragma Float_Representation
2265 @cindex OpenVMS
2266 @findex Float_Representation
2267 @noindent
2268 Syntax:
2269
2270 @smallexample @c ada
2271 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2272
2273 FLOAT_REP ::= VAX_Float | IEEE_Float
2274 @end smallexample
2275
2276 @noindent
2277 In the one argument form, this pragma is a configuration pragma which
2278 allows control over the internal representation chosen for the predefined
2279 floating point types declared in the packages @code{Standard} and
2280 @code{System}. On all systems other than OpenVMS, the argument must
2281 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2282 argument may be @code{VAX_Float} to specify the use of the VAX float
2283 format for the floating-point types in Standard. This requires that
2284 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2285 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2286 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2287
2288 The two argument form specifies the representation to be used for
2289 the specified floating-point type. On all systems other than OpenVMS,
2290 the argument must
2291 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2292 argument may be @code{VAX_Float} to specify the use of the VAX float
2293 format, as follows:
2294
2295 @itemize @bullet
2296 @item
2297 For digits values up to 6, F float format will be used.
2298 @item
2299 For digits values from 7 to 9, G float format will be used.
2300 @item
2301 For digits values from 10 to 15, F float format will be used.
2302 @item
2303 Digits values above 15 are not allowed.
2304 @end itemize
2305
2306 @node Pragma Ident
2307 @unnumberedsec Pragma Ident
2308 @findex Ident
2309 @noindent
2310 Syntax:
2311
2312 @smallexample @c ada
2313 pragma Ident (static_string_EXPRESSION);
2314 @end smallexample
2315
2316 @noindent
2317 This pragma provides a string identification in the generated object file,
2318 if the system supports the concept of this kind of identification string.
2319 This pragma is allowed only in the outermost declarative part or
2320 declarative items of a compilation unit. If more than one @code{Ident}
2321 pragma is given, only the last one processed is effective.
2322 @cindex OpenVMS
2323 On OpenVMS systems, the effect of the pragma is identical to the effect of
2324 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2325 maximum allowed length is 31 characters, so if it is important to
2326 maintain compatibility with this compiler, you should obey this length
2327 limit.
2328
2329 @node Pragma Implemented_By_Entry
2330 @unnumberedsec Pragma Implemented_By_Entry
2331 @findex Implemented_By_Entry
2332 @noindent
2333 Syntax:
2334
2335 @smallexample @c ada
2336 pragma Implemented_By_Entry (LOCAL_NAME);
2337 @end smallexample
2338
2339 @noindent
2340 This is a representation pragma which applies to protected, synchronized and
2341 task interface primitives. If the pragma is applied to primitive operation Op
2342 of interface Iface, it is illegal to override Op in a type that implements
2343 Iface, with anything other than an entry.
2344
2345 @smallexample @c ada
2346 type Iface is protected interface;
2347 procedure Do_Something (Object : in out Iface) is abstract;
2348 pragma Implemented_By_Entry (Do_Something);
2349
2350 protected type P is new Iface with
2351    procedure Do_Something;  --  Illegal
2352 end P;
2353
2354 task type T is new Iface with
2355    entry Do_Something;      --  Legal
2356 end T;
2357 @end smallexample
2358
2359 @noindent
2360 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2361 is intended to be used in conjunction with dispatching requeue statements as
2362 described in AI05-0030. Should the ARG decide on an official name and syntax,
2363 this pragma will become language-defined rather than GNAT-specific.
2364
2365 @node Pragma Implicit_Packing
2366 @unnumberedsec Pragma Implicit_Packing
2367 @findex Implicit_Packing
2368 @noindent
2369 Syntax:
2370
2371 @smallexample @c ada
2372 pragma Implicit_Packing;
2373 @end smallexample
2374
2375 @noindent
2376 This is a configuration pragma that requests implicit packing for packed
2377 arrays for which a size clause is given but no explicit pragma Pack or
2378 specification of Component_Size is present. Consider this example:
2379
2380 @smallexample @c ada
2381 type R is array (0 .. 7) of Boolean;
2382 for R'Size use 8;
2383 @end smallexample
2384
2385 @noindent
2386 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2387 does not change the layout of a composite object. So the Size clause in the
2388 above example is normally rejected, since the default layout of the array uses
2389 8-bit components, and thus the array requires a minimum of 64 bits.
2390
2391 If this declaration is compiled in a region of code covered by an occurrence
2392 of the configuration pragma Implicit_Packing, then the Size clause in this
2393 and similar examples will cause implicit packing and thus be accepted. For
2394 this implicit packing to occur, the type in question must be an array of small
2395 components whose size is known at compile time, and the Size clause must
2396 specify the exact size that corresponds to the length of the array multiplied
2397 by the size in bits of the component type.
2398 @cindex Array packing
2399
2400 @node Pragma Import_Exception
2401 @unnumberedsec Pragma Import_Exception
2402 @cindex OpenVMS
2403 @findex Import_Exception
2404 @noindent
2405 Syntax:
2406
2407 @smallexample @c ada
2408 pragma Import_Exception (
2409      [Internal =>] LOCAL_NAME
2410   [, [External =>] EXTERNAL_SYMBOL]
2411   [, [Form     =>] Ada | VMS]
2412   [, [Code     =>] static_integer_EXPRESSION]);
2413
2414 EXTERNAL_SYMBOL ::=
2415   IDENTIFIER
2416 | static_string_EXPRESSION
2417 @end smallexample
2418
2419 @noindent
2420 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2421 It allows OpenVMS conditions (for example, from OpenVMS system services or
2422 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2423 The pragma specifies that the exception associated with an exception
2424 declaration in an Ada program be defined externally (in non-Ada code).
2425 For further details on this pragma, see the
2426 DEC Ada Language Reference Manual, section 13.9a.3.1.
2427
2428 @node Pragma Import_Function
2429 @unnumberedsec Pragma Import_Function
2430 @findex Import_Function
2431 @noindent
2432 Syntax:
2433
2434 @smallexample @c ada
2435 pragma Import_Function (
2436      [Internal                 =>] LOCAL_NAME,
2437   [, [External                 =>] EXTERNAL_SYMBOL]
2438   [, [Parameter_Types          =>] PARAMETER_TYPES]
2439   [, [Result_Type              =>] SUBTYPE_MARK]
2440   [, [Mechanism                =>] MECHANISM]
2441   [, [Result_Mechanism         =>] MECHANISM_NAME]
2442   [, [First_Optional_Parameter =>] IDENTIFIER]);
2443
2444 EXTERNAL_SYMBOL ::=
2445   IDENTIFIER
2446 | static_string_EXPRESSION
2447
2448 PARAMETER_TYPES ::=
2449   null
2450 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2451
2452 TYPE_DESIGNATOR ::=
2453   subtype_NAME
2454 | subtype_Name ' Access
2455
2456 MECHANISM ::=
2457   MECHANISM_NAME
2458 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2459
2460 MECHANISM_ASSOCIATION ::=
2461   [formal_parameter_NAME =>] MECHANISM_NAME
2462
2463 MECHANISM_NAME ::=
2464   Value
2465 | Reference
2466 | Descriptor [([Class =>] CLASS_NAME)]
2467
2468 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2469 @end smallexample
2470
2471 @noindent
2472 This pragma is used in conjunction with a pragma @code{Import} to
2473 specify additional information for an imported function.  The pragma
2474 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2475 @code{Import_Function} pragma and both must appear in the same
2476 declarative part as the function specification.
2477
2478 The @var{Internal} argument must uniquely designate
2479 the function to which the
2480 pragma applies.  If more than one function name exists of this name in
2481 the declarative part you must use the @code{Parameter_Types} and
2482 @var{Result_Type} parameters to achieve the required unique
2483 designation.  Subtype marks in these parameters must exactly match the
2484 subtypes in the corresponding function specification, using positional
2485 notation to match parameters with subtype marks.
2486 The form with an @code{'Access} attribute can be used to match an
2487 anonymous access parameter.
2488
2489 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2490 parameters to specify passing mechanisms for the
2491 parameters and result.  If you specify a single mechanism name, it
2492 applies to all parameters.  Otherwise you may specify a mechanism on a
2493 parameter by parameter basis using either positional or named
2494 notation.  If the mechanism is not specified, the default mechanism
2495 is used.
2496
2497 @cindex OpenVMS
2498 @cindex Passing by descriptor
2499 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2500
2501 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2502 It specifies that the designated parameter and all following parameters
2503 are optional, meaning that they are not passed at the generated code
2504 level (this is distinct from the notion of optional parameters in Ada
2505 where the parameters are passed anyway with the designated optional
2506 parameters).  All optional parameters must be of mode @code{IN} and have
2507 default parameter values that are either known at compile time
2508 expressions, or uses of the @code{'Null_Parameter} attribute.
2509
2510 @node Pragma Import_Object
2511 @unnumberedsec Pragma Import_Object
2512 @findex Import_Object
2513 @noindent
2514 Syntax:
2515
2516 @smallexample @c ada
2517 pragma Import_Object
2518      [Internal =>] LOCAL_NAME
2519   [, [External =>] EXTERNAL_SYMBOL]
2520   [, [Size     =>] EXTERNAL_SYMBOL]);
2521
2522 EXTERNAL_SYMBOL ::=
2523   IDENTIFIER
2524 | static_string_EXPRESSION
2525 @end smallexample
2526
2527 @noindent
2528 This pragma designates an object as imported, and apart from the
2529 extended rules for external symbols, is identical in effect to the use of
2530 the normal @code{Import} pragma applied to an object.  Unlike the
2531 subprogram case, you need not use a separate @code{Import} pragma,
2532 although you may do so (and probably should do so from a portability
2533 point of view).  @var{size} is syntax checked, but otherwise ignored by
2534 GNAT@.
2535
2536 @node Pragma Import_Procedure
2537 @unnumberedsec Pragma Import_Procedure
2538 @findex Import_Procedure
2539 @noindent
2540 Syntax:
2541
2542 @smallexample @c ada
2543 pragma Import_Procedure (
2544      [Internal                 =>] LOCAL_NAME
2545   [, [External                 =>] EXTERNAL_SYMBOL]
2546   [, [Parameter_Types          =>] PARAMETER_TYPES]
2547   [, [Mechanism                =>] MECHANISM]
2548   [, [First_Optional_Parameter =>] IDENTIFIER]);
2549
2550 EXTERNAL_SYMBOL ::=
2551   IDENTIFIER
2552 | static_string_EXPRESSION
2553
2554 PARAMETER_TYPES ::=
2555   null
2556 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2557
2558 TYPE_DESIGNATOR ::=
2559   subtype_NAME
2560 | subtype_Name ' Access
2561
2562 MECHANISM ::=
2563   MECHANISM_NAME
2564 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2565
2566 MECHANISM_ASSOCIATION ::=
2567   [formal_parameter_NAME =>] MECHANISM_NAME
2568
2569 MECHANISM_NAME ::=
2570   Value
2571 | Reference
2572 | Descriptor [([Class =>] CLASS_NAME)]
2573
2574 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2575 @end smallexample
2576
2577 @noindent
2578 This pragma is identical to @code{Import_Function} except that it
2579 applies to a procedure rather than a function and the parameters
2580 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2581
2582 @node Pragma Import_Valued_Procedure
2583 @unnumberedsec Pragma Import_Valued_Procedure
2584 @findex Import_Valued_Procedure
2585 @noindent
2586 Syntax:
2587
2588 @smallexample @c ada
2589 pragma Import_Valued_Procedure (
2590      [Internal                 =>] LOCAL_NAME
2591   [, [External                 =>] EXTERNAL_SYMBOL]
2592   [, [Parameter_Types          =>] PARAMETER_TYPES]
2593   [, [Mechanism                =>] MECHANISM]
2594   [, [First_Optional_Parameter =>] IDENTIFIER]);
2595
2596 EXTERNAL_SYMBOL ::=
2597   IDENTIFIER
2598 | static_string_EXPRESSION
2599
2600 PARAMETER_TYPES ::=
2601   null
2602 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2603
2604 TYPE_DESIGNATOR ::=
2605   subtype_NAME
2606 | subtype_Name ' Access
2607
2608 MECHANISM ::=
2609   MECHANISM_NAME
2610 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2611
2612 MECHANISM_ASSOCIATION ::=
2613   [formal_parameter_NAME =>] MECHANISM_NAME
2614
2615 MECHANISM_NAME ::=
2616   Value
2617 | Reference
2618 | Descriptor [([Class =>] CLASS_NAME)]
2619
2620 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2621 @end smallexample
2622
2623 @noindent
2624 This pragma is identical to @code{Import_Procedure} except that the
2625 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2626 mode @code{OUT}, and externally the subprogram is treated as a function
2627 with this parameter as the result of the function.  The purpose of this
2628 capability is to allow the use of @code{OUT} and @code{IN OUT}
2629 parameters in interfacing to external functions (which are not permitted
2630 in Ada functions).  You may optionally use the @code{Mechanism}
2631 parameters to specify passing mechanisms for the parameters.
2632 If you specify a single mechanism name, it applies to all parameters.
2633 Otherwise you may specify a mechanism on a parameter by parameter
2634 basis using either positional or named notation.  If the mechanism is not
2635 specified, the default mechanism is used.
2636
2637 Note that it is important to use this pragma in conjunction with a separate
2638 pragma Import that specifies the desired convention, since otherwise the
2639 default convention is Ada, which is almost certainly not what is required.
2640
2641 @node Pragma Initialize_Scalars
2642 @unnumberedsec Pragma Initialize_Scalars
2643 @findex Initialize_Scalars
2644 @cindex debugging with Initialize_Scalars
2645 @noindent
2646 Syntax:
2647
2648 @smallexample @c ada
2649 pragma Initialize_Scalars;
2650 @end smallexample
2651
2652 @noindent
2653 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2654 two important differences.  First, there is no requirement for the pragma
2655 to be used uniformly in all units of a partition, in particular, it is fine
2656 to use this just for some or all of the application units of a partition,
2657 without needing to recompile the run-time library.
2658
2659 In the case where some units are compiled with the pragma, and some without,
2660 then a declaration of a variable where the type is defined in package
2661 Standard or is locally declared will always be subject to initialization,
2662 as will any declaration of a scalar variable.  For composite variables,
2663 whether the variable is initialized may also depend on whether the package
2664 in which the type of the variable is declared is compiled with the pragma.
2665
2666 The other important difference is that you can control the value used
2667 for initializing scalar objects.  At bind time, you can select several
2668 options for initialization. You can
2669 initialize with invalid values (similar to Normalize_Scalars, though for
2670 Initialize_Scalars it is not always possible to determine the invalid
2671 values in complex cases like signed component fields with non-standard
2672 sizes). You can also initialize with high or
2673 low values, or with a specified bit pattern.  See the users guide for binder
2674 options for specifying these cases.
2675
2676 This means that you can compile a program, and then without having to
2677 recompile the program, you can run it with different values being used
2678 for initializing otherwise uninitialized values, to test if your program
2679 behavior depends on the choice.  Of course the behavior should not change,
2680 and if it does, then most likely you have an erroneous reference to an
2681 uninitialized value.
2682
2683 It is even possible to change the value at execution time eliminating even
2684 the need to rebind with a different switch using an environment variable.
2685 See the GNAT users guide for details.
2686
2687 Note that pragma @code{Initialize_Scalars} is particularly useful in
2688 conjunction with the enhanced validity checking that is now provided
2689 in GNAT, which checks for invalid values under more conditions.
2690 Using this feature (see description of the @option{-gnatV} flag in the
2691 users guide) in conjunction with pragma @code{Initialize_Scalars}
2692 provides a powerful new tool to assist in the detection of problems
2693 caused by uninitialized variables.
2694
2695 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2696 effect on the generated code. This may cause your code to be
2697 substantially larger. It may also cause an increase in the amount
2698 of stack required, so it is probably a good idea to turn on stack
2699 checking (see description of stack checking in the GNAT users guide)
2700 when using this pragma.
2701
2702 @node Pragma Inline_Always
2703 @unnumberedsec Pragma Inline_Always
2704 @findex Inline_Always
2705 @noindent
2706 Syntax:
2707
2708 @smallexample @c ada
2709 pragma Inline_Always (NAME [, NAME]);
2710 @end smallexample
2711
2712 @noindent
2713 Similar to pragma @code{Inline} except that inlining is not subject to
2714 the use of option @option{-gnatn} and the inlining happens regardless of
2715 whether this option is used.
2716
2717 @node Pragma Inline_Generic
2718 @unnumberedsec Pragma Inline_Generic
2719 @findex Inline_Generic
2720 @noindent
2721 Syntax:
2722
2723 @smallexample @c ada
2724 pragma Inline_Generic (generic_package_NAME);
2725 @end smallexample
2726
2727 @noindent
2728 This is implemented for compatibility with DEC Ada 83 and is recognized,
2729 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2730 by default when using GNAT@.
2731
2732 @node Pragma Interface
2733 @unnumberedsec Pragma Interface
2734 @findex Interface
2735 @noindent
2736 Syntax:
2737
2738 @smallexample @c ada
2739 pragma Interface (
2740      [Convention    =>] convention_identifier,
2741      [Entity        =>] local_NAME
2742   [, [External_Name =>] static_string_expression]
2743   [, [Link_Name     =>] static_string_expression]);
2744 @end smallexample
2745
2746 @noindent
2747 This pragma is identical in syntax and semantics to
2748 the standard Ada pragma @code{Import}.  It is provided for compatibility
2749 with Ada 83.  The definition is upwards compatible both with pragma
2750 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2751 with some extended implementations of this pragma in certain Ada 83
2752 implementations.
2753
2754 @node Pragma Interface_Name
2755 @unnumberedsec Pragma Interface_Name
2756 @findex Interface_Name
2757 @noindent
2758 Syntax:
2759
2760 @smallexample @c ada
2761 pragma Interface_Name (
2762      [Entity        =>] LOCAL_NAME
2763   [, [External_Name =>] static_string_EXPRESSION]
2764   [, [Link_Name     =>] static_string_EXPRESSION]);
2765 @end smallexample
2766
2767 @noindent
2768 This pragma provides an alternative way of specifying the interface name
2769 for an interfaced subprogram, and is provided for compatibility with Ada
2770 83 compilers that use the pragma for this purpose.  You must provide at
2771 least one of @var{External_Name} or @var{Link_Name}.
2772
2773 @node Pragma Interrupt_Handler
2774 @unnumberedsec Pragma Interrupt_Handler
2775 @findex Interrupt_Handler
2776 @noindent
2777 Syntax:
2778
2779 @smallexample @c ada
2780 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2781 @end smallexample
2782
2783 @noindent
2784 This program unit pragma is supported for parameterless protected procedures
2785 as described in Annex C of the Ada Reference Manual. On the AAMP target
2786 the pragma can also be specified for nonprotected parameterless procedures
2787 that are declared at the library level (which includes procedures
2788 declared at the top level of a library package). In the case of AAMP,
2789 when this pragma is applied to a nonprotected procedure, the instruction
2790 @code{IERET} is generated for returns from the procedure, enabling
2791 maskable interrupts, in place of the normal return instruction.
2792
2793 @node Pragma Interrupt_State
2794 @unnumberedsec Pragma Interrupt_State
2795 @findex Interrupt_State
2796 @noindent
2797 Syntax:
2798
2799 @smallexample @c ada
2800 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2801 @end smallexample
2802
2803 @noindent
2804 Normally certain interrupts are reserved to the implementation.  Any attempt
2805 to attach an interrupt causes Program_Error to be raised, as described in
2806 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2807 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2808 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2809 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2810 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2811 Ada exceptions, or used to implement run-time functions such as the
2812 @code{abort} statement and stack overflow checking.
2813
2814 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2815 such uses of interrupts.  It subsumes the functionality of pragma
2816 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2817 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2818 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2819 and may be used to mark interrupts required by the board support package
2820 as reserved.
2821
2822 Interrupts can be in one of three states:
2823 @itemize @bullet
2824 @item System
2825
2826 The interrupt is reserved (no Ada handler can be installed), and the
2827 Ada run-time may not install a handler. As a result you are guaranteed
2828 standard system default action if this interrupt is raised.
2829
2830 @item Runtime
2831
2832 The interrupt is reserved (no Ada handler can be installed). The run time
2833 is allowed to install a handler for internal control purposes, but is
2834 not required to do so.
2835
2836 @item User
2837
2838 The interrupt is unreserved.  The user may install a handler to provide
2839 some other action.
2840 @end itemize
2841
2842 @noindent
2843 These states are the allowed values of the @code{State} parameter of the
2844 pragma.  The @code{Name} parameter is a value of the type
2845 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2846 @code{Ada.Interrupts.Names}.
2847
2848 This is a configuration pragma, and the binder will check that there
2849 are no inconsistencies between different units in a partition in how a
2850 given interrupt is specified. It may appear anywhere a pragma is legal.
2851
2852 The effect is to move the interrupt to the specified state.
2853
2854 By declaring interrupts to be SYSTEM, you guarantee the standard system
2855 action, such as a core dump.
2856
2857 By declaring interrupts to be USER, you guarantee that you can install
2858 a handler.
2859
2860 Note that certain signals on many operating systems cannot be caught and
2861 handled by applications.  In such cases, the pragma is ignored.  See the
2862 operating system documentation, or the value of the array @code{Reserved}
2863 declared in the spec of package @code{System.OS_Interface}.
2864
2865 Overriding the default state of signals used by the Ada runtime may interfere
2866 with an application's runtime behavior in the cases of the synchronous signals,
2867 and in the case of the signal used to implement the @code{abort} statement.
2868
2869 @node Pragma Keep_Names
2870 @unnumberedsec Pragma Keep_Names
2871 @findex Keep_Names
2872 @noindent
2873 Syntax:
2874
2875 @smallexample @c ada
2876 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2877 @end smallexample
2878
2879 @noindent
2880 The @var{LOCAL_NAME} argument
2881 must refer to an enumeration first subtype
2882 in the current declarative part. The effect is to retain the enumeration
2883 literal names for use by @code{Image} and @code{Value} even if a global
2884 @code{Discard_Names} pragma applies. This is useful when you want to
2885 generally suppress enumeration literal names and for example you therefore
2886 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2887 want to retain the names for specific enumeration types.
2888
2889 @node Pragma License
2890 @unnumberedsec Pragma License
2891 @findex License
2892 @cindex License checking
2893 @noindent
2894 Syntax:
2895
2896 @smallexample @c ada
2897 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2898 @end smallexample
2899
2900 @noindent
2901 This pragma is provided to allow automated checking for appropriate license
2902 conditions with respect to the standard and modified GPL@.  A pragma
2903 @code{License}, which is a configuration pragma that typically appears at
2904 the start of a source file or in a separate @file{gnat.adc} file, specifies
2905 the licensing conditions of a unit as follows:
2906
2907 @itemize @bullet
2908 @item Unrestricted
2909 This is used for a unit that can be freely used with no license restrictions.
2910 Examples of such units are public domain units, and units from the Ada
2911 Reference Manual.
2912
2913 @item GPL
2914 This is used for a unit that is licensed under the unmodified GPL, and which
2915 therefore cannot be @code{with}'ed by a restricted unit.
2916
2917 @item Modified_GPL
2918 This is used for a unit licensed under the GNAT modified GPL that includes
2919 a special exception paragraph that specifically permits the inclusion of
2920 the unit in programs without requiring the entire program to be released
2921 under the GPL@.
2922
2923 @item Restricted
2924 This is used for a unit that is restricted in that it is not permitted to
2925 depend on units that are licensed under the GPL@.  Typical examples are
2926 proprietary code that is to be released under more restrictive license
2927 conditions.  Note that restricted units are permitted to @code{with} units
2928 which are licensed under the modified GPL (this is the whole point of the
2929 modified GPL).
2930
2931 @end itemize
2932
2933 @noindent
2934 Normally a unit with no @code{License} pragma is considered to have an
2935 unknown license, and no checking is done.  However, standard GNAT headers
2936 are recognized, and license information is derived from them as follows.
2937
2938 @itemize @bullet
2939
2940 A GNAT license header starts with a line containing 78 hyphens.  The following
2941 comment text is searched for the appearance of any of the following strings.
2942
2943 If the string ``GNU General Public License'' is found, then the unit is assumed
2944 to have GPL license, unless the string ``As a special exception'' follows, in
2945 which case the license is assumed to be modified GPL@.
2946
2947 If one of the strings
2948 ``This specification is adapted from the Ada Semantic Interface'' or
2949 ``This specification is derived from the Ada Reference Manual'' is found
2950 then the unit is assumed to be unrestricted.
2951 @end itemize
2952
2953 @noindent
2954 These default actions means that a program with a restricted license pragma
2955 will automatically get warnings if a GPL unit is inappropriately
2956 @code{with}'ed.  For example, the program:
2957
2958 @smallexample @c ada
2959 with Sem_Ch3;
2960 with GNAT.Sockets;
2961 procedure Secret_Stuff is
2962   @dots{}
2963 end Secret_Stuff
2964 @end smallexample
2965
2966 @noindent
2967 if compiled with pragma @code{License} (@code{Restricted}) in a
2968 @file{gnat.adc} file will generate the warning:
2969
2970 @smallexample
2971 1.  with Sem_Ch3;
2972         |
2973    >>> license of withed unit "Sem_Ch3" is incompatible
2974
2975 2.  with GNAT.Sockets;
2976 3.  procedure Secret_Stuff is
2977 @end smallexample
2978
2979 @noindent
2980 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2981 compiler and is licensed under the
2982 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2983 run time, and is therefore licensed under the modified GPL@.
2984
2985 @node Pragma Link_With
2986 @unnumberedsec Pragma Link_With
2987 @findex Link_With
2988 @noindent
2989 Syntax:
2990
2991 @smallexample @c ada
2992 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2993 @end smallexample
2994
2995 @noindent
2996 This pragma is provided for compatibility with certain Ada 83 compilers.
2997 It has exactly the same effect as pragma @code{Linker_Options} except
2998 that spaces occurring within one of the string expressions are treated
2999 as separators. For example, in the following case:
3000
3001 @smallexample @c ada
3002 pragma Link_With ("-labc -ldef");
3003 @end smallexample
3004
3005 @noindent
3006 results in passing the strings @code{-labc} and @code{-ldef} as two
3007 separate arguments to the linker. In addition pragma Link_With allows
3008 multiple arguments, with the same effect as successive pragmas.
3009
3010 @node Pragma Linker_Alias
3011 @unnumberedsec Pragma Linker_Alias
3012 @findex Linker_Alias
3013 @noindent
3014 Syntax:
3015
3016 @smallexample @c ada
3017 pragma Linker_Alias (
3018   [Entity =>] LOCAL_NAME,
3019   [Target =>] static_string_EXPRESSION);
3020 @end smallexample
3021
3022 @noindent
3023 @var{LOCAL_NAME} must refer to an object that is declared at the library
3024 level. This pragma establishes the given entity as a linker alias for the
3025 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3026 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3027 @var{static_string_EXPRESSION} in the object file, that is to say no space
3028 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3029 to the same address as @var{static_string_EXPRESSION} by the linker.
3030
3031 The actual linker name for the target must be used (e.g.@: the fully
3032 encoded name with qualification in Ada, or the mangled name in C++),
3033 or it must be declared using the C convention with @code{pragma Import}
3034 or @code{pragma Export}.
3035
3036 Not all target machines support this pragma. On some of them it is accepted
3037 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3038
3039 @smallexample @c ada
3040 --  Example of the use of pragma Linker_Alias
3041
3042 package p is
3043   i : Integer := 1;
3044   pragma Export (C, i);
3045
3046   new_name_for_i : Integer;
3047   pragma Linker_Alias (new_name_for_i, "i");
3048 end p;
3049 @end smallexample
3050
3051 @node Pragma Linker_Constructor
3052 @unnumberedsec Pragma Linker_Constructor
3053 @findex Linker_Constructor
3054 @noindent
3055 Syntax:
3056
3057 @smallexample @c ada
3058 pragma Linker_Constructor (procedure_LOCAL_NAME);
3059 @end smallexample
3060
3061 @noindent
3062 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3063 is declared at the library level. A procedure to which this pragma is
3064 applied will be treated as an initialization routine by the linker.
3065 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3066 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3067 of the executable is called (or immediately after the shared library is
3068 loaded if the procedure is linked in a shared library), in particular
3069 before the Ada run-time environment is set up.
3070
3071 Because of these specific contexts, the set of operations such a procedure
3072 can perform is very limited and the type of objects it can manipulate is
3073 essentially restricted to the elementary types. In particular, it must only
3074 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3075
3076 This pragma is used by GNAT to implement auto-initialization of shared Stand
3077 Alone Libraries, which provides a related capability without the restrictions
3078 listed above. Where possible, the use of Stand Alone Libraries is preferable
3079 to the use of this pragma.
3080
3081 @node Pragma Linker_Destructor
3082 @unnumberedsec Pragma Linker_Destructor
3083 @findex Linker_Destructor
3084 @noindent
3085 Syntax:
3086
3087 @smallexample @c ada
3088 pragma Linker_Destructor (procedure_LOCAL_NAME);
3089 @end smallexample
3090
3091 @noindent
3092 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3093 is declared at the library level. A procedure to which this pragma is
3094 applied will be treated as a finalization routine by the linker.
3095 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3096 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3097 of the executable has exited (or immediately before the shared library
3098 is unloaded if the procedure is linked in a shared library), in particular
3099 after the Ada run-time environment is shut down.
3100
3101 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3102 because of these specific contexts.
3103
3104 @node Pragma Linker_Section
3105 @unnumberedsec Pragma Linker_Section
3106 @findex Linker_Section
3107 @noindent
3108 Syntax:
3109
3110 @smallexample @c ada
3111 pragma Linker_Section (
3112   [Entity  =>] LOCAL_NAME,
3113   [Section =>] static_string_EXPRESSION);
3114 @end smallexample
3115
3116 @noindent
3117 @var{LOCAL_NAME} must refer to an object that is declared at the library
3118 level. This pragma specifies the name of the linker section for the given
3119 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3120 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3121 section of the executable (assuming the linker doesn't rename the section).
3122
3123 The compiler normally places library-level objects in standard sections
3124 depending on their type: procedures and functions generally go in the
3125 @code{.text} section, initialized variables in the @code{.data} section
3126 and uninitialized variables in the @code{.bss} section.
3127
3128 Other, special sections may exist on given target machines to map special
3129 hardware, for example I/O ports or flash memory. This pragma is a means to
3130 defer the final layout of the executable to the linker, thus fully working
3131 at the symbolic level with the compiler.
3132
3133 Some file formats do not support arbitrary sections so not all target
3134 machines support this pragma. The use of this pragma may cause a program
3135 execution to be erroneous if it is used to place an entity into an
3136 inappropriate section (e.g.@: a modified variable into the @code{.text}
3137 section). See also @code{pragma Persistent_BSS}.
3138
3139 @smallexample @c ada
3140 --  Example of the use of pragma Linker_Section
3141
3142 package IO_Card is
3143   Port_A : Integer;
3144   pragma Volatile (Port_A);
3145   pragma Linker_Section (Port_A, ".bss.port_a");
3146
3147   Port_B : Integer;
3148   pragma Volatile (Port_B);
3149   pragma Linker_Section (Port_B, ".bss.port_b");
3150 end IO_Card;
3151 @end smallexample
3152
3153 @node Pragma Long_Float
3154 @unnumberedsec Pragma Long_Float
3155 @cindex OpenVMS
3156 @findex Long_Float
3157 @noindent
3158 Syntax:
3159
3160 @smallexample @c ada
3161 pragma Long_Float (FLOAT_FORMAT);
3162
3163 FLOAT_FORMAT ::= D_Float | G_Float
3164 @end smallexample
3165
3166 @noindent
3167 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3168 It allows control over the internal representation chosen for the predefined
3169 type @code{Long_Float} and for floating point type representations with
3170 @code{digits} specified in the range 7 through 15.
3171 For further details on this pragma, see the
3172 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3173 this pragma, the standard runtime libraries must be recompiled.
3174 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3175 @value{EDITION} User's Guide OpenVMS}, for a description of the
3176 @code{GNAT LIBRARY} command.
3177
3178 @node Pragma Machine_Attribute
3179 @unnumberedsec Pragma Machine_Attribute
3180 @findex Machine_Attribute
3181 @noindent
3182 Syntax:
3183
3184 @smallexample @c ada
3185 pragma Machine_Attribute (
3186      [Entity         =>] LOCAL_NAME,
3187      [Attribute_Name =>] static_string_EXPRESSION
3188   [, [Info           =>] static_string_EXPRESSION] );
3189 @end smallexample
3190
3191 @noindent
3192 Machine-dependent attributes can be specified for types and/or
3193 declarations.  This pragma is semantically equivalent to
3194 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3195 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3196 in GNU C, where @code{@var{attribute_name}} is recognized by the
3197 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3198 machine.  The optional parameter @var{info} is transformed into an
3199 identifier, which may make this pragma unusable for some attributes
3200 (parameter of some attributes must be a number or a string).
3201 @xref{Target Attributes,, Defining target-specific uses of
3202 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3203 further information.  It is not possible to specify
3204 attributes defined by other languages, only attributes defined by the
3205 machine the code is intended to run on.
3206
3207 @node Pragma Main
3208 @unnumberedsec Pragma Main
3209 @cindex OpenVMS
3210 @findex Main
3211 @noindent
3212 Syntax:
3213
3214 @smallexample @c ada
3215 pragma Main
3216  (MAIN_OPTION [, MAIN_OPTION]);
3217
3218 MAIN_OPTION ::=
3219   [STACK_SIZE              =>] static_integer_EXPRESSION
3220 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3221 | [TIME_SLICING_ENABLED    =>] static_boolean_EXPRESSION
3222 @end smallexample
3223
3224 @noindent
3225 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3226 no effect in GNAT, other than being syntax checked.
3227
3228 @node Pragma Main_Storage
3229 @unnumberedsec Pragma Main_Storage
3230 @cindex OpenVMS
3231 @findex Main_Storage
3232 @noindent
3233 Syntax:
3234
3235 @smallexample @c ada
3236 pragma Main_Storage
3237   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3238
3239 MAIN_STORAGE_OPTION ::=
3240   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3241 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3242 @end smallexample
3243
3244 @noindent
3245 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3246 no effect in GNAT, other than being syntax checked.  Note that the pragma
3247 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3248
3249 @node Pragma No_Body
3250 @unnumberedsec Pragma No_Body
3251 @findex No_Body
3252 @noindent
3253 Syntax:
3254
3255 @smallexample @c ada
3256 pragma No_Body;
3257 @end smallexample
3258
3259 @noindent
3260 There are a number of cases in which a package spec does not require a body,
3261 and in fact a body is not permitted. GNAT will not permit the spec to be
3262 compiled if there is a body around. The pragma No_Body allows you to provide
3263 a body file, even in a case where no body is allowed. The body file must
3264 contain only comments and a single No_Body pragma. This is recognized by
3265 the compiler as indicating that no body is logically present.
3266
3267 This is particularly useful during maintenance when a package is modified in
3268 such a way that a body needed before is no longer needed. The provision of a
3269 dummy body with a No_Body pragma ensures that there is no interference from
3270 earlier versions of the package body.
3271
3272 @node Pragma No_Return
3273 @unnumberedsec Pragma No_Return
3274 @findex No_Return
3275 @noindent
3276 Syntax:
3277
3278 @smallexample @c ada
3279 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3280 @end smallexample
3281
3282 @noindent
3283 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3284 declarations in the current declarative part.  A procedure to which this
3285 pragma is applied may not contain any explicit @code{return} statements.
3286 In addition, if the procedure contains any implicit returns from falling
3287 off the end of a statement sequence, then execution of that implicit
3288 return will cause Program_Error to be raised.
3289
3290 One use of this pragma is to identify procedures whose only purpose is to raise
3291 an exception. Another use of this pragma is to suppress incorrect warnings
3292 about missing returns in functions, where the last statement of a function
3293 statement sequence is a call to such a procedure.
3294
3295 Note that in Ada 2005 mode, this pragma is part of the language, and is
3296 identical in effect to the pragma as implemented in Ada 95 mode.
3297
3298 @node Pragma No_Strict_Aliasing
3299 @unnumberedsec Pragma No_Strict_Aliasing
3300 @findex No_Strict_Aliasing
3301 @noindent
3302 Syntax:
3303
3304 @smallexample @c ada
3305 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3306 @end smallexample
3307
3308 @noindent
3309 @var{type_LOCAL_NAME} must refer to an access type
3310 declaration in the current declarative part.  The effect is to inhibit
3311 strict aliasing optimization for the given type.  The form with no
3312 arguments is a configuration pragma which applies to all access types
3313 declared in units to which the pragma applies. For a detailed
3314 description of the strict aliasing optimization, and the situations
3315 in which it must be suppressed, see @ref{Optimization and Strict
3316 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3317
3318 @node Pragma Normalize_Scalars
3319 @unnumberedsec Pragma Normalize_Scalars
3320 @findex Normalize_Scalars
3321 @noindent
3322 Syntax:
3323
3324 @smallexample @c ada
3325 pragma Normalize_Scalars;
3326 @end smallexample
3327
3328 @noindent
3329 This is a language defined pragma which is fully implemented in GNAT@.  The
3330 effect is to cause all scalar objects that are not otherwise initialized
3331 to be initialized.  The initial values are implementation dependent and
3332 are as follows:
3333
3334 @table @code
3335 @item Standard.Character
3336 @noindent
3337 Objects whose root type is Standard.Character are initialized to
3338 Character'Last unless the subtype range excludes NUL (in which case
3339 NUL is used). This choice will always generate an invalid value if
3340 one exists.
3341
3342 @item Standard.Wide_Character
3343 @noindent
3344 Objects whose root type is Standard.Wide_Character are initialized to
3345 Wide_Character'Last unless the subtype range excludes NUL (in which case
3346 NUL is used). This choice will always generate an invalid value if
3347 one exists.
3348
3349 @item Standard.Wide_Wide_Character
3350 @noindent
3351 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3352 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3353 which case NUL is used). This choice will always generate an invalid value if
3354 one exists.
3355
3356 @item Integer types
3357 @noindent
3358 Objects of an integer type are treated differently depending on whether
3359 negative values are present in the subtype. If no negative values are
3360 present, then all one bits is used as the initial value except in the
3361 special case where zero is excluded from the subtype, in which case
3362 all zero bits are used. This choice will always generate an invalid
3363 value if one exists.
3364
3365 For subtypes with negative values present, the largest negative number
3366 is used, except in the unusual case where this largest negative number
3367 is in the subtype, and the largest positive number is not, in which case
3368 the largest positive value is used. This choice will always generate
3369 an invalid value if one exists.
3370
3371 @item Floating-Point Types
3372 Objects of all floating-point types are initialized to all 1-bits. For
3373 standard IEEE format, this corresponds to a NaN (not a number) which is
3374 indeed an invalid value.
3375
3376 @item Fixed-Point Types
3377 Objects of all fixed-point types are treated as described above for integers,
3378 with the rules applying to the underlying integer value used to represent
3379 the fixed-point value.
3380
3381 @item Modular types
3382 Objects of a modular type are initialized to all one bits, except in
3383 the special case where zero is excluded from the subtype, in which
3384 case all zero bits are used. This choice will always generate an
3385 invalid value if one exists.
3386
3387 @item Enumeration types
3388 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3389 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3390 whose Pos value is zero, in which case a code of zero is used. This choice
3391 will always generate an invalid value if one exists.
3392
3393 @end table
3394
3395 @node Pragma Obsolescent
3396 @unnumberedsec Pragma Obsolescent
3397 @findex Obsolescent
3398 @noindent
3399 Syntax:
3400
3401 @smallexample @c ada
3402 pragma Obsolescent
3403   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3404 @end smallexample
3405
3406 @noindent
3407 This pragma can occur immediately following a declaration of an entity,
3408 including the case of a record component, and usually the Entity name
3409 must match the name of the entity declared by this declaration.
3410 Alternatively, the pragma can immediately follow an
3411 enumeration type declaration, where the entity argument names one of the
3412 enumeration literals.
3413
3414 This pragma is used to indicate that the named entity
3415 is considered obsolescent and should not be used. Typically this is
3416 used when an API must be modified by eventually removing or modifying
3417 existing subprograms or other entities. The pragma can be used at an
3418 intermediate stage when the entity is still present, but will be
3419 removed later.
3420
3421 The effect of this pragma is to output a warning message on
3422 a call to a program thus marked that the
3423 subprogram is obsolescent if the appropriate warning option in the
3424 compiler is activated. If the string parameter is present, then a second
3425 warning message is given containing this text.
3426 In addition, a call to such a program is considered a violation of
3427 pragma Restrictions (No_Obsolescent_Features).
3428
3429 This pragma can also be used as a program unit pragma for a package,
3430 in which case the entity name is the name of the package, and the
3431 pragma indicates that the entire package is considered
3432 obsolescent. In this case a client @code{with}'ing such a package
3433 violates the restriction, and the @code{with} statement is
3434 flagged with warnings if the warning option is set.
3435
3436 If the optional third parameter is present (which must be exactly
3437 the identifier Ada_05, no other argument is allowed), then the
3438 indication of obsolescence applies only when compiling in Ada 2005
3439 mode. This is primarily intended for dealing with the situations
3440 in the predefined library where subprograms or packages
3441 have become defined as obsolescent in Ada 2005
3442 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3443
3444 The following examples show typical uses of this pragma:
3445
3446 @smallexample @c ada
3447 package p is
3448    pragma Obsolescent
3449      (Entity => p, "use pp instead of p");
3450 end p;
3451
3452 package q is
3453    procedure q2;
3454    pragma Obsolescent
3455      (Entity => q2, "use q2new instead");
3456
3457    type R is new integer;
3458    pragma Obsolescent
3459      (Entity => R, "use RR in Ada 2005", Ada_05);
3460
3461    type M is record
3462       F1 : Integer;
3463       F2 : Integer;
3464       pragma Obsolescent (Entity => F2);
3465       F3 : Integer;
3466    end record;
3467
3468    type E is (a, bc, 'd', quack);
3469    pragma Obsolescent (Entity => bc)
3470    pragma Obsolescent (Entity => 'd')
3471
3472    function "+"
3473      (a, b : character) return character;
3474    pragma Obsolescent (Entity => "+");
3475 end;
3476 @end smallexample
3477
3478 @noindent
3479 In an earlier version of GNAT, the Entity parameter was not required,
3480 and this form is still accepted for compatibility purposes. If the
3481 Entity parameter is omitted, then the pragma applies to the declaration
3482 immediately preceding the pragma (this form cannot be used for the
3483 enumeration literal case).
3484
3485 @node Pragma Optimize_Alignment
3486 @unnumberedsec Pragma Optimize_Alignment
3487 @findex Optimize_Alignment
3488 @cindex Alignment, default settings
3489 @noindent
3490 Syntax:
3491
3492 @smallexample @c ada
3493 pragma Optimize_Alignment (TIME | SPACE | OFF);
3494 @end smallexample
3495
3496 @noindent
3497 This is a configuration pragma which affects the choice of default alignments
3498 for types where no alignment is explicitly specified. There is a time/space
3499 trade-off in the selection of these values. Large alignments result in more
3500 efficient code, at the expense of larger data space, since sizes have to be
3501 increased to match these alignments. Smaller alignments save space, but the
3502 access code is slower. The normal choice of default alignments (which is what
3503 you get if you do not use this pragma, or if you use an argument of OFF),
3504 tries to balance these two requirements.
3505
3506 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3507 First any packed record is given an alignment of 1. Second, if a size is given
3508 for the type, then the alignment is chosen to avoid increasing this size. For
3509 example, consider:
3510
3511 @smallexample @c ada
3512    type R is record
3513       X : Integer;
3514       Y : Character;
3515    end record;
3516
3517    for R'Size use 5*8;
3518 @end smallexample
3519
3520 @noindent
3521 In the default mode, this type gets an alignment of 4, so that access to the
3522 Integer field X are efficient. But this means that objects of the type end up
3523 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3524 allowed to be bigger than the size of the type, but it can waste space if for
3525 example fields of type R appear in an enclosing record. If the above type is
3526 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3527
3528 Specifying TIME causes larger default alignments to be chosen in the case of
3529 small types with sizes that are not a power of 2. For example, consider:
3530
3531 @smallexample @c ada
3532    type R is record
3533       A : Character;
3534       B : Character;
3535       C : Boolean;
3536    end record;
3537
3538    pragma Pack (R);
3539    for R'Size use 17;
3540 @end smallexample
3541
3542 @noindent
3543 The default alignment for this record is normally 1, but if this type is
3544 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3545 to 4, which wastes space for objects of the type, since they are now 4 bytes
3546 long, but results in more efficient access when the whole record is referenced.
3547
3548 As noted above, this is a configuration pragma, and there is a requirement
3549 that all units in a partition be compiled with a consistent setting of the
3550 optimization setting. This would normally be achieved by use of a configuration
3551 pragma file containing the appropriate setting. The exception to this rule is
3552 that units with an explicit configuration pragma in the same file as the source
3553 unit are excluded from the consistency check, as are all predefined units. The
3554 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3555 pragma appears at the start of the file.
3556
3557 @node Pragma Passive
3558 @unnumberedsec Pragma Passive
3559 @findex Passive
3560 @noindent
3561 Syntax:
3562
3563 @smallexample @c ada
3564 pragma Passive [(Semaphore | No)];
3565 @end smallexample
3566
3567 @noindent
3568 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3569 compatibility with DEC Ada 83 implementations, where it is used within a
3570 task definition to request that a task be made passive.  If the argument
3571 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3572 treats the pragma as an assertion that the containing task is passive
3573 and that optimization of context switch with this task is permitted and
3574 desired.  If the argument @code{No} is present, the task must not be
3575 optimized.  GNAT does not attempt to optimize any tasks in this manner
3576 (since protected objects are available in place of passive tasks).
3577
3578 @node Pragma Persistent_BSS
3579 @unnumberedsec Pragma Persistent_BSS
3580 @findex Persistent_BSS
3581 @noindent
3582 Syntax:
3583
3584 @smallexample @c ada
3585 pragma Persistent_BSS [(LOCAL_NAME)]
3586 @end smallexample
3587
3588 @noindent
3589 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3590 section. On some targets the linker and loader provide for special
3591 treatment of this section, allowing a program to be reloaded without
3592 affecting the contents of this data (hence the name persistent).
3593
3594 There are two forms of usage. If an argument is given, it must be the
3595 local name of a library level object, with no explicit initialization
3596 and whose type is potentially persistent. If no argument is given, then
3597 the pragma is a configuration pragma, and applies to all library level
3598 objects with no explicit initialization of potentially persistent types.
3599
3600 A potentially persistent type is a scalar type, or a non-tagged,
3601 non-discriminated record, all of whose components have no explicit
3602 initialization and are themselves of a potentially persistent type,
3603 or an array, all of whose constraints are static, and whose component
3604 type is potentially persistent.
3605
3606 If this pragma is used on a target where this feature is not supported,
3607 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3608
3609 @node Pragma Polling
3610 @unnumberedsec Pragma Polling
3611 @findex Polling
3612 @noindent
3613 Syntax:
3614
3615 @smallexample @c ada
3616 pragma Polling (ON | OFF);
3617 @end smallexample
3618
3619 @noindent
3620 This pragma controls the generation of polling code.  This is normally off.
3621 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3622 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3623 runtime library, and can be found in file @file{a-excpol.adb}.
3624
3625 Pragma @code{Polling} can appear as a configuration pragma (for example it
3626 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3627 can be used in the statement or declaration sequence to control polling
3628 more locally.
3629
3630 A call to the polling routine is generated at the start of every loop and
3631 at the start of every subprogram call.  This guarantees that the @code{Poll}
3632 routine is called frequently, and places an upper bound (determined by
3633 the complexity of the code) on the period between two @code{Poll} calls.
3634
3635 The primary purpose of the polling interface is to enable asynchronous
3636 aborts on targets that cannot otherwise support it (for example Windows
3637 NT), but it may be used for any other purpose requiring periodic polling.
3638 The standard version is null, and can be replaced by a user program.  This
3639 will require re-compilation of the @code{Ada.Exceptions} package that can
3640 be found in files @file{a-except.ads} and @file{a-except.adb}.
3641
3642 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3643 distribution) is used to enable the asynchronous abort capability on
3644 targets that do not normally support the capability.  The version of
3645 @code{Poll} in this file makes a call to the appropriate runtime routine
3646 to test for an abort condition.
3647
3648 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3649 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3650 details.
3651
3652 @node Pragma Postcondition
3653 @unnumberedsec Pragma Postcondition
3654 @cindex Postconditions
3655 @cindex Checks, postconditions
3656 @findex Postconditions
3657 @noindent
3658 Syntax:
3659
3660 @smallexample @c ada
3661 pragma Postcondition (
3662    [Check   =>] Boolean_Expression
3663  [,[Message =>] String_Expression]);
3664 @end smallexample
3665
3666 @noindent
3667 The @code{Postcondition} pragma allows specification of automatic
3668 postcondition checks for subprograms. These checks are similar to
3669 assertions, but are automatically inserted just prior to the return
3670 statements of the subprogram with which they are associated.
3671 Furthermore, the boolean expression which is the condition which
3672 must be true may contain references to function'Result in the case
3673 of a function to refer to the returned value.
3674
3675 @code{Postcondition} pragmas may appear either immediate following the
3676 (separate) declaration of a subprogram, or at the start of the
3677 declarations of a subprogram body. Only other pragmas may intervene
3678 (that is appear between the subprogram declaration and its
3679 postconditions, or appear before the postcondition in the
3680 declaration sequence in a subprogram body). In the case of a
3681 postcondition appearing after a subprogram declaration, the
3682 formal arguments of the subprogram are visible, and can be
3683 referenced in the postcondition expressions.
3684
3685 The postconditions are collected and automatically tested just
3686 before any return (implicit or explicit) in the subprogram body.
3687 A postcondition is only recognized if postconditions are active
3688 at the time the pragma is encountered. The compiler switch @option{gnata}
3689 turns on all postconditions by default, and pragma @code{Check_Policy}
3690 with an identifier of @code{Postcondition} can also be used to
3691 control whether postconditions are active.
3692
3693 The general approach is that postconditions are placed in the spec
3694 if they represent functional aspects which make sense to the client.
3695 For example we might have:
3696
3697 @smallexample @c ada
3698    function Direction return Integer;
3699    pragma Postcondition
3700     (Direction'Result = +1
3701        or else
3702      Direction'Result = -1);
3703 @end smallexample
3704
3705 @noindent
3706 which serves to document that the result must be +1 or -1, and
3707 will test that this is the case at run time if postcondition
3708 checking is active.
3709
3710 Postconditions within the subprogram body can be used to
3711 check that some internal aspect of the implementation,
3712 not visible to the client, is operating as expected.
3713 For instance if a square root routine keeps an internal
3714 counter of the number of times it is called, then we
3715 might have the following postcondition:
3716
3717 @smallexample @c ada
3718    Sqrt_Calls : Natural := 0;
3719
3720    function Sqrt (Arg : Float) return Float is
3721      pragma Postcondition
3722        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3723      ...
3724    end Sqrt
3725 @end smallexample
3726
3727 @noindent
3728 As this example, shows, the use of the @code{Old} attribute
3729 is often useful in postconditions to refer to the state on
3730 entry to the subprogram.
3731
3732 Note that postconditions are only checked on normal returns
3733 from the subprogram. If an abnormal return results from
3734 raising an exception, then the postconditions are not checked.
3735
3736 If a postcondition fails, then the exception
3737 @code{System.Assertions.Assert_Failure} is raised. If
3738 a message argument was supplied, then the given string
3739 will be used as the exception message. If no message
3740 argument was supplied, then the default message has
3741 the form "Postcondition failed at file:line". The
3742 exception is raised in the context of the subprogram
3743 body, so it is possible to catch postcondition failures
3744 within the subprogram body itself.
3745
3746 Within a package spec, normal visibility rules
3747 in Ada would prevent forward references within a
3748 postcondition pragma to functions defined later in
3749 the same package. This would introduce undesirable
3750 ordering constraints. To avoid this problem, all
3751 postcondition pragmas are analyzed at the end of
3752 the package spec, allowing forward references.
3753
3754 The following example shows that this even allows
3755 mutually recursive postconditions as in:
3756
3757 @smallexample @c ada
3758 package Parity_Functions is
3759    function Odd  (X : Natural) return Boolean;
3760    pragma Postcondition
3761      (Odd'Result =
3762         (x = 1
3763           or else
3764         (x /= 0 and then Even (X - 1))));
3765
3766    function Even (X : Natural) return Boolean;
3767    pragma Postcondition
3768      (Even'Result =
3769         (x = 0
3770           or else
3771         (x /= 1 and then Odd (X - 1))));
3772
3773 end Parity_Functions;
3774 @end smallexample
3775
3776 @noindent
3777 There are no restrictions on the complexity or form of
3778 conditions used within @code{Postcondition} pragmas.
3779 The following example shows that it is even possible
3780 to verify performance behavior.
3781
3782 @smallexample @c ada
3783 package Sort is
3784
3785    Performance : constant Float;
3786    --  Performance constant set by implementation
3787    --  to match target architecture behavior.
3788
3789    procedure Treesort (Arg : String);
3790    --  Sorts characters of argument using N*logN sort
3791    pragma Postcondition
3792      (Float (Clock - Clock'Old) <=
3793         Float (Arg'Length) *
3794         log (Float (Arg'Length)) *
3795         Performance);
3796 end Sort;
3797 @end smallexample
3798
3799 @node Pragma Precondition
3800 @unnumberedsec Pragma Precondition
3801 @cindex Preconditions
3802 @cindex Checks, preconditions
3803 @findex Preconditions
3804 @noindent
3805 Syntax:
3806
3807 @smallexample @c ada
3808 pragma Precondition (
3809    [Check   =>] Boolean_Expression
3810  [,[Message =>] String_Expression]);
3811 @end smallexample
3812
3813 @noindent
3814 The @code{Precondition} pragma is similar to @code{Postcondition}
3815 except that the corresponding checks take place immediately upon
3816 entry to the subprogram, and if a precondition fails, the exception
3817 is raised in the context of the caller, and the attribute 'Result
3818 cannot be used within the precondition expression.
3819
3820 Otherwise, the placement and visibility rules are identical to those
3821 described for postconditions. The following is an example of use
3822 within a package spec:
3823
3824 @smallexample @c ada
3825 package Math_Functions is
3826    ...
3827    function Sqrt (Arg : Float) return Float;
3828    pragma Precondition (Arg >= 0.0)
3829    ...
3830 end Math_Functions;
3831 @end smallexample
3832
3833 @code{Postcondition} pragmas may appear either immediate following the
3834 (separate) declaration of a subprogram, or at the start of the
3835 declarations of a subprogram body. Only other pragmas may intervene
3836 (that is appear between the subprogram declaration and its
3837 postconditions, or appear before the postcondition in the
3838 declaration sequence in a subprogram body).
3839
3840 @node Pragma Profile (Ravenscar)
3841 @unnumberedsec Pragma Profile (Ravenscar)
3842 @findex Ravenscar
3843 @noindent
3844 Syntax:
3845
3846 @smallexample @c ada
3847 pragma Profile (Ravenscar);
3848 @end smallexample
3849
3850 @noindent
3851 A configuration pragma that establishes the following set of configuration
3852 pragmas:
3853
3854 @table @code
3855 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3856 [RM D.2.2] Tasks are dispatched following a preemptive
3857 priority-ordered scheduling policy.
3858
3859 @item Locking_Policy (Ceiling_Locking)
3860 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3861 the ceiling priority of the corresponding protected object.
3862 @c
3863 @c @item Detect_Blocking
3864 @c This pragma forces the detection of potentially blocking operations within a
3865 @c protected operation, and to raise Program_Error if that happens.
3866 @end table
3867 @noindent
3868
3869 plus the following set of restrictions:
3870
3871 @table @code
3872 @item Max_Entry_Queue_Length = 1
3873 Defines the maximum number of calls that are queued on a (protected) entry.
3874 Note that this restrictions is checked at run time. Violation of this
3875 restriction results in the raising of Program_Error exception at the point of
3876 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3877 always 1 and hence no task can be queued on a protected entry.
3878
3879 @item Max_Protected_Entries = 1
3880 [RM D.7] Specifies the maximum number of entries per protected type. The
3881 bounds of every entry family of a protected unit shall be static, or shall be
3882 defined by a discriminant of a subtype whose corresponding bound is static.
3883 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3884
3885 @item Max_Task_Entries = 0
3886 [RM D.7] Specifies the maximum number of entries
3887 per task.  The bounds of every entry family
3888 of a task unit shall be static, or shall be
3889 defined by a discriminant of a subtype whose
3890 corresponding bound is static.  A value of zero
3891 indicates that no rendezvous are possible.  For
3892 the Profile (Ravenscar), the value of Max_Task_Entries is always
3893 0 (zero).
3894
3895 @item No_Abort_Statements
3896 [RM D.7] There are no abort_statements, and there are
3897 no calls to Task_Identification.Abort_Task.
3898
3899 @item No_Asynchronous_Control
3900 [RM D.7] There are no semantic dependences on the package
3901 Asynchronous_Task_Control.
3902
3903 @item No_Calendar
3904 There are no semantic dependencies on the package Ada.Calendar.
3905
3906 @item No_Dynamic_Attachment
3907 There is no call to any of the operations defined in package Ada.Interrupts
3908 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3909 Detach_Handler, and Reference).
3910
3911 @item No_Dynamic_Priorities
3912 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3913
3914 @item No_Implicit_Heap_Allocations
3915 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3916
3917 @item No_Local_Protected_Objects
3918 Protected objects and access types that designate
3919 such objects shall be declared only at library level.
3920
3921 @item No_Protected_Type_Allocators
3922 There are no allocators for protected types or
3923 types containing protected subcomponents.
3924
3925 @item No_Relative_Delay
3926 There are no delay_relative statements.
3927
3928 @item No_Requeue_Statements
3929 Requeue statements are not allowed.
3930
3931 @item No_Select_Statements
3932 There are no select_statements.
3933
3934 @item No_Task_Allocators
3935 [RM D.7] There are no allocators for task types
3936 or types containing task subcomponents.
3937
3938 @item No_Task_Attributes_Package
3939 There are no semantic dependencies on the Ada.Task_Attributes package.
3940
3941 @item No_Task_Hierarchy
3942 [RM D.7] All (non-environment) tasks depend
3943 directly on the environment task of the partition.
3944
3945 @item No_Task_Termination
3946 Tasks which terminate are erroneous.
3947
3948 @item Simple_Barriers
3949 Entry barrier condition expressions shall be either static
3950 boolean expressions or boolean objects which are declared in
3951 the protected type which contains the entry.
3952 @end table
3953
3954 @noindent
3955 This set of configuration pragmas and restrictions correspond to the
3956 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3957 published by the @cite{International Real-Time Ada Workshop}, 1997,
3958 and whose most recent description is available at
3959 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3960
3961 The original definition of the profile was revised at subsequent IRTAW
3962 meetings. It has been included in the ISO
3963 @cite{Guide for the Use of the Ada Programming Language in High
3964 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3965 the next revision of the standard. The formal definition given by
3966 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3967 AI-305) available at
3968 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3969 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3970 respectively.
3971
3972 The above set is a superset of the restrictions provided by pragma
3973 @code{Profile (Restricted)}, it includes six additional restrictions
3974 (@code{Simple_Barriers}, @code{No_Select_Statements},
3975 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3976 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3977 that pragma @code{Profile (Ravenscar)}, like the pragma
3978 @code{Profile (Restricted)},
3979 automatically causes the use of a simplified,
3980 more efficient version of the tasking run-time system.
3981
3982 @node Pragma Profile (Restricted)
3983 @unnumberedsec Pragma Profile (Restricted)
3984 @findex Restricted Run Time
3985 @noindent
3986 Syntax:
3987
3988 @smallexample @c ada
3989 pragma Profile (Restricted);
3990 @end smallexample
3991
3992 @noindent
3993 A configuration pragma that establishes the following set of restrictions:
3994
3995 @itemize @bullet
3996 @item No_Abort_Statements
3997 @item No_Entry_Queue
3998 @item No_Task_Hierarchy
3999 @item No_Task_Allocators
4000 @item No_Dynamic_Priorities
4001 @item No_Terminate_Alternatives
4002 @item No_Dynamic_Attachment
4003 @item No_Protected_Type_Allocators
4004 @item No_Local_Protected_Objects
4005 @item No_Requeue_Statements
4006 @item No_Task_Attributes_Package
4007 @item Max_Asynchronous_Select_Nesting =  0
4008 @item Max_Task_Entries =  0
4009 @item Max_Protected_Entries = 1
4010 @item Max_Select_Alternatives = 0
4011 @end itemize
4012
4013 @noindent
4014 This set of restrictions causes the automatic selection of a simplified
4015 version of the run time that provides improved performance for the
4016 limited set of tasking functionality permitted by this set of restrictions.
4017
4018 @node Pragma Psect_Object
4019 @unnumberedsec Pragma Psect_Object
4020 @findex Psect_Object
4021 @noindent
4022 Syntax:
4023
4024 @smallexample @c ada
4025 pragma Psect_Object (
4026      [Internal =>] LOCAL_NAME,
4027   [, [External =>] EXTERNAL_SYMBOL]
4028   [, [Size     =>] EXTERNAL_SYMBOL]);
4029
4030 EXTERNAL_SYMBOL ::=
4031   IDENTIFIER
4032 | static_string_EXPRESSION
4033 @end smallexample
4034
4035 @noindent
4036 This pragma is identical in effect to pragma @code{Common_Object}.
4037
4038 @node Pragma Pure_Function
4039 @unnumberedsec Pragma Pure_Function
4040 @findex Pure_Function
4041 @noindent
4042 Syntax:
4043
4044 @smallexample @c ada
4045 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4046 @end smallexample
4047
4048 @noindent
4049 This pragma appears in the same declarative part as a function
4050 declaration (or a set of function declarations if more than one
4051 overloaded declaration exists, in which case the pragma applies
4052 to all entities).  It specifies that the function @code{Entity} is
4053 to be considered pure for the purposes of code generation.  This means
4054 that the compiler can assume that there are no side effects, and
4055 in particular that two calls with identical arguments produce the
4056 same result.  It also means that the function can be used in an
4057 address clause.
4058
4059 Note that, quite deliberately, there are no static checks to try
4060 to ensure that this promise is met, so @code{Pure_Function} can be used
4061 with functions that are conceptually pure, even if they do modify
4062 global variables.  For example, a square root function that is
4063 instrumented to count the number of times it is called is still
4064 conceptually pure, and can still be optimized, even though it
4065 modifies a global variable (the count).  Memo functions are another
4066 example (where a table of previous calls is kept and consulted to
4067 avoid re-computation).
4068
4069 @findex Pure
4070 Note: Most functions in a @code{Pure} package are automatically pure, and
4071 there is no need to use pragma @code{Pure_Function} for such functions.  One
4072 exception is any function that has at least one formal of type
4073 @code{System.Address} or a type derived from it.  Such functions are not
4074 considered pure by default, since the compiler assumes that the
4075 @code{Address} parameter may be functioning as a pointer and that the
4076 referenced data may change even if the address value does not.
4077 Similarly, imported functions are not considered to be pure by default,
4078 since there is no way of checking that they are in fact pure.  The use
4079 of pragma @code{Pure_Function} for such a function will override these default
4080 assumption, and cause the compiler to treat a designated subprogram as pure
4081 in these cases.
4082
4083 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4084 applies to the underlying renamed function.  This can be used to
4085 disambiguate cases of overloading where some but not all functions
4086 in a set of overloaded functions are to be designated as pure.
4087
4088 If pragma @code{Pure_Function} is applied to a library level function, the
4089 function is also considered pure from an optimization point of view, but the
4090 unit is not a Pure unit in the categorization sense. So for example, a function
4091 thus marked is free to @code{with} non-pure units.
4092
4093 @node Pragma Restriction_Warnings
4094 @unnumberedsec Pragma Restriction_Warnings
4095 @findex Restriction_Warnings
4096 @noindent
4097 Syntax:
4098
4099 @smallexample @c ada
4100 pragma Restriction_Warnings
4101   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4102 @end smallexample
4103
4104 @noindent
4105 This pragma allows a series of restriction identifiers to be
4106 specified (the list of allowed identifiers is the same as for
4107 pragma @code{Restrictions}). For each of these identifiers
4108 the compiler checks for violations of the restriction, but
4109 generates a warning message rather than an error message
4110 if the restriction is violated.
4111
4112 @node Pragma Shared
4113 @unnumberedsec Pragma Shared
4114 @findex Shared
4115
4116 @noindent
4117 This pragma is provided for compatibility with Ada 83. The syntax and
4118 semantics are identical to pragma Atomic.
4119
4120 @node Pragma Source_File_Name
4121 @unnumberedsec Pragma Source_File_Name
4122 @findex Source_File_Name
4123 @noindent
4124 Syntax:
4125
4126 @smallexample @c ada
4127 pragma Source_File_Name (
4128   [Unit_Name   =>] unit_NAME,
4129   Spec_File_Name =>  STRING_LITERAL);
4130
4131 pragma Source_File_Name (
4132   [Unit_Name   =>] unit_NAME,
4133   Body_File_Name =>  STRING_LITERAL);
4134 @end smallexample
4135
4136 @noindent
4137 Use this to override the normal naming convention.  It is a configuration
4138 pragma, and so has the usual applicability of configuration pragmas
4139 (i.e.@: it applies to either an entire partition, or to all units in a
4140 compilation, or to a single unit, depending on how it is used.
4141 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4142 the second argument is required, and indicates whether this is the file
4143 name for the spec or for the body.
4144
4145 Another form of the @code{Source_File_Name} pragma allows
4146 the specification of patterns defining alternative file naming schemes
4147 to apply to all files.
4148
4149 @smallexample @c ada
4150 pragma Source_File_Name
4151   (Spec_File_Name => STRING_LITERAL
4152    [,Casing => CASING_SPEC]
4153    [,Dot_Replacement => STRING_LITERAL]);
4154
4155 pragma Source_File_Name
4156   (Body_File_Name => STRING_LITERAL
4157    [,Casing => CASING_SPEC]
4158    [,Dot_Replacement => STRING_LITERAL]);
4159
4160 pragma Source_File_Name
4161   (Subunit_File_Name => STRING_LITERAL
4162    [,Casing => CASING_SPEC]
4163    [,Dot_Replacement => STRING_LITERAL]);
4164
4165 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4166 @end smallexample
4167
4168 @noindent
4169 The first argument is a pattern that contains a single asterisk indicating
4170 the point at which the unit name is to be inserted in the pattern string
4171 to form the file name.  The second argument is optional.  If present it
4172 specifies the casing of the unit name in the resulting file name string.
4173 The default is lower case.  Finally the third argument allows for systematic
4174 replacement of any dots in the unit name by the specified string literal.
4175
4176 A pragma Source_File_Name cannot appear after a
4177 @ref{Pragma Source_File_Name_Project}.
4178
4179 For more details on the use of the @code{Source_File_Name} pragma,
4180 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4181 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4182 User's Guide}.
4183
4184 @node Pragma Source_File_Name_Project
4185 @unnumberedsec Pragma Source_File_Name_Project
4186 @findex Source_File_Name_Project
4187 @noindent
4188
4189 This pragma has the same syntax and semantics as pragma Source_File_Name.
4190 It is only allowed as a stand alone configuration pragma.
4191 It cannot appear after a @ref{Pragma Source_File_Name}, and
4192 most importantly, once pragma Source_File_Name_Project appears,
4193 no further Source_File_Name pragmas are allowed.
4194
4195 The intention is that Source_File_Name_Project pragmas are always
4196 generated by the Project Manager in a manner consistent with the naming
4197 specified in a project file, and when naming is controlled in this manner,
4198 it is not permissible to attempt to modify this naming scheme using
4199 Source_File_Name pragmas (which would not be known to the project manager).
4200
4201 @node Pragma Source_Reference
4202 @unnumberedsec Pragma Source_Reference
4203 @findex Source_Reference
4204 @noindent
4205 Syntax:
4206
4207 @smallexample @c ada
4208 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4209 @end smallexample
4210
4211 @noindent
4212 This pragma must appear as the first line of a source file.
4213 @var{integer_literal} is the logical line number of the line following
4214 the pragma line (for use in error messages and debugging
4215 information).  @var{string_literal} is a static string constant that
4216 specifies the file name to be used in error messages and debugging
4217 information.  This is most notably used for the output of @code{gnatchop}
4218 with the @option{-r} switch, to make sure that the original unchopped
4219 source file is the one referred to.
4220
4221 The second argument must be a string literal, it cannot be a static
4222 string expression other than a string literal.  This is because its value
4223 is needed for error messages issued by all phases of the compiler.
4224
4225 @node Pragma Stream_Convert
4226 @unnumberedsec Pragma Stream_Convert
4227 @findex Stream_Convert
4228 @noindent
4229 Syntax:
4230
4231 @smallexample @c ada
4232 pragma Stream_Convert (
4233   [Entity =>] type_LOCAL_NAME,
4234   [Read   =>] function_NAME,
4235   [Write  =>] function_NAME);
4236 @end smallexample
4237
4238 @noindent
4239 This pragma provides an efficient way of providing stream functions for
4240 types defined in packages.  Not only is it simpler to use than declaring
4241 the necessary functions with attribute representation clauses, but more
4242 significantly, it allows the declaration to made in such a way that the
4243 stream packages are not loaded unless they are needed.  The use of
4244 the Stream_Convert pragma adds no overhead at all, unless the stream
4245 attributes are actually used on the designated type.
4246
4247 The first argument specifies the type for which stream functions are
4248 provided.  The second parameter provides a function used to read values
4249 of this type.  It must name a function whose argument type may be any
4250 subtype, and whose returned type must be the type given as the first
4251 argument to the pragma.
4252
4253 The meaning of the @var{Read}
4254 parameter is that if a stream attribute directly
4255 or indirectly specifies reading of the type given as the first parameter,
4256 then a value of the type given as the argument to the Read function is
4257 read from the stream, and then the Read function is used to convert this
4258 to the required target type.
4259
4260 Similarly the @var{Write} parameter specifies how to treat write attributes
4261 that directly or indirectly apply to the type given as the first parameter.
4262 It must have an input parameter of the type specified by the first parameter,
4263 and the return type must be the same as the input type of the Read function.
4264 The effect is to first call the Write function to convert to the given stream
4265 type, and then write the result type to the stream.
4266
4267 The Read and Write functions must not be overloaded subprograms.  If necessary
4268 renamings can be supplied to meet this requirement.
4269 The usage of this attribute is best illustrated by a simple example, taken
4270 from the GNAT implementation of package Ada.Strings.Unbounded:
4271
4272 @smallexample @c ada
4273 function To_Unbounded (S : String)
4274            return Unbounded_String
4275   renames To_Unbounded_String;
4276
4277 pragma Stream_Convert
4278   (Unbounded_String, To_Unbounded, To_String);
4279 @end smallexample
4280
4281 @noindent
4282 The specifications of the referenced functions, as given in the Ada
4283 Reference Manual are:
4284
4285 @smallexample @c ada
4286 function To_Unbounded_String (Source : String)
4287   return Unbounded_String;
4288
4289 function To_String (Source : Unbounded_String)
4290   return String;
4291 @end smallexample
4292
4293 @noindent
4294 The effect is that if the value of an unbounded string is written to a
4295 stream, then the representation of the item in the stream is in the same
4296 format used for @code{Standard.String}, and this same representation is
4297 expected when a value of this type is read from the stream.
4298
4299 @node Pragma Style_Checks
4300 @unnumberedsec Pragma Style_Checks
4301 @findex Style_Checks
4302 @noindent
4303 Syntax:
4304
4305 @smallexample @c ada
4306 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4307                      On | Off [, LOCAL_NAME]);
4308 @end smallexample
4309
4310 @noindent
4311 This pragma is used in conjunction with compiler switches to control the
4312 built in style checking provided by GNAT@.  The compiler switches, if set,
4313 provide an initial setting for the switches, and this pragma may be used
4314 to modify these settings, or the settings may be provided entirely by
4315 the use of the pragma.  This pragma can be used anywhere that a pragma
4316 is legal, including use as a configuration pragma (including use in
4317 the @file{gnat.adc} file).
4318
4319 The form with a string literal specifies which style options are to be
4320 activated.  These are additive, so they apply in addition to any previously
4321 set style check options.  The codes for the options are the same as those
4322 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4323 For example the following two methods can be used to enable
4324 layout checking:
4325
4326 @itemize @bullet
4327 @item
4328 @smallexample @c ada
4329 pragma Style_Checks ("l");
4330 @end smallexample
4331
4332 @item
4333 @smallexample
4334 gcc -c -gnatyl @dots{}
4335 @end smallexample
4336 @end itemize
4337
4338 @noindent
4339 The form ALL_CHECKS activates all standard checks (its use is equivalent
4340 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4341 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4342 @value{EDITION} User's Guide}, for details.
4343
4344 The forms with @code{Off} and @code{On}
4345 can be used to temporarily disable style checks
4346 as shown in the following example:
4347
4348 @smallexample @c ada
4349 @iftex
4350 @leftskip=0cm
4351 @end iftex
4352 pragma Style_Checks ("k"); -- requires keywords in lower case
4353 pragma Style_Checks (Off); -- turn off style checks
4354 NULL;                      -- this will not generate an error message
4355 pragma Style_Checks (On);  -- turn style checks back on
4356 NULL;                      -- this will generate an error message
4357 @end smallexample
4358
4359 @noindent
4360 Finally the two argument form is allowed only if the first argument is
4361 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4362 for the specified entity, as shown in the following example:
4363
4364 @smallexample @c ada
4365 @iftex
4366 @leftskip=0cm
4367 @end iftex
4368 pragma Style_Checks ("r"); -- require consistency of identifier casing
4369 Arg : Integer;
4370 Rf1 : Integer := ARG;      -- incorrect, wrong case
4371 pragma Style_Checks (Off, Arg);
4372 Rf2 : Integer := ARG;      -- OK, no error
4373 @end smallexample
4374
4375 @node Pragma Subtitle
4376 @unnumberedsec Pragma Subtitle
4377 @findex Subtitle
4378 @noindent
4379 Syntax:
4380
4381 @smallexample @c ada
4382 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4383 @end smallexample
4384
4385 @noindent
4386 This pragma is recognized for compatibility with other Ada compilers
4387 but is ignored by GNAT@.
4388
4389 @node Pragma Suppress
4390 @unnumberedsec Pragma Suppress
4391 @findex Suppress
4392 @noindent
4393 Syntax:
4394
4395 @smallexample @c ada
4396 pragma Suppress (Identifier [, [On =>] Name]);
4397 @end smallexample
4398
4399 @noindent
4400 This is a standard pragma, and supports all the check names required in
4401 the RM. It is included here because GNAT recognizes one additional check
4402 name: @code{Alignment_Check} which can be used to suppress alignment checks
4403 on addresses used in address clauses. Such checks can also be suppressed
4404 by suppressing range checks, but the specific use of @code{Alignment_Check}
4405 allows suppression of alignment checks without suppressing other range checks.
4406
4407 @node Pragma Suppress_All
4408 @unnumberedsec Pragma Suppress_All
4409 @findex Suppress_All
4410 @noindent
4411 Syntax:
4412
4413 @smallexample @c ada
4414 pragma Suppress_All;
4415 @end smallexample
4416
4417 @noindent
4418 This pragma can only appear immediately following a compilation
4419 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4420 which it follows.  This pragma is implemented for compatibility with DEC
4421 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4422 configuration pragma is the preferred usage in GNAT@.
4423
4424 @node Pragma Suppress_Exception_Locations
4425 @unnumberedsec Pragma Suppress_Exception_Locations
4426 @findex Suppress_Exception_Locations
4427 @noindent
4428 Syntax:
4429
4430 @smallexample @c ada
4431 pragma Suppress_Exception_Locations;
4432 @end smallexample
4433
4434 @noindent
4435 In normal mode, a raise statement for an exception by default generates
4436 an exception message giving the file name and line number for the location
4437 of the raise. This is useful for debugging and logging purposes, but this
4438 entails extra space for the strings for the messages. The configuration
4439 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4440 generation of these strings, with the result that space is saved, but the
4441 exception message for such raises is null. This configuration pragma may
4442 appear in a global configuration pragma file, or in a specific unit as
4443 usual. It is not required that this pragma be used consistently within
4444 a partition, so it is fine to have some units within a partition compiled
4445 with this pragma and others compiled in normal mode without it.
4446
4447 @node Pragma Suppress_Initialization
4448 @unnumberedsec Pragma Suppress_Initialization
4449 @findex Suppress_Initialization
4450 @cindex Suppressing initialization
4451 @cindex Initialization, suppression of
4452 @noindent
4453 Syntax:
4454
4455 @smallexample @c ada
4456 pragma Suppress_Initialization ([Entity =>] type_Name);
4457 @end smallexample
4458
4459 @noindent
4460 This pragma suppresses any implicit or explicit initialization
4461 associated with the given type name for all variables of this type.
4462
4463 @node Pragma Task_Info
4464 @unnumberedsec Pragma Task_Info
4465 @findex Task_Info
4466 @noindent
4467 Syntax
4468
4469 @smallexample @c ada
4470 pragma Task_Info (EXPRESSION);
4471 @end smallexample
4472
4473 @noindent
4474 This pragma appears within a task definition (like pragma
4475 @code{Priority}) and applies to the task in which it appears.  The
4476 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4477 The @code{Task_Info} pragma provides system dependent control over
4478 aspects of tasking implementation, for example, the ability to map
4479 tasks to specific processors.  For details on the facilities available
4480 for the version of GNAT that you are using, see the documentation
4481 in the spec of package System.Task_Info in the runtime
4482 library.
4483
4484 @node Pragma Task_Name
4485 @unnumberedsec Pragma Task_Name
4486 @findex Task_Name
4487 @noindent
4488 Syntax
4489
4490 @smallexample @c ada
4491 pragma Task_Name (string_EXPRESSION);
4492 @end smallexample
4493
4494 @noindent
4495 This pragma appears within a task definition (like pragma
4496 @code{Priority}) and applies to the task in which it appears.  The
4497 argument must be of type String, and provides a name to be used for
4498 the task instance when the task is created.  Note that this expression
4499 is not required to be static, and in particular, it can contain
4500 references to task discriminants.  This facility can be used to
4501 provide different names for different tasks as they are created,
4502 as illustrated in the example below.
4503
4504 The task name is recorded internally in the run-time structures
4505 and is accessible to tools like the debugger.  In addition the
4506 routine @code{Ada.Task_Identification.Image} will return this
4507 string, with a unique task address appended.
4508
4509 @smallexample @c ada
4510 --  Example of the use of pragma Task_Name
4511
4512 with Ada.Task_Identification;
4513 use Ada.Task_Identification;
4514 with Text_IO; use Text_IO;
4515 procedure t3 is
4516
4517    type Astring is access String;
4518
4519    task type Task_Typ (Name : access String) is
4520       pragma Task_Name (Name.all);
4521    end Task_Typ;
4522
4523    task body Task_Typ is
4524       Nam : constant String := Image (Current_Task);
4525    begin
4526       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4527    end Task_Typ;
4528
4529    type Ptr_Task is access Task_Typ;
4530    Task_Var : Ptr_Task;
4531
4532 begin
4533    Task_Var :=
4534      new Task_Typ (new String'("This is task 1"));
4535    Task_Var :=
4536      new Task_Typ (new String'("This is task 2"));
4537 end;
4538 @end smallexample
4539
4540 @node Pragma Task_Storage
4541 @unnumberedsec Pragma Task_Storage
4542 @findex Task_Storage
4543 Syntax:
4544
4545 @smallexample @c ada
4546 pragma Task_Storage (
4547   [Task_Type =>] LOCAL_NAME,
4548   [Top_Guard =>] static_integer_EXPRESSION);
4549 @end smallexample
4550
4551 @noindent
4552 This pragma specifies the length of the guard area for tasks.  The guard
4553 area is an additional storage area allocated to a task.  A value of zero
4554 means that either no guard area is created or a minimal guard area is
4555 created, depending on the target.  This pragma can appear anywhere a
4556 @code{Storage_Size} attribute definition clause is allowed for a task
4557 type.
4558
4559 @node Pragma Time_Slice
4560 @unnumberedsec Pragma Time_Slice
4561 @findex Time_Slice
4562 @noindent
4563 Syntax:
4564
4565 @smallexample @c ada
4566 pragma Time_Slice (static_duration_EXPRESSION);
4567 @end smallexample
4568
4569 @noindent
4570 For implementations of GNAT on operating systems where it is possible
4571 to supply a time slice value, this pragma may be used for this purpose.
4572 It is ignored if it is used in a system that does not allow this control,
4573 or if it appears in other than the main program unit.
4574 @cindex OpenVMS
4575 Note that the effect of this pragma is identical to the effect of the
4576 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4577
4578 @node Pragma Title
4579 @unnumberedsec Pragma Title
4580 @findex Title
4581 @noindent
4582 Syntax:
4583
4584 @smallexample @c ada
4585 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4586
4587 TITLING_OPTION ::=
4588   [Title    =>] STRING_LITERAL,
4589 | [Subtitle =>] STRING_LITERAL
4590 @end smallexample
4591
4592 @noindent
4593 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4594 pragma used in DEC Ada 83 implementations to provide a title and/or
4595 subtitle for the program listing.  The program listing generated by GNAT
4596 does not have titles or subtitles.
4597
4598 Unlike other pragmas, the full flexibility of named notation is allowed
4599 for this pragma, i.e.@: the parameters may be given in any order if named
4600 notation is used, and named and positional notation can be mixed
4601 following the normal rules for procedure calls in Ada.
4602
4603 @node Pragma Unchecked_Union
4604 @unnumberedsec Pragma Unchecked_Union
4605 @cindex Unions in C
4606 @findex Unchecked_Union
4607 @noindent
4608 Syntax:
4609
4610 @smallexample @c ada
4611 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4612 @end smallexample
4613
4614 @noindent
4615 This pragma is used to specify a representation of a record type that is
4616 equivalent to a C union. It was introduced as a GNAT implementation defined
4617 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4618 pragma, making it language defined, and GNAT fully implements this extended
4619 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4620 details, consult the Ada 2005 Reference Manual, section B.3.3.
4621
4622 @node Pragma Unimplemented_Unit
4623 @unnumberedsec Pragma Unimplemented_Unit
4624 @findex Unimplemented_Unit
4625 @noindent
4626 Syntax:
4627
4628 @smallexample @c ada
4629 pragma Unimplemented_Unit;
4630 @end smallexample
4631
4632 @noindent
4633 If this pragma occurs in a unit that is processed by the compiler, GNAT
4634 aborts with the message @samp{@var{xxx} not implemented}, where
4635 @var{xxx} is the name of the current compilation unit.  This pragma is
4636 intended to allow the compiler to handle unimplemented library units in
4637 a clean manner.
4638
4639 The abort only happens if code is being generated.  Thus you can use
4640 specs of unimplemented packages in syntax or semantic checking mode.
4641
4642 @node Pragma Universal_Aliasing
4643 @unnumberedsec Pragma Universal_Aliasing
4644 @findex Universal_Aliasing
4645 @noindent
4646 Syntax:
4647
4648 @smallexample @c ada
4649 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4650 @end smallexample
4651
4652 @noindent
4653 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4654 declarative part.  The effect is to inhibit strict type-based aliasing
4655 optimization for the given type.  In other words, the effect is as though
4656 access types designating this type were subject to pragma No_Strict_Aliasing.
4657 For a detailed description of the strict aliasing optimization, and the
4658 situations in which it must be suppressed, @xref{Optimization and Strict
4659 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4660
4661 @node Pragma Universal_Data
4662 @unnumberedsec Pragma Universal_Data
4663 @findex Universal_Data
4664 @noindent
4665 Syntax:
4666
4667 @smallexample @c ada
4668 pragma Universal_Data [(library_unit_Name)];
4669 @end smallexample
4670
4671 @noindent
4672 This pragma is supported only for the AAMP target and is ignored for
4673 other targets. The pragma specifies that all library-level objects
4674 (Counter 0 data) associated with the library unit are to be accessed
4675 and updated using universal addressing (24-bit addresses for AAMP5)
4676 rather than the default of 16-bit Data Environment (DENV) addressing.
4677 Use of this pragma will generally result in less efficient code for
4678 references to global data associated with the library unit, but
4679 allows such data to be located anywhere in memory. This pragma is
4680 a library unit pragma, but can also be used as a configuration pragma
4681 (including use in the @file{gnat.adc} file). The functionality
4682 of this pragma is also available by applying the -univ switch on the
4683 compilations of units where universal addressing of the data is desired.
4684
4685 @node Pragma Unmodified
4686 @unnumberedsec Pragma Unmodified
4687 @findex Unmodified
4688 @cindex Warnings, unmodified
4689 @noindent
4690 Syntax:
4691
4692 @smallexample @c ada
4693 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4694 @end smallexample
4695
4696 @noindent
4697 This pragma signals that the assignable entities (variables,
4698 @code{out} parameters, @code{in out} parameters) whose names are listed are
4699 deliberately not assigned in the current source unit. This
4700 suppresses warnings about the
4701 entities being referenced but not assigned, and in addition a warning will be
4702 generated if one of these entities is in fact assigned in the
4703 same unit as the pragma (or in the corresponding body, or one
4704 of its subunits).
4705
4706 This is particularly useful for clearly signaling that a particular
4707 parameter is not modified, even though the spec suggests that it might
4708 be.
4709
4710 @node Pragma Unreferenced
4711 @unnumberedsec Pragma Unreferenced
4712 @findex Unreferenced
4713 @cindex Warnings, unreferenced
4714 @noindent
4715 Syntax:
4716
4717 @smallexample @c ada
4718 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4719 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4720 @end smallexample
4721
4722 @noindent
4723 This pragma signals that the entities whose names are listed are
4724 deliberately not referenced in the current source unit. This
4725 suppresses warnings about the
4726 entities being unreferenced, and in addition a warning will be
4727 generated if one of these entities is in fact referenced in the
4728 same unit as the pragma (or in the corresponding body, or one
4729 of its subunits).
4730
4731 This is particularly useful for clearly signaling that a particular
4732 parameter is not referenced in some particular subprogram implementation
4733 and that this is deliberate. It can also be useful in the case of
4734 objects declared only for their initialization or finalization side
4735 effects.
4736
4737 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4738 current scope, then the entity most recently declared is the one to which
4739 the pragma applies. Note that in the case of accept formals, the pragma
4740 Unreferenced may appear immediately after the keyword @code{do} which
4741 allows the indication of whether or not accept formals are referenced
4742 or not to be given individually for each accept statement.
4743
4744 The left hand side of an assignment does not count as a reference for the
4745 purpose of this pragma. Thus it is fine to assign to an entity for which
4746 pragma Unreferenced is given.
4747
4748 Note that if a warning is desired for all calls to a given subprogram,
4749 regardless of whether they occur in the same unit as the subprogram
4750 declaration, then this pragma should not be used (calls from another
4751 unit would not be flagged); pragma Obsolescent can be used instead
4752 for this purpose, see @xref{Pragma Obsolescent}.
4753
4754 The second form of pragma @code{Unreferenced} is used within a context
4755 clause. In this case the arguments must be unit names of units previously
4756 mentioned in @code{with} clauses (similar to the usage of pragma
4757 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4758 units and unreferenced entities within these units.
4759
4760 @node Pragma Unreferenced_Objects
4761 @unnumberedsec Pragma Unreferenced_Objects
4762 @findex Unreferenced_Objects
4763 @cindex Warnings, unreferenced
4764 @noindent
4765 Syntax:
4766
4767 @smallexample @c ada
4768 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4769 @end smallexample
4770
4771 @noindent
4772 This pragma signals that for the types or subtypes whose names are
4773 listed, objects which are declared with one of these types or subtypes may
4774 not be referenced, and if no references appear, no warnings are given.
4775
4776 This is particularly useful for objects which are declared solely for their
4777 initialization and finalization effect. Such variables are sometimes referred
4778 to as RAII variables (Resource Acquisition Is Initialization). Using this
4779 pragma on the relevant type (most typically a limited controlled type), the
4780 compiler will automatically suppress unwanted warnings about these variables
4781 not being referenced.
4782
4783 @node Pragma Unreserve_All_Interrupts
4784 @unnumberedsec Pragma Unreserve_All_Interrupts
4785 @findex Unreserve_All_Interrupts
4786 @noindent
4787 Syntax:
4788
4789 @smallexample @c ada
4790 pragma Unreserve_All_Interrupts;
4791 @end smallexample
4792
4793 @noindent
4794 Normally certain interrupts are reserved to the implementation.  Any attempt
4795 to attach an interrupt causes Program_Error to be raised, as described in
4796 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4797 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4798 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4799 interrupt execution.
4800
4801 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4802 a program, then all such interrupts are unreserved.  This allows the
4803 program to handle these interrupts, but disables their standard
4804 functions.  For example, if this pragma is used, then pressing
4805 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4806 a program can then handle the @code{SIGINT} interrupt as it chooses.
4807
4808 For a full list of the interrupts handled in a specific implementation,
4809 see the source code for the spec of @code{Ada.Interrupts.Names} in
4810 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4811 list of interrupts recognized for a given target.  The documentation in
4812 this file also specifies what interrupts are affected by the use of
4813 the @code{Unreserve_All_Interrupts} pragma.
4814
4815 For a more general facility for controlling what interrupts can be
4816 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4817 of the @code{Unreserve_All_Interrupts} pragma.
4818
4819 @node Pragma Unsuppress
4820 @unnumberedsec Pragma Unsuppress
4821 @findex Unsuppress
4822 @noindent
4823 Syntax:
4824
4825 @smallexample @c ada
4826 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4827 @end smallexample
4828
4829 @noindent
4830 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4831 there is no corresponding pragma @code{Suppress} in effect, it has no
4832 effect.  The range of the effect is the same as for pragma
4833 @code{Suppress}.  The meaning of the arguments is identical to that used
4834 in pragma @code{Suppress}.
4835
4836 One important application is to ensure that checks are on in cases where
4837 code depends on the checks for its correct functioning, so that the code
4838 will compile correctly even if the compiler switches are set to suppress
4839 checks.
4840
4841 @node Pragma Use_VADS_Size
4842 @unnumberedsec Pragma Use_VADS_Size
4843 @cindex @code{Size}, VADS compatibility
4844 @findex Use_VADS_Size
4845 @noindent
4846 Syntax:
4847
4848 @smallexample @c ada
4849 pragma Use_VADS_Size;
4850 @end smallexample
4851
4852 @noindent
4853 This is a configuration pragma.  In a unit to which it applies, any use
4854 of the 'Size attribute is automatically interpreted as a use of the
4855 'VADS_Size attribute.  Note that this may result in incorrect semantic
4856 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
4857 the handling of existing code which depends on the interpretation of Size
4858 as implemented in the VADS compiler.  See description of the VADS_Size
4859 attribute for further details.
4860
4861 @node Pragma Validity_Checks
4862 @unnumberedsec Pragma Validity_Checks
4863 @findex Validity_Checks
4864 @noindent
4865 Syntax:
4866
4867 @smallexample @c ada
4868 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4869 @end smallexample
4870
4871 @noindent
4872 This pragma is used in conjunction with compiler switches to control the
4873 built-in validity checking provided by GNAT@.  The compiler switches, if set
4874 provide an initial setting for the switches, and this pragma may be used
4875 to modify these settings, or the settings may be provided entirely by
4876 the use of the pragma.  This pragma can be used anywhere that a pragma
4877 is legal, including use as a configuration pragma (including use in
4878 the @file{gnat.adc} file).
4879
4880 The form with a string literal specifies which validity options are to be
4881 activated.  The validity checks are first set to include only the default
4882 reference manual settings, and then a string of letters in the string
4883 specifies the exact set of options required.  The form of this string
4884 is exactly as described for the @option{-gnatVx} compiler switch (see the
4885 GNAT users guide for details).  For example the following two methods
4886 can be used to enable validity checking for mode @code{in} and
4887 @code{in out} subprogram parameters:
4888
4889 @itemize @bullet
4890 @item
4891 @smallexample @c ada
4892 pragma Validity_Checks ("im");
4893 @end smallexample
4894
4895 @item
4896 @smallexample
4897 gcc -c -gnatVim @dots{}
4898 @end smallexample
4899 @end itemize
4900
4901 @noindent
4902 The form ALL_CHECKS activates all standard checks (its use is equivalent
4903 to the use of the @code{gnatva} switch.
4904
4905 The forms with @code{Off} and @code{On}
4906 can be used to temporarily disable validity checks
4907 as shown in the following example:
4908
4909 @smallexample @c ada
4910 @iftex
4911 @leftskip=0cm
4912 @end iftex
4913 pragma Validity_Checks ("c"); -- validity checks for copies
4914 pragma Validity_Checks (Off); -- turn off validity checks
4915 A := B;                       -- B will not be validity checked
4916 pragma Validity_Checks (On);  -- turn validity checks back on
4917 A := C;                       -- C will be validity checked
4918 @end smallexample
4919
4920 @node Pragma Volatile
4921 @unnumberedsec Pragma Volatile
4922 @findex Volatile
4923 @noindent
4924 Syntax:
4925
4926 @smallexample @c ada
4927 pragma Volatile (LOCAL_NAME);
4928 @end smallexample
4929
4930 @noindent
4931 This pragma is defined by the Ada Reference Manual, and the GNAT
4932 implementation is fully conformant with this definition.  The reason it
4933 is mentioned in this section is that a pragma of the same name was supplied
4934 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
4935 implementation of pragma Volatile is upwards compatible with the
4936 implementation in DEC Ada 83.
4937
4938 @node Pragma Warnings
4939 @unnumberedsec Pragma Warnings
4940 @findex Warnings
4941 @noindent
4942 Syntax:
4943
4944 @smallexample @c ada
4945 pragma Warnings (On | Off);
4946 pragma Warnings (On | Off, LOCAL_NAME);
4947 pragma Warnings (static_string_EXPRESSION);
4948 pragma Warnings (On | Off, static_string_EXPRESSION);
4949 @end smallexample
4950
4951 @noindent
4952 Normally warnings are enabled, with the output being controlled by
4953 the command line switch.  Warnings (@code{Off}) turns off generation of
4954 warnings until a Warnings (@code{On}) is encountered or the end of the
4955 current unit.  If generation of warnings is turned off using this
4956 pragma, then no warning messages are output, regardless of the
4957 setting of the command line switches.
4958
4959 The form with a single argument may be used as a configuration pragma.
4960
4961 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4962 the specified entity.  This suppression is effective from the point where
4963 it occurs till the end of the extended scope of the variable (similar to
4964 the scope of @code{Suppress}).
4965
4966 The form with a single static_string_EXPRESSION argument provides more precise
4967 control over which warnings are active. The string is a list of letters
4968 specifying which warnings are to be activated and which deactivated. The
4969 code for these letters is the same as the string used in the command
4970 line switch controlling warnings. The following is a brief summary. For
4971 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
4972 User's Guide}.
4973
4974 @smallexample
4975 a    turn on all optional warnings (except d h l .o)
4976 A    turn off all optional warnings
4977 .a*  turn on warnings for failing assertions
4978 .A   turn off warnings for failing assertions
4979 b    turn on warnings for bad fixed value (not multiple of small)
4980 B*   turn off warnings for bad fixed value (not multiple of small)
4981 c    turn on warnings for constant conditional
4982 C*   turn off warnings for constant conditional
4983 .c   turn on warnings for unrepped components
4984 .C*  turn off warnings for unrepped components
4985 d    turn on warnings for implicit dereference
4986 D*   turn off warnings for implicit dereference
4987 e    treat all warnings as errors
4988 f    turn on warnings for unreferenced formal
4989 F*   turn off warnings for unreferenced formal
4990 g*   turn on warnings for unrecognized pragma
4991 G    turn off warnings for unrecognized pragma
4992 h    turn on warnings for hiding variable
4993 H*   turn off warnings for hiding variable
4994 i*   turn on warnings for implementation unit
4995 I    turn off warnings for implementation unit
4996 j    turn on warnings for obsolescent (annex J) feature
4997 J*   turn off warnings for obsolescent (annex J) feature
4998 k    turn on warnings on constant variable
4999 K*   turn off warnings on constant variable
5000 l    turn on warnings for missing elaboration pragma
5001 L*   turn off warnings for missing elaboration pragma
5002 m    turn on warnings for variable assigned but not read
5003 M*   turn off warnings for variable assigned but not read
5004 n*   normal warning mode (cancels -gnatws/-gnatwe)
5005 o*   turn on warnings for address clause overlay
5006 O    turn off warnings for address clause overlay
5007 .o   turn on warnings for out parameters assigned but not read
5008 .O*  turn off warnings for out parameters assigned but not read
5009 p    turn on warnings for ineffective pragma Inline in frontend
5010 P*   turn off warnings for ineffective pragma Inline in frontend
5011 q*   turn on warnings for questionable missing parentheses
5012 Q    turn off warnings for questionable missing parentheses
5013 r    turn on warnings for redundant construct
5014 R*   turn off warnings for redundant construct
5015 .r   turn on warnings for object renaming function
5016 .R*  turn off warnings for object renaming function
5017 s    suppress all warnings
5018 t    turn on warnings for tracking deleted code
5019 T*   turn off warnings for tracking deleted code
5020 u    turn on warnings for unused entity
5021 U*   turn off warnings for unused entity
5022 v*   turn on warnings for unassigned variable
5023 V    turn off warnings for unassigned variable
5024 w*   turn on warnings for wrong low bound assumption
5025 W    turn off warnings for wrong low bound assumption
5026 x*   turn on warnings for export/import
5027 X    turn off warnings for export/import
5028 .x   turn on warnings for non-local exceptions
5029 .X*  turn off warnings for non-local exceptions
5030 y*   turn on warnings for Ada 2005 incompatibility
5031 Y    turn off warnings for Ada 2005 incompatibility
5032 z*   turn on convention/size/align warnings for unchecked conversion
5033 Z    turn off convention/size/align warnings for unchecked conversion
5034 *    indicates default in above list
5035 @end smallexample
5036
5037 @noindent
5038 The specified warnings will be in effect until the end of the program
5039 or another pragma Warnings is encountered. The effect of the pragma is
5040 cumulative. Initially the set of warnings is the standard default set
5041 as possibly modified by compiler switches. Then each pragma Warning
5042 modifies this set of warnings as specified. This form of the pragma may
5043 also be used as a configuration pragma.
5044
5045 The fourth form, with an On|Off parameter and a string, is used to
5046 control individual messages, based on their text. The string argument
5047 is a pattern that is used to match against the text of individual
5048 warning messages (not including the initial "warnings: " tag).
5049
5050 The pattern may contain asterisks which match zero or more characters in
5051 the message. For example, you can use
5052 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5053 message @code{warning: 960 bits of "a" unused}. No other regular
5054 expression notations are permitted. All characters other than asterisk in
5055 these three specific cases are treated as literal characters in the match.
5056
5057 There are two ways to use this pragma. The OFF form can be used as a
5058 configuration pragma. The effect is to suppress all warnings (if any)
5059 that match the pattern string throughout the compilation.
5060
5061 The second usage is to suppress a warning locally, and in this case, two
5062 pragmas must appear in sequence:
5063
5064 @smallexample @c ada
5065 pragma Warnings (Off, Pattern);
5066 @dots{} code where given warning is to be suppressed
5067 pragma Warnings (On, Pattern);
5068 @end smallexample
5069
5070 @noindent
5071 In this usage, the pattern string must match in the Off and On pragmas,
5072 and at least one matching warning must be suppressed.
5073
5074 @node Pragma Weak_External
5075 @unnumberedsec Pragma Weak_External
5076 @findex Weak_External
5077 @noindent
5078 Syntax:
5079
5080 @smallexample @c ada
5081 pragma Weak_External ([Entity =>] LOCAL_NAME);
5082 @end smallexample
5083
5084 @noindent
5085 @var{LOCAL_NAME} must refer to an object that is declared at the library
5086 level. This pragma specifies that the given entity should be marked as a
5087 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5088 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5089 of a regular symbol, that is to say a symbol that does not have to be
5090 resolved by the linker if used in conjunction with a pragma Import.
5091
5092 When a weak symbol is not resolved by the linker, its address is set to
5093 zero. This is useful in writing interfaces to external modules that may
5094 or may not be linked in the final executable, for example depending on
5095 configuration settings.
5096
5097 If a program references at run time an entity to which this pragma has been
5098 applied, and the corresponding symbol was not resolved at link time, then
5099 the execution of the program is erroneous. It is not erroneous to take the
5100 Address of such an entity, for example to guard potential references,
5101 as shown in the example below.
5102
5103 Some file formats do not support weak symbols so not all target machines
5104 support this pragma.
5105
5106 @smallexample @c ada
5107 --  Example of the use of pragma Weak_External
5108
5109 package External_Module is
5110   key : Integer;
5111   pragma Import (C, key);
5112   pragma Weak_External (key);
5113   function Present return boolean;
5114 end External_Module;
5115
5116 with System; use System;
5117 package body External_Module is
5118   function Present return boolean is
5119   begin
5120     return key'Address /= System.Null_Address;
5121   end Present;
5122 end External_Module;
5123 @end smallexample
5124
5125 @node Pragma Wide_Character_Encoding
5126 @unnumberedsec Pragma Wide_Character_Encoding
5127 @findex Wide_Character_Encoding
5128 @noindent
5129 Syntax:
5130
5131 @smallexample @c ada
5132 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5133 @end smallexample
5134
5135 @noindent
5136 This pragma specifies the wide character encoding to be used in program
5137 source text appearing subsequently. It is a configuration pragma, but may
5138 also be used at any point that a pragma is allowed, and it is permissible
5139 to have more than one such pragma in a file, allowing multiple encodings
5140 to appear within the same file.
5141
5142 The argument can be an identifier or a character literal. In the identifier
5143 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5144 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5145 case it is correspondingly one of the characters @samp{h}, @samp{u},
5146 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5147
5148 Note that when the pragma is used within a file, it affects only the
5149 encoding within that file, and does not affect withed units, specs,
5150 or subunits.
5151
5152 @node Implementation Defined Attributes
5153 @chapter Implementation Defined Attributes
5154 Ada defines (throughout the Ada reference manual,
5155 summarized in Annex K),
5156 a set of attributes that provide useful additional functionality in all
5157 areas of the language.  These language defined attributes are implemented
5158 in GNAT and work as described in the Ada Reference Manual.
5159
5160 In addition, Ada allows implementations to define additional
5161 attributes whose meaning is defined by the implementation.  GNAT provides
5162 a number of these implementation-dependent attributes which can be used
5163 to extend and enhance the functionality of the compiler.  This section of
5164 the GNAT reference manual describes these additional attributes.
5165
5166 Note that any program using these attributes may not be portable to
5167 other compilers (although GNAT implements this set of attributes on all
5168 platforms).  Therefore if portability to other compilers is an important
5169 consideration, you should minimize the use of these attributes.
5170
5171 @menu
5172 * Abort_Signal::
5173 * Address_Size::
5174 * Asm_Input::
5175 * Asm_Output::
5176 * AST_Entry::
5177 * Bit::
5178 * Bit_Position::
5179 * Code_Address::
5180 * Default_Bit_Order::
5181 * Elaborated::
5182 * Elab_Body::
5183 * Elab_Spec::
5184 * Emax::
5185 * Enabled::
5186 * Enum_Rep::
5187 * Enum_Val::
5188 * Epsilon::
5189 * Fixed_Value::
5190 * Has_Access_Values::
5191 * Has_Discriminants::
5192 * Img::
5193 * Integer_Value::
5194 * Invalid_Value::
5195 * Large::
5196 * Machine_Size::
5197 * Mantissa::
5198 * Max_Interrupt_Priority::
5199 * Max_Priority::
5200 * Maximum_Alignment::
5201 * Mechanism_Code::
5202 * Null_Parameter::
5203 * Object_Size::
5204 * Old::
5205 * Passed_By_Reference::
5206 * Pool_Address::
5207 * Range_Length::
5208 * Safe_Emax::
5209 * Safe_Large::
5210 * Small::
5211 * Storage_Unit::
5212 * Stub_Type::
5213 * Target_Name::
5214 * Tick::
5215 * To_Address::
5216 * Type_Class::
5217 * UET_Address::
5218 * Unconstrained_Array::
5219 * Universal_Literal_String::
5220 * Unrestricted_Access::
5221 * VADS_Size::
5222 * Value_Size::
5223 * Wchar_T_Size::
5224 * Word_Size::
5225 @end menu
5226
5227 @node Abort_Signal
5228 @unnumberedsec Abort_Signal
5229 @findex Abort_Signal
5230 @noindent
5231 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5232 prefix) provides the entity for the special exception used to signal
5233 task abort or asynchronous transfer of control.  Normally this attribute
5234 should only be used in the tasking runtime (it is highly peculiar, and
5235 completely outside the normal semantics of Ada, for a user program to
5236 intercept the abort exception).
5237
5238 @node Address_Size
5239 @unnumberedsec Address_Size
5240 @cindex Size of @code{Address}
5241 @findex Address_Size
5242 @noindent
5243 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5244 prefix) is a static constant giving the number of bits in an
5245 @code{Address}. It is the same value as System.Address'Size,
5246 but has the advantage of being static, while a direct
5247 reference to System.Address'Size is non-static because Address
5248 is a private type.
5249
5250 @node Asm_Input
5251 @unnumberedsec Asm_Input
5252 @findex Asm_Input
5253 @noindent
5254 The @code{Asm_Input} attribute denotes a function that takes two
5255 parameters.  The first is a string, the second is an expression of the
5256 type designated by the prefix.  The first (string) argument is required
5257 to be a static expression, and is the constraint for the parameter,
5258 (e.g.@: what kind of register is required).  The second argument is the
5259 value to be used as the input argument.  The possible values for the
5260 constant are the same as those used in the RTL, and are dependent on
5261 the configuration file used to built the GCC back end.
5262 @ref{Machine Code Insertions}
5263
5264 @node Asm_Output
5265 @unnumberedsec Asm_Output
5266 @findex Asm_Output
5267 @noindent
5268 The @code{Asm_Output} attribute denotes a function that takes two
5269 parameters.  The first is a string, the second is the name of a variable
5270 of the type designated by the attribute prefix.  The first (string)
5271 argument is required to be a static expression and designates the
5272 constraint for the parameter (e.g.@: what kind of register is
5273 required).  The second argument is the variable to be updated with the
5274 result.  The possible values for constraint are the same as those used in
5275 the RTL, and are dependent on the configuration file used to build the
5276 GCC back end.  If there are no output operands, then this argument may
5277 either be omitted, or explicitly given as @code{No_Output_Operands}.
5278 @ref{Machine Code Insertions}
5279
5280 @node AST_Entry
5281 @unnumberedsec AST_Entry
5282 @cindex OpenVMS
5283 @findex AST_Entry
5284 @noindent
5285 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5286 the name of an entry, it yields a value of the predefined type AST_Handler
5287 (declared in the predefined package System, as extended by the use of
5288 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5289 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5290 Language Reference Manual}, section 9.12a.
5291
5292 @node Bit
5293 @unnumberedsec Bit
5294 @findex Bit
5295 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5296 offset within the storage unit (byte) that contains the first bit of
5297 storage allocated for the object.  The value of this attribute is of the
5298 type @code{Universal_Integer}, and is always a non-negative number not
5299 exceeding the value of @code{System.Storage_Unit}.
5300
5301 For an object that is a variable or a constant allocated in a register,
5302 the value is zero.  (The use of this attribute does not force the
5303 allocation of a variable to memory).
5304
5305 For an object that is a formal parameter, this attribute applies
5306 to either the matching actual parameter or to a copy of the
5307 matching actual parameter.
5308
5309 For an access object the value is zero.  Note that
5310 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5311 designated object.  Similarly for a record component
5312 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5313 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5314 are subject to index checks.
5315
5316 This attribute is designed to be compatible with the DEC Ada 83 definition
5317 and implementation of the @code{Bit} attribute.
5318
5319 @node Bit_Position
5320 @unnumberedsec Bit_Position
5321 @findex Bit_Position
5322 @noindent
5323 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5324 of the fields of the record type, yields the bit
5325 offset within the record contains the first bit of
5326 storage allocated for the object.  The value of this attribute is of the
5327 type @code{Universal_Integer}.  The value depends only on the field
5328 @var{C} and is independent of the alignment of
5329 the containing record @var{R}.
5330
5331 @node Code_Address
5332 @unnumberedsec Code_Address
5333 @findex Code_Address
5334 @cindex Subprogram address
5335 @cindex Address of subprogram code
5336 @noindent
5337 The @code{'Address}
5338 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5339 intended effect seems to be to provide
5340 an address value which can be used to call the subprogram by means of
5341 an address clause as in the following example:
5342
5343 @smallexample @c ada
5344 procedure K is @dots{}
5345
5346 procedure L;
5347 for L'Address use K'Address;
5348 pragma Import (Ada, L);
5349 @end smallexample
5350
5351 @noindent
5352 A call to @code{L} is then expected to result in a call to @code{K}@.
5353 In Ada 83, where there were no access-to-subprogram values, this was
5354 a common work-around for getting the effect of an indirect call.
5355 GNAT implements the above use of @code{Address} and the technique
5356 illustrated by the example code works correctly.
5357
5358 However, for some purposes, it is useful to have the address of the start
5359 of the generated code for the subprogram.  On some architectures, this is
5360 not necessarily the same as the @code{Address} value described above.
5361 For example, the @code{Address} value may reference a subprogram
5362 descriptor rather than the subprogram itself.
5363
5364 The @code{'Code_Address} attribute, which can only be applied to
5365 subprogram entities, always returns the address of the start of the
5366 generated code of the specified subprogram, which may or may not be
5367 the same value as is returned by the corresponding @code{'Address}
5368 attribute.
5369
5370 @node Default_Bit_Order
5371 @unnumberedsec Default_Bit_Order
5372 @cindex Big endian
5373 @cindex Little endian
5374 @findex Default_Bit_Order
5375 @noindent
5376 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5377 permissible prefix), provides the value @code{System.Default_Bit_Order}
5378 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5379 @code{Low_Order_First}).  This is used to construct the definition of
5380 @code{Default_Bit_Order} in package @code{System}.
5381
5382 @node Elaborated
5383 @unnumberedsec Elaborated
5384 @findex Elaborated
5385 @noindent
5386 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5387 value is a Boolean which indicates whether or not the given unit has been
5388 elaborated.  This attribute is primarily intended for internal use by the
5389 generated code for dynamic elaboration checking, but it can also be used
5390 in user programs.  The value will always be True once elaboration of all
5391 units has been completed.  An exception is for units which need no
5392 elaboration, the value is always False for such units.
5393
5394 @node Elab_Body
5395 @unnumberedsec Elab_Body
5396 @findex Elab_Body
5397 @noindent
5398 This attribute can only be applied to a program unit name.  It returns
5399 the entity for the corresponding elaboration procedure for elaborating
5400 the body of the referenced unit.  This is used in the main generated
5401 elaboration procedure by the binder and is not normally used in any
5402 other context.  However, there may be specialized situations in which it
5403 is useful to be able to call this elaboration procedure from Ada code,
5404 e.g.@: if it is necessary to do selective re-elaboration to fix some
5405 error.
5406
5407 @node Elab_Spec
5408 @unnumberedsec Elab_Spec
5409 @findex Elab_Spec
5410 @noindent
5411 This attribute can only be applied to a program unit name.  It returns
5412 the entity for the corresponding elaboration procedure for elaborating
5413 the spec of the referenced unit.  This is used in the main
5414 generated elaboration procedure by the binder and is not normally used
5415 in any other context.  However, there may be specialized situations in
5416 which it is useful to be able to call this elaboration procedure from
5417 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5418 some error.
5419
5420 @node Emax
5421 @unnumberedsec Emax
5422 @cindex Ada 83 attributes
5423 @findex Emax
5424 @noindent
5425 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5426 the Ada 83 reference manual for an exact description of the semantics of
5427 this attribute.
5428
5429 @node Enabled
5430 @unnumberedsec Enabled
5431 @findex Enabled
5432 @noindent
5433 The @code{Enabled} attribute allows an application program to check at compile
5434 time to see if the designated check is currently enabled. The prefix is a
5435 simple identifier, referencing any predefined check name (other than
5436 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5437 no argument is given for the attribute, the check is for the general state
5438 of the check, if an argument is given, then it is an entity name, and the
5439 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5440 given naming the entity (if not, then the argument is ignored).
5441
5442 Note that instantiations inherit the check status at the point of the
5443 instantiation, so a useful idiom is to have a library package that
5444 introduces a check name with @code{pragma Check_Name}, and then contains
5445 generic packages or subprograms which use the @code{Enabled} attribute
5446 to see if the check is enabled. A user of this package can then issue
5447 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5448 the package or subprogram, controlling whether the check will be present.
5449
5450 @node Enum_Rep
5451 @unnumberedsec Enum_Rep
5452 @cindex Representation of enums
5453 @findex Enum_Rep
5454 @noindent
5455 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5456 function with the following spec:
5457
5458 @smallexample @c ada
5459 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5460   return @i{Universal_Integer};
5461 @end smallexample
5462
5463 @noindent
5464 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5465 enumeration type or to a non-overloaded enumeration
5466 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5467 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5468 enumeration literal or object.
5469
5470 The function returns the representation value for the given enumeration
5471 value.  This will be equal to value of the @code{Pos} attribute in the
5472 absence of an enumeration representation clause.  This is a static
5473 attribute (i.e.@: the result is static if the argument is static).
5474
5475 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5476 in which case it simply returns the integer value.  The reason for this
5477 is to allow it to be used for @code{(<>)} discrete formal arguments in
5478 a generic unit that can be instantiated with either enumeration types
5479 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5480 type whose upper bound exceeds the upper bound of the largest signed
5481 integer type, and the argument is a variable, so that the universal
5482 integer calculation is done at run time, then the call to @code{Enum_Rep}
5483 may raise @code{Constraint_Error}.
5484
5485 @node Enum_Val
5486 @unnumberedsec Enum_Val
5487 @cindex Representation of enums
5488 @findex Enum_Val
5489 @noindent
5490 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5491 function with the following spec:
5492
5493 @smallexample @c ada
5494 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5495   return @var{S}'Base};
5496 @end smallexample
5497
5498 @noindent
5499 The function returns the enumeration value whose representation matches the
5500 argument, or raises Constraint_Error if no enumeration literal of the type
5501 has the matching value.
5502 This will be equal to value of the @code{Val} attribute in the
5503 absence of an enumeration representation clause.  This is a static
5504 attribute (i.e.@: the result is static if the argument is static).
5505
5506 @node Epsilon
5507 @unnumberedsec Epsilon
5508 @cindex Ada 83 attributes
5509 @findex Epsilon
5510 @noindent
5511 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5512 the Ada 83 reference manual for an exact description of the semantics of
5513 this attribute.
5514
5515 @node Fixed_Value
5516 @unnumberedsec Fixed_Value
5517 @findex Fixed_Value
5518 @noindent
5519 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5520 function with the following specification:
5521
5522 @smallexample @c ada
5523 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5524   return @var{S};
5525 @end smallexample
5526
5527 @noindent
5528 The value returned is the fixed-point value @var{V} such that
5529
5530 @smallexample @c ada
5531 @var{V} = Arg * @var{S}'Small
5532 @end smallexample
5533
5534 @noindent
5535 The effect is thus similar to first converting the argument to the
5536 integer type used to represent @var{S}, and then doing an unchecked
5537 conversion to the fixed-point type.  The difference is
5538 that there are full range checks, to ensure that the result is in range.
5539 This attribute is primarily intended for use in implementation of the
5540 input-output functions for fixed-point values.
5541
5542 @node Has_Access_Values
5543 @unnumberedsec Has_Access_Values
5544 @cindex Access values, testing for
5545 @findex Has_Access_Values
5546 @noindent
5547 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5548 is a Boolean value which is True if the is an access type, or is a composite
5549 type with a component (at any nesting depth) that is an access type, and is
5550 False otherwise.
5551 The intended use of this attribute is in conjunction with generic
5552 definitions.  If the attribute is applied to a generic private type, it
5553 indicates whether or not the corresponding actual type has access values.
5554
5555 @node Has_Discriminants
5556 @unnumberedsec Has_Discriminants
5557 @cindex Discriminants, testing for
5558 @findex Has_Discriminants
5559 @noindent
5560 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5561 is a Boolean value which is True if the type has discriminants, and False
5562 otherwise.  The intended use of this attribute is in conjunction with generic
5563 definitions.  If the attribute is applied to a generic private type, it
5564 indicates whether or not the corresponding actual type has discriminants.
5565
5566 @node Img
5567 @unnumberedsec Img
5568 @findex Img
5569 @noindent
5570 The @code{Img} attribute differs from @code{Image} in that it may be
5571 applied to objects as well as types, in which case it gives the
5572 @code{Image} for the subtype of the object.  This is convenient for
5573 debugging:
5574
5575 @smallexample @c ada
5576 Put_Line ("X = " & X'Img);
5577 @end smallexample
5578
5579 @noindent
5580 has the same meaning as the more verbose:
5581
5582 @smallexample @c ada
5583 Put_Line ("X = " & @var{T}'Image (X));
5584 @end smallexample
5585
5586 @noindent
5587 where @var{T} is the (sub)type of the object @code{X}.
5588
5589 @node Integer_Value
5590 @unnumberedsec Integer_Value
5591 @findex Integer_Value
5592 @noindent
5593 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5594 function with the following spec:
5595
5596 @smallexample @c ada
5597 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5598   return @var{S};
5599 @end smallexample
5600
5601 @noindent
5602 The value returned is the integer value @var{V}, such that
5603
5604 @smallexample @c ada
5605 Arg = @var{V} * @var{T}'Small
5606 @end smallexample
5607
5608 @noindent
5609 where @var{T} is the type of @code{Arg}.
5610 The effect is thus similar to first doing an unchecked conversion from
5611 the fixed-point type to its corresponding implementation type, and then
5612 converting the result to the target integer type.  The difference is
5613 that there are full range checks, to ensure that the result is in range.
5614 This attribute is primarily intended for use in implementation of the
5615 standard input-output functions for fixed-point values.
5616
5617 @node Invalid_Value
5618 @unnumberedsec Invalid_Value
5619 @findex Invalid_Value
5620 @noindent
5621 For every scalar type S, S'Invalid_Value returns an undefined value of the
5622 type. If possible this value is an invalid representation for the type. The
5623 value returned is identical to the value used to initialize an otherwise
5624 uninitialized value of the type if pragma Initialize_Scalars is used,
5625 including the ability to modify the value with the binder -Sxx flag and
5626 relevant environment variables at run time.
5627
5628 @node Large
5629 @unnumberedsec Large
5630 @cindex Ada 83 attributes
5631 @findex Large
5632 @noindent
5633 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5634 the Ada 83 reference manual for an exact description of the semantics of
5635 this attribute.
5636
5637 @node Machine_Size
5638 @unnumberedsec Machine_Size
5639 @findex Machine_Size
5640 @noindent
5641 This attribute is identical to the @code{Object_Size} attribute.  It is
5642 provided for compatibility with the DEC Ada 83 attribute of this name.
5643
5644 @node Mantissa
5645 @unnumberedsec Mantissa
5646 @cindex Ada 83 attributes
5647 @findex Mantissa
5648 @noindent
5649 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5650 the Ada 83 reference manual for an exact description of the semantics of
5651 this attribute.
5652
5653 @node Max_Interrupt_Priority
5654 @unnumberedsec Max_Interrupt_Priority
5655 @cindex Interrupt priority, maximum
5656 @findex Max_Interrupt_Priority
5657 @noindent
5658 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5659 permissible prefix), provides the same value as
5660 @code{System.Max_Interrupt_Priority}.
5661
5662 @node Max_Priority
5663 @unnumberedsec Max_Priority
5664 @cindex Priority, maximum
5665 @findex Max_Priority
5666 @noindent
5667 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5668 prefix) provides the same value as @code{System.Max_Priority}.
5669
5670 @node Maximum_Alignment
5671 @unnumberedsec Maximum_Alignment
5672 @cindex Alignment, maximum
5673 @findex Maximum_Alignment
5674 @noindent
5675 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5676 permissible prefix) provides the maximum useful alignment value for the
5677 target.  This is a static value that can be used to specify the alignment
5678 for an object, guaranteeing that it is properly aligned in all
5679 cases.
5680
5681 @node Mechanism_Code
5682 @unnumberedsec Mechanism_Code
5683 @cindex Return values, passing mechanism
5684 @cindex Parameters, passing mechanism
5685 @findex Mechanism_Code
5686 @noindent
5687 @code{@var{function}'Mechanism_Code} yields an integer code for the
5688 mechanism used for the result of function, and
5689 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5690 used for formal parameter number @var{n} (a static integer value with 1
5691 meaning the first parameter) of @var{subprogram}.  The code returned is:
5692
5693 @table @asis
5694 @item 1
5695 by copy (value)
5696 @item 2
5697 by reference
5698 @item 3
5699 by descriptor (default descriptor class)
5700 @item 4
5701 by descriptor (UBS: unaligned bit string)
5702 @item 5
5703 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5704 @item 6
5705 by descriptor (UBA: unaligned bit array)
5706 @item 7
5707 by descriptor (S: string, also scalar access type parameter)
5708 @item 8
5709 by descriptor (SB: string with arbitrary bounds)
5710 @item 9
5711 by descriptor (A: contiguous array)
5712 @item 10
5713 by descriptor (NCA: non-contiguous array)
5714 @end table
5715
5716 @noindent
5717 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5718 @cindex OpenVMS
5719
5720 @node Null_Parameter
5721 @unnumberedsec Null_Parameter
5722 @cindex Zero address, passing
5723 @findex Null_Parameter
5724 @noindent
5725 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5726 type or subtype @var{T} allocated at machine address zero.  The attribute
5727 is allowed only as the default expression of a formal parameter, or as
5728 an actual expression of a subprogram call.  In either case, the
5729 subprogram must be imported.
5730
5731 The identity of the object is represented by the address zero in the
5732 argument list, independent of the passing mechanism (explicit or
5733 default).
5734
5735 This capability is needed to specify that a zero address should be
5736 passed for a record or other composite object passed by reference.
5737 There is no way of indicating this without the @code{Null_Parameter}
5738 attribute.
5739
5740 @node Object_Size
5741 @unnumberedsec Object_Size
5742 @cindex Size, used for objects
5743 @findex Object_Size
5744 @noindent
5745 The size of an object is not necessarily the same as the size of the type
5746 of an object.  This is because by default object sizes are increased to be
5747 a multiple of the alignment of the object.  For example,
5748 @code{Natural'Size} is
5749 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5750 Similarly, a record containing an integer and a character:
5751
5752 @smallexample @c ada
5753 type Rec is record
5754    I : Integer;
5755    C : Character;
5756 end record;
5757 @end smallexample
5758
5759 @noindent
5760 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5761 alignment will be 4, because of the
5762 integer field, and so the default size of record objects for this type
5763 will be 64 (8 bytes).
5764
5765 @node Old
5766 @unnumberedsec Old
5767 @cindex Capturing Old values
5768 @cindex Postconditions
5769 @noindent
5770 The attribute Prefix'Old can be used within a
5771 subprogram to refer to the value of the prefix on entry. So for
5772 example if you have an argument of a record type X called Arg1,
5773 you can refer to Arg1.Field'Old which yields the value of
5774 Arg1.Field on entry. The implementation simply involves generating
5775 an object declaration which captures the value on entry. Any
5776 prefix is allowed except one of a limited type (since limited
5777 types cannot be copied to capture their values) or a local variable
5778 (since it does not exist at subprogram entry time).
5779
5780 The following example shows the use of 'Old to implement
5781 a test of a postcondition:
5782
5783 @smallexample @c ada
5784 with Old_Pkg;
5785 procedure Old is
5786 begin
5787    Old_Pkg.Incr;
5788 end Old;
5789
5790 package Old_Pkg is
5791    procedure Incr;
5792 end Old_Pkg;
5793
5794 package body Old_Pkg is
5795    Count : Natural := 0;
5796
5797    procedure Incr is
5798    begin
5799       ... code manipulating the value of Count
5800
5801       pragma Assert (Count = Count'Old + 1);
5802    end Incr;
5803 end Old_Pkg;
5804 @end smallexample
5805
5806 @noindent
5807 Note that it is allowed to apply 'Old to a constant entity, but this will
5808 result in a warning, since the old and new values will always be the same.
5809
5810 @node Passed_By_Reference
5811 @unnumberedsec Passed_By_Reference
5812 @cindex Parameters, when passed by reference
5813 @findex Passed_By_Reference
5814 @noindent
5815 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5816 a value of type @code{Boolean} value that is @code{True} if the type is
5817 normally passed by reference and @code{False} if the type is normally
5818 passed by copy in calls.  For scalar types, the result is always @code{False}
5819 and is static.  For non-scalar types, the result is non-static.
5820
5821 @node Pool_Address
5822 @unnumberedsec Pool_Address
5823 @cindex Parameters, when passed by reference
5824 @findex Pool_Address
5825 @noindent
5826 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5827 of X within its storage pool. This is the same as
5828 @code{@var{X}'Address}, except that for an unconstrained array whose
5829 bounds are allocated just before the first component,
5830 @code{@var{X}'Pool_Address} returns the address of those bounds,
5831 whereas @code{@var{X}'Address} returns the address of the first
5832 component.
5833
5834 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5835 the object is allocated'', which could be a user-defined storage pool,
5836 the global heap, on the stack, or in a static memory area. For an
5837 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5838 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5839
5840 @node Range_Length
5841 @unnumberedsec Range_Length
5842 @findex Range_Length
5843 @noindent
5844 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5845 the number of values represented by the subtype (zero for a null
5846 range).  The result is static for static subtypes.  @code{Range_Length}
5847 applied to the index subtype of a one dimensional array always gives the
5848 same result as @code{Range} applied to the array itself.
5849
5850 @node Safe_Emax
5851 @unnumberedsec Safe_Emax
5852 @cindex Ada 83 attributes
5853 @findex Safe_Emax
5854 @noindent
5855 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5856 the Ada 83 reference manual for an exact description of the semantics of
5857 this attribute.
5858
5859 @node Safe_Large
5860 @unnumberedsec Safe_Large
5861 @cindex Ada 83 attributes
5862 @findex Safe_Large
5863 @noindent
5864 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5865 the Ada 83 reference manual for an exact description of the semantics of
5866 this attribute.
5867
5868 @node Small
5869 @unnumberedsec Small
5870 @cindex Ada 83 attributes
5871 @findex Small
5872 @noindent
5873 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5874 fixed-point types.
5875 GNAT also allows this attribute to be applied to floating-point types
5876 for compatibility with Ada 83.  See
5877 the Ada 83 reference manual for an exact description of the semantics of
5878 this attribute when applied to floating-point types.
5879
5880 @node Storage_Unit
5881 @unnumberedsec Storage_Unit
5882 @findex Storage_Unit
5883 @noindent
5884 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5885 prefix) provides the same value as @code{System.Storage_Unit}.
5886
5887 @node Stub_Type
5888 @unnumberedsec Stub_Type
5889 @findex Stub_Type
5890 @noindent
5891 The GNAT implementation of remote access-to-classwide types is
5892 organized as described in AARM section E.4 (20.t): a value of an RACW type
5893 (designating a remote object) is represented as a normal access
5894 value, pointing to a "stub" object which in turn contains the
5895 necessary information to contact the designated remote object. A
5896 call on any dispatching operation of such a stub object does the
5897 remote call, if necessary, using the information in the stub object
5898 to locate the target partition, etc.
5899
5900 For a prefix @code{T} that denotes a remote access-to-classwide type,
5901 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5902
5903 By construction, the layout of @code{T'Stub_Type} is identical to that of
5904 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5905 unit @code{System.Partition_Interface}. Use of this attribute will create
5906 an implicit dependency on this unit.
5907
5908 @node Target_Name
5909 @unnumberedsec Target_Name
5910 @findex Target_Name
5911 @noindent
5912 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5913 prefix) provides a static string value that identifies the target
5914 for the current compilation. For GCC implementations, this is the
5915 standard gcc target name without the terminating slash (for
5916 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5917
5918 @node Tick
5919 @unnumberedsec Tick
5920 @findex Tick
5921 @noindent
5922 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5923 provides the same value as @code{System.Tick},
5924
5925 @node To_Address
5926 @unnumberedsec To_Address
5927 @findex To_Address
5928 @noindent
5929 The @code{System'To_Address}
5930 (@code{System} is the only permissible prefix)
5931 denotes a function identical to
5932 @code{System.Storage_Elements.To_Address} except that
5933 it is a static attribute.  This means that if its argument is
5934 a static expression, then the result of the attribute is a
5935 static expression.  The result is that such an expression can be
5936 used in contexts (e.g.@: preelaborable packages) which require a
5937 static expression and where the function call could not be used
5938 (since the function call is always non-static, even if its
5939 argument is static).
5940
5941 @node Type_Class
5942 @unnumberedsec Type_Class
5943 @findex Type_Class
5944 @noindent
5945 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5946 the value of the type class for the full type of @var{type}.  If
5947 @var{type} is a generic formal type, the value is the value for the
5948 corresponding actual subtype.  The value of this attribute is of type
5949 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5950
5951 @smallexample @c ada
5952   type Type_Class is
5953     (Type_Class_Enumeration,
5954      Type_Class_Integer,
5955      Type_Class_Fixed_Point,
5956      Type_Class_Floating_Point,
5957      Type_Class_Array,
5958      Type_Class_Record,
5959      Type_Class_Access,
5960      Type_Class_Task,
5961      Type_Class_Address);
5962 @end smallexample
5963
5964 @noindent
5965 Protected types yield the value @code{Type_Class_Task}, which thus
5966 applies to all concurrent types.  This attribute is designed to
5967 be compatible with the DEC Ada 83 attribute of the same name.
5968
5969 @node UET_Address
5970 @unnumberedsec UET_Address
5971 @findex UET_Address
5972 @noindent
5973 The @code{UET_Address} attribute can only be used for a prefix which
5974 denotes a library package.  It yields the address of the unit exception
5975 table when zero cost exception handling is used.  This attribute is
5976 intended only for use within the GNAT implementation.  See the unit
5977 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5978 for details on how this attribute is used in the implementation.
5979
5980 @node Unconstrained_Array
5981 @unnumberedsec Unconstrained_Array
5982 @findex Unconstrained_Array
5983 @noindent
5984 The @code{Unconstrained_Array} attribute can be used with a prefix that
5985 denotes any type or subtype. It is a static attribute that yields
5986 @code{True} if the prefix designates an unconstrained array,
5987 and @code{False} otherwise. In a generic instance, the result is
5988 still static, and yields the result of applying this test to the
5989 generic actual.
5990
5991 @node Universal_Literal_String
5992 @unnumberedsec Universal_Literal_String
5993 @cindex Named numbers, representation of
5994 @findex Universal_Literal_String
5995 @noindent
5996 The prefix of @code{Universal_Literal_String} must be a named
5997 number.  The static result is the string consisting of the characters of
5998 the number as defined in the original source.  This allows the user
5999 program to access the actual text of named numbers without intermediate
6000 conversions and without the need to enclose the strings in quotes (which
6001 would preclude their use as numbers).  This is used internally for the
6002 construction of values of the floating-point attributes from the file
6003 @file{ttypef.ads}, but may also be used by user programs.
6004
6005 For example, the following program prints the first 50 digits of pi:
6006
6007 @smallexample @c ada
6008 with Text_IO; use Text_IO;
6009 with Ada.Numerics;
6010 procedure Pi is
6011 begin
6012    Put (Ada.Numerics.Pi'Universal_Literal_String);
6013 end;
6014 @end smallexample
6015
6016 @node Unrestricted_Access
6017 @unnumberedsec Unrestricted_Access
6018 @cindex @code{Access}, unrestricted
6019 @findex Unrestricted_Access
6020 @noindent
6021 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6022 except that all accessibility and aliased view checks are omitted.  This
6023 is a user-beware attribute.  It is similar to
6024 @code{Address}, for which it is a desirable replacement where the value
6025 desired is an access type.  In other words, its effect is identical to
6026 first applying the @code{Address} attribute and then doing an unchecked
6027 conversion to a desired access type.  In GNAT, but not necessarily in
6028 other implementations, the use of static chains for inner level
6029 subprograms means that @code{Unrestricted_Access} applied to a
6030 subprogram yields a value that can be called as long as the subprogram
6031 is in scope (normal Ada accessibility rules restrict this usage).
6032
6033 It is possible to use @code{Unrestricted_Access} for any type, but care
6034 must be exercised if it is used to create pointers to unconstrained
6035 objects. In this case, the resulting pointer has the same scope as the
6036 context of the attribute, and may not be returned to some enclosing
6037 scope. For instance, a function cannot use @code{Unrestricted_Access}
6038 to create a unconstrained pointer and then return that value to the
6039 caller.
6040
6041 @node VADS_Size
6042 @unnumberedsec VADS_Size
6043 @cindex @code{Size}, VADS compatibility
6044 @findex VADS_Size
6045 @noindent
6046 The @code{'VADS_Size} attribute is intended to make it easier to port
6047 legacy code which relies on the semantics of @code{'Size} as implemented
6048 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6049 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6050 to a predefined or other primitive type with no Size clause yields the
6051 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6052 typical machines).  In addition @code{'VADS_Size} applied to an object
6053 gives the result that would be obtained by applying the attribute to
6054 the corresponding type.
6055
6056 @node Value_Size
6057 @unnumberedsec Value_Size
6058 @cindex @code{Size}, setting for not-first subtype
6059 @findex Value_Size
6060 @code{@var{type}'Value_Size} is the number of bits required to represent
6061 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6062 but, unlike @code{Size}, may be set for non-first subtypes.
6063
6064 @node Wchar_T_Size
6065 @unnumberedsec Wchar_T_Size
6066 @findex Wchar_T_Size
6067 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6068 prefix) provides the size in bits of the C @code{wchar_t} type
6069 primarily for constructing the definition of this type in
6070 package @code{Interfaces.C}.
6071
6072 @node Word_Size
6073 @unnumberedsec Word_Size
6074 @findex Word_Size
6075 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6076 prefix) provides the value @code{System.Word_Size}.
6077
6078 @c ------------------------
6079 @node Implementation Advice
6080 @chapter Implementation Advice
6081 @noindent
6082 The main text of the Ada Reference Manual describes the required
6083 behavior of all Ada compilers, and the GNAT compiler conforms to
6084 these requirements.
6085
6086 In addition, there are sections throughout the Ada Reference Manual headed
6087 by the phrase ``Implementation advice''.  These sections are not normative,
6088 i.e., they do not specify requirements that all compilers must
6089 follow.  Rather they provide advice on generally desirable behavior.  You
6090 may wonder why they are not requirements.  The most typical answer is
6091 that they describe behavior that seems generally desirable, but cannot
6092 be provided on all systems, or which may be undesirable on some systems.
6093
6094 As far as practical, GNAT follows the implementation advice sections in
6095 the Ada Reference Manual.  This chapter contains a table giving the
6096 reference manual section number, paragraph number and several keywords
6097 for each advice.  Each entry consists of the text of the advice followed
6098 by the GNAT interpretation of this advice.  Most often, this simply says
6099 ``followed'', which means that GNAT follows the advice.  However, in a
6100 number of cases, GNAT deliberately deviates from this advice, in which
6101 case the text describes what GNAT does and why.
6102
6103 @cindex Error detection
6104 @unnumberedsec 1.1.3(20): Error Detection
6105 @sp 1
6106 @cartouche
6107 If an implementation detects the use of an unsupported Specialized Needs
6108 Annex feature at run time, it should raise @code{Program_Error} if
6109 feasible.
6110 @end cartouche
6111 Not relevant.  All specialized needs annex features are either supported,
6112 or diagnosed at compile time.
6113
6114 @cindex Child Units
6115 @unnumberedsec 1.1.3(31): Child Units
6116 @sp 1
6117 @cartouche
6118 If an implementation wishes to provide implementation-defined
6119 extensions to the functionality of a language-defined library unit, it
6120 should normally do so by adding children to the library unit.
6121 @end cartouche
6122 Followed.
6123
6124 @cindex Bounded errors
6125 @unnumberedsec 1.1.5(12): Bounded Errors
6126 @sp 1
6127 @cartouche
6128 If an implementation detects a bounded error or erroneous
6129 execution, it should raise @code{Program_Error}.
6130 @end cartouche
6131 Followed in all cases in which the implementation detects a bounded
6132 error or erroneous execution.  Not all such situations are detected at
6133 runtime.
6134
6135 @cindex Pragmas
6136 @unnumberedsec 2.8(16): Pragmas
6137 @sp 1
6138 @cartouche
6139 Normally, implementation-defined pragmas should have no semantic effect
6140 for error-free programs; that is, if the implementation-defined pragmas
6141 are removed from a working program, the program should still be legal,
6142 and should still have the same semantics.
6143 @end cartouche
6144 The following implementation defined pragmas are exceptions to this
6145 rule:
6146
6147 @table @code
6148 @item Abort_Defer
6149 Affects semantics
6150 @item Ada_83
6151 Affects legality
6152 @item Assert
6153 Affects semantics
6154 @item CPP_Class
6155 Affects semantics
6156 @item CPP_Constructor
6157 Affects semantics
6158 @item Debug
6159 Affects semantics
6160 @item Interface_Name
6161 Affects semantics
6162 @item Machine_Attribute
6163 Affects semantics
6164 @item Unimplemented_Unit
6165 Affects legality
6166 @item Unchecked_Union
6167 Affects semantics
6168 @end table
6169
6170 @noindent
6171 In each of the above cases, it is essential to the purpose of the pragma
6172 that this advice not be followed.  For details see the separate section
6173 on implementation defined pragmas.
6174
6175 @unnumberedsec 2.8(17-19): Pragmas
6176 @sp 1
6177 @cartouche
6178 Normally, an implementation should not define pragmas that can
6179 make an illegal program legal, except as follows:
6180 @end cartouche
6181 @sp 1
6182 @cartouche
6183 A pragma used to complete a declaration, such as a pragma @code{Import};
6184 @end cartouche
6185 @sp 1
6186 @cartouche
6187 A pragma used to configure the environment by adding, removing, or
6188 replacing @code{library_items}.
6189 @end cartouche
6190 See response to paragraph 16 of this same section.
6191
6192 @cindex Character Sets
6193 @cindex Alternative Character Sets
6194 @unnumberedsec 3.5.2(5): Alternative Character Sets
6195 @sp 1
6196 @cartouche
6197 If an implementation supports a mode with alternative interpretations
6198 for @code{Character} and @code{Wide_Character}, the set of graphic
6199 characters of @code{Character} should nevertheless remain a proper
6200 subset of the set of graphic characters of @code{Wide_Character}.  Any
6201 character set ``localizations'' should be reflected in the results of
6202 the subprograms defined in the language-defined package
6203 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6204 an alternative interpretation of @code{Character}, the implementation should
6205 also support a corresponding change in what is a legal
6206 @code{identifier_letter}.
6207 @end cartouche
6208 Not all wide character modes follow this advice, in particular the JIS
6209 and IEC modes reflect standard usage in Japan, and in these encoding,
6210 the upper half of the Latin-1 set is not part of the wide-character
6211 subset, since the most significant bit is used for wide character
6212 encoding.  However, this only applies to the external forms.  Internally
6213 there is no such restriction.
6214
6215 @cindex Integer types
6216 @unnumberedsec 3.5.4(28): Integer Types
6217
6218 @sp 1
6219 @cartouche
6220 An implementation should support @code{Long_Integer} in addition to
6221 @code{Integer} if the target machine supports 32-bit (or longer)
6222 arithmetic.  No other named integer subtypes are recommended for package
6223 @code{Standard}.  Instead, appropriate named integer subtypes should be
6224 provided in the library package @code{Interfaces} (see B.2).
6225 @end cartouche
6226 @code{Long_Integer} is supported.  Other standard integer types are supported
6227 so this advice is not fully followed.  These types
6228 are supported for convenient interface to C, and so that all hardware
6229 types of the machine are easily available.
6230 @unnumberedsec 3.5.4(29): Integer Types
6231
6232 @sp 1
6233 @cartouche
6234 An implementation for a two's complement machine should support
6235 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6236 implementation should support a non-binary modules up to @code{Integer'Last}.
6237 @end cartouche
6238 Followed.
6239
6240 @cindex Enumeration values
6241 @unnumberedsec 3.5.5(8): Enumeration Values
6242 @sp 1
6243 @cartouche
6244 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6245 subtype, if the value of the operand does not correspond to the internal
6246 code for any enumeration literal of its type (perhaps due to an
6247 un-initialized variable), then the implementation should raise
6248 @code{Program_Error}.  This is particularly important for enumeration
6249 types with noncontiguous internal codes specified by an
6250 enumeration_representation_clause.
6251 @end cartouche
6252 Followed.
6253
6254 @cindex Float types
6255 @unnumberedsec 3.5.7(17): Float Types
6256 @sp 1
6257 @cartouche
6258 An implementation should support @code{Long_Float} in addition to
6259 @code{Float} if the target machine supports 11 or more digits of
6260 precision.  No other named floating point subtypes are recommended for
6261 package @code{Standard}.  Instead, appropriate named floating point subtypes
6262 should be provided in the library package @code{Interfaces} (see B.2).
6263 @end cartouche
6264 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6265 former provides improved compatibility with other implementations
6266 supporting this type.  The latter corresponds to the highest precision
6267 floating-point type supported by the hardware.  On most machines, this
6268 will be the same as @code{Long_Float}, but on some machines, it will
6269 correspond to the IEEE extended form.  The notable case is all ia32
6270 (x86) implementations, where @code{Long_Long_Float} corresponds to
6271 the 80-bit extended precision format supported in hardware on this
6272 processor.  Note that the 128-bit format on SPARC is not supported,
6273 since this is a software rather than a hardware format.
6274
6275 @cindex Multidimensional arrays
6276 @cindex Arrays, multidimensional
6277 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6278 @sp 1
6279 @cartouche
6280 An implementation should normally represent multidimensional arrays in
6281 row-major order, consistent with the notation used for multidimensional
6282 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6283 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6284 column-major order should be used instead (see B.5, ``Interfacing with
6285 Fortran'').
6286 @end cartouche
6287 Followed.
6288
6289 @findex Duration'Small
6290 @unnumberedsec 9.6(30-31): Duration'Small
6291 @sp 1
6292 @cartouche
6293 Whenever possible in an implementation, the value of @code{Duration'Small}
6294 should be no greater than 100 microseconds.
6295 @end cartouche
6296 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6297
6298 @sp 1
6299 @cartouche
6300 The time base for @code{delay_relative_statements} should be monotonic;
6301 it need not be the same time base as used for @code{Calendar.Clock}.
6302 @end cartouche
6303 Followed.
6304
6305 @unnumberedsec 10.2.1(12): Consistent Representation
6306 @sp 1
6307 @cartouche
6308 In an implementation, a type declared in a pre-elaborated package should
6309 have the same representation in every elaboration of a given version of
6310 the package, whether the elaborations occur in distinct executions of
6311 the same program, or in executions of distinct programs or partitions
6312 that include the given version.
6313 @end cartouche
6314 Followed, except in the case of tagged types.  Tagged types involve
6315 implicit pointers to a local copy of a dispatch table, and these pointers
6316 have representations which thus depend on a particular elaboration of the
6317 package.  It is not easy to see how it would be possible to follow this
6318 advice without severely impacting efficiency of execution.
6319
6320 @cindex Exception information
6321 @unnumberedsec 11.4.1(19): Exception Information
6322 @sp 1
6323 @cartouche
6324 @code{Exception_Message} by default and @code{Exception_Information}
6325 should produce information useful for
6326 debugging.  @code{Exception_Message} should be short, about one
6327 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6328 should not include the
6329 @code{Exception_Name}.  @code{Exception_Information} should include both
6330 the @code{Exception_Name} and the @code{Exception_Message}.
6331 @end cartouche
6332 Followed.  For each exception that doesn't have a specified
6333 @code{Exception_Message}, the compiler generates one containing the location
6334 of the raise statement.  This location has the form ``file:line'', where
6335 file is the short file name (without path information) and line is the line
6336 number in the file.  Note that in the case of the Zero Cost Exception
6337 mechanism, these messages become redundant with the Exception_Information that
6338 contains a full backtrace of the calling sequence, so they are disabled.
6339 To disable explicitly the generation of the source location message, use the
6340 Pragma @code{Discard_Names}.
6341
6342 @cindex Suppression of checks
6343 @cindex Checks, suppression of
6344 @unnumberedsec 11.5(28): Suppression of Checks
6345 @sp 1
6346 @cartouche
6347 The implementation should minimize the code executed for checks that
6348 have been suppressed.
6349 @end cartouche
6350 Followed.
6351
6352 @cindex Representation clauses
6353 @unnumberedsec 13.1 (21-24): Representation Clauses
6354 @sp 1
6355 @cartouche
6356 The recommended level of support for all representation items is
6357 qualified as follows:
6358 @end cartouche
6359 @sp 1
6360 @cartouche
6361 An implementation need not support representation items containing
6362 non-static expressions, except that an implementation should support a
6363 representation item for a given entity if each non-static expression in
6364 the representation item is a name that statically denotes a constant
6365 declared before the entity.
6366 @end cartouche
6367 Followed.  In fact, GNAT goes beyond the recommended level of support
6368 by allowing nonstatic expressions in some representation clauses even
6369 without the need to declare constants initialized with the values of
6370 such expressions.
6371 For example:
6372
6373 @smallexample @c ada
6374   X : Integer;
6375   Y : Float;
6376   for Y'Address use X'Address;>>
6377 @end smallexample
6378
6379
6380 @sp 1
6381 @cartouche
6382 An implementation need not support a specification for the @code{Size}
6383 for a given composite subtype, nor the size or storage place for an
6384 object (including a component) of a given composite subtype, unless the
6385 constraints on the subtype and its composite subcomponents (if any) are
6386 all static constraints.
6387 @end cartouche
6388 Followed.  Size Clauses are not permitted on non-static components, as
6389 described above.
6390
6391 @sp 1
6392 @cartouche
6393 An aliased component, or a component whose type is by-reference, should
6394 always be allocated at an addressable location.
6395 @end cartouche
6396 Followed.
6397
6398 @cindex Packed types
6399 @unnumberedsec 13.2(6-8): Packed Types
6400 @sp 1
6401 @cartouche
6402 If a type is packed, then the implementation should try to minimize
6403 storage allocated to objects of the type, possibly at the expense of
6404 speed of accessing components, subject to reasonable complexity in
6405 addressing calculations.
6406 @end cartouche
6407 @sp 1
6408 @cartouche
6409 The recommended level of support pragma @code{Pack} is:
6410
6411 For a packed record type, the components should be packed as tightly as
6412 possible subject to the Sizes of the component subtypes, and subject to
6413 any @code{record_representation_clause} that applies to the type; the
6414 implementation may, but need not, reorder components or cross aligned
6415 word boundaries to improve the packing.  A component whose @code{Size} is
6416 greater than the word size may be allocated an integral number of words.
6417 @end cartouche
6418 Followed.  Tight packing of arrays is supported for all component sizes
6419 up to 64-bits. If the array component size is 1 (that is to say, if
6420 the component is a boolean type or an enumeration type with two values)
6421 then values of the type are implicitly initialized to zero. This
6422 happens both for objects of the packed type, and for objects that have a
6423 subcomponent of the packed type.
6424
6425 @sp 1
6426 @cartouche
6427 An implementation should support Address clauses for imported
6428 subprograms.
6429 @end cartouche
6430 Followed.
6431 @cindex @code{Address} clauses
6432 @unnumberedsec 13.3(14-19): Address Clauses
6433
6434 @sp 1
6435 @cartouche
6436 For an array @var{X}, @code{@var{X}'Address} should point at the first
6437 component of the array, and not at the array bounds.
6438 @end cartouche
6439 Followed.
6440
6441 @sp 1
6442 @cartouche
6443 The recommended level of support for the @code{Address} attribute is:
6444
6445 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6446 object that is aliased or of a by-reference type, or is an entity whose
6447 @code{Address} has been specified.
6448 @end cartouche
6449 Followed.  A valid address will be produced even if none of those
6450 conditions have been met.  If necessary, the object is forced into
6451 memory to ensure the address is valid.
6452
6453 @sp 1
6454 @cartouche
6455 An implementation should support @code{Address} clauses for imported
6456 subprograms.
6457 @end cartouche
6458 Followed.
6459
6460 @sp 1
6461 @cartouche
6462 Objects (including subcomponents) that are aliased or of a by-reference
6463 type should be allocated on storage element boundaries.
6464 @end cartouche
6465 Followed.
6466
6467 @sp 1
6468 @cartouche
6469 If the @code{Address} of an object is specified, or it is imported or exported,
6470 then the implementation should not perform optimizations based on
6471 assumptions of no aliases.
6472 @end cartouche
6473 Followed.
6474
6475 @cindex @code{Alignment} clauses
6476 @unnumberedsec 13.3(29-35): Alignment Clauses
6477 @sp 1
6478 @cartouche
6479 The recommended level of support for the @code{Alignment} attribute for
6480 subtypes is:
6481
6482 An implementation should support specified Alignments that are factors
6483 and multiples of the number of storage elements per word, subject to the
6484 following:
6485 @end cartouche
6486 Followed.
6487
6488 @sp 1
6489 @cartouche
6490 An implementation need not support specified @code{Alignment}s for
6491 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6492 loaded and stored by available machine instructions.
6493 @end cartouche
6494 Followed.
6495
6496 @sp 1
6497 @cartouche
6498 An implementation need not support specified @code{Alignment}s that are
6499 greater than the maximum @code{Alignment} the implementation ever returns by
6500 default.
6501 @end cartouche
6502 Followed.
6503
6504 @sp 1
6505 @cartouche
6506 The recommended level of support for the @code{Alignment} attribute for
6507 objects is:
6508
6509 Same as above, for subtypes, but in addition:
6510 @end cartouche
6511 Followed.
6512
6513 @sp 1
6514 @cartouche
6515 For stand-alone library-level objects of statically constrained
6516 subtypes, the implementation should support all @code{Alignment}s
6517 supported by the target linker.  For example, page alignment is likely to
6518 be supported for such objects, but not for subtypes.
6519 @end cartouche
6520 Followed.
6521
6522 @cindex @code{Size} clauses
6523 @unnumberedsec 13.3(42-43): Size Clauses
6524 @sp 1
6525 @cartouche
6526 The recommended level of support for the @code{Size} attribute of
6527 objects is:
6528
6529 A @code{Size} clause should be supported for an object if the specified
6530 @code{Size} is at least as large as its subtype's @code{Size}, and
6531 corresponds to a size in storage elements that is a multiple of the
6532 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6533 @end cartouche
6534 Followed.
6535
6536 @unnumberedsec 13.3(50-56): Size Clauses
6537 @sp 1
6538 @cartouche
6539 If the @code{Size} of a subtype is specified, and allows for efficient
6540 independent addressability (see 9.10) on the target architecture, then
6541 the @code{Size} of the following objects of the subtype should equal the
6542 @code{Size} of the subtype:
6543
6544 Aliased objects (including components).
6545 @end cartouche
6546 Followed.
6547
6548 @sp 1
6549 @cartouche
6550 @code{Size} clause on a composite subtype should not affect the
6551 internal layout of components.
6552 @end cartouche
6553 Followed. But note that this can be overridden by use of the implementation
6554 pragma Implicit_Packing in the case of packed arrays.
6555
6556 @sp 1
6557 @cartouche
6558 The recommended level of support for the @code{Size} attribute of subtypes is:
6559 @end cartouche
6560 @sp 1
6561 @cartouche
6562 The @code{Size} (if not specified) of a static discrete or fixed point
6563 subtype should be the number of bits needed to represent each value
6564 belonging to the subtype using an unbiased representation, leaving space
6565 for a sign bit only if the subtype contains negative values.  If such a
6566 subtype is a first subtype, then an implementation should support a
6567 specified @code{Size} for it that reflects this representation.
6568 @end cartouche
6569 Followed.
6570
6571 @sp 1
6572 @cartouche
6573 For a subtype implemented with levels of indirection, the @code{Size}
6574 should include the size of the pointers, but not the size of what they
6575 point at.
6576 @end cartouche
6577 Followed.
6578
6579 @cindex @code{Component_Size} clauses
6580 @unnumberedsec 13.3(71-73): Component Size Clauses
6581 @sp 1
6582 @cartouche
6583 The recommended level of support for the @code{Component_Size}
6584 attribute is:
6585 @end cartouche
6586 @sp 1
6587 @cartouche
6588 An implementation need not support specified @code{Component_Sizes} that are
6589 less than the @code{Size} of the component subtype.
6590 @end cartouche
6591 Followed.
6592
6593 @sp 1
6594 @cartouche
6595 An implementation should support specified @code{Component_Size}s that
6596 are factors and multiples of the word size.  For such
6597 @code{Component_Size}s, the array should contain no gaps between
6598 components.  For other @code{Component_Size}s (if supported), the array
6599 should contain no gaps between components when packing is also
6600 specified; the implementation should forbid this combination in cases
6601 where it cannot support a no-gaps representation.
6602 @end cartouche
6603 Followed.
6604
6605 @cindex Enumeration representation clauses
6606 @cindex Representation clauses, enumeration
6607 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6608 @sp 1
6609 @cartouche
6610 The recommended level of support for enumeration representation clauses
6611 is:
6612
6613 An implementation need not support enumeration representation clauses
6614 for boolean types, but should at minimum support the internal codes in
6615 the range @code{System.Min_Int.System.Max_Int}.
6616 @end cartouche
6617 Followed.
6618
6619 @cindex Record representation clauses
6620 @cindex Representation clauses, records
6621 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6622 @sp 1
6623 @cartouche
6624 The recommended level of support for
6625 @*@code{record_representation_clauses} is:
6626
6627 An implementation should support storage places that can be extracted
6628 with a load, mask, shift sequence of machine code, and set with a load,
6629 shift, mask, store sequence, given the available machine instructions
6630 and run-time model.
6631 @end cartouche
6632 Followed.
6633
6634 @sp 1
6635 @cartouche
6636 A storage place should be supported if its size is equal to the
6637 @code{Size} of the component subtype, and it starts and ends on a
6638 boundary that obeys the @code{Alignment} of the component subtype.
6639 @end cartouche
6640 Followed.
6641
6642 @sp 1
6643 @cartouche
6644 If the default bit ordering applies to the declaration of a given type,
6645 then for a component whose subtype's @code{Size} is less than the word
6646 size, any storage place that does not cross an aligned word boundary
6647 should be supported.
6648 @end cartouche
6649 Followed.
6650
6651 @sp 1
6652 @cartouche
6653 An implementation may reserve a storage place for the tag field of a
6654 tagged type, and disallow other components from overlapping that place.
6655 @end cartouche
6656 Followed.  The storage place for the tag field is the beginning of the tagged
6657 record, and its size is Address'Size.  GNAT will reject an explicit component
6658 clause for the tag field.
6659
6660 @sp 1
6661 @cartouche
6662 An implementation need not support a @code{component_clause} for a
6663 component of an extension part if the storage place is not after the
6664 storage places of all components of the parent type, whether or not
6665 those storage places had been specified.
6666 @end cartouche
6667 Followed.  The above advice on record representation clauses is followed,
6668 and all mentioned features are implemented.
6669
6670 @cindex Storage place attributes
6671 @unnumberedsec 13.5.2(5): Storage Place Attributes
6672 @sp 1
6673 @cartouche
6674 If a component is represented using some form of pointer (such as an
6675 offset) to the actual data of the component, and this data is contiguous
6676 with the rest of the object, then the storage place attributes should
6677 reflect the place of the actual data, not the pointer.  If a component is
6678 allocated discontinuously from the rest of the object, then a warning
6679 should be generated upon reference to one of its storage place
6680 attributes.
6681 @end cartouche
6682 Followed.  There are no such components in GNAT@.
6683
6684 @cindex Bit ordering
6685 @unnumberedsec 13.5.3(7-8): Bit Ordering
6686 @sp 1
6687 @cartouche
6688 The recommended level of support for the non-default bit ordering is:
6689 @end cartouche
6690 @sp 1
6691 @cartouche
6692 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6693 should support the non-default bit ordering in addition to the default
6694 bit ordering.
6695 @end cartouche
6696 Followed.  Word size does not equal storage size in this implementation.
6697 Thus non-default bit ordering is not supported.
6698
6699 @cindex @code{Address}, as private type
6700 @unnumberedsec 13.7(37): Address as Private
6701 @sp 1
6702 @cartouche
6703 @code{Address} should be of a private type.
6704 @end cartouche
6705 Followed.
6706
6707 @cindex Operations, on @code{Address}
6708 @cindex @code{Address}, operations of
6709 @unnumberedsec 13.7.1(16): Address Operations
6710 @sp 1
6711 @cartouche
6712 Operations in @code{System} and its children should reflect the target
6713 environment semantics as closely as is reasonable.  For example, on most
6714 machines, it makes sense for address arithmetic to ``wrap around''.
6715 Operations that do not make sense should raise @code{Program_Error}.
6716 @end cartouche
6717 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6718 operation raises @code{Program_Error}, since all operations make sense.
6719
6720 @cindex Unchecked conversion
6721 @unnumberedsec 13.9(14-17): Unchecked Conversion
6722 @sp 1
6723 @cartouche
6724 The @code{Size} of an array object should not include its bounds; hence,
6725 the bounds should not be part of the converted data.
6726 @end cartouche
6727 Followed.
6728
6729 @sp 1
6730 @cartouche
6731 The implementation should not generate unnecessary run-time checks to
6732 ensure that the representation of @var{S} is a representation of the
6733 target type.  It should take advantage of the permission to return by
6734 reference when possible.  Restrictions on unchecked conversions should be
6735 avoided unless required by the target environment.
6736 @end cartouche
6737 Followed.  There are no restrictions on unchecked conversion.  A warning is
6738 generated if the source and target types do not have the same size since
6739 the semantics in this case may be target dependent.
6740
6741 @sp 1
6742 @cartouche
6743 The recommended level of support for unchecked conversions is:
6744 @end cartouche
6745 @sp 1
6746 @cartouche
6747 Unchecked conversions should be supported and should be reversible in
6748 the cases where this clause defines the result.  To enable meaningful use
6749 of unchecked conversion, a contiguous representation should be used for
6750 elementary subtypes, for statically constrained array subtypes whose
6751 component subtype is one of the subtypes described in this paragraph,
6752 and for record subtypes without discriminants whose component subtypes
6753 are described in this paragraph.
6754 @end cartouche
6755 Followed.
6756
6757 @cindex Heap usage, implicit
6758 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6759 @sp 1
6760 @cartouche
6761 An implementation should document any cases in which it dynamically
6762 allocates heap storage for a purpose other than the evaluation of an
6763 allocator.
6764 @end cartouche
6765 Followed, the only other points at which heap storage is dynamically
6766 allocated are as follows:
6767
6768 @itemize @bullet
6769 @item
6770 At initial elaboration time, to allocate dynamically sized global
6771 objects.
6772
6773 @item
6774 To allocate space for a task when a task is created.
6775
6776 @item
6777 To extend the secondary stack dynamically when needed.  The secondary
6778 stack is used for returning variable length results.
6779 @end itemize
6780
6781 @sp 1
6782 @cartouche
6783 A default (implementation-provided) storage pool for an
6784 access-to-constant type should not have overhead to support deallocation of
6785 individual objects.
6786 @end cartouche
6787 Followed.
6788
6789 @sp 1
6790 @cartouche
6791 A storage pool for an anonymous access type should be created at the
6792 point of an allocator for the type, and be reclaimed when the designated
6793 object becomes inaccessible.
6794 @end cartouche
6795 Followed.
6796
6797 @cindex Unchecked deallocation
6798 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6799 @sp 1
6800 @cartouche
6801 For a standard storage pool, @code{Free} should actually reclaim the
6802 storage.
6803 @end cartouche
6804 Followed.
6805
6806 @cindex Stream oriented attributes
6807 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6808 @sp 1
6809 @cartouche
6810 If a stream element is the same size as a storage element, then the
6811 normal in-memory representation should be used by @code{Read} and
6812 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6813 should use the smallest number of stream elements needed to represent
6814 all values in the base range of the scalar type.
6815 @end cartouche
6816
6817 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6818 which specifies using the size of the first subtype.
6819 However, such an implementation is based on direct binary
6820 representations and is therefore target- and endianness-dependent.
6821 To address this issue, GNAT also supplies an alternate implementation
6822 of the stream attributes @code{Read} and @code{Write},
6823 which uses the target-independent XDR standard representation
6824 for scalar types.
6825 @cindex XDR representation
6826 @cindex @code{Read} attribute
6827 @cindex @code{Write} attribute
6828 @cindex Stream oriented attributes
6829 The XDR implementation is provided as an alternative body of the
6830 @code{System.Stream_Attributes} package, in the file
6831 @file{s-strxdr.adb} in the GNAT library.
6832 There is no @file{s-strxdr.ads} file.
6833 In order to install the XDR implementation, do the following:
6834 @enumerate
6835 @item Replace the default implementation of the
6836 @code{System.Stream_Attributes} package with the XDR implementation.
6837 For example on a Unix platform issue the commands:
6838 @smallexample
6839 $ mv s-stratt.adb s-strold.adb
6840 $ mv s-strxdr.adb s-stratt.adb
6841 @end smallexample
6842
6843 @item
6844 Rebuild the GNAT run-time library as documented in
6845 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6846 @end enumerate
6847
6848 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6849 @sp 1
6850 @cartouche
6851 If an implementation provides additional named predefined integer types,
6852 then the names should end with @samp{Integer} as in
6853 @samp{Long_Integer}.  If an implementation provides additional named
6854 predefined floating point types, then the names should end with
6855 @samp{Float} as in @samp{Long_Float}.
6856 @end cartouche
6857 Followed.
6858
6859 @findex Ada.Characters.Handling
6860 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6861 @sp 1
6862 @cartouche
6863 If an implementation provides a localized definition of @code{Character}
6864 or @code{Wide_Character}, then the effects of the subprograms in
6865 @code{Characters.Handling} should reflect the localizations.  See also
6866 3.5.2.
6867 @end cartouche
6868 Followed.  GNAT provides no such localized definitions.
6869
6870 @cindex Bounded-length strings
6871 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6872 @sp 1
6873 @cartouche
6874 Bounded string objects should not be implemented by implicit pointers
6875 and dynamic allocation.
6876 @end cartouche
6877 Followed.  No implicit pointers or dynamic allocation are used.
6878
6879 @cindex Random number generation
6880 @unnumberedsec A.5.2(46-47): Random Number Generation
6881 @sp 1
6882 @cartouche
6883 Any storage associated with an object of type @code{Generator} should be
6884 reclaimed on exit from the scope of the object.
6885 @end cartouche
6886 Followed.
6887
6888 @sp 1
6889 @cartouche
6890 If the generator period is sufficiently long in relation to the number
6891 of distinct initiator values, then each possible value of
6892 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6893 random numbers that does not, in a practical sense, overlap the sequence
6894 initiated by any other value.  If this is not possible, then the mapping
6895 between initiator values and generator states should be a rapidly
6896 varying function of the initiator value.
6897 @end cartouche
6898 Followed.  The generator period is sufficiently long for the first
6899 condition here to hold true.
6900
6901 @findex Get_Immediate
6902 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6903 @sp 1
6904 @cartouche
6905 The @code{Get_Immediate} procedures should be implemented with
6906 unbuffered input.  For a device such as a keyboard, input should be
6907 @dfn{available} if a key has already been typed, whereas for a disk
6908 file, input should always be available except at end of file.  For a file
6909 associated with a keyboard-like device, any line-editing features of the
6910 underlying operating system should be disabled during the execution of
6911 @code{Get_Immediate}.
6912 @end cartouche
6913 Followed on all targets except VxWorks. For VxWorks, there is no way to
6914 provide this functionality that does not result in the input buffer being
6915 flushed before the @code{Get_Immediate} call. A special unit
6916 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6917 this functionality.
6918
6919 @findex Export
6920 @unnumberedsec B.1(39-41): Pragma @code{Export}
6921 @sp 1
6922 @cartouche
6923 If an implementation supports pragma @code{Export} to a given language,
6924 then it should also allow the main subprogram to be written in that
6925 language.  It should support some mechanism for invoking the elaboration
6926 of the Ada library units included in the system, and for invoking the
6927 finalization of the environment task.  On typical systems, the
6928 recommended mechanism is to provide two subprograms whose link names are
6929 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6930 elaboration code for library units.  @code{adafinal} should contain the
6931 finalization code.  These subprograms should have no effect the second
6932 and subsequent time they are called.
6933 @end cartouche
6934 Followed.
6935
6936 @sp 1
6937 @cartouche
6938 Automatic elaboration of pre-elaborated packages should be
6939 provided when pragma @code{Export} is supported.
6940 @end cartouche
6941 Followed when the main program is in Ada.  If the main program is in a
6942 foreign language, then
6943 @code{adainit} must be called to elaborate pre-elaborated
6944 packages.
6945
6946 @sp 1
6947 @cartouche
6948 For each supported convention @var{L} other than @code{Intrinsic}, an
6949 implementation should support @code{Import} and @code{Export} pragmas
6950 for objects of @var{L}-compatible types and for subprograms, and pragma
6951 @code{Convention} for @var{L}-eligible types and for subprograms,
6952 presuming the other language has corresponding features.  Pragma
6953 @code{Convention} need not be supported for scalar types.
6954 @end cartouche
6955 Followed.
6956
6957 @cindex Package @code{Interfaces}
6958 @findex Interfaces
6959 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6960 @sp 1
6961 @cartouche
6962 For each implementation-defined convention identifier, there should be a
6963 child package of package Interfaces with the corresponding name.  This
6964 package should contain any declarations that would be useful for
6965 interfacing to the language (implementation) represented by the
6966 convention.  Any declarations useful for interfacing to any language on
6967 the given hardware architecture should be provided directly in
6968 @code{Interfaces}.
6969 @end cartouche
6970 Followed. An additional package not defined
6971 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6972 for interfacing to C++.
6973
6974 @sp 1
6975 @cartouche
6976 An implementation supporting an interface to C, COBOL, or Fortran should
6977 provide the corresponding package or packages described in the following
6978 clauses.
6979 @end cartouche
6980 Followed.  GNAT provides all the packages described in this section.
6981
6982 @cindex C, interfacing with
6983 @unnumberedsec B.3(63-71): Interfacing with C
6984 @sp 1
6985 @cartouche
6986 An implementation should support the following interface correspondences
6987 between Ada and C@.
6988 @end cartouche
6989 Followed.
6990
6991 @sp 1
6992 @cartouche
6993 An Ada procedure corresponds to a void-returning C function.
6994 @end cartouche
6995 Followed.
6996
6997 @sp 1
6998 @cartouche
6999 An Ada function corresponds to a non-void C function.
7000 @end cartouche
7001 Followed.
7002
7003 @sp 1
7004 @cartouche
7005 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7006 function.
7007 @end cartouche
7008 Followed.
7009
7010 @sp 1
7011 @cartouche
7012 An Ada @code{in} parameter of an access-to-object type with designated
7013 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7014 where @var{t} is the C type corresponding to the Ada type @var{T}.
7015 @end cartouche
7016 Followed.
7017
7018 @sp 1
7019 @cartouche
7020 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7021 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7022 argument to a C function, where @var{t} is the C type corresponding to
7023 the Ada type @var{T}.  In the case of an elementary @code{out} or
7024 @code{in out} parameter, a pointer to a temporary copy is used to
7025 preserve by-copy semantics.
7026 @end cartouche
7027 Followed.
7028
7029 @sp 1
7030 @cartouche
7031 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7032 @code{@var{t}*} argument to a C function, where @var{t} is the C
7033 structure corresponding to the Ada type @var{T}.
7034 @end cartouche
7035 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7036 pragma, or Convention, or by explicitly specifying the mechanism for a given
7037 call using an extended import or export pragma.
7038
7039 @sp 1
7040 @cartouche
7041 An Ada parameter of an array type with component type @var{T}, of any
7042 mode, is passed as a @code{@var{t}*} argument to a C function, where
7043 @var{t} is the C type corresponding to the Ada type @var{T}.
7044 @end cartouche
7045 Followed.
7046
7047 @sp 1
7048 @cartouche
7049 An Ada parameter of an access-to-subprogram type is passed as a pointer
7050 to a C function whose prototype corresponds to the designated
7051 subprogram's specification.
7052 @end cartouche
7053 Followed.
7054
7055 @cindex COBOL, interfacing with
7056 @unnumberedsec B.4(95-98): Interfacing with COBOL
7057 @sp 1
7058 @cartouche
7059 An Ada implementation should support the following interface
7060 correspondences between Ada and COBOL@.
7061 @end cartouche
7062 Followed.
7063
7064 @sp 1
7065 @cartouche
7066 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7067 the COBOL type corresponding to @var{T}.
7068 @end cartouche
7069 Followed.
7070
7071 @sp 1
7072 @cartouche
7073 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7074 the corresponding COBOL type.
7075 @end cartouche
7076 Followed.
7077
7078 @sp 1
7079 @cartouche
7080 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7081 COBOL type corresponding to the Ada parameter type; for scalars, a local
7082 copy is used if necessary to ensure by-copy semantics.
7083 @end cartouche
7084 Followed.
7085
7086 @cindex Fortran, interfacing with
7087 @unnumberedsec B.5(22-26): Interfacing with Fortran
7088 @sp 1
7089 @cartouche
7090 An Ada implementation should support the following interface
7091 correspondences between Ada and Fortran:
7092 @end cartouche
7093 Followed.
7094
7095 @sp 1
7096 @cartouche
7097 An Ada procedure corresponds to a Fortran subroutine.
7098 @end cartouche
7099 Followed.
7100
7101 @sp 1
7102 @cartouche
7103 An Ada function corresponds to a Fortran function.
7104 @end cartouche
7105 Followed.
7106
7107 @sp 1
7108 @cartouche
7109 An Ada parameter of an elementary, array, or record type @var{T} is
7110 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7111 the Fortran type corresponding to the Ada type @var{T}, and where the
7112 INTENT attribute of the corresponding dummy argument matches the Ada
7113 formal parameter mode; the Fortran implementation's parameter passing
7114 conventions are used.  For elementary types, a local copy is used if
7115 necessary to ensure by-copy semantics.
7116 @end cartouche
7117 Followed.
7118
7119 @sp 1
7120 @cartouche
7121 An Ada parameter of an access-to-subprogram type is passed as a
7122 reference to a Fortran procedure whose interface corresponds to the
7123 designated subprogram's specification.
7124 @end cartouche
7125 Followed.
7126
7127 @cindex Machine operations
7128 @unnumberedsec C.1(3-5): Access to Machine Operations
7129 @sp 1
7130 @cartouche
7131 The machine code or intrinsic support should allow access to all
7132 operations normally available to assembly language programmers for the
7133 target environment, including privileged instructions, if any.
7134 @end cartouche
7135 Followed.
7136
7137 @sp 1
7138 @cartouche
7139 The interfacing pragmas (see Annex B) should support interface to
7140 assembler; the default assembler should be associated with the
7141 convention identifier @code{Assembler}.
7142 @end cartouche
7143 Followed.
7144
7145 @sp 1
7146 @cartouche
7147 If an entity is exported to assembly language, then the implementation
7148 should allocate it at an addressable location, and should ensure that it
7149 is retained by the linking process, even if not otherwise referenced
7150 from the Ada code.  The implementation should assume that any call to a
7151 machine code or assembler subprogram is allowed to read or update every
7152 object that is specified as exported.
7153 @end cartouche
7154 Followed.
7155
7156 @unnumberedsec C.1(10-16): Access to Machine Operations
7157 @sp 1
7158 @cartouche
7159 The implementation should ensure that little or no overhead is
7160 associated with calling intrinsic and machine-code subprograms.
7161 @end cartouche
7162 Followed for both intrinsics and machine-code subprograms.
7163
7164 @sp 1
7165 @cartouche
7166 It is recommended that intrinsic subprograms be provided for convenient
7167 access to any machine operations that provide special capabilities or
7168 efficiency and that are not otherwise available through the language
7169 constructs.
7170 @end cartouche
7171 Followed.  A full set of machine operation intrinsic subprograms is provided.
7172
7173 @sp 1
7174 @cartouche
7175 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7176 swap, decrement and test, enqueue/dequeue.
7177 @end cartouche
7178 Followed on any target supporting such operations.
7179
7180 @sp 1
7181 @cartouche
7182 Standard numeric functions---e.g.@:, sin, log.
7183 @end cartouche
7184 Followed on any target supporting such operations.
7185
7186 @sp 1
7187 @cartouche
7188 String manipulation operations---e.g.@:, translate and test.
7189 @end cartouche
7190 Followed on any target supporting such operations.
7191
7192 @sp 1
7193 @cartouche
7194 Vector operations---e.g.@:, compare vector against thresholds.
7195 @end cartouche
7196 Followed on any target supporting such operations.
7197
7198 @sp 1
7199 @cartouche
7200 Direct operations on I/O ports.
7201 @end cartouche
7202 Followed on any target supporting such operations.
7203
7204 @cindex Interrupt support
7205 @unnumberedsec C.3(28): Interrupt Support
7206 @sp 1
7207 @cartouche
7208 If the @code{Ceiling_Locking} policy is not in effect, the
7209 implementation should provide means for the application to specify which
7210 interrupts are to be blocked during protected actions, if the underlying
7211 system allows for a finer-grain control of interrupt blocking.
7212 @end cartouche
7213 Followed.  The underlying system does not allow for finer-grain control
7214 of interrupt blocking.
7215
7216 @cindex Protected procedure handlers
7217 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7218 @sp 1
7219 @cartouche
7220 Whenever possible, the implementation should allow interrupt handlers to
7221 be called directly by the hardware.
7222 @end cartouche
7223 @c SGI info:
7224 @ignore
7225 This is never possible under IRIX, so this is followed by default.
7226 @end ignore
7227 Followed on any target where the underlying operating system permits
7228 such direct calls.
7229
7230 @sp 1
7231 @cartouche
7232 Whenever practical, violations of any
7233 implementation-defined restrictions should be detected before run time.
7234 @end cartouche
7235 Followed.  Compile time warnings are given when possible.
7236
7237 @cindex Package @code{Interrupts}
7238 @findex Interrupts
7239 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7240
7241 @sp 1
7242 @cartouche
7243 If implementation-defined forms of interrupt handler procedures are
7244 supported, such as protected procedures with parameters, then for each
7245 such form of a handler, a type analogous to @code{Parameterless_Handler}
7246 should be specified in a child package of @code{Interrupts}, with the
7247 same operations as in the predefined package Interrupts.
7248 @end cartouche
7249 Followed.
7250
7251 @cindex Pre-elaboration requirements
7252 @unnumberedsec C.4(14): Pre-elaboration Requirements
7253 @sp 1
7254 @cartouche
7255 It is recommended that pre-elaborated packages be implemented in such a
7256 way that there should be little or no code executed at run time for the
7257 elaboration of entities not already covered by the Implementation
7258 Requirements.
7259 @end cartouche
7260 Followed.  Executable code is generated in some cases, e.g.@: loops
7261 to initialize large arrays.
7262
7263 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7264
7265 @sp 1
7266 @cartouche
7267 If the pragma applies to an entity, then the implementation should
7268 reduce the amount of storage used for storing names associated with that
7269 entity.
7270 @end cartouche
7271 Followed.
7272
7273 @cindex Package @code{Task_Attributes}
7274 @findex Task_Attributes
7275 @unnumberedsec C.7.2(30): The Package Task_Attributes
7276 @sp 1
7277 @cartouche
7278 Some implementations are targeted to domains in which memory use at run
7279 time must be completely deterministic.  For such implementations, it is
7280 recommended that the storage for task attributes will be pre-allocated
7281 statically and not from the heap.  This can be accomplished by either
7282 placing restrictions on the number and the size of the task's
7283 attributes, or by using the pre-allocated storage for the first @var{N}
7284 attribute objects, and the heap for the others.  In the latter case,
7285 @var{N} should be documented.
7286 @end cartouche
7287 Not followed.  This implementation is not targeted to such a domain.
7288
7289 @cindex Locking Policies
7290 @unnumberedsec D.3(17): Locking Policies
7291
7292 @sp 1
7293 @cartouche
7294 The implementation should use names that end with @samp{_Locking} for
7295 locking policies defined by the implementation.
7296 @end cartouche
7297 Followed.  A single implementation-defined locking policy is defined,
7298 whose name (@code{Inheritance_Locking}) follows this suggestion.
7299
7300 @cindex Entry queuing policies
7301 @unnumberedsec D.4(16): Entry Queuing Policies
7302 @sp 1
7303 @cartouche
7304 Names that end with @samp{_Queuing} should be used
7305 for all implementation-defined queuing policies.
7306 @end cartouche
7307 Followed.  No such implementation-defined queuing policies exist.
7308
7309 @cindex Preemptive abort
7310 @unnumberedsec D.6(9-10): Preemptive Abort
7311 @sp 1
7312 @cartouche
7313 Even though the @code{abort_statement} is included in the list of
7314 potentially blocking operations (see 9.5.1), it is recommended that this
7315 statement be implemented in a way that never requires the task executing
7316 the @code{abort_statement} to block.
7317 @end cartouche
7318 Followed.
7319
7320 @sp 1
7321 @cartouche
7322 On a multi-processor, the delay associated with aborting a task on
7323 another processor should be bounded; the implementation should use
7324 periodic polling, if necessary, to achieve this.
7325 @end cartouche
7326 Followed.
7327
7328 @cindex Tasking restrictions
7329 @unnumberedsec D.7(21): Tasking Restrictions
7330 @sp 1
7331 @cartouche
7332 When feasible, the implementation should take advantage of the specified
7333 restrictions to produce a more efficient implementation.
7334 @end cartouche
7335 GNAT currently takes advantage of these restrictions by providing an optimized
7336 run time when the Ravenscar profile and the GNAT restricted run time set
7337 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7338 pragma @code{Profile (Restricted)} for more details.
7339
7340 @cindex Time, monotonic
7341 @unnumberedsec D.8(47-49): Monotonic Time
7342 @sp 1
7343 @cartouche
7344 When appropriate, implementations should provide configuration
7345 mechanisms to change the value of @code{Tick}.
7346 @end cartouche
7347 Such configuration mechanisms are not appropriate to this implementation
7348 and are thus not supported.
7349
7350 @sp 1
7351 @cartouche
7352 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7353 be implemented as transformations of the same time base.
7354 @end cartouche
7355 Followed.
7356
7357 @sp 1
7358 @cartouche
7359 It is recommended that the @dfn{best} time base which exists in
7360 the underlying system be available to the application through
7361 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7362 @end cartouche
7363 Followed.
7364
7365 @cindex Partition communication subsystem
7366 @cindex PCS
7367 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7368 @sp 1
7369 @cartouche
7370 Whenever possible, the PCS on the called partition should allow for
7371 multiple tasks to call the RPC-receiver with different messages and
7372 should allow them to block until the corresponding subprogram body
7373 returns.
7374 @end cartouche
7375 Followed by GLADE, a separately supplied PCS that can be used with
7376 GNAT.
7377
7378 @sp 1
7379 @cartouche
7380 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7381 should raise @code{Storage_Error} if it runs out of space trying to
7382 write the @code{Item} into the stream.
7383 @end cartouche
7384 Followed by GLADE, a separately supplied PCS that can be used with
7385 GNAT@.
7386
7387 @cindex COBOL support
7388 @unnumberedsec F(7): COBOL Support
7389 @sp 1
7390 @cartouche
7391 If COBOL (respectively, C) is widely supported in the target
7392 environment, implementations supporting the Information Systems Annex
7393 should provide the child package @code{Interfaces.COBOL} (respectively,
7394 @code{Interfaces.C}) specified in Annex B and should support a
7395 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7396 pragmas (see Annex B), thus allowing Ada programs to interface with
7397 programs written in that language.
7398 @end cartouche
7399 Followed.
7400
7401 @cindex Decimal radix support
7402 @unnumberedsec F.1(2): Decimal Radix Support
7403 @sp 1
7404 @cartouche
7405 Packed decimal should be used as the internal representation for objects
7406 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7407 @end cartouche
7408 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7409 representations.
7410
7411 @cindex Numerics
7412 @unnumberedsec G: Numerics
7413 @sp 2
7414 @cartouche
7415 If Fortran (respectively, C) is widely supported in the target
7416 environment, implementations supporting the Numerics Annex
7417 should provide the child package @code{Interfaces.Fortran} (respectively,
7418 @code{Interfaces.C}) specified in Annex B and should support a
7419 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7420 pragmas (see Annex B), thus allowing Ada programs to interface with
7421 programs written in that language.
7422 @end cartouche
7423 Followed.
7424
7425 @cindex Complex types
7426 @unnumberedsec G.1.1(56-58): Complex Types
7427 @sp 2
7428 @cartouche
7429 Because the usual mathematical meaning of multiplication of a complex
7430 operand and a real operand is that of the scaling of both components of
7431 the former by the latter, an implementation should not perform this
7432 operation by first promoting the real operand to complex type and then
7433 performing a full complex multiplication.  In systems that, in the
7434 future, support an Ada binding to IEC 559:1989, the latter technique
7435 will not generate the required result when one of the components of the
7436 complex operand is infinite.  (Explicit multiplication of the infinite
7437 component by the zero component obtained during promotion yields a NaN
7438 that propagates into the final result.) Analogous advice applies in the
7439 case of multiplication of a complex operand and a pure-imaginary
7440 operand, and in the case of division of a complex operand by a real or
7441 pure-imaginary operand.
7442 @end cartouche
7443 Not followed.
7444
7445 @sp 1
7446 @cartouche
7447 Similarly, because the usual mathematical meaning of addition of a
7448 complex operand and a real operand is that the imaginary operand remains
7449 unchanged, an implementation should not perform this operation by first
7450 promoting the real operand to complex type and then performing a full
7451 complex addition.  In implementations in which the @code{Signed_Zeros}
7452 attribute of the component type is @code{True} (and which therefore
7453 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7454 predefined arithmetic operations), the latter technique will not
7455 generate the required result when the imaginary component of the complex
7456 operand is a negatively signed zero.  (Explicit addition of the negative
7457 zero to the zero obtained during promotion yields a positive zero.)
7458 Analogous advice applies in the case of addition of a complex operand
7459 and a pure-imaginary operand, and in the case of subtraction of a
7460 complex operand and a real or pure-imaginary operand.
7461 @end cartouche
7462 Not followed.
7463
7464 @sp 1
7465 @cartouche
7466 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7467 attempt to provide a rational treatment of the signs of zero results and
7468 result components.  As one example, the result of the @code{Argument}
7469 function should have the sign of the imaginary component of the
7470 parameter @code{X} when the point represented by that parameter lies on
7471 the positive real axis; as another, the sign of the imaginary component
7472 of the @code{Compose_From_Polar} function should be the same as
7473 (respectively, the opposite of) that of the @code{Argument} parameter when that
7474 parameter has a value of zero and the @code{Modulus} parameter has a
7475 nonnegative (respectively, negative) value.
7476 @end cartouche
7477 Followed.
7478
7479 @cindex Complex elementary functions
7480 @unnumberedsec G.1.2(49): Complex Elementary Functions
7481 @sp 1
7482 @cartouche
7483 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7484 @code{True} should attempt to provide a rational treatment of the signs
7485 of zero results and result components.  For example, many of the complex
7486 elementary functions have components that are odd functions of one of
7487 the parameter components; in these cases, the result component should
7488 have the sign of the parameter component at the origin.  Other complex
7489 elementary functions have zero components whose sign is opposite that of
7490 a parameter component at the origin, or is always positive or always
7491 negative.
7492 @end cartouche
7493 Followed.
7494
7495 @cindex Accuracy requirements
7496 @unnumberedsec G.2.4(19): Accuracy Requirements
7497 @sp 1
7498 @cartouche
7499 The versions of the forward trigonometric functions without a
7500 @code{Cycle} parameter should not be implemented by calling the
7501 corresponding version with a @code{Cycle} parameter of
7502 @code{2.0*Numerics.Pi}, since this will not provide the required
7503 accuracy in some portions of the domain.  For the same reason, the
7504 version of @code{Log} without a @code{Base} parameter should not be
7505 implemented by calling the corresponding version with a @code{Base}
7506 parameter of @code{Numerics.e}.
7507 @end cartouche
7508 Followed.
7509
7510 @cindex Complex arithmetic accuracy
7511 @cindex Accuracy, complex arithmetic
7512 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7513
7514 @sp 1
7515 @cartouche
7516 The version of the @code{Compose_From_Polar} function without a
7517 @code{Cycle} parameter should not be implemented by calling the
7518 corresponding version with a @code{Cycle} parameter of
7519 @code{2.0*Numerics.Pi}, since this will not provide the required
7520 accuracy in some portions of the domain.
7521 @end cartouche
7522 Followed.
7523
7524 @c -----------------------------------------
7525 @node Implementation Defined Characteristics
7526 @chapter Implementation Defined Characteristics
7527
7528 @noindent
7529 In addition to the implementation dependent pragmas and attributes, and
7530 the implementation advice, there are a number of other Ada features
7531 that are potentially implementation dependent.  These are mentioned
7532 throughout the Ada Reference Manual, and are summarized in annex M@.
7533
7534 A requirement for conforming Ada compilers is that they provide
7535 documentation describing how the implementation deals with each of these
7536 issues.  In this chapter, you will find each point in annex M listed
7537 followed by a description in italic font of how GNAT
7538 @c SGI info:
7539 @ignore
7540 in the ProDev Ada
7541 implementation on IRIX 5.3 operating system or greater
7542 @end ignore
7543 handles the implementation dependence.
7544
7545 You can use this chapter as a guide to minimizing implementation
7546 dependent features in your programs if portability to other compilers
7547 and other operating systems is an important consideration.  The numbers
7548 in each section below correspond to the paragraph number in the Ada
7549 Reference Manual.
7550
7551 @sp 1
7552 @cartouche
7553 @noindent
7554 @strong{2}.  Whether or not each recommendation given in Implementation
7555 Advice is followed.  See 1.1.2(37).
7556 @end cartouche
7557 @noindent
7558 @xref{Implementation Advice}.
7559
7560 @sp 1
7561 @cartouche
7562 @noindent
7563 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7564 @end cartouche
7565 @noindent
7566 The complexity of programs that can be processed is limited only by the
7567 total amount of available virtual memory, and disk space for the
7568 generated object files.
7569
7570 @sp 1
7571 @cartouche
7572 @noindent
7573 @strong{4}.  Variations from the standard that are impractical to avoid
7574 given the implementation's execution environment.  See 1.1.3(6).
7575 @end cartouche
7576 @noindent
7577 There are no variations from the standard.
7578
7579 @sp 1
7580 @cartouche
7581 @noindent
7582 @strong{5}.  Which @code{code_statement}s cause external
7583 interactions.  See 1.1.3(10).
7584 @end cartouche
7585 @noindent
7586 Any @code{code_statement} can potentially cause external interactions.
7587
7588 @sp 1
7589 @cartouche
7590 @noindent
7591 @strong{6}.  The coded representation for the text of an Ada
7592 program.  See 2.1(4).
7593 @end cartouche
7594 @noindent
7595 See separate section on source representation.
7596
7597 @sp 1
7598 @cartouche
7599 @noindent
7600 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7601 @end cartouche
7602 @noindent
7603 See separate section on source representation.
7604
7605 @sp 1
7606 @cartouche
7607 @noindent
7608 @strong{8}.  The representation for an end of line.  See 2.2(2).
7609 @end cartouche
7610 @noindent
7611 See separate section on source representation.
7612
7613 @sp 1
7614 @cartouche
7615 @noindent
7616 @strong{9}.  Maximum supported line length and lexical element
7617 length.  See 2.2(15).
7618 @end cartouche
7619 @noindent
7620 The maximum line length is 255 characters and the maximum length of a
7621 lexical element is also 255 characters.
7622
7623 @sp 1
7624 @cartouche
7625 @noindent
7626 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7627 @end cartouche
7628 @noindent
7629
7630 @xref{Implementation Defined Pragmas}.
7631
7632 @sp 1
7633 @cartouche
7634 @noindent
7635 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7636 @end cartouche
7637 @noindent
7638 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7639 parameter, checks that the optimization flag is set, and aborts if it is
7640 not.
7641
7642 @sp 1
7643 @cartouche
7644 @noindent
7645 @strong{12}.  The sequence of characters of the value returned by
7646 @code{@var{S}'Image} when some of the graphic characters of
7647 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7648 3.5(37).
7649 @end cartouche
7650 @noindent
7651 The sequence of characters is as defined by the wide character encoding
7652 method used for the source.  See section on source representation for
7653 further details.
7654
7655 @sp 1
7656 @cartouche
7657 @noindent
7658 @strong{13}.  The predefined integer types declared in
7659 @code{Standard}.  See 3.5.4(25).
7660 @end cartouche
7661 @noindent
7662 @table @code
7663 @item Short_Short_Integer
7664 8 bit signed
7665 @item Short_Integer
7666 (Short) 16 bit signed
7667 @item Integer
7668 32 bit signed
7669 @item Long_Integer
7670 64 bit signed (Alpha OpenVMS only)
7671 32 bit signed (all other targets)
7672 @item Long_Long_Integer
7673 64 bit signed
7674 @end table
7675
7676 @sp 1
7677 @cartouche
7678 @noindent
7679 @strong{14}.  Any nonstandard integer types and the operators defined
7680 for them.  See 3.5.4(26).
7681 @end cartouche
7682 @noindent
7683 There are no nonstandard integer types.
7684
7685 @sp 1
7686 @cartouche
7687 @noindent
7688 @strong{15}.  Any nonstandard real types and the operators defined for
7689 them.  See 3.5.6(8).
7690 @end cartouche
7691 @noindent
7692 There are no nonstandard real types.
7693
7694 @sp 1
7695 @cartouche
7696 @noindent
7697 @strong{16}.  What combinations of requested decimal precision and range
7698 are supported for floating point types.  See 3.5.7(7).
7699 @end cartouche
7700 @noindent
7701 The precision and range is as defined by the IEEE standard.
7702
7703 @sp 1
7704 @cartouche
7705 @noindent
7706 @strong{17}.  The predefined floating point types declared in
7707 @code{Standard}.  See 3.5.7(16).
7708 @end cartouche
7709 @noindent
7710 @table @code
7711 @item Short_Float
7712 32 bit IEEE short
7713 @item Float
7714 (Short) 32 bit IEEE short
7715 @item Long_Float
7716 64 bit IEEE long
7717 @item Long_Long_Float
7718 64 bit IEEE long (80 bit IEEE long on x86 processors)
7719 @end table
7720
7721 @sp 1
7722 @cartouche
7723 @noindent
7724 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7725 @end cartouche
7726 @noindent
7727 @code{Fine_Delta} is 2**(@minus{}63)
7728
7729 @sp 1
7730 @cartouche
7731 @noindent
7732 @strong{19}.  What combinations of small, range, and digits are
7733 supported for fixed point types.  See 3.5.9(10).
7734 @end cartouche
7735 @noindent
7736 Any combinations are permitted that do not result in a small less than
7737 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7738 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7739 is 64 bits (true of all architectures except ia32), then the output from
7740 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7741 is because floating-point conversions are used to convert fixed point.
7742
7743 @sp 1
7744 @cartouche
7745 @noindent
7746 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7747 within an unnamed @code{block_statement}.  See 3.9(10).
7748 @end cartouche
7749 @noindent
7750 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7751 decimal integer are allocated.
7752
7753 @sp 1
7754 @cartouche
7755 @noindent
7756 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7757 @end cartouche
7758 @noindent
7759 @xref{Implementation Defined Attributes}.
7760
7761 @sp 1
7762 @cartouche
7763 @noindent
7764 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7765 @end cartouche
7766 @noindent
7767 There are no implementation-defined time types.
7768
7769 @sp 1
7770 @cartouche
7771 @noindent
7772 @strong{23}.  The time base associated with relative delays.
7773 @end cartouche
7774 @noindent
7775 See 9.6(20).  The time base used is that provided by the C library
7776 function @code{gettimeofday}.
7777
7778 @sp 1
7779 @cartouche
7780 @noindent
7781 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7782 9.6(23).
7783 @end cartouche
7784 @noindent
7785 The time base used is that provided by the C library function
7786 @code{gettimeofday}.
7787
7788 @sp 1
7789 @cartouche
7790 @noindent
7791 @strong{25}.  The time zone used for package @code{Calendar}
7792 operations.  See 9.6(24).
7793 @end cartouche
7794 @noindent
7795 The time zone used by package @code{Calendar} is the current system time zone
7796 setting for local time, as accessed by the C library function
7797 @code{localtime}.
7798
7799 @sp 1
7800 @cartouche
7801 @noindent
7802 @strong{26}.  Any limit on @code{delay_until_statements} of
7803 @code{select_statements}.  See 9.6(29).
7804 @end cartouche
7805 @noindent
7806 There are no such limits.
7807
7808 @sp 1
7809 @cartouche
7810 @noindent
7811 @strong{27}.  Whether or not two non-overlapping parts of a composite
7812 object are independently addressable, in the case where packing, record
7813 layout, or @code{Component_Size} is specified for the object.  See
7814 9.10(1).
7815 @end cartouche
7816 @noindent
7817 Separate components are independently addressable if they do not share
7818 overlapping storage units.
7819
7820 @sp 1
7821 @cartouche
7822 @noindent
7823 @strong{28}.  The representation for a compilation.  See 10.1(2).
7824 @end cartouche
7825 @noindent
7826 A compilation is represented by a sequence of files presented to the
7827 compiler in a single invocation of the @command{gcc} command.
7828
7829 @sp 1
7830 @cartouche
7831 @noindent
7832 @strong{29}.  Any restrictions on compilations that contain multiple
7833 compilation_units.  See 10.1(4).
7834 @end cartouche
7835 @noindent
7836 No single file can contain more than one compilation unit, but any
7837 sequence of files can be presented to the compiler as a single
7838 compilation.
7839
7840 @sp 1
7841 @cartouche
7842 @noindent
7843 @strong{30}.  The mechanisms for creating an environment and for adding
7844 and replacing compilation units.  See 10.1.4(3).
7845 @end cartouche
7846 @noindent
7847 See separate section on compilation model.
7848
7849 @sp 1
7850 @cartouche
7851 @noindent
7852 @strong{31}.  The manner of explicitly assigning library units to a
7853 partition.  See 10.2(2).
7854 @end cartouche
7855 @noindent
7856 If a unit contains an Ada main program, then the Ada units for the partition
7857 are determined by recursive application of the rules in the Ada Reference
7858 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7859 are needed by the main program, and then this definition of need is applied
7860 recursively to those units, and the partition contains the transitive
7861 closure determined by this relationship.  In short, all the necessary units
7862 are included, with no need to explicitly specify the list.  If additional
7863 units are required, e.g.@: by foreign language units, then all units must be
7864 mentioned in the context clause of one of the needed Ada units.
7865
7866 If the partition contains no main program, or if the main program is in
7867 a language other than Ada, then GNAT
7868 provides the binder options @option{-z} and @option{-n} respectively, and in
7869 this case a list of units can be explicitly supplied to the binder for
7870 inclusion in the partition (all units needed by these units will also
7871 be included automatically).  For full details on the use of these
7872 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
7873 @value{EDITION} User's Guide}.
7874
7875 @sp 1
7876 @cartouche
7877 @noindent
7878 @strong{32}.  The implementation-defined means, if any, of specifying
7879 which compilation units are needed by a given compilation unit.  See
7880 10.2(2).
7881 @end cartouche
7882 @noindent
7883 The units needed by a given compilation unit are as defined in
7884 the Ada Reference Manual section 10.2(2-6).  There are no
7885 implementation-defined pragmas or other implementation-defined
7886 means for specifying needed units.
7887
7888 @sp 1
7889 @cartouche
7890 @noindent
7891 @strong{33}.  The manner of designating the main subprogram of a
7892 partition.  See 10.2(7).
7893 @end cartouche
7894 @noindent
7895 The main program is designated by providing the name of the
7896 corresponding @file{ALI} file as the input parameter to the binder.
7897
7898 @sp 1
7899 @cartouche
7900 @noindent
7901 @strong{34}.  The order of elaboration of @code{library_items}.  See
7902 10.2(18).
7903 @end cartouche
7904 @noindent
7905 The first constraint on ordering is that it meets the requirements of
7906 Chapter 10 of the Ada Reference Manual.  This still leaves some
7907 implementation dependent choices, which are resolved by first
7908 elaborating bodies as early as possible (i.e., in preference to specs
7909 where there is a choice), and second by evaluating the immediate with
7910 clauses of a unit to determine the probably best choice, and
7911 third by elaborating in alphabetical order of unit names
7912 where a choice still remains.
7913
7914 @sp 1
7915 @cartouche
7916 @noindent
7917 @strong{35}.  Parameter passing and function return for the main
7918 subprogram.  See 10.2(21).
7919 @end cartouche
7920 @noindent
7921 The main program has no parameters.  It may be a procedure, or a function
7922 returning an integer type.  In the latter case, the returned integer
7923 value is the return code of the program (overriding any value that
7924 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7925
7926 @sp 1
7927 @cartouche
7928 @noindent
7929 @strong{36}.  The mechanisms for building and running partitions.  See
7930 10.2(24).
7931 @end cartouche
7932 @noindent
7933 GNAT itself supports programs with only a single partition.  The GNATDIST
7934 tool provided with the GLADE package (which also includes an implementation
7935 of the PCS) provides a completely flexible method for building and running
7936 programs consisting of multiple partitions.  See the separate GLADE manual
7937 for details.
7938
7939 @sp 1
7940 @cartouche
7941 @noindent
7942 @strong{37}.  The details of program execution, including program
7943 termination.  See 10.2(25).
7944 @end cartouche
7945 @noindent
7946 See separate section on compilation model.
7947
7948 @sp 1
7949 @cartouche
7950 @noindent
7951 @strong{38}.  The semantics of any non-active partitions supported by the
7952 implementation.  See 10.2(28).
7953 @end cartouche
7954 @noindent
7955 Passive partitions are supported on targets where shared memory is
7956 provided by the operating system.  See the GLADE reference manual for
7957 further details.
7958
7959 @sp 1
7960 @cartouche
7961 @noindent
7962 @strong{39}.  The information returned by @code{Exception_Message}.  See
7963 11.4.1(10).
7964 @end cartouche
7965 @noindent
7966 Exception message returns the null string unless a specific message has
7967 been passed by the program.
7968
7969 @sp 1
7970 @cartouche
7971 @noindent
7972 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7973 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7974 @end cartouche
7975 @noindent
7976 Blocks have implementation defined names of the form @code{B@var{nnn}}
7977 where @var{nnn} is an integer.
7978
7979 @sp 1
7980 @cartouche
7981 @noindent
7982 @strong{41}.  The information returned by
7983 @code{Exception_Information}.  See 11.4.1(13).
7984 @end cartouche
7985 @noindent
7986 @code{Exception_Information} returns a string in the following format:
7987
7988 @smallexample
7989 @emph{Exception_Name:} nnnnn
7990 @emph{Message:} mmmmm
7991 @emph{PID:} ppp
7992 @emph{Call stack traceback locations:}
7993 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7994 @end smallexample
7995
7996 @noindent
7997 where
7998
7999 @itemize @bullet
8000 @item
8001 @code{nnnn} is the fully qualified name of the exception in all upper
8002 case letters. This line is always present.
8003
8004 @item
8005 @code{mmmm} is the message (this line present only if message is non-null)
8006
8007 @item
8008 @code{ppp} is the Process Id value as a decimal integer (this line is
8009 present only if the Process Id is nonzero). Currently we are
8010 not making use of this field.
8011
8012 @item
8013 The Call stack traceback locations line and the following values
8014 are present only if at least one traceback location was recorded.
8015 The values are given in C style format, with lower case letters
8016 for a-f, and only as many digits present as are necessary.
8017 @end itemize
8018
8019 @noindent
8020 The line terminator sequence at the end of each line, including
8021 the last line is a single @code{LF} character (@code{16#0A#}).
8022
8023 @sp 1
8024 @cartouche
8025 @noindent
8026 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8027 @end cartouche
8028 @noindent
8029 The implementation defined check name Alignment_Check controls checking of
8030 address clause values for proper alignment (that is, the address supplied
8031 must be consistent with the alignment of the type).
8032
8033 In addition, a user program can add implementation-defined check names
8034 by means of the pragma Check_Name.
8035
8036 @sp 1
8037 @cartouche
8038 @noindent
8039 @strong{43}.  The interpretation of each aspect of representation.  See
8040 13.1(20).
8041 @end cartouche
8042 @noindent
8043 See separate section on data representations.
8044
8045 @sp 1
8046 @cartouche
8047 @noindent
8048 @strong{44}.  Any restrictions placed upon representation items.  See
8049 13.1(20).
8050 @end cartouche
8051 @noindent
8052 See separate section on data representations.
8053
8054 @sp 1
8055 @cartouche
8056 @noindent
8057 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8058 13.3(48).
8059 @end cartouche
8060 @noindent
8061 Size for an indefinite subtype is the maximum possible size, except that
8062 for the case of a subprogram parameter, the size of the parameter object
8063 is the actual size.
8064
8065 @sp 1
8066 @cartouche
8067 @noindent
8068 @strong{46}.  The default external representation for a type tag.  See
8069 13.3(75).
8070 @end cartouche
8071 @noindent
8072 The default external representation for a type tag is the fully expanded
8073 name of the type in upper case letters.
8074
8075 @sp 1
8076 @cartouche
8077 @noindent
8078 @strong{47}.  What determines whether a compilation unit is the same in
8079 two different partitions.  See 13.3(76).
8080 @end cartouche
8081 @noindent
8082 A compilation unit is the same in two different partitions if and only
8083 if it derives from the same source file.
8084
8085 @sp 1
8086 @cartouche
8087 @noindent
8088 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8089 @end cartouche
8090 @noindent
8091 The only implementation defined component is the tag for a tagged type,
8092 which contains a pointer to the dispatching table.
8093
8094 @sp 1
8095 @cartouche
8096 @noindent
8097 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8098 ordering.  See 13.5.3(5).
8099 @end cartouche
8100 @noindent
8101 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8102 implementation, so no non-default bit ordering is supported.  The default
8103 bit ordering corresponds to the natural endianness of the target architecture.
8104
8105 @sp 1
8106 @cartouche
8107 @noindent
8108 @strong{50}.  The contents of the visible part of package @code{System}
8109 and its language-defined children.  See 13.7(2).
8110 @end cartouche
8111 @noindent
8112 See the definition of these packages in files @file{system.ads} and
8113 @file{s-stoele.ads}.
8114
8115 @sp 1
8116 @cartouche
8117 @noindent
8118 @strong{51}.  The contents of the visible part of package
8119 @code{System.Machine_Code}, and the meaning of
8120 @code{code_statements}.  See 13.8(7).
8121 @end cartouche
8122 @noindent
8123 See the definition and documentation in file @file{s-maccod.ads}.
8124
8125 @sp 1
8126 @cartouche
8127 @noindent
8128 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8129 @end cartouche
8130 @noindent
8131 Unchecked conversion between types of the same size
8132 results in an uninterpreted transmission of the bits from one type
8133 to the other.  If the types are of unequal sizes, then in the case of
8134 discrete types, a shorter source is first zero or sign extended as
8135 necessary, and a shorter target is simply truncated on the left.
8136 For all non-discrete types, the source is first copied if necessary
8137 to ensure that the alignment requirements of the target are met, then
8138 a pointer is constructed to the source value, and the result is obtained
8139 by dereferencing this pointer after converting it to be a pointer to the
8140 target type. Unchecked conversions where the target subtype is an
8141 unconstrained array are not permitted. If the target alignment is
8142 greater than the source alignment, then a copy of the result is
8143 made with appropriate alignment
8144
8145 @sp 1
8146 @cartouche
8147 @noindent
8148 @strong{53}.  The manner of choosing a storage pool for an access type
8149 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8150 @end cartouche
8151 @noindent
8152 There are 3 different standard pools used by the compiler when
8153 @code{Storage_Pool} is not specified depending whether the type is local
8154 to a subprogram or defined at the library level and whether
8155 @code{Storage_Size}is specified or not.  See documentation in the runtime
8156 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8157 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8158 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8159 default pools used.
8160
8161 @sp 1
8162 @cartouche
8163 @noindent
8164 @strong{54}.  Whether or not the implementation provides user-accessible
8165 names for the standard pool type(s).  See 13.11(17).
8166 @end cartouche
8167 @noindent
8168
8169 See documentation in the sources of the run time mentioned in paragraph
8170 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8171 these units.
8172
8173 @sp 1
8174 @cartouche
8175 @noindent
8176 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8177 @end cartouche
8178 @noindent
8179 @code{Storage_Size} is measured in storage units, and refers to the
8180 total space available for an access type collection, or to the primary
8181 stack space for a task.
8182
8183 @sp 1
8184 @cartouche
8185 @noindent
8186 @strong{56}.  Implementation-defined aspects of storage pools.  See
8187 13.11(22).
8188 @end cartouche
8189 @noindent
8190 See documentation in the sources of the run time mentioned in paragraph
8191 @strong{53} for details on GNAT-defined aspects of storage pools.
8192
8193 @sp 1
8194 @cartouche
8195 @noindent
8196 @strong{57}.  The set of restrictions allowed in a pragma
8197 @code{Restrictions}.  See 13.12(7).
8198 @end cartouche
8199 @noindent
8200 All RM defined Restriction identifiers are implemented.  The following
8201 additional restriction identifiers are provided.  There are two separate
8202 lists of implementation dependent restriction identifiers.  The first
8203 set requires consistency throughout a partition (in other words, if the
8204 restriction identifier is used for any compilation unit in the partition,
8205 then all compilation units in the partition must obey the restriction.
8206
8207 @table @code
8208
8209 @item Simple_Barriers
8210 @findex Simple_Barriers
8211 This restriction ensures at compile time that barriers in entry declarations
8212 for protected types are restricted to either static boolean expressions or
8213 references to simple boolean variables defined in the private part of the
8214 protected type.  No other form of entry barriers is permitted.  This is one
8215 of the restrictions of the Ravenscar profile for limited tasking (see also
8216 pragma @code{Profile (Ravenscar)}).
8217
8218 @item Max_Entry_Queue_Length => Expr
8219 @findex Max_Entry_Queue_Length
8220 This restriction is a declaration that any protected entry compiled in
8221 the scope of the restriction has at most the specified number of
8222 tasks waiting on the entry
8223 at any one time, and so no queue is required.  This restriction is not
8224 checked at compile time.  A program execution is erroneous if an attempt
8225 is made to queue more than the specified number of tasks on such an entry.
8226
8227 @item No_Calendar
8228 @findex No_Calendar
8229 This restriction ensures at compile time that there is no implicit or
8230 explicit dependence on the package @code{Ada.Calendar}.
8231
8232 @item No_Default_Initialization
8233 @findex No_Default_Initialization
8234
8235 This restriction prohibits any instance of default initialization of variables.
8236 The binder implements a consistency rule which prevents any unit compiled
8237 without the restriction from with'ing a unit with the restriction (this allows
8238 the generation of initialization procedures to be skipped, since you can be
8239 sure that no call is ever generated to an initialization procedure in a unit
8240 with the restriction active). If used in conjunction with Initialize_Scalars or
8241 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8242 without a specific initializer (including the case of OUT scalar parameters).
8243
8244 @item No_Direct_Boolean_Operators
8245 @findex No_Direct_Boolean_Operators
8246 This restriction ensures that no logical (and/or/xor) or comparison
8247 operators are used on operands of type Boolean (or any type derived
8248 from Boolean). This is intended for use in safety critical programs
8249 where the certification protocol requires the use of short-circuit
8250 (and then, or else) forms for all composite boolean operations.
8251
8252 @item No_Dispatching_Calls
8253 @findex No_Dispatching_Calls
8254 This restriction ensures at compile time that the code generated by the
8255 compiler involves no dispatching calls. The use of this restriction allows the
8256 safe use of record extensions, classwide membership tests and other classwide
8257 features not involving implicit dispatching. This restriction ensures that
8258 the code contains no indirect calls through a dispatching mechanism. Note that
8259 this includes internally-generated calls created by the compiler, for example
8260 in the implementation of class-wide objects assignments. The
8261 membership test is allowed in the presence of this restriction, because its
8262 implementation requires no dispatching.
8263 This restriction is comparable to the official Ada restriction
8264 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8265 all classwide constructs that do not imply dispatching.
8266 The following example indicates constructs that violate this restriction.
8267
8268 @smallexample
8269 package Pkg is
8270   type T is tagged record
8271     Data : Natural;
8272   end record;
8273   procedure P (X : T);
8274
8275   type DT is new T with record
8276     More_Data : Natural;
8277   end record;
8278   procedure Q (X : DT);
8279 end Pkg;
8280
8281 with Pkg; use Pkg;
8282 procedure Example is
8283   procedure Test (O : T'Class) is
8284     N : Natural  := O'Size;--  Error: Dispatching call
8285     C : T'Class := O;      --  Error: implicit Dispatching Call
8286   begin
8287     if O in DT'Class then  --  OK   : Membership test
8288        Q (DT (O));         --  OK   : Type conversion plus direct call
8289     else
8290        P (O);              --  Error: Dispatching call
8291     end if;
8292   end Test;
8293
8294   Obj : DT;
8295 begin
8296   P (Obj);                 --  OK   : Direct call
8297   P (T (Obj));             --  OK   : Type conversion plus direct call
8298   P (T'Class (Obj));       --  Error: Dispatching call
8299
8300   Test (Obj);              --  OK   : Type conversion
8301
8302   if Obj in T'Class then   --  OK   : Membership test
8303      null;
8304   end if;
8305 end Example;
8306 @end smallexample
8307
8308 @item No_Dynamic_Attachment
8309 @findex No_Dynamic_Attachment
8310 This restriction ensures that there is no call to any of the operations
8311 defined in package Ada.Interrupts.
8312
8313 @item No_Enumeration_Maps
8314 @findex No_Enumeration_Maps
8315 This restriction ensures at compile time that no operations requiring
8316 enumeration maps are used (that is Image and Value attributes applied
8317 to enumeration types).
8318
8319 @item No_Entry_Calls_In_Elaboration_Code
8320 @findex No_Entry_Calls_In_Elaboration_Code
8321 This restriction ensures at compile time that no task or protected entry
8322 calls are made during elaboration code.  As a result of the use of this
8323 restriction, the compiler can assume that no code past an accept statement
8324 in a task can be executed at elaboration time.
8325
8326 @item No_Exception_Handlers
8327 @findex No_Exception_Handlers
8328 This restriction ensures at compile time that there are no explicit
8329 exception handlers. It also indicates that no exception propagation will
8330 be provided. In this mode, exceptions may be raised but will result in
8331 an immediate call to the last chance handler, a routine that the user
8332 must define with the following profile:
8333
8334    procedure Last_Chance_Handler
8335      (Source_Location : System.Address; Line : Integer);
8336    pragma Export (C, Last_Chance_Handler,
8337                   "__gnat_last_chance_handler");
8338
8339    The parameter is a C null-terminated string representing a message to be
8340    associated with the exception (typically the source location of the raise
8341    statement generated by the compiler). The Line parameter when nonzero
8342    represents the line number in the source program where the raise occurs.
8343
8344 @item No_Exception_Propagation
8345 @findex No_Exception_Propagation
8346 This restriction guarantees that exceptions are never propagated to an outer
8347 subprogram scope). The only case in which an exception may be raised is when
8348 the handler is statically in the same subprogram, so that the effect of a raise
8349 is essentially like a goto statement. Any other raise statement (implicit or
8350 explicit) will be considered unhandled. Exception handlers are allowed, but may
8351 not contain an exception occurrence identifier (exception choice). In addition
8352 use of the package GNAT.Current_Exception is not permitted, and reraise
8353 statements (raise with no operand) are not permitted.
8354
8355 @item No_Exception_Registration
8356 @findex No_Exception_Registration
8357 This restriction ensures at compile time that no stream operations for
8358 types Exception_Id or Exception_Occurrence are used. This also makes it
8359 impossible to pass exceptions to or from a partition with this restriction
8360 in a distributed environment. If this exception is active, then the generated
8361 code is simplified by omitting the otherwise-required global registration
8362 of exceptions when they are declared.
8363
8364 @item No_Implicit_Conditionals
8365 @findex No_Implicit_Conditionals
8366 This restriction ensures that the generated code does not contain any
8367 implicit conditionals, either by modifying the generated code where possible,
8368 or by rejecting any construct that would otherwise generate an implicit
8369 conditional. Note that this check does not include run time constraint
8370 checks, which on some targets may generate implicit conditionals as
8371 well. To control the latter, constraint checks can be suppressed in the
8372 normal manner. Constructs generating implicit conditionals include comparisons
8373 of composite objects and the Max/Min attributes.
8374
8375 @item No_Implicit_Dynamic_Code
8376 @findex No_Implicit_Dynamic_Code
8377 @cindex trampoline
8378 This restriction prevents the compiler from building ``trampolines''.
8379 This is a structure that is built on the stack and contains dynamic
8380 code to be executed at run time. On some targets, a trampoline is
8381 built for the following features: @code{Access},
8382 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8383 nested task bodies; primitive operations of nested tagged types.
8384 Trampolines do not work on machines that prevent execution of stack
8385 data. For example, on windows systems, enabling DEP (data execution
8386 protection) will cause trampolines to raise an exception.
8387 Trampolines are also quite slow at run time.
8388
8389 On many targets, trampolines have been largely eliminated. Look at the
8390 version of system.ads for your target --- if it has
8391 Always_Compatible_Rep equal to False, then trampolines are largely
8392 eliminated. In particular, a trampoline is built for the following
8393 features: @code{Address} of a nested subprogram;
8394 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8395 but only if pragma Favor_Top_Level applies, or the access type has a
8396 foreign-language convention; primitive operations of nested tagged
8397 types.
8398
8399 @item No_Implicit_Loops
8400 @findex No_Implicit_Loops
8401 This restriction ensures that the generated code does not contain any
8402 implicit @code{for} loops, either by modifying
8403 the generated code where possible,
8404 or by rejecting any construct that would otherwise generate an implicit
8405 @code{for} loop. If this restriction is active, it is possible to build
8406 large array aggregates with all static components without generating an
8407 intermediate temporary, and without generating a loop to initialize individual
8408 components. Otherwise, a loop is created for arrays larger than about 5000
8409 scalar components.
8410
8411 @item No_Initialize_Scalars
8412 @findex No_Initialize_Scalars
8413 This restriction ensures that no unit in the partition is compiled with
8414 pragma Initialize_Scalars. This allows the generation of more efficient
8415 code, and in particular eliminates dummy null initialization routines that
8416 are otherwise generated for some record and array types.
8417
8418 @item No_Local_Protected_Objects
8419 @findex No_Local_Protected_Objects
8420 This restriction ensures at compile time that protected objects are
8421 only declared at the library level.
8422
8423 @item No_Protected_Type_Allocators
8424 @findex No_Protected_Type_Allocators
8425 This restriction ensures at compile time that there are no allocator
8426 expressions that attempt to allocate protected objects.
8427
8428 @item No_Secondary_Stack
8429 @findex No_Secondary_Stack
8430 This restriction ensures at compile time that the generated code does not
8431 contain any reference to the secondary stack.  The secondary stack is used
8432 to implement functions returning unconstrained objects (arrays or records)
8433 on some targets.
8434
8435 @item No_Select_Statements
8436 @findex No_Select_Statements
8437 This restriction ensures at compile time no select statements of any kind
8438 are permitted, that is the keyword @code{select} may not appear.
8439 This is one of the restrictions of the Ravenscar
8440 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8441
8442 @item No_Standard_Storage_Pools
8443 @findex No_Standard_Storage_Pools
8444 This restriction ensures at compile time that no access types
8445 use the standard default storage pool.  Any access type declared must
8446 have an explicit Storage_Pool attribute defined specifying a
8447 user-defined storage pool.
8448
8449 @item No_Streams
8450 @findex No_Streams
8451 This restriction ensures at compile/bind time that there are no
8452 stream objects created (and therefore no actual stream operations).
8453 This restriction does not forbid dependences on the package
8454 @code{Ada.Streams}. So it is permissible to with
8455 @code{Ada.Streams} (or another package that does so itself)
8456 as long as no actual stream objects are created.
8457
8458 @item No_Task_Attributes_Package
8459 @findex No_Task_Attributes_Package
8460 This restriction ensures at compile time that there are no implicit or
8461 explicit dependencies on the package @code{Ada.Task_Attributes}.
8462
8463 @item No_Task_Termination
8464 @findex No_Task_Termination
8465 This restriction ensures at compile time that no terminate alternatives
8466 appear in any task body.
8467
8468 @item No_Tasking
8469 @findex No_Tasking
8470 This restriction prevents the declaration of tasks or task types throughout
8471 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8472 except that violations are caught at compile time and cause an error message
8473 to be output either by the compiler or binder.
8474
8475 @item Static_Priorities
8476 @findex Static_Priorities
8477 This restriction ensures at compile time that all priority expressions
8478 are static, and that there are no dependencies on the package
8479 @code{Ada.Dynamic_Priorities}.
8480
8481 @item Static_Storage_Size
8482 @findex Static_Storage_Size
8483 This restriction ensures at compile time that any expression appearing
8484 in a Storage_Size pragma or attribute definition clause is static.
8485
8486 @end table
8487
8488 @noindent
8489 The second set of implementation dependent restriction identifiers
8490 does not require partition-wide consistency.
8491 The restriction may be enforced for a single
8492 compilation unit without any effect on any of the
8493 other compilation units in the partition.
8494
8495 @table @code
8496
8497 @item No_Elaboration_Code
8498 @findex No_Elaboration_Code
8499 This restriction ensures at compile time that no elaboration code is
8500 generated.  Note that this is not the same condition as is enforced
8501 by pragma @code{Preelaborate}.  There are cases in which pragma
8502 @code{Preelaborate} still permits code to be generated (e.g.@: code
8503 to initialize a large array to all zeroes), and there are cases of units
8504 which do not meet the requirements for pragma @code{Preelaborate},
8505 but for which no elaboration code is generated.  Generally, it is
8506 the case that preelaborable units will meet the restrictions, with
8507 the exception of large aggregates initialized with an others_clause,
8508 and exception declarations (which generate calls to a run-time
8509 registry procedure).  This restriction is enforced on
8510 a unit by unit basis, it need not be obeyed consistently
8511 throughout a partition.
8512
8513 In the case of aggregates with others, if the aggregate has a dynamic
8514 size, there is no way to eliminate the elaboration code (such dynamic
8515 bounds would be incompatible with @code{Preelaborate} in any case). If
8516 the bounds are static, then use of this restriction actually modifies
8517 the code choice of the compiler to avoid generating a loop, and instead
8518 generate the aggregate statically if possible, no matter how many times
8519 the data for the others clause must be repeatedly generated.
8520
8521 It is not possible to precisely document
8522 the constructs which are compatible with this restriction, since,
8523 unlike most other restrictions, this is not a restriction on the
8524 source code, but a restriction on the generated object code. For
8525 example, if the source contains a declaration:
8526
8527 @smallexample
8528    Val : constant Integer := X;
8529 @end smallexample
8530
8531 @noindent
8532 where X is not a static constant, it may be possible, depending
8533 on complex optimization circuitry, for the compiler to figure
8534 out the value of X at compile time, in which case this initialization
8535 can be done by the loader, and requires no initialization code. It
8536 is not possible to document the precise conditions under which the
8537 optimizer can figure this out.
8538
8539 Note that this the implementation of this restriction requires full
8540 code generation. If it is used in conjunction with "semantics only"
8541 checking, then some cases of violations may be missed.
8542
8543 @item No_Entry_Queue
8544 @findex No_Entry_Queue
8545 This restriction is a declaration that any protected entry compiled in
8546 the scope of the restriction has at most one task waiting on the entry
8547 at any one time, and so no queue is required.  This restriction is not
8548 checked at compile time.  A program execution is erroneous if an attempt
8549 is made to queue a second task on such an entry.
8550
8551 @item No_Implementation_Attributes
8552 @findex No_Implementation_Attributes
8553 This restriction checks at compile time that no GNAT-defined attributes
8554 are present.  With this restriction, the only attributes that can be used
8555 are those defined in the Ada Reference Manual.
8556
8557 @item No_Implementation_Pragmas
8558 @findex No_Implementation_Pragmas
8559 This restriction checks at compile time that no GNAT-defined pragmas
8560 are present.  With this restriction, the only pragmas that can be used
8561 are those defined in the Ada Reference Manual.
8562
8563 @item No_Implementation_Restrictions
8564 @findex No_Implementation_Restrictions
8565 This restriction checks at compile time that no GNAT-defined restriction
8566 identifiers (other than @code{No_Implementation_Restrictions} itself)
8567 are present.  With this restriction, the only other restriction identifiers
8568 that can be used are those defined in the Ada Reference Manual.
8569
8570 @item No_Wide_Characters
8571 @findex No_Wide_Characters
8572 This restriction ensures at compile time that no uses of the types
8573 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8574 wide types
8575 appear, and that no wide or wide wide string or character literals
8576 appear in the program (that is literals representing characters not in
8577 type @code{Character}.
8578
8579 @end table
8580
8581 @sp 1
8582 @cartouche
8583 @noindent
8584 @strong{58}.  The consequences of violating limitations on
8585 @code{Restrictions} pragmas.  See 13.12(9).
8586 @end cartouche
8587 @noindent
8588 Restrictions that can be checked at compile time result in illegalities
8589 if violated.  Currently there are no other consequences of violating
8590 restrictions.
8591
8592 @sp 1
8593 @cartouche
8594 @noindent
8595 @strong{59}.  The representation used by the @code{Read} and
8596 @code{Write} attributes of elementary types in terms of stream
8597 elements.  See 13.13.2(9).
8598 @end cartouche
8599 @noindent
8600 The representation is the in-memory representation of the base type of
8601 the type, using the number of bits corresponding to the
8602 @code{@var{type}'Size} value, and the natural ordering of the machine.
8603
8604 @sp 1
8605 @cartouche
8606 @noindent
8607 @strong{60}.  The names and characteristics of the numeric subtypes
8608 declared in the visible part of package @code{Standard}.  See A.1(3).
8609 @end cartouche
8610 @noindent
8611 See items describing the integer and floating-point types supported.
8612
8613 @sp 1
8614 @cartouche
8615 @noindent
8616 @strong{61}.  The accuracy actually achieved by the elementary
8617 functions.  See A.5.1(1).
8618 @end cartouche
8619 @noindent
8620 The elementary functions correspond to the functions available in the C
8621 library.  Only fast math mode is implemented.
8622
8623 @sp 1
8624 @cartouche
8625 @noindent
8626 @strong{62}.  The sign of a zero result from some of the operators or
8627 functions in @code{Numerics.Generic_Elementary_Functions}, when
8628 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8629 @end cartouche
8630 @noindent
8631 The sign of zeroes follows the requirements of the IEEE 754 standard on
8632 floating-point.
8633
8634 @sp 1
8635 @cartouche
8636 @noindent
8637 @strong{63}.  The value of
8638 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8639 @end cartouche
8640 @noindent
8641 Maximum image width is 649, see library file @file{a-numran.ads}.
8642
8643 @sp 1
8644 @cartouche
8645 @noindent
8646 @strong{64}.  The value of
8647 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8648 @end cartouche
8649 @noindent
8650 Maximum image width is 80, see library file @file{a-nudira.ads}.
8651
8652 @sp 1
8653 @cartouche
8654 @noindent
8655 @strong{65}.  The algorithms for random number generation.  See
8656 A.5.2(32).
8657 @end cartouche
8658 @noindent
8659 The algorithm is documented in the source files @file{a-numran.ads} and
8660 @file{a-numran.adb}.
8661
8662 @sp 1
8663 @cartouche
8664 @noindent
8665 @strong{66}.  The string representation of a random number generator's
8666 state.  See A.5.2(38).
8667 @end cartouche
8668 @noindent
8669 See the documentation contained in the file @file{a-numran.adb}.
8670
8671 @sp 1
8672 @cartouche
8673 @noindent
8674 @strong{67}.  The minimum time interval between calls to the
8675 time-dependent Reset procedure that are guaranteed to initiate different
8676 random number sequences.  See A.5.2(45).
8677 @end cartouche
8678 @noindent
8679 The minimum period between reset calls to guarantee distinct series of
8680 random numbers is one microsecond.
8681
8682 @sp 1
8683 @cartouche
8684 @noindent
8685 @strong{68}.  The values of the @code{Model_Mantissa},
8686 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8687 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8688 Annex is not supported.  See A.5.3(72).
8689 @end cartouche
8690 @noindent
8691 See the source file @file{ttypef.ads} for the values of all numeric
8692 attributes.
8693
8694 @sp 1
8695 @cartouche
8696 @noindent
8697 @strong{69}.  Any implementation-defined characteristics of the
8698 input-output packages.  See A.7(14).
8699 @end cartouche
8700 @noindent
8701 There are no special implementation defined characteristics for these
8702 packages.
8703
8704 @sp 1
8705 @cartouche
8706 @noindent
8707 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8708 A.9(10).
8709 @end cartouche
8710 @noindent
8711 All type representations are contiguous, and the @code{Buffer_Size} is
8712 the value of @code{@var{type}'Size} rounded up to the next storage unit
8713 boundary.
8714
8715 @sp 1
8716 @cartouche
8717 @noindent
8718 @strong{71}.  External files for standard input, standard output, and
8719 standard error See A.10(5).
8720 @end cartouche
8721 @noindent
8722 These files are mapped onto the files provided by the C streams
8723 libraries.  See source file @file{i-cstrea.ads} for further details.
8724
8725 @sp 1
8726 @cartouche
8727 @noindent
8728 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8729 A.10.9(36).
8730 @end cartouche
8731 @noindent
8732 If more digits are requested in the output than are represented by the
8733 precision of the value, zeroes are output in the corresponding least
8734 significant digit positions.
8735
8736 @sp 1
8737 @cartouche
8738 @noindent
8739 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8740 @code{Command_Name}.  See A.15(1).
8741 @end cartouche
8742 @noindent
8743 These are mapped onto the @code{argv} and @code{argc} parameters of the
8744 main program in the natural manner.
8745
8746 @sp 1
8747 @cartouche
8748 @noindent
8749 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8750 @end cartouche
8751 @noindent
8752 The following convention names are supported
8753
8754 @table @code
8755 @item  Ada
8756 Ada
8757 @item Assembler
8758 Assembly language
8759 @item Asm
8760 Synonym for Assembler
8761 @item Assembly
8762 Synonym for Assembler
8763 @item C
8764 C
8765 @item C_Pass_By_Copy
8766 Allowed only for record types, like C, but also notes that record
8767 is to be passed by copy rather than reference.
8768 @item COBOL
8769 COBOL
8770 @item C_Plus_Plus (or CPP)
8771 C++
8772 @item Default
8773 Treated the same as C
8774 @item External
8775 Treated the same as C
8776 @item Fortran
8777 Fortran
8778 @item Intrinsic
8779 For support of pragma @code{Import} with convention Intrinsic, see
8780 separate section on Intrinsic Subprograms.
8781 @item Stdcall
8782 Stdcall (used for Windows implementations only).  This convention correspond
8783 to the WINAPI (previously called Pascal convention) C/C++ convention under
8784 Windows.  A function with this convention cleans the stack before exit.
8785 @item DLL
8786 Synonym for Stdcall
8787 @item Win32
8788 Synonym for Stdcall
8789 @item Stubbed
8790 Stubbed is a special convention used to indicate that the body of the
8791 subprogram will be entirely ignored.  Any call to the subprogram
8792 is converted into a raise of the @code{Program_Error} exception.  If a
8793 pragma @code{Import} specifies convention @code{stubbed} then no body need
8794 be present at all.  This convention is useful during development for the
8795 inclusion of subprograms whose body has not yet been written.
8796
8797 @end table
8798 @noindent
8799 In addition, all otherwise unrecognized convention names are also
8800 treated as being synonymous with convention C@.  In all implementations
8801 except for VMS, use of such other names results in a warning.  In VMS
8802 implementations, these names are accepted silently.
8803
8804 @sp 1
8805 @cartouche
8806 @noindent
8807 @strong{75}.  The meaning of link names.  See B.1(36).
8808 @end cartouche
8809 @noindent
8810 Link names are the actual names used by the linker.
8811
8812 @sp 1
8813 @cartouche
8814 @noindent
8815 @strong{76}.  The manner of choosing link names when neither the link
8816 name nor the address of an imported or exported entity is specified.  See
8817 B.1(36).
8818 @end cartouche
8819 @noindent
8820 The default linker name is that which would be assigned by the relevant
8821 external language, interpreting the Ada name as being in all lower case
8822 letters.
8823
8824 @sp 1
8825 @cartouche
8826 @noindent
8827 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8828 @end cartouche
8829 @noindent
8830 The string passed to @code{Linker_Options} is presented uninterpreted as
8831 an argument to the link command, unless it contains ASCII.NUL characters.
8832 NUL characters if they appear act as argument separators, so for example
8833
8834 @smallexample @c ada
8835 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8836 @end smallexample
8837
8838 @noindent
8839 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8840 linker. The order of linker options is preserved for a given unit. The final
8841 list of options passed to the linker is in reverse order of the elaboration
8842 order. For example, linker options for a body always appear before the options
8843 from the corresponding package spec.
8844
8845 @sp 1
8846 @cartouche
8847 @noindent
8848 @strong{78}.  The contents of the visible part of package
8849 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8850 @end cartouche
8851 @noindent
8852 See files with prefix @file{i-} in the distributed library.
8853
8854 @sp 1
8855 @cartouche
8856 @noindent
8857 @strong{79}.  Implementation-defined children of package
8858 @code{Interfaces}.  The contents of the visible part of package
8859 @code{Interfaces}.  See B.2(11).
8860 @end cartouche
8861 @noindent
8862 See files with prefix @file{i-} in the distributed library.
8863
8864 @sp 1
8865 @cartouche
8866 @noindent
8867 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8868 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8869 @code{COBOL_Character}; and the initialization of the variables
8870 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8871 @code{Interfaces.COBOL}.  See B.4(50).
8872 @end cartouche
8873 @noindent
8874 @table @code
8875 @item Floating
8876 Float
8877 @item Long_Floating
8878 (Floating) Long_Float
8879 @item Binary
8880 Integer
8881 @item Long_Binary
8882 Long_Long_Integer
8883 @item Decimal_Element
8884 Character
8885 @item COBOL_Character
8886 Character
8887 @end table
8888
8889 @noindent
8890 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8891
8892 @sp 1
8893 @cartouche
8894 @noindent
8895 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8896 @end cartouche
8897 @noindent
8898 See documentation in file @file{s-maccod.ads} in the distributed library.
8899
8900 @sp 1
8901 @cartouche
8902 @noindent
8903 @strong{82}.  Implementation-defined aspects of access to machine
8904 operations.  See C.1(9).
8905 @end cartouche
8906 @noindent
8907 See documentation in file @file{s-maccod.ads} in the distributed library.
8908
8909 @sp 1
8910 @cartouche
8911 @noindent
8912 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8913 @end cartouche
8914 @noindent
8915 Interrupts are mapped to signals or conditions as appropriate.  See
8916 definition of unit
8917 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8918 on the interrupts supported on a particular target.
8919
8920 @sp 1
8921 @cartouche
8922 @noindent
8923 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8924 C.4(13).
8925 @end cartouche
8926 @noindent
8927 GNAT does not permit a partition to be restarted without reloading,
8928 except under control of the debugger.
8929
8930 @sp 1
8931 @cartouche
8932 @noindent
8933 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8934 @end cartouche
8935 @noindent
8936 Pragma @code{Discard_Names} causes names of enumeration literals to
8937 be suppressed.  In the presence of this pragma, the Image attribute
8938 provides the image of the Pos of the literal, and Value accepts
8939 Pos values.
8940
8941 @sp 1
8942 @cartouche
8943 @noindent
8944 @strong{86}.  The result of the @code{Task_Identification.Image}
8945 attribute.  See C.7.1(7).
8946 @end cartouche
8947 @noindent
8948 The result of this attribute is a string that identifies
8949 the object or component that denotes a given task. If a variable @code{Var}
8950 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
8951 where the suffix
8952 is the hexadecimal representation of the virtual address of the corresponding
8953 task control block. If the variable is an array of tasks, the image of each
8954 task will have the form of an indexed component indicating the position of a
8955 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
8956 component of a record, the image of the task will have the form of a selected
8957 component. These rules are fully recursive, so that the image of a task that
8958 is a subcomponent of a composite object corresponds to the expression that
8959 designates this task.
8960 @noindent
8961 If a task is created by an allocator, its image depends on the context. If the
8962 allocator is part of an object declaration, the rules described above are used
8963 to construct its image, and this image is not affected by subsequent
8964 assignments. If the allocator appears within an expression, the image
8965 includes only the name of the task type.
8966 @noindent
8967 If the configuration pragma Discard_Names is present, or if the restriction
8968 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8969 the numeric suffix, that is to say the hexadecimal representation of the
8970 virtual address of the control block of the task.
8971 @sp 1
8972 @cartouche
8973 @noindent
8974 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8975 or interrupt handler.  See C.7.1(17).
8976 @end cartouche
8977 @noindent
8978 Protected entries or interrupt handlers can be executed by any
8979 convenient thread, so the value of @code{Current_Task} is undefined.
8980
8981 @sp 1
8982 @cartouche
8983 @noindent
8984 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8985 body or interrupt handler.  See C.7.1(19).
8986 @end cartouche
8987 @noindent
8988 The effect of calling @code{Current_Task} from an entry body or
8989 interrupt handler is to return the identification of the task currently
8990 executing the code.
8991
8992 @sp 1
8993 @cartouche
8994 @noindent
8995 @strong{89}.  Implementation-defined aspects of
8996 @code{Task_Attributes}.  See C.7.2(19).
8997 @end cartouche
8998 @noindent
8999 There are no implementation-defined aspects of @code{Task_Attributes}.
9000
9001 @sp 1
9002 @cartouche
9003 @noindent
9004 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9005 @end cartouche
9006 @noindent
9007 The metrics information for GNAT depends on the performance of the
9008 underlying operating system.  The sources of the run-time for tasking
9009 implementation, together with the output from @option{-gnatG} can be
9010 used to determine the exact sequence of operating systems calls made
9011 to implement various tasking constructs.  Together with appropriate
9012 information on the performance of the underlying operating system,
9013 on the exact target in use, this information can be used to determine
9014 the required metrics.
9015
9016 @sp 1
9017 @cartouche
9018 @noindent
9019 @strong{91}.  The declarations of @code{Any_Priority} and
9020 @code{Priority}.  See D.1(11).
9021 @end cartouche
9022 @noindent
9023 See declarations in file @file{system.ads}.
9024
9025 @sp 1
9026 @cartouche
9027 @noindent
9028 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9029 @end cartouche
9030 @noindent
9031 There are no implementation-defined execution resources.
9032
9033 @sp 1
9034 @cartouche
9035 @noindent
9036 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9037 access to a protected object keeps its processor busy.  See D.2.1(3).
9038 @end cartouche
9039 @noindent
9040 On a multi-processor, a task that is waiting for access to a protected
9041 object does not keep its processor busy.
9042
9043 @sp 1
9044 @cartouche
9045 @noindent
9046 @strong{94}.  The affect of implementation defined execution resources
9047 on task dispatching.  See D.2.1(9).
9048 @end cartouche
9049 @noindent
9050 @c SGI info
9051 @ignore
9052 Tasks map to IRIX threads, and the dispatching policy is as defined by
9053 the IRIX implementation of threads.
9054 @end ignore
9055 Tasks map to threads in the threads package used by GNAT@.  Where possible
9056 and appropriate, these threads correspond to native threads of the
9057 underlying operating system.
9058
9059 @sp 1
9060 @cartouche
9061 @noindent
9062 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9063 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9064 @end cartouche
9065 @noindent
9066 There are no implementation-defined policy-identifiers allowed in this
9067 pragma.
9068
9069 @sp 1
9070 @cartouche
9071 @noindent
9072 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9073 D.2.2(16).
9074 @end cartouche
9075 @noindent
9076 Execution of a task cannot be preempted by the implementation processing
9077 of delay expirations for lower priority tasks.
9078
9079 @sp 1
9080 @cartouche
9081 @noindent
9082 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9083 @end cartouche
9084 @noindent
9085 @c SGI info:
9086 @ignore
9087 Tasks map to IRIX threads, and the dispatching policy is as defined by
9088 the IRIX implementation of threads.
9089 @end ignore
9090 The policy is the same as that of the underlying threads implementation.
9091
9092 @sp 1
9093 @cartouche
9094 @noindent
9095 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9096 in a pragma @code{Locking_Policy}.  See D.3(4).
9097 @end cartouche
9098 @noindent
9099 The only implementation defined policy permitted in GNAT is
9100 @code{Inheritance_Locking}.  On targets that support this policy, locking
9101 is implemented by inheritance, i.e.@: the task owning the lock operates
9102 at a priority equal to the highest priority of any task currently
9103 requesting the lock.
9104
9105 @sp 1
9106 @cartouche
9107 @noindent
9108 @strong{99}.  Default ceiling priorities.  See D.3(10).
9109 @end cartouche
9110 @noindent
9111 The ceiling priority of protected objects of the type
9112 @code{System.Interrupt_Priority'Last} as described in the Ada
9113 Reference Manual D.3(10),
9114
9115 @sp 1
9116 @cartouche
9117 @noindent
9118 @strong{100}.  The ceiling of any protected object used internally by
9119 the implementation.  See D.3(16).
9120 @end cartouche
9121 @noindent
9122 The ceiling priority of internal protected objects is
9123 @code{System.Priority'Last}.
9124
9125 @sp 1
9126 @cartouche
9127 @noindent
9128 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9129 @end cartouche
9130 @noindent
9131 There are no implementation-defined queuing policies.
9132
9133 @sp 1
9134 @cartouche
9135 @noindent
9136 @strong{102}.  On a multiprocessor, any conditions that cause the
9137 completion of an aborted construct to be delayed later than what is
9138 specified for a single processor.  See D.6(3).
9139 @end cartouche
9140 @noindent
9141 The semantics for abort on a multi-processor is the same as on a single
9142 processor, there are no further delays.
9143
9144 @sp 1
9145 @cartouche
9146 @noindent
9147 @strong{103}.  Any operations that implicitly require heap storage
9148 allocation.  See D.7(8).
9149 @end cartouche
9150 @noindent
9151 The only operation that implicitly requires heap storage allocation is
9152 task creation.
9153
9154 @sp 1
9155 @cartouche
9156 @noindent
9157 @strong{104}.  Implementation-defined aspects of pragma
9158 @code{Restrictions}.  See D.7(20).
9159 @end cartouche
9160 @noindent
9161 There are no such implementation-defined aspects.
9162
9163 @sp 1
9164 @cartouche
9165 @noindent
9166 @strong{105}.  Implementation-defined aspects of package
9167 @code{Real_Time}.  See D.8(17).
9168 @end cartouche
9169 @noindent
9170 There are no implementation defined aspects of package @code{Real_Time}.
9171
9172 @sp 1
9173 @cartouche
9174 @noindent
9175 @strong{106}.  Implementation-defined aspects of
9176 @code{delay_statements}.  See D.9(8).
9177 @end cartouche
9178 @noindent
9179 Any difference greater than one microsecond will cause the task to be
9180 delayed (see D.9(7)).
9181
9182 @sp 1
9183 @cartouche
9184 @noindent
9185 @strong{107}.  The upper bound on the duration of interrupt blocking
9186 caused by the implementation.  See D.12(5).
9187 @end cartouche
9188 @noindent
9189 The upper bound is determined by the underlying operating system.  In
9190 no cases is it more than 10 milliseconds.
9191
9192 @sp 1
9193 @cartouche
9194 @noindent
9195 @strong{108}.  The means for creating and executing distributed
9196 programs.  See E(5).
9197 @end cartouche
9198 @noindent
9199 The GLADE package provides a utility GNATDIST for creating and executing
9200 distributed programs.  See the GLADE reference manual for further details.
9201
9202 @sp 1
9203 @cartouche
9204 @noindent
9205 @strong{109}.  Any events that can result in a partition becoming
9206 inaccessible.  See E.1(7).
9207 @end cartouche
9208 @noindent
9209 See the GLADE reference manual for full details on such events.
9210
9211 @sp 1
9212 @cartouche
9213 @noindent
9214 @strong{110}.  The scheduling policies, treatment of priorities, and
9215 management of shared resources between partitions in certain cases.  See
9216 E.1(11).
9217 @end cartouche
9218 @noindent
9219 See the GLADE reference manual for full details on these aspects of
9220 multi-partition execution.
9221
9222 @sp 1
9223 @cartouche
9224 @noindent
9225 @strong{111}.  Events that cause the version of a compilation unit to
9226 change.  See E.3(5).
9227 @end cartouche
9228 @noindent
9229 Editing the source file of a compilation unit, or the source files of
9230 any units on which it is dependent in a significant way cause the version
9231 to change.  No other actions cause the version number to change.  All changes
9232 are significant except those which affect only layout, capitalization or
9233 comments.
9234
9235 @sp 1
9236 @cartouche
9237 @noindent
9238 @strong{112}.  Whether the execution of the remote subprogram is
9239 immediately aborted as a result of cancellation.  See E.4(13).
9240 @end cartouche
9241 @noindent
9242 See the GLADE reference manual for details on the effect of abort in
9243 a distributed application.
9244
9245 @sp 1
9246 @cartouche
9247 @noindent
9248 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9249 @end cartouche
9250 @noindent
9251 See the GLADE reference manual for a full description of all implementation
9252 defined aspects of the PCS@.
9253
9254 @sp 1
9255 @cartouche
9256 @noindent
9257 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9258 E.5(26).
9259 @end cartouche
9260 @noindent
9261 See the GLADE reference manual for a full description of all
9262 implementation defined interfaces.
9263
9264 @sp 1
9265 @cartouche
9266 @noindent
9267 @strong{115}.  The values of named numbers in the package
9268 @code{Decimal}.  See F.2(7).
9269 @end cartouche
9270 @noindent
9271 @table @code
9272 @item Max_Scale
9273 +18
9274 @item Min_Scale
9275 -18
9276 @item Min_Delta
9277 1.0E-18
9278 @item Max_Delta
9279 1.0E+18
9280 @item Max_Decimal_Digits
9281 18
9282 @end table
9283
9284 @sp 1
9285 @cartouche
9286 @noindent
9287 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9288 @code{Text_IO.Editing}.  See F.3.3(16).
9289 @end cartouche
9290 @noindent
9291 64
9292
9293 @sp 1
9294 @cartouche
9295 @noindent
9296 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9297 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9298 @end cartouche
9299 @noindent
9300 64
9301
9302 @sp 1
9303 @cartouche
9304 @noindent
9305 @strong{118}.  The accuracy actually achieved by the complex elementary
9306 functions and by other complex arithmetic operations.  See G.1(1).
9307 @end cartouche
9308 @noindent
9309 Standard library functions are used for the complex arithmetic
9310 operations.  Only fast math mode is currently supported.
9311
9312 @sp 1
9313 @cartouche
9314 @noindent
9315 @strong{119}.  The sign of a zero result (or a component thereof) from
9316 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9317 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9318 @end cartouche
9319 @noindent
9320 The signs of zero values are as recommended by the relevant
9321 implementation advice.
9322
9323 @sp 1
9324 @cartouche
9325 @noindent
9326 @strong{120}.  The sign of a zero result (or a component thereof) from
9327 any operator or function in
9328 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9329 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9330 @end cartouche
9331 @noindent
9332 The signs of zero values are as recommended by the relevant
9333 implementation advice.
9334
9335 @sp 1
9336 @cartouche
9337 @noindent
9338 @strong{121}.  Whether the strict mode or the relaxed mode is the
9339 default.  See G.2(2).
9340 @end cartouche
9341 @noindent
9342 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9343 provides a highly efficient implementation of strict mode.
9344
9345 @sp 1
9346 @cartouche
9347 @noindent
9348 @strong{122}.  The result interval in certain cases of fixed-to-float
9349 conversion.  See G.2.1(10).
9350 @end cartouche
9351 @noindent
9352 For cases where the result interval is implementation dependent, the
9353 accuracy is that provided by performing all operations in 64-bit IEEE
9354 floating-point format.
9355
9356 @sp 1
9357 @cartouche
9358 @noindent
9359 @strong{123}.  The result of a floating point arithmetic operation in
9360 overflow situations, when the @code{Machine_Overflows} attribute of the
9361 result type is @code{False}.  See G.2.1(13).
9362 @end cartouche
9363 @noindent
9364 Infinite and NaN values are produced as dictated by the IEEE
9365 floating-point standard.
9366
9367 Note that on machines that are not fully compliant with the IEEE
9368 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9369 must be used for achieving IEEE confirming behavior (although at the cost
9370 of a significant performance penalty), so infinite and NaN values are
9371 properly generated.
9372
9373 @sp 1
9374 @cartouche
9375 @noindent
9376 @strong{124}.  The result interval for division (or exponentiation by a
9377 negative exponent), when the floating point hardware implements division
9378 as multiplication by a reciprocal.  See G.2.1(16).
9379 @end cartouche
9380 @noindent
9381 Not relevant, division is IEEE exact.
9382
9383 @sp 1
9384 @cartouche
9385 @noindent
9386 @strong{125}.  The definition of close result set, which determines the
9387 accuracy of certain fixed point multiplications and divisions.  See
9388 G.2.3(5).
9389 @end cartouche
9390 @noindent
9391 Operations in the close result set are performed using IEEE long format
9392 floating-point arithmetic.  The input operands are converted to
9393 floating-point, the operation is done in floating-point, and the result
9394 is converted to the target type.
9395
9396 @sp 1
9397 @cartouche
9398 @noindent
9399 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9400 point multiplication or division for which the result shall be in the
9401 perfect result set.  See G.2.3(22).
9402 @end cartouche
9403 @noindent
9404 The result is only defined to be in the perfect result set if the result
9405 can be computed by a single scaling operation involving a scale factor
9406 representable in 64-bits.
9407
9408 @sp 1
9409 @cartouche
9410 @noindent
9411 @strong{127}.  The result of a fixed point arithmetic operation in
9412 overflow situations, when the @code{Machine_Overflows} attribute of the
9413 result type is @code{False}.  See G.2.3(27).
9414 @end cartouche
9415 @noindent
9416 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9417 types.
9418
9419 @sp 1
9420 @cartouche
9421 @noindent
9422 @strong{128}.  The result of an elementary function reference in
9423 overflow situations, when the @code{Machine_Overflows} attribute of the
9424 result type is @code{False}.  See G.2.4(4).
9425 @end cartouche
9426 @noindent
9427 IEEE infinite and Nan values are produced as appropriate.
9428
9429 @sp 1
9430 @cartouche
9431 @noindent
9432 @strong{129}.  The value of the angle threshold, within which certain
9433 elementary functions, complex arithmetic operations, and complex
9434 elementary functions yield results conforming to a maximum relative
9435 error bound.  See G.2.4(10).
9436 @end cartouche
9437 @noindent
9438 Information on this subject is not yet available.
9439
9440 @sp 1
9441 @cartouche
9442 @noindent
9443 @strong{130}.  The accuracy of certain elementary functions for
9444 parameters beyond the angle threshold.  See G.2.4(10).
9445 @end cartouche
9446 @noindent
9447 Information on this subject is not yet available.
9448
9449 @sp 1
9450 @cartouche
9451 @noindent
9452 @strong{131}.  The result of a complex arithmetic operation or complex
9453 elementary function reference in overflow situations, when the
9454 @code{Machine_Overflows} attribute of the corresponding real type is
9455 @code{False}.  See G.2.6(5).
9456 @end cartouche
9457 @noindent
9458 IEEE infinite and Nan values are produced as appropriate.
9459
9460 @sp 1
9461 @cartouche
9462 @noindent
9463 @strong{132}.  The accuracy of certain complex arithmetic operations and
9464 certain complex elementary functions for parameters (or components
9465 thereof) beyond the angle threshold.  See G.2.6(8).
9466 @end cartouche
9467 @noindent
9468 Information on those subjects is not yet available.
9469
9470 @sp 1
9471 @cartouche
9472 @noindent
9473 @strong{133}.  Information regarding bounded errors and erroneous
9474 execution.  See H.2(1).
9475 @end cartouche
9476 @noindent
9477 Information on this subject is not yet available.
9478
9479 @sp 1
9480 @cartouche
9481 @noindent
9482 @strong{134}.  Implementation-defined aspects of pragma
9483 @code{Inspection_Point}.  See H.3.2(8).
9484 @end cartouche
9485 @noindent
9486 Pragma @code{Inspection_Point} ensures that the variable is live and can
9487 be examined by the debugger at the inspection point.
9488
9489 @sp 1
9490 @cartouche
9491 @noindent
9492 @strong{135}.  Implementation-defined aspects of pragma
9493 @code{Restrictions}.  See H.4(25).
9494 @end cartouche
9495 @noindent
9496 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9497 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9498 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9499
9500 @sp 1
9501 @cartouche
9502 @noindent
9503 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9504 H.4(27).
9505 @end cartouche
9506 @noindent
9507 There are no restrictions on pragma @code{Restrictions}.
9508
9509 @node Intrinsic Subprograms
9510 @chapter Intrinsic Subprograms
9511 @cindex Intrinsic Subprograms
9512
9513 @menu
9514 * Intrinsic Operators::
9515 * Enclosing_Entity::
9516 * Exception_Information::
9517 * Exception_Message::
9518 * Exception_Name::
9519 * File::
9520 * Line::
9521 * Rotate_Left::
9522 * Rotate_Right::
9523 * Shift_Left::
9524 * Shift_Right::
9525 * Shift_Right_Arithmetic::
9526 * Source_Location::
9527 @end menu
9528
9529 @noindent
9530 GNAT allows a user application program to write the declaration:
9531
9532 @smallexample @c ada
9533    pragma Import (Intrinsic, name);
9534 @end smallexample
9535
9536 @noindent
9537 providing that the name corresponds to one of the implemented intrinsic
9538 subprograms in GNAT, and that the parameter profile of the referenced
9539 subprogram meets the requirements.  This chapter describes the set of
9540 implemented intrinsic subprograms, and the requirements on parameter profiles.
9541 Note that no body is supplied; as with other uses of pragma Import, the
9542 body is supplied elsewhere (in this case by the compiler itself).  Note
9543 that any use of this feature is potentially non-portable, since the
9544 Ada standard does not require Ada compilers to implement this feature.
9545
9546 @node Intrinsic Operators
9547 @section Intrinsic Operators
9548 @cindex Intrinsic operator
9549
9550 @noindent
9551 All the predefined numeric operators in package Standard
9552 in @code{pragma Import (Intrinsic,..)}
9553 declarations.  In the binary operator case, the operands must have the same
9554 size.  The operand or operands must also be appropriate for
9555 the operator.  For example, for addition, the operands must
9556 both be floating-point or both be fixed-point, and the
9557 right operand for @code{"**"} must have a root type of
9558 @code{Standard.Integer'Base}.
9559 You can use an intrinsic operator declaration as in the following example:
9560
9561 @smallexample @c ada
9562    type Int1 is new Integer;
9563    type Int2 is new Integer;
9564
9565    function "+" (X1 : Int1; X2 : Int2) return Int1;
9566    function "+" (X1 : Int1; X2 : Int2) return Int2;
9567    pragma Import (Intrinsic, "+");
9568 @end smallexample
9569
9570 @noindent
9571 This declaration would permit ``mixed mode'' arithmetic on items
9572 of the differing types @code{Int1} and @code{Int2}.
9573 It is also possible to specify such operators for private types, if the
9574 full views are appropriate arithmetic types.
9575
9576 @node Enclosing_Entity
9577 @section Enclosing_Entity
9578 @cindex Enclosing_Entity
9579 @noindent
9580 This intrinsic subprogram is used in the implementation of the
9581 library routine @code{GNAT.Source_Info}.  The only useful use of the
9582 intrinsic import in this case is the one in this unit, so an
9583 application program should simply call the function
9584 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9585 the current subprogram, package, task, entry, or protected subprogram.
9586
9587 @node Exception_Information
9588 @section Exception_Information
9589 @cindex Exception_Information'
9590 @noindent
9591 This intrinsic subprogram is used in the implementation of the
9592 library routine @code{GNAT.Current_Exception}.  The only useful
9593 use of the intrinsic import in this case is the one in this unit,
9594 so an application program should simply call the function
9595 @code{GNAT.Current_Exception.Exception_Information} to obtain
9596 the exception information associated with the current exception.
9597
9598 @node Exception_Message
9599 @section Exception_Message
9600 @cindex Exception_Message
9601 @noindent
9602 This intrinsic subprogram is used in the implementation of the
9603 library routine @code{GNAT.Current_Exception}.  The only useful
9604 use of the intrinsic import in this case is the one in this unit,
9605 so an application program should simply call the function
9606 @code{GNAT.Current_Exception.Exception_Message} to obtain
9607 the message associated with the current exception.
9608
9609 @node Exception_Name
9610 @section Exception_Name
9611 @cindex Exception_Name
9612 @noindent
9613 This intrinsic subprogram is used in the implementation of the
9614 library routine @code{GNAT.Current_Exception}.  The only useful
9615 use of the intrinsic import in this case is the one in this unit,
9616 so an application program should simply call the function
9617 @code{GNAT.Current_Exception.Exception_Name} to obtain
9618 the name of the current exception.
9619
9620 @node File
9621 @section File
9622 @cindex File
9623 @noindent
9624 This intrinsic subprogram is used in the implementation of the
9625 library routine @code{GNAT.Source_Info}.  The only useful use of the
9626 intrinsic import in this case is the one in this unit, so an
9627 application program should simply call the function
9628 @code{GNAT.Source_Info.File} to obtain the name of the current
9629 file.
9630
9631 @node Line
9632 @section Line
9633 @cindex Line
9634 @noindent
9635 This intrinsic subprogram is used in the implementation of the
9636 library routine @code{GNAT.Source_Info}.  The only useful use of the
9637 intrinsic import in this case is the one in this unit, so an
9638 application program should simply call the function
9639 @code{GNAT.Source_Info.Line} to obtain the number of the current
9640 source line.
9641
9642 @node Rotate_Left
9643 @section Rotate_Left
9644 @cindex Rotate_Left
9645 @noindent
9646 In standard Ada, the @code{Rotate_Left} function is available only
9647 for the predefined modular types in package @code{Interfaces}.  However, in
9648 GNAT it is possible to define a Rotate_Left function for a user
9649 defined modular type or any signed integer type as in this example:
9650
9651 @smallexample @c ada
9652    function Shift_Left
9653      (Value  : My_Modular_Type;
9654       Amount : Natural)
9655       return   My_Modular_Type;
9656 @end smallexample
9657
9658 @noindent
9659 The requirements are that the profile be exactly as in the example
9660 above.  The only modifications allowed are in the formal parameter
9661 names, and in the type of @code{Value} and the return type, which
9662 must be the same, and must be either a signed integer type, or
9663 a modular integer type with a binary modulus, and the size must
9664 be 8.  16, 32 or 64 bits.
9665
9666 @node Rotate_Right
9667 @section Rotate_Right
9668 @cindex Rotate_Right
9669 @noindent
9670 A @code{Rotate_Right} function can be defined for any user defined
9671 binary modular integer type, or signed integer type, as described
9672 above for @code{Rotate_Left}.
9673
9674 @node Shift_Left
9675 @section Shift_Left
9676 @cindex Shift_Left
9677 @noindent
9678 A @code{Shift_Left} function can be defined for any user defined
9679 binary modular integer type, or signed integer type, as described
9680 above for @code{Rotate_Left}.
9681
9682 @node Shift_Right
9683 @section Shift_Right
9684 @cindex Shift_Right
9685 @noindent
9686 A @code{Shift_Right} function can be defined for any user defined
9687 binary modular integer type, or signed integer type, as described
9688 above for @code{Rotate_Left}.
9689
9690 @node Shift_Right_Arithmetic
9691 @section Shift_Right_Arithmetic
9692 @cindex Shift_Right_Arithmetic
9693 @noindent
9694 A @code{Shift_Right_Arithmetic} function can be defined for any user
9695 defined binary modular integer type, or signed integer type, as described
9696 above for @code{Rotate_Left}.
9697
9698 @node Source_Location
9699 @section Source_Location
9700 @cindex Source_Location
9701 @noindent
9702 This intrinsic subprogram is used in the implementation of the
9703 library routine @code{GNAT.Source_Info}.  The only useful use of the
9704 intrinsic import in this case is the one in this unit, so an
9705 application program should simply call the function
9706 @code{GNAT.Source_Info.Source_Location} to obtain the current
9707 source file location.
9708
9709 @node Representation Clauses and Pragmas
9710 @chapter Representation Clauses and Pragmas
9711 @cindex Representation Clauses
9712
9713 @menu
9714 * Alignment Clauses::
9715 * Size Clauses::
9716 * Storage_Size Clauses::
9717 * Size of Variant Record Objects::
9718 * Biased Representation ::
9719 * Value_Size and Object_Size Clauses::
9720 * Component_Size Clauses::
9721 * Bit_Order Clauses::
9722 * Effect of Bit_Order on Byte Ordering::
9723 * Pragma Pack for Arrays::
9724 * Pragma Pack for Records::
9725 * Record Representation Clauses::
9726 * Enumeration Clauses::
9727 * Address Clauses::
9728 * Effect of Convention on Representation::
9729 * Determining the Representations chosen by GNAT::
9730 @end menu
9731
9732 @noindent
9733 @cindex Representation Clause
9734 @cindex Representation Pragma
9735 @cindex Pragma, representation
9736 This section describes the representation clauses accepted by GNAT, and
9737 their effect on the representation of corresponding data objects.
9738
9739 GNAT fully implements Annex C (Systems Programming).  This means that all
9740 the implementation advice sections in chapter 13 are fully implemented.
9741 However, these sections only require a minimal level of support for
9742 representation clauses.  GNAT provides much more extensive capabilities,
9743 and this section describes the additional capabilities provided.
9744
9745 @node Alignment Clauses
9746 @section Alignment Clauses
9747 @cindex Alignment Clause
9748
9749 @noindent
9750 GNAT requires that all alignment clauses specify a power of 2, and all
9751 default alignments are always a power of 2.  The default alignment
9752 values are as follows:
9753
9754 @itemize @bullet
9755 @item @emph{Primitive Types}.
9756 For primitive types, the alignment is the minimum of the actual size of
9757 objects of the type divided by @code{Storage_Unit},
9758 and the maximum alignment supported by the target.
9759 (This maximum alignment is given by the GNAT-specific attribute
9760 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9761 @cindex @code{Maximum_Alignment} attribute
9762 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9763 default alignment will be 8 on any target that supports alignments
9764 this large, but on some targets, the maximum alignment may be smaller
9765 than 8, in which case objects of type @code{Long_Float} will be maximally
9766 aligned.
9767
9768 @item @emph{Arrays}.
9769 For arrays, the alignment is equal to the alignment of the component type
9770 for the normal case where no packing or component size is given.  If the
9771 array is packed, and the packing is effective (see separate section on
9772 packed arrays), then the alignment will be one for long packed arrays,
9773 or arrays whose length is not known at compile time.  For short packed
9774 arrays, which are handled internally as modular types, the alignment
9775 will be as described for primitive types, e.g.@: a packed array of length
9776 31 bits will have an object size of four bytes, and an alignment of 4.
9777
9778 @item @emph{Records}.
9779 For the normal non-packed case, the alignment of a record is equal to
9780 the maximum alignment of any of its components.  For tagged records, this
9781 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9782 is used and all components are packable (see separate section on pragma
9783 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9784 record makes it profitable to increase it.
9785
9786 A special case is when:
9787 @itemize @bullet
9788 @item
9789 the size of the record is given explicitly, or a
9790 full record representation clause is given, and
9791 @item
9792 the size of the record is 2, 4, or 8 bytes.
9793 @end itemize
9794 @noindent
9795 In this case, an alignment is chosen to match the
9796 size of the record. For example, if we have:
9797
9798 @smallexample @c ada
9799    type Small is record
9800       A, B : Character;
9801    end record;
9802    for Small'Size use 16;
9803 @end smallexample
9804
9805 @noindent
9806 then the default alignment of the record type @code{Small} is 2, not 1. This
9807 leads to more efficient code when the record is treated as a unit, and also
9808 allows the type to specified as @code{Atomic} on architectures requiring
9809 strict alignment.
9810
9811 @end itemize
9812
9813 @noindent
9814 An alignment clause may specify a larger alignment than the default value
9815 up to some maximum value dependent on the target (obtainable by using the
9816 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9817 a smaller alignment than the default value for enumeration, integer and
9818 fixed point types, as well as for record types, for example
9819
9820 @smallexample @c ada
9821   type V is record
9822      A : Integer;
9823   end record;
9824
9825   for V'alignment use 1;
9826 @end smallexample
9827
9828 @noindent
9829 @cindex Alignment, default
9830 The default alignment for the type @code{V} is 4, as a result of the
9831 Integer field in the record, but it is permissible, as shown, to
9832 override the default alignment of the record with a smaller value.
9833
9834 @node Size Clauses
9835 @section Size Clauses
9836 @cindex Size Clause
9837
9838 @noindent
9839 The default size for a type @code{T} is obtainable through the
9840 language-defined attribute @code{T'Size} and also through the
9841 equivalent GNAT-defined attribute @code{T'Value_Size}.
9842 For objects of type @code{T}, GNAT will generally increase the type size
9843 so that the object size (obtainable through the GNAT-defined attribute
9844 @code{T'Object_Size})
9845 is a multiple of @code{T'Alignment * Storage_Unit}.
9846 For example
9847
9848 @smallexample @c ada
9849    type Smallint is range 1 .. 6;
9850
9851    type Rec is record
9852       Y1 : integer;
9853       Y2 : boolean;
9854    end record;
9855 @end smallexample
9856
9857 @noindent
9858 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9859 as specified by the RM rules,
9860 but objects of this type will have a size of 8
9861 (@code{Smallint'Object_Size} = 8),
9862 since objects by default occupy an integral number
9863 of storage units.  On some targets, notably older
9864 versions of the Digital Alpha, the size of stand
9865 alone objects of this type may be 32, reflecting
9866 the inability of the hardware to do byte load/stores.
9867
9868 Similarly, the size of type @code{Rec} is 40 bits
9869 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9870 the alignment is 4, so objects of this type will have
9871 their size increased to 64 bits so that it is a multiple
9872 of the alignment (in bits).  This decision is
9873 in accordance with the specific Implementation Advice in RM 13.3(43):
9874
9875 @quotation
9876 A @code{Size} clause should be supported for an object if the specified
9877 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9878 to a size in storage elements that is a multiple of the object's
9879 @code{Alignment} (if the @code{Alignment} is nonzero).
9880 @end quotation
9881
9882 @noindent
9883 An explicit size clause may be used to override the default size by
9884 increasing it.  For example, if we have:
9885
9886 @smallexample @c ada
9887    type My_Boolean is new Boolean;
9888    for My_Boolean'Size use 32;
9889 @end smallexample
9890
9891 @noindent
9892 then values of this type will always be 32 bits long.  In the case of
9893 discrete types, the size can be increased up to 64 bits, with the effect
9894 that the entire specified field is used to hold the value, sign- or
9895 zero-extended as appropriate.  If more than 64 bits is specified, then
9896 padding space is allocated after the value, and a warning is issued that
9897 there are unused bits.
9898
9899 Similarly the size of records and arrays may be increased, and the effect
9900 is to add padding bits after the value.  This also causes a warning message
9901 to be generated.
9902
9903 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9904 Size in bits, this corresponds to an object of size 256 megabytes (minus
9905 one).  This limitation is true on all targets.  The reason for this
9906 limitation is that it improves the quality of the code in many cases
9907 if it is known that a Size value can be accommodated in an object of
9908 type Integer.
9909
9910 @node Storage_Size Clauses
9911 @section Storage_Size Clauses
9912 @cindex Storage_Size Clause
9913
9914 @noindent
9915 For tasks, the @code{Storage_Size} clause specifies the amount of space
9916 to be allocated for the task stack.  This cannot be extended, and if the
9917 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9918 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9919 or a @code{Storage_Size} pragma in the task definition to set the
9920 appropriate required size.  A useful technique is to include in every
9921 task definition a pragma of the form:
9922
9923 @smallexample @c ada
9924    pragma Storage_Size (Default_Stack_Size);
9925 @end smallexample
9926
9927 @noindent
9928 Then @code{Default_Stack_Size} can be defined in a global package, and
9929 modified as required. Any tasks requiring stack sizes different from the
9930 default can have an appropriate alternative reference in the pragma.
9931
9932 You can also use the @option{-d} binder switch to modify the default stack
9933 size.
9934
9935 For access types, the @code{Storage_Size} clause specifies the maximum
9936 space available for allocation of objects of the type.  If this space is
9937 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9938 In the case where the access type is declared local to a subprogram, the
9939 use of a @code{Storage_Size} clause triggers automatic use of a special
9940 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9941 space for the pool is automatically reclaimed on exit from the scope in
9942 which the type is declared.
9943
9944 A special case recognized by the compiler is the specification of a
9945 @code{Storage_Size} of zero for an access type.  This means that no
9946 items can be allocated from the pool, and this is recognized at compile
9947 time, and all the overhead normally associated with maintaining a fixed
9948 size storage pool is eliminated.  Consider the following example:
9949
9950 @smallexample @c ada
9951    procedure p is
9952       type R is array (Natural) of Character;
9953       type P is access all R;
9954       for P'Storage_Size use 0;
9955       --  Above access type intended only for interfacing purposes
9956
9957       y : P;
9958
9959       procedure g (m : P);
9960       pragma Import (C, g);
9961
9962       --  @dots{}
9963
9964    begin
9965       --  @dots{}
9966       y := new R;
9967    end;
9968 @end smallexample
9969
9970 @noindent
9971 As indicated in this example, these dummy storage pools are often useful in
9972 connection with interfacing where no object will ever be allocated.  If you
9973 compile the above example, you get the warning:
9974
9975 @smallexample
9976    p.adb:16:09: warning: allocation from empty storage pool
9977    p.adb:16:09: warning: Storage_Error will be raised at run time
9978 @end smallexample
9979
9980 @noindent
9981 Of course in practice, there will not be any explicit allocators in the
9982 case of such an access declaration.
9983
9984 @node Size of Variant Record Objects
9985 @section Size of Variant Record Objects
9986 @cindex Size, variant record objects
9987 @cindex Variant record objects, size
9988
9989 @noindent
9990 In the case of variant record objects, there is a question whether Size gives
9991 information about a particular variant, or the maximum size required
9992 for any variant.  Consider the following program
9993
9994 @smallexample @c ada
9995 with Text_IO; use Text_IO;
9996 procedure q is
9997    type R1 (A : Boolean := False) is record
9998      case A is
9999        when True  => X : Character;
10000        when False => null;
10001      end case;
10002    end record;
10003
10004    V1 : R1 (False);
10005    V2 : R1;
10006
10007 begin
10008    Put_Line (Integer'Image (V1'Size));
10009    Put_Line (Integer'Image (V2'Size));
10010 end q;
10011 @end smallexample
10012
10013 @noindent
10014 Here we are dealing with a variant record, where the True variant
10015 requires 16 bits, and the False variant requires 8 bits.
10016 In the above example, both V1 and V2 contain the False variant,
10017 which is only 8 bits long.  However, the result of running the
10018 program is:
10019
10020 @smallexample
10021 8
10022 16
10023 @end smallexample
10024
10025 @noindent
10026 The reason for the difference here is that the discriminant value of
10027 V1 is fixed, and will always be False.  It is not possible to assign
10028 a True variant value to V1, therefore 8 bits is sufficient.  On the
10029 other hand, in the case of V2, the initial discriminant value is
10030 False (from the default), but it is possible to assign a True
10031 variant value to V2, therefore 16 bits must be allocated for V2
10032 in the general case, even fewer bits may be needed at any particular
10033 point during the program execution.
10034
10035 As can be seen from the output of this program, the @code{'Size}
10036 attribute applied to such an object in GNAT gives the actual allocated
10037 size of the variable, which is the largest size of any of the variants.
10038 The Ada Reference Manual is not completely clear on what choice should
10039 be made here, but the GNAT behavior seems most consistent with the
10040 language in the RM@.
10041
10042 In some cases, it may be desirable to obtain the size of the current
10043 variant, rather than the size of the largest variant.  This can be
10044 achieved in GNAT by making use of the fact that in the case of a
10045 subprogram parameter, GNAT does indeed return the size of the current
10046 variant (because a subprogram has no way of knowing how much space
10047 is actually allocated for the actual).
10048
10049 Consider the following modified version of the above program:
10050
10051 @smallexample @c ada
10052 with Text_IO; use Text_IO;
10053 procedure q is
10054    type R1 (A : Boolean := False) is record
10055      case A is
10056        when True  => X : Character;
10057        when False => null;
10058      end case;
10059    end record;
10060
10061    V2 : R1;
10062
10063    function Size (V : R1) return Integer is
10064    begin
10065       return V'Size;
10066    end Size;
10067
10068 begin
10069    Put_Line (Integer'Image (V2'Size));
10070    Put_Line (Integer'IMage (Size (V2)));
10071    V2 := (True, 'x');
10072    Put_Line (Integer'Image (V2'Size));
10073    Put_Line (Integer'IMage (Size (V2)));
10074 end q;
10075 @end smallexample
10076
10077 @noindent
10078 The output from this program is
10079
10080 @smallexample
10081 16
10082 8
10083 16
10084 16
10085 @end smallexample
10086
10087 @noindent
10088 Here we see that while the @code{'Size} attribute always returns
10089 the maximum size, regardless of the current variant value, the
10090 @code{Size} function does indeed return the size of the current
10091 variant value.
10092
10093 @node Biased Representation
10094 @section Biased Representation
10095 @cindex Size for biased representation
10096 @cindex Biased representation
10097
10098 @noindent
10099 In the case of scalars with a range starting at other than zero, it is
10100 possible in some cases to specify a size smaller than the default minimum
10101 value, and in such cases, GNAT uses an unsigned biased representation,
10102 in which zero is used to represent the lower bound, and successive values
10103 represent successive values of the type.
10104
10105 For example, suppose we have the declaration:
10106
10107 @smallexample @c ada
10108    type Small is range -7 .. -4;
10109    for Small'Size use 2;
10110 @end smallexample
10111
10112 @noindent
10113 Although the default size of type @code{Small} is 4, the @code{Size}
10114 clause is accepted by GNAT and results in the following representation
10115 scheme:
10116
10117 @smallexample
10118   -7 is represented as 2#00#
10119   -6 is represented as 2#01#
10120   -5 is represented as 2#10#
10121   -4 is represented as 2#11#
10122 @end smallexample
10123
10124 @noindent
10125 Biased representation is only used if the specified @code{Size} clause
10126 cannot be accepted in any other manner.  These reduced sizes that force
10127 biased representation can be used for all discrete types except for
10128 enumeration types for which a representation clause is given.
10129
10130 @node Value_Size and Object_Size Clauses
10131 @section Value_Size and Object_Size Clauses
10132 @findex Value_Size
10133 @findex Object_Size
10134 @cindex Size, of objects
10135
10136 @noindent
10137 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10138 number of bits required to hold values of type @code{T}.
10139 Although this interpretation was allowed in Ada 83, it was not required,
10140 and this requirement in practice can cause some significant difficulties.
10141 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10142 However, in Ada 95 and Ada 2005,
10143 @code{Natural'Size} is
10144 typically 31.  This means that code may change in behavior when moving
10145 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10146
10147 @smallexample @c ada
10148    type Rec is record;
10149       A : Natural;
10150       B : Natural;
10151    end record;
10152
10153    for Rec use record
10154       at 0  range 0 .. Natural'Size - 1;
10155       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10156    end record;
10157 @end smallexample
10158
10159 @noindent
10160 In the above code, since the typical size of @code{Natural} objects
10161 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10162 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10163 there are cases where the fact that the object size can exceed the
10164 size of the type causes surprises.
10165
10166 To help get around this problem GNAT provides two implementation
10167 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10168 applied to a type, these attributes yield the size of the type
10169 (corresponding to the RM defined size attribute), and the size of
10170 objects of the type respectively.
10171
10172 The @code{Object_Size} is used for determining the default size of
10173 objects and components.  This size value can be referred to using the
10174 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10175 the basis of the determination of the size.  The backend is free to
10176 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10177 character might be stored in 32 bits on a machine with no efficient
10178 byte access instructions such as the Alpha.
10179
10180 The default rules for the value of @code{Object_Size} for
10181 discrete types are as follows:
10182
10183 @itemize @bullet
10184 @item
10185 The @code{Object_Size} for base subtypes reflect the natural hardware
10186 size in bits (run the compiler with @option{-gnatS} to find those values
10187 for numeric types). Enumeration types and fixed-point base subtypes have
10188 8, 16, 32 or 64 bits for this size, depending on the range of values
10189 to be stored.
10190
10191 @item
10192 The @code{Object_Size} of a subtype is the same as the
10193 @code{Object_Size} of
10194 the type from which it is obtained.
10195
10196 @item
10197 The @code{Object_Size} of a derived base type is copied from the parent
10198 base type, and the @code{Object_Size} of a derived first subtype is copied
10199 from the parent first subtype.
10200 @end itemize
10201
10202 @noindent
10203 The @code{Value_Size} attribute
10204 is the (minimum) number of bits required to store a value
10205 of the type.
10206 This value is used to determine how tightly to pack
10207 records or arrays with components of this type, and also affects
10208 the semantics of unchecked conversion (unchecked conversions where
10209 the @code{Value_Size} values differ generate a warning, and are potentially
10210 target dependent).
10211
10212 The default rules for the value of @code{Value_Size} are as follows:
10213
10214 @itemize @bullet
10215 @item
10216 The @code{Value_Size} for a base subtype is the minimum number of bits
10217 required to store all values of the type (including the sign bit
10218 only if negative values are possible).
10219
10220 @item
10221 If a subtype statically matches the first subtype of a given type, then it has
10222 by default the same @code{Value_Size} as the first subtype.  This is a
10223 consequence of RM 13.1(14) (``if two subtypes statically match,
10224 then their subtype-specific aspects are the same''.)
10225
10226 @item
10227 All other subtypes have a @code{Value_Size} corresponding to the minimum
10228 number of bits required to store all values of the subtype.  For
10229 dynamic bounds, it is assumed that the value can range down or up
10230 to the corresponding bound of the ancestor
10231 @end itemize
10232
10233 @noindent
10234 The RM defined attribute @code{Size} corresponds to the
10235 @code{Value_Size} attribute.
10236
10237 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10238 the @code{Value_Size} of
10239 the first-named subtype to the given value, and the
10240 @code{Object_Size} of this first-named subtype to the given value padded up
10241 to an appropriate boundary.  It is a consequence of the default rules
10242 above that this @code{Object_Size} will apply to all further subtypes.  On the
10243 other hand, @code{Value_Size} is affected only for the first subtype, any
10244 dynamic subtypes obtained from it directly, and any statically matching
10245 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10246
10247 @code{Value_Size} and
10248 @code{Object_Size} may be explicitly set for any subtype using
10249 an attribute definition clause.  Note that the use of these attributes
10250 can cause the RM 13.1(14) rule to be violated.  If two access types
10251 reference aliased objects whose subtypes have differing @code{Object_Size}
10252 values as a result of explicit attribute definition clauses, then it
10253 is erroneous to convert from one access subtype to the other.
10254
10255 At the implementation level, Esize stores the Object_Size and the
10256 RM_Size field stores the @code{Value_Size} (and hence the value of the
10257 @code{Size} attribute,
10258 which, as noted above, is equivalent to @code{Value_Size}).
10259
10260 To get a feel for the difference, consider the following examples (note
10261 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10262
10263 @smallexample
10264                                        Object_Size     Value_Size
10265
10266 type x1 is range 0 .. 5;                    8               3
10267
10268 type x2 is range 0 .. 5;
10269 for x2'size use 12;                        16              12
10270
10271 subtype x3 is x2 range 0 .. 3;             16               2
10272
10273 subtype x4 is x2'base range 0 .. 10;        8               4
10274
10275 subtype x5 is x2 range 0 .. dynamic;       16               3*
10276
10277 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10278
10279 @end smallexample
10280
10281 @noindent
10282 Note: the entries marked ``3*'' are not actually specified by the Ada
10283 Reference Manual, but it seems in the spirit of the RM rules to allocate
10284 the minimum number of bits (here 3, given the range for @code{x2})
10285 known to be large enough to hold the given range of values.
10286
10287 So far, so good, but GNAT has to obey the RM rules, so the question is
10288 under what conditions must the RM @code{Size} be used.
10289 The following is a list
10290 of the occasions on which the RM @code{Size} must be used:
10291
10292 @itemize @bullet
10293 @item
10294 Component size for packed arrays or records
10295
10296 @item
10297 Value of the attribute @code{Size} for a type
10298
10299 @item
10300 Warning about sizes not matching for unchecked conversion
10301 @end itemize
10302
10303 @noindent
10304 For record types, the @code{Object_Size} is always a multiple of the
10305 alignment of the type (this is true for all types). In some cases the
10306 @code{Value_Size} can be smaller. Consider:
10307
10308 @smallexample
10309    type R is record
10310      X : Integer;
10311      Y : Character;
10312    end record;
10313 @end smallexample
10314
10315 @noindent
10316 On a typical 32-bit architecture, the X component will be four bytes, and
10317 require four-byte alignment, and the Y component will be one byte. In this
10318 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10319 required to store a value of this type, and for example, it is permissible
10320 to have a component of type R in an outer record whose component size is
10321 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10322 since it must be rounded up so that this value is a multiple of the
10323 alignment (4 bytes = 32 bits).
10324
10325 @noindent
10326 For all other types, the @code{Object_Size}
10327 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10328 Only @code{Size} may be specified for such types.
10329
10330 @node Component_Size Clauses
10331 @section Component_Size Clauses
10332 @cindex Component_Size Clause
10333
10334 @noindent
10335 Normally, the value specified in a component size clause must be consistent
10336 with the subtype of the array component with regard to size and alignment.
10337 In other words, the value specified must be at least equal to the size
10338 of this subtype, and must be a multiple of the alignment value.
10339
10340 In addition, component size clauses are allowed which cause the array
10341 to be packed, by specifying a smaller value.  A first case is for
10342 component size values in the range 1 through 63.  The value specified
10343 must not be smaller than the Size of the subtype.  GNAT will accurately
10344 honor all packing requests in this range.  For example, if we have:
10345
10346 @smallexample @c ada
10347 type r is array (1 .. 8) of Natural;
10348 for r'Component_Size use 31;
10349 @end smallexample
10350
10351 @noindent
10352 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10353 Of course access to the components of such an array is considerably
10354 less efficient than if the natural component size of 32 is used.
10355 A second case is when the subtype of the component is a record type
10356 padded because of its default alignment.  For example, if we have:
10357
10358 @smallexample @c ada
10359 type r is record
10360   i : Integer;
10361   j : Integer;
10362   b : Boolean;
10363 end record;
10364
10365 type a is array (1 .. 8) of r;
10366 for a'Component_Size use 72;
10367 @end smallexample
10368
10369 @noindent
10370 then the resulting array has a length of 72 bytes, instead of 96 bytes
10371 if the alignment of the record (4) was obeyed.
10372
10373 Note that there is no point in giving both a component size clause
10374 and a pragma Pack for the same array type. if such duplicate
10375 clauses are given, the pragma Pack will be ignored.
10376
10377 @node Bit_Order Clauses
10378 @section Bit_Order Clauses
10379 @cindex Bit_Order Clause
10380 @cindex bit ordering
10381 @cindex ordering, of bits
10382
10383 @noindent
10384 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10385 attribute.  The specification may either correspond to the default bit
10386 order for the target, in which case the specification has no effect and
10387 places no additional restrictions, or it may be for the non-standard
10388 setting (that is the opposite of the default).
10389
10390 In the case where the non-standard value is specified, the effect is
10391 to renumber bits within each byte, but the ordering of bytes is not
10392 affected.  There are certain
10393 restrictions placed on component clauses as follows:
10394
10395 @itemize @bullet
10396
10397 @item Components fitting within a single storage unit.
10398 @noindent
10399 These are unrestricted, and the effect is merely to renumber bits.  For
10400 example if we are on a little-endian machine with @code{Low_Order_First}
10401 being the default, then the following two declarations have exactly
10402 the same effect:
10403
10404 @smallexample @c ada
10405    type R1 is record
10406       A : Boolean;
10407       B : Integer range 1 .. 120;
10408    end record;
10409
10410    for R1 use record
10411       A at 0 range 0 .. 0;
10412       B at 0 range 1 .. 7;
10413    end record;
10414
10415    type R2 is record
10416       A : Boolean;
10417       B : Integer range 1 .. 120;
10418    end record;
10419
10420    for R2'Bit_Order use High_Order_First;
10421
10422    for R2 use record
10423       A at 0 range 7 .. 7;
10424       B at 0 range 0 .. 6;
10425    end record;
10426 @end smallexample
10427
10428 @noindent
10429 The useful application here is to write the second declaration with the
10430 @code{Bit_Order} attribute definition clause, and know that it will be treated
10431 the same, regardless of whether the target is little-endian or big-endian.
10432
10433 @item Components occupying an integral number of bytes.
10434 @noindent
10435 These are components that exactly fit in two or more bytes.  Such component
10436 declarations are allowed, but have no effect, since it is important to realize
10437 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10438 In particular, the following attempt at getting an endian-independent integer
10439 does not work:
10440
10441 @smallexample @c ada
10442    type R2 is record
10443       A : Integer;
10444    end record;
10445
10446    for R2'Bit_Order use High_Order_First;
10447
10448    for R2 use record
10449       A at 0 range 0 .. 31;
10450    end record;
10451 @end smallexample
10452
10453 @noindent
10454 This declaration will result in a little-endian integer on a
10455 little-endian machine, and a big-endian integer on a big-endian machine.
10456 If byte flipping is required for interoperability between big- and
10457 little-endian machines, this must be explicitly programmed.  This capability
10458 is not provided by @code{Bit_Order}.
10459
10460 @item Components that are positioned across byte boundaries
10461 @noindent
10462 but do not occupy an integral number of bytes.  Given that bytes are not
10463 reordered, such fields would occupy a non-contiguous sequence of bits
10464 in memory, requiring non-trivial code to reassemble.  They are for this
10465 reason not permitted, and any component clause specifying such a layout
10466 will be flagged as illegal by GNAT@.
10467
10468 @end itemize
10469
10470 @noindent
10471 Since the misconception that Bit_Order automatically deals with all
10472 endian-related incompatibilities is a common one, the specification of
10473 a component field that is an integral number of bytes will always
10474 generate a warning.  This warning may be suppressed using @code{pragma
10475 Warnings (Off)} if desired.  The following section contains additional
10476 details regarding the issue of byte ordering.
10477
10478 @node Effect of Bit_Order on Byte Ordering
10479 @section Effect of Bit_Order on Byte Ordering
10480 @cindex byte ordering
10481 @cindex ordering, of bytes
10482
10483 @noindent
10484 In this section we will review the effect of the @code{Bit_Order} attribute
10485 definition clause on byte ordering.  Briefly, it has no effect at all, but
10486 a detailed example will be helpful.  Before giving this
10487 example, let us review the precise
10488 definition of the effect of defining @code{Bit_Order}.  The effect of a
10489 non-standard bit order is described in section 15.5.3 of the Ada
10490 Reference Manual:
10491
10492 @quotation
10493 2   A bit ordering is a method of interpreting the meaning of
10494 the storage place attributes.
10495 @end quotation
10496
10497 @noindent
10498 To understand the precise definition of storage place attributes in
10499 this context, we visit section 13.5.1 of the manual:
10500
10501 @quotation
10502 13   A record_representation_clause (without the mod_clause)
10503 specifies the layout.  The storage place attributes (see 13.5.2)
10504 are taken from the values of the position, first_bit, and last_bit
10505 expressions after normalizing those values so that first_bit is
10506 less than Storage_Unit.
10507 @end quotation
10508
10509 @noindent
10510 The critical point here is that storage places are taken from
10511 the values after normalization, not before.  So the @code{Bit_Order}
10512 interpretation applies to normalized values.  The interpretation
10513 is described in the later part of the 15.5.3 paragraph:
10514
10515 @quotation
10516 2   A bit ordering is a method of interpreting the meaning of
10517 the storage place attributes.  High_Order_First (known in the
10518 vernacular as ``big endian'') means that the first bit of a
10519 storage element (bit 0) is the most significant bit (interpreting
10520 the sequence of bits that represent a component as an unsigned
10521 integer value).  Low_Order_First (known in the vernacular as
10522 ``little endian'') means the opposite: the first bit is the
10523 least significant.
10524 @end quotation
10525
10526 @noindent
10527 Note that the numbering is with respect to the bits of a storage
10528 unit.  In other words, the specification affects only the numbering
10529 of bits within a single storage unit.
10530
10531 We can make the effect clearer by giving an example.
10532
10533 Suppose that we have an external device which presents two bytes, the first
10534 byte presented, which is the first (low addressed byte) of the two byte
10535 record is called Master, and the second byte is called Slave.
10536
10537 The left most (most significant bit is called Control for each byte, and
10538 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10539 (least significant) bit.
10540
10541 On a big-endian machine, we can write the following representation clause
10542
10543 @smallexample @c ada
10544    type Data is record
10545       Master_Control : Bit;
10546       Master_V1      : Bit;
10547       Master_V2      : Bit;
10548       Master_V3      : Bit;
10549       Master_V4      : Bit;
10550       Master_V5      : Bit;
10551       Master_V6      : Bit;
10552       Master_V7      : Bit;
10553       Slave_Control  : Bit;
10554       Slave_V1       : Bit;
10555       Slave_V2       : Bit;
10556       Slave_V3       : Bit;
10557       Slave_V4       : Bit;
10558       Slave_V5       : Bit;
10559       Slave_V6       : Bit;
10560       Slave_V7       : Bit;
10561    end record;
10562
10563    for Data use record
10564       Master_Control at 0 range 0 .. 0;
10565       Master_V1      at 0 range 1 .. 1;
10566       Master_V2      at 0 range 2 .. 2;
10567       Master_V3      at 0 range 3 .. 3;
10568       Master_V4      at 0 range 4 .. 4;
10569       Master_V5      at 0 range 5 .. 5;
10570       Master_V6      at 0 range 6 .. 6;
10571       Master_V7      at 0 range 7 .. 7;
10572       Slave_Control  at 1 range 0 .. 0;
10573       Slave_V1       at 1 range 1 .. 1;
10574       Slave_V2       at 1 range 2 .. 2;
10575       Slave_V3       at 1 range 3 .. 3;
10576       Slave_V4       at 1 range 4 .. 4;
10577       Slave_V5       at 1 range 5 .. 5;
10578       Slave_V6       at 1 range 6 .. 6;
10579       Slave_V7       at 1 range 7 .. 7;
10580    end record;
10581 @end smallexample
10582
10583 @noindent
10584 Now if we move this to a little endian machine, then the bit ordering within
10585 the byte is backwards, so we have to rewrite the record rep clause as:
10586
10587 @smallexample @c ada
10588    for Data use record
10589       Master_Control at 0 range 7 .. 7;
10590       Master_V1      at 0 range 6 .. 6;
10591       Master_V2      at 0 range 5 .. 5;
10592       Master_V3      at 0 range 4 .. 4;
10593       Master_V4      at 0 range 3 .. 3;
10594       Master_V5      at 0 range 2 .. 2;
10595       Master_V6      at 0 range 1 .. 1;
10596       Master_V7      at 0 range 0 .. 0;
10597       Slave_Control  at 1 range 7 .. 7;
10598       Slave_V1       at 1 range 6 .. 6;
10599       Slave_V2       at 1 range 5 .. 5;
10600       Slave_V3       at 1 range 4 .. 4;
10601       Slave_V4       at 1 range 3 .. 3;
10602       Slave_V5       at 1 range 2 .. 2;
10603       Slave_V6       at 1 range 1 .. 1;
10604       Slave_V7       at 1 range 0 .. 0;
10605    end record;
10606 @end smallexample
10607
10608 @noindent
10609 It is a nuisance to have to rewrite the clause, especially if
10610 the code has to be maintained on both machines.  However,
10611 this is a case that we can handle with the
10612 @code{Bit_Order} attribute if it is implemented.
10613 Note that the implementation is not required on byte addressed
10614 machines, but it is indeed implemented in GNAT.
10615 This means that we can simply use the
10616 first record clause, together with the declaration
10617
10618 @smallexample @c ada
10619    for Data'Bit_Order use High_Order_First;
10620 @end smallexample
10621
10622 @noindent
10623 and the effect is what is desired, namely the layout is exactly the same,
10624 independent of whether the code is compiled on a big-endian or little-endian
10625 machine.
10626
10627 The important point to understand is that byte ordering is not affected.
10628 A @code{Bit_Order} attribute definition never affects which byte a field
10629 ends up in, only where it ends up in that byte.
10630 To make this clear, let us rewrite the record rep clause of the previous
10631 example as:
10632
10633 @smallexample @c ada
10634    for Data'Bit_Order use High_Order_First;
10635    for Data use record
10636       Master_Control at 0 range  0 .. 0;
10637       Master_V1      at 0 range  1 .. 1;
10638       Master_V2      at 0 range  2 .. 2;
10639       Master_V3      at 0 range  3 .. 3;
10640       Master_V4      at 0 range  4 .. 4;
10641       Master_V5      at 0 range  5 .. 5;
10642       Master_V6      at 0 range  6 .. 6;
10643       Master_V7      at 0 range  7 .. 7;
10644       Slave_Control  at 0 range  8 .. 8;
10645       Slave_V1       at 0 range  9 .. 9;
10646       Slave_V2       at 0 range 10 .. 10;
10647       Slave_V3       at 0 range 11 .. 11;
10648       Slave_V4       at 0 range 12 .. 12;
10649       Slave_V5       at 0 range 13 .. 13;
10650       Slave_V6       at 0 range 14 .. 14;
10651       Slave_V7       at 0 range 15 .. 15;
10652    end record;
10653 @end smallexample
10654
10655 @noindent
10656 This is exactly equivalent to saying (a repeat of the first example):
10657
10658 @smallexample @c ada
10659    for Data'Bit_Order use High_Order_First;
10660    for Data use record
10661       Master_Control at 0 range 0 .. 0;
10662       Master_V1      at 0 range 1 .. 1;
10663       Master_V2      at 0 range 2 .. 2;
10664       Master_V3      at 0 range 3 .. 3;
10665       Master_V4      at 0 range 4 .. 4;
10666       Master_V5      at 0 range 5 .. 5;
10667       Master_V6      at 0 range 6 .. 6;
10668       Master_V7      at 0 range 7 .. 7;
10669       Slave_Control  at 1 range 0 .. 0;
10670       Slave_V1       at 1 range 1 .. 1;
10671       Slave_V2       at 1 range 2 .. 2;
10672       Slave_V3       at 1 range 3 .. 3;
10673       Slave_V4       at 1 range 4 .. 4;
10674       Slave_V5       at 1 range 5 .. 5;
10675       Slave_V6       at 1 range 6 .. 6;
10676       Slave_V7       at 1 range 7 .. 7;
10677    end record;
10678 @end smallexample
10679
10680 @noindent
10681 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10682 field.  The storage place attributes are obtained by normalizing the
10683 values given so that the @code{First_Bit} value is less than 8.  After
10684 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10685 we specified in the other case.
10686
10687 Now one might expect that the @code{Bit_Order} attribute might affect
10688 bit numbering within the entire record component (two bytes in this
10689 case, thus affecting which byte fields end up in), but that is not
10690 the way this feature is defined, it only affects numbering of bits,
10691 not which byte they end up in.
10692
10693 Consequently it never makes sense to specify a starting bit number
10694 greater than 7 (for a byte addressable field) if an attribute
10695 definition for @code{Bit_Order} has been given, and indeed it
10696 may be actively confusing to specify such a value, so the compiler
10697 generates a warning for such usage.
10698
10699 If you do need to control byte ordering then appropriate conditional
10700 values must be used.  If in our example, the slave byte came first on
10701 some machines we might write:
10702
10703 @smallexample @c ada
10704    Master_Byte_First constant Boolean := @dots{};
10705
10706    Master_Byte : constant Natural :=
10707                    1 - Boolean'Pos (Master_Byte_First);
10708    Slave_Byte  : constant Natural :=
10709                    Boolean'Pos (Master_Byte_First);
10710
10711    for Data'Bit_Order use High_Order_First;
10712    for Data use record
10713       Master_Control at Master_Byte range 0 .. 0;
10714       Master_V1      at Master_Byte range 1 .. 1;
10715       Master_V2      at Master_Byte range 2 .. 2;
10716       Master_V3      at Master_Byte range 3 .. 3;
10717       Master_V4      at Master_Byte range 4 .. 4;
10718       Master_V5      at Master_Byte range 5 .. 5;
10719       Master_V6      at Master_Byte range 6 .. 6;
10720       Master_V7      at Master_Byte range 7 .. 7;
10721       Slave_Control  at Slave_Byte  range 0 .. 0;
10722       Slave_V1       at Slave_Byte  range 1 .. 1;
10723       Slave_V2       at Slave_Byte  range 2 .. 2;
10724       Slave_V3       at Slave_Byte  range 3 .. 3;
10725       Slave_V4       at Slave_Byte  range 4 .. 4;
10726       Slave_V5       at Slave_Byte  range 5 .. 5;
10727       Slave_V6       at Slave_Byte  range 6 .. 6;
10728       Slave_V7       at Slave_Byte  range 7 .. 7;
10729    end record;
10730 @end smallexample
10731
10732 @noindent
10733 Now to switch between machines, all that is necessary is
10734 to set the boolean constant @code{Master_Byte_First} in
10735 an appropriate manner.
10736
10737 @node Pragma Pack for Arrays
10738 @section Pragma Pack for Arrays
10739 @cindex Pragma Pack (for arrays)
10740
10741 @noindent
10742 Pragma @code{Pack} applied to an array has no effect unless the component type
10743 is packable.  For a component type to be packable, it must be one of the
10744 following cases:
10745
10746 @itemize @bullet
10747 @item
10748 Any scalar type
10749 @item
10750 Any type whose size is specified with a size clause
10751 @item
10752 Any packed array type with a static size
10753 @item
10754 Any record type padded because of its default alignment
10755 @end itemize
10756
10757 @noindent
10758 For all these cases, if the component subtype size is in the range
10759 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10760 component size were specified giving the component subtype size.
10761 For example if we have:
10762
10763 @smallexample @c ada
10764    type r is range 0 .. 17;
10765
10766    type ar is array (1 .. 8) of r;
10767    pragma Pack (ar);
10768 @end smallexample
10769
10770 @noindent
10771 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10772 and the size of the array @code{ar} will be exactly 40 bits.
10773
10774 Note that in some cases this rather fierce approach to packing can produce
10775 unexpected effects.  For example, in Ada 95 and Ada 2005,
10776 subtype @code{Natural} typically has a size of 31, meaning that if you
10777 pack an array of @code{Natural}, you get 31-bit
10778 close packing, which saves a few bits, but results in far less efficient
10779 access.  Since many other Ada compilers will ignore such a packing request,
10780 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10781 might not be what is intended.  You can easily remove this warning by
10782 using an explicit @code{Component_Size} setting instead, which never generates
10783 a warning, since the intention of the programmer is clear in this case.
10784
10785 GNAT treats packed arrays in one of two ways.  If the size of the array is
10786 known at compile time and is less than 64 bits, then internally the array
10787 is represented as a single modular type, of exactly the appropriate number
10788 of bits.  If the length is greater than 63 bits, or is not known at compile
10789 time, then the packed array is represented as an array of bytes, and the
10790 length is always a multiple of 8 bits.
10791
10792 Note that to represent a packed array as a modular type, the alignment must
10793 be suitable for the modular type involved. For example, on typical machines
10794 a 32-bit packed array will be represented by a 32-bit modular integer with
10795 an alignment of four bytes. If you explicitly override the default alignment
10796 with an alignment clause that is too small, the modular representation
10797 cannot be used. For example, consider the following set of declarations:
10798
10799 @smallexample @c ada
10800    type R is range 1 .. 3;
10801    type S is array (1 .. 31) of R;
10802    for S'Component_Size use 2;
10803    for S'Size use 62;
10804    for S'Alignment use 1;
10805 @end smallexample
10806
10807 @noindent
10808 If the alignment clause were not present, then a 62-bit modular
10809 representation would be chosen (typically with an alignment of 4 or 8
10810 bytes depending on the target). But the default alignment is overridden
10811 with the explicit alignment clause. This means that the modular
10812 representation cannot be used, and instead the array of bytes
10813 representation must be used, meaning that the length must be a multiple
10814 of 8. Thus the above set of declarations will result in a diagnostic
10815 rejecting the size clause and noting that the minimum size allowed is 64.
10816
10817 @cindex Pragma Pack (for type Natural)
10818 @cindex Pragma Pack warning
10819
10820 One special case that is worth noting occurs when the base type of the
10821 component size is 8/16/32 and the subtype is one bit less. Notably this
10822 occurs with subtype @code{Natural}. Consider:
10823
10824 @smallexample @c ada
10825    type Arr is array (1 .. 32) of Natural;
10826    pragma Pack (Arr);
10827 @end smallexample
10828
10829 @noindent
10830 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10831 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10832 Ada 83 compilers did not attempt 31 bit packing.
10833
10834 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10835 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10836 substantial unintended performance penalty when porting legacy Ada 83 code.
10837 To help prevent this, GNAT generates a warning in such cases. If you really
10838 want 31 bit packing in a case like this, you can set the component size
10839 explicitly:
10840
10841 @smallexample @c ada
10842    type Arr is array (1 .. 32) of Natural;
10843    for Arr'Component_Size use 31;
10844 @end smallexample
10845
10846 @noindent
10847 Here 31-bit packing is achieved as required, and no warning is generated,
10848 since in this case the programmer intention is clear.
10849
10850 @node Pragma Pack for Records
10851 @section Pragma Pack for Records
10852 @cindex Pragma Pack (for records)
10853
10854 @noindent
10855 Pragma @code{Pack} applied to a record will pack the components to reduce
10856 wasted space from alignment gaps and by reducing the amount of space
10857 taken by components.  We distinguish between @emph{packable} components and
10858 @emph{non-packable} components.
10859 Components of the following types are considered packable:
10860 @itemize @bullet
10861 @item
10862 All primitive types are packable.
10863
10864 @item
10865 Small packed arrays, whose size does not exceed 64 bits, and where the
10866 size is statically known at compile time, are represented internally
10867 as modular integers, and so they are also packable.
10868
10869 @end itemize
10870
10871 @noindent
10872 All packable components occupy the exact number of bits corresponding to
10873 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10874 can start on an arbitrary bit boundary.
10875
10876 All other types are non-packable, they occupy an integral number of
10877 storage units, and
10878 are placed at a boundary corresponding to their alignment requirements.
10879
10880 For example, consider the record
10881
10882 @smallexample @c ada
10883    type Rb1 is array (1 .. 13) of Boolean;
10884    pragma Pack (rb1);
10885
10886    type Rb2 is array (1 .. 65) of Boolean;
10887    pragma Pack (rb2);
10888
10889    type x2 is record
10890       l1 : Boolean;
10891       l2 : Duration;
10892       l3 : Float;
10893       l4 : Boolean;
10894       l5 : Rb1;
10895       l6 : Rb2;
10896    end record;
10897    pragma Pack (x2);
10898 @end smallexample
10899
10900 @noindent
10901 The representation for the record x2 is as follows:
10902
10903 @smallexample @c ada
10904 for x2'Size use 224;
10905 for x2 use record
10906    l1 at  0 range  0 .. 0;
10907    l2 at  0 range  1 .. 64;
10908    l3 at 12 range  0 .. 31;
10909    l4 at 16 range  0 .. 0;
10910    l5 at 16 range  1 .. 13;
10911    l6 at 18 range  0 .. 71;
10912 end record;
10913 @end smallexample
10914
10915 @noindent
10916 Studying this example, we see that the packable fields @code{l1}
10917 and @code{l2} are
10918 of length equal to their sizes, and placed at specific bit boundaries (and
10919 not byte boundaries) to
10920 eliminate padding.  But @code{l3} is of a non-packable float type, so
10921 it is on the next appropriate alignment boundary.
10922
10923 The next two fields are fully packable, so @code{l4} and @code{l5} are
10924 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10925 array that is longer than 64 bits, so it is itself non-packable.  Thus
10926 the @code{l6} field is aligned to the next byte boundary, and takes an
10927 integral number of bytes, i.e.@: 72 bits.
10928
10929 @node Record Representation Clauses
10930 @section Record Representation Clauses
10931 @cindex Record Representation Clause
10932
10933 @noindent
10934 Record representation clauses may be given for all record types, including
10935 types obtained by record extension.  Component clauses are allowed for any
10936 static component.  The restrictions on component clauses depend on the type
10937 of the component.
10938
10939 @cindex Component Clause
10940 For all components of an elementary type, the only restriction on component
10941 clauses is that the size must be at least the 'Size value of the type
10942 (actually the Value_Size).  There are no restrictions due to alignment,
10943 and such components may freely cross storage boundaries.
10944
10945 Packed arrays with a size up to and including 64 bits are represented
10946 internally using a modular type with the appropriate number of bits, and
10947 thus the same lack of restriction applies.  For example, if you declare:
10948
10949 @smallexample @c ada
10950    type R is array (1 .. 49) of Boolean;
10951    pragma Pack (R);
10952    for R'Size use 49;
10953 @end smallexample
10954
10955 @noindent
10956 then a component clause for a component of type R may start on any
10957 specified bit boundary, and may specify a value of 49 bits or greater.
10958
10959 For packed bit arrays that are longer than 64 bits, there are two
10960 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10961 including the important case of single bits or boolean values, then
10962 there are no limitations on placement of such components, and they
10963 may start and end at arbitrary bit boundaries.
10964
10965 If the component size is not a power of 2 (e.g.@: 3 or 5), then
10966 an array of this type longer than 64 bits must always be placed on
10967 on a storage unit (byte) boundary and occupy an integral number
10968 of storage units (bytes). Any component clause that does not
10969 meet this requirement will be rejected.
10970
10971 Any aliased component, or component of an aliased type, must
10972 have its normal alignment and size. A component clause that
10973 does not meet this requirement will be rejected.
10974
10975 The tag field of a tagged type always occupies an address sized field at
10976 the start of the record.  No component clause may attempt to overlay this
10977 tag. When a tagged type appears as a component, the tag field must have
10978 proper alignment
10979
10980 In the case of a record extension T1, of a type T, no component clause applied
10981 to the type T1 can specify a storage location that would overlap the first
10982 T'Size bytes of the record.
10983
10984 For all other component types, including non-bit-packed arrays,
10985 the component can be placed at an arbitrary bit boundary,
10986 so for example, the following is permitted:
10987
10988 @smallexample @c ada
10989    type R is array (1 .. 10) of Boolean;
10990    for R'Size use 80;
10991
10992    type Q is record
10993       G, H : Boolean;
10994       L, M : R;
10995    end record;
10996
10997    for Q use record
10998       G at 0 range  0 ..   0;
10999       H at 0 range  1 ..   1;
11000       L at 0 range  2 ..  81;
11001       R at 0 range 82 .. 161;
11002    end record;
11003 @end smallexample
11004
11005 @noindent
11006 Note: the above rules apply to recent releases of GNAT 5.
11007 In GNAT 3, there are more severe restrictions on larger components.
11008 For non-primitive types, including packed arrays with a size greater than
11009 64 bits, component clauses must respect the alignment requirement of the
11010 type, in particular, always starting on a byte boundary, and the length
11011 must be a multiple of the storage unit.
11012
11013 @node Enumeration Clauses
11014 @section Enumeration Clauses
11015
11016 The only restriction on enumeration clauses is that the range of values
11017 must be representable.  For the signed case, if one or more of the
11018 representation values are negative, all values must be in the range:
11019
11020 @smallexample @c ada
11021    System.Min_Int .. System.Max_Int
11022 @end smallexample
11023
11024 @noindent
11025 For the unsigned case, where all values are nonnegative, the values must
11026 be in the range:
11027
11028 @smallexample @c ada
11029    0 .. System.Max_Binary_Modulus;
11030 @end smallexample
11031
11032 @noindent
11033 A @emph{confirming} representation clause is one in which the values range
11034 from 0 in sequence, i.e.@: a clause that confirms the default representation
11035 for an enumeration type.
11036 Such a confirming representation
11037 is permitted by these rules, and is specially recognized by the compiler so
11038 that no extra overhead results from the use of such a clause.
11039
11040 If an array has an index type which is an enumeration type to which an
11041 enumeration clause has been applied, then the array is stored in a compact
11042 manner.  Consider the declarations:
11043
11044 @smallexample @c ada
11045    type r is (A, B, C);
11046    for r use (A => 1, B => 5, C => 10);
11047    type t is array (r) of Character;
11048 @end smallexample
11049
11050 @noindent
11051 The array type t corresponds to a vector with exactly three elements and
11052 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11053 use of space, but means that accesses to elements of the array will incur
11054 the overhead of converting representation values to the corresponding
11055 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11056
11057 @node Address Clauses
11058 @section Address Clauses
11059 @cindex Address Clause
11060
11061 The reference manual allows a general restriction on representation clauses,
11062 as found in RM 13.1(22):
11063
11064 @quotation
11065 An implementation need not support representation
11066 items containing nonstatic expressions, except that
11067 an implementation should support a representation item
11068 for a given entity if each nonstatic expression in the
11069 representation item is a name that statically denotes
11070 a constant declared before the entity.
11071 @end quotation
11072
11073 @noindent
11074 In practice this is applicable only to address clauses, since this is the
11075 only case in which a non-static expression is permitted by the syntax.  As
11076 the AARM notes in sections 13.1 (22.a-22.h):
11077
11078 @display
11079   22.a   Reason: This is to avoid the following sort of thing:
11080
11081   22.b        X : Integer := F(@dots{});
11082               Y : Address := G(@dots{});
11083               for X'Address use Y;
11084
11085   22.c   In the above, we have to evaluate the
11086          initialization expression for X before we
11087          know where to put the result.  This seems
11088          like an unreasonable implementation burden.
11089
11090   22.d   The above code should instead be written
11091          like this:
11092
11093   22.e        Y : constant Address := G(@dots{});
11094               X : Integer := F(@dots{});
11095               for X'Address use Y;
11096
11097   22.f   This allows the expression ``Y'' to be safely
11098          evaluated before X is created.
11099
11100   22.g   The constant could be a formal parameter of mode in.
11101
11102   22.h   An implementation can support other nonstatic
11103          expressions if it wants to.  Expressions of type
11104          Address are hardly ever static, but their value
11105          might be known at compile time anyway in many
11106          cases.
11107 @end display
11108
11109 @noindent
11110 GNAT does indeed permit many additional cases of non-static expressions.  In
11111 particular, if the type involved is elementary there are no restrictions
11112 (since in this case, holding a temporary copy of the initialization value,
11113 if one is present, is inexpensive).  In addition, if there is no implicit or
11114 explicit initialization, then there are no restrictions.  GNAT will reject
11115 only the case where all three of these conditions hold:
11116
11117 @itemize @bullet
11118
11119 @item
11120 The type of the item is non-elementary (e.g.@: a record or array).
11121
11122 @item
11123 There is explicit or implicit initialization required for the object.
11124 Note that access values are always implicitly initialized, and also
11125 in GNAT, certain bit-packed arrays (those having a dynamic length or
11126 a length greater than 64) will also be implicitly initialized to zero.
11127
11128 @item
11129 The address value is non-static.  Here GNAT is more permissive than the
11130 RM, and allows the address value to be the address of a previously declared
11131 stand-alone variable, as long as it does not itself have an address clause.
11132
11133 @smallexample @c ada
11134            Anchor  : Some_Initialized_Type;
11135            Overlay : Some_Initialized_Type;
11136            for Overlay'Address use Anchor'Address;
11137 @end smallexample
11138
11139 @noindent
11140 However, the prefix of the address clause cannot be an array component, or
11141 a component of a discriminated record.
11142
11143 @end itemize
11144
11145 @noindent
11146 As noted above in section 22.h, address values are typically non-static.  In
11147 particular the To_Address function, even if applied to a literal value, is
11148 a non-static function call.  To avoid this minor annoyance, GNAT provides
11149 the implementation defined attribute 'To_Address.  The following two
11150 expressions have identical values:
11151
11152 @findex Attribute
11153 @findex To_Address
11154 @smallexample @c ada
11155    To_Address (16#1234_0000#)
11156    System'To_Address (16#1234_0000#);
11157 @end smallexample
11158
11159 @noindent
11160 except that the second form is considered to be a static expression, and
11161 thus when used as an address clause value is always permitted.
11162
11163 @noindent
11164 Additionally, GNAT treats as static an address clause that is an
11165 unchecked_conversion of a static integer value.  This simplifies the porting
11166 of legacy code, and provides a portable equivalent to the GNAT attribute
11167 @code{To_Address}.
11168
11169 Another issue with address clauses is the interaction with alignment
11170 requirements.  When an address clause is given for an object, the address
11171 value must be consistent with the alignment of the object (which is usually
11172 the same as the alignment of the type of the object).  If an address clause
11173 is given that specifies an inappropriately aligned address value, then the
11174 program execution is erroneous.
11175
11176 Since this source of erroneous behavior can have unfortunate effects, GNAT
11177 checks (at compile time if possible, generating a warning, or at execution
11178 time with a run-time check) that the alignment is appropriate.  If the
11179 run-time check fails, then @code{Program_Error} is raised.  This run-time
11180 check is suppressed if range checks are suppressed, or if the special GNAT
11181 check Alignment_Check is suppressed, or if
11182 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11183
11184 Finally, GNAT does not permit overlaying of objects of controlled types or
11185 composite types containing a controlled component. In most cases, the compiler
11186 can detect an attempt at such overlays and will generate a warning at compile
11187 time and a Program_Error exception at run time.
11188
11189 @findex Export
11190 An address clause cannot be given for an exported object.  More
11191 understandably the real restriction is that objects with an address
11192 clause cannot be exported.  This is because such variables are not
11193 defined by the Ada program, so there is no external object to export.
11194
11195 @findex Import
11196 It is permissible to give an address clause and a pragma Import for the
11197 same object.  In this case, the variable is not really defined by the
11198 Ada program, so there is no external symbol to be linked.  The link name
11199 and the external name are ignored in this case.  The reason that we allow this
11200 combination is that it provides a useful idiom to avoid unwanted
11201 initializations on objects with address clauses.
11202
11203 When an address clause is given for an object that has implicit or
11204 explicit initialization, then by default initialization takes place.  This
11205 means that the effect of the object declaration is to overwrite the
11206 memory at the specified address.  This is almost always not what the
11207 programmer wants, so GNAT will output a warning:
11208
11209 @smallexample
11210   with System;
11211   package G is
11212      type R is record
11213         M : Integer := 0;
11214      end record;
11215
11216      Ext : R;
11217      for Ext'Address use System'To_Address (16#1234_1234#);
11218          |
11219   >>> warning: implicit initialization of "Ext" may
11220       modify overlaid storage
11221   >>> warning: use pragma Import for "Ext" to suppress
11222       initialization (RM B(24))
11223
11224   end G;
11225 @end smallexample
11226
11227 @noindent
11228 As indicated by the warning message, the solution is to use a (dummy) pragma
11229 Import to suppress this initialization.  The pragma tell the compiler that the
11230 object is declared and initialized elsewhere.  The following package compiles
11231 without warnings (and the initialization is suppressed):
11232
11233 @smallexample @c ada
11234    with System;
11235    package G is
11236       type R is record
11237          M : Integer := 0;
11238       end record;
11239
11240       Ext : R;
11241       for Ext'Address use System'To_Address (16#1234_1234#);
11242       pragma Import (Ada, Ext);
11243    end G;
11244 @end smallexample
11245
11246 @noindent
11247 A final issue with address clauses involves their use for overlaying
11248 variables, as in the following example:
11249 @cindex Overlaying of objects
11250
11251 @smallexample @c ada
11252   A : Integer;
11253   B : Integer;
11254   for B'Address use A'Address;
11255 @end smallexample
11256
11257 @noindent
11258 or alternatively, using the form recommended by the RM:
11259
11260 @smallexample @c ada
11261   A    : Integer;
11262   Addr : constant Address := A'Address;
11263   B    : Integer;
11264   for B'Address use Addr;
11265 @end smallexample
11266
11267 @noindent
11268 In both of these cases, @code{A}
11269 and @code{B} become aliased to one another via the
11270 address clause. This use of address clauses to overlay
11271 variables, achieving an effect similar to unchecked
11272 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11273 the effect is implementation defined. Furthermore, the
11274 Ada RM specifically recommends that in a situation
11275 like this, @code{B} should be subject to the following
11276 implementation advice (RM 13.3(19)):
11277
11278 @quotation
11279 19  If the Address of an object is specified, or it is imported
11280     or exported, then the implementation should not perform
11281     optimizations based on assumptions of no aliases.
11282 @end quotation
11283
11284 @noindent
11285 GNAT follows this recommendation, and goes further by also applying
11286 this recommendation to the overlaid variable (@code{A}
11287 in the above example) in this case. This means that the overlay
11288 works "as expected", in that a modification to one of the variables
11289 will affect the value of the other.
11290
11291 @node Effect of Convention on Representation
11292 @section Effect of Convention on Representation
11293 @cindex Convention, effect on representation
11294
11295 @noindent
11296 Normally the specification of a foreign language convention for a type or
11297 an object has no effect on the chosen representation.  In particular, the
11298 representation chosen for data in GNAT generally meets the standard system
11299 conventions, and for example records are laid out in a manner that is
11300 consistent with C@.  This means that specifying convention C (for example)
11301 has no effect.
11302
11303 There are four exceptions to this general rule:
11304
11305 @itemize @bullet
11306
11307 @item Convention Fortran and array subtypes
11308 If pragma Convention Fortran is specified for an array subtype, then in
11309 accordance with the implementation advice in section 3.6.2(11) of the
11310 Ada Reference Manual, the array will be stored in a Fortran-compatible
11311 column-major manner, instead of the normal default row-major order.
11312
11313 @item Convention C and enumeration types
11314 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11315 to accommodate all values of the type.  For example, for the enumeration
11316 type declared by:
11317
11318 @smallexample @c ada
11319    type Color is (Red, Green, Blue);
11320 @end smallexample
11321
11322 @noindent
11323 8 bits is sufficient to store all values of the type, so by default, objects
11324 of type @code{Color} will be represented using 8 bits.  However, normal C
11325 convention is to use 32 bits for all enum values in C, since enum values
11326 are essentially of type int.  If pragma @code{Convention C} is specified for an
11327 Ada enumeration type, then the size is modified as necessary (usually to
11328 32 bits) to be consistent with the C convention for enum values.
11329
11330 Note that this treatment applies only to types. If Convention C is given for
11331 an enumeration object, where the enumeration type is not Convention C, then
11332 Object_Size bits are allocated. For example, for a normal enumeration type,
11333 with less than 256 elements, only 8 bits will be allocated for the object.
11334 Since this may be a surprise in terms of what C expects, GNAT will issue a
11335 warning in this situation. The warning can be suppressed by giving an explicit
11336 size clause specifying the desired size.
11337
11338 @item Convention C/Fortran and Boolean types
11339 In C, the usual convention for boolean values, that is values used for
11340 conditions, is that zero represents false, and nonzero values represent
11341 true.  In Ada, the normal convention is that two specific values, typically
11342 0/1, are used to represent false/true respectively.
11343
11344 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11345 value represents true).
11346
11347 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11348 C or Fortran convention for a derived Boolean, as in the following example:
11349
11350 @smallexample @c ada
11351    type C_Switch is new Boolean;
11352    pragma Convention (C, C_Switch);
11353 @end smallexample
11354
11355 @noindent
11356 then the GNAT generated code will treat any nonzero value as true.  For truth
11357 values generated by GNAT, the conventional value 1 will be used for True, but
11358 when one of these values is read, any nonzero value is treated as True.
11359
11360 @item Access types on OpenVMS
11361 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11362 arrays) are 64-bits long. An exception to this rule is for the case of
11363 C-convention access types where there is no explicit size clause present (or
11364 inherited for derived types). In this case, GNAT chooses to make these
11365 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11366 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11367
11368 @end itemize
11369
11370 @node Determining the Representations chosen by GNAT
11371 @section Determining the Representations chosen by GNAT
11372 @cindex Representation, determination of
11373 @cindex @option{-gnatR} switch
11374
11375 @noindent
11376 Although the descriptions in this section are intended to be complete, it is
11377 often easier to simply experiment to see what GNAT accepts and what the
11378 effect is on the layout of types and objects.
11379
11380 As required by the Ada RM, if a representation clause is not accepted, then
11381 it must be rejected as illegal by the compiler.  However, when a
11382 representation clause or pragma is accepted, there can still be questions
11383 of what the compiler actually does.  For example, if a partial record
11384 representation clause specifies the location of some components and not
11385 others, then where are the non-specified components placed? Or if pragma
11386 @code{Pack} is used on a record, then exactly where are the resulting
11387 fields placed? The section on pragma @code{Pack} in this chapter can be
11388 used to answer the second question, but it is often easier to just see
11389 what the compiler does.
11390
11391 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11392 with this option, then the compiler will output information on the actual
11393 representations chosen, in a format similar to source representation
11394 clauses.  For example, if we compile the package:
11395
11396 @smallexample @c ada
11397 package q is
11398    type r (x : boolean) is tagged record
11399       case x is
11400          when True => S : String (1 .. 100);
11401          when False => null;
11402       end case;
11403    end record;
11404
11405    type r2 is new r (false) with record
11406       y2 : integer;
11407    end record;
11408
11409    for r2 use record
11410       y2 at 16 range 0 .. 31;
11411    end record;
11412
11413    type x is record
11414       y : character;
11415    end record;
11416
11417    type x1 is array (1 .. 10) of x;
11418    for x1'component_size use 11;
11419
11420    type ia is access integer;
11421
11422    type Rb1 is array (1 .. 13) of Boolean;
11423    pragma Pack (rb1);
11424
11425    type Rb2 is array (1 .. 65) of Boolean;
11426    pragma Pack (rb2);
11427
11428    type x2 is record
11429       l1 : Boolean;
11430       l2 : Duration;
11431       l3 : Float;
11432       l4 : Boolean;
11433       l5 : Rb1;
11434       l6 : Rb2;
11435    end record;
11436    pragma Pack (x2);
11437 end q;
11438 @end smallexample
11439
11440 @noindent
11441 using the switch @option{-gnatR} we obtain the following output:
11442
11443 @smallexample
11444 Representation information for unit q
11445 -------------------------------------
11446
11447 for r'Size use ??;
11448 for r'Alignment use 4;
11449 for r use record
11450    x    at 4 range  0 .. 7;
11451    _tag at 0 range  0 .. 31;
11452    s    at 5 range  0 .. 799;
11453 end record;
11454
11455 for r2'Size use 160;
11456 for r2'Alignment use 4;
11457 for r2 use record
11458    x       at  4 range  0 .. 7;
11459    _tag    at  0 range  0 .. 31;
11460    _parent at  0 range  0 .. 63;
11461    y2      at 16 range  0 .. 31;
11462 end record;
11463
11464 for x'Size use 8;
11465 for x'Alignment use 1;
11466 for x use record
11467    y at 0 range  0 .. 7;
11468 end record;
11469
11470 for x1'Size use 112;
11471 for x1'Alignment use 1;
11472 for x1'Component_Size use 11;
11473
11474 for rb1'Size use 13;
11475 for rb1'Alignment use 2;
11476 for rb1'Component_Size use 1;
11477
11478 for rb2'Size use 72;
11479 for rb2'Alignment use 1;
11480 for rb2'Component_Size use 1;
11481
11482 for x2'Size use 224;
11483 for x2'Alignment use 4;
11484 for x2 use record
11485    l1 at  0 range  0 .. 0;
11486    l2 at  0 range  1 .. 64;
11487    l3 at 12 range  0 .. 31;
11488    l4 at 16 range  0 .. 0;
11489    l5 at 16 range  1 .. 13;
11490    l6 at 18 range  0 .. 71;
11491 end record;
11492 @end smallexample
11493
11494 @noindent
11495 The Size values are actually the Object_Size, i.e.@: the default size that
11496 will be allocated for objects of the type.
11497 The ?? size for type r indicates that we have a variant record, and the
11498 actual size of objects will depend on the discriminant value.
11499
11500 The Alignment values show the actual alignment chosen by the compiler
11501 for each record or array type.
11502
11503 The record representation clause for type r shows where all fields
11504 are placed, including the compiler generated tag field (whose location
11505 cannot be controlled by the programmer).
11506
11507 The record representation clause for the type extension r2 shows all the
11508 fields present, including the parent field, which is a copy of the fields
11509 of the parent type of r2, i.e.@: r1.
11510
11511 The component size and size clauses for types rb1 and rb2 show
11512 the exact effect of pragma @code{Pack} on these arrays, and the record
11513 representation clause for type x2 shows how pragma @code{Pack} affects
11514 this record type.
11515
11516 In some cases, it may be useful to cut and paste the representation clauses
11517 generated by the compiler into the original source to fix and guarantee
11518 the actual representation to be used.
11519
11520 @node Standard Library Routines
11521 @chapter Standard Library Routines
11522
11523 @noindent
11524 The Ada Reference Manual contains in Annex A a full description of an
11525 extensive set of standard library routines that can be used in any Ada
11526 program, and which must be provided by all Ada compilers.  They are
11527 analogous to the standard C library used by C programs.
11528
11529 GNAT implements all of the facilities described in annex A, and for most
11530 purposes the description in the Ada Reference Manual, or appropriate Ada
11531 text book, will be sufficient for making use of these facilities.
11532
11533 In the case of the input-output facilities,
11534 @xref{The Implementation of Standard I/O},
11535 gives details on exactly how GNAT interfaces to the
11536 file system.  For the remaining packages, the Ada Reference Manual
11537 should be sufficient.  The following is a list of the packages included,
11538 together with a brief description of the functionality that is provided.
11539
11540 For completeness, references are included to other predefined library
11541 routines defined in other sections of the Ada Reference Manual (these are
11542 cross-indexed from Annex A).
11543
11544 @table @code
11545 @item Ada (A.2)
11546 This is a parent package for all the standard library packages.  It is
11547 usually included implicitly in your program, and itself contains no
11548 useful data or routines.
11549
11550 @item Ada.Calendar (9.6)
11551 @code{Calendar} provides time of day access, and routines for
11552 manipulating times and durations.
11553
11554 @item Ada.Characters (A.3.1)
11555 This is a dummy parent package that contains no useful entities
11556
11557 @item Ada.Characters.Handling (A.3.2)
11558 This package provides some basic character handling capabilities,
11559 including classification functions for classes of characters (e.g.@: test
11560 for letters, or digits).
11561
11562 @item Ada.Characters.Latin_1 (A.3.3)
11563 This package includes a complete set of definitions of the characters
11564 that appear in type CHARACTER@.  It is useful for writing programs that
11565 will run in international environments.  For example, if you want an
11566 upper case E with an acute accent in a string, it is often better to use
11567 the definition of @code{UC_E_Acute} in this package.  Then your program
11568 will print in an understandable manner even if your environment does not
11569 support these extended characters.
11570
11571 @item Ada.Command_Line (A.15)
11572 This package provides access to the command line parameters and the name
11573 of the current program (analogous to the use of @code{argc} and @code{argv}
11574 in C), and also allows the exit status for the program to be set in a
11575 system-independent manner.
11576
11577 @item Ada.Decimal (F.2)
11578 This package provides constants describing the range of decimal numbers
11579 implemented, and also a decimal divide routine (analogous to the COBOL
11580 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11581
11582 @item Ada.Direct_IO (A.8.4)
11583 This package provides input-output using a model of a set of records of
11584 fixed-length, containing an arbitrary definite Ada type, indexed by an
11585 integer record number.
11586
11587 @item Ada.Dynamic_Priorities (D.5)
11588 This package allows the priorities of a task to be adjusted dynamically
11589 as the task is running.
11590
11591 @item Ada.Exceptions (11.4.1)
11592 This package provides additional information on exceptions, and also
11593 contains facilities for treating exceptions as data objects, and raising
11594 exceptions with associated messages.
11595
11596 @item Ada.Finalization (7.6)
11597 This package contains the declarations and subprograms to support the
11598 use of controlled types, providing for automatic initialization and
11599 finalization (analogous to the constructors and destructors of C++)
11600
11601 @item Ada.Interrupts (C.3.2)
11602 This package provides facilities for interfacing to interrupts, which
11603 includes the set of signals or conditions that can be raised and
11604 recognized as interrupts.
11605
11606 @item Ada.Interrupts.Names (C.3.2)
11607 This package provides the set of interrupt names (actually signal
11608 or condition names) that can be handled by GNAT@.
11609
11610 @item Ada.IO_Exceptions (A.13)
11611 This package defines the set of exceptions that can be raised by use of
11612 the standard IO packages.
11613
11614 @item Ada.Numerics
11615 This package contains some standard constants and exceptions used
11616 throughout the numerics packages.  Note that the constants pi and e are
11617 defined here, and it is better to use these definitions than rolling
11618 your own.
11619
11620 @item Ada.Numerics.Complex_Elementary_Functions
11621 Provides the implementation of standard elementary functions (such as
11622 log and trigonometric functions) operating on complex numbers using the
11623 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11624 created by the package @code{Numerics.Complex_Types}.
11625
11626 @item Ada.Numerics.Complex_Types
11627 This is a predefined instantiation of
11628 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11629 build the type @code{Complex} and @code{Imaginary}.
11630
11631 @item Ada.Numerics.Discrete_Random
11632 This package provides a random number generator suitable for generating
11633 random integer values from a specified range.
11634
11635 @item Ada.Numerics.Float_Random
11636 This package provides a random number generator suitable for generating
11637 uniformly distributed floating point values.
11638
11639 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11640 This is a generic version of the package that provides the
11641 implementation of standard elementary functions (such as log and
11642 trigonometric functions) for an arbitrary complex type.
11643
11644 The following predefined instantiations of this package are provided:
11645
11646 @table @code
11647 @item Short_Float
11648 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11649 @item Float
11650 @code{Ada.Numerics.Complex_Elementary_Functions}
11651 @item Long_Float
11652 @code{Ada.Numerics.
11653  Long_Complex_Elementary_Functions}
11654 @end table
11655
11656 @item Ada.Numerics.Generic_Complex_Types
11657 This is a generic package that allows the creation of complex types,
11658 with associated complex arithmetic operations.
11659
11660 The following predefined instantiations of this package exist
11661 @table @code
11662 @item Short_Float
11663 @code{Ada.Numerics.Short_Complex_Complex_Types}
11664 @item Float
11665 @code{Ada.Numerics.Complex_Complex_Types}
11666 @item Long_Float
11667 @code{Ada.Numerics.Long_Complex_Complex_Types}
11668 @end table
11669
11670 @item Ada.Numerics.Generic_Elementary_Functions
11671 This is a generic package that provides the implementation of standard
11672 elementary functions (such as log an trigonometric functions) for an
11673 arbitrary float type.
11674
11675 The following predefined instantiations of this package exist
11676
11677 @table @code
11678 @item Short_Float
11679 @code{Ada.Numerics.Short_Elementary_Functions}
11680 @item Float
11681 @code{Ada.Numerics.Elementary_Functions}
11682 @item Long_Float
11683 @code{Ada.Numerics.Long_Elementary_Functions}
11684 @end table
11685
11686 @item Ada.Real_Time (D.8)
11687 This package provides facilities similar to those of @code{Calendar}, but
11688 operating with a finer clock suitable for real time control. Note that
11689 annex D requires that there be no backward clock jumps, and GNAT generally
11690 guarantees this behavior, but of course if the external clock on which
11691 the GNAT runtime depends is deliberately reset by some external event,
11692 then such a backward jump may occur.
11693
11694 @item Ada.Sequential_IO (A.8.1)
11695 This package provides input-output facilities for sequential files,
11696 which can contain a sequence of values of a single type, which can be
11697 any Ada type, including indefinite (unconstrained) types.
11698
11699 @item Ada.Storage_IO (A.9)
11700 This package provides a facility for mapping arbitrary Ada types to and
11701 from a storage buffer.  It is primarily intended for the creation of new
11702 IO packages.
11703
11704 @item Ada.Streams (13.13.1)
11705 This is a generic package that provides the basic support for the
11706 concept of streams as used by the stream attributes (@code{Input},
11707 @code{Output}, @code{Read} and @code{Write}).
11708
11709 @item Ada.Streams.Stream_IO (A.12.1)
11710 This package is a specialization of the type @code{Streams} defined in
11711 package @code{Streams} together with a set of operations providing
11712 Stream_IO capability.  The Stream_IO model permits both random and
11713 sequential access to a file which can contain an arbitrary set of values
11714 of one or more Ada types.
11715
11716 @item Ada.Strings (A.4.1)
11717 This package provides some basic constants used by the string handling
11718 packages.
11719
11720 @item Ada.Strings.Bounded (A.4.4)
11721 This package provides facilities for handling variable length
11722 strings.  The bounded model requires a maximum length.  It is thus
11723 somewhat more limited than the unbounded model, but avoids the use of
11724 dynamic allocation or finalization.
11725
11726 @item Ada.Strings.Fixed (A.4.3)
11727 This package provides facilities for handling fixed length strings.
11728
11729 @item Ada.Strings.Maps (A.4.2)
11730 This package provides facilities for handling character mappings and
11731 arbitrarily defined subsets of characters.  For instance it is useful in
11732 defining specialized translation tables.
11733
11734 @item Ada.Strings.Maps.Constants (A.4.6)
11735 This package provides a standard set of predefined mappings and
11736 predefined character sets.  For example, the standard upper to lower case
11737 conversion table is found in this package.  Note that upper to lower case
11738 conversion is non-trivial if you want to take the entire set of
11739 characters, including extended characters like E with an acute accent,
11740 into account.  You should use the mappings in this package (rather than
11741 adding 32 yourself) to do case mappings.
11742
11743 @item Ada.Strings.Unbounded (A.4.5)
11744 This package provides facilities for handling variable length
11745 strings.  The unbounded model allows arbitrary length strings, but
11746 requires the use of dynamic allocation and finalization.
11747
11748 @item Ada.Strings.Wide_Bounded (A.4.7)
11749 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11750 @itemx Ada.Strings.Wide_Maps (A.4.7)
11751 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11752 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11753 These packages provide analogous capabilities to the corresponding
11754 packages without @samp{Wide_} in the name, but operate with the types
11755 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11756 and @code{Character}.
11757
11758 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11759 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11760 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11761 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11762 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11763 These packages provide analogous capabilities to the corresponding
11764 packages without @samp{Wide_} in the name, but operate with the types
11765 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11766 of @code{String} and @code{Character}.
11767
11768 @item Ada.Synchronous_Task_Control (D.10)
11769 This package provides some standard facilities for controlling task
11770 communication in a synchronous manner.
11771
11772 @item Ada.Tags
11773 This package contains definitions for manipulation of the tags of tagged
11774 values.
11775
11776 @item Ada.Task_Attributes
11777 This package provides the capability of associating arbitrary
11778 task-specific data with separate tasks.
11779
11780 @item Ada.Text_IO
11781 This package provides basic text input-output capabilities for
11782 character, string and numeric data.  The subpackages of this
11783 package are listed next.
11784
11785 @item Ada.Text_IO.Decimal_IO
11786 Provides input-output facilities for decimal fixed-point types
11787
11788 @item Ada.Text_IO.Enumeration_IO
11789 Provides input-output facilities for enumeration types.
11790
11791 @item Ada.Text_IO.Fixed_IO
11792 Provides input-output facilities for ordinary fixed-point types.
11793
11794 @item Ada.Text_IO.Float_IO
11795 Provides input-output facilities for float types.  The following
11796 predefined instantiations of this generic package are available:
11797
11798 @table @code
11799 @item Short_Float
11800 @code{Short_Float_Text_IO}
11801 @item Float
11802 @code{Float_Text_IO}
11803 @item Long_Float
11804 @code{Long_Float_Text_IO}
11805 @end table
11806
11807 @item Ada.Text_IO.Integer_IO
11808 Provides input-output facilities for integer types.  The following
11809 predefined instantiations of this generic package are available:
11810
11811 @table @code
11812 @item Short_Short_Integer
11813 @code{Ada.Short_Short_Integer_Text_IO}
11814 @item Short_Integer
11815 @code{Ada.Short_Integer_Text_IO}
11816 @item Integer
11817 @code{Ada.Integer_Text_IO}
11818 @item Long_Integer
11819 @code{Ada.Long_Integer_Text_IO}
11820 @item Long_Long_Integer
11821 @code{Ada.Long_Long_Integer_Text_IO}
11822 @end table
11823
11824 @item Ada.Text_IO.Modular_IO
11825 Provides input-output facilities for modular (unsigned) types
11826
11827 @item Ada.Text_IO.Complex_IO (G.1.3)
11828 This package provides basic text input-output capabilities for complex
11829 data.
11830
11831 @item Ada.Text_IO.Editing (F.3.3)
11832 This package contains routines for edited output, analogous to the use
11833 of pictures in COBOL@.  The picture formats used by this package are a
11834 close copy of the facility in COBOL@.
11835
11836 @item Ada.Text_IO.Text_Streams (A.12.2)
11837 This package provides a facility that allows Text_IO files to be treated
11838 as streams, so that the stream attributes can be used for writing
11839 arbitrary data, including binary data, to Text_IO files.
11840
11841 @item Ada.Unchecked_Conversion (13.9)
11842 This generic package allows arbitrary conversion from one type to
11843 another of the same size, providing for breaking the type safety in
11844 special circumstances.
11845
11846 If the types have the same Size (more accurately the same Value_Size),
11847 then the effect is simply to transfer the bits from the source to the
11848 target type without any modification.  This usage is well defined, and
11849 for simple types whose representation is typically the same across
11850 all implementations, gives a portable method of performing such
11851 conversions.
11852
11853 If the types do not have the same size, then the result is implementation
11854 defined, and thus may be non-portable.  The following describes how GNAT
11855 handles such unchecked conversion cases.
11856
11857 If the types are of different sizes, and are both discrete types, then
11858 the effect is of a normal type conversion without any constraint checking.
11859 In particular if the result type has a larger size, the result will be
11860 zero or sign extended.  If the result type has a smaller size, the result
11861 will be truncated by ignoring high order bits.
11862
11863 If the types are of different sizes, and are not both discrete types,
11864 then the conversion works as though pointers were created to the source
11865 and target, and the pointer value is converted.  The effect is that bits
11866 are copied from successive low order storage units and bits of the source
11867 up to the length of the target type.
11868
11869 A warning is issued if the lengths differ, since the effect in this
11870 case is implementation dependent, and the above behavior may not match
11871 that of some other compiler.
11872
11873 A pointer to one type may be converted to a pointer to another type using
11874 unchecked conversion.  The only case in which the effect is undefined is
11875 when one or both pointers are pointers to unconstrained array types.  In
11876 this case, the bounds information may get incorrectly transferred, and in
11877 particular, GNAT uses double size pointers for such types, and it is
11878 meaningless to convert between such pointer types.  GNAT will issue a
11879 warning if the alignment of the target designated type is more strict
11880 than the alignment of the source designated type (since the result may
11881 be unaligned in this case).
11882
11883 A pointer other than a pointer to an unconstrained array type may be
11884 converted to and from System.Address.  Such usage is common in Ada 83
11885 programs, but note that Ada.Address_To_Access_Conversions is the
11886 preferred method of performing such conversions in Ada 95 and Ada 2005.
11887 Neither
11888 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11889 used in conjunction with pointers to unconstrained objects, since
11890 the bounds information cannot be handled correctly in this case.
11891
11892 @item Ada.Unchecked_Deallocation (13.11.2)
11893 This generic package allows explicit freeing of storage previously
11894 allocated by use of an allocator.
11895
11896 @item Ada.Wide_Text_IO (A.11)
11897 This package is similar to @code{Ada.Text_IO}, except that the external
11898 file supports wide character representations, and the internal types are
11899 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11900 and @code{String}.  It contains generic subpackages listed next.
11901
11902 @item Ada.Wide_Text_IO.Decimal_IO
11903 Provides input-output facilities for decimal fixed-point types
11904
11905 @item Ada.Wide_Text_IO.Enumeration_IO
11906 Provides input-output facilities for enumeration types.
11907
11908 @item Ada.Wide_Text_IO.Fixed_IO
11909 Provides input-output facilities for ordinary fixed-point types.
11910
11911 @item Ada.Wide_Text_IO.Float_IO
11912 Provides input-output facilities for float types.  The following
11913 predefined instantiations of this generic package are available:
11914
11915 @table @code
11916 @item Short_Float
11917 @code{Short_Float_Wide_Text_IO}
11918 @item Float
11919 @code{Float_Wide_Text_IO}
11920 @item Long_Float
11921 @code{Long_Float_Wide_Text_IO}
11922 @end table
11923
11924 @item Ada.Wide_Text_IO.Integer_IO
11925 Provides input-output facilities for integer types.  The following
11926 predefined instantiations of this generic package are available:
11927
11928 @table @code
11929 @item Short_Short_Integer
11930 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11931 @item Short_Integer
11932 @code{Ada.Short_Integer_Wide_Text_IO}
11933 @item Integer
11934 @code{Ada.Integer_Wide_Text_IO}
11935 @item Long_Integer
11936 @code{Ada.Long_Integer_Wide_Text_IO}
11937 @item Long_Long_Integer
11938 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11939 @end table
11940
11941 @item Ada.Wide_Text_IO.Modular_IO
11942 Provides input-output facilities for modular (unsigned) types
11943
11944 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11945 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11946 external file supports wide character representations.
11947
11948 @item Ada.Wide_Text_IO.Editing (F.3.4)
11949 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11950 types are @code{Wide_Character} and @code{Wide_String} instead of
11951 @code{Character} and @code{String}.
11952
11953 @item Ada.Wide_Text_IO.Streams (A.12.3)
11954 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11955 types are @code{Wide_Character} and @code{Wide_String} instead of
11956 @code{Character} and @code{String}.
11957
11958 @item Ada.Wide_Wide_Text_IO (A.11)
11959 This package is similar to @code{Ada.Text_IO}, except that the external
11960 file supports wide character representations, and the internal types are
11961 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11962 and @code{String}.  It contains generic subpackages listed next.
11963
11964 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11965 Provides input-output facilities for decimal fixed-point types
11966
11967 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11968 Provides input-output facilities for enumeration types.
11969
11970 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11971 Provides input-output facilities for ordinary fixed-point types.
11972
11973 @item Ada.Wide_Wide_Text_IO.Float_IO
11974 Provides input-output facilities for float types.  The following
11975 predefined instantiations of this generic package are available:
11976
11977 @table @code
11978 @item Short_Float
11979 @code{Short_Float_Wide_Wide_Text_IO}
11980 @item Float
11981 @code{Float_Wide_Wide_Text_IO}
11982 @item Long_Float
11983 @code{Long_Float_Wide_Wide_Text_IO}
11984 @end table
11985
11986 @item Ada.Wide_Wide_Text_IO.Integer_IO
11987 Provides input-output facilities for integer types.  The following
11988 predefined instantiations of this generic package are available:
11989
11990 @table @code
11991 @item Short_Short_Integer
11992 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11993 @item Short_Integer
11994 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11995 @item Integer
11996 @code{Ada.Integer_Wide_Wide_Text_IO}
11997 @item Long_Integer
11998 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11999 @item Long_Long_Integer
12000 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12001 @end table
12002
12003 @item Ada.Wide_Wide_Text_IO.Modular_IO
12004 Provides input-output facilities for modular (unsigned) types
12005
12006 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12007 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12008 external file supports wide character representations.
12009
12010 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12011 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12012 types are @code{Wide_Character} and @code{Wide_String} instead of
12013 @code{Character} and @code{String}.
12014
12015 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12016 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12017 types are @code{Wide_Character} and @code{Wide_String} instead of
12018 @code{Character} and @code{String}.
12019 @end table
12020
12021
12022
12023 @node The Implementation of Standard I/O
12024 @chapter The Implementation of Standard I/O
12025
12026 @noindent
12027 GNAT implements all the required input-output facilities described in
12028 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12029 required behavior of these packages from the Ada point of view, and if
12030 you are writing a portable Ada program that does not need to know the
12031 exact manner in which Ada maps to the outside world when it comes to
12032 reading or writing external files, then you do not need to read this
12033 chapter.  As long as your files are all regular files (not pipes or
12034 devices), and as long as you write and read the files only from Ada, the
12035 description in the Ada Reference Manual is sufficient.
12036
12037 However, if you want to do input-output to pipes or other devices, such
12038 as the keyboard or screen, or if the files you are dealing with are
12039 either generated by some other language, or to be read by some other
12040 language, then you need to know more about the details of how the GNAT
12041 implementation of these input-output facilities behaves.
12042
12043 In this chapter we give a detailed description of exactly how GNAT
12044 interfaces to the file system.  As always, the sources of the system are
12045 available to you for answering questions at an even more detailed level,
12046 but for most purposes the information in this chapter will suffice.
12047
12048 Another reason that you may need to know more about how input-output is
12049 implemented arises when you have a program written in mixed languages
12050 where, for example, files are shared between the C and Ada sections of
12051 the same program.  GNAT provides some additional facilities, in the form
12052 of additional child library packages, that facilitate this sharing, and
12053 these additional facilities are also described in this chapter.
12054
12055 @menu
12056 * Standard I/O Packages::
12057 * FORM Strings::
12058 * Direct_IO::
12059 * Sequential_IO::
12060 * Text_IO::
12061 * Wide_Text_IO::
12062 * Wide_Wide_Text_IO::
12063 * Stream_IO::
12064 * Shared Files::
12065 * Filenames encoding::
12066 * Open Modes::
12067 * Operations on C Streams::
12068 * Interfacing to C Streams::
12069 @end menu
12070
12071 @node Standard I/O Packages
12072 @section Standard I/O Packages
12073
12074 @noindent
12075 The Standard I/O packages described in Annex A for
12076
12077 @itemize @bullet
12078 @item
12079 Ada.Text_IO
12080 @item
12081 Ada.Text_IO.Complex_IO
12082 @item
12083 Ada.Text_IO.Text_Streams
12084 @item
12085 Ada.Wide_Text_IO
12086 @item
12087 Ada.Wide_Text_IO.Complex_IO
12088 @item
12089 Ada.Wide_Text_IO.Text_Streams
12090 @item
12091 Ada.Wide_Wide_Text_IO
12092 @item
12093 Ada.Wide_Wide_Text_IO.Complex_IO
12094 @item
12095 Ada.Wide_Wide_Text_IO.Text_Streams
12096 @item
12097 Ada.Stream_IO
12098 @item
12099 Ada.Sequential_IO
12100 @item
12101 Ada.Direct_IO
12102 @end itemize
12103
12104 @noindent
12105 are implemented using the C
12106 library streams facility; where
12107
12108 @itemize @bullet
12109 @item
12110 All files are opened using @code{fopen}.
12111 @item
12112 All input/output operations use @code{fread}/@code{fwrite}.
12113 @end itemize
12114
12115 @noindent
12116 There is no internal buffering of any kind at the Ada library level. The only
12117 buffering is that provided at the system level in the implementation of the
12118 library routines that support streams. This facilitates shared use of these
12119 streams by mixed language programs. Note though that system level buffering is
12120 explicitly enabled at elaboration of the standard I/O packages and that can
12121 have an impact on mixed language programs, in particular those using I/O before
12122 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12123 the Ada elaboration routine before performing any I/O or when impractical,
12124 flush the common I/O streams and in particular Standard_Output before
12125 elaborating the Ada code.
12126
12127 @node FORM Strings
12128 @section FORM Strings
12129
12130 @noindent
12131 The format of a FORM string in GNAT is:
12132
12133 @smallexample
12134 "keyword=value,keyword=value,@dots{},keyword=value"
12135 @end smallexample
12136
12137 @noindent
12138 where letters may be in upper or lower case, and there are no spaces
12139 between values.  The order of the entries is not important.  Currently
12140 there are two keywords defined.
12141
12142 @smallexample
12143 SHARED=[YES|NO]
12144 WCEM=[n|h|u|s|e|8|b]
12145 @end smallexample
12146
12147 @noindent
12148 The use of these parameters is described later in this section.
12149
12150 @node Direct_IO
12151 @section Direct_IO
12152
12153 @noindent
12154 Direct_IO can only be instantiated for definite types.  This is a
12155 restriction of the Ada language, which means that the records are fixed
12156 length (the length being determined by @code{@var{type}'Size}, rounded
12157 up to the next storage unit boundary if necessary).
12158
12159 The records of a Direct_IO file are simply written to the file in index
12160 sequence, with the first record starting at offset zero, and subsequent
12161 records following.  There is no control information of any kind.  For
12162 example, if 32-bit integers are being written, each record takes
12163 4-bytes, so the record at index @var{K} starts at offset
12164 (@var{K}@minus{}1)*4.
12165
12166 There is no limit on the size of Direct_IO files, they are expanded as
12167 necessary to accommodate whatever records are written to the file.
12168
12169 @node Sequential_IO
12170 @section Sequential_IO
12171
12172 @noindent
12173 Sequential_IO may be instantiated with either a definite (constrained)
12174 or indefinite (unconstrained) type.
12175
12176 For the definite type case, the elements written to the file are simply
12177 the memory images of the data values with no control information of any
12178 kind.  The resulting file should be read using the same type, no validity
12179 checking is performed on input.
12180
12181 For the indefinite type case, the elements written consist of two
12182 parts.  First is the size of the data item, written as the memory image
12183 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12184 the data value.  The resulting file can only be read using the same
12185 (unconstrained) type.  Normal assignment checks are performed on these
12186 read operations, and if these checks fail, @code{Data_Error} is
12187 raised.  In particular, in the array case, the lengths must match, and in
12188 the variant record case, if the variable for a particular read operation
12189 is constrained, the discriminants must match.
12190
12191 Note that it is not possible to use Sequential_IO to write variable
12192 length array items, and then read the data back into different length
12193 arrays.  For example, the following will raise @code{Data_Error}:
12194
12195 @smallexample @c ada
12196  package IO is new Sequential_IO (String);
12197  F : IO.File_Type;
12198  S : String (1..4);
12199  @dots{}
12200  IO.Create (F)
12201  IO.Write (F, "hello!")
12202  IO.Reset (F, Mode=>In_File);
12203  IO.Read (F, S);
12204  Put_Line (S);
12205
12206 @end smallexample
12207
12208 @noindent
12209 On some Ada implementations, this will print @code{hell}, but the program is
12210 clearly incorrect, since there is only one element in the file, and that
12211 element is the string @code{hello!}.
12212
12213 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12214 using Stream_IO, and this is the preferred mechanism.  In particular, the
12215 above program fragment rewritten to use Stream_IO will work correctly.
12216
12217 @node Text_IO
12218 @section Text_IO
12219
12220 @noindent
12221 Text_IO files consist of a stream of characters containing the following
12222 special control characters:
12223
12224 @smallexample
12225 LF (line feed, 16#0A#) Line Mark
12226 FF (form feed, 16#0C#) Page Mark
12227 @end smallexample
12228
12229 @noindent
12230 A canonical Text_IO file is defined as one in which the following
12231 conditions are met:
12232
12233 @itemize @bullet
12234 @item
12235 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12236 of the line.
12237
12238 @item
12239 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12240 end of a page and consequently can appear only immediately following a
12241 @code{LF} (line mark) character.
12242
12243 @item
12244 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12245 (line mark, page mark).  In the former case, the page mark is implicitly
12246 assumed to be present.
12247 @end itemize
12248
12249 @noindent
12250 A file written using Text_IO will be in canonical form provided that no
12251 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12252 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12253 the file unless an explicit @code{New_Page} operation was performed
12254 before closing the file.
12255
12256 A canonical Text_IO file that is a regular file (i.e., not a device or a
12257 pipe) can be read using any of the routines in Text_IO@.  The
12258 semantics in this case will be exactly as defined in the Ada Reference
12259 Manual, and all the routines in Text_IO are fully implemented.
12260
12261 A text file that does not meet the requirements for a canonical Text_IO
12262 file has one of the following:
12263
12264 @itemize @bullet
12265 @item
12266 The file contains @code{FF} characters not immediately following a
12267 @code{LF} character.
12268
12269 @item
12270 The file contains @code{LF} or @code{FF} characters written by
12271 @code{Put} or @code{Put_Line}, which are not logically considered to be
12272 line marks or page marks.
12273
12274 @item
12275 The file ends in a character other than @code{LF} or @code{FF},
12276 i.e.@: there is no explicit line mark or page mark at the end of the file.
12277 @end itemize
12278
12279 @noindent
12280 Text_IO can be used to read such non-standard text files but subprograms
12281 to do with line or page numbers do not have defined meanings.  In
12282 particular, a @code{FF} character that does not follow a @code{LF}
12283 character may or may not be treated as a page mark from the point of
12284 view of page and line numbering.  Every @code{LF} character is considered
12285 to end a line, and there is an implied @code{LF} character at the end of
12286 the file.
12287
12288 @menu
12289 * Text_IO Stream Pointer Positioning::
12290 * Text_IO Reading and Writing Non-Regular Files::
12291 * Get_Immediate::
12292 * Treating Text_IO Files as Streams::
12293 * Text_IO Extensions::
12294 * Text_IO Facilities for Unbounded Strings::
12295 @end menu
12296
12297 @node Text_IO Stream Pointer Positioning
12298 @subsection Stream Pointer Positioning
12299
12300 @noindent
12301 @code{Ada.Text_IO} has a definition of current position for a file that
12302 is being read.  No internal buffering occurs in Text_IO, and usually the
12303 physical position in the stream used to implement the file corresponds
12304 to this logical position defined by Text_IO@.  There are two exceptions:
12305
12306 @itemize @bullet
12307 @item
12308 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12309 is positioned past the @code{LF} (line mark) that precedes the page
12310 mark.  Text_IO maintains an internal flag so that subsequent read
12311 operations properly handle the logical position which is unchanged by
12312 the @code{End_Of_Page} call.
12313
12314 @item
12315 After a call to @code{End_Of_File} that returns @code{True}, if the
12316 Text_IO file was positioned before the line mark at the end of file
12317 before the call, then the logical position is unchanged, but the stream
12318 is physically positioned right at the end of file (past the line mark,
12319 and past a possible page mark following the line mark.  Again Text_IO
12320 maintains internal flags so that subsequent read operations properly
12321 handle the logical position.
12322 @end itemize
12323
12324 @noindent
12325 These discrepancies have no effect on the observable behavior of
12326 Text_IO, but if a single Ada stream is shared between a C program and
12327 Ada program, or shared (using @samp{shared=yes} in the form string)
12328 between two Ada files, then the difference may be observable in some
12329 situations.
12330
12331 @node Text_IO Reading and Writing Non-Regular Files
12332 @subsection Reading and Writing Non-Regular Files
12333
12334 @noindent
12335 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12336 can be used for reading and writing.  Writing is not affected and the
12337 sequence of characters output is identical to the normal file case, but
12338 for reading, the behavior of Text_IO is modified to avoid undesirable
12339 look-ahead as follows:
12340
12341 An input file that is not a regular file is considered to have no page
12342 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12343 page mark) appearing in the file are considered to be data
12344 characters.  In particular:
12345
12346 @itemize @bullet
12347 @item
12348 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12349 following a line mark.  If a page mark appears, it will be treated as a
12350 data character.
12351
12352 @item
12353 This avoids the need to wait for an extra character to be typed or
12354 entered from the pipe to complete one of these operations.
12355
12356 @item
12357 @code{End_Of_Page} always returns @code{False}
12358
12359 @item
12360 @code{End_Of_File} will return @code{False} if there is a page mark at
12361 the end of the file.
12362 @end itemize
12363
12364 @noindent
12365 Output to non-regular files is the same as for regular files.  Page marks
12366 may be written to non-regular files using @code{New_Page}, but as noted
12367 above they will not be treated as page marks on input if the output is
12368 piped to another Ada program.
12369
12370 Another important discrepancy when reading non-regular files is that the end
12371 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12372 pressing the @key{EOT} key,
12373 then end of file
12374 is signaled once (i.e.@: the test @code{End_Of_File}
12375 will yield @code{True}, or a read will
12376 raise @code{End_Error}), but then reading can resume
12377 to read data past that end of
12378 file indication, until another end of file indication is entered.
12379
12380 @node Get_Immediate
12381 @subsection Get_Immediate
12382 @cindex Get_Immediate
12383
12384 @noindent
12385 Get_Immediate returns the next character (including control characters)
12386 from the input file.  In particular, Get_Immediate will return LF or FF
12387 characters used as line marks or page marks.  Such operations leave the
12388 file positioned past the control character, and it is thus not treated
12389 as having its normal function.  This means that page, line and column
12390 counts after this kind of Get_Immediate call are set as though the mark
12391 did not occur.  In the case where a Get_Immediate leaves the file
12392 positioned between the line mark and page mark (which is not normally
12393 possible), it is undefined whether the FF character will be treated as a
12394 page mark.
12395
12396 @node Treating Text_IO Files as Streams
12397 @subsection Treating Text_IO Files as Streams
12398 @cindex Stream files
12399
12400 @noindent
12401 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12402 as a stream.  Data written to a Text_IO file in this stream mode is
12403 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12404 16#0C# (@code{FF}), the resulting file may have non-standard
12405 format.  Similarly if read operations are used to read from a Text_IO
12406 file treated as a stream, then @code{LF} and @code{FF} characters may be
12407 skipped and the effect is similar to that described above for
12408 @code{Get_Immediate}.
12409
12410 @node Text_IO Extensions
12411 @subsection Text_IO Extensions
12412 @cindex Text_IO extensions
12413
12414 @noindent
12415 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12416 to the standard @code{Text_IO} package:
12417
12418 @itemize @bullet
12419 @item function File_Exists (Name : String) return Boolean;
12420 Determines if a file of the given name exists.
12421
12422 @item function Get_Line return String;
12423 Reads a string from the standard input file.  The value returned is exactly
12424 the length of the line that was read.
12425
12426 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12427 Similar, except that the parameter File specifies the file from which
12428 the string is to be read.
12429
12430 @end itemize
12431
12432 @node Text_IO Facilities for Unbounded Strings
12433 @subsection Text_IO Facilities for Unbounded Strings
12434 @cindex Text_IO for unbounded strings
12435 @cindex Unbounded_String, Text_IO operations
12436
12437 @noindent
12438 The package @code{Ada.Strings.Unbounded.Text_IO}
12439 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12440 subprograms useful for Text_IO operations on unbounded strings:
12441
12442 @itemize @bullet
12443
12444 @item function Get_Line (File : File_Type) return Unbounded_String;
12445 Reads a line from the specified file
12446 and returns the result as an unbounded string.
12447
12448 @item procedure Put (File : File_Type; U : Unbounded_String);
12449 Writes the value of the given unbounded string to the specified file
12450 Similar to the effect of
12451 @code{Put (To_String (U))} except that an extra copy is avoided.
12452
12453 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12454 Writes the value of the given unbounded string to the specified file,
12455 followed by a @code{New_Line}.
12456 Similar to the effect of @code{Put_Line (To_String (U))} except
12457 that an extra copy is avoided.
12458 @end itemize
12459
12460 @noindent
12461 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12462 and is optional.  If the parameter is omitted, then the standard input or
12463 output file is referenced as appropriate.
12464
12465 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12466 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12467 @code{Wide_Text_IO} functionality for unbounded wide strings.
12468
12469 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12470 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12471 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12472
12473 @node Wide_Text_IO
12474 @section Wide_Text_IO
12475
12476 @noindent
12477 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12478 both input and output files may contain special sequences that represent
12479 wide character values.  The encoding scheme for a given file may be
12480 specified using a FORM parameter:
12481
12482 @smallexample
12483 WCEM=@var{x}
12484 @end smallexample
12485
12486 @noindent
12487 as part of the FORM string (WCEM = wide character encoding method),
12488 where @var{x} is one of the following characters
12489
12490 @table @samp
12491 @item h
12492 Hex ESC encoding
12493 @item u
12494 Upper half encoding
12495 @item s
12496 Shift-JIS encoding
12497 @item e
12498 EUC Encoding
12499 @item 8
12500 UTF-8 encoding
12501 @item b
12502 Brackets encoding
12503 @end table
12504
12505 @noindent
12506 The encoding methods match those that
12507 can be used in a source
12508 program, but there is no requirement that the encoding method used for
12509 the source program be the same as the encoding method used for files,
12510 and different files may use different encoding methods.
12511
12512 The default encoding method for the standard files, and for opened files
12513 for which no WCEM parameter is given in the FORM string matches the
12514 wide character encoding specified for the main program (the default
12515 being brackets encoding if no coding method was specified with -gnatW).
12516
12517 @table @asis
12518 @item Hex Coding
12519 In this encoding, a wide character is represented by a five character
12520 sequence:
12521
12522 @smallexample
12523 ESC a b c d
12524 @end smallexample
12525
12526 @noindent
12527 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12528 characters (using upper case letters) of the wide character code.  For
12529 example, ESC A345 is used to represent the wide character with code
12530 16#A345#.  This scheme is compatible with use of the full
12531 @code{Wide_Character} set.
12532
12533 @item Upper Half Coding
12534 The wide character with encoding 16#abcd#, where the upper bit is on
12535 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12536 16#cd#.  The second byte may never be a format control character, but is
12537 not required to be in the upper half.  This method can be also used for
12538 shift-JIS or EUC where the internal coding matches the external coding.
12539
12540 @item Shift JIS Coding
12541 A wide character is represented by a two character sequence 16#ab# and
12542 16#cd#, with the restrictions described for upper half encoding as
12543 described above.  The internal character code is the corresponding JIS
12544 character according to the standard algorithm for Shift-JIS
12545 conversion.  Only characters defined in the JIS code set table can be
12546 used with this encoding method.
12547
12548 @item EUC Coding
12549 A wide character is represented by a two character sequence 16#ab# and
12550 16#cd#, with both characters being in the upper half.  The internal
12551 character code is the corresponding JIS character according to the EUC
12552 encoding algorithm.  Only characters defined in the JIS code set table
12553 can be used with this encoding method.
12554
12555 @item UTF-8 Coding
12556 A wide character is represented using
12557 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12558 10646-1/Am.2.  Depending on the character value, the representation
12559 is a one, two, or three byte sequence:
12560
12561 @smallexample
12562 16#0000#-16#007f#: 2#0xxxxxxx#
12563 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12564 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12565 @end smallexample
12566
12567 @noindent
12568 where the @var{xxx} bits correspond to the left-padded bits of the
12569 16-bit character value.  Note that all lower half ASCII characters
12570 are represented as ASCII bytes and all upper half characters and
12571 other wide characters are represented as sequences of upper-half
12572 (The full UTF-8 scheme allows for encoding 31-bit characters as
12573 6-byte sequences, but in this implementation, all UTF-8 sequences
12574 of four or more bytes length will raise a Constraint_Error, as
12575 will all invalid UTF-8 sequences.)
12576
12577 @item Brackets Coding
12578 In this encoding, a wide character is represented by the following eight
12579 character sequence:
12580
12581 @smallexample
12582 [ " a b c d " ]
12583 @end smallexample
12584
12585 @noindent
12586 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12587 characters (using uppercase letters) of the wide character code.  For
12588 example, @code{["A345"]} is used to represent the wide character with code
12589 @code{16#A345#}.
12590 This scheme is compatible with use of the full Wide_Character set.
12591 On input, brackets coding can also be used for upper half characters,
12592 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12593 is only used for wide characters with a code greater than @code{16#FF#}.
12594
12595 Note that brackets coding is not normally used in the context of
12596 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12597 a portable way of encoding source files. In the context of Wide_Text_IO
12598 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12599 any instance of the left bracket character other than to encode wide
12600 character values using the brackets encoding method. In practice it is
12601 expected that some standard wide character encoding method such
12602 as UTF-8 will be used for text input output.
12603
12604 If brackets notation is used, then any occurrence of a left bracket
12605 in the input file which is not the start of a valid wide character
12606 sequence will cause Constraint_Error to be raised. It is possible to
12607 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12608 input will interpret this as a left bracket.
12609
12610 However, when a left bracket is output, it will be output as a left bracket
12611 and not as ["5B"]. We make this decision because for normal use of
12612 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12613 brackets. For example, if we write:
12614
12615 @smallexample
12616    Put_Line ("Start of output [first run]");
12617 @end smallexample
12618
12619 @noindent
12620 we really do not want to have the left bracket in this message clobbered so
12621 that the output reads:
12622
12623 @smallexample
12624    Start of output ["5B"]first run]
12625 @end smallexample
12626
12627 @noindent
12628 In practice brackets encoding is reasonably useful for normal Put_Line use
12629 since we won't get confused between left brackets and wide character
12630 sequences in the output. But for input, or when files are written out
12631 and read back in, it really makes better sense to use one of the standard
12632 encoding methods such as UTF-8.
12633
12634 @end table
12635
12636 @noindent
12637 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12638 not all wide character
12639 values can be represented.  An attempt to output a character that cannot
12640 be represented using the encoding scheme for the file causes
12641 Constraint_Error to be raised.  An invalid wide character sequence on
12642 input also causes Constraint_Error to be raised.
12643
12644 @menu
12645 * Wide_Text_IO Stream Pointer Positioning::
12646 * Wide_Text_IO Reading and Writing Non-Regular Files::
12647 @end menu
12648
12649 @node Wide_Text_IO Stream Pointer Positioning
12650 @subsection Stream Pointer Positioning
12651
12652 @noindent
12653 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12654 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12655 case:
12656
12657 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12658 normal lower ASCII set (i.e.@: a character in the range:
12659
12660 @smallexample @c ada
12661 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12662 @end smallexample
12663
12664 @noindent
12665 then although the logical position of the file pointer is unchanged by
12666 the @code{Look_Ahead} call, the stream is physically positioned past the
12667 wide character sequence.  Again this is to avoid the need for buffering
12668 or backup, and all @code{Wide_Text_IO} routines check the internal
12669 indication that this situation has occurred so that this is not visible
12670 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12671 can be observed if the wide text file shares a stream with another file.
12672
12673 @node Wide_Text_IO Reading and Writing Non-Regular Files
12674 @subsection Reading and Writing Non-Regular Files
12675
12676 @noindent
12677 As in the case of Text_IO, when a non-regular file is read, it is
12678 assumed that the file contains no page marks (any form characters are
12679 treated as data characters), and @code{End_Of_Page} always returns
12680 @code{False}.  Similarly, the end of file indication is not sticky, so
12681 it is possible to read beyond an end of file.
12682
12683 @node Wide_Wide_Text_IO
12684 @section Wide_Wide_Text_IO
12685
12686 @noindent
12687 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12688 both input and output files may contain special sequences that represent
12689 wide wide character values.  The encoding scheme for a given file may be
12690 specified using a FORM parameter:
12691
12692 @smallexample
12693 WCEM=@var{x}
12694 @end smallexample
12695
12696 @noindent
12697 as part of the FORM string (WCEM = wide character encoding method),
12698 where @var{x} is one of the following characters
12699
12700 @table @samp
12701 @item h
12702 Hex ESC encoding
12703 @item u
12704 Upper half encoding
12705 @item s
12706 Shift-JIS encoding
12707 @item e
12708 EUC Encoding
12709 @item 8
12710 UTF-8 encoding
12711 @item b
12712 Brackets encoding
12713 @end table
12714
12715 @noindent
12716 The encoding methods match those that
12717 can be used in a source
12718 program, but there is no requirement that the encoding method used for
12719 the source program be the same as the encoding method used for files,
12720 and different files may use different encoding methods.
12721
12722 The default encoding method for the standard files, and for opened files
12723 for which no WCEM parameter is given in the FORM string matches the
12724 wide character encoding specified for the main program (the default
12725 being brackets encoding if no coding method was specified with -gnatW).
12726
12727 @table @asis
12728
12729 @item UTF-8 Coding
12730 A wide character is represented using
12731 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12732 10646-1/Am.2.  Depending on the character value, the representation
12733 is a one, two, three, or four byte sequence:
12734
12735 @smallexample
12736 16#000000#-16#00007f#: 2#0xxxxxxx#
12737 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12738 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12739 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12740 @end smallexample
12741
12742 @noindent
12743 where the @var{xxx} bits correspond to the left-padded bits of the
12744 21-bit character value.  Note that all lower half ASCII characters
12745 are represented as ASCII bytes and all upper half characters and
12746 other wide characters are represented as sequences of upper-half
12747 characters.
12748
12749 @item Brackets Coding
12750 In this encoding, a wide wide character is represented by the following eight
12751 character sequence if is in wide character range
12752
12753 @smallexample
12754 [ " a b c d " ]
12755 @end smallexample
12756
12757 and by the following ten character sequence if not
12758
12759 @smallexample
12760 [ " a b c d e f " ]
12761 @end smallexample
12762
12763 @noindent
12764 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12765 are the four or six hexadecimal
12766 characters (using uppercase letters) of the wide wide character code.  For
12767 example, @code{["01A345"]} is used to represent the wide wide character
12768 with code @code{16#01A345#}.
12769
12770 This scheme is compatible with use of the full Wide_Wide_Character set.
12771 On input, brackets coding can also be used for upper half characters,
12772 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12773 is only used for wide characters with a code greater than @code{16#FF#}.
12774
12775 @end table
12776
12777 @noindent
12778 If is also possible to use the other Wide_Character encoding methods,
12779 such as Shift-JIS, but the other schemes cannot support the full range
12780 of wide wide characters.
12781 An attempt to output a character that cannot
12782 be represented using the encoding scheme for the file causes
12783 Constraint_Error to be raised.  An invalid wide character sequence on
12784 input also causes Constraint_Error to be raised.
12785
12786 @menu
12787 * Wide_Wide_Text_IO Stream Pointer Positioning::
12788 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12789 @end menu
12790
12791 @node Wide_Wide_Text_IO Stream Pointer Positioning
12792 @subsection Stream Pointer Positioning
12793
12794 @noindent
12795 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12796 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12797 case:
12798
12799 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12800 normal lower ASCII set (i.e.@: a character in the range:
12801
12802 @smallexample @c ada
12803 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12804 @end smallexample
12805
12806 @noindent
12807 then although the logical position of the file pointer is unchanged by
12808 the @code{Look_Ahead} call, the stream is physically positioned past the
12809 wide character sequence.  Again this is to avoid the need for buffering
12810 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12811 indication that this situation has occurred so that this is not visible
12812 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12813 can be observed if the wide text file shares a stream with another file.
12814
12815 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12816 @subsection Reading and Writing Non-Regular Files
12817
12818 @noindent
12819 As in the case of Text_IO, when a non-regular file is read, it is
12820 assumed that the file contains no page marks (any form characters are
12821 treated as data characters), and @code{End_Of_Page} always returns
12822 @code{False}.  Similarly, the end of file indication is not sticky, so
12823 it is possible to read beyond an end of file.
12824
12825 @node Stream_IO
12826 @section Stream_IO
12827
12828 @noindent
12829 A stream file is a sequence of bytes, where individual elements are
12830 written to the file as described in the Ada Reference Manual.  The type
12831 @code{Stream_Element} is simply a byte.  There are two ways to read or
12832 write a stream file.
12833
12834 @itemize @bullet
12835 @item
12836 The operations @code{Read} and @code{Write} directly read or write a
12837 sequence of stream elements with no control information.
12838
12839 @item
12840 The stream attributes applied to a stream file transfer data in the
12841 manner described for stream attributes.
12842 @end itemize
12843
12844 @node Shared Files
12845 @section Shared Files
12846
12847 @noindent
12848 Section A.14 of the Ada Reference Manual allows implementations to
12849 provide a wide variety of behavior if an attempt is made to access the
12850 same external file with two or more internal files.
12851
12852 To provide a full range of functionality, while at the same time
12853 minimizing the problems of portability caused by this implementation
12854 dependence, GNAT handles file sharing as follows:
12855
12856 @itemize @bullet
12857 @item
12858 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12859 to open two or more files with the same full name is considered an error
12860 and is not supported.  The exception @code{Use_Error} will be
12861 raised.  Note that a file that is not explicitly closed by the program
12862 remains open until the program terminates.
12863
12864 @item
12865 If the form parameter @samp{shared=no} appears in the form string, the
12866 file can be opened or created with its own separate stream identifier,
12867 regardless of whether other files sharing the same external file are
12868 opened.  The exact effect depends on how the C stream routines handle
12869 multiple accesses to the same external files using separate streams.
12870
12871 @item
12872 If the form parameter @samp{shared=yes} appears in the form string for
12873 each of two or more files opened using the same full name, the same
12874 stream is shared between these files, and the semantics are as described
12875 in Ada Reference Manual, Section A.14.
12876 @end itemize
12877
12878 @noindent
12879 When a program that opens multiple files with the same name is ported
12880 from another Ada compiler to GNAT, the effect will be that
12881 @code{Use_Error} is raised.
12882
12883 The documentation of the original compiler and the documentation of the
12884 program should then be examined to determine if file sharing was
12885 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12886 and @code{Create} calls as required.
12887
12888 When a program is ported from GNAT to some other Ada compiler, no
12889 special attention is required unless the @samp{shared=@var{xxx}} form
12890 parameter is used in the program.  In this case, you must examine the
12891 documentation of the new compiler to see if it supports the required
12892 file sharing semantics, and form strings modified appropriately.  Of
12893 course it may be the case that the program cannot be ported if the
12894 target compiler does not support the required functionality.  The best
12895 approach in writing portable code is to avoid file sharing (and hence
12896 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12897 completely.
12898
12899 One common use of file sharing in Ada 83 is the use of instantiations of
12900 Sequential_IO on the same file with different types, to achieve
12901 heterogeneous input-output.  Although this approach will work in GNAT if
12902 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12903 for this purpose (using the stream attributes)
12904
12905 @node Filenames encoding
12906 @section Filenames encoding
12907
12908 @noindent
12909 An encoding form parameter can be used to specify the filename
12910 encoding @samp{encoding=@var{xxx}}.
12911
12912 @itemize @bullet
12913 @item
12914 If the form parameter @samp{encoding=utf8} appears in the form string, the
12915 filename must be encoded in UTF-8.
12916
12917 @item
12918 If the form parameter @samp{encoding=8bits} appears in the form
12919 string, the filename must be a standard 8bits string.
12920 @end itemize
12921
12922 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12923 value UTF-8 is used. This encoding form parameter is only supported on
12924 the Windows platform. On the other Operating Systems the runtime is
12925 supporting UTF-8 natively.
12926
12927 @node Open Modes
12928 @section Open Modes
12929
12930 @noindent
12931 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12932 using the mode shown in the following table:
12933
12934 @sp 2
12935 @center @code{Open} and @code{Create} Call Modes
12936 @smallexample
12937                                @b{OPEN }           @b{CREATE}
12938 Append_File                    "r+"             "w+"
12939 In_File                        "r"              "w+"
12940 Out_File (Direct_IO)           "r+"             "w"
12941 Out_File (all other cases)     "w"              "w"
12942 Inout_File                     "r+"             "w+"
12943 @end smallexample
12944
12945 @noindent
12946 If text file translation is required, then either @samp{b} or @samp{t}
12947 is added to the mode, depending on the setting of Text.  Text file
12948 translation refers to the mapping of CR/LF sequences in an external file
12949 to LF characters internally.  This mapping only occurs in DOS and
12950 DOS-like systems, and is not relevant to other systems.
12951
12952 A special case occurs with Stream_IO@.  As shown in the above table, the
12953 file is initially opened in @samp{r} or @samp{w} mode for the
12954 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12955 subsequently requires switching from reading to writing or vice-versa,
12956 then the file is reopened in @samp{r+} mode to permit the required operation.
12957
12958 @node Operations on C Streams
12959 @section Operations on C Streams
12960 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12961 access to the C library functions for operations on C streams:
12962
12963 @smallexample @c adanocomment
12964 package Interfaces.C_Streams is
12965   -- Note: the reason we do not use the types that are in
12966   -- Interfaces.C is that we want to avoid dragging in the
12967   -- code in this unit if possible.
12968   subtype chars is System.Address;
12969   -- Pointer to null-terminated array of characters
12970   subtype FILEs is System.Address;
12971   -- Corresponds to the C type FILE*
12972   subtype voids is System.Address;
12973   -- Corresponds to the C type void*
12974   subtype int is Integer;
12975   subtype long is Long_Integer;
12976   -- Note: the above types are subtypes deliberately, and it
12977   -- is part of this spec that the above correspondences are
12978   -- guaranteed.  This means that it is legitimate to, for
12979   -- example, use Integer instead of int.  We provide these
12980   -- synonyms for clarity, but in some cases it may be
12981   -- convenient to use the underlying types (for example to
12982   -- avoid an unnecessary dependency of a spec on the spec
12983   -- of this unit).
12984   type size_t is mod 2 ** Standard'Address_Size;
12985   NULL_Stream : constant FILEs;
12986   -- Value returned (NULL in C) to indicate an
12987   -- fdopen/fopen/tmpfile error
12988   ----------------------------------
12989   -- Constants Defined in stdio.h --
12990   ----------------------------------
12991   EOF : constant int;
12992   -- Used by a number of routines to indicate error or
12993   -- end of file
12994   IOFBF : constant int;
12995   IOLBF : constant int;
12996   IONBF : constant int;
12997   -- Used to indicate buffering mode for setvbuf call
12998   SEEK_CUR : constant int;
12999   SEEK_END : constant int;
13000   SEEK_SET : constant int;
13001   -- Used to indicate origin for fseek call
13002   function stdin return FILEs;
13003   function stdout return FILEs;
13004   function stderr return FILEs;
13005   -- Streams associated with standard files
13006   --------------------------
13007   -- Standard C functions --
13008   --------------------------
13009   -- The functions selected below are ones that are
13010   -- available in DOS, OS/2, UNIX and Xenix (but not
13011   -- necessarily in ANSI C).  These are very thin interfaces
13012   -- which copy exactly the C headers.  For more
13013   -- documentation on these functions, see the Microsoft C
13014   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13015   -- ISBN 1-55615-225-6), which includes useful information
13016   -- on system compatibility.
13017   procedure clearerr (stream : FILEs);
13018   function fclose (stream : FILEs) return int;
13019   function fdopen (handle : int; mode : chars) return FILEs;
13020   function feof (stream : FILEs) return int;
13021   function ferror (stream : FILEs) return int;
13022   function fflush (stream : FILEs) return int;
13023   function fgetc (stream : FILEs) return int;
13024   function fgets (strng : chars; n : int; stream : FILEs)
13025       return chars;
13026   function fileno (stream : FILEs) return int;
13027   function fopen (filename : chars; Mode : chars)
13028       return FILEs;
13029   -- Note: to maintain target independence, use
13030   -- text_translation_required, a boolean variable defined in
13031   -- a-sysdep.c to deal with the target dependent text
13032   -- translation requirement.  If this variable is set,
13033   -- then  b/t should be appended to the standard mode
13034   -- argument to set the text translation mode off or on
13035   -- as required.
13036   function fputc (C : int; stream : FILEs) return int;
13037   function fputs (Strng : chars; Stream : FILEs) return int;
13038   function fread
13039      (buffer : voids;
13040       size : size_t;
13041       count : size_t;
13042       stream : FILEs)
13043       return size_t;
13044   function freopen
13045      (filename : chars;
13046       mode : chars;
13047       stream : FILEs)
13048       return FILEs;
13049   function fseek
13050      (stream : FILEs;
13051       offset : long;
13052       origin : int)
13053       return int;
13054   function ftell (stream : FILEs) return long;
13055   function fwrite
13056      (buffer : voids;
13057       size : size_t;
13058       count : size_t;
13059       stream : FILEs)
13060       return size_t;
13061   function isatty (handle : int) return int;
13062   procedure mktemp (template : chars);
13063   -- The return value (which is just a pointer to template)
13064   -- is discarded
13065   procedure rewind (stream : FILEs);
13066   function rmtmp return int;
13067   function setvbuf
13068      (stream : FILEs;
13069       buffer : chars;
13070       mode : int;
13071       size : size_t)
13072       return int;
13073
13074   function tmpfile return FILEs;
13075   function ungetc (c : int; stream : FILEs) return int;
13076   function unlink (filename : chars) return int;
13077   ---------------------
13078   -- Extra functions --
13079   ---------------------
13080   -- These functions supply slightly thicker bindings than
13081   -- those above.  They are derived from functions in the
13082   -- C Run-Time Library, but may do a bit more work than
13083   -- just directly calling one of the Library functions.
13084   function is_regular_file (handle : int) return int;
13085   -- Tests if given handle is for a regular file (result 1)
13086   -- or for a non-regular file (pipe or device, result 0).
13087   ---------------------------------
13088   -- Control of Text/Binary Mode --
13089   ---------------------------------
13090   -- If text_translation_required is true, then the following
13091   -- functions may be used to dynamically switch a file from
13092   -- binary to text mode or vice versa.  These functions have
13093   -- no effect if text_translation_required is false (i.e.@: in
13094   -- normal UNIX mode).  Use fileno to get a stream handle.
13095   procedure set_binary_mode (handle : int);
13096   procedure set_text_mode (handle : int);
13097   ----------------------------
13098   -- Full Path Name support --
13099   ----------------------------
13100   procedure full_name (nam : chars; buffer : chars);
13101   -- Given a NUL terminated string representing a file
13102   -- name, returns in buffer a NUL terminated string
13103   -- representing the full path name for the file name.
13104   -- On systems where it is relevant the   drive is also
13105   -- part of the full path name.  It is the responsibility
13106   -- of the caller to pass an actual parameter for buffer
13107   -- that is big enough for any full path name.  Use
13108   -- max_path_len given below as the size of buffer.
13109   max_path_len : integer;
13110   -- Maximum length of an allowable full path name on the
13111   -- system, including a terminating NUL character.
13112 end Interfaces.C_Streams;
13113 @end smallexample
13114
13115 @node Interfacing to C Streams
13116 @section Interfacing to C Streams
13117
13118 @noindent
13119 The packages in this section permit interfacing Ada files to C Stream
13120 operations.
13121
13122 @smallexample @c ada
13123  with Interfaces.C_Streams;
13124  package Ada.Sequential_IO.C_Streams is
13125     function C_Stream (F : File_Type)
13126        return Interfaces.C_Streams.FILEs;
13127     procedure Open
13128       (File : in out File_Type;
13129        Mode : in File_Mode;
13130        C_Stream : in Interfaces.C_Streams.FILEs;
13131        Form : in String := "");
13132  end Ada.Sequential_IO.C_Streams;
13133
13134   with Interfaces.C_Streams;
13135   package Ada.Direct_IO.C_Streams is
13136      function C_Stream (F : File_Type)
13137         return Interfaces.C_Streams.FILEs;
13138      procedure Open
13139        (File : in out File_Type;
13140         Mode : in File_Mode;
13141         C_Stream : in Interfaces.C_Streams.FILEs;
13142         Form : in String := "");
13143   end Ada.Direct_IO.C_Streams;
13144
13145   with Interfaces.C_Streams;
13146   package Ada.Text_IO.C_Streams is
13147      function C_Stream (F : File_Type)
13148         return Interfaces.C_Streams.FILEs;
13149      procedure Open
13150        (File : in out File_Type;
13151         Mode : in File_Mode;
13152         C_Stream : in Interfaces.C_Streams.FILEs;
13153         Form : in String := "");
13154   end Ada.Text_IO.C_Streams;
13155
13156   with Interfaces.C_Streams;
13157   package Ada.Wide_Text_IO.C_Streams is
13158      function C_Stream (F : File_Type)
13159         return Interfaces.C_Streams.FILEs;
13160      procedure Open
13161        (File : in out File_Type;
13162         Mode : in File_Mode;
13163         C_Stream : in Interfaces.C_Streams.FILEs;
13164         Form : in String := "");
13165  end Ada.Wide_Text_IO.C_Streams;
13166
13167   with Interfaces.C_Streams;
13168   package Ada.Wide_Wide_Text_IO.C_Streams is
13169      function C_Stream (F : File_Type)
13170         return Interfaces.C_Streams.FILEs;
13171      procedure Open
13172        (File : in out File_Type;
13173         Mode : in File_Mode;
13174         C_Stream : in Interfaces.C_Streams.FILEs;
13175         Form : in String := "");
13176  end Ada.Wide_Wide_Text_IO.C_Streams;
13177
13178  with Interfaces.C_Streams;
13179  package Ada.Stream_IO.C_Streams is
13180     function C_Stream (F : File_Type)
13181        return Interfaces.C_Streams.FILEs;
13182     procedure Open
13183       (File : in out File_Type;
13184        Mode : in File_Mode;
13185        C_Stream : in Interfaces.C_Streams.FILEs;
13186        Form : in String := "");
13187  end Ada.Stream_IO.C_Streams;
13188 @end smallexample
13189
13190 @noindent
13191 In each of these six packages, the @code{C_Stream} function obtains the
13192 @code{FILE} pointer from a currently opened Ada file.  It is then
13193 possible to use the @code{Interfaces.C_Streams} package to operate on
13194 this stream, or the stream can be passed to a C program which can
13195 operate on it directly.  Of course the program is responsible for
13196 ensuring that only appropriate sequences of operations are executed.
13197
13198 One particular use of relevance to an Ada program is that the
13199 @code{setvbuf} function can be used to control the buffering of the
13200 stream used by an Ada file.  In the absence of such a call the standard
13201 default buffering is used.
13202
13203 The @code{Open} procedures in these packages open a file giving an
13204 existing C Stream instead of a file name.  Typically this stream is
13205 imported from a C program, allowing an Ada file to operate on an
13206 existing C file.
13207
13208 @node The GNAT Library
13209 @chapter The GNAT Library
13210
13211 @noindent
13212 The GNAT library contains a number of general and special purpose packages.
13213 It represents functionality that the GNAT developers have found useful, and
13214 which is made available to GNAT users.  The packages described here are fully
13215 supported, and upwards compatibility will be maintained in future releases,
13216 so you can use these facilities with the confidence that the same functionality
13217 will be available in future releases.
13218
13219 The chapter here simply gives a brief summary of the facilities available.
13220 The full documentation is found in the spec file for the package.  The full
13221 sources of these library packages, including both spec and body, are provided
13222 with all GNAT releases.  For example, to find out the full specifications of
13223 the SPITBOL pattern matching capability, including a full tutorial and
13224 extensive examples, look in the @file{g-spipat.ads} file in the library.
13225
13226 For each entry here, the package name (as it would appear in a @code{with}
13227 clause) is given, followed by the name of the corresponding spec file in
13228 parentheses.  The packages are children in four hierarchies, @code{Ada},
13229 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13230 GNAT-specific hierarchy.
13231
13232 Note that an application program should only use packages in one of these
13233 four hierarchies if the package is defined in the Ada Reference Manual,
13234 or is listed in this section of the GNAT Programmers Reference Manual.
13235 All other units should be considered internal implementation units and
13236 should not be directly @code{with}'ed by application code.  The use of
13237 a @code{with} statement that references one of these internal implementation
13238 units makes an application potentially dependent on changes in versions
13239 of GNAT, and will generate a warning message.
13240
13241 @menu
13242 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13243 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13244 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13245 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13246 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13247 * Ada.Command_Line.Environment (a-colien.ads)::
13248 * Ada.Command_Line.Remove (a-colire.ads)::
13249 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13250 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13251 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13252 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13253 * Ada.Exceptions.Traceback (a-exctra.ads)::
13254 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13255 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13256 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13257 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13258 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13259 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13260 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13261 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13262 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13263 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13264 * GNAT.Altivec (g-altive.ads)::
13265 * GNAT.Altivec.Conversions (g-altcon.ads)::
13266 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13267 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13268 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13269 * GNAT.Array_Split (g-arrspl.ads)::
13270 * GNAT.AWK (g-awk.ads)::
13271 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13272 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13273 * GNAT.Bubble_Sort (g-bubsor.ads)::
13274 * GNAT.Bubble_Sort_A (g-busora.ads)::
13275 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13276 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13277 * GNAT.Byte_Swapping (g-bytswa.ads)::
13278 * GNAT.Calendar (g-calend.ads)::
13279 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13280 * GNAT.Case_Util (g-casuti.ads)::
13281 * GNAT.CGI (g-cgi.ads)::
13282 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13283 * GNAT.CGI.Debug (g-cgideb.ads)::
13284 * GNAT.Command_Line (g-comlin.ads)::
13285 * GNAT.Compiler_Version (g-comver.ads)::
13286 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13287 * GNAT.CRC32 (g-crc32.ads)::
13288 * GNAT.Current_Exception (g-curexc.ads)::
13289 * GNAT.Debug_Pools (g-debpoo.ads)::
13290 * GNAT.Debug_Utilities (g-debuti.ads)::
13291 * GNAT.Decode_String (g-decstr.ads)::
13292 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13293 * GNAT.Directory_Operations (g-dirope.ads)::
13294 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13295 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13296 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13297 * GNAT.Encode_String (g-encstr.ads)::
13298 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13299 * GNAT.Exception_Actions (g-excact.ads)::
13300 * GNAT.Exception_Traces (g-exctra.ads)::
13301 * GNAT.Exceptions (g-except.ads)::
13302 * GNAT.Expect (g-expect.ads)::
13303 * GNAT.Float_Control (g-flocon.ads)::
13304 * GNAT.Heap_Sort (g-heasor.ads)::
13305 * GNAT.Heap_Sort_A (g-hesora.ads)::
13306 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13307 * GNAT.HTable (g-htable.ads)::
13308 * GNAT.IO (g-io.ads)::
13309 * GNAT.IO_Aux (g-io_aux.ads)::
13310 * GNAT.Lock_Files (g-locfil.ads)::
13311 * GNAT.MD5 (g-md5.ads)::
13312 * GNAT.Memory_Dump (g-memdum.ads)::
13313 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13314 * GNAT.OS_Lib (g-os_lib.ads)::
13315 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13316 * GNAT.Random_Numbers (g-rannum.ads)::
13317 * GNAT.Regexp (g-regexp.ads)::
13318 * GNAT.Registry (g-regist.ads)::
13319 * GNAT.Regpat (g-regpat.ads)::
13320 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13321 * GNAT.Semaphores (g-semaph.ads)::
13322 * GNAT.Serial_Communications (g-sercom.ads)::
13323 * GNAT.SHA1 (g-sha1.ads)::
13324 * GNAT.Signals (g-signal.ads)::
13325 * GNAT.Sockets (g-socket.ads)::
13326 * GNAT.Source_Info (g-souinf.ads)::
13327 * GNAT.Spelling_Checker (g-speche.ads)::
13328 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13329 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13330 * GNAT.Spitbol (g-spitbo.ads)::
13331 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13332 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13333 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13334 * GNAT.Strings (g-string.ads)::
13335 * GNAT.String_Split (g-strspl.ads)::
13336 * GNAT.Table (g-table.ads)::
13337 * GNAT.Task_Lock (g-tasloc.ads)::
13338 * GNAT.Threads (g-thread.ads)::
13339 * GNAT.Time_Stamp (g-timsta.ads)::
13340 * GNAT.Traceback (g-traceb.ads)::
13341 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13342 * GNAT.UTF_32 (g-utf_32.ads)::
13343 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13344 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13345 * GNAT.Wide_String_Split (g-wistsp.ads)::
13346 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13347 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13348 * Interfaces.C.Extensions (i-cexten.ads)::
13349 * Interfaces.C.Streams (i-cstrea.ads)::
13350 * Interfaces.CPP (i-cpp.ads)::
13351 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13352 * Interfaces.VxWorks (i-vxwork.ads)::
13353 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13354 * System.Address_Image (s-addima.ads)::
13355 * System.Assertions (s-assert.ads)::
13356 * System.Memory (s-memory.ads)::
13357 * System.Partition_Interface (s-parint.ads)::
13358 * System.Pool_Global (s-pooglo.ads)::
13359 * System.Pool_Local (s-pooloc.ads)::
13360 * System.Restrictions (s-restri.ads)::
13361 * System.Rident (s-rident.ads)::
13362 * System.Task_Info (s-tasinf.ads)::
13363 * System.Wch_Cnv (s-wchcnv.ads)::
13364 * System.Wch_Con (s-wchcon.ads)::
13365 @end menu
13366
13367 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13368 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13369 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13370 @cindex Latin_9 constants for Character
13371
13372 @noindent
13373 This child of @code{Ada.Characters}
13374 provides a set of definitions corresponding to those in the
13375 RM-defined package @code{Ada.Characters.Latin_1} but with the
13376 few modifications required for @code{Latin-9}
13377 The provision of such a package
13378 is specifically authorized by the Ada Reference Manual
13379 (RM A.3.3(27)).
13380
13381 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13382 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13383 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13384 @cindex Latin_1 constants for Wide_Character
13385
13386 @noindent
13387 This child of @code{Ada.Characters}
13388 provides a set of definitions corresponding to those in the
13389 RM-defined package @code{Ada.Characters.Latin_1} but with the
13390 types of the constants being @code{Wide_Character}
13391 instead of @code{Character}.  The provision of such a package
13392 is specifically authorized by the Ada Reference Manual
13393 (RM A.3.3(27)).
13394
13395 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13396 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13397 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13398 @cindex Latin_9 constants for Wide_Character
13399
13400 @noindent
13401 This child of @code{Ada.Characters}
13402 provides a set of definitions corresponding to those in the
13403 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13404 types of the constants being @code{Wide_Character}
13405 instead of @code{Character}.  The provision of such a package
13406 is specifically authorized by the Ada Reference Manual
13407 (RM A.3.3(27)).
13408
13409 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13410 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13411 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13412 @cindex Latin_1 constants for Wide_Wide_Character
13413
13414 @noindent
13415 This child of @code{Ada.Characters}
13416 provides a set of definitions corresponding to those in the
13417 RM-defined package @code{Ada.Characters.Latin_1} but with the
13418 types of the constants being @code{Wide_Wide_Character}
13419 instead of @code{Character}.  The provision of such a package
13420 is specifically authorized by the Ada Reference Manual
13421 (RM A.3.3(27)).
13422
13423 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13424 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13425 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13426 @cindex Latin_9 constants for Wide_Wide_Character
13427
13428 @noindent
13429 This child of @code{Ada.Characters}
13430 provides a set of definitions corresponding to those in the
13431 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13432 types of the constants being @code{Wide_Wide_Character}
13433 instead of @code{Character}.  The provision of such a package
13434 is specifically authorized by the Ada Reference Manual
13435 (RM A.3.3(27)).
13436
13437 @node Ada.Command_Line.Environment (a-colien.ads)
13438 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13439 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13440 @cindex Environment entries
13441
13442 @noindent
13443 This child of @code{Ada.Command_Line}
13444 provides a mechanism for obtaining environment values on systems
13445 where this concept makes sense.
13446
13447 @node Ada.Command_Line.Remove (a-colire.ads)
13448 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13449 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13450 @cindex Removing command line arguments
13451 @cindex Command line, argument removal
13452
13453 @noindent
13454 This child of @code{Ada.Command_Line}
13455 provides a mechanism for logically removing
13456 arguments from the argument list.  Once removed, an argument is not visible
13457 to further calls on the subprograms in @code{Ada.Command_Line} will not
13458 see the removed argument.
13459
13460 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13461 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13462 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13463 @cindex Response file for command line
13464 @cindex Command line, response file
13465 @cindex Command line, handling long command lines
13466
13467 @noindent
13468 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13469 getting command line arguments from a text file, called a "response file".
13470 Using a response file allow passing a set of arguments to an executable longer
13471 than the maximum allowed by the system on the command line.
13472
13473 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13474 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13475 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13476 @cindex C Streams, Interfacing with Direct_IO
13477
13478 @noindent
13479 This package provides subprograms that allow interfacing between
13480 C streams and @code{Direct_IO}.  The stream identifier can be
13481 extracted from a file opened on the Ada side, and an Ada file
13482 can be constructed from a stream opened on the C side.
13483
13484 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13485 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13486 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13487 @cindex Null_Occurrence, testing for
13488
13489 @noindent
13490 This child subprogram provides a way of testing for the null
13491 exception occurrence (@code{Null_Occurrence}) without raising
13492 an exception.
13493
13494 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13495 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13496 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13497 @cindex Null_Occurrence, testing for
13498
13499 @noindent
13500 This child subprogram is used for handling otherwise unhandled
13501 exceptions (hence the name last chance), and perform clean ups before
13502 terminating the program. Note that this subprogram never returns.
13503
13504 @node Ada.Exceptions.Traceback (a-exctra.ads)
13505 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13506 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13507 @cindex Traceback for Exception Occurrence
13508
13509 @noindent
13510 This child package provides the subprogram (@code{Tracebacks}) to
13511 give a traceback array of addresses based on an exception
13512 occurrence.
13513
13514 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13515 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13516 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13517 @cindex C Streams, Interfacing with Sequential_IO
13518
13519 @noindent
13520 This package provides subprograms that allow interfacing between
13521 C streams and @code{Sequential_IO}.  The stream identifier can be
13522 extracted from a file opened on the Ada side, and an Ada file
13523 can be constructed from a stream opened on the C side.
13524
13525 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13526 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13527 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13528 @cindex C Streams, Interfacing with Stream_IO
13529
13530 @noindent
13531 This package provides subprograms that allow interfacing between
13532 C streams and @code{Stream_IO}.  The stream identifier can be
13533 extracted from a file opened on the Ada side, and an Ada file
13534 can be constructed from a stream opened on the C side.
13535
13536 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13537 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13538 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13539 @cindex @code{Unbounded_String}, IO support
13540 @cindex @code{Text_IO}, extensions for unbounded strings
13541
13542 @noindent
13543 This package provides subprograms for Text_IO for unbounded
13544 strings, avoiding the necessity for an intermediate operation
13545 with ordinary strings.
13546
13547 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13548 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13549 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13550 @cindex @code{Unbounded_Wide_String}, IO support
13551 @cindex @code{Text_IO}, extensions for unbounded wide strings
13552
13553 @noindent
13554 This package provides subprograms for Text_IO for unbounded
13555 wide strings, avoiding the necessity for an intermediate operation
13556 with ordinary wide strings.
13557
13558 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13559 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13560 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13561 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13562 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13563
13564 @noindent
13565 This package provides subprograms for Text_IO for unbounded
13566 wide wide strings, avoiding the necessity for an intermediate operation
13567 with ordinary wide wide strings.
13568
13569 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13570 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13571 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13572 @cindex C Streams, Interfacing with @code{Text_IO}
13573
13574 @noindent
13575 This package provides subprograms that allow interfacing between
13576 C streams and @code{Text_IO}.  The stream identifier can be
13577 extracted from a file opened on the Ada side, and an Ada file
13578 can be constructed from a stream opened on the C side.
13579
13580 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13581 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13582 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13583 @cindex Unicode categorization, Wide_Character
13584
13585 @noindent
13586 This package provides subprograms that allow categorization of
13587 Wide_Character values according to Unicode categories.
13588
13589 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13590 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13591 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13592 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13593
13594 @noindent
13595 This package provides subprograms that allow interfacing between
13596 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13597 extracted from a file opened on the Ada side, and an Ada file
13598 can be constructed from a stream opened on the C side.
13599
13600 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13601 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13602 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13603 @cindex Unicode categorization, Wide_Wide_Character
13604
13605 @noindent
13606 This package provides subprograms that allow categorization of
13607 Wide_Wide_Character values according to Unicode categories.
13608
13609 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13610 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13611 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13612 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13613
13614 @noindent
13615 This package provides subprograms that allow interfacing between
13616 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13617 extracted from a file opened on the Ada side, and an Ada file
13618 can be constructed from a stream opened on the C side.
13619
13620 @node GNAT.Altivec (g-altive.ads)
13621 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13622 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13623 @cindex AltiVec
13624
13625 @noindent
13626 This is the root package of the GNAT AltiVec binding. It provides
13627 definitions of constants and types common to all the versions of the
13628 binding.
13629
13630 @node GNAT.Altivec.Conversions (g-altcon.ads)
13631 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13632 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13633 @cindex AltiVec
13634
13635 @noindent
13636 This package provides the Vector/View conversion routines.
13637
13638 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13639 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13640 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13641 @cindex AltiVec
13642
13643 @noindent
13644 This package exposes the Ada interface to the AltiVec operations on
13645 vector objects. A soft emulation is included by default in the GNAT
13646 library. The hard binding is provided as a separate package. This unit
13647 is common to both bindings.
13648
13649 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13650 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13651 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13652 @cindex AltiVec
13653
13654 @noindent
13655 This package exposes the various vector types part of the Ada binding
13656 to AltiVec facilities.
13657
13658 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13659 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13660 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13661 @cindex AltiVec
13662
13663 @noindent
13664 This package provides public 'View' data types from/to which private
13665 vector representations can be converted via
13666 GNAT.Altivec.Conversions. This allows convenient access to individual
13667 vector elements and provides a simple way to initialize vector
13668 objects.
13669
13670 @node GNAT.Array_Split (g-arrspl.ads)
13671 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13672 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13673 @cindex Array splitter
13674
13675 @noindent
13676 Useful array-manipulation routines: given a set of separators, split
13677 an array wherever the separators appear, and provide direct access
13678 to the resulting slices.
13679
13680 @node GNAT.AWK (g-awk.ads)
13681 @section @code{GNAT.AWK} (@file{g-awk.ads})
13682 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13683 @cindex Parsing
13684 @cindex AWK
13685
13686 @noindent
13687 Provides AWK-like parsing functions, with an easy interface for parsing one
13688 or more files containing formatted data.  The file is viewed as a database
13689 where each record is a line and a field is a data element in this line.
13690
13691 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13692 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13693 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13694 @cindex Parsing
13695 @cindex Bounded Buffers
13696
13697 @noindent
13698 Provides a concurrent generic bounded buffer abstraction.  Instances are
13699 useful directly or as parts of the implementations of other abstractions,
13700 such as mailboxes.
13701
13702 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13703 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13704 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13705 @cindex Parsing
13706 @cindex Mailboxes
13707
13708 @noindent
13709 Provides a thread-safe asynchronous intertask mailbox communication facility.
13710
13711 @node GNAT.Bubble_Sort (g-bubsor.ads)
13712 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13713 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13714 @cindex Sorting
13715 @cindex Bubble sort
13716
13717 @noindent
13718 Provides a general implementation of bubble sort usable for sorting arbitrary
13719 data items.  Exchange and comparison procedures are provided by passing
13720 access-to-procedure values.
13721
13722 @node GNAT.Bubble_Sort_A (g-busora.ads)
13723 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13724 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13725 @cindex Sorting
13726 @cindex Bubble sort
13727
13728 @noindent
13729 Provides a general implementation of bubble sort usable for sorting arbitrary
13730 data items.  Move and comparison procedures are provided by passing
13731 access-to-procedure values. This is an older version, retained for
13732 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13733
13734 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13735 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13736 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13737 @cindex Sorting
13738 @cindex Bubble sort
13739
13740 @noindent
13741 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13742 are provided as generic parameters, this improves efficiency, especially
13743 if the procedures can be inlined, at the expense of duplicating code for
13744 multiple instantiations.
13745
13746 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13747 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13748 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13749 @cindex UTF-8 representation
13750 @cindex Wide characte representations
13751
13752 @noindent
13753 Provides a routine which given a string, reads the start of the string to
13754 see whether it is one of the standard byte order marks (BOM's) which signal
13755 the encoding of the string. The routine includes detection of special XML
13756 sequences for various UCS input formats.
13757
13758 @node GNAT.Byte_Swapping (g-bytswa.ads)
13759 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13760 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13761 @cindex Byte swapping
13762 @cindex Endian
13763
13764 @noindent
13765 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13766 Machine-specific implementations are available in some cases.
13767
13768 @node GNAT.Calendar (g-calend.ads)
13769 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13770 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13771 @cindex @code{Calendar}
13772
13773 @noindent
13774 Extends the facilities provided by @code{Ada.Calendar} to include handling
13775 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13776 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13777 C @code{timeval} format.
13778
13779 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13780 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13781 @cindex @code{Calendar}
13782 @cindex Time
13783 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13784
13785 @node GNAT.CRC32 (g-crc32.ads)
13786 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13787 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13788 @cindex CRC32
13789 @cindex Cyclic Redundancy Check
13790
13791 @noindent
13792 This package implements the CRC-32 algorithm.  For a full description
13793 of this algorithm see
13794 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13795 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13796 Aug.@: 1988.  Sarwate, D.V@.
13797
13798 @node GNAT.Case_Util (g-casuti.ads)
13799 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13800 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13801 @cindex Casing utilities
13802 @cindex Character handling (@code{GNAT.Case_Util})
13803
13804 @noindent
13805 A set of simple routines for handling upper and lower casing of strings
13806 without the overhead of the full casing tables
13807 in @code{Ada.Characters.Handling}.
13808
13809 @node GNAT.CGI (g-cgi.ads)
13810 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13811 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13812 @cindex CGI (Common Gateway Interface)
13813
13814 @noindent
13815 This is a package for interfacing a GNAT program with a Web server via the
13816 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13817 parameters, which are a set of key/value pairs sent by the Web server.  It
13818 builds a table whose index is the key and provides some services to deal
13819 with this table.
13820
13821 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13822 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13823 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13824 @cindex CGI (Common Gateway Interface) cookie support
13825 @cindex Cookie support in CGI
13826
13827 @noindent
13828 This is a package to interface a GNAT program with a Web server via the
13829 Common Gateway Interface (CGI).  It exports services to deal with Web
13830 cookies (piece of information kept in the Web client software).
13831
13832 @node GNAT.CGI.Debug (g-cgideb.ads)
13833 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13834 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13835 @cindex CGI (Common Gateway Interface) debugging
13836
13837 @noindent
13838 This is a package to help debugging CGI (Common Gateway Interface)
13839 programs written in Ada.
13840
13841 @node GNAT.Command_Line (g-comlin.ads)
13842 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13843 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13844 @cindex Command line
13845
13846 @noindent
13847 Provides a high level interface to @code{Ada.Command_Line} facilities,
13848 including the ability to scan for named switches with optional parameters
13849 and expand file names using wild card notations.
13850
13851 @node GNAT.Compiler_Version (g-comver.ads)
13852 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13853 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13854 @cindex Compiler Version
13855 @cindex Version, of compiler
13856
13857 @noindent
13858 Provides a routine for obtaining the version of the compiler used to
13859 compile the program. More accurately this is the version of the binder
13860 used to bind the program (this will normally be the same as the version
13861 of the compiler if a consistent tool set is used to compile all units
13862 of a partition).
13863
13864 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13865 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13866 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13867 @cindex Interrupt
13868
13869 @noindent
13870 Provides a simple interface to handle Ctrl-C keyboard events.
13871
13872 @node GNAT.Current_Exception (g-curexc.ads)
13873 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13874 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13875 @cindex Current exception
13876 @cindex Exception retrieval
13877
13878 @noindent
13879 Provides access to information on the current exception that has been raised
13880 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13881 specification syntax.
13882 This is particularly useful in simulating typical facilities for
13883 obtaining information about exceptions provided by Ada 83 compilers.
13884
13885 @node GNAT.Debug_Pools (g-debpoo.ads)
13886 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13887 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13888 @cindex Debugging
13889 @cindex Debug pools
13890 @cindex Memory corruption debugging
13891
13892 @noindent
13893 Provide a debugging storage pools that helps tracking memory corruption
13894 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13895 @value{EDITION} User's Guide}.
13896
13897 @node GNAT.Debug_Utilities (g-debuti.ads)
13898 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13899 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13900 @cindex Debugging
13901
13902 @noindent
13903 Provides a few useful utilities for debugging purposes, including conversion
13904 to and from string images of address values. Supports both C and Ada formats
13905 for hexadecimal literals.
13906
13907 @node GNAT.Decode_String (g-decstr.ads)
13908 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13909 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13910 @cindex Decoding strings
13911 @cindex String decoding
13912 @cindex Wide character encoding
13913 @cindex UTF-8
13914 @cindex Unicode
13915
13916 @noindent
13917 A generic package providing routines for decoding wide character and wide wide
13918 character strings encoded as sequences of 8-bit characters using a specified
13919 encoding method. Includes validation routines, and also routines for stepping
13920 to next or previous encoded character in an encoded string.
13921 Useful in conjunction with Unicode character coding. Note there is a
13922 preinstantiation for UTF-8. See next entry.
13923
13924 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13925 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13926 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13927 @cindex Decoding strings
13928 @cindex Decoding UTF-8 strings
13929 @cindex UTF-8 string decoding
13930 @cindex Wide character decoding
13931 @cindex UTF-8
13932 @cindex Unicode
13933
13934 @noindent
13935 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13936
13937 @node GNAT.Directory_Operations (g-dirope.ads)
13938 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13939 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13940 @cindex Directory operations
13941
13942 @noindent
13943 Provides a set of routines for manipulating directories, including changing
13944 the current directory, making new directories, and scanning the files in a
13945 directory.
13946
13947 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13948 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13949 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13950 @cindex Directory operations iteration
13951
13952 @noindent
13953 A child unit of GNAT.Directory_Operations providing additional operations
13954 for iterating through directories.
13955
13956 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13957 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13958 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13959 @cindex Hash tables
13960
13961 @noindent
13962 A generic implementation of hash tables that can be used to hash arbitrary
13963 data.  Provided in two forms, a simple form with built in hash functions,
13964 and a more complex form in which the hash function is supplied.
13965
13966 @noindent
13967 This package provides a facility similar to that of @code{GNAT.HTable},
13968 except that this package declares a type that can be used to define
13969 dynamic instances of the hash table, while an instantiation of
13970 @code{GNAT.HTable} creates a single instance of the hash table.
13971
13972 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13973 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13974 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13975 @cindex Table implementation
13976 @cindex Arrays, extendable
13977
13978 @noindent
13979 A generic package providing a single dimension array abstraction where the
13980 length of the array can be dynamically modified.
13981
13982 @noindent
13983 This package provides a facility similar to that of @code{GNAT.Table},
13984 except that this package declares a type that can be used to define
13985 dynamic instances of the table, while an instantiation of
13986 @code{GNAT.Table} creates a single instance of the table type.
13987
13988 @node GNAT.Encode_String (g-encstr.ads)
13989 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
13990 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
13991 @cindex Encoding strings
13992 @cindex String encoding
13993 @cindex Wide character encoding
13994 @cindex UTF-8
13995 @cindex Unicode
13996
13997 @noindent
13998 A generic package providing routines for encoding wide character and wide
13999 wide character strings as sequences of 8-bit characters using a specified
14000 encoding method. Useful in conjunction with Unicode character coding.
14001 Note there is a preinstantiation for UTF-8. See next entry.
14002
14003 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14004 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14005 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14006 @cindex Encoding strings
14007 @cindex Encoding UTF-8 strings
14008 @cindex UTF-8 string encoding
14009 @cindex Wide character encoding
14010 @cindex UTF-8
14011 @cindex Unicode
14012
14013 @noindent
14014 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14015
14016 @node GNAT.Exception_Actions (g-excact.ads)
14017 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14018 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14019 @cindex Exception actions
14020
14021 @noindent
14022 Provides callbacks when an exception is raised. Callbacks can be registered
14023 for specific exceptions, or when any exception is raised. This
14024 can be used for instance to force a core dump to ease debugging.
14025
14026 @node GNAT.Exception_Traces (g-exctra.ads)
14027 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14028 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14029 @cindex Exception traces
14030 @cindex Debugging
14031
14032 @noindent
14033 Provides an interface allowing to control automatic output upon exception
14034 occurrences.
14035
14036 @node GNAT.Exceptions (g-except.ads)
14037 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14038 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14039 @cindex Exceptions, Pure
14040 @cindex Pure packages, exceptions
14041
14042 @noindent
14043 Normally it is not possible to raise an exception with
14044 a message from a subprogram in a pure package, since the
14045 necessary types and subprograms are in @code{Ada.Exceptions}
14046 which is not a pure unit. @code{GNAT.Exceptions} provides a
14047 facility for getting around this limitation for a few
14048 predefined exceptions, and for example allow raising
14049 @code{Constraint_Error} with a message from a pure subprogram.
14050
14051 @node GNAT.Expect (g-expect.ads)
14052 @section @code{GNAT.Expect} (@file{g-expect.ads})
14053 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14054
14055 @noindent
14056 Provides a set of subprograms similar to what is available
14057 with the standard Tcl Expect tool.
14058 It allows you to easily spawn and communicate with an external process.
14059 You can send commands or inputs to the process, and compare the output
14060 with some expected regular expression. Currently @code{GNAT.Expect}
14061 is implemented on all native GNAT ports except for OpenVMS@.
14062 It is not implemented for cross ports, and in particular is not
14063 implemented for VxWorks or LynxOS@.
14064
14065 @node GNAT.Float_Control (g-flocon.ads)
14066 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14067 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14068 @cindex Floating-Point Processor
14069
14070 @noindent
14071 Provides an interface for resetting the floating-point processor into the
14072 mode required for correct semantic operation in Ada.  Some third party
14073 library calls may cause this mode to be modified, and the Reset procedure
14074 in this package can be used to reestablish the required mode.
14075
14076 @node GNAT.Heap_Sort (g-heasor.ads)
14077 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14078 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14079 @cindex Sorting
14080
14081 @noindent
14082 Provides a general implementation of heap sort usable for sorting arbitrary
14083 data items. Exchange and comparison procedures are provided by passing
14084 access-to-procedure values.  The algorithm used is a modified heap sort
14085 that performs approximately N*log(N) comparisons in the worst case.
14086
14087 @node GNAT.Heap_Sort_A (g-hesora.ads)
14088 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14089 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14090 @cindex Sorting
14091
14092 @noindent
14093 Provides a general implementation of heap sort usable for sorting arbitrary
14094 data items. Move and comparison procedures are provided by passing
14095 access-to-procedure values.  The algorithm used is a modified heap sort
14096 that performs approximately N*log(N) comparisons in the worst case.
14097 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14098 interface, but may be slightly more efficient.
14099
14100 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14101 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14102 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14103 @cindex Sorting
14104
14105 @noindent
14106 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14107 are provided as generic parameters, this improves efficiency, especially
14108 if the procedures can be inlined, at the expense of duplicating code for
14109 multiple instantiations.
14110
14111 @node GNAT.HTable (g-htable.ads)
14112 @section @code{GNAT.HTable} (@file{g-htable.ads})
14113 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14114 @cindex Hash tables
14115
14116 @noindent
14117 A generic implementation of hash tables that can be used to hash arbitrary
14118 data.  Provides two approaches, one a simple static approach, and the other
14119 allowing arbitrary dynamic hash tables.
14120
14121 @node GNAT.IO (g-io.ads)
14122 @section @code{GNAT.IO} (@file{g-io.ads})
14123 @cindex @code{GNAT.IO} (@file{g-io.ads})
14124 @cindex Simple I/O
14125 @cindex Input/Output facilities
14126
14127 @noindent
14128 A simple preelaborable input-output package that provides a subset of
14129 simple Text_IO functions for reading characters and strings from
14130 Standard_Input, and writing characters, strings and integers to either
14131 Standard_Output or Standard_Error.
14132
14133 @node GNAT.IO_Aux (g-io_aux.ads)
14134 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14135 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14136 @cindex Text_IO
14137 @cindex Input/Output facilities
14138
14139 Provides some auxiliary functions for use with Text_IO, including a test
14140 for whether a file exists, and functions for reading a line of text.
14141
14142 @node GNAT.Lock_Files (g-locfil.ads)
14143 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14144 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14145 @cindex File locking
14146 @cindex Locking using files
14147
14148 @noindent
14149 Provides a general interface for using files as locks.  Can be used for
14150 providing program level synchronization.
14151
14152 @node GNAT.MD5 (g-md5.ads)
14153 @section @code{GNAT.MD5} (@file{g-md5.ads})
14154 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14155 @cindex Message Digest MD5
14156
14157 @noindent
14158 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14159
14160 @node GNAT.Memory_Dump (g-memdum.ads)
14161 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14162 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14163 @cindex Dump Memory
14164
14165 @noindent
14166 Provides a convenient routine for dumping raw memory to either the
14167 standard output or standard error files. Uses GNAT.IO for actual
14168 output.
14169
14170 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14171 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14172 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14173 @cindex Exception, obtaining most recent
14174
14175 @noindent
14176 Provides access to the most recently raised exception.  Can be used for
14177 various logging purposes, including duplicating functionality of some
14178 Ada 83 implementation dependent extensions.
14179
14180 @node GNAT.OS_Lib (g-os_lib.ads)
14181 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14182 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14183 @cindex Operating System interface
14184 @cindex Spawn capability
14185
14186 @noindent
14187 Provides a range of target independent operating system interface functions,
14188 including time/date management, file operations, subprocess management,
14189 including a portable spawn procedure, and access to environment variables
14190 and error return codes.
14191
14192 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14193 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14194 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14195 @cindex Hash functions
14196
14197 @noindent
14198 Provides a generator of static minimal perfect hash functions. No
14199 collisions occur and each item can be retrieved from the table in one
14200 probe (perfect property). The hash table size corresponds to the exact
14201 size of the key set and no larger (minimal property). The key set has to
14202 be know in advance (static property). The hash functions are also order
14203 preserving. If w2 is inserted after w1 in the generator, their
14204 hashcode are in the same order. These hashing functions are very
14205 convenient for use with realtime applications.
14206
14207 @node GNAT.Random_Numbers (g-rannum.ads)
14208 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14209 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14210 @cindex Random number generation
14211
14212 @noindent
14213 Provides random number capabilities which extend those available in the
14214 standard Ada library and are more convenient to use.
14215
14216 @node GNAT.Regexp (g-regexp.ads)
14217 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14218 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14219 @cindex Regular expressions
14220 @cindex Pattern matching
14221
14222 @noindent
14223 A simple implementation of regular expressions, using a subset of regular
14224 expression syntax copied from familiar Unix style utilities.  This is the
14225 simples of the three pattern matching packages provided, and is particularly
14226 suitable for ``file globbing'' applications.
14227
14228 @node GNAT.Registry (g-regist.ads)
14229 @section @code{GNAT.Registry} (@file{g-regist.ads})
14230 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14231 @cindex Windows Registry
14232
14233 @noindent
14234 This is a high level binding to the Windows registry.  It is possible to
14235 do simple things like reading a key value, creating a new key.  For full
14236 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14237 package provided with the Win32Ada binding
14238
14239 @node GNAT.Regpat (g-regpat.ads)
14240 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14241 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14242 @cindex Regular expressions
14243 @cindex Pattern matching
14244
14245 @noindent
14246 A complete implementation of Unix-style regular expression matching, copied
14247 from the original V7 style regular expression library written in C by
14248 Henry Spencer (and binary compatible with this C library).
14249
14250 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14251 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14252 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14253 @cindex Secondary Stack Info
14254
14255 @noindent
14256 Provide the capability to query the high water mark of the current task's
14257 secondary stack.
14258
14259 @node GNAT.Semaphores (g-semaph.ads)
14260 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14261 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14262 @cindex Semaphores
14263
14264 @noindent
14265 Provides classic counting and binary semaphores using protected types.
14266
14267 @node GNAT.Serial_Communications (g-sercom.ads)
14268 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14269 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14270 @cindex Serial_Communications
14271
14272 @noindent
14273 Provides a simple interface to send and receive data over a serial
14274 port. This is only supported on GNU/Linux and Windows.
14275
14276 @node GNAT.SHA1 (g-sha1.ads)
14277 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14278 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14279 @cindex Secure Hash Algorithm SHA-1
14280
14281 @noindent
14282 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14283
14284 @node GNAT.Signals (g-signal.ads)
14285 @section @code{GNAT.Signals} (@file{g-signal.ads})
14286 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14287 @cindex Signals
14288
14289 @noindent
14290 Provides the ability to manipulate the blocked status of signals on supported
14291 targets.
14292
14293 @node GNAT.Sockets (g-socket.ads)
14294 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14295 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14296 @cindex Sockets
14297
14298 @noindent
14299 A high level and portable interface to develop sockets based applications.
14300 This package is based on the sockets thin binding found in
14301 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14302 on all native GNAT ports except for OpenVMS@.  It is not implemented
14303 for the LynxOS@ cross port.
14304
14305 @node GNAT.Source_Info (g-souinf.ads)
14306 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14307 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14308 @cindex Source Information
14309
14310 @noindent
14311 Provides subprograms that give access to source code information known at
14312 compile time, such as the current file name and line number.
14313
14314 @node GNAT.Spelling_Checker (g-speche.ads)
14315 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14316 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14317 @cindex Spell checking
14318
14319 @noindent
14320 Provides a function for determining whether one string is a plausible
14321 near misspelling of another string.
14322
14323 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14324 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14325 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14326 @cindex Spell checking
14327
14328 @noindent
14329 Provides a generic function that can be instantiated with a string type for
14330 determining whether one string is a plausible near misspelling of another
14331 string.
14332
14333 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14334 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14335 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14336 @cindex SPITBOL pattern matching
14337 @cindex Pattern matching
14338
14339 @noindent
14340 A complete implementation of SNOBOL4 style pattern matching.  This is the
14341 most elaborate of the pattern matching packages provided.  It fully duplicates
14342 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14343 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14344
14345 @node GNAT.Spitbol (g-spitbo.ads)
14346 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14347 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14348 @cindex SPITBOL interface
14349
14350 @noindent
14351 The top level package of the collection of SPITBOL-style functionality, this
14352 package provides basic SNOBOL4 string manipulation functions, such as
14353 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14354 useful for constructing arbitrary mappings from strings in the style of
14355 the SNOBOL4 TABLE function.
14356
14357 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14358 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14359 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14360 @cindex Sets of strings
14361 @cindex SPITBOL Tables
14362
14363 @noindent
14364 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14365 for type @code{Standard.Boolean}, giving an implementation of sets of
14366 string values.
14367
14368 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14369 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14370 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14371 @cindex Integer maps
14372 @cindex Maps
14373 @cindex SPITBOL Tables
14374
14375 @noindent
14376 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14377 for type @code{Standard.Integer}, giving an implementation of maps
14378 from string to integer values.
14379
14380 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14381 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14382 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14383 @cindex String maps
14384 @cindex Maps
14385 @cindex SPITBOL Tables
14386
14387 @noindent
14388 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14389 a variable length string type, giving an implementation of general
14390 maps from strings to strings.
14391
14392 @node GNAT.Strings (g-string.ads)
14393 @section @code{GNAT.Strings} (@file{g-string.ads})
14394 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14395
14396 @noindent
14397 Common String access types and related subprograms. Basically it
14398 defines a string access and an array of string access types.
14399
14400 @node GNAT.String_Split (g-strspl.ads)
14401 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14402 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14403 @cindex String splitter
14404
14405 @noindent
14406 Useful string manipulation routines: given a set of separators, split
14407 a string wherever the separators appear, and provide direct access
14408 to the resulting slices. This package is instantiated from
14409 @code{GNAT.Array_Split}.
14410
14411 @node GNAT.Table (g-table.ads)
14412 @section @code{GNAT.Table} (@file{g-table.ads})
14413 @cindex @code{GNAT.Table} (@file{g-table.ads})
14414 @cindex Table implementation
14415 @cindex Arrays, extendable
14416
14417 @noindent
14418 A generic package providing a single dimension array abstraction where the
14419 length of the array can be dynamically modified.
14420
14421 @noindent
14422 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14423 except that this package declares a single instance of the table type,
14424 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14425 used to define dynamic instances of the table.
14426
14427 @node GNAT.Task_Lock (g-tasloc.ads)
14428 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14429 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14430 @cindex Task synchronization
14431 @cindex Task locking
14432 @cindex Locking
14433
14434 @noindent
14435 A very simple facility for locking and unlocking sections of code using a
14436 single global task lock.  Appropriate for use in situations where contention
14437 between tasks is very rarely expected.
14438
14439 @node GNAT.Time_Stamp (g-timsta.ads)
14440 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14441 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14442 @cindex Time stamp
14443 @cindex Current time
14444
14445 @noindent
14446 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14447 represents the current date and time in ISO 8601 format. This is a very simple
14448 routine with minimal code and there are no dependencies on any other unit.
14449
14450 @node GNAT.Threads (g-thread.ads)
14451 @section @code{GNAT.Threads} (@file{g-thread.ads})
14452 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14453 @cindex Foreign threads
14454 @cindex Threads, foreign
14455
14456 @noindent
14457 Provides facilities for dealing with foreign threads which need to be known
14458 by the GNAT run-time system. Consult the documentation of this package for
14459 further details if your program has threads that are created by a non-Ada
14460 environment which then accesses Ada code.
14461
14462 @node GNAT.Traceback (g-traceb.ads)
14463 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14464 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14465 @cindex Trace back facilities
14466
14467 @noindent
14468 Provides a facility for obtaining non-symbolic traceback information, useful
14469 in various debugging situations.
14470
14471 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14472 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14473 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14474 @cindex Trace back facilities
14475
14476 @node GNAT.UTF_32 (g-utf_32.ads)
14477 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14478 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14479 @cindex Wide character codes
14480
14481 @noindent
14482 This is a package intended to be used in conjunction with the
14483 @code{Wide_Character} type in Ada 95 and the
14484 @code{Wide_Wide_Character} type in Ada 2005 (available
14485 in @code{GNAT} in Ada 2005 mode). This package contains
14486 Unicode categorization routines, as well as lexical
14487 categorization routines corresponding to the Ada 2005
14488 lexical rules for identifiers and strings, and also a
14489 lower case to upper case fold routine corresponding to
14490 the Ada 2005 rules for identifier equivalence.
14491
14492 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14493 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14494 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14495 @cindex Spell checking
14496
14497 @noindent
14498 Provides a function for determining whether one wide wide string is a plausible
14499 near misspelling of another wide wide string, where the strings are represented
14500 using the UTF_32_String type defined in System.Wch_Cnv.
14501
14502 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14503 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14504 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14505 @cindex Spell checking
14506
14507 @noindent
14508 Provides a function for determining whether one wide string is a plausible
14509 near misspelling of another wide string.
14510
14511 @node GNAT.Wide_String_Split (g-wistsp.ads)
14512 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14513 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14514 @cindex Wide_String splitter
14515
14516 @noindent
14517 Useful wide string manipulation routines: given a set of separators, split
14518 a wide string wherever the separators appear, and provide direct access
14519 to the resulting slices. This package is instantiated from
14520 @code{GNAT.Array_Split}.
14521
14522 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14523 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14524 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14525 @cindex Spell checking
14526
14527 @noindent
14528 Provides a function for determining whether one wide wide string is a plausible
14529 near misspelling of another wide wide string.
14530
14531 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14532 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14533 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14534 @cindex Wide_Wide_String splitter
14535
14536 @noindent
14537 Useful wide wide string manipulation routines: given a set of separators, split
14538 a wide wide string wherever the separators appear, and provide direct access
14539 to the resulting slices. This package is instantiated from
14540 @code{GNAT.Array_Split}.
14541
14542 @node Interfaces.C.Extensions (i-cexten.ads)
14543 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14544 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14545
14546 @noindent
14547 This package contains additional C-related definitions, intended
14548 for use with either manually or automatically generated bindings
14549 to C libraries.
14550
14551 @node Interfaces.C.Streams (i-cstrea.ads)
14552 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14553 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14554 @cindex  C streams, interfacing
14555
14556 @noindent
14557 This package is a binding for the most commonly used operations
14558 on C streams.
14559
14560 @node Interfaces.CPP (i-cpp.ads)
14561 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14562 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14563 @cindex  C++ interfacing
14564 @cindex  Interfacing, to C++
14565
14566 @noindent
14567 This package provides facilities for use in interfacing to C++.  It
14568 is primarily intended to be used in connection with automated tools
14569 for the generation of C++ interfaces.
14570
14571 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14572 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14573 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14574 @cindex  IBM Packed Format
14575 @cindex  Packed Decimal
14576
14577 @noindent
14578 This package provides a set of routines for conversions to and
14579 from a packed decimal format compatible with that used on IBM
14580 mainframes.
14581
14582 @node Interfaces.VxWorks (i-vxwork.ads)
14583 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14584 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14585 @cindex Interfacing to VxWorks
14586 @cindex VxWorks, interfacing
14587
14588 @noindent
14589 This package provides a limited binding to the VxWorks API.
14590 In particular, it interfaces with the
14591 VxWorks hardware interrupt facilities.
14592
14593 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14594 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14595 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14596 @cindex Interfacing to VxWorks' I/O
14597 @cindex VxWorks, I/O interfacing
14598 @cindex VxWorks, Get_Immediate
14599 @cindex Get_Immediate, VxWorks
14600
14601 @noindent
14602 This package provides a binding to the ioctl (IO/Control)
14603 function of VxWorks, defining a set of option values and
14604 function codes. A particular use of this package is
14605 to enable the use of Get_Immediate under VxWorks.
14606
14607 @node System.Address_Image (s-addima.ads)
14608 @section @code{System.Address_Image} (@file{s-addima.ads})
14609 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14610 @cindex Address image
14611 @cindex Image, of an address
14612
14613 @noindent
14614 This function provides a useful debugging
14615 function that gives an (implementation dependent)
14616 string which identifies an address.
14617
14618 @node System.Assertions (s-assert.ads)
14619 @section @code{System.Assertions} (@file{s-assert.ads})
14620 @cindex @code{System.Assertions} (@file{s-assert.ads})
14621 @cindex Assertions
14622 @cindex Assert_Failure, exception
14623
14624 @noindent
14625 This package provides the declaration of the exception raised
14626 by an run-time assertion failure, as well as the routine that
14627 is used internally to raise this assertion.
14628
14629 @node System.Memory (s-memory.ads)
14630 @section @code{System.Memory} (@file{s-memory.ads})
14631 @cindex @code{System.Memory} (@file{s-memory.ads})
14632 @cindex Memory allocation
14633
14634 @noindent
14635 This package provides the interface to the low level routines used
14636 by the generated code for allocation and freeing storage for the
14637 default storage pool (analogous to the C routines malloc and free.
14638 It also provides a reallocation interface analogous to the C routine
14639 realloc. The body of this unit may be modified to provide alternative
14640 allocation mechanisms for the default pool, and in addition, direct
14641 calls to this unit may be made for low level allocation uses (for
14642 example see the body of @code{GNAT.Tables}).
14643
14644 @node System.Partition_Interface (s-parint.ads)
14645 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14646 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14647 @cindex Partition interfacing functions
14648
14649 @noindent
14650 This package provides facilities for partition interfacing.  It
14651 is used primarily in a distribution context when using Annex E
14652 with @code{GLADE}.
14653
14654 @node System.Pool_Global (s-pooglo.ads)
14655 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14656 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14657 @cindex Storage pool, global
14658 @cindex Global storage pool
14659
14660 @noindent
14661 This package provides a storage pool that is equivalent to the default
14662 storage pool used for access types for which no pool is specifically
14663 declared. It uses malloc/free to allocate/free and does not attempt to
14664 do any automatic reclamation.
14665
14666 @node System.Pool_Local (s-pooloc.ads)
14667 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14668 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14669 @cindex Storage pool, local
14670 @cindex Local storage pool
14671
14672 @noindent
14673 This package provides a storage pool that is intended for use with locally
14674 defined access types. It uses malloc/free for allocate/free, and maintains
14675 a list of allocated blocks, so that all storage allocated for the pool can
14676 be freed automatically when the pool is finalized.
14677
14678 @node System.Restrictions (s-restri.ads)
14679 @section @code{System.Restrictions} (@file{s-restri.ads})
14680 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14681 @cindex Run-time restrictions access
14682
14683 @noindent
14684 This package provides facilities for accessing at run time
14685 the status of restrictions specified at compile time for
14686 the partition. Information is available both with regard
14687 to actual restrictions specified, and with regard to
14688 compiler determined information on which restrictions
14689 are violated by one or more packages in the partition.
14690
14691 @node System.Rident (s-rident.ads)
14692 @section @code{System.Rident} (@file{s-rident.ads})
14693 @cindex @code{System.Rident} (@file{s-rident.ads})
14694 @cindex Restrictions definitions
14695
14696 @noindent
14697 This package provides definitions of the restrictions
14698 identifiers supported by GNAT, and also the format of
14699 the restrictions provided in package System.Restrictions.
14700 It is not normally necessary to @code{with} this generic package
14701 since the necessary instantiation is included in
14702 package System.Restrictions.
14703
14704 @node System.Task_Info (s-tasinf.ads)
14705 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14706 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14707 @cindex Task_Info pragma
14708
14709 @noindent
14710 This package provides target dependent functionality that is used
14711 to support the @code{Task_Info} pragma
14712
14713 @node System.Wch_Cnv (s-wchcnv.ads)
14714 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14715 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14716 @cindex Wide Character, Representation
14717 @cindex Wide String, Conversion
14718 @cindex Representation of wide characters
14719
14720 @noindent
14721 This package provides routines for converting between
14722 wide and wide wide characters and a representation as a value of type
14723 @code{Standard.String}, using a specified wide character
14724 encoding method.  It uses definitions in
14725 package @code{System.Wch_Con}.
14726
14727 @node System.Wch_Con (s-wchcon.ads)
14728 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14729 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14730
14731 @noindent
14732 This package provides definitions and descriptions of
14733 the various methods used for encoding wide characters
14734 in ordinary strings.  These definitions are used by
14735 the package @code{System.Wch_Cnv}.
14736
14737 @node Interfacing to Other Languages
14738 @chapter Interfacing to Other Languages
14739 @noindent
14740 The facilities in annex B of the Ada Reference Manual are fully
14741 implemented in GNAT, and in addition, a full interface to C++ is
14742 provided.
14743
14744 @menu
14745 * Interfacing to C::
14746 * Interfacing to C++::
14747 * Interfacing to COBOL::
14748 * Interfacing to Fortran::
14749 * Interfacing to non-GNAT Ada code::
14750 @end menu
14751
14752 @node Interfacing to C
14753 @section Interfacing to C
14754
14755 @noindent
14756 Interfacing to C with GNAT can use one of two approaches:
14757
14758 @itemize @bullet
14759 @item
14760 The types in the package @code{Interfaces.C} may be used.
14761 @item
14762 Standard Ada types may be used directly.  This may be less portable to
14763 other compilers, but will work on all GNAT compilers, which guarantee
14764 correspondence between the C and Ada types.
14765 @end itemize
14766
14767 @noindent
14768 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14769 effect, since this is the default.  The following table shows the
14770 correspondence between Ada scalar types and the corresponding C types.
14771
14772 @table @code
14773 @item Integer
14774 @code{int}
14775 @item Short_Integer
14776 @code{short}
14777 @item Short_Short_Integer
14778 @code{signed char}
14779 @item Long_Integer
14780 @code{long}
14781 @item Long_Long_Integer
14782 @code{long long}
14783 @item Short_Float
14784 @code{float}
14785 @item Float
14786 @code{float}
14787 @item Long_Float
14788 @code{double}
14789 @item Long_Long_Float
14790 This is the longest floating-point type supported by the hardware.
14791 @end table
14792
14793 @noindent
14794 Additionally, there are the following general correspondences between Ada
14795 and C types:
14796 @itemize @bullet
14797 @item
14798 Ada enumeration types map to C enumeration types directly if pragma
14799 @code{Convention C} is specified, which causes them to have int
14800 length.  Without pragma @code{Convention C}, Ada enumeration types map to
14801 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14802 @code{int}, respectively) depending on the number of values passed.
14803 This is the only case in which pragma @code{Convention C} affects the
14804 representation of an Ada type.
14805
14806 @item
14807 Ada access types map to C pointers, except for the case of pointers to
14808 unconstrained types in Ada, which have no direct C equivalent.
14809
14810 @item
14811 Ada arrays map directly to C arrays.
14812
14813 @item
14814 Ada records map directly to C structures.
14815
14816 @item
14817 Packed Ada records map to C structures where all members are bit fields
14818 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14819 @end itemize
14820
14821 @node Interfacing to C++
14822 @section Interfacing to C++
14823
14824 @noindent
14825 The interface to C++ makes use of the following pragmas, which are
14826 primarily intended to be constructed automatically using a binding generator
14827 tool, although it is possible to construct them by hand.  No suitable binding
14828 generator tool is supplied with GNAT though.
14829
14830 Using these pragmas it is possible to achieve complete
14831 inter-operability between Ada tagged types and C++ class definitions.
14832 See @ref{Implementation Defined Pragmas}, for more details.
14833
14834 @table @code
14835 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14836 The argument denotes an entity in the current declarative region that is
14837 declared as a tagged or untagged record type. It indicates that the type
14838 corresponds to an externally declared C++ class type, and is to be laid
14839 out the same way that C++ would lay out the type.
14840
14841 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14842 for backward compatibility but its functionality is available
14843 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14844
14845 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14846 This pragma identifies an imported function (imported in the usual way
14847 with pragma @code{Import}) as corresponding to a C++ constructor.
14848 @end table
14849
14850 @node Interfacing to COBOL
14851 @section Interfacing to COBOL
14852
14853 @noindent
14854 Interfacing to COBOL is achieved as described in section B.4 of
14855 the Ada Reference Manual.
14856
14857 @node Interfacing to Fortran
14858 @section Interfacing to Fortran
14859
14860 @noindent
14861 Interfacing to Fortran is achieved as described in section B.5 of the
14862 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14863 multi-dimensional array causes the array to be stored in column-major
14864 order as required for convenient interface to Fortran.
14865
14866 @node Interfacing to non-GNAT Ada code
14867 @section Interfacing to non-GNAT Ada code
14868
14869 It is possible to specify the convention @code{Ada} in a pragma
14870 @code{Import} or pragma @code{Export}.  However this refers to
14871 the calling conventions used by GNAT, which may or may not be
14872 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14873 compiler to allow interoperation.
14874
14875 If arguments types are kept simple, and if the foreign compiler generally
14876 follows system calling conventions, then it may be possible to integrate
14877 files compiled by other Ada compilers, provided that the elaboration
14878 issues are adequately addressed (for example by eliminating the
14879 need for any load time elaboration).
14880
14881 In particular, GNAT running on VMS is designed to
14882 be highly compatible with the DEC Ada 83 compiler, so this is one
14883 case in which it is possible to import foreign units of this type,
14884 provided that the data items passed are restricted to simple scalar
14885 values or simple record types without variants, or simple array
14886 types with fixed bounds.
14887
14888 @node Specialized Needs Annexes
14889 @chapter Specialized Needs Annexes
14890
14891 @noindent
14892 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14893 required in all implementations.  However, as described in this chapter,
14894 GNAT implements all of these annexes:
14895
14896 @table @asis
14897 @item Systems Programming (Annex C)
14898 The Systems Programming Annex is fully implemented.
14899
14900 @item Real-Time Systems (Annex D)
14901 The Real-Time Systems Annex is fully implemented.
14902
14903 @item Distributed Systems (Annex E)
14904 Stub generation is fully implemented in the GNAT compiler.  In addition,
14905 a complete compatible PCS is available as part of the GLADE system,
14906 a separate product.  When the two
14907 products are used in conjunction, this annex is fully implemented.
14908
14909 @item Information Systems (Annex F)
14910 The Information Systems annex is fully implemented.
14911
14912 @item Numerics (Annex G)
14913 The Numerics Annex is fully implemented.
14914
14915 @item Safety and Security / High-Integrity Systems (Annex H)
14916 The Safety and Security Annex (termed the High-Integrity Systems Annex
14917 in Ada 2005) is fully implemented.
14918 @end table
14919
14920 @node Implementation of Specific Ada Features
14921 @chapter Implementation of Specific Ada Features
14922
14923 @noindent
14924 This chapter describes the GNAT implementation of several Ada language
14925 facilities.
14926
14927 @menu
14928 * Machine Code Insertions::
14929 * GNAT Implementation of Tasking::
14930 * GNAT Implementation of Shared Passive Packages::
14931 * Code Generation for Array Aggregates::
14932 * The Size of Discriminated Records with Default Discriminants::
14933 * Strict Conformance to the Ada Reference Manual::
14934 @end menu
14935
14936 @node Machine Code Insertions
14937 @section Machine Code Insertions
14938 @cindex Machine Code insertions
14939
14940 @noindent
14941 Package @code{Machine_Code} provides machine code support as described
14942 in the Ada Reference Manual in two separate forms:
14943 @itemize @bullet
14944 @item
14945 Machine code statements, consisting of qualified expressions that
14946 fit the requirements of RM section 13.8.
14947 @item
14948 An intrinsic callable procedure, providing an alternative mechanism of
14949 including machine instructions in a subprogram.
14950 @end itemize
14951
14952 @noindent
14953 The two features are similar, and both are closely related to the mechanism
14954 provided by the asm instruction in the GNU C compiler.  Full understanding
14955 and use of the facilities in this package requires understanding the asm
14956 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
14957 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
14958
14959 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14960 semantic restrictions and effects as described below.  Both are provided so
14961 that the procedure call can be used as a statement, and the function call
14962 can be used to form a code_statement.
14963
14964 The first example given in the GCC documentation is the C @code{asm}
14965 instruction:
14966 @smallexample
14967    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14968 @end smallexample
14969
14970 @noindent
14971 The equivalent can be written for GNAT as:
14972
14973 @smallexample @c ada
14974 Asm ("fsinx %1 %0",
14975      My_Float'Asm_Output ("=f", result),
14976      My_Float'Asm_Input  ("f",  angle));
14977 @end smallexample
14978
14979 @noindent
14980 The first argument to @code{Asm} is the assembler template, and is
14981 identical to what is used in GNU C@.  This string must be a static
14982 expression.  The second argument is the output operand list.  It is
14983 either a single @code{Asm_Output} attribute reference, or a list of such
14984 references enclosed in parentheses (technically an array aggregate of
14985 such references).
14986
14987 The @code{Asm_Output} attribute denotes a function that takes two
14988 parameters.  The first is a string, the second is the name of a variable
14989 of the type designated by the attribute prefix.  The first (string)
14990 argument is required to be a static expression and designates the
14991 constraint for the parameter (e.g.@: what kind of register is
14992 required).  The second argument is the variable to be updated with the
14993 result.  The possible values for constraint are the same as those used in
14994 the RTL, and are dependent on the configuration file used to build the
14995 GCC back end.  If there are no output operands, then this argument may
14996 either be omitted, or explicitly given as @code{No_Output_Operands}.
14997
14998 The second argument of @code{@var{my_float}'Asm_Output} functions as
14999 though it were an @code{out} parameter, which is a little curious, but
15000 all names have the form of expressions, so there is no syntactic
15001 irregularity, even though normally functions would not be permitted
15002 @code{out} parameters.  The third argument is the list of input
15003 operands.  It is either a single @code{Asm_Input} attribute reference, or
15004 a list of such references enclosed in parentheses (technically an array
15005 aggregate of such references).
15006
15007 The @code{Asm_Input} attribute denotes a function that takes two
15008 parameters.  The first is a string, the second is an expression of the
15009 type designated by the prefix.  The first (string) argument is required
15010 to be a static expression, and is the constraint for the parameter,
15011 (e.g.@: what kind of register is required).  The second argument is the
15012 value to be used as the input argument.  The possible values for the
15013 constant are the same as those used in the RTL, and are dependent on
15014 the configuration file used to built the GCC back end.
15015
15016 If there are no input operands, this argument may either be omitted, or
15017 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15018 present in the above example, is a list of register names, called the
15019 @dfn{clobber} argument.  This argument, if given, must be a static string
15020 expression, and is a space or comma separated list of names of registers
15021 that must be considered destroyed as a result of the @code{Asm} call.  If
15022 this argument is the null string (the default value), then the code
15023 generator assumes that no additional registers are destroyed.
15024
15025 The fifth argument, not present in the above example, called the
15026 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15027 the literal value @code{True} to indicate to the code generator that all
15028 optimizations with respect to the instruction specified should be
15029 suppressed, and that in particular, for an instruction that has outputs,
15030 the instruction will still be generated, even if none of the outputs are
15031 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15032 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15033 Generally it is strongly advisable to use Volatile for any ASM statement
15034 that is missing either input or output operands, or when two or more ASM
15035 statements appear in sequence, to avoid unwanted optimizations. A warning
15036 is generated if this advice is not followed.
15037
15038 The @code{Asm} subprograms may be used in two ways.  First the procedure
15039 forms can be used anywhere a procedure call would be valid, and
15040 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15041 be used to intersperse machine instructions with other Ada statements.
15042 Second, the function forms, which return a dummy value of the limited
15043 private type @code{Asm_Insn}, can be used in code statements, and indeed
15044 this is the only context where such calls are allowed.  Code statements
15045 appear as aggregates of the form:
15046
15047 @smallexample @c ada
15048 Asm_Insn'(Asm (@dots{}));
15049 Asm_Insn'(Asm_Volatile (@dots{}));
15050 @end smallexample
15051
15052 @noindent
15053 In accordance with RM rules, such code statements are allowed only
15054 within subprograms whose entire body consists of such statements.  It is
15055 not permissible to intermix such statements with other Ada statements.
15056
15057 Typically the form using intrinsic procedure calls is more convenient
15058 and more flexible.  The code statement form is provided to meet the RM
15059 suggestion that such a facility should be made available.  The following
15060 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15061 is used, the arguments may be given in arbitrary order, following the
15062 normal rules for use of positional and named arguments)
15063
15064 @smallexample
15065 ASM_CALL ::= Asm (
15066                  [Template =>] static_string_EXPRESSION
15067                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15068                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15069                [,[Clobber  =>] static_string_EXPRESSION ]
15070                [,[Volatile =>] static_boolean_EXPRESSION] )
15071
15072 OUTPUT_OPERAND_LIST ::=
15073   [PREFIX.]No_Output_Operands
15074 | OUTPUT_OPERAND_ATTRIBUTE
15075 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15076
15077 OUTPUT_OPERAND_ATTRIBUTE ::=
15078   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15079
15080 INPUT_OPERAND_LIST ::=
15081   [PREFIX.]No_Input_Operands
15082 | INPUT_OPERAND_ATTRIBUTE
15083 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15084
15085 INPUT_OPERAND_ATTRIBUTE ::=
15086   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15087 @end smallexample
15088
15089 @noindent
15090 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15091 are declared in the package @code{Machine_Code} and must be referenced
15092 according to normal visibility rules. In particular if there is no
15093 @code{use} clause for this package, then appropriate package name
15094 qualification is required.
15095
15096 @node GNAT Implementation of Tasking
15097 @section GNAT Implementation of Tasking
15098
15099 @noindent
15100 This chapter outlines the basic GNAT approach to tasking (in particular,
15101 a multi-layered library for portability) and discusses issues related
15102 to compliance with the Real-Time Systems Annex.
15103
15104 @menu
15105 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15106 * Ensuring Compliance with the Real-Time Annex::
15107 @end menu
15108
15109 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15110 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15111
15112 @noindent
15113 GNAT's run-time support comprises two layers:
15114
15115 @itemize @bullet
15116 @item GNARL (GNAT Run-time Layer)
15117 @item GNULL (GNAT Low-level Library)
15118 @end itemize
15119
15120 @noindent
15121 In GNAT, Ada's tasking services rely on a platform and OS independent
15122 layer known as GNARL@.  This code is responsible for implementing the
15123 correct semantics of Ada's task creation, rendezvous, protected
15124 operations etc.
15125
15126 GNARL decomposes Ada's tasking semantics into simpler lower level
15127 operations such as create a thread, set the priority of a thread,
15128 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15129 operations constitutes GNULLI, the GNULL Interface.  This interface is
15130 directly inspired from the POSIX real-time API@.
15131
15132 If the underlying executive or OS implements the POSIX standard
15133 faithfully, the GNULL Interface maps as is to the services offered by
15134 the underlying kernel.  Otherwise, some target dependent glue code maps
15135 the services offered by the underlying kernel to the semantics expected
15136 by GNARL@.
15137
15138 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15139 key point is that each Ada task is mapped on a thread in the underlying
15140 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15141
15142 In addition Ada task priorities map onto the underlying thread priorities.
15143 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15144
15145 @itemize @bullet
15146 @item
15147 The underlying scheduler is used to schedule the Ada tasks.  This
15148 makes Ada tasks as efficient as kernel threads from a scheduling
15149 standpoint.
15150
15151 @item
15152 Interaction with code written in C containing threads is eased
15153 since at the lowest level Ada tasks and C threads map onto the same
15154 underlying kernel concept.
15155
15156 @item
15157 When an Ada task is blocked during I/O the remaining Ada tasks are
15158 able to proceed.
15159
15160 @item
15161 On multiprocessor systems Ada tasks can execute in parallel.
15162 @end itemize
15163
15164 @noindent
15165 Some threads libraries offer a mechanism to fork a new process, with the
15166 child process duplicating the threads from the parent.
15167 GNAT does not
15168 support this functionality when the parent contains more than one task.
15169 @cindex Forking a new process
15170
15171 @node Ensuring Compliance with the Real-Time Annex
15172 @subsection Ensuring Compliance with the Real-Time Annex
15173 @cindex Real-Time Systems Annex compliance
15174
15175 @noindent
15176 Although mapping Ada tasks onto
15177 the underlying threads has significant advantages, it does create some
15178 complications when it comes to respecting the scheduling semantics
15179 specified in the real-time annex (Annex D).
15180
15181 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15182 scheduling policy states:
15183
15184 @quotation
15185 @emph{When the active priority of a ready task that is not running
15186 changes, or the setting of its base priority takes effect, the
15187 task is removed from the ready queue for its old active priority
15188 and is added at the tail of the ready queue for its new active
15189 priority, except in the case where the active priority is lowered
15190 due to the loss of inherited priority, in which case the task is
15191 added at the head of the ready queue for its new active priority.}
15192 @end quotation
15193
15194 @noindent
15195 While most kernels do put tasks at the end of the priority queue when
15196 a task changes its priority, (which respects the main
15197 FIFO_Within_Priorities requirement), almost none keep a thread at the
15198 beginning of its priority queue when its priority drops from the loss
15199 of inherited priority.
15200
15201 As a result most vendors have provided incomplete Annex D implementations.
15202
15203 The GNAT run-time, has a nice cooperative solution to this problem
15204 which ensures that accurate FIFO_Within_Priorities semantics are
15205 respected.
15206
15207 The principle is as follows.  When an Ada task T is about to start
15208 running, it checks whether some other Ada task R with the same
15209 priority as T has been suspended due to the loss of priority
15210 inheritance.  If this is the case, T yields and is placed at the end of
15211 its priority queue.  When R arrives at the front of the queue it
15212 executes.
15213
15214 Note that this simple scheme preserves the relative order of the tasks
15215 that were ready to execute in the priority queue where R has been
15216 placed at the end.
15217
15218 @node GNAT Implementation of Shared Passive Packages
15219 @section GNAT Implementation of Shared Passive Packages
15220 @cindex Shared passive packages
15221
15222 @noindent
15223 GNAT fully implements the pragma @code{Shared_Passive} for
15224 @cindex pragma @code{Shared_Passive}
15225 the purpose of designating shared passive packages.
15226 This allows the use of passive partitions in the
15227 context described in the Ada Reference Manual; i.e., for communication
15228 between separate partitions of a distributed application using the
15229 features in Annex E.
15230 @cindex Annex E
15231 @cindex Distribution Systems Annex
15232
15233 However, the implementation approach used by GNAT provides for more
15234 extensive usage as follows:
15235
15236 @table @emph
15237 @item Communication between separate programs
15238
15239 This allows separate programs to access the data in passive
15240 partitions, using protected objects for synchronization where
15241 needed. The only requirement is that the two programs have a
15242 common shared file system. It is even possible for programs
15243 running on different machines with different architectures
15244 (e.g.@: different endianness) to communicate via the data in
15245 a passive partition.
15246
15247 @item Persistence between program runs
15248
15249 The data in a passive package can persist from one run of a
15250 program to another, so that a later program sees the final
15251 values stored by a previous run of the same program.
15252
15253 @end table
15254
15255 @noindent
15256 The implementation approach used is to store the data in files. A
15257 separate stream file is created for each object in the package, and
15258 an access to an object causes the corresponding file to be read or
15259 written.
15260
15261 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15262 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15263 set to the directory to be used for these files.
15264 The files in this directory
15265 have names that correspond to their fully qualified names. For
15266 example, if we have the package
15267
15268 @smallexample @c ada
15269 package X is
15270   pragma Shared_Passive (X);
15271   Y : Integer;
15272   Z : Float;
15273 end X;
15274 @end smallexample
15275
15276 @noindent
15277 and the environment variable is set to @code{/stemp/}, then the files created
15278 will have the names:
15279
15280 @smallexample
15281 /stemp/x.y
15282 /stemp/x.z
15283 @end smallexample
15284
15285 @noindent
15286 These files are created when a value is initially written to the object, and
15287 the files are retained until manually deleted. This provides the persistence
15288 semantics. If no file exists, it means that no partition has assigned a value
15289 to the variable; in this case the initial value declared in the package
15290 will be used. This model ensures that there are no issues in synchronizing
15291 the elaboration process, since elaboration of passive packages elaborates the
15292 initial values, but does not create the files.
15293
15294 The files are written using normal @code{Stream_IO} access.
15295 If you want to be able
15296 to communicate between programs or partitions running on different
15297 architectures, then you should use the XDR versions of the stream attribute
15298 routines, since these are architecture independent.
15299
15300 If active synchronization is required for access to the variables in the
15301 shared passive package, then as described in the Ada Reference Manual, the
15302 package may contain protected objects used for this purpose. In this case
15303 a lock file (whose name is @file{___lock} (three underscores)
15304 is created in the shared memory directory.
15305 @cindex @file{___lock} file (for shared passive packages)
15306 This is used to provide the required locking
15307 semantics for proper protected object synchronization.
15308
15309 As of January 2003, GNAT supports shared passive packages on all platforms
15310 except for OpenVMS.
15311
15312 @node Code Generation for Array Aggregates
15313 @section Code Generation for Array Aggregates
15314
15315 @menu
15316 * Static constant aggregates with static bounds::
15317 * Constant aggregates with unconstrained nominal types::
15318 * Aggregates with static bounds::
15319 * Aggregates with non-static bounds::
15320 * Aggregates in assignment statements::
15321 @end menu
15322
15323 @noindent
15324 Aggregates have a rich syntax and allow the user to specify the values of
15325 complex data structures by means of a single construct.  As a result, the
15326 code generated for aggregates can be quite complex and involve loops, case
15327 statements and multiple assignments.  In the simplest cases, however, the
15328 compiler will recognize aggregates whose components and constraints are
15329 fully static, and in those cases the compiler will generate little or no
15330 executable code.  The following is an outline of the code that GNAT generates
15331 for various aggregate constructs.  For further details, you will find it
15332 useful to examine the output produced by the -gnatG flag to see the expanded
15333 source that is input to the code generator.  You may also want to examine
15334 the assembly code generated at various levels of optimization.
15335
15336 The code generated for aggregates depends on the context, the component values,
15337 and the type.  In the context of an object declaration the code generated is
15338 generally simpler than in the case of an assignment.  As a general rule, static
15339 component values and static subtypes also lead to simpler code.
15340
15341 @node Static constant aggregates with static bounds
15342 @subsection Static constant aggregates with static bounds
15343
15344 @noindent
15345 For the declarations:
15346 @smallexample @c ada
15347     type One_Dim is array (1..10) of integer;
15348     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15349 @end smallexample
15350
15351 @noindent
15352 GNAT generates no executable code: the constant ar0 is placed in static memory.
15353 The same is true for constant aggregates with named associations:
15354
15355 @smallexample @c ada
15356     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15357     Cr3 : constant One_Dim := (others => 7777);
15358 @end smallexample
15359
15360 @noindent
15361 The same is true for multidimensional constant arrays such as:
15362
15363 @smallexample @c ada
15364     type two_dim is array (1..3, 1..3) of integer;
15365     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15366 @end smallexample
15367
15368 @noindent
15369 The same is true for arrays of one-dimensional arrays: the following are
15370 static:
15371
15372 @smallexample @c ada
15373 type ar1b  is array (1..3) of boolean;
15374 type ar_ar is array (1..3) of ar1b;
15375 None  : constant ar1b := (others => false);     --  fully static
15376 None2 : constant ar_ar := (1..3 => None);       --  fully static
15377 @end smallexample
15378
15379 @noindent
15380 However, for multidimensional aggregates with named associations, GNAT will
15381 generate assignments and loops, even if all associations are static.  The
15382 following two declarations generate a loop for the first dimension, and
15383 individual component assignments for the second dimension:
15384
15385 @smallexample @c ada
15386 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15387 Zero2: constant two_dim := (others => (others => 0));
15388 @end smallexample
15389
15390 @node Constant aggregates with unconstrained nominal types
15391 @subsection Constant aggregates with unconstrained nominal types
15392
15393 @noindent
15394 In such cases the aggregate itself establishes the subtype, so that
15395 associations with @code{others} cannot be used.  GNAT determines the
15396 bounds for the actual subtype of the aggregate, and allocates the
15397 aggregate statically as well.  No code is generated for the following:
15398
15399 @smallexample @c ada
15400     type One_Unc is array (natural range <>) of integer;
15401     Cr_Unc : constant One_Unc := (12,24,36);
15402 @end smallexample
15403
15404 @node Aggregates with static bounds
15405 @subsection Aggregates with static bounds
15406
15407 @noindent
15408 In all previous examples the aggregate was the initial (and immutable) value
15409 of a constant.  If the aggregate initializes a variable, then code is generated
15410 for it as a combination of individual assignments and loops over the target
15411 object.  The declarations
15412
15413 @smallexample @c ada
15414        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15415        Cr_Var2 : One_Dim := (others > -1);
15416 @end smallexample
15417
15418 @noindent
15419 generate the equivalent of
15420
15421 @smallexample @c ada
15422        Cr_Var1 (1) := 2;
15423        Cr_Var1 (2) := 3;
15424        Cr_Var1 (3) := 5;
15425        Cr_Var1 (4) := 11;
15426
15427        for I in Cr_Var2'range loop
15428           Cr_Var2 (I) := -1;
15429        end loop;
15430 @end smallexample
15431
15432 @node Aggregates with non-static bounds
15433 @subsection Aggregates with non-static bounds
15434
15435 @noindent
15436 If the bounds of the aggregate are not statically compatible with the bounds
15437 of the nominal subtype  of the target, then constraint checks have to be
15438 generated on the bounds.  For a multidimensional array, constraint checks may
15439 have to be applied to sub-arrays individually, if they do not have statically
15440 compatible subtypes.
15441
15442 @node Aggregates in assignment statements
15443 @subsection Aggregates in assignment statements
15444
15445 @noindent
15446 In general, aggregate assignment requires the construction of a temporary,
15447 and a copy from the temporary to the target of the assignment.  This is because
15448 it is not always possible to convert the assignment into a series of individual
15449 component assignments.  For example, consider the simple case:
15450
15451 @smallexample @c ada
15452         A := (A(2), A(1));
15453 @end smallexample
15454
15455 @noindent
15456 This cannot be converted into:
15457
15458 @smallexample @c ada
15459         A(1) := A(2);
15460         A(2) := A(1);
15461 @end smallexample
15462
15463 @noindent
15464 So the aggregate has to be built first in a separate location, and then
15465 copied into the target.  GNAT recognizes simple cases where this intermediate
15466 step is not required, and the assignments can be performed in place, directly
15467 into the target.  The following sufficient criteria are applied:
15468
15469 @itemize @bullet
15470 @item
15471 The bounds of the aggregate are static, and the associations are static.
15472 @item
15473 The components of the aggregate are static constants, names of
15474 simple variables that are not renamings, or expressions not involving
15475 indexed components whose operands obey these rules.
15476 @end itemize
15477
15478 @noindent
15479 If any of these conditions are violated, the aggregate will be built in
15480 a temporary (created either by the front-end or the code generator) and then
15481 that temporary will be copied onto the target.
15482
15483
15484 @node The Size of Discriminated Records with Default Discriminants
15485 @section The Size of Discriminated Records with Default Discriminants
15486
15487 @noindent
15488 If a discriminated type @code{T} has discriminants with default values, it is
15489 possible to declare an object of this type without providing an explicit
15490 constraint:
15491
15492 @smallexample @c ada
15493 @group
15494 type Size is range 1..100;
15495
15496 type Rec (D : Size := 15) is record
15497    Name : String (1..D);
15498 end T;
15499
15500 Word : Rec;
15501 @end group
15502 @end smallexample
15503
15504 @noindent
15505 Such an object is said to be @emph{unconstrained}.
15506 The discriminant of the object
15507 can be modified by a full assignment to the object, as long as it preserves the
15508 relation between the value of the discriminant, and the value of the components
15509 that depend on it:
15510
15511 @smallexample @c ada
15512 @group
15513 Word := (3, "yes");
15514
15515 Word := (5, "maybe");
15516
15517 Word := (5, "no"); -- raises Constraint_Error
15518 @end group
15519 @end smallexample
15520
15521 @noindent
15522 In order to support this behavior efficiently, an unconstrained object is
15523 given the maximum size that any value of the type requires. In the case
15524 above, @code{Word} has storage for the discriminant and for
15525 a @code{String} of length 100.
15526 It is important to note that unconstrained objects do not require dynamic
15527 allocation. It would be an improper implementation to place on the heap those
15528 components whose size depends on discriminants. (This improper implementation
15529 was used by some Ada83 compilers, where the @code{Name} component above
15530 would have
15531 been stored as a pointer to a dynamic string). Following the principle that
15532 dynamic storage management should never be introduced implicitly,
15533 an Ada compiler should reserve the full size for an unconstrained declared
15534 object, and place it on the stack.
15535
15536 This maximum size approach
15537 has been a source of surprise to some users, who expect the default
15538 values of the discriminants to determine the size reserved for an
15539 unconstrained object: ``If the default is 15, why should the object occupy
15540 a larger size?''
15541 The answer, of course, is that the discriminant may be later modified,
15542 and its full range of values must be taken into account. This is why the
15543 declaration:
15544
15545 @smallexample
15546 @group
15547 type Rec (D : Positive := 15) is record
15548    Name : String (1..D);
15549 end record;
15550
15551 Too_Large : Rec;
15552 @end group
15553 @end smallexample
15554
15555 @noindent
15556 is flagged by the compiler with a warning:
15557 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15558 because the required size includes @code{Positive'Last}
15559 bytes. As the first example indicates, the proper approach is to declare an
15560 index type of ``reasonable'' range so that unconstrained objects are not too
15561 large.
15562
15563 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15564 created in the heap by means of an allocator, then it is @emph{not}
15565 unconstrained:
15566 it is constrained by the default values of the discriminants, and those values
15567 cannot be modified by full assignment. This is because in the presence of
15568 aliasing all views of the object (which may be manipulated by different tasks,
15569 say) must be consistent, so it is imperative that the object, once created,
15570 remain invariant.
15571
15572 @node Strict Conformance to the Ada Reference Manual
15573 @section Strict Conformance to the Ada Reference Manual
15574
15575 @noindent
15576 The dynamic semantics defined by the Ada Reference Manual impose a set of
15577 run-time checks to be generated. By default, the GNAT compiler will insert many
15578 run-time checks into the compiled code, including most of those required by the
15579 Ada Reference Manual. However, there are three checks that are not enabled
15580 in the default mode for efficiency reasons: arithmetic overflow checking for
15581 integer operations (including division by zero), checks for access before
15582 elaboration on subprogram calls, and stack overflow checking (most operating
15583 systems do not perform this check by default).
15584
15585 Strict conformance to the Ada Reference Manual can be achieved by adding
15586 three compiler options for overflow checking for integer operations
15587 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15588 calls and generic instantiations (@option{-gnatE}), and stack overflow
15589 checking (@option{-fstack-check}).
15590
15591 Note that the result of a floating point arithmetic operation in overflow and
15592 invalid situations, when the @code{Machine_Overflows} attribute of the result
15593 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15594 case for machines compliant with the IEEE floating-point standard, but on
15595 machines that are not fully compliant with this standard, such as Alpha, the
15596 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15597 behavior (although at the cost of a significant performance penalty), so
15598 infinite and and NaN values are properly generated.
15599
15600
15601 @node Project File Reference
15602 @chapter Project File Reference
15603
15604 @noindent
15605 This chapter describes the syntax and semantics of project files.
15606 Project files specify the options to be used when building a system.
15607 Project files can specify global settings for all tools,
15608 as well as tool-specific settings.
15609 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15610 for examples of use.
15611
15612 @menu
15613 * Reserved Words::
15614 * Lexical Elements::
15615 * Declarations::
15616 * Empty declarations::
15617 * Typed string declarations::
15618 * Variables::
15619 * Expressions::
15620 * Attributes::
15621 * Project Attributes::
15622 * Attribute References::
15623 * External Values::
15624 * Case Construction::
15625 * Packages::
15626 * Package Renamings::
15627 * Projects::
15628 * Project Extensions::
15629 * Project File Elaboration::
15630 @end menu
15631
15632 @node Reserved Words
15633 @section Reserved Words
15634
15635 @noindent
15636 All Ada reserved words are reserved in project files, and cannot be used
15637 as variable names or project names. In addition, the following are
15638 also reserved in project files:
15639
15640 @itemize
15641 @item @code{extends}
15642
15643 @item @code{external}
15644
15645 @item @code{project}
15646
15647 @end itemize
15648
15649 @node Lexical Elements
15650 @section Lexical Elements
15651
15652 @noindent
15653 Rules for identifiers are the same as in Ada. Identifiers
15654 are case-insensitive.  Strings are case sensitive, except where noted.
15655 Comments have the same form as in Ada.
15656
15657 @noindent
15658 Syntax:
15659
15660 @smallexample
15661 simple_name ::=
15662   identifier
15663
15664 name ::=
15665   simple_name @{. simple_name@}
15666 @end smallexample
15667
15668 @node Declarations
15669 @section Declarations
15670
15671 @noindent
15672 Declarations introduce new entities that denote types, variables, attributes,
15673 and packages. Some declarations can only appear immediately within a project
15674 declaration. Others can appear within a project or within a package.
15675
15676 Syntax:
15677 @smallexample
15678 declarative_item ::=
15679   simple_declarative_item |
15680   typed_string_declaration |
15681   package_declaration
15682
15683 simple_declarative_item ::=
15684   variable_declaration |
15685   typed_variable_declaration |
15686   attribute_declaration |
15687   case_construction |
15688   empty_declaration
15689 @end smallexample
15690
15691 @node Empty declarations
15692 @section Empty declarations
15693
15694 @smallexample
15695 empty_declaration ::=
15696   @b{null} ;
15697 @end smallexample
15698
15699 An empty declaration is allowed anywhere a declaration is allowed.
15700 It has no effect.
15701
15702 @node Typed string declarations
15703 @section Typed string declarations
15704
15705 @noindent
15706 Typed strings are sequences of string literals. Typed strings are the only
15707 named types in project files. They are used in case constructions, where they
15708 provide support for conditional attribute definitions.
15709
15710 Syntax:
15711 @smallexample
15712 typed_string_declaration ::=
15713   @b{type} <typed_string_>_simple_name @b{is}
15714    ( string_literal @{, string_literal@} );
15715 @end smallexample
15716
15717 @noindent
15718 A typed string declaration can only appear immediately within a project
15719 declaration.
15720
15721 All the string literals in a typed string declaration must be distinct.
15722
15723 @node Variables
15724 @section Variables
15725
15726 @noindent
15727 Variables denote values, and appear as constituents of expressions.
15728
15729 @smallexample
15730 typed_variable_declaration ::=
15731   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15732
15733 variable_declaration ::=
15734   <variable_>simple_name := expression;
15735 @end smallexample
15736
15737 @noindent
15738 The elaboration of a variable declaration introduces the variable and
15739 assigns to it the value of the expression. The name of the variable is
15740 available after the assignment symbol.
15741
15742 @noindent
15743 A typed_variable can only be declare once.
15744
15745 @noindent
15746 a non-typed variable can be declared multiple times.
15747
15748 @noindent
15749 Before the completion of its first declaration, the value of variable
15750 is the null string.
15751
15752 @node Expressions
15753 @section Expressions
15754
15755 @noindent
15756 An expression is a formula that defines a computation or retrieval of a value.
15757 In a project file the value of an expression is either a string or a list
15758 of strings. A string value in an expression is either a literal, the current
15759 value of a variable, an external value, an attribute reference, or a
15760 concatenation operation.
15761
15762 Syntax:
15763
15764 @smallexample
15765 expression ::=
15766   term @{& term@}
15767
15768 term ::=
15769   string_literal |
15770   string_list |
15771   <variable_>name |
15772   external_value |
15773   attribute_reference
15774
15775 string_literal ::=
15776   (same as Ada)
15777
15778 string_list ::=
15779   ( <string_>expression @{ , <string_>expression @} )
15780 @end smallexample
15781
15782 @subsection Concatenation
15783 @noindent
15784 The following concatenation functions are defined:
15785
15786 @smallexample @c ada
15787   function "&" (X : String;      Y : String)      return String;
15788   function "&" (X : String_List; Y : String)      return String_List;
15789   function "&" (X : String_List; Y : String_List) return String_List;
15790 @end smallexample
15791
15792 @node Attributes
15793 @section Attributes
15794
15795 @noindent
15796 An attribute declaration defines a property of a project or package. This
15797 property can later be queried by means of an attribute reference.
15798 Attribute values are strings or string lists.
15799
15800 Some attributes are associative arrays. These attributes are mappings whose
15801 domain is a set of strings. These attributes are declared one association
15802 at a time, by specifying a point in the domain and the corresponding image
15803 of the attribute. They may also be declared as a full associative array,
15804 getting the same associations as the corresponding attribute in an imported
15805 or extended project.
15806
15807 Attributes that are not associative arrays are called simple attributes.
15808
15809 Syntax:
15810 @smallexample
15811 attribute_declaration ::=
15812   full_associative_array_declaration |
15813   @b{for} attribute_designator @b{use} expression ;
15814
15815 full_associative_array_declaration ::=
15816   @b{for} <associative_array_attribute_>simple_name @b{use}
15817   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15818
15819 attribute_designator ::=
15820   <simple_attribute_>simple_name |
15821   <associative_array_attribute_>simple_name ( string_literal )
15822 @end smallexample
15823
15824 @noindent
15825 Some attributes are project-specific, and can only appear immediately within
15826 a project declaration. Others are package-specific, and can only appear within
15827 the proper package.
15828
15829 The expression in an attribute definition must be a string or a string_list.
15830 The string literal appearing in the attribute_designator of an associative
15831 array attribute is case-insensitive.
15832
15833 @node Project Attributes
15834 @section Project Attributes
15835
15836 @noindent
15837 The following attributes apply to a project. All of them are simple
15838 attributes.
15839
15840 @table @code
15841 @item   Object_Dir
15842 Expression must be a path name. The attribute defines the
15843 directory in which the object files created by the build are to be placed. If
15844 not specified, object files are placed in the project directory.
15845
15846 @item   Exec_Dir
15847 Expression must be a path name. The attribute defines the
15848 directory in which the executables created by the build are to be placed.
15849 If not specified, executables are placed in the object directory.
15850
15851 @item  Source_Dirs
15852 Expression must be a list of path names. The attribute
15853 defines the directories in which the source files for the project are to be
15854 found. If not specified, source files are found in the project directory.
15855 If a string in the list ends with "/**", then the directory that precedes
15856 "/**" and all of its subdirectories (recursively) are included in the list
15857 of source directories.
15858
15859 @item  Excluded_Source_Dirs
15860 Expression must be a list of strings. Each entry designates a directory that
15861 is not to be included in the list of source directories of the project.
15862 This is normally used when there are strings ending with "/**" in the value
15863 of attribute Source_Dirs.
15864
15865 @item  Source_Files
15866 Expression must be a list of file names. The attribute
15867 defines the individual files, in the project directory, which are to be used
15868 as sources for the project. File names are path_names that contain no directory
15869 information. If the project has no sources the attribute must be declared
15870 explicitly with an empty list.
15871
15872 @item  Excluded_Source_Files (Locally_Removed_Files)
15873 Expression must be a list of strings that are legal file names.
15874 Each file name must designate a source that would normally be a source file
15875 in the source directories of the project or, if the project file is an
15876 extending project file, inherited by the current project file. It cannot
15877 designate an immediate source that is not inherited. Each of the source files
15878 in the list are not considered to be sources of the project file: they are not
15879 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15880 Excluded_Source_Files is preferred.
15881
15882 @item  Source_List_File
15883 Expression must a single path name. The attribute
15884 defines a text file that contains a list of source file names to be used
15885 as sources for the project
15886
15887 @item  Library_Dir
15888 Expression must be a path name. The attribute defines the
15889 directory in which a  library is to be built.  The directory must exist, must
15890 be distinct from the project's object directory, and must be writable.
15891
15892 @item  Library_Name
15893 Expression must be a string that is a legal file name,
15894 without extension. The attribute defines a string that is used to generate
15895 the name of the library to be built by the project.
15896
15897 @item  Library_Kind
15898 Argument must be a string value that must be one of the
15899 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15900 string is case-insensitive. If this attribute is not specified, the library is
15901 a static library. Otherwise, the library may be dynamic or relocatable. This
15902 distinction is operating-system dependent.
15903
15904 @item  Library_Version
15905 Expression must be a string value whose interpretation
15906 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15907 libraries as the internal name of the library (the @code{"soname"}). If the
15908 library file name (built from the @code{Library_Name}) is different from the
15909 @code{Library_Version}, then the library file will be a symbolic link to the
15910 actual file whose name will be @code{Library_Version}.
15911
15912 @item Library_Interface
15913 Expression must be a string list. Each element of the string list
15914 must designate a unit of the project.
15915 If this attribute is present in a Library Project File, then the project
15916 file is a Stand-alone Library_Project_File.
15917
15918 @item Library_Auto_Init
15919 Expression must be a single string "true" or "false", case-insensitive.
15920 If this attribute is present in a Stand-alone Library Project File,
15921 it indicates if initialization is automatic when the dynamic library
15922 is loaded.
15923
15924 @item Library_Options
15925 Expression must be a string list. Indicates additional switches that
15926 are to be used when building a shared library.
15927
15928 @item Library_GCC
15929 Expression must be a single string. Designates an alternative to "gcc"
15930 for building shared libraries.
15931
15932 @item  Library_Src_Dir
15933 Expression must be a path name. The attribute defines the
15934 directory in which the sources of the interfaces of a Stand-alone Library will
15935 be copied.  The directory must exist, must be distinct from the project's
15936 object directory and source directories of all projects in the project tree,
15937 and must be writable.
15938
15939 @item  Library_Src_Dir
15940 Expression must be a path name. The attribute defines the
15941 directory in which the ALI files of a Library will
15942 be copied.  The directory must exist, must be distinct from the project's
15943 object directory and source directories of all projects in the project tree,
15944 and must be writable.
15945
15946 @item  Library_Symbol_File
15947 Expression must be a single string. Its value is the single file name of a
15948 symbol file to be created when building a stand-alone library when the
15949 symbol policy is either "compliant", "controlled" or "restricted",
15950 on platforms that support symbol control, such as VMS. When symbol policy
15951 is "direct", then a file with this name must exist in the object directory.
15952
15953 @item   Library_Reference_Symbol_File
15954 Expression must be a single string. Its value is the path name of a
15955 reference symbol file that is read when the symbol policy is either
15956 "compliant" or "controlled", on platforms that support symbol control,
15957 such as VMS, when building a stand-alone library. The path may be an absolute
15958 path or a path relative to the project directory.
15959
15960 @item  Library_Symbol_Policy
15961 Expression must be a single string. Its case-insensitive value can only be
15962 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15963
15964 This attribute is not taken into account on all platforms. It controls the
15965 policy for exported symbols and, on some platforms (like VMS) that have the
15966 notions of major and minor IDs built in the library files, it controls
15967 the setting of these IDs.
15968
15969 "autonomous" or "default": exported symbols are not controlled.
15970
15971 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15972 it is equivalent to policy "autonomous". If there are exported symbols in
15973 the reference symbol file that are not in the object files of the interfaces,
15974 the major ID of the library is increased. If there are symbols in the
15975 object files of the interfaces that are not in the reference symbol file,
15976 these symbols are put at the end of the list in the newly created symbol file
15977 and the minor ID is increased.
15978
15979 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15980 The library will fail to build if the exported symbols in the object files of
15981 the interfaces do not match exactly the symbol in the symbol file.
15982
15983 "restricted": The attribute Library_Symbol_File must be defined. The library
15984 will fail to build if there are symbols in the symbol file that are not in
15985 the exported symbols of the object files of the interfaces. Additional symbols
15986 in the object files are not added to the symbol file.
15987
15988 "direct": The attribute Library_Symbol_File must be defined and must designate
15989 an existing file in the object directory. This symbol file is passed directly
15990 to the underlying linker without any symbol processing.
15991
15992 @item  Main
15993 Expression must be a list of strings that are legal file names.
15994 These file names designate existing compilation units in the source directory
15995 that are legal main subprograms.
15996
15997 When a project file is elaborated, as part of the execution of a gnatmake
15998 command, one or several executables are built and placed in the Exec_Dir.
15999 If the gnatmake command does not include explicit file names, the executables
16000 that are built correspond to the files specified by this attribute.
16001
16002 @item  Externally_Built
16003 Expression must be a single string. Its value must be either "true" of "false",
16004 case-insensitive. The default is "false". When the value of this attribute is
16005 "true", no attempt is made to compile the sources or to build the library,
16006 when the project is a library project.
16007
16008 @item Main_Language
16009 This is a simple attribute. Its value is a string that specifies the
16010 language of the main program.
16011
16012 @item  Languages
16013 Expression must be a string list. Each string designates
16014 a programming language that is known to GNAT. The strings are case-insensitive.
16015
16016 @end table
16017
16018 @node Attribute References
16019 @section Attribute References
16020
16021 @noindent
16022 Attribute references are used to retrieve the value of previously defined
16023 attribute for a package or project.
16024 Syntax:
16025 @smallexample
16026 attribute_reference ::=
16027   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16028
16029 attribute_prefix ::=
16030   @b{project} |
16031   <project_simple_name | package_identifier |
16032   <project_>simple_name . package_identifier
16033 @end smallexample
16034
16035 @noindent
16036 If an attribute has not been specified for a given package or project, its
16037 value is the null string or the empty list.
16038
16039 @node External Values
16040 @section External Values
16041
16042 @noindent
16043 An external value is an expression whose value is obtained from the command
16044 that invoked the processing of the current project file (typically a
16045 gnatmake command).
16046
16047 Syntax:
16048 @smallexample
16049 external_value ::=
16050   @b{external} ( string_literal [, string_literal] )
16051 @end smallexample
16052
16053 @noindent
16054 The first string_literal is the string to be used on the command line or
16055 in the environment to specify the external value. The second string_literal,
16056 if present, is the default to use if there is no specification for this
16057 external value either on the command line or in the environment.
16058
16059 @node Case Construction
16060 @section Case Construction
16061
16062 @noindent
16063 A case construction supports attribute and variable declarations that depend
16064 on the value of a previously declared variable.
16065
16066 Syntax:
16067 @smallexample
16068 case_construction ::=
16069   @b{case} <typed_variable_>name @b{is}
16070     @{case_item@}
16071   @b{end case} ;
16072
16073 case_item ::=
16074   @b{when} discrete_choice_list =>
16075     @{case_construction |
16076       attribute_declaration |
16077       variable_declaration |
16078       empty_declaration@}
16079
16080 discrete_choice_list ::=
16081   string_literal @{| string_literal@} |
16082     @b{others}
16083 @end smallexample
16084
16085 @noindent
16086 Inside a case construction, variable declarations must be for variables that
16087 have already been declared before the case construction.
16088
16089 All choices in a choice list must be distinct. The choice lists of two
16090 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16091 alternatives do not need to include all values of the type. An @code{others}
16092 choice must appear last in the list of alternatives.
16093
16094 @node Packages
16095 @section Packages
16096
16097 @noindent
16098 A package provides a grouping of variable declarations and attribute
16099 declarations to be used when invoking various GNAT tools. The name of
16100 the package indicates the tool(s) to which it applies.
16101 Syntax:
16102
16103 @smallexample
16104 package_declaration ::=
16105   package_spec | package_renaming
16106
16107 package_spec ::=
16108   @b{package} package_identifier @b{is}
16109     @{simple_declarative_item@}
16110   @b{end} package_identifier ;
16111
16112 package_identifier ::=
16113   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16114   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16115   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16116 @end smallexample
16117
16118 @subsection Package Naming
16119
16120 @noindent
16121 The attributes of a @code{Naming} package specifies the naming conventions
16122 that apply to the source files in a project. When invoking other GNAT tools,
16123 they will use the sources in the source directories that satisfy these
16124 naming conventions.
16125
16126 The following attributes apply to a @code{Naming} package:
16127
16128 @table @code
16129 @item Casing
16130 This is a simple attribute whose value is a string. Legal values of this
16131 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16132 These strings are themselves case insensitive.
16133
16134 @noindent
16135 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16136
16137 @item Dot_Replacement
16138 This is a simple attribute whose string value satisfies the following
16139 requirements:
16140
16141 @itemize @bullet
16142 @item It must not be empty
16143 @item It cannot start or end with an alphanumeric character
16144 @item It cannot be a single underscore
16145 @item It cannot start with an underscore followed by an alphanumeric
16146 @item It cannot contain a dot @code{'.'} if longer than one character
16147 @end itemize
16148
16149 @noindent
16150 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16151
16152 @item Spec_Suffix
16153 This is an associative array attribute, defined on language names,
16154 whose image is a string that must satisfy the following
16155 conditions:
16156
16157 @itemize @bullet
16158 @item It must not be empty
16159 @item It cannot start with an alphanumeric character
16160 @item It cannot start with an underscore followed by an alphanumeric character
16161 @end itemize
16162
16163 @noindent
16164 For Ada, the attribute denotes the suffix used in file names that contain
16165 library unit declarations, that is to say units that are package and
16166 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16167 specified, then the default is @code{".ads"}.
16168
16169 For C and C++, the attribute denotes the suffix used in file names that
16170 contain prototypes.
16171
16172 @item Body_Suffix
16173 This is an associative array attribute defined on language names,
16174 whose image is a string that must satisfy the following
16175 conditions:
16176
16177 @itemize @bullet
16178 @item It must not be empty
16179 @item It cannot start with an alphanumeric character
16180 @item It cannot start with an underscore followed by an alphanumeric character
16181 @item It cannot be a suffix of @code{Spec_Suffix}
16182 @end itemize
16183
16184 @noindent
16185 For Ada, the attribute denotes the suffix used in file names that contain
16186 library bodies, that is to say units that are package and subprogram bodies.
16187 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16188 @code{".adb"}.
16189
16190 For C and C++, the attribute denotes the suffix used in file names that contain
16191 source code.
16192
16193 @item Separate_Suffix
16194 This is a simple attribute whose value satisfies the same conditions as
16195 @code{Body_Suffix}.
16196
16197 This attribute is specific to Ada. It denotes the suffix used in file names
16198 that contain separate bodies. If it is not specified, then it defaults to same
16199 value as @code{Body_Suffix ("Ada")}.
16200
16201 @item Spec
16202 This is an associative array attribute, specific to Ada, defined over
16203 compilation unit names. The image is a string that is the name of the file
16204 that contains that library unit. The file name is case sensitive if the
16205 conventions of the host operating system require it.
16206
16207 @item Body
16208 This is an associative array attribute, specific to Ada, defined over
16209 compilation unit names. The image is a string that is the name of the file
16210 that contains the library unit body for the named unit. The file name is case
16211 sensitive if the conventions of the host operating system require it.
16212
16213 @item Specification_Exceptions
16214 This is an associative array attribute defined on language names,
16215 whose value is a list of strings.
16216
16217 This attribute is not significant for Ada.
16218
16219 For C and C++, each string in the list denotes the name of a file that
16220 contains prototypes, but whose suffix is not necessarily the
16221 @code{Spec_Suffix} for the language.
16222
16223 @item Implementation_Exceptions
16224 This is an associative array attribute defined on language names,
16225 whose value is a list of strings.
16226
16227 This attribute is not significant for Ada.
16228
16229 For C and C++, each string in the list denotes the name of a file that
16230 contains source code, but whose suffix is not necessarily the
16231 @code{Body_Suffix} for the language.
16232 @end table
16233
16234 The following attributes of package @code{Naming} are obsolescent. They are
16235 kept as synonyms of other attributes for compatibility with previous versions
16236 of the Project Manager.
16237
16238 @table @code
16239 @item Specification_Suffix
16240 This is a synonym of @code{Spec_Suffix}.
16241
16242 @item Implementation_Suffix
16243 This is a synonym of @code{Body_Suffix}.
16244
16245 @item Specification
16246 This is a synonym of @code{Spec}.
16247
16248 @item Implementation
16249 This is a synonym of @code{Body}.
16250 @end table
16251
16252 @subsection package Compiler
16253
16254 @noindent
16255 The attributes of the @code{Compiler} package specify the compilation options
16256 to be used by the underlying compiler.
16257
16258 @table @code
16259 @item  Default_Switches
16260 This is an associative array attribute. Its
16261 domain is a set of language names. Its range is a string list that
16262 specifies the compilation options to be used when compiling a component
16263 written in that language, for which no file-specific switches have been
16264 specified.
16265
16266 @item  Switches
16267 This is an associative array attribute. Its domain is
16268 a set of file names. Its range is a string list that specifies the
16269 compilation options to be used when compiling the named file. If a file
16270 is not specified in the Switches attribute, it is compiled with the
16271 options specified by Default_Switches of its language, if defined.
16272
16273 @item  Local_Configuration_Pragmas.
16274 This is a simple attribute, whose
16275 value is a path name that designates a file containing configuration pragmas
16276 to be used for all invocations of the compiler for immediate sources of the
16277 project.
16278 @end table
16279
16280 @subsection package Builder
16281
16282 @noindent
16283 The attributes of package @code{Builder} specify the compilation, binding, and
16284 linking options to be used when building an executable for a project. The
16285 following attributes apply to package @code{Builder}:
16286
16287 @table @code
16288 @item Default_Switches
16289 This is an associative array attribute. Its
16290 domain is a set of language names. Its range is a string list that
16291 specifies options to be used when building a main
16292 written in that language, for which no file-specific switches have been
16293 specified.
16294
16295 @item Switches
16296 This is an associative array attribute. Its domain is
16297 a set of file names. Its range is a string list that specifies
16298 options to be used when building the named main file. If a main file
16299 is not specified in the Switches attribute, it is built with the
16300 options specified by Default_Switches of its language, if defined.
16301
16302 @item Global_Configuration_Pragmas
16303 This is a simple attribute, whose
16304 value is a path name that designates a file that contains configuration pragmas
16305 to be used in every build of an executable. If both local and global
16306 configuration pragmas are specified, a compilation makes use of both sets.
16307
16308
16309 @item Executable
16310 This is an associative array attribute. Its domain is
16311 a set of main source file names. Its range is a simple string that specifies
16312 the executable file name to be used when linking the specified main source.
16313 If a main source is not specified in the Executable attribute, the executable
16314 file name is deducted from the main source file name.
16315 This attribute has no effect if its value is the empty string.
16316
16317 @item Executable_Suffix
16318 This is a simple attribute whose value is the suffix to be added to
16319 the executables that don't have an attribute Executable specified.
16320 @end table
16321
16322 @subsection package Gnatls
16323
16324 @noindent
16325 The attributes of package @code{Gnatls} specify the tool options to be used
16326 when invoking the library browser @command{gnatls}.
16327 The following attributes apply to package @code{Gnatls}:
16328
16329 @table @code
16330 @item Switches
16331 This is a single attribute with a string list value. Each nonempty string
16332 in the list is an option when invoking @code{gnatls}.
16333 @end table
16334
16335 @subsection package Binder
16336
16337 @noindent
16338 The attributes of package @code{Binder} specify the options to be used
16339 when invoking the binder in the construction of an executable.
16340 The following attributes apply to package @code{Binder}:
16341
16342 @table @code
16343 @item     Default_Switches
16344 This is an associative array attribute. Its
16345 domain is a set of language names. Its range is a string list that
16346 specifies options to be used when binding a main
16347 written in that language, for which no file-specific switches have been
16348 specified.
16349
16350 @item Switches
16351 This is an associative array attribute. Its domain is
16352 a set of file names. Its range is a string list that specifies
16353 options to be used when binding the named main file. If a main file
16354 is not specified in the Switches attribute, it is bound with the
16355 options specified by Default_Switches of its language, if defined.
16356 @end table
16357
16358 @subsection package Linker
16359
16360 @noindent
16361 The attributes of package @code{Linker} specify the options to be used when
16362 invoking the linker in the construction of an executable.
16363 The following attributes apply to package @code{Linker}:
16364
16365 @table @code
16366 @item     Default_Switches
16367 This is an associative array attribute. Its
16368 domain is a set of language names. Its range is a string list that
16369 specifies options to be used when linking a main
16370 written in that language, for which no file-specific switches have been
16371 specified.
16372
16373 @item Switches
16374 This is an associative array attribute. Its domain is
16375 a set of file names. Its range is a string list that specifies
16376 options to be used when linking the named main file. If a main file
16377 is not specified in the Switches attribute, it is linked with the
16378 options specified by Default_Switches of its language, if defined.
16379
16380 @item  Linker_Options
16381 This is a string list attribute. Its value specifies additional options that
16382 be given to the linker when linking an executable. This attribute is not
16383 used in the main project, only in projects imported directly or indirectly.
16384
16385 @end table
16386
16387 @subsection package Cross_Reference
16388
16389 @noindent
16390 The attributes of package @code{Cross_Reference} specify the tool options
16391 to be used
16392 when invoking the library tool @command{gnatxref}.
16393 The following attributes apply to package @code{Cross_Reference}:
16394
16395 @table @code
16396 @item     Default_Switches
16397 This is an associative array attribute. Its
16398 domain is a set of language names. Its range is a string list that
16399 specifies options to be used when calling @command{gnatxref} on a source
16400 written in that language, for which no file-specific switches have been
16401 specified.
16402
16403 @item Switches
16404 This is an associative array attribute. Its domain is
16405 a set of file names. Its range is a string list that specifies
16406 options to be used when calling @command{gnatxref} on the named main source.
16407 If a source is not specified in the Switches attribute, @command{gnatxref} will
16408 be called with the options specified by Default_Switches of its language,
16409 if defined.
16410 @end table
16411
16412 @subsection package   Finder
16413
16414 @noindent
16415 The attributes of package @code{Finder} specify the tool options to be used
16416 when invoking the search tool @command{gnatfind}.
16417 The following attributes apply to package @code{Finder}:
16418
16419 @table @code
16420 @item     Default_Switches
16421 This is an associative array attribute. Its
16422 domain is a set of language names. Its range is a string list that
16423 specifies options to be used when calling @command{gnatfind} on a source
16424 written in that language, for which no file-specific switches have been
16425 specified.
16426
16427 @item Switches
16428 This is an associative array attribute. Its domain is
16429 a set of file names. Its range is a string list that specifies
16430 options to be used when calling @command{gnatfind} on the named main source.
16431 If a source is not specified in the Switches attribute, @command{gnatfind} will
16432 be called with the options specified by Default_Switches of its language,
16433 if defined.
16434 @end table
16435
16436 @subsection package Pretty_Printer
16437
16438 @noindent
16439 The attributes of package @code{Pretty_Printer}
16440 specify the tool options to be used
16441 when invoking the formatting tool @command{gnatpp}.
16442 The following attributes apply to package @code{Pretty_Printer}:
16443
16444 @table @code
16445 @item     Default_switches
16446 This is an associative array attribute. Its
16447 domain is a set of language names. Its range is a string list that
16448 specifies options to be used when calling @command{gnatpp} on a source
16449 written in that language, for which no file-specific switches have been
16450 specified.
16451
16452 @item Switches
16453 This is an associative array attribute. Its domain is
16454 a set of file names. Its range is a string list that specifies
16455 options to be used when calling @command{gnatpp} on the named main source.
16456 If a source is not specified in the Switches attribute, @command{gnatpp} will
16457 be called with the options specified by Default_Switches of its language,
16458 if defined.
16459 @end table
16460
16461 @subsection package gnatstub
16462
16463 @noindent
16464 The attributes of package @code{gnatstub}
16465 specify the tool options to be used
16466 when invoking the tool @command{gnatstub}.
16467 The following attributes apply to package @code{gnatstub}:
16468
16469 @table @code
16470 @item     Default_switches
16471 This is an associative array attribute. Its
16472 domain is a set of language names. Its range is a string list that
16473 specifies options to be used when calling @command{gnatstub} on a source
16474 written in that language, for which no file-specific switches have been
16475 specified.
16476
16477 @item Switches
16478 This is an associative array attribute. Its domain is
16479 a set of file names. Its range is a string list that specifies
16480 options to be used when calling @command{gnatstub} on the named main source.
16481 If a source is not specified in the Switches attribute, @command{gnatpp} will
16482 be called with the options specified by Default_Switches of its language,
16483 if defined.
16484 @end table
16485
16486 @subsection package Eliminate
16487
16488 @noindent
16489 The attributes of package @code{Eliminate}
16490 specify the tool options to be used
16491 when invoking the tool @command{gnatelim}.
16492 The following attributes apply to package @code{Eliminate}:
16493
16494 @table @code
16495 @item     Default_switches
16496 This is an associative array attribute. Its
16497 domain is a set of language names. Its range is a string list that
16498 specifies options to be used when calling @command{gnatelim} on a source
16499 written in that language, for which no file-specific switches have been
16500 specified.
16501
16502 @item Switches
16503 This is an associative array attribute. Its domain is
16504 a set of file names. Its range is a string list that specifies
16505 options to be used when calling @command{gnatelim} on the named main source.
16506 If a source is not specified in the Switches attribute, @command{gnatelim} will
16507 be called with the options specified by Default_Switches of its language,
16508 if defined.
16509 @end table
16510
16511 @subsection package Metrics
16512
16513 @noindent
16514 The attributes of package @code{Metrics}
16515 specify the tool options to be used
16516 when invoking the tool @command{gnatmetric}.
16517 The following attributes apply to package @code{Metrics}:
16518
16519 @table @code
16520 @item     Default_switches
16521 This is an associative array attribute. Its
16522 domain is a set of language names. Its range is a string list that
16523 specifies options to be used when calling @command{gnatmetric} on a source
16524 written in that language, for which no file-specific switches have been
16525 specified.
16526
16527 @item Switches
16528 This is an associative array attribute. Its domain is
16529 a set of file names. Its range is a string list that specifies
16530 options to be used when calling @command{gnatmetric} on the named main source.
16531 If a source is not specified in the Switches attribute, @command{gnatmetric}
16532 will be called with the options specified by Default_Switches of its language,
16533 if defined.
16534 @end table
16535
16536 @subsection  package IDE
16537
16538 @noindent
16539 The attributes of package @code{IDE} specify the options to be used when using
16540 an Integrated Development Environment such as @command{GPS}.
16541
16542 @table @code
16543 @item Remote_Host
16544 This is a simple attribute. Its value is a string that designates the remote
16545 host in a cross-compilation environment, to be used for remote compilation and
16546 debugging. This field should not be specified when running on the local
16547 machine.
16548
16549 @item Program_Host
16550 This is a simple attribute. Its value is a string that specifies the
16551 name of IP address of the embedded target in a cross-compilation environment,
16552 on which the program should execute.
16553
16554 @item Communication_Protocol
16555 This is a simple string attribute. Its value is the name of the protocol
16556 to use to communicate with the target in a cross-compilation environment,
16557 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16558
16559 @item Compiler_Command
16560 This is an associative array attribute, whose domain is a language name. Its
16561 value is  string that denotes the command to be used to invoke the compiler.
16562 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16563 gnatmake, in particular in the handling of switches.
16564
16565 @item Debugger_Command
16566 This is simple attribute, Its value is a string that specifies the name of
16567 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16568
16569 @item Default_Switches
16570 This is an associative array attribute. Its indexes are the name of the
16571 external tools that the GNAT Programming System (GPS) is supporting. Its
16572 value is a list of switches to use when invoking that tool.
16573
16574 @item  Gnatlist
16575 This is a simple attribute.  Its value is a string that specifies the name
16576 of the @command{gnatls} utility to be used to retrieve information about the
16577 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16578
16579 @item VCS_Kind
16580 This is a simple attribute. Its value is a string used to specify the
16581 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16582 ClearCase or Perforce.
16583
16584 @item VCS_File_Check
16585 This is a simple attribute. Its value is a string that specifies the
16586 command used by the VCS to check the validity of a file, either
16587 when the user explicitly asks for a check, or as a sanity check before
16588 doing the check-in.
16589
16590 @item VCS_Log_Check
16591 This is a simple attribute. Its value is a string that specifies
16592 the command used by the VCS to check the validity of a log file.
16593
16594 @item VCS_Repository_Root
16595 The VCS repository root path. This is used to create tags or branches
16596 of the repository. For subversion the value should be the @code{URL}
16597 as specified to check-out the working copy of the repository.
16598
16599 @item VCS_Patch_Root
16600 The local root directory to use for building patch file. All patch chunks
16601 will be relative to this path. The root project directory is used if
16602 this value is not defined.
16603
16604 @end table
16605
16606 @node Package Renamings
16607 @section Package Renamings
16608
16609 @noindent
16610 A package can be defined by a renaming declaration. The new package renames
16611 a package declared in a different project file, and has the same attributes
16612 as the package it renames.
16613 Syntax:
16614 @smallexample
16615 package_renaming ::==
16616   @b{package} package_identifier @b{renames}
16617        <project_>simple_name.package_identifier ;
16618 @end smallexample
16619
16620 @noindent
16621 The package_identifier of the renamed package must be the same as the
16622 package_identifier. The project whose name is the prefix of the renamed
16623 package must contain a package declaration with this name. This project
16624 must appear in the context_clause of the enclosing project declaration,
16625 or be the parent project of the enclosing child project.
16626
16627 @node Projects
16628 @section Projects
16629
16630 @noindent
16631 A project file specifies a set of rules for constructing a software system.
16632 A project file can be self-contained, or depend on other project files.
16633 Dependencies are expressed through a context clause that names other projects.
16634
16635 Syntax:
16636
16637 @smallexample
16638 project ::=
16639   context_clause project_declaration
16640
16641 project_declaration ::=
16642   simple_project_declaration | project_extension
16643
16644 simple_project_declaration ::=
16645   @b{project} <project_>simple_name @b{is}
16646     @{declarative_item@}
16647   @b{end} <project_>simple_name;
16648
16649 context_clause ::=
16650   @{with_clause@}
16651
16652 with_clause ::=
16653   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16654
16655 path_name ::=
16656    string_literal
16657 @end smallexample
16658
16659 @noindent
16660 A path name denotes a project file. A path name can be absolute or relative.
16661 An absolute path name includes a sequence of directories, in the syntax of
16662 the host operating system, that identifies uniquely the project file in the
16663 file system. A relative path name identifies the project file, relative
16664 to the directory that contains the current project, or relative to a
16665 directory listed in the environment variable ADA_PROJECT_PATH.
16666 Path names are case sensitive if file names in the host operating system
16667 are case sensitive.
16668
16669 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16670 directory names separated by colons (semicolons on Windows).
16671
16672 A given project name can appear only once in a context_clause.
16673
16674 It is illegal for a project imported by a context clause to refer, directly
16675 or indirectly, to the project in which this context clause appears (the
16676 dependency graph cannot contain cycles), except when one of the with_clause
16677 in the cycle is a @code{limited with}.
16678
16679 @node Project Extensions
16680 @section Project Extensions
16681
16682 @noindent
16683 A project extension introduces a new project, which inherits the declarations
16684 of another project.
16685 Syntax:
16686 @smallexample
16687
16688 project_extension ::=
16689   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16690     @{declarative_item@}
16691   @b{end} <project_>simple_name;
16692 @end smallexample
16693
16694 @noindent
16695 The project extension declares a child project. The child project inherits
16696 all the declarations and all the files of the parent project, These inherited
16697 declaration can be overridden in the child project, by means of suitable
16698 declarations.
16699
16700 @node Project File Elaboration
16701 @section Project File Elaboration
16702
16703 @noindent
16704 A project file is processed as part of the invocation of a gnat tool that
16705 uses the project option. Elaboration of the process file consists in the
16706 sequential elaboration of all its declarations. The computed values of
16707 attributes and variables in the project are then used to establish the
16708 environment in which the gnat tool will execute.
16709
16710 @node Obsolescent Features
16711 @chapter Obsolescent Features
16712
16713 @noindent
16714 This chapter describes features that are provided by GNAT, but are
16715 considered obsolescent since there are preferred ways of achieving
16716 the same effect. These features are provided solely for historical
16717 compatibility purposes.
16718
16719 @menu
16720 * pragma No_Run_Time::
16721 * pragma Ravenscar::
16722 * pragma Restricted_Run_Time::
16723 @end menu
16724
16725 @node pragma No_Run_Time
16726 @section pragma No_Run_Time
16727
16728 The pragma @code{No_Run_Time} is used to achieve an affect similar
16729 to the use of the "Zero Foot Print" configurable run time, but without
16730 requiring a specially configured run time. The result of using this
16731 pragma, which must be used for all units in a partition, is to restrict
16732 the use of any language features requiring run-time support code. The
16733 preferred usage is to use an appropriately configured run-time that
16734 includes just those features that are to be made accessible.
16735
16736 @node pragma Ravenscar
16737 @section pragma Ravenscar
16738
16739 The pragma @code{Ravenscar} has exactly the same effect as pragma
16740 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16741 is part of the new Ada 2005 standard.
16742
16743 @node pragma Restricted_Run_Time
16744 @section pragma Restricted_Run_Time
16745
16746 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16747 pragma @code{Profile (Restricted)}. The latter usage is
16748 preferred since the Ada 2005 pragma @code{Profile} is intended for
16749 this kind of implementation dependent addition.
16750
16751 @include fdl.texi
16752 @c GNU Free Documentation License
16753
16754 @node Index,,GNU Free Documentation License, Top
16755 @unnumbered Index
16756
16757 @printindex cp
16758
16759 @contents
16760
16761 @bye