OSDN Git Service

libgomp/
[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 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_Local_Timing_Events
3922 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
3923 declared at the library level.
3924
3925 @item No_Protected_Type_Allocators
3926 There are no allocators for protected types or
3927 types containing protected subcomponents.
3928
3929 @item No_Relative_Delay
3930 There are no delay_relative statements.
3931
3932 @item No_Requeue_Statements
3933 Requeue statements are not allowed.
3934
3935 @item No_Select_Statements
3936 There are no select_statements.
3937
3938 @item No_Specific_Termination_Handlers
3939 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
3940 or to Ada.Task_Termination.Specific_Handler.
3941
3942 @item No_Task_Allocators
3943 [RM D.7] There are no allocators for task types
3944 or types containing task subcomponents.
3945
3946 @item No_Task_Attributes_Package
3947 There are no semantic dependencies on the Ada.Task_Attributes package.
3948
3949 @item No_Task_Hierarchy
3950 [RM D.7] All (non-environment) tasks depend
3951 directly on the environment task of the partition.
3952
3953 @item No_Task_Termination
3954 Tasks which terminate are erroneous.
3955
3956 @item No_Unchecked_Conversion
3957 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
3958
3959 @item No_Unchecked_Deallocation
3960 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
3961
3962 @item Simple_Barriers
3963 Entry barrier condition expressions shall be either static
3964 boolean expressions or boolean objects which are declared in
3965 the protected type which contains the entry.
3966 @end table
3967
3968 @noindent
3969 This set of configuration pragmas and restrictions correspond to the
3970 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3971 published by the @cite{International Real-Time Ada Workshop}, 1997,
3972 and whose most recent description is available at
3973 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3974
3975 The original definition of the profile was revised at subsequent IRTAW
3976 meetings. It has been included in the ISO
3977 @cite{Guide for the Use of the Ada Programming Language in High
3978 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3979 the next revision of the standard. The formal definition given by
3980 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3981 AI-305) available at
3982 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3983 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3984 respectively.
3985
3986 The above set is a superset of the restrictions provided by pragma
3987 @code{Profile (Restricted)}, it includes six additional restrictions
3988 (@code{Simple_Barriers}, @code{No_Select_Statements},
3989 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3990 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3991 that pragma @code{Profile (Ravenscar)}, like the pragma
3992 @code{Profile (Restricted)},
3993 automatically causes the use of a simplified,
3994 more efficient version of the tasking run-time system.
3995
3996 @node Pragma Profile (Restricted)
3997 @unnumberedsec Pragma Profile (Restricted)
3998 @findex Restricted Run Time
3999 @noindent
4000 Syntax:
4001
4002 @smallexample @c ada
4003 pragma Profile (Restricted);
4004 @end smallexample
4005
4006 @noindent
4007 A configuration pragma that establishes the following set of restrictions:
4008
4009 @itemize @bullet
4010 @item No_Abort_Statements
4011 @item No_Entry_Queue
4012 @item No_Task_Hierarchy
4013 @item No_Task_Allocators
4014 @item No_Dynamic_Priorities
4015 @item No_Terminate_Alternatives
4016 @item No_Dynamic_Attachment
4017 @item No_Protected_Type_Allocators
4018 @item No_Local_Protected_Objects
4019 @item No_Requeue_Statements
4020 @item No_Task_Attributes_Package
4021 @item Max_Asynchronous_Select_Nesting =  0
4022 @item Max_Task_Entries =  0
4023 @item Max_Protected_Entries = 1
4024 @item Max_Select_Alternatives = 0
4025 @end itemize
4026
4027 @noindent
4028 This set of restrictions causes the automatic selection of a simplified
4029 version of the run time that provides improved performance for the
4030 limited set of tasking functionality permitted by this set of restrictions.
4031
4032 @node Pragma Psect_Object
4033 @unnumberedsec Pragma Psect_Object
4034 @findex Psect_Object
4035 @noindent
4036 Syntax:
4037
4038 @smallexample @c ada
4039 pragma Psect_Object (
4040      [Internal =>] LOCAL_NAME,
4041   [, [External =>] EXTERNAL_SYMBOL]
4042   [, [Size     =>] EXTERNAL_SYMBOL]);
4043
4044 EXTERNAL_SYMBOL ::=
4045   IDENTIFIER
4046 | static_string_EXPRESSION
4047 @end smallexample
4048
4049 @noindent
4050 This pragma is identical in effect to pragma @code{Common_Object}.
4051
4052 @node Pragma Pure_Function
4053 @unnumberedsec Pragma Pure_Function
4054 @findex Pure_Function
4055 @noindent
4056 Syntax:
4057
4058 @smallexample @c ada
4059 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4060 @end smallexample
4061
4062 @noindent
4063 This pragma appears in the same declarative part as a function
4064 declaration (or a set of function declarations if more than one
4065 overloaded declaration exists, in which case the pragma applies
4066 to all entities).  It specifies that the function @code{Entity} is
4067 to be considered pure for the purposes of code generation.  This means
4068 that the compiler can assume that there are no side effects, and
4069 in particular that two calls with identical arguments produce the
4070 same result.  It also means that the function can be used in an
4071 address clause.
4072
4073 Note that, quite deliberately, there are no static checks to try
4074 to ensure that this promise is met, so @code{Pure_Function} can be used
4075 with functions that are conceptually pure, even if they do modify
4076 global variables.  For example, a square root function that is
4077 instrumented to count the number of times it is called is still
4078 conceptually pure, and can still be optimized, even though it
4079 modifies a global variable (the count).  Memo functions are another
4080 example (where a table of previous calls is kept and consulted to
4081 avoid re-computation).
4082
4083 @findex Pure
4084 Note: Most functions in a @code{Pure} package are automatically pure, and
4085 there is no need to use pragma @code{Pure_Function} for such functions.  One
4086 exception is any function that has at least one formal of type
4087 @code{System.Address} or a type derived from it.  Such functions are not
4088 considered pure by default, since the compiler assumes that the
4089 @code{Address} parameter may be functioning as a pointer and that the
4090 referenced data may change even if the address value does not.
4091 Similarly, imported functions are not considered to be pure by default,
4092 since there is no way of checking that they are in fact pure.  The use
4093 of pragma @code{Pure_Function} for such a function will override these default
4094 assumption, and cause the compiler to treat a designated subprogram as pure
4095 in these cases.
4096
4097 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4098 applies to the underlying renamed function.  This can be used to
4099 disambiguate cases of overloading where some but not all functions
4100 in a set of overloaded functions are to be designated as pure.
4101
4102 If pragma @code{Pure_Function} is applied to a library level function, the
4103 function is also considered pure from an optimization point of view, but the
4104 unit is not a Pure unit in the categorization sense. So for example, a function
4105 thus marked is free to @code{with} non-pure units.
4106
4107 @node Pragma Restriction_Warnings
4108 @unnumberedsec Pragma Restriction_Warnings
4109 @findex Restriction_Warnings
4110 @noindent
4111 Syntax:
4112
4113 @smallexample @c ada
4114 pragma Restriction_Warnings
4115   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4116 @end smallexample
4117
4118 @noindent
4119 This pragma allows a series of restriction identifiers to be
4120 specified (the list of allowed identifiers is the same as for
4121 pragma @code{Restrictions}). For each of these identifiers
4122 the compiler checks for violations of the restriction, but
4123 generates a warning message rather than an error message
4124 if the restriction is violated.
4125
4126 @node Pragma Shared
4127 @unnumberedsec Pragma Shared
4128 @findex Shared
4129
4130 @noindent
4131 This pragma is provided for compatibility with Ada 83. The syntax and
4132 semantics are identical to pragma Atomic.
4133
4134 @node Pragma Source_File_Name
4135 @unnumberedsec Pragma Source_File_Name
4136 @findex Source_File_Name
4137 @noindent
4138 Syntax:
4139
4140 @smallexample @c ada
4141 pragma Source_File_Name (
4142   [Unit_Name   =>] unit_NAME,
4143   Spec_File_Name =>  STRING_LITERAL);
4144
4145 pragma Source_File_Name (
4146   [Unit_Name   =>] unit_NAME,
4147   Body_File_Name =>  STRING_LITERAL);
4148 @end smallexample
4149
4150 @noindent
4151 Use this to override the normal naming convention.  It is a configuration
4152 pragma, and so has the usual applicability of configuration pragmas
4153 (i.e.@: it applies to either an entire partition, or to all units in a
4154 compilation, or to a single unit, depending on how it is used.
4155 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4156 the second argument is required, and indicates whether this is the file
4157 name for the spec or for the body.
4158
4159 Another form of the @code{Source_File_Name} pragma allows
4160 the specification of patterns defining alternative file naming schemes
4161 to apply to all files.
4162
4163 @smallexample @c ada
4164 pragma Source_File_Name
4165   (Spec_File_Name => STRING_LITERAL
4166    [,Casing => CASING_SPEC]
4167    [,Dot_Replacement => STRING_LITERAL]);
4168
4169 pragma Source_File_Name
4170   (Body_File_Name => STRING_LITERAL
4171    [,Casing => CASING_SPEC]
4172    [,Dot_Replacement => STRING_LITERAL]);
4173
4174 pragma Source_File_Name
4175   (Subunit_File_Name => STRING_LITERAL
4176    [,Casing => CASING_SPEC]
4177    [,Dot_Replacement => STRING_LITERAL]);
4178
4179 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4180 @end smallexample
4181
4182 @noindent
4183 The first argument is a pattern that contains a single asterisk indicating
4184 the point at which the unit name is to be inserted in the pattern string
4185 to form the file name.  The second argument is optional.  If present it
4186 specifies the casing of the unit name in the resulting file name string.
4187 The default is lower case.  Finally the third argument allows for systematic
4188 replacement of any dots in the unit name by the specified string literal.
4189
4190 A pragma Source_File_Name cannot appear after a
4191 @ref{Pragma Source_File_Name_Project}.
4192
4193 For more details on the use of the @code{Source_File_Name} pragma,
4194 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4195 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4196 User's Guide}.
4197
4198 @node Pragma Source_File_Name_Project
4199 @unnumberedsec Pragma Source_File_Name_Project
4200 @findex Source_File_Name_Project
4201 @noindent
4202
4203 This pragma has the same syntax and semantics as pragma Source_File_Name.
4204 It is only allowed as a stand alone configuration pragma.
4205 It cannot appear after a @ref{Pragma Source_File_Name}, and
4206 most importantly, once pragma Source_File_Name_Project appears,
4207 no further Source_File_Name pragmas are allowed.
4208
4209 The intention is that Source_File_Name_Project pragmas are always
4210 generated by the Project Manager in a manner consistent with the naming
4211 specified in a project file, and when naming is controlled in this manner,
4212 it is not permissible to attempt to modify this naming scheme using
4213 Source_File_Name pragmas (which would not be known to the project manager).
4214
4215 @node Pragma Source_Reference
4216 @unnumberedsec Pragma Source_Reference
4217 @findex Source_Reference
4218 @noindent
4219 Syntax:
4220
4221 @smallexample @c ada
4222 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4223 @end smallexample
4224
4225 @noindent
4226 This pragma must appear as the first line of a source file.
4227 @var{integer_literal} is the logical line number of the line following
4228 the pragma line (for use in error messages and debugging
4229 information).  @var{string_literal} is a static string constant that
4230 specifies the file name to be used in error messages and debugging
4231 information.  This is most notably used for the output of @code{gnatchop}
4232 with the @option{-r} switch, to make sure that the original unchopped
4233 source file is the one referred to.
4234
4235 The second argument must be a string literal, it cannot be a static
4236 string expression other than a string literal.  This is because its value
4237 is needed for error messages issued by all phases of the compiler.
4238
4239 @node Pragma Stream_Convert
4240 @unnumberedsec Pragma Stream_Convert
4241 @findex Stream_Convert
4242 @noindent
4243 Syntax:
4244
4245 @smallexample @c ada
4246 pragma Stream_Convert (
4247   [Entity =>] type_LOCAL_NAME,
4248   [Read   =>] function_NAME,
4249   [Write  =>] function_NAME);
4250 @end smallexample
4251
4252 @noindent
4253 This pragma provides an efficient way of providing stream functions for
4254 types defined in packages.  Not only is it simpler to use than declaring
4255 the necessary functions with attribute representation clauses, but more
4256 significantly, it allows the declaration to made in such a way that the
4257 stream packages are not loaded unless they are needed.  The use of
4258 the Stream_Convert pragma adds no overhead at all, unless the stream
4259 attributes are actually used on the designated type.
4260
4261 The first argument specifies the type for which stream functions are
4262 provided.  The second parameter provides a function used to read values
4263 of this type.  It must name a function whose argument type may be any
4264 subtype, and whose returned type must be the type given as the first
4265 argument to the pragma.
4266
4267 The meaning of the @var{Read}
4268 parameter is that if a stream attribute directly
4269 or indirectly specifies reading of the type given as the first parameter,
4270 then a value of the type given as the argument to the Read function is
4271 read from the stream, and then the Read function is used to convert this
4272 to the required target type.
4273
4274 Similarly the @var{Write} parameter specifies how to treat write attributes
4275 that directly or indirectly apply to the type given as the first parameter.
4276 It must have an input parameter of the type specified by the first parameter,
4277 and the return type must be the same as the input type of the Read function.
4278 The effect is to first call the Write function to convert to the given stream
4279 type, and then write the result type to the stream.
4280
4281 The Read and Write functions must not be overloaded subprograms.  If necessary
4282 renamings can be supplied to meet this requirement.
4283 The usage of this attribute is best illustrated by a simple example, taken
4284 from the GNAT implementation of package Ada.Strings.Unbounded:
4285
4286 @smallexample @c ada
4287 function To_Unbounded (S : String)
4288            return Unbounded_String
4289   renames To_Unbounded_String;
4290
4291 pragma Stream_Convert
4292   (Unbounded_String, To_Unbounded, To_String);
4293 @end smallexample
4294
4295 @noindent
4296 The specifications of the referenced functions, as given in the Ada
4297 Reference Manual are:
4298
4299 @smallexample @c ada
4300 function To_Unbounded_String (Source : String)
4301   return Unbounded_String;
4302
4303 function To_String (Source : Unbounded_String)
4304   return String;
4305 @end smallexample
4306
4307 @noindent
4308 The effect is that if the value of an unbounded string is written to a
4309 stream, then the representation of the item in the stream is in the same
4310 format used for @code{Standard.String}, and this same representation is
4311 expected when a value of this type is read from the stream.
4312
4313 @node Pragma Style_Checks
4314 @unnumberedsec Pragma Style_Checks
4315 @findex Style_Checks
4316 @noindent
4317 Syntax:
4318
4319 @smallexample @c ada
4320 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4321                      On | Off [, LOCAL_NAME]);
4322 @end smallexample
4323
4324 @noindent
4325 This pragma is used in conjunction with compiler switches to control the
4326 built in style checking provided by GNAT@.  The compiler switches, if set,
4327 provide an initial setting for the switches, and this pragma may be used
4328 to modify these settings, or the settings may be provided entirely by
4329 the use of the pragma.  This pragma can be used anywhere that a pragma
4330 is legal, including use as a configuration pragma (including use in
4331 the @file{gnat.adc} file).
4332
4333 The form with a string literal specifies which style options are to be
4334 activated.  These are additive, so they apply in addition to any previously
4335 set style check options.  The codes for the options are the same as those
4336 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4337 For example the following two methods can be used to enable
4338 layout checking:
4339
4340 @itemize @bullet
4341 @item
4342 @smallexample @c ada
4343 pragma Style_Checks ("l");
4344 @end smallexample
4345
4346 @item
4347 @smallexample
4348 gcc -c -gnatyl @dots{}
4349 @end smallexample
4350 @end itemize
4351
4352 @noindent
4353 The form ALL_CHECKS activates all standard checks (its use is equivalent
4354 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4355 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4356 @value{EDITION} User's Guide}, for details.
4357
4358 The forms with @code{Off} and @code{On}
4359 can be used to temporarily disable style checks
4360 as shown in the following example:
4361
4362 @smallexample @c ada
4363 @iftex
4364 @leftskip=0cm
4365 @end iftex
4366 pragma Style_Checks ("k"); -- requires keywords in lower case
4367 pragma Style_Checks (Off); -- turn off style checks
4368 NULL;                      -- this will not generate an error message
4369 pragma Style_Checks (On);  -- turn style checks back on
4370 NULL;                      -- this will generate an error message
4371 @end smallexample
4372
4373 @noindent
4374 Finally the two argument form is allowed only if the first argument is
4375 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4376 for the specified entity, as shown in the following example:
4377
4378 @smallexample @c ada
4379 @iftex
4380 @leftskip=0cm
4381 @end iftex
4382 pragma Style_Checks ("r"); -- require consistency of identifier casing
4383 Arg : Integer;
4384 Rf1 : Integer := ARG;      -- incorrect, wrong case
4385 pragma Style_Checks (Off, Arg);
4386 Rf2 : Integer := ARG;      -- OK, no error
4387 @end smallexample
4388
4389 @node Pragma Subtitle
4390 @unnumberedsec Pragma Subtitle
4391 @findex Subtitle
4392 @noindent
4393 Syntax:
4394
4395 @smallexample @c ada
4396 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4397 @end smallexample
4398
4399 @noindent
4400 This pragma is recognized for compatibility with other Ada compilers
4401 but is ignored by GNAT@.
4402
4403 @node Pragma Suppress
4404 @unnumberedsec Pragma Suppress
4405 @findex Suppress
4406 @noindent
4407 Syntax:
4408
4409 @smallexample @c ada
4410 pragma Suppress (Identifier [, [On =>] Name]);
4411 @end smallexample
4412
4413 @noindent
4414 This is a standard pragma, and supports all the check names required in
4415 the RM. It is included here because GNAT recognizes one additional check
4416 name: @code{Alignment_Check} which can be used to suppress alignment checks
4417 on addresses used in address clauses. Such checks can also be suppressed
4418 by suppressing range checks, but the specific use of @code{Alignment_Check}
4419 allows suppression of alignment checks without suppressing other range checks.
4420
4421 @node Pragma Suppress_All
4422 @unnumberedsec Pragma Suppress_All
4423 @findex Suppress_All
4424 @noindent
4425 Syntax:
4426
4427 @smallexample @c ada
4428 pragma Suppress_All;
4429 @end smallexample
4430
4431 @noindent
4432 This pragma can only appear immediately following a compilation
4433 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4434 which it follows.  This pragma is implemented for compatibility with DEC
4435 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4436 configuration pragma is the preferred usage in GNAT@.
4437
4438 @node Pragma Suppress_Exception_Locations
4439 @unnumberedsec Pragma Suppress_Exception_Locations
4440 @findex Suppress_Exception_Locations
4441 @noindent
4442 Syntax:
4443
4444 @smallexample @c ada
4445 pragma Suppress_Exception_Locations;
4446 @end smallexample
4447
4448 @noindent
4449 In normal mode, a raise statement for an exception by default generates
4450 an exception message giving the file name and line number for the location
4451 of the raise. This is useful for debugging and logging purposes, but this
4452 entails extra space for the strings for the messages. The configuration
4453 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4454 generation of these strings, with the result that space is saved, but the
4455 exception message for such raises is null. This configuration pragma may
4456 appear in a global configuration pragma file, or in a specific unit as
4457 usual. It is not required that this pragma be used consistently within
4458 a partition, so it is fine to have some units within a partition compiled
4459 with this pragma and others compiled in normal mode without it.
4460
4461 @node Pragma Suppress_Initialization
4462 @unnumberedsec Pragma Suppress_Initialization
4463 @findex Suppress_Initialization
4464 @cindex Suppressing initialization
4465 @cindex Initialization, suppression of
4466 @noindent
4467 Syntax:
4468
4469 @smallexample @c ada
4470 pragma Suppress_Initialization ([Entity =>] type_Name);
4471 @end smallexample
4472
4473 @noindent
4474 This pragma suppresses any implicit or explicit initialization
4475 associated with the given type name for all variables of this type.
4476
4477 @node Pragma Task_Info
4478 @unnumberedsec Pragma Task_Info
4479 @findex Task_Info
4480 @noindent
4481 Syntax
4482
4483 @smallexample @c ada
4484 pragma Task_Info (EXPRESSION);
4485 @end smallexample
4486
4487 @noindent
4488 This pragma appears within a task definition (like pragma
4489 @code{Priority}) and applies to the task in which it appears.  The
4490 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4491 The @code{Task_Info} pragma provides system dependent control over
4492 aspects of tasking implementation, for example, the ability to map
4493 tasks to specific processors.  For details on the facilities available
4494 for the version of GNAT that you are using, see the documentation
4495 in the spec of package System.Task_Info in the runtime
4496 library.
4497
4498 @node Pragma Task_Name
4499 @unnumberedsec Pragma Task_Name
4500 @findex Task_Name
4501 @noindent
4502 Syntax
4503
4504 @smallexample @c ada
4505 pragma Task_Name (string_EXPRESSION);
4506 @end smallexample
4507
4508 @noindent
4509 This pragma appears within a task definition (like pragma
4510 @code{Priority}) and applies to the task in which it appears.  The
4511 argument must be of type String, and provides a name to be used for
4512 the task instance when the task is created.  Note that this expression
4513 is not required to be static, and in particular, it can contain
4514 references to task discriminants.  This facility can be used to
4515 provide different names for different tasks as they are created,
4516 as illustrated in the example below.
4517
4518 The task name is recorded internally in the run-time structures
4519 and is accessible to tools like the debugger.  In addition the
4520 routine @code{Ada.Task_Identification.Image} will return this
4521 string, with a unique task address appended.
4522
4523 @smallexample @c ada
4524 --  Example of the use of pragma Task_Name
4525
4526 with Ada.Task_Identification;
4527 use Ada.Task_Identification;
4528 with Text_IO; use Text_IO;
4529 procedure t3 is
4530
4531    type Astring is access String;
4532
4533    task type Task_Typ (Name : access String) is
4534       pragma Task_Name (Name.all);
4535    end Task_Typ;
4536
4537    task body Task_Typ is
4538       Nam : constant String := Image (Current_Task);
4539    begin
4540       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4541    end Task_Typ;
4542
4543    type Ptr_Task is access Task_Typ;
4544    Task_Var : Ptr_Task;
4545
4546 begin
4547    Task_Var :=
4548      new Task_Typ (new String'("This is task 1"));
4549    Task_Var :=
4550      new Task_Typ (new String'("This is task 2"));
4551 end;
4552 @end smallexample
4553
4554 @node Pragma Task_Storage
4555 @unnumberedsec Pragma Task_Storage
4556 @findex Task_Storage
4557 Syntax:
4558
4559 @smallexample @c ada
4560 pragma Task_Storage (
4561   [Task_Type =>] LOCAL_NAME,
4562   [Top_Guard =>] static_integer_EXPRESSION);
4563 @end smallexample
4564
4565 @noindent
4566 This pragma specifies the length of the guard area for tasks.  The guard
4567 area is an additional storage area allocated to a task.  A value of zero
4568 means that either no guard area is created or a minimal guard area is
4569 created, depending on the target.  This pragma can appear anywhere a
4570 @code{Storage_Size} attribute definition clause is allowed for a task
4571 type.
4572
4573 @node Pragma Time_Slice
4574 @unnumberedsec Pragma Time_Slice
4575 @findex Time_Slice
4576 @noindent
4577 Syntax:
4578
4579 @smallexample @c ada
4580 pragma Time_Slice (static_duration_EXPRESSION);
4581 @end smallexample
4582
4583 @noindent
4584 For implementations of GNAT on operating systems where it is possible
4585 to supply a time slice value, this pragma may be used for this purpose.
4586 It is ignored if it is used in a system that does not allow this control,
4587 or if it appears in other than the main program unit.
4588 @cindex OpenVMS
4589 Note that the effect of this pragma is identical to the effect of the
4590 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4591
4592 @node Pragma Title
4593 @unnumberedsec Pragma Title
4594 @findex Title
4595 @noindent
4596 Syntax:
4597
4598 @smallexample @c ada
4599 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4600
4601 TITLING_OPTION ::=
4602   [Title    =>] STRING_LITERAL,
4603 | [Subtitle =>] STRING_LITERAL
4604 @end smallexample
4605
4606 @noindent
4607 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4608 pragma used in DEC Ada 83 implementations to provide a title and/or
4609 subtitle for the program listing.  The program listing generated by GNAT
4610 does not have titles or subtitles.
4611
4612 Unlike other pragmas, the full flexibility of named notation is allowed
4613 for this pragma, i.e.@: the parameters may be given in any order if named
4614 notation is used, and named and positional notation can be mixed
4615 following the normal rules for procedure calls in Ada.
4616
4617 @node Pragma Unchecked_Union
4618 @unnumberedsec Pragma Unchecked_Union
4619 @cindex Unions in C
4620 @findex Unchecked_Union
4621 @noindent
4622 Syntax:
4623
4624 @smallexample @c ada
4625 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4626 @end smallexample
4627
4628 @noindent
4629 This pragma is used to specify a representation of a record type that is
4630 equivalent to a C union. It was introduced as a GNAT implementation defined
4631 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4632 pragma, making it language defined, and GNAT fully implements this extended
4633 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4634 details, consult the Ada 2005 Reference Manual, section B.3.3.
4635
4636 @node Pragma Unimplemented_Unit
4637 @unnumberedsec Pragma Unimplemented_Unit
4638 @findex Unimplemented_Unit
4639 @noindent
4640 Syntax:
4641
4642 @smallexample @c ada
4643 pragma Unimplemented_Unit;
4644 @end smallexample
4645
4646 @noindent
4647 If this pragma occurs in a unit that is processed by the compiler, GNAT
4648 aborts with the message @samp{@var{xxx} not implemented}, where
4649 @var{xxx} is the name of the current compilation unit.  This pragma is
4650 intended to allow the compiler to handle unimplemented library units in
4651 a clean manner.
4652
4653 The abort only happens if code is being generated.  Thus you can use
4654 specs of unimplemented packages in syntax or semantic checking mode.
4655
4656 @node Pragma Universal_Aliasing
4657 @unnumberedsec Pragma Universal_Aliasing
4658 @findex Universal_Aliasing
4659 @noindent
4660 Syntax:
4661
4662 @smallexample @c ada
4663 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4664 @end smallexample
4665
4666 @noindent
4667 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4668 declarative part.  The effect is to inhibit strict type-based aliasing
4669 optimization for the given type.  In other words, the effect is as though
4670 access types designating this type were subject to pragma No_Strict_Aliasing.
4671 For a detailed description of the strict aliasing optimization, and the
4672 situations in which it must be suppressed, @xref{Optimization and Strict
4673 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4674
4675 @node Pragma Universal_Data
4676 @unnumberedsec Pragma Universal_Data
4677 @findex Universal_Data
4678 @noindent
4679 Syntax:
4680
4681 @smallexample @c ada
4682 pragma Universal_Data [(library_unit_Name)];
4683 @end smallexample
4684
4685 @noindent
4686 This pragma is supported only for the AAMP target and is ignored for
4687 other targets. The pragma specifies that all library-level objects
4688 (Counter 0 data) associated with the library unit are to be accessed
4689 and updated using universal addressing (24-bit addresses for AAMP5)
4690 rather than the default of 16-bit Data Environment (DENV) addressing.
4691 Use of this pragma will generally result in less efficient code for
4692 references to global data associated with the library unit, but
4693 allows such data to be located anywhere in memory. This pragma is
4694 a library unit pragma, but can also be used as a configuration pragma
4695 (including use in the @file{gnat.adc} file). The functionality
4696 of this pragma is also available by applying the -univ switch on the
4697 compilations of units where universal addressing of the data is desired.
4698
4699 @node Pragma Unmodified
4700 @unnumberedsec Pragma Unmodified
4701 @findex Unmodified
4702 @cindex Warnings, unmodified
4703 @noindent
4704 Syntax:
4705
4706 @smallexample @c ada
4707 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4708 @end smallexample
4709
4710 @noindent
4711 This pragma signals that the assignable entities (variables,
4712 @code{out} parameters, @code{in out} parameters) whose names are listed are
4713 deliberately not assigned in the current source unit. This
4714 suppresses warnings about the
4715 entities being referenced but not assigned, and in addition a warning will be
4716 generated if one of these entities is in fact assigned in the
4717 same unit as the pragma (or in the corresponding body, or one
4718 of its subunits).
4719
4720 This is particularly useful for clearly signaling that a particular
4721 parameter is not modified, even though the spec suggests that it might
4722 be.
4723
4724 @node Pragma Unreferenced
4725 @unnumberedsec Pragma Unreferenced
4726 @findex Unreferenced
4727 @cindex Warnings, unreferenced
4728 @noindent
4729 Syntax:
4730
4731 @smallexample @c ada
4732 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4733 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4734 @end smallexample
4735
4736 @noindent
4737 This pragma signals that the entities whose names are listed are
4738 deliberately not referenced in the current source unit. This
4739 suppresses warnings about the
4740 entities being unreferenced, and in addition a warning will be
4741 generated if one of these entities is in fact referenced in the
4742 same unit as the pragma (or in the corresponding body, or one
4743 of its subunits).
4744
4745 This is particularly useful for clearly signaling that a particular
4746 parameter is not referenced in some particular subprogram implementation
4747 and that this is deliberate. It can also be useful in the case of
4748 objects declared only for their initialization or finalization side
4749 effects.
4750
4751 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4752 current scope, then the entity most recently declared is the one to which
4753 the pragma applies. Note that in the case of accept formals, the pragma
4754 Unreferenced may appear immediately after the keyword @code{do} which
4755 allows the indication of whether or not accept formals are referenced
4756 or not to be given individually for each accept statement.
4757
4758 The left hand side of an assignment does not count as a reference for the
4759 purpose of this pragma. Thus it is fine to assign to an entity for which
4760 pragma Unreferenced is given.
4761
4762 Note that if a warning is desired for all calls to a given subprogram,
4763 regardless of whether they occur in the same unit as the subprogram
4764 declaration, then this pragma should not be used (calls from another
4765 unit would not be flagged); pragma Obsolescent can be used instead
4766 for this purpose, see @xref{Pragma Obsolescent}.
4767
4768 The second form of pragma @code{Unreferenced} is used within a context
4769 clause. In this case the arguments must be unit names of units previously
4770 mentioned in @code{with} clauses (similar to the usage of pragma
4771 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4772 units and unreferenced entities within these units.
4773
4774 @node Pragma Unreferenced_Objects
4775 @unnumberedsec Pragma Unreferenced_Objects
4776 @findex Unreferenced_Objects
4777 @cindex Warnings, unreferenced
4778 @noindent
4779 Syntax:
4780
4781 @smallexample @c ada
4782 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4783 @end smallexample
4784
4785 @noindent
4786 This pragma signals that for the types or subtypes whose names are
4787 listed, objects which are declared with one of these types or subtypes may
4788 not be referenced, and if no references appear, no warnings are given.
4789
4790 This is particularly useful for objects which are declared solely for their
4791 initialization and finalization effect. Such variables are sometimes referred
4792 to as RAII variables (Resource Acquisition Is Initialization). Using this
4793 pragma on the relevant type (most typically a limited controlled type), the
4794 compiler will automatically suppress unwanted warnings about these variables
4795 not being referenced.
4796
4797 @node Pragma Unreserve_All_Interrupts
4798 @unnumberedsec Pragma Unreserve_All_Interrupts
4799 @findex Unreserve_All_Interrupts
4800 @noindent
4801 Syntax:
4802
4803 @smallexample @c ada
4804 pragma Unreserve_All_Interrupts;
4805 @end smallexample
4806
4807 @noindent
4808 Normally certain interrupts are reserved to the implementation.  Any attempt
4809 to attach an interrupt causes Program_Error to be raised, as described in
4810 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4811 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4812 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4813 interrupt execution.
4814
4815 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4816 a program, then all such interrupts are unreserved.  This allows the
4817 program to handle these interrupts, but disables their standard
4818 functions.  For example, if this pragma is used, then pressing
4819 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4820 a program can then handle the @code{SIGINT} interrupt as it chooses.
4821
4822 For a full list of the interrupts handled in a specific implementation,
4823 see the source code for the spec of @code{Ada.Interrupts.Names} in
4824 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4825 list of interrupts recognized for a given target.  The documentation in
4826 this file also specifies what interrupts are affected by the use of
4827 the @code{Unreserve_All_Interrupts} pragma.
4828
4829 For a more general facility for controlling what interrupts can be
4830 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4831 of the @code{Unreserve_All_Interrupts} pragma.
4832
4833 @node Pragma Unsuppress
4834 @unnumberedsec Pragma Unsuppress
4835 @findex Unsuppress
4836 @noindent
4837 Syntax:
4838
4839 @smallexample @c ada
4840 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4841 @end smallexample
4842
4843 @noindent
4844 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4845 there is no corresponding pragma @code{Suppress} in effect, it has no
4846 effect.  The range of the effect is the same as for pragma
4847 @code{Suppress}.  The meaning of the arguments is identical to that used
4848 in pragma @code{Suppress}.
4849
4850 One important application is to ensure that checks are on in cases where
4851 code depends on the checks for its correct functioning, so that the code
4852 will compile correctly even if the compiler switches are set to suppress
4853 checks.
4854
4855 @node Pragma Use_VADS_Size
4856 @unnumberedsec Pragma Use_VADS_Size
4857 @cindex @code{Size}, VADS compatibility
4858 @findex Use_VADS_Size
4859 @noindent
4860 Syntax:
4861
4862 @smallexample @c ada
4863 pragma Use_VADS_Size;
4864 @end smallexample
4865
4866 @noindent
4867 This is a configuration pragma.  In a unit to which it applies, any use
4868 of the 'Size attribute is automatically interpreted as a use of the
4869 'VADS_Size attribute.  Note that this may result in incorrect semantic
4870 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
4871 the handling of existing code which depends on the interpretation of Size
4872 as implemented in the VADS compiler.  See description of the VADS_Size
4873 attribute for further details.
4874
4875 @node Pragma Validity_Checks
4876 @unnumberedsec Pragma Validity_Checks
4877 @findex Validity_Checks
4878 @noindent
4879 Syntax:
4880
4881 @smallexample @c ada
4882 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4883 @end smallexample
4884
4885 @noindent
4886 This pragma is used in conjunction with compiler switches to control the
4887 built-in validity checking provided by GNAT@.  The compiler switches, if set
4888 provide an initial setting for the switches, and this pragma may be used
4889 to modify these settings, or the settings may be provided entirely by
4890 the use of the pragma.  This pragma can be used anywhere that a pragma
4891 is legal, including use as a configuration pragma (including use in
4892 the @file{gnat.adc} file).
4893
4894 The form with a string literal specifies which validity options are to be
4895 activated.  The validity checks are first set to include only the default
4896 reference manual settings, and then a string of letters in the string
4897 specifies the exact set of options required.  The form of this string
4898 is exactly as described for the @option{-gnatVx} compiler switch (see the
4899 GNAT users guide for details).  For example the following two methods
4900 can be used to enable validity checking for mode @code{in} and
4901 @code{in out} subprogram parameters:
4902
4903 @itemize @bullet
4904 @item
4905 @smallexample @c ada
4906 pragma Validity_Checks ("im");
4907 @end smallexample
4908
4909 @item
4910 @smallexample
4911 gcc -c -gnatVim @dots{}
4912 @end smallexample
4913 @end itemize
4914
4915 @noindent
4916 The form ALL_CHECKS activates all standard checks (its use is equivalent
4917 to the use of the @code{gnatva} switch.
4918
4919 The forms with @code{Off} and @code{On}
4920 can be used to temporarily disable validity checks
4921 as shown in the following example:
4922
4923 @smallexample @c ada
4924 @iftex
4925 @leftskip=0cm
4926 @end iftex
4927 pragma Validity_Checks ("c"); -- validity checks for copies
4928 pragma Validity_Checks (Off); -- turn off validity checks
4929 A := B;                       -- B will not be validity checked
4930 pragma Validity_Checks (On);  -- turn validity checks back on
4931 A := C;                       -- C will be validity checked
4932 @end smallexample
4933
4934 @node Pragma Volatile
4935 @unnumberedsec Pragma Volatile
4936 @findex Volatile
4937 @noindent
4938 Syntax:
4939
4940 @smallexample @c ada
4941 pragma Volatile (LOCAL_NAME);
4942 @end smallexample
4943
4944 @noindent
4945 This pragma is defined by the Ada Reference Manual, and the GNAT
4946 implementation is fully conformant with this definition.  The reason it
4947 is mentioned in this section is that a pragma of the same name was supplied
4948 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
4949 implementation of pragma Volatile is upwards compatible with the
4950 implementation in DEC Ada 83.
4951
4952 @node Pragma Warnings
4953 @unnumberedsec Pragma Warnings
4954 @findex Warnings
4955 @noindent
4956 Syntax:
4957
4958 @smallexample @c ada
4959 pragma Warnings (On | Off);
4960 pragma Warnings (On | Off, LOCAL_NAME);
4961 pragma Warnings (static_string_EXPRESSION);
4962 pragma Warnings (On | Off, static_string_EXPRESSION);
4963 @end smallexample
4964
4965 @noindent
4966 Normally warnings are enabled, with the output being controlled by
4967 the command line switch.  Warnings (@code{Off}) turns off generation of
4968 warnings until a Warnings (@code{On}) is encountered or the end of the
4969 current unit.  If generation of warnings is turned off using this
4970 pragma, then no warning messages are output, regardless of the
4971 setting of the command line switches.
4972
4973 The form with a single argument may be used as a configuration pragma.
4974
4975 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4976 the specified entity.  This suppression is effective from the point where
4977 it occurs till the end of the extended scope of the variable (similar to
4978 the scope of @code{Suppress}).
4979
4980 The form with a single static_string_EXPRESSION argument provides more precise
4981 control over which warnings are active. The string is a list of letters
4982 specifying which warnings are to be activated and which deactivated. The
4983 code for these letters is the same as the string used in the command
4984 line switch controlling warnings. The following is a brief summary. For
4985 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
4986 User's Guide}.
4987
4988 @smallexample
4989 a    turn on all optional warnings (except d h l .o)
4990 A    turn off all optional warnings
4991 .a*  turn on warnings for failing assertions
4992 .A   turn off warnings for failing assertions
4993 b    turn on warnings for bad fixed value (not multiple of small)
4994 B*   turn off warnings for bad fixed value (not multiple of small)
4995 c    turn on warnings for constant conditional
4996 C*   turn off warnings for constant conditional
4997 .c   turn on warnings for unrepped components
4998 .C*  turn off warnings for unrepped components
4999 d    turn on warnings for implicit dereference
5000 D*   turn off warnings for implicit dereference
5001 e    treat all warnings as errors
5002 f    turn on warnings for unreferenced formal
5003 F*   turn off warnings for unreferenced formal
5004 g*   turn on warnings for unrecognized pragma
5005 G    turn off warnings for unrecognized pragma
5006 h    turn on warnings for hiding variable
5007 H*   turn off warnings for hiding variable
5008 i*   turn on warnings for implementation unit
5009 I    turn off warnings for implementation unit
5010 j    turn on warnings for obsolescent (annex J) feature
5011 J*   turn off warnings for obsolescent (annex J) feature
5012 k    turn on warnings on constant variable
5013 K*   turn off warnings on constant variable
5014 l    turn on warnings for missing elaboration pragma
5015 L*   turn off warnings for missing elaboration pragma
5016 m    turn on warnings for variable assigned but not read
5017 M*   turn off warnings for variable assigned but not read
5018 n*   normal warning mode (cancels -gnatws/-gnatwe)
5019 o*   turn on warnings for address clause overlay
5020 O    turn off warnings for address clause overlay
5021 .o   turn on warnings for out parameters assigned but not read
5022 .O*  turn off warnings for out parameters assigned but not read
5023 p    turn on warnings for ineffective pragma Inline in frontend
5024 P*   turn off warnings for ineffective pragma Inline in frontend
5025 q*   turn on warnings for questionable missing parentheses
5026 Q    turn off warnings for questionable missing parentheses
5027 r    turn on warnings for redundant construct
5028 R*   turn off warnings for redundant construct
5029 .r   turn on warnings for object renaming function
5030 .R*  turn off warnings for object renaming function
5031 s    suppress all warnings
5032 t    turn on warnings for tracking deleted code
5033 T*   turn off warnings for tracking deleted code
5034 u    turn on warnings for unused entity
5035 U*   turn off warnings for unused entity
5036 v*   turn on warnings for unassigned variable
5037 V    turn off warnings for unassigned variable
5038 w*   turn on warnings for wrong low bound assumption
5039 W    turn off warnings for wrong low bound assumption
5040 x*   turn on warnings for export/import
5041 X    turn off warnings for export/import
5042 .x   turn on warnings for non-local exceptions
5043 .X*  turn off warnings for non-local exceptions
5044 y*   turn on warnings for Ada 2005 incompatibility
5045 Y    turn off warnings for Ada 2005 incompatibility
5046 z*   turn on convention/size/align warnings for unchecked conversion
5047 Z    turn off convention/size/align warnings for unchecked conversion
5048 *    indicates default in above list
5049 @end smallexample
5050
5051 @noindent
5052 The specified warnings will be in effect until the end of the program
5053 or another pragma Warnings is encountered. The effect of the pragma is
5054 cumulative. Initially the set of warnings is the standard default set
5055 as possibly modified by compiler switches. Then each pragma Warning
5056 modifies this set of warnings as specified. This form of the pragma may
5057 also be used as a configuration pragma.
5058
5059 The fourth form, with an On|Off parameter and a string, is used to
5060 control individual messages, based on their text. The string argument
5061 is a pattern that is used to match against the text of individual
5062 warning messages (not including the initial "warnings: " tag).
5063
5064 The pattern may contain asterisks which match zero or more characters in
5065 the message. For example, you can use
5066 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5067 message @code{warning: 960 bits of "a" unused}. No other regular
5068 expression notations are permitted. All characters other than asterisk in
5069 these three specific cases are treated as literal characters in the match.
5070
5071 There are two ways to use this pragma. The OFF form can be used as a
5072 configuration pragma. The effect is to suppress all warnings (if any)
5073 that match the pattern string throughout the compilation.
5074
5075 The second usage is to suppress a warning locally, and in this case, two
5076 pragmas must appear in sequence:
5077
5078 @smallexample @c ada
5079 pragma Warnings (Off, Pattern);
5080 @dots{} code where given warning is to be suppressed
5081 pragma Warnings (On, Pattern);
5082 @end smallexample
5083
5084 @noindent
5085 In this usage, the pattern string must match in the Off and On pragmas,
5086 and at least one matching warning must be suppressed.
5087
5088 @node Pragma Weak_External
5089 @unnumberedsec Pragma Weak_External
5090 @findex Weak_External
5091 @noindent
5092 Syntax:
5093
5094 @smallexample @c ada
5095 pragma Weak_External ([Entity =>] LOCAL_NAME);
5096 @end smallexample
5097
5098 @noindent
5099 @var{LOCAL_NAME} must refer to an object that is declared at the library
5100 level. This pragma specifies that the given entity should be marked as a
5101 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5102 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5103 of a regular symbol, that is to say a symbol that does not have to be
5104 resolved by the linker if used in conjunction with a pragma Import.
5105
5106 When a weak symbol is not resolved by the linker, its address is set to
5107 zero. This is useful in writing interfaces to external modules that may
5108 or may not be linked in the final executable, for example depending on
5109 configuration settings.
5110
5111 If a program references at run time an entity to which this pragma has been
5112 applied, and the corresponding symbol was not resolved at link time, then
5113 the execution of the program is erroneous. It is not erroneous to take the
5114 Address of such an entity, for example to guard potential references,
5115 as shown in the example below.
5116
5117 Some file formats do not support weak symbols so not all target machines
5118 support this pragma.
5119
5120 @smallexample @c ada
5121 --  Example of the use of pragma Weak_External
5122
5123 package External_Module is
5124   key : Integer;
5125   pragma Import (C, key);
5126   pragma Weak_External (key);
5127   function Present return boolean;
5128 end External_Module;
5129
5130 with System; use System;
5131 package body External_Module is
5132   function Present return boolean is
5133   begin
5134     return key'Address /= System.Null_Address;
5135   end Present;
5136 end External_Module;
5137 @end smallexample
5138
5139 @node Pragma Wide_Character_Encoding
5140 @unnumberedsec Pragma Wide_Character_Encoding
5141 @findex Wide_Character_Encoding
5142 @noindent
5143 Syntax:
5144
5145 @smallexample @c ada
5146 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5147 @end smallexample
5148
5149 @noindent
5150 This pragma specifies the wide character encoding to be used in program
5151 source text appearing subsequently. It is a configuration pragma, but may
5152 also be used at any point that a pragma is allowed, and it is permissible
5153 to have more than one such pragma in a file, allowing multiple encodings
5154 to appear within the same file.
5155
5156 The argument can be an identifier or a character literal. In the identifier
5157 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5158 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5159 case it is correspondingly one of the characters @samp{h}, @samp{u},
5160 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5161
5162 Note that when the pragma is used within a file, it affects only the
5163 encoding within that file, and does not affect withed units, specs,
5164 or subunits.
5165
5166 @node Implementation Defined Attributes
5167 @chapter Implementation Defined Attributes
5168 Ada defines (throughout the Ada reference manual,
5169 summarized in Annex K),
5170 a set of attributes that provide useful additional functionality in all
5171 areas of the language.  These language defined attributes are implemented
5172 in GNAT and work as described in the Ada Reference Manual.
5173
5174 In addition, Ada allows implementations to define additional
5175 attributes whose meaning is defined by the implementation.  GNAT provides
5176 a number of these implementation-dependent attributes which can be used
5177 to extend and enhance the functionality of the compiler.  This section of
5178 the GNAT reference manual describes these additional attributes.
5179
5180 Note that any program using these attributes may not be portable to
5181 other compilers (although GNAT implements this set of attributes on all
5182 platforms).  Therefore if portability to other compilers is an important
5183 consideration, you should minimize the use of these attributes.
5184
5185 @menu
5186 * Abort_Signal::
5187 * Address_Size::
5188 * Asm_Input::
5189 * Asm_Output::
5190 * AST_Entry::
5191 * Bit::
5192 * Bit_Position::
5193 * Code_Address::
5194 * Default_Bit_Order::
5195 * Elaborated::
5196 * Elab_Body::
5197 * Elab_Spec::
5198 * Emax::
5199 * Enabled::
5200 * Enum_Rep::
5201 * Enum_Val::
5202 * Epsilon::
5203 * Fixed_Value::
5204 * Has_Access_Values::
5205 * Has_Discriminants::
5206 * Img::
5207 * Integer_Value::
5208 * Invalid_Value::
5209 * Large::
5210 * Machine_Size::
5211 * Mantissa::
5212 * Max_Interrupt_Priority::
5213 * Max_Priority::
5214 * Maximum_Alignment::
5215 * Mechanism_Code::
5216 * Null_Parameter::
5217 * Object_Size::
5218 * Old::
5219 * Passed_By_Reference::
5220 * Pool_Address::
5221 * Range_Length::
5222 * Safe_Emax::
5223 * Safe_Large::
5224 * Small::
5225 * Storage_Unit::
5226 * Stub_Type::
5227 * Target_Name::
5228 * Tick::
5229 * To_Address::
5230 * Type_Class::
5231 * UET_Address::
5232 * Unconstrained_Array::
5233 * Universal_Literal_String::
5234 * Unrestricted_Access::
5235 * VADS_Size::
5236 * Value_Size::
5237 * Wchar_T_Size::
5238 * Word_Size::
5239 @end menu
5240
5241 @node Abort_Signal
5242 @unnumberedsec Abort_Signal
5243 @findex Abort_Signal
5244 @noindent
5245 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5246 prefix) provides the entity for the special exception used to signal
5247 task abort or asynchronous transfer of control.  Normally this attribute
5248 should only be used in the tasking runtime (it is highly peculiar, and
5249 completely outside the normal semantics of Ada, for a user program to
5250 intercept the abort exception).
5251
5252 @node Address_Size
5253 @unnumberedsec Address_Size
5254 @cindex Size of @code{Address}
5255 @findex Address_Size
5256 @noindent
5257 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5258 prefix) is a static constant giving the number of bits in an
5259 @code{Address}. It is the same value as System.Address'Size,
5260 but has the advantage of being static, while a direct
5261 reference to System.Address'Size is non-static because Address
5262 is a private type.
5263
5264 @node Asm_Input
5265 @unnumberedsec Asm_Input
5266 @findex Asm_Input
5267 @noindent
5268 The @code{Asm_Input} attribute denotes a function that takes two
5269 parameters.  The first is a string, the second is an expression of the
5270 type designated by the prefix.  The first (string) argument is required
5271 to be a static expression, and is the constraint for the parameter,
5272 (e.g.@: what kind of register is required).  The second argument is the
5273 value to be used as the input argument.  The possible values for the
5274 constant are the same as those used in the RTL, and are dependent on
5275 the configuration file used to built the GCC back end.
5276 @ref{Machine Code Insertions}
5277
5278 @node Asm_Output
5279 @unnumberedsec Asm_Output
5280 @findex Asm_Output
5281 @noindent
5282 The @code{Asm_Output} attribute denotes a function that takes two
5283 parameters.  The first is a string, the second is the name of a variable
5284 of the type designated by the attribute prefix.  The first (string)
5285 argument is required to be a static expression and designates the
5286 constraint for the parameter (e.g.@: what kind of register is
5287 required).  The second argument is the variable to be updated with the
5288 result.  The possible values for constraint are the same as those used in
5289 the RTL, and are dependent on the configuration file used to build the
5290 GCC back end.  If there are no output operands, then this argument may
5291 either be omitted, or explicitly given as @code{No_Output_Operands}.
5292 @ref{Machine Code Insertions}
5293
5294 @node AST_Entry
5295 @unnumberedsec AST_Entry
5296 @cindex OpenVMS
5297 @findex AST_Entry
5298 @noindent
5299 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5300 the name of an entry, it yields a value of the predefined type AST_Handler
5301 (declared in the predefined package System, as extended by the use of
5302 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5303 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5304 Language Reference Manual}, section 9.12a.
5305
5306 @node Bit
5307 @unnumberedsec Bit
5308 @findex Bit
5309 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5310 offset within the storage unit (byte) that contains the first bit of
5311 storage allocated for the object.  The value of this attribute is of the
5312 type @code{Universal_Integer}, and is always a non-negative number not
5313 exceeding the value of @code{System.Storage_Unit}.
5314
5315 For an object that is a variable or a constant allocated in a register,
5316 the value is zero.  (The use of this attribute does not force the
5317 allocation of a variable to memory).
5318
5319 For an object that is a formal parameter, this attribute applies
5320 to either the matching actual parameter or to a copy of the
5321 matching actual parameter.
5322
5323 For an access object the value is zero.  Note that
5324 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5325 designated object.  Similarly for a record component
5326 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5327 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5328 are subject to index checks.
5329
5330 This attribute is designed to be compatible with the DEC Ada 83 definition
5331 and implementation of the @code{Bit} attribute.
5332
5333 @node Bit_Position
5334 @unnumberedsec Bit_Position
5335 @findex Bit_Position
5336 @noindent
5337 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5338 of the fields of the record type, yields the bit
5339 offset within the record contains the first bit of
5340 storage allocated for the object.  The value of this attribute is of the
5341 type @code{Universal_Integer}.  The value depends only on the field
5342 @var{C} and is independent of the alignment of
5343 the containing record @var{R}.
5344
5345 @node Code_Address
5346 @unnumberedsec Code_Address
5347 @findex Code_Address
5348 @cindex Subprogram address
5349 @cindex Address of subprogram code
5350 @noindent
5351 The @code{'Address}
5352 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5353 intended effect seems to be to provide
5354 an address value which can be used to call the subprogram by means of
5355 an address clause as in the following example:
5356
5357 @smallexample @c ada
5358 procedure K is @dots{}
5359
5360 procedure L;
5361 for L'Address use K'Address;
5362 pragma Import (Ada, L);
5363 @end smallexample
5364
5365 @noindent
5366 A call to @code{L} is then expected to result in a call to @code{K}@.
5367 In Ada 83, where there were no access-to-subprogram values, this was
5368 a common work-around for getting the effect of an indirect call.
5369 GNAT implements the above use of @code{Address} and the technique
5370 illustrated by the example code works correctly.
5371
5372 However, for some purposes, it is useful to have the address of the start
5373 of the generated code for the subprogram.  On some architectures, this is
5374 not necessarily the same as the @code{Address} value described above.
5375 For example, the @code{Address} value may reference a subprogram
5376 descriptor rather than the subprogram itself.
5377
5378 The @code{'Code_Address} attribute, which can only be applied to
5379 subprogram entities, always returns the address of the start of the
5380 generated code of the specified subprogram, which may or may not be
5381 the same value as is returned by the corresponding @code{'Address}
5382 attribute.
5383
5384 @node Default_Bit_Order
5385 @unnumberedsec Default_Bit_Order
5386 @cindex Big endian
5387 @cindex Little endian
5388 @findex Default_Bit_Order
5389 @noindent
5390 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5391 permissible prefix), provides the value @code{System.Default_Bit_Order}
5392 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5393 @code{Low_Order_First}).  This is used to construct the definition of
5394 @code{Default_Bit_Order} in package @code{System}.
5395
5396 @node Elaborated
5397 @unnumberedsec Elaborated
5398 @findex Elaborated
5399 @noindent
5400 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5401 value is a Boolean which indicates whether or not the given unit has been
5402 elaborated.  This attribute is primarily intended for internal use by the
5403 generated code for dynamic elaboration checking, but it can also be used
5404 in user programs.  The value will always be True once elaboration of all
5405 units has been completed.  An exception is for units which need no
5406 elaboration, the value is always False for such units.
5407
5408 @node Elab_Body
5409 @unnumberedsec Elab_Body
5410 @findex Elab_Body
5411 @noindent
5412 This attribute can only be applied to a program unit name.  It returns
5413 the entity for the corresponding elaboration procedure for elaborating
5414 the body of the referenced unit.  This is used in the main generated
5415 elaboration procedure by the binder and is not normally used in any
5416 other context.  However, there may be specialized situations in which it
5417 is useful to be able to call this elaboration procedure from Ada code,
5418 e.g.@: if it is necessary to do selective re-elaboration to fix some
5419 error.
5420
5421 @node Elab_Spec
5422 @unnumberedsec Elab_Spec
5423 @findex Elab_Spec
5424 @noindent
5425 This attribute can only be applied to a program unit name.  It returns
5426 the entity for the corresponding elaboration procedure for elaborating
5427 the spec of the referenced unit.  This is used in the main
5428 generated elaboration procedure by the binder and is not normally used
5429 in any other context.  However, there may be specialized situations in
5430 which it is useful to be able to call this elaboration procedure from
5431 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5432 some error.
5433
5434 @node Emax
5435 @unnumberedsec Emax
5436 @cindex Ada 83 attributes
5437 @findex Emax
5438 @noindent
5439 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5440 the Ada 83 reference manual for an exact description of the semantics of
5441 this attribute.
5442
5443 @node Enabled
5444 @unnumberedsec Enabled
5445 @findex Enabled
5446 @noindent
5447 The @code{Enabled} attribute allows an application program to check at compile
5448 time to see if the designated check is currently enabled. The prefix is a
5449 simple identifier, referencing any predefined check name (other than
5450 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5451 no argument is given for the attribute, the check is for the general state
5452 of the check, if an argument is given, then it is an entity name, and the
5453 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5454 given naming the entity (if not, then the argument is ignored).
5455
5456 Note that instantiations inherit the check status at the point of the
5457 instantiation, so a useful idiom is to have a library package that
5458 introduces a check name with @code{pragma Check_Name}, and then contains
5459 generic packages or subprograms which use the @code{Enabled} attribute
5460 to see if the check is enabled. A user of this package can then issue
5461 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5462 the package or subprogram, controlling whether the check will be present.
5463
5464 @node Enum_Rep
5465 @unnumberedsec Enum_Rep
5466 @cindex Representation of enums
5467 @findex Enum_Rep
5468 @noindent
5469 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5470 function with the following spec:
5471
5472 @smallexample @c ada
5473 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5474   return @i{Universal_Integer};
5475 @end smallexample
5476
5477 @noindent
5478 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5479 enumeration type or to a non-overloaded enumeration
5480 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5481 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5482 enumeration literal or object.
5483
5484 The function returns the representation value for the given enumeration
5485 value.  This will be equal to value of the @code{Pos} attribute in the
5486 absence of an enumeration representation clause.  This is a static
5487 attribute (i.e.@: the result is static if the argument is static).
5488
5489 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5490 in which case it simply returns the integer value.  The reason for this
5491 is to allow it to be used for @code{(<>)} discrete formal arguments in
5492 a generic unit that can be instantiated with either enumeration types
5493 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5494 type whose upper bound exceeds the upper bound of the largest signed
5495 integer type, and the argument is a variable, so that the universal
5496 integer calculation is done at run time, then the call to @code{Enum_Rep}
5497 may raise @code{Constraint_Error}.
5498
5499 @node Enum_Val
5500 @unnumberedsec Enum_Val
5501 @cindex Representation of enums
5502 @findex Enum_Val
5503 @noindent
5504 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5505 function with the following spec:
5506
5507 @smallexample @c ada
5508 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5509   return @var{S}'Base};
5510 @end smallexample
5511
5512 @noindent
5513 The function returns the enumeration value whose representation matches the
5514 argument, or raises Constraint_Error if no enumeration literal of the type
5515 has the matching value.
5516 This will be equal to value of the @code{Val} attribute in the
5517 absence of an enumeration representation clause.  This is a static
5518 attribute (i.e.@: the result is static if the argument is static).
5519
5520 @node Epsilon
5521 @unnumberedsec Epsilon
5522 @cindex Ada 83 attributes
5523 @findex Epsilon
5524 @noindent
5525 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5526 the Ada 83 reference manual for an exact description of the semantics of
5527 this attribute.
5528
5529 @node Fixed_Value
5530 @unnumberedsec Fixed_Value
5531 @findex Fixed_Value
5532 @noindent
5533 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5534 function with the following specification:
5535
5536 @smallexample @c ada
5537 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5538   return @var{S};
5539 @end smallexample
5540
5541 @noindent
5542 The value returned is the fixed-point value @var{V} such that
5543
5544 @smallexample @c ada
5545 @var{V} = Arg * @var{S}'Small
5546 @end smallexample
5547
5548 @noindent
5549 The effect is thus similar to first converting the argument to the
5550 integer type used to represent @var{S}, and then doing an unchecked
5551 conversion to the fixed-point type.  The difference is
5552 that there are full range checks, to ensure that the result is in range.
5553 This attribute is primarily intended for use in implementation of the
5554 input-output functions for fixed-point values.
5555
5556 @node Has_Access_Values
5557 @unnumberedsec Has_Access_Values
5558 @cindex Access values, testing for
5559 @findex Has_Access_Values
5560 @noindent
5561 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5562 is a Boolean value which is True if the is an access type, or is a composite
5563 type with a component (at any nesting depth) that is an access type, and is
5564 False otherwise.
5565 The intended use of this attribute is in conjunction with generic
5566 definitions.  If the attribute is applied to a generic private type, it
5567 indicates whether or not the corresponding actual type has access values.
5568
5569 @node Has_Discriminants
5570 @unnumberedsec Has_Discriminants
5571 @cindex Discriminants, testing for
5572 @findex Has_Discriminants
5573 @noindent
5574 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5575 is a Boolean value which is True if the type has discriminants, and False
5576 otherwise.  The intended use of this attribute is in conjunction with generic
5577 definitions.  If the attribute is applied to a generic private type, it
5578 indicates whether or not the corresponding actual type has discriminants.
5579
5580 @node Img
5581 @unnumberedsec Img
5582 @findex Img
5583 @noindent
5584 The @code{Img} attribute differs from @code{Image} in that it may be
5585 applied to objects as well as types, in which case it gives the
5586 @code{Image} for the subtype of the object.  This is convenient for
5587 debugging:
5588
5589 @smallexample @c ada
5590 Put_Line ("X = " & X'Img);
5591 @end smallexample
5592
5593 @noindent
5594 has the same meaning as the more verbose:
5595
5596 @smallexample @c ada
5597 Put_Line ("X = " & @var{T}'Image (X));
5598 @end smallexample
5599
5600 @noindent
5601 where @var{T} is the (sub)type of the object @code{X}.
5602
5603 @node Integer_Value
5604 @unnumberedsec Integer_Value
5605 @findex Integer_Value
5606 @noindent
5607 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5608 function with the following spec:
5609
5610 @smallexample @c ada
5611 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5612   return @var{S};
5613 @end smallexample
5614
5615 @noindent
5616 The value returned is the integer value @var{V}, such that
5617
5618 @smallexample @c ada
5619 Arg = @var{V} * @var{T}'Small
5620 @end smallexample
5621
5622 @noindent
5623 where @var{T} is the type of @code{Arg}.
5624 The effect is thus similar to first doing an unchecked conversion from
5625 the fixed-point type to its corresponding implementation type, and then
5626 converting the result to the target integer type.  The difference is
5627 that there are full range checks, to ensure that the result is in range.
5628 This attribute is primarily intended for use in implementation of the
5629 standard input-output functions for fixed-point values.
5630
5631 @node Invalid_Value
5632 @unnumberedsec Invalid_Value
5633 @findex Invalid_Value
5634 @noindent
5635 For every scalar type S, S'Invalid_Value returns an undefined value of the
5636 type. If possible this value is an invalid representation for the type. The
5637 value returned is identical to the value used to initialize an otherwise
5638 uninitialized value of the type if pragma Initialize_Scalars is used,
5639 including the ability to modify the value with the binder -Sxx flag and
5640 relevant environment variables at run time.
5641
5642 @node Large
5643 @unnumberedsec Large
5644 @cindex Ada 83 attributes
5645 @findex Large
5646 @noindent
5647 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5648 the Ada 83 reference manual for an exact description of the semantics of
5649 this attribute.
5650
5651 @node Machine_Size
5652 @unnumberedsec Machine_Size
5653 @findex Machine_Size
5654 @noindent
5655 This attribute is identical to the @code{Object_Size} attribute.  It is
5656 provided for compatibility with the DEC Ada 83 attribute of this name.
5657
5658 @node Mantissa
5659 @unnumberedsec Mantissa
5660 @cindex Ada 83 attributes
5661 @findex Mantissa
5662 @noindent
5663 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5664 the Ada 83 reference manual for an exact description of the semantics of
5665 this attribute.
5666
5667 @node Max_Interrupt_Priority
5668 @unnumberedsec Max_Interrupt_Priority
5669 @cindex Interrupt priority, maximum
5670 @findex Max_Interrupt_Priority
5671 @noindent
5672 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5673 permissible prefix), provides the same value as
5674 @code{System.Max_Interrupt_Priority}.
5675
5676 @node Max_Priority
5677 @unnumberedsec Max_Priority
5678 @cindex Priority, maximum
5679 @findex Max_Priority
5680 @noindent
5681 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5682 prefix) provides the same value as @code{System.Max_Priority}.
5683
5684 @node Maximum_Alignment
5685 @unnumberedsec Maximum_Alignment
5686 @cindex Alignment, maximum
5687 @findex Maximum_Alignment
5688 @noindent
5689 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5690 permissible prefix) provides the maximum useful alignment value for the
5691 target.  This is a static value that can be used to specify the alignment
5692 for an object, guaranteeing that it is properly aligned in all
5693 cases.
5694
5695 @node Mechanism_Code
5696 @unnumberedsec Mechanism_Code
5697 @cindex Return values, passing mechanism
5698 @cindex Parameters, passing mechanism
5699 @findex Mechanism_Code
5700 @noindent
5701 @code{@var{function}'Mechanism_Code} yields an integer code for the
5702 mechanism used for the result of function, and
5703 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5704 used for formal parameter number @var{n} (a static integer value with 1
5705 meaning the first parameter) of @var{subprogram}.  The code returned is:
5706
5707 @table @asis
5708 @item 1
5709 by copy (value)
5710 @item 2
5711 by reference
5712 @item 3
5713 by descriptor (default descriptor class)
5714 @item 4
5715 by descriptor (UBS: unaligned bit string)
5716 @item 5
5717 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5718 @item 6
5719 by descriptor (UBA: unaligned bit array)
5720 @item 7
5721 by descriptor (S: string, also scalar access type parameter)
5722 @item 8
5723 by descriptor (SB: string with arbitrary bounds)
5724 @item 9
5725 by descriptor (A: contiguous array)
5726 @item 10
5727 by descriptor (NCA: non-contiguous array)
5728 @end table
5729
5730 @noindent
5731 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5732 @cindex OpenVMS
5733
5734 @node Null_Parameter
5735 @unnumberedsec Null_Parameter
5736 @cindex Zero address, passing
5737 @findex Null_Parameter
5738 @noindent
5739 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5740 type or subtype @var{T} allocated at machine address zero.  The attribute
5741 is allowed only as the default expression of a formal parameter, or as
5742 an actual expression of a subprogram call.  In either case, the
5743 subprogram must be imported.
5744
5745 The identity of the object is represented by the address zero in the
5746 argument list, independent of the passing mechanism (explicit or
5747 default).
5748
5749 This capability is needed to specify that a zero address should be
5750 passed for a record or other composite object passed by reference.
5751 There is no way of indicating this without the @code{Null_Parameter}
5752 attribute.
5753
5754 @node Object_Size
5755 @unnumberedsec Object_Size
5756 @cindex Size, used for objects
5757 @findex Object_Size
5758 @noindent
5759 The size of an object is not necessarily the same as the size of the type
5760 of an object.  This is because by default object sizes are increased to be
5761 a multiple of the alignment of the object.  For example,
5762 @code{Natural'Size} is
5763 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5764 Similarly, a record containing an integer and a character:
5765
5766 @smallexample @c ada
5767 type Rec is record
5768    I : Integer;
5769    C : Character;
5770 end record;
5771 @end smallexample
5772
5773 @noindent
5774 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5775 alignment will be 4, because of the
5776 integer field, and so the default size of record objects for this type
5777 will be 64 (8 bytes).
5778
5779 @node Old
5780 @unnumberedsec Old
5781 @cindex Capturing Old values
5782 @cindex Postconditions
5783 @noindent
5784 The attribute Prefix'Old can be used within a
5785 subprogram to refer to the value of the prefix on entry. So for
5786 example if you have an argument of a record type X called Arg1,
5787 you can refer to Arg1.Field'Old which yields the value of
5788 Arg1.Field on entry. The implementation simply involves generating
5789 an object declaration which captures the value on entry. Any
5790 prefix is allowed except one of a limited type (since limited
5791 types cannot be copied to capture their values) or a local variable
5792 (since it does not exist at subprogram entry time).
5793
5794 The following example shows the use of 'Old to implement
5795 a test of a postcondition:
5796
5797 @smallexample @c ada
5798 with Old_Pkg;
5799 procedure Old is
5800 begin
5801    Old_Pkg.Incr;
5802 end Old;
5803
5804 package Old_Pkg is
5805    procedure Incr;
5806 end Old_Pkg;
5807
5808 package body Old_Pkg is
5809    Count : Natural := 0;
5810
5811    procedure Incr is
5812    begin
5813       ... code manipulating the value of Count
5814
5815       pragma Assert (Count = Count'Old + 1);
5816    end Incr;
5817 end Old_Pkg;
5818 @end smallexample
5819
5820 @noindent
5821 Note that it is allowed to apply 'Old to a constant entity, but this will
5822 result in a warning, since the old and new values will always be the same.
5823
5824 @node Passed_By_Reference
5825 @unnumberedsec Passed_By_Reference
5826 @cindex Parameters, when passed by reference
5827 @findex Passed_By_Reference
5828 @noindent
5829 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5830 a value of type @code{Boolean} value that is @code{True} if the type is
5831 normally passed by reference and @code{False} if the type is normally
5832 passed by copy in calls.  For scalar types, the result is always @code{False}
5833 and is static.  For non-scalar types, the result is non-static.
5834
5835 @node Pool_Address
5836 @unnumberedsec Pool_Address
5837 @cindex Parameters, when passed by reference
5838 @findex Pool_Address
5839 @noindent
5840 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5841 of X within its storage pool. This is the same as
5842 @code{@var{X}'Address}, except that for an unconstrained array whose
5843 bounds are allocated just before the first component,
5844 @code{@var{X}'Pool_Address} returns the address of those bounds,
5845 whereas @code{@var{X}'Address} returns the address of the first
5846 component.
5847
5848 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5849 the object is allocated'', which could be a user-defined storage pool,
5850 the global heap, on the stack, or in a static memory area. For an
5851 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5852 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5853
5854 @node Range_Length
5855 @unnumberedsec Range_Length
5856 @findex Range_Length
5857 @noindent
5858 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5859 the number of values represented by the subtype (zero for a null
5860 range).  The result is static for static subtypes.  @code{Range_Length}
5861 applied to the index subtype of a one dimensional array always gives the
5862 same result as @code{Range} applied to the array itself.
5863
5864 @node Safe_Emax
5865 @unnumberedsec Safe_Emax
5866 @cindex Ada 83 attributes
5867 @findex Safe_Emax
5868 @noindent
5869 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5870 the Ada 83 reference manual for an exact description of the semantics of
5871 this attribute.
5872
5873 @node Safe_Large
5874 @unnumberedsec Safe_Large
5875 @cindex Ada 83 attributes
5876 @findex Safe_Large
5877 @noindent
5878 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5879 the Ada 83 reference manual for an exact description of the semantics of
5880 this attribute.
5881
5882 @node Small
5883 @unnumberedsec Small
5884 @cindex Ada 83 attributes
5885 @findex Small
5886 @noindent
5887 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5888 fixed-point types.
5889 GNAT also allows this attribute to be applied to floating-point types
5890 for compatibility with Ada 83.  See
5891 the Ada 83 reference manual for an exact description of the semantics of
5892 this attribute when applied to floating-point types.
5893
5894 @node Storage_Unit
5895 @unnumberedsec Storage_Unit
5896 @findex Storage_Unit
5897 @noindent
5898 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5899 prefix) provides the same value as @code{System.Storage_Unit}.
5900
5901 @node Stub_Type
5902 @unnumberedsec Stub_Type
5903 @findex Stub_Type
5904 @noindent
5905 The GNAT implementation of remote access-to-classwide types is
5906 organized as described in AARM section E.4 (20.t): a value of an RACW type
5907 (designating a remote object) is represented as a normal access
5908 value, pointing to a "stub" object which in turn contains the
5909 necessary information to contact the designated remote object. A
5910 call on any dispatching operation of such a stub object does the
5911 remote call, if necessary, using the information in the stub object
5912 to locate the target partition, etc.
5913
5914 For a prefix @code{T} that denotes a remote access-to-classwide type,
5915 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5916
5917 By construction, the layout of @code{T'Stub_Type} is identical to that of
5918 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5919 unit @code{System.Partition_Interface}. Use of this attribute will create
5920 an implicit dependency on this unit.
5921
5922 @node Target_Name
5923 @unnumberedsec Target_Name
5924 @findex Target_Name
5925 @noindent
5926 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5927 prefix) provides a static string value that identifies the target
5928 for the current compilation. For GCC implementations, this is the
5929 standard gcc target name without the terminating slash (for
5930 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5931
5932 @node Tick
5933 @unnumberedsec Tick
5934 @findex Tick
5935 @noindent
5936 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5937 provides the same value as @code{System.Tick},
5938
5939 @node To_Address
5940 @unnumberedsec To_Address
5941 @findex To_Address
5942 @noindent
5943 The @code{System'To_Address}
5944 (@code{System} is the only permissible prefix)
5945 denotes a function identical to
5946 @code{System.Storage_Elements.To_Address} except that
5947 it is a static attribute.  This means that if its argument is
5948 a static expression, then the result of the attribute is a
5949 static expression.  The result is that such an expression can be
5950 used in contexts (e.g.@: preelaborable packages) which require a
5951 static expression and where the function call could not be used
5952 (since the function call is always non-static, even if its
5953 argument is static).
5954
5955 @node Type_Class
5956 @unnumberedsec Type_Class
5957 @findex Type_Class
5958 @noindent
5959 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5960 the value of the type class for the full type of @var{type}.  If
5961 @var{type} is a generic formal type, the value is the value for the
5962 corresponding actual subtype.  The value of this attribute is of type
5963 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5964
5965 @smallexample @c ada
5966   type Type_Class is
5967     (Type_Class_Enumeration,
5968      Type_Class_Integer,
5969      Type_Class_Fixed_Point,
5970      Type_Class_Floating_Point,
5971      Type_Class_Array,
5972      Type_Class_Record,
5973      Type_Class_Access,
5974      Type_Class_Task,
5975      Type_Class_Address);
5976 @end smallexample
5977
5978 @noindent
5979 Protected types yield the value @code{Type_Class_Task}, which thus
5980 applies to all concurrent types.  This attribute is designed to
5981 be compatible with the DEC Ada 83 attribute of the same name.
5982
5983 @node UET_Address
5984 @unnumberedsec UET_Address
5985 @findex UET_Address
5986 @noindent
5987 The @code{UET_Address} attribute can only be used for a prefix which
5988 denotes a library package.  It yields the address of the unit exception
5989 table when zero cost exception handling is used.  This attribute is
5990 intended only for use within the GNAT implementation.  See the unit
5991 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5992 for details on how this attribute is used in the implementation.
5993
5994 @node Unconstrained_Array
5995 @unnumberedsec Unconstrained_Array
5996 @findex Unconstrained_Array
5997 @noindent
5998 The @code{Unconstrained_Array} attribute can be used with a prefix that
5999 denotes any type or subtype. It is a static attribute that yields
6000 @code{True} if the prefix designates an unconstrained array,
6001 and @code{False} otherwise. In a generic instance, the result is
6002 still static, and yields the result of applying this test to the
6003 generic actual.
6004
6005 @node Universal_Literal_String
6006 @unnumberedsec Universal_Literal_String
6007 @cindex Named numbers, representation of
6008 @findex Universal_Literal_String
6009 @noindent
6010 The prefix of @code{Universal_Literal_String} must be a named
6011 number.  The static result is the string consisting of the characters of
6012 the number as defined in the original source.  This allows the user
6013 program to access the actual text of named numbers without intermediate
6014 conversions and without the need to enclose the strings in quotes (which
6015 would preclude their use as numbers).  This is used internally for the
6016 construction of values of the floating-point attributes from the file
6017 @file{ttypef.ads}, but may also be used by user programs.
6018
6019 For example, the following program prints the first 50 digits of pi:
6020
6021 @smallexample @c ada
6022 with Text_IO; use Text_IO;
6023 with Ada.Numerics;
6024 procedure Pi is
6025 begin
6026    Put (Ada.Numerics.Pi'Universal_Literal_String);
6027 end;
6028 @end smallexample
6029
6030 @node Unrestricted_Access
6031 @unnumberedsec Unrestricted_Access
6032 @cindex @code{Access}, unrestricted
6033 @findex Unrestricted_Access
6034 @noindent
6035 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6036 except that all accessibility and aliased view checks are omitted.  This
6037 is a user-beware attribute.  It is similar to
6038 @code{Address}, for which it is a desirable replacement where the value
6039 desired is an access type.  In other words, its effect is identical to
6040 first applying the @code{Address} attribute and then doing an unchecked
6041 conversion to a desired access type.  In GNAT, but not necessarily in
6042 other implementations, the use of static chains for inner level
6043 subprograms means that @code{Unrestricted_Access} applied to a
6044 subprogram yields a value that can be called as long as the subprogram
6045 is in scope (normal Ada accessibility rules restrict this usage).
6046
6047 It is possible to use @code{Unrestricted_Access} for any type, but care
6048 must be exercised if it is used to create pointers to unconstrained
6049 objects. In this case, the resulting pointer has the same scope as the
6050 context of the attribute, and may not be returned to some enclosing
6051 scope. For instance, a function cannot use @code{Unrestricted_Access}
6052 to create a unconstrained pointer and then return that value to the
6053 caller.
6054
6055 @node VADS_Size
6056 @unnumberedsec VADS_Size
6057 @cindex @code{Size}, VADS compatibility
6058 @findex VADS_Size
6059 @noindent
6060 The @code{'VADS_Size} attribute is intended to make it easier to port
6061 legacy code which relies on the semantics of @code{'Size} as implemented
6062 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6063 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6064 to a predefined or other primitive type with no Size clause yields the
6065 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6066 typical machines).  In addition @code{'VADS_Size} applied to an object
6067 gives the result that would be obtained by applying the attribute to
6068 the corresponding type.
6069
6070 @node Value_Size
6071 @unnumberedsec Value_Size
6072 @cindex @code{Size}, setting for not-first subtype
6073 @findex Value_Size
6074 @code{@var{type}'Value_Size} is the number of bits required to represent
6075 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6076 but, unlike @code{Size}, may be set for non-first subtypes.
6077
6078 @node Wchar_T_Size
6079 @unnumberedsec Wchar_T_Size
6080 @findex Wchar_T_Size
6081 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6082 prefix) provides the size in bits of the C @code{wchar_t} type
6083 primarily for constructing the definition of this type in
6084 package @code{Interfaces.C}.
6085
6086 @node Word_Size
6087 @unnumberedsec Word_Size
6088 @findex Word_Size
6089 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6090 prefix) provides the value @code{System.Word_Size}.
6091
6092 @c ------------------------
6093 @node Implementation Advice
6094 @chapter Implementation Advice
6095 @noindent
6096 The main text of the Ada Reference Manual describes the required
6097 behavior of all Ada compilers, and the GNAT compiler conforms to
6098 these requirements.
6099
6100 In addition, there are sections throughout the Ada Reference Manual headed
6101 by the phrase ``Implementation advice''.  These sections are not normative,
6102 i.e., they do not specify requirements that all compilers must
6103 follow.  Rather they provide advice on generally desirable behavior.  You
6104 may wonder why they are not requirements.  The most typical answer is
6105 that they describe behavior that seems generally desirable, but cannot
6106 be provided on all systems, or which may be undesirable on some systems.
6107
6108 As far as practical, GNAT follows the implementation advice sections in
6109 the Ada Reference Manual.  This chapter contains a table giving the
6110 reference manual section number, paragraph number and several keywords
6111 for each advice.  Each entry consists of the text of the advice followed
6112 by the GNAT interpretation of this advice.  Most often, this simply says
6113 ``followed'', which means that GNAT follows the advice.  However, in a
6114 number of cases, GNAT deliberately deviates from this advice, in which
6115 case the text describes what GNAT does and why.
6116
6117 @cindex Error detection
6118 @unnumberedsec 1.1.3(20): Error Detection
6119 @sp 1
6120 @cartouche
6121 If an implementation detects the use of an unsupported Specialized Needs
6122 Annex feature at run time, it should raise @code{Program_Error} if
6123 feasible.
6124 @end cartouche
6125 Not relevant.  All specialized needs annex features are either supported,
6126 or diagnosed at compile time.
6127
6128 @cindex Child Units
6129 @unnumberedsec 1.1.3(31): Child Units
6130 @sp 1
6131 @cartouche
6132 If an implementation wishes to provide implementation-defined
6133 extensions to the functionality of a language-defined library unit, it
6134 should normally do so by adding children to the library unit.
6135 @end cartouche
6136 Followed.
6137
6138 @cindex Bounded errors
6139 @unnumberedsec 1.1.5(12): Bounded Errors
6140 @sp 1
6141 @cartouche
6142 If an implementation detects a bounded error or erroneous
6143 execution, it should raise @code{Program_Error}.
6144 @end cartouche
6145 Followed in all cases in which the implementation detects a bounded
6146 error or erroneous execution.  Not all such situations are detected at
6147 runtime.
6148
6149 @cindex Pragmas
6150 @unnumberedsec 2.8(16): Pragmas
6151 @sp 1
6152 @cartouche
6153 Normally, implementation-defined pragmas should have no semantic effect
6154 for error-free programs; that is, if the implementation-defined pragmas
6155 are removed from a working program, the program should still be legal,
6156 and should still have the same semantics.
6157 @end cartouche
6158 The following implementation defined pragmas are exceptions to this
6159 rule:
6160
6161 @table @code
6162 @item Abort_Defer
6163 Affects semantics
6164 @item Ada_83
6165 Affects legality
6166 @item Assert
6167 Affects semantics
6168 @item CPP_Class
6169 Affects semantics
6170 @item CPP_Constructor
6171 Affects semantics
6172 @item Debug
6173 Affects semantics
6174 @item Interface_Name
6175 Affects semantics
6176 @item Machine_Attribute
6177 Affects semantics
6178 @item Unimplemented_Unit
6179 Affects legality
6180 @item Unchecked_Union
6181 Affects semantics
6182 @end table
6183
6184 @noindent
6185 In each of the above cases, it is essential to the purpose of the pragma
6186 that this advice not be followed.  For details see the separate section
6187 on implementation defined pragmas.
6188
6189 @unnumberedsec 2.8(17-19): Pragmas
6190 @sp 1
6191 @cartouche
6192 Normally, an implementation should not define pragmas that can
6193 make an illegal program legal, except as follows:
6194 @end cartouche
6195 @sp 1
6196 @cartouche
6197 A pragma used to complete a declaration, such as a pragma @code{Import};
6198 @end cartouche
6199 @sp 1
6200 @cartouche
6201 A pragma used to configure the environment by adding, removing, or
6202 replacing @code{library_items}.
6203 @end cartouche
6204 See response to paragraph 16 of this same section.
6205
6206 @cindex Character Sets
6207 @cindex Alternative Character Sets
6208 @unnumberedsec 3.5.2(5): Alternative Character Sets
6209 @sp 1
6210 @cartouche
6211 If an implementation supports a mode with alternative interpretations
6212 for @code{Character} and @code{Wide_Character}, the set of graphic
6213 characters of @code{Character} should nevertheless remain a proper
6214 subset of the set of graphic characters of @code{Wide_Character}.  Any
6215 character set ``localizations'' should be reflected in the results of
6216 the subprograms defined in the language-defined package
6217 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6218 an alternative interpretation of @code{Character}, the implementation should
6219 also support a corresponding change in what is a legal
6220 @code{identifier_letter}.
6221 @end cartouche
6222 Not all wide character modes follow this advice, in particular the JIS
6223 and IEC modes reflect standard usage in Japan, and in these encoding,
6224 the upper half of the Latin-1 set is not part of the wide-character
6225 subset, since the most significant bit is used for wide character
6226 encoding.  However, this only applies to the external forms.  Internally
6227 there is no such restriction.
6228
6229 @cindex Integer types
6230 @unnumberedsec 3.5.4(28): Integer Types
6231
6232 @sp 1
6233 @cartouche
6234 An implementation should support @code{Long_Integer} in addition to
6235 @code{Integer} if the target machine supports 32-bit (or longer)
6236 arithmetic.  No other named integer subtypes are recommended for package
6237 @code{Standard}.  Instead, appropriate named integer subtypes should be
6238 provided in the library package @code{Interfaces} (see B.2).
6239 @end cartouche
6240 @code{Long_Integer} is supported.  Other standard integer types are supported
6241 so this advice is not fully followed.  These types
6242 are supported for convenient interface to C, and so that all hardware
6243 types of the machine are easily available.
6244 @unnumberedsec 3.5.4(29): Integer Types
6245
6246 @sp 1
6247 @cartouche
6248 An implementation for a two's complement machine should support
6249 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6250 implementation should support a non-binary modules up to @code{Integer'Last}.
6251 @end cartouche
6252 Followed.
6253
6254 @cindex Enumeration values
6255 @unnumberedsec 3.5.5(8): Enumeration Values
6256 @sp 1
6257 @cartouche
6258 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6259 subtype, if the value of the operand does not correspond to the internal
6260 code for any enumeration literal of its type (perhaps due to an
6261 un-initialized variable), then the implementation should raise
6262 @code{Program_Error}.  This is particularly important for enumeration
6263 types with noncontiguous internal codes specified by an
6264 enumeration_representation_clause.
6265 @end cartouche
6266 Followed.
6267
6268 @cindex Float types
6269 @unnumberedsec 3.5.7(17): Float Types
6270 @sp 1
6271 @cartouche
6272 An implementation should support @code{Long_Float} in addition to
6273 @code{Float} if the target machine supports 11 or more digits of
6274 precision.  No other named floating point subtypes are recommended for
6275 package @code{Standard}.  Instead, appropriate named floating point subtypes
6276 should be provided in the library package @code{Interfaces} (see B.2).
6277 @end cartouche
6278 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6279 former provides improved compatibility with other implementations
6280 supporting this type.  The latter corresponds to the highest precision
6281 floating-point type supported by the hardware.  On most machines, this
6282 will be the same as @code{Long_Float}, but on some machines, it will
6283 correspond to the IEEE extended form.  The notable case is all ia32
6284 (x86) implementations, where @code{Long_Long_Float} corresponds to
6285 the 80-bit extended precision format supported in hardware on this
6286 processor.  Note that the 128-bit format on SPARC is not supported,
6287 since this is a software rather than a hardware format.
6288
6289 @cindex Multidimensional arrays
6290 @cindex Arrays, multidimensional
6291 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6292 @sp 1
6293 @cartouche
6294 An implementation should normally represent multidimensional arrays in
6295 row-major order, consistent with the notation used for multidimensional
6296 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6297 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6298 column-major order should be used instead (see B.5, ``Interfacing with
6299 Fortran'').
6300 @end cartouche
6301 Followed.
6302
6303 @findex Duration'Small
6304 @unnumberedsec 9.6(30-31): Duration'Small
6305 @sp 1
6306 @cartouche
6307 Whenever possible in an implementation, the value of @code{Duration'Small}
6308 should be no greater than 100 microseconds.
6309 @end cartouche
6310 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6311
6312 @sp 1
6313 @cartouche
6314 The time base for @code{delay_relative_statements} should be monotonic;
6315 it need not be the same time base as used for @code{Calendar.Clock}.
6316 @end cartouche
6317 Followed.
6318
6319 @unnumberedsec 10.2.1(12): Consistent Representation
6320 @sp 1
6321 @cartouche
6322 In an implementation, a type declared in a pre-elaborated package should
6323 have the same representation in every elaboration of a given version of
6324 the package, whether the elaborations occur in distinct executions of
6325 the same program, or in executions of distinct programs or partitions
6326 that include the given version.
6327 @end cartouche
6328 Followed, except in the case of tagged types.  Tagged types involve
6329 implicit pointers to a local copy of a dispatch table, and these pointers
6330 have representations which thus depend on a particular elaboration of the
6331 package.  It is not easy to see how it would be possible to follow this
6332 advice without severely impacting efficiency of execution.
6333
6334 @cindex Exception information
6335 @unnumberedsec 11.4.1(19): Exception Information
6336 @sp 1
6337 @cartouche
6338 @code{Exception_Message} by default and @code{Exception_Information}
6339 should produce information useful for
6340 debugging.  @code{Exception_Message} should be short, about one
6341 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6342 should not include the
6343 @code{Exception_Name}.  @code{Exception_Information} should include both
6344 the @code{Exception_Name} and the @code{Exception_Message}.
6345 @end cartouche
6346 Followed.  For each exception that doesn't have a specified
6347 @code{Exception_Message}, the compiler generates one containing the location
6348 of the raise statement.  This location has the form ``file:line'', where
6349 file is the short file name (without path information) and line is the line
6350 number in the file.  Note that in the case of the Zero Cost Exception
6351 mechanism, these messages become redundant with the Exception_Information that
6352 contains a full backtrace of the calling sequence, so they are disabled.
6353 To disable explicitly the generation of the source location message, use the
6354 Pragma @code{Discard_Names}.
6355
6356 @cindex Suppression of checks
6357 @cindex Checks, suppression of
6358 @unnumberedsec 11.5(28): Suppression of Checks
6359 @sp 1
6360 @cartouche
6361 The implementation should minimize the code executed for checks that
6362 have been suppressed.
6363 @end cartouche
6364 Followed.
6365
6366 @cindex Representation clauses
6367 @unnumberedsec 13.1 (21-24): Representation Clauses
6368 @sp 1
6369 @cartouche
6370 The recommended level of support for all representation items is
6371 qualified as follows:
6372 @end cartouche
6373 @sp 1
6374 @cartouche
6375 An implementation need not support representation items containing
6376 non-static expressions, except that an implementation should support a
6377 representation item for a given entity if each non-static expression in
6378 the representation item is a name that statically denotes a constant
6379 declared before the entity.
6380 @end cartouche
6381 Followed.  In fact, GNAT goes beyond the recommended level of support
6382 by allowing nonstatic expressions in some representation clauses even
6383 without the need to declare constants initialized with the values of
6384 such expressions.
6385 For example:
6386
6387 @smallexample @c ada
6388   X : Integer;
6389   Y : Float;
6390   for Y'Address use X'Address;>>
6391 @end smallexample
6392
6393
6394 @sp 1
6395 @cartouche
6396 An implementation need not support a specification for the @code{Size}
6397 for a given composite subtype, nor the size or storage place for an
6398 object (including a component) of a given composite subtype, unless the
6399 constraints on the subtype and its composite subcomponents (if any) are
6400 all static constraints.
6401 @end cartouche
6402 Followed.  Size Clauses are not permitted on non-static components, as
6403 described above.
6404
6405 @sp 1
6406 @cartouche
6407 An aliased component, or a component whose type is by-reference, should
6408 always be allocated at an addressable location.
6409 @end cartouche
6410 Followed.
6411
6412 @cindex Packed types
6413 @unnumberedsec 13.2(6-8): Packed Types
6414 @sp 1
6415 @cartouche
6416 If a type is packed, then the implementation should try to minimize
6417 storage allocated to objects of the type, possibly at the expense of
6418 speed of accessing components, subject to reasonable complexity in
6419 addressing calculations.
6420 @end cartouche
6421 @sp 1
6422 @cartouche
6423 The recommended level of support pragma @code{Pack} is:
6424
6425 For a packed record type, the components should be packed as tightly as
6426 possible subject to the Sizes of the component subtypes, and subject to
6427 any @code{record_representation_clause} that applies to the type; the
6428 implementation may, but need not, reorder components or cross aligned
6429 word boundaries to improve the packing.  A component whose @code{Size} is
6430 greater than the word size may be allocated an integral number of words.
6431 @end cartouche
6432 Followed.  Tight packing of arrays is supported for all component sizes
6433 up to 64-bits. If the array component size is 1 (that is to say, if
6434 the component is a boolean type or an enumeration type with two values)
6435 then values of the type are implicitly initialized to zero. This
6436 happens both for objects of the packed type, and for objects that have a
6437 subcomponent of the packed type.
6438
6439 @sp 1
6440 @cartouche
6441 An implementation should support Address clauses for imported
6442 subprograms.
6443 @end cartouche
6444 Followed.
6445 @cindex @code{Address} clauses
6446 @unnumberedsec 13.3(14-19): Address Clauses
6447
6448 @sp 1
6449 @cartouche
6450 For an array @var{X}, @code{@var{X}'Address} should point at the first
6451 component of the array, and not at the array bounds.
6452 @end cartouche
6453 Followed.
6454
6455 @sp 1
6456 @cartouche
6457 The recommended level of support for the @code{Address} attribute is:
6458
6459 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6460 object that is aliased or of a by-reference type, or is an entity whose
6461 @code{Address} has been specified.
6462 @end cartouche
6463 Followed.  A valid address will be produced even if none of those
6464 conditions have been met.  If necessary, the object is forced into
6465 memory to ensure the address is valid.
6466
6467 @sp 1
6468 @cartouche
6469 An implementation should support @code{Address} clauses for imported
6470 subprograms.
6471 @end cartouche
6472 Followed.
6473
6474 @sp 1
6475 @cartouche
6476 Objects (including subcomponents) that are aliased or of a by-reference
6477 type should be allocated on storage element boundaries.
6478 @end cartouche
6479 Followed.
6480
6481 @sp 1
6482 @cartouche
6483 If the @code{Address} of an object is specified, or it is imported or exported,
6484 then the implementation should not perform optimizations based on
6485 assumptions of no aliases.
6486 @end cartouche
6487 Followed.
6488
6489 @cindex @code{Alignment} clauses
6490 @unnumberedsec 13.3(29-35): Alignment Clauses
6491 @sp 1
6492 @cartouche
6493 The recommended level of support for the @code{Alignment} attribute for
6494 subtypes is:
6495
6496 An implementation should support specified Alignments that are factors
6497 and multiples of the number of storage elements per word, subject to the
6498 following:
6499 @end cartouche
6500 Followed.
6501
6502 @sp 1
6503 @cartouche
6504 An implementation need not support specified @code{Alignment}s for
6505 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6506 loaded and stored by available machine instructions.
6507 @end cartouche
6508 Followed.
6509
6510 @sp 1
6511 @cartouche
6512 An implementation need not support specified @code{Alignment}s that are
6513 greater than the maximum @code{Alignment} the implementation ever returns by
6514 default.
6515 @end cartouche
6516 Followed.
6517
6518 @sp 1
6519 @cartouche
6520 The recommended level of support for the @code{Alignment} attribute for
6521 objects is:
6522
6523 Same as above, for subtypes, but in addition:
6524 @end cartouche
6525 Followed.
6526
6527 @sp 1
6528 @cartouche
6529 For stand-alone library-level objects of statically constrained
6530 subtypes, the implementation should support all @code{Alignment}s
6531 supported by the target linker.  For example, page alignment is likely to
6532 be supported for such objects, but not for subtypes.
6533 @end cartouche
6534 Followed.
6535
6536 @cindex @code{Size} clauses
6537 @unnumberedsec 13.3(42-43): Size Clauses
6538 @sp 1
6539 @cartouche
6540 The recommended level of support for the @code{Size} attribute of
6541 objects is:
6542
6543 A @code{Size} clause should be supported for an object if the specified
6544 @code{Size} is at least as large as its subtype's @code{Size}, and
6545 corresponds to a size in storage elements that is a multiple of the
6546 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6547 @end cartouche
6548 Followed.
6549
6550 @unnumberedsec 13.3(50-56): Size Clauses
6551 @sp 1
6552 @cartouche
6553 If the @code{Size} of a subtype is specified, and allows for efficient
6554 independent addressability (see 9.10) on the target architecture, then
6555 the @code{Size} of the following objects of the subtype should equal the
6556 @code{Size} of the subtype:
6557
6558 Aliased objects (including components).
6559 @end cartouche
6560 Followed.
6561
6562 @sp 1
6563 @cartouche
6564 @code{Size} clause on a composite subtype should not affect the
6565 internal layout of components.
6566 @end cartouche
6567 Followed. But note that this can be overridden by use of the implementation
6568 pragma Implicit_Packing in the case of packed arrays.
6569
6570 @sp 1
6571 @cartouche
6572 The recommended level of support for the @code{Size} attribute of subtypes is:
6573 @end cartouche
6574 @sp 1
6575 @cartouche
6576 The @code{Size} (if not specified) of a static discrete or fixed point
6577 subtype should be the number of bits needed to represent each value
6578 belonging to the subtype using an unbiased representation, leaving space
6579 for a sign bit only if the subtype contains negative values.  If such a
6580 subtype is a first subtype, then an implementation should support a
6581 specified @code{Size} for it that reflects this representation.
6582 @end cartouche
6583 Followed.
6584
6585 @sp 1
6586 @cartouche
6587 For a subtype implemented with levels of indirection, the @code{Size}
6588 should include the size of the pointers, but not the size of what they
6589 point at.
6590 @end cartouche
6591 Followed.
6592
6593 @cindex @code{Component_Size} clauses
6594 @unnumberedsec 13.3(71-73): Component Size Clauses
6595 @sp 1
6596 @cartouche
6597 The recommended level of support for the @code{Component_Size}
6598 attribute is:
6599 @end cartouche
6600 @sp 1
6601 @cartouche
6602 An implementation need not support specified @code{Component_Sizes} that are
6603 less than the @code{Size} of the component subtype.
6604 @end cartouche
6605 Followed.
6606
6607 @sp 1
6608 @cartouche
6609 An implementation should support specified @code{Component_Size}s that
6610 are factors and multiples of the word size.  For such
6611 @code{Component_Size}s, the array should contain no gaps between
6612 components.  For other @code{Component_Size}s (if supported), the array
6613 should contain no gaps between components when packing is also
6614 specified; the implementation should forbid this combination in cases
6615 where it cannot support a no-gaps representation.
6616 @end cartouche
6617 Followed.
6618
6619 @cindex Enumeration representation clauses
6620 @cindex Representation clauses, enumeration
6621 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6622 @sp 1
6623 @cartouche
6624 The recommended level of support for enumeration representation clauses
6625 is:
6626
6627 An implementation need not support enumeration representation clauses
6628 for boolean types, but should at minimum support the internal codes in
6629 the range @code{System.Min_Int.System.Max_Int}.
6630 @end cartouche
6631 Followed.
6632
6633 @cindex Record representation clauses
6634 @cindex Representation clauses, records
6635 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6636 @sp 1
6637 @cartouche
6638 The recommended level of support for
6639 @*@code{record_representation_clauses} is:
6640
6641 An implementation should support storage places that can be extracted
6642 with a load, mask, shift sequence of machine code, and set with a load,
6643 shift, mask, store sequence, given the available machine instructions
6644 and run-time model.
6645 @end cartouche
6646 Followed.
6647
6648 @sp 1
6649 @cartouche
6650 A storage place should be supported if its size is equal to the
6651 @code{Size} of the component subtype, and it starts and ends on a
6652 boundary that obeys the @code{Alignment} of the component subtype.
6653 @end cartouche
6654 Followed.
6655
6656 @sp 1
6657 @cartouche
6658 If the default bit ordering applies to the declaration of a given type,
6659 then for a component whose subtype's @code{Size} is less than the word
6660 size, any storage place that does not cross an aligned word boundary
6661 should be supported.
6662 @end cartouche
6663 Followed.
6664
6665 @sp 1
6666 @cartouche
6667 An implementation may reserve a storage place for the tag field of a
6668 tagged type, and disallow other components from overlapping that place.
6669 @end cartouche
6670 Followed.  The storage place for the tag field is the beginning of the tagged
6671 record, and its size is Address'Size.  GNAT will reject an explicit component
6672 clause for the tag field.
6673
6674 @sp 1
6675 @cartouche
6676 An implementation need not support a @code{component_clause} for a
6677 component of an extension part if the storage place is not after the
6678 storage places of all components of the parent type, whether or not
6679 those storage places had been specified.
6680 @end cartouche
6681 Followed.  The above advice on record representation clauses is followed,
6682 and all mentioned features are implemented.
6683
6684 @cindex Storage place attributes
6685 @unnumberedsec 13.5.2(5): Storage Place Attributes
6686 @sp 1
6687 @cartouche
6688 If a component is represented using some form of pointer (such as an
6689 offset) to the actual data of the component, and this data is contiguous
6690 with the rest of the object, then the storage place attributes should
6691 reflect the place of the actual data, not the pointer.  If a component is
6692 allocated discontinuously from the rest of the object, then a warning
6693 should be generated upon reference to one of its storage place
6694 attributes.
6695 @end cartouche
6696 Followed.  There are no such components in GNAT@.
6697
6698 @cindex Bit ordering
6699 @unnumberedsec 13.5.3(7-8): Bit Ordering
6700 @sp 1
6701 @cartouche
6702 The recommended level of support for the non-default bit ordering is:
6703 @end cartouche
6704 @sp 1
6705 @cartouche
6706 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6707 should support the non-default bit ordering in addition to the default
6708 bit ordering.
6709 @end cartouche
6710 Followed.  Word size does not equal storage size in this implementation.
6711 Thus non-default bit ordering is not supported.
6712
6713 @cindex @code{Address}, as private type
6714 @unnumberedsec 13.7(37): Address as Private
6715 @sp 1
6716 @cartouche
6717 @code{Address} should be of a private type.
6718 @end cartouche
6719 Followed.
6720
6721 @cindex Operations, on @code{Address}
6722 @cindex @code{Address}, operations of
6723 @unnumberedsec 13.7.1(16): Address Operations
6724 @sp 1
6725 @cartouche
6726 Operations in @code{System} and its children should reflect the target
6727 environment semantics as closely as is reasonable.  For example, on most
6728 machines, it makes sense for address arithmetic to ``wrap around''.
6729 Operations that do not make sense should raise @code{Program_Error}.
6730 @end cartouche
6731 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6732 operation raises @code{Program_Error}, since all operations make sense.
6733
6734 @cindex Unchecked conversion
6735 @unnumberedsec 13.9(14-17): Unchecked Conversion
6736 @sp 1
6737 @cartouche
6738 The @code{Size} of an array object should not include its bounds; hence,
6739 the bounds should not be part of the converted data.
6740 @end cartouche
6741 Followed.
6742
6743 @sp 1
6744 @cartouche
6745 The implementation should not generate unnecessary run-time checks to
6746 ensure that the representation of @var{S} is a representation of the
6747 target type.  It should take advantage of the permission to return by
6748 reference when possible.  Restrictions on unchecked conversions should be
6749 avoided unless required by the target environment.
6750 @end cartouche
6751 Followed.  There are no restrictions on unchecked conversion.  A warning is
6752 generated if the source and target types do not have the same size since
6753 the semantics in this case may be target dependent.
6754
6755 @sp 1
6756 @cartouche
6757 The recommended level of support for unchecked conversions is:
6758 @end cartouche
6759 @sp 1
6760 @cartouche
6761 Unchecked conversions should be supported and should be reversible in
6762 the cases where this clause defines the result.  To enable meaningful use
6763 of unchecked conversion, a contiguous representation should be used for
6764 elementary subtypes, for statically constrained array subtypes whose
6765 component subtype is one of the subtypes described in this paragraph,
6766 and for record subtypes without discriminants whose component subtypes
6767 are described in this paragraph.
6768 @end cartouche
6769 Followed.
6770
6771 @cindex Heap usage, implicit
6772 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6773 @sp 1
6774 @cartouche
6775 An implementation should document any cases in which it dynamically
6776 allocates heap storage for a purpose other than the evaluation of an
6777 allocator.
6778 @end cartouche
6779 Followed, the only other points at which heap storage is dynamically
6780 allocated are as follows:
6781
6782 @itemize @bullet
6783 @item
6784 At initial elaboration time, to allocate dynamically sized global
6785 objects.
6786
6787 @item
6788 To allocate space for a task when a task is created.
6789
6790 @item
6791 To extend the secondary stack dynamically when needed.  The secondary
6792 stack is used for returning variable length results.
6793 @end itemize
6794
6795 @sp 1
6796 @cartouche
6797 A default (implementation-provided) storage pool for an
6798 access-to-constant type should not have overhead to support deallocation of
6799 individual objects.
6800 @end cartouche
6801 Followed.
6802
6803 @sp 1
6804 @cartouche
6805 A storage pool for an anonymous access type should be created at the
6806 point of an allocator for the type, and be reclaimed when the designated
6807 object becomes inaccessible.
6808 @end cartouche
6809 Followed.
6810
6811 @cindex Unchecked deallocation
6812 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6813 @sp 1
6814 @cartouche
6815 For a standard storage pool, @code{Free} should actually reclaim the
6816 storage.
6817 @end cartouche
6818 Followed.
6819
6820 @cindex Stream oriented attributes
6821 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6822 @sp 1
6823 @cartouche
6824 If a stream element is the same size as a storage element, then the
6825 normal in-memory representation should be used by @code{Read} and
6826 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6827 should use the smallest number of stream elements needed to represent
6828 all values in the base range of the scalar type.
6829 @end cartouche
6830
6831 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6832 which specifies using the size of the first subtype.
6833 However, such an implementation is based on direct binary
6834 representations and is therefore target- and endianness-dependent.
6835 To address this issue, GNAT also supplies an alternate implementation
6836 of the stream attributes @code{Read} and @code{Write},
6837 which uses the target-independent XDR standard representation
6838 for scalar types.
6839 @cindex XDR representation
6840 @cindex @code{Read} attribute
6841 @cindex @code{Write} attribute
6842 @cindex Stream oriented attributes
6843 The XDR implementation is provided as an alternative body of the
6844 @code{System.Stream_Attributes} package, in the file
6845 @file{s-strxdr.adb} in the GNAT library.
6846 There is no @file{s-strxdr.ads} file.
6847 In order to install the XDR implementation, do the following:
6848 @enumerate
6849 @item Replace the default implementation of the
6850 @code{System.Stream_Attributes} package with the XDR implementation.
6851 For example on a Unix platform issue the commands:
6852 @smallexample
6853 $ mv s-stratt.adb s-strold.adb
6854 $ mv s-strxdr.adb s-stratt.adb
6855 @end smallexample
6856
6857 @item
6858 Rebuild the GNAT run-time library as documented in
6859 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6860 @end enumerate
6861
6862 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6863 @sp 1
6864 @cartouche
6865 If an implementation provides additional named predefined integer types,
6866 then the names should end with @samp{Integer} as in
6867 @samp{Long_Integer}.  If an implementation provides additional named
6868 predefined floating point types, then the names should end with
6869 @samp{Float} as in @samp{Long_Float}.
6870 @end cartouche
6871 Followed.
6872
6873 @findex Ada.Characters.Handling
6874 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6875 @sp 1
6876 @cartouche
6877 If an implementation provides a localized definition of @code{Character}
6878 or @code{Wide_Character}, then the effects of the subprograms in
6879 @code{Characters.Handling} should reflect the localizations.  See also
6880 3.5.2.
6881 @end cartouche
6882 Followed.  GNAT provides no such localized definitions.
6883
6884 @cindex Bounded-length strings
6885 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6886 @sp 1
6887 @cartouche
6888 Bounded string objects should not be implemented by implicit pointers
6889 and dynamic allocation.
6890 @end cartouche
6891 Followed.  No implicit pointers or dynamic allocation are used.
6892
6893 @cindex Random number generation
6894 @unnumberedsec A.5.2(46-47): Random Number Generation
6895 @sp 1
6896 @cartouche
6897 Any storage associated with an object of type @code{Generator} should be
6898 reclaimed on exit from the scope of the object.
6899 @end cartouche
6900 Followed.
6901
6902 @sp 1
6903 @cartouche
6904 If the generator period is sufficiently long in relation to the number
6905 of distinct initiator values, then each possible value of
6906 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6907 random numbers that does not, in a practical sense, overlap the sequence
6908 initiated by any other value.  If this is not possible, then the mapping
6909 between initiator values and generator states should be a rapidly
6910 varying function of the initiator value.
6911 @end cartouche
6912 Followed.  The generator period is sufficiently long for the first
6913 condition here to hold true.
6914
6915 @findex Get_Immediate
6916 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6917 @sp 1
6918 @cartouche
6919 The @code{Get_Immediate} procedures should be implemented with
6920 unbuffered input.  For a device such as a keyboard, input should be
6921 @dfn{available} if a key has already been typed, whereas for a disk
6922 file, input should always be available except at end of file.  For a file
6923 associated with a keyboard-like device, any line-editing features of the
6924 underlying operating system should be disabled during the execution of
6925 @code{Get_Immediate}.
6926 @end cartouche
6927 Followed on all targets except VxWorks. For VxWorks, there is no way to
6928 provide this functionality that does not result in the input buffer being
6929 flushed before the @code{Get_Immediate} call. A special unit
6930 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6931 this functionality.
6932
6933 @findex Export
6934 @unnumberedsec B.1(39-41): Pragma @code{Export}
6935 @sp 1
6936 @cartouche
6937 If an implementation supports pragma @code{Export} to a given language,
6938 then it should also allow the main subprogram to be written in that
6939 language.  It should support some mechanism for invoking the elaboration
6940 of the Ada library units included in the system, and for invoking the
6941 finalization of the environment task.  On typical systems, the
6942 recommended mechanism is to provide two subprograms whose link names are
6943 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6944 elaboration code for library units.  @code{adafinal} should contain the
6945 finalization code.  These subprograms should have no effect the second
6946 and subsequent time they are called.
6947 @end cartouche
6948 Followed.
6949
6950 @sp 1
6951 @cartouche
6952 Automatic elaboration of pre-elaborated packages should be
6953 provided when pragma @code{Export} is supported.
6954 @end cartouche
6955 Followed when the main program is in Ada.  If the main program is in a
6956 foreign language, then
6957 @code{adainit} must be called to elaborate pre-elaborated
6958 packages.
6959
6960 @sp 1
6961 @cartouche
6962 For each supported convention @var{L} other than @code{Intrinsic}, an
6963 implementation should support @code{Import} and @code{Export} pragmas
6964 for objects of @var{L}-compatible types and for subprograms, and pragma
6965 @code{Convention} for @var{L}-eligible types and for subprograms,
6966 presuming the other language has corresponding features.  Pragma
6967 @code{Convention} need not be supported for scalar types.
6968 @end cartouche
6969 Followed.
6970
6971 @cindex Package @code{Interfaces}
6972 @findex Interfaces
6973 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6974 @sp 1
6975 @cartouche
6976 For each implementation-defined convention identifier, there should be a
6977 child package of package Interfaces with the corresponding name.  This
6978 package should contain any declarations that would be useful for
6979 interfacing to the language (implementation) represented by the
6980 convention.  Any declarations useful for interfacing to any language on
6981 the given hardware architecture should be provided directly in
6982 @code{Interfaces}.
6983 @end cartouche
6984 Followed. An additional package not defined
6985 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6986 for interfacing to C++.
6987
6988 @sp 1
6989 @cartouche
6990 An implementation supporting an interface to C, COBOL, or Fortran should
6991 provide the corresponding package or packages described in the following
6992 clauses.
6993 @end cartouche
6994 Followed.  GNAT provides all the packages described in this section.
6995
6996 @cindex C, interfacing with
6997 @unnumberedsec B.3(63-71): Interfacing with C
6998 @sp 1
6999 @cartouche
7000 An implementation should support the following interface correspondences
7001 between Ada and C@.
7002 @end cartouche
7003 Followed.
7004
7005 @sp 1
7006 @cartouche
7007 An Ada procedure corresponds to a void-returning C function.
7008 @end cartouche
7009 Followed.
7010
7011 @sp 1
7012 @cartouche
7013 An Ada function corresponds to a non-void C function.
7014 @end cartouche
7015 Followed.
7016
7017 @sp 1
7018 @cartouche
7019 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7020 function.
7021 @end cartouche
7022 Followed.
7023
7024 @sp 1
7025 @cartouche
7026 An Ada @code{in} parameter of an access-to-object type with designated
7027 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7028 where @var{t} is the C type corresponding to the Ada type @var{T}.
7029 @end cartouche
7030 Followed.
7031
7032 @sp 1
7033 @cartouche
7034 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7035 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7036 argument to a C function, where @var{t} is the C type corresponding to
7037 the Ada type @var{T}.  In the case of an elementary @code{out} or
7038 @code{in out} parameter, a pointer to a temporary copy is used to
7039 preserve by-copy semantics.
7040 @end cartouche
7041 Followed.
7042
7043 @sp 1
7044 @cartouche
7045 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7046 @code{@var{t}*} argument to a C function, where @var{t} is the C
7047 structure corresponding to the Ada type @var{T}.
7048 @end cartouche
7049 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7050 pragma, or Convention, or by explicitly specifying the mechanism for a given
7051 call using an extended import or export pragma.
7052
7053 @sp 1
7054 @cartouche
7055 An Ada parameter of an array type with component type @var{T}, of any
7056 mode, is passed as a @code{@var{t}*} argument to a C function, where
7057 @var{t} is the C type corresponding to the Ada type @var{T}.
7058 @end cartouche
7059 Followed.
7060
7061 @sp 1
7062 @cartouche
7063 An Ada parameter of an access-to-subprogram type is passed as a pointer
7064 to a C function whose prototype corresponds to the designated
7065 subprogram's specification.
7066 @end cartouche
7067 Followed.
7068
7069 @cindex COBOL, interfacing with
7070 @unnumberedsec B.4(95-98): Interfacing with COBOL
7071 @sp 1
7072 @cartouche
7073 An Ada implementation should support the following interface
7074 correspondences between Ada and COBOL@.
7075 @end cartouche
7076 Followed.
7077
7078 @sp 1
7079 @cartouche
7080 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7081 the COBOL type corresponding to @var{T}.
7082 @end cartouche
7083 Followed.
7084
7085 @sp 1
7086 @cartouche
7087 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7088 the corresponding COBOL type.
7089 @end cartouche
7090 Followed.
7091
7092 @sp 1
7093 @cartouche
7094 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7095 COBOL type corresponding to the Ada parameter type; for scalars, a local
7096 copy is used if necessary to ensure by-copy semantics.
7097 @end cartouche
7098 Followed.
7099
7100 @cindex Fortran, interfacing with
7101 @unnumberedsec B.5(22-26): Interfacing with Fortran
7102 @sp 1
7103 @cartouche
7104 An Ada implementation should support the following interface
7105 correspondences between Ada and Fortran:
7106 @end cartouche
7107 Followed.
7108
7109 @sp 1
7110 @cartouche
7111 An Ada procedure corresponds to a Fortran subroutine.
7112 @end cartouche
7113 Followed.
7114
7115 @sp 1
7116 @cartouche
7117 An Ada function corresponds to a Fortran function.
7118 @end cartouche
7119 Followed.
7120
7121 @sp 1
7122 @cartouche
7123 An Ada parameter of an elementary, array, or record type @var{T} is
7124 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7125 the Fortran type corresponding to the Ada type @var{T}, and where the
7126 INTENT attribute of the corresponding dummy argument matches the Ada
7127 formal parameter mode; the Fortran implementation's parameter passing
7128 conventions are used.  For elementary types, a local copy is used if
7129 necessary to ensure by-copy semantics.
7130 @end cartouche
7131 Followed.
7132
7133 @sp 1
7134 @cartouche
7135 An Ada parameter of an access-to-subprogram type is passed as a
7136 reference to a Fortran procedure whose interface corresponds to the
7137 designated subprogram's specification.
7138 @end cartouche
7139 Followed.
7140
7141 @cindex Machine operations
7142 @unnumberedsec C.1(3-5): Access to Machine Operations
7143 @sp 1
7144 @cartouche
7145 The machine code or intrinsic support should allow access to all
7146 operations normally available to assembly language programmers for the
7147 target environment, including privileged instructions, if any.
7148 @end cartouche
7149 Followed.
7150
7151 @sp 1
7152 @cartouche
7153 The interfacing pragmas (see Annex B) should support interface to
7154 assembler; the default assembler should be associated with the
7155 convention identifier @code{Assembler}.
7156 @end cartouche
7157 Followed.
7158
7159 @sp 1
7160 @cartouche
7161 If an entity is exported to assembly language, then the implementation
7162 should allocate it at an addressable location, and should ensure that it
7163 is retained by the linking process, even if not otherwise referenced
7164 from the Ada code.  The implementation should assume that any call to a
7165 machine code or assembler subprogram is allowed to read or update every
7166 object that is specified as exported.
7167 @end cartouche
7168 Followed.
7169
7170 @unnumberedsec C.1(10-16): Access to Machine Operations
7171 @sp 1
7172 @cartouche
7173 The implementation should ensure that little or no overhead is
7174 associated with calling intrinsic and machine-code subprograms.
7175 @end cartouche
7176 Followed for both intrinsics and machine-code subprograms.
7177
7178 @sp 1
7179 @cartouche
7180 It is recommended that intrinsic subprograms be provided for convenient
7181 access to any machine operations that provide special capabilities or
7182 efficiency and that are not otherwise available through the language
7183 constructs.
7184 @end cartouche
7185 Followed.  A full set of machine operation intrinsic subprograms is provided.
7186
7187 @sp 1
7188 @cartouche
7189 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7190 swap, decrement and test, enqueue/dequeue.
7191 @end cartouche
7192 Followed on any target supporting such operations.
7193
7194 @sp 1
7195 @cartouche
7196 Standard numeric functions---e.g.@:, sin, log.
7197 @end cartouche
7198 Followed on any target supporting such operations.
7199
7200 @sp 1
7201 @cartouche
7202 String manipulation operations---e.g.@:, translate and test.
7203 @end cartouche
7204 Followed on any target supporting such operations.
7205
7206 @sp 1
7207 @cartouche
7208 Vector operations---e.g.@:, compare vector against thresholds.
7209 @end cartouche
7210 Followed on any target supporting such operations.
7211
7212 @sp 1
7213 @cartouche
7214 Direct operations on I/O ports.
7215 @end cartouche
7216 Followed on any target supporting such operations.
7217
7218 @cindex Interrupt support
7219 @unnumberedsec C.3(28): Interrupt Support
7220 @sp 1
7221 @cartouche
7222 If the @code{Ceiling_Locking} policy is not in effect, the
7223 implementation should provide means for the application to specify which
7224 interrupts are to be blocked during protected actions, if the underlying
7225 system allows for a finer-grain control of interrupt blocking.
7226 @end cartouche
7227 Followed.  The underlying system does not allow for finer-grain control
7228 of interrupt blocking.
7229
7230 @cindex Protected procedure handlers
7231 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7232 @sp 1
7233 @cartouche
7234 Whenever possible, the implementation should allow interrupt handlers to
7235 be called directly by the hardware.
7236 @end cartouche
7237 @c SGI info:
7238 @ignore
7239 This is never possible under IRIX, so this is followed by default.
7240 @end ignore
7241 Followed on any target where the underlying operating system permits
7242 such direct calls.
7243
7244 @sp 1
7245 @cartouche
7246 Whenever practical, violations of any
7247 implementation-defined restrictions should be detected before run time.
7248 @end cartouche
7249 Followed.  Compile time warnings are given when possible.
7250
7251 @cindex Package @code{Interrupts}
7252 @findex Interrupts
7253 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7254
7255 @sp 1
7256 @cartouche
7257 If implementation-defined forms of interrupt handler procedures are
7258 supported, such as protected procedures with parameters, then for each
7259 such form of a handler, a type analogous to @code{Parameterless_Handler}
7260 should be specified in a child package of @code{Interrupts}, with the
7261 same operations as in the predefined package Interrupts.
7262 @end cartouche
7263 Followed.
7264
7265 @cindex Pre-elaboration requirements
7266 @unnumberedsec C.4(14): Pre-elaboration Requirements
7267 @sp 1
7268 @cartouche
7269 It is recommended that pre-elaborated packages be implemented in such a
7270 way that there should be little or no code executed at run time for the
7271 elaboration of entities not already covered by the Implementation
7272 Requirements.
7273 @end cartouche
7274 Followed.  Executable code is generated in some cases, e.g.@: loops
7275 to initialize large arrays.
7276
7277 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7278
7279 @sp 1
7280 @cartouche
7281 If the pragma applies to an entity, then the implementation should
7282 reduce the amount of storage used for storing names associated with that
7283 entity.
7284 @end cartouche
7285 Followed.
7286
7287 @cindex Package @code{Task_Attributes}
7288 @findex Task_Attributes
7289 @unnumberedsec C.7.2(30): The Package Task_Attributes
7290 @sp 1
7291 @cartouche
7292 Some implementations are targeted to domains in which memory use at run
7293 time must be completely deterministic.  For such implementations, it is
7294 recommended that the storage for task attributes will be pre-allocated
7295 statically and not from the heap.  This can be accomplished by either
7296 placing restrictions on the number and the size of the task's
7297 attributes, or by using the pre-allocated storage for the first @var{N}
7298 attribute objects, and the heap for the others.  In the latter case,
7299 @var{N} should be documented.
7300 @end cartouche
7301 Not followed.  This implementation is not targeted to such a domain.
7302
7303 @cindex Locking Policies
7304 @unnumberedsec D.3(17): Locking Policies
7305
7306 @sp 1
7307 @cartouche
7308 The implementation should use names that end with @samp{_Locking} for
7309 locking policies defined by the implementation.
7310 @end cartouche
7311 Followed.  A single implementation-defined locking policy is defined,
7312 whose name (@code{Inheritance_Locking}) follows this suggestion.
7313
7314 @cindex Entry queuing policies
7315 @unnumberedsec D.4(16): Entry Queuing Policies
7316 @sp 1
7317 @cartouche
7318 Names that end with @samp{_Queuing} should be used
7319 for all implementation-defined queuing policies.
7320 @end cartouche
7321 Followed.  No such implementation-defined queuing policies exist.
7322
7323 @cindex Preemptive abort
7324 @unnumberedsec D.6(9-10): Preemptive Abort
7325 @sp 1
7326 @cartouche
7327 Even though the @code{abort_statement} is included in the list of
7328 potentially blocking operations (see 9.5.1), it is recommended that this
7329 statement be implemented in a way that never requires the task executing
7330 the @code{abort_statement} to block.
7331 @end cartouche
7332 Followed.
7333
7334 @sp 1
7335 @cartouche
7336 On a multi-processor, the delay associated with aborting a task on
7337 another processor should be bounded; the implementation should use
7338 periodic polling, if necessary, to achieve this.
7339 @end cartouche
7340 Followed.
7341
7342 @cindex Tasking restrictions
7343 @unnumberedsec D.7(21): Tasking Restrictions
7344 @sp 1
7345 @cartouche
7346 When feasible, the implementation should take advantage of the specified
7347 restrictions to produce a more efficient implementation.
7348 @end cartouche
7349 GNAT currently takes advantage of these restrictions by providing an optimized
7350 run time when the Ravenscar profile and the GNAT restricted run time set
7351 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7352 pragma @code{Profile (Restricted)} for more details.
7353
7354 @cindex Time, monotonic
7355 @unnumberedsec D.8(47-49): Monotonic Time
7356 @sp 1
7357 @cartouche
7358 When appropriate, implementations should provide configuration
7359 mechanisms to change the value of @code{Tick}.
7360 @end cartouche
7361 Such configuration mechanisms are not appropriate to this implementation
7362 and are thus not supported.
7363
7364 @sp 1
7365 @cartouche
7366 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7367 be implemented as transformations of the same time base.
7368 @end cartouche
7369 Followed.
7370
7371 @sp 1
7372 @cartouche
7373 It is recommended that the @dfn{best} time base which exists in
7374 the underlying system be available to the application through
7375 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7376 @end cartouche
7377 Followed.
7378
7379 @cindex Partition communication subsystem
7380 @cindex PCS
7381 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7382 @sp 1
7383 @cartouche
7384 Whenever possible, the PCS on the called partition should allow for
7385 multiple tasks to call the RPC-receiver with different messages and
7386 should allow them to block until the corresponding subprogram body
7387 returns.
7388 @end cartouche
7389 Followed by GLADE, a separately supplied PCS that can be used with
7390 GNAT.
7391
7392 @sp 1
7393 @cartouche
7394 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7395 should raise @code{Storage_Error} if it runs out of space trying to
7396 write the @code{Item} into the stream.
7397 @end cartouche
7398 Followed by GLADE, a separately supplied PCS that can be used with
7399 GNAT@.
7400
7401 @cindex COBOL support
7402 @unnumberedsec F(7): COBOL Support
7403 @sp 1
7404 @cartouche
7405 If COBOL (respectively, C) is widely supported in the target
7406 environment, implementations supporting the Information Systems Annex
7407 should provide the child package @code{Interfaces.COBOL} (respectively,
7408 @code{Interfaces.C}) specified in Annex B and should support a
7409 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7410 pragmas (see Annex B), thus allowing Ada programs to interface with
7411 programs written in that language.
7412 @end cartouche
7413 Followed.
7414
7415 @cindex Decimal radix support
7416 @unnumberedsec F.1(2): Decimal Radix Support
7417 @sp 1
7418 @cartouche
7419 Packed decimal should be used as the internal representation for objects
7420 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7421 @end cartouche
7422 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7423 representations.
7424
7425 @cindex Numerics
7426 @unnumberedsec G: Numerics
7427 @sp 2
7428 @cartouche
7429 If Fortran (respectively, C) is widely supported in the target
7430 environment, implementations supporting the Numerics Annex
7431 should provide the child package @code{Interfaces.Fortran} (respectively,
7432 @code{Interfaces.C}) specified in Annex B and should support a
7433 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7434 pragmas (see Annex B), thus allowing Ada programs to interface with
7435 programs written in that language.
7436 @end cartouche
7437 Followed.
7438
7439 @cindex Complex types
7440 @unnumberedsec G.1.1(56-58): Complex Types
7441 @sp 2
7442 @cartouche
7443 Because the usual mathematical meaning of multiplication of a complex
7444 operand and a real operand is that of the scaling of both components of
7445 the former by the latter, an implementation should not perform this
7446 operation by first promoting the real operand to complex type and then
7447 performing a full complex multiplication.  In systems that, in the
7448 future, support an Ada binding to IEC 559:1989, the latter technique
7449 will not generate the required result when one of the components of the
7450 complex operand is infinite.  (Explicit multiplication of the infinite
7451 component by the zero component obtained during promotion yields a NaN
7452 that propagates into the final result.) Analogous advice applies in the
7453 case of multiplication of a complex operand and a pure-imaginary
7454 operand, and in the case of division of a complex operand by a real or
7455 pure-imaginary operand.
7456 @end cartouche
7457 Not followed.
7458
7459 @sp 1
7460 @cartouche
7461 Similarly, because the usual mathematical meaning of addition of a
7462 complex operand and a real operand is that the imaginary operand remains
7463 unchanged, an implementation should not perform this operation by first
7464 promoting the real operand to complex type and then performing a full
7465 complex addition.  In implementations in which the @code{Signed_Zeros}
7466 attribute of the component type is @code{True} (and which therefore
7467 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7468 predefined arithmetic operations), the latter technique will not
7469 generate the required result when the imaginary component of the complex
7470 operand is a negatively signed zero.  (Explicit addition of the negative
7471 zero to the zero obtained during promotion yields a positive zero.)
7472 Analogous advice applies in the case of addition of a complex operand
7473 and a pure-imaginary operand, and in the case of subtraction of a
7474 complex operand and a real or pure-imaginary operand.
7475 @end cartouche
7476 Not followed.
7477
7478 @sp 1
7479 @cartouche
7480 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7481 attempt to provide a rational treatment of the signs of zero results and
7482 result components.  As one example, the result of the @code{Argument}
7483 function should have the sign of the imaginary component of the
7484 parameter @code{X} when the point represented by that parameter lies on
7485 the positive real axis; as another, the sign of the imaginary component
7486 of the @code{Compose_From_Polar} function should be the same as
7487 (respectively, the opposite of) that of the @code{Argument} parameter when that
7488 parameter has a value of zero and the @code{Modulus} parameter has a
7489 nonnegative (respectively, negative) value.
7490 @end cartouche
7491 Followed.
7492
7493 @cindex Complex elementary functions
7494 @unnumberedsec G.1.2(49): Complex Elementary Functions
7495 @sp 1
7496 @cartouche
7497 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7498 @code{True} should attempt to provide a rational treatment of the signs
7499 of zero results and result components.  For example, many of the complex
7500 elementary functions have components that are odd functions of one of
7501 the parameter components; in these cases, the result component should
7502 have the sign of the parameter component at the origin.  Other complex
7503 elementary functions have zero components whose sign is opposite that of
7504 a parameter component at the origin, or is always positive or always
7505 negative.
7506 @end cartouche
7507 Followed.
7508
7509 @cindex Accuracy requirements
7510 @unnumberedsec G.2.4(19): Accuracy Requirements
7511 @sp 1
7512 @cartouche
7513 The versions of the forward trigonometric functions without a
7514 @code{Cycle} parameter should not be implemented by calling the
7515 corresponding version with a @code{Cycle} parameter of
7516 @code{2.0*Numerics.Pi}, since this will not provide the required
7517 accuracy in some portions of the domain.  For the same reason, the
7518 version of @code{Log} without a @code{Base} parameter should not be
7519 implemented by calling the corresponding version with a @code{Base}
7520 parameter of @code{Numerics.e}.
7521 @end cartouche
7522 Followed.
7523
7524 @cindex Complex arithmetic accuracy
7525 @cindex Accuracy, complex arithmetic
7526 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7527
7528 @sp 1
7529 @cartouche
7530 The version of the @code{Compose_From_Polar} function without a
7531 @code{Cycle} parameter should not be implemented by calling the
7532 corresponding version with a @code{Cycle} parameter of
7533 @code{2.0*Numerics.Pi}, since this will not provide the required
7534 accuracy in some portions of the domain.
7535 @end cartouche
7536 Followed.
7537
7538 @c -----------------------------------------
7539 @node Implementation Defined Characteristics
7540 @chapter Implementation Defined Characteristics
7541
7542 @noindent
7543 In addition to the implementation dependent pragmas and attributes, and
7544 the implementation advice, there are a number of other Ada features
7545 that are potentially implementation dependent.  These are mentioned
7546 throughout the Ada Reference Manual, and are summarized in annex M@.
7547
7548 A requirement for conforming Ada compilers is that they provide
7549 documentation describing how the implementation deals with each of these
7550 issues.  In this chapter, you will find each point in annex M listed
7551 followed by a description in italic font of how GNAT
7552 @c SGI info:
7553 @ignore
7554 in the ProDev Ada
7555 implementation on IRIX 5.3 operating system or greater
7556 @end ignore
7557 handles the implementation dependence.
7558
7559 You can use this chapter as a guide to minimizing implementation
7560 dependent features in your programs if portability to other compilers
7561 and other operating systems is an important consideration.  The numbers
7562 in each section below correspond to the paragraph number in the Ada
7563 Reference Manual.
7564
7565 @sp 1
7566 @cartouche
7567 @noindent
7568 @strong{2}.  Whether or not each recommendation given in Implementation
7569 Advice is followed.  See 1.1.2(37).
7570 @end cartouche
7571 @noindent
7572 @xref{Implementation Advice}.
7573
7574 @sp 1
7575 @cartouche
7576 @noindent
7577 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7578 @end cartouche
7579 @noindent
7580 The complexity of programs that can be processed is limited only by the
7581 total amount of available virtual memory, and disk space for the
7582 generated object files.
7583
7584 @sp 1
7585 @cartouche
7586 @noindent
7587 @strong{4}.  Variations from the standard that are impractical to avoid
7588 given the implementation's execution environment.  See 1.1.3(6).
7589 @end cartouche
7590 @noindent
7591 There are no variations from the standard.
7592
7593 @sp 1
7594 @cartouche
7595 @noindent
7596 @strong{5}.  Which @code{code_statement}s cause external
7597 interactions.  See 1.1.3(10).
7598 @end cartouche
7599 @noindent
7600 Any @code{code_statement} can potentially cause external interactions.
7601
7602 @sp 1
7603 @cartouche
7604 @noindent
7605 @strong{6}.  The coded representation for the text of an Ada
7606 program.  See 2.1(4).
7607 @end cartouche
7608 @noindent
7609 See separate section on source representation.
7610
7611 @sp 1
7612 @cartouche
7613 @noindent
7614 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7615 @end cartouche
7616 @noindent
7617 See separate section on source representation.
7618
7619 @sp 1
7620 @cartouche
7621 @noindent
7622 @strong{8}.  The representation for an end of line.  See 2.2(2).
7623 @end cartouche
7624 @noindent
7625 See separate section on source representation.
7626
7627 @sp 1
7628 @cartouche
7629 @noindent
7630 @strong{9}.  Maximum supported line length and lexical element
7631 length.  See 2.2(15).
7632 @end cartouche
7633 @noindent
7634 The maximum line length is 255 characters and the maximum length of a
7635 lexical element is also 255 characters.
7636
7637 @sp 1
7638 @cartouche
7639 @noindent
7640 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7641 @end cartouche
7642 @noindent
7643
7644 @xref{Implementation Defined Pragmas}.
7645
7646 @sp 1
7647 @cartouche
7648 @noindent
7649 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7650 @end cartouche
7651 @noindent
7652 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7653 parameter, checks that the optimization flag is set, and aborts if it is
7654 not.
7655
7656 @sp 1
7657 @cartouche
7658 @noindent
7659 @strong{12}.  The sequence of characters of the value returned by
7660 @code{@var{S}'Image} when some of the graphic characters of
7661 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7662 3.5(37).
7663 @end cartouche
7664 @noindent
7665 The sequence of characters is as defined by the wide character encoding
7666 method used for the source.  See section on source representation for
7667 further details.
7668
7669 @sp 1
7670 @cartouche
7671 @noindent
7672 @strong{13}.  The predefined integer types declared in
7673 @code{Standard}.  See 3.5.4(25).
7674 @end cartouche
7675 @noindent
7676 @table @code
7677 @item Short_Short_Integer
7678 8 bit signed
7679 @item Short_Integer
7680 (Short) 16 bit signed
7681 @item Integer
7682 32 bit signed
7683 @item Long_Integer
7684 64 bit signed (Alpha OpenVMS only)
7685 32 bit signed (all other targets)
7686 @item Long_Long_Integer
7687 64 bit signed
7688 @end table
7689
7690 @sp 1
7691 @cartouche
7692 @noindent
7693 @strong{14}.  Any nonstandard integer types and the operators defined
7694 for them.  See 3.5.4(26).
7695 @end cartouche
7696 @noindent
7697 There are no nonstandard integer types.
7698
7699 @sp 1
7700 @cartouche
7701 @noindent
7702 @strong{15}.  Any nonstandard real types and the operators defined for
7703 them.  See 3.5.6(8).
7704 @end cartouche
7705 @noindent
7706 There are no nonstandard real types.
7707
7708 @sp 1
7709 @cartouche
7710 @noindent
7711 @strong{16}.  What combinations of requested decimal precision and range
7712 are supported for floating point types.  See 3.5.7(7).
7713 @end cartouche
7714 @noindent
7715 The precision and range is as defined by the IEEE standard.
7716
7717 @sp 1
7718 @cartouche
7719 @noindent
7720 @strong{17}.  The predefined floating point types declared in
7721 @code{Standard}.  See 3.5.7(16).
7722 @end cartouche
7723 @noindent
7724 @table @code
7725 @item Short_Float
7726 32 bit IEEE short
7727 @item Float
7728 (Short) 32 bit IEEE short
7729 @item Long_Float
7730 64 bit IEEE long
7731 @item Long_Long_Float
7732 64 bit IEEE long (80 bit IEEE long on x86 processors)
7733 @end table
7734
7735 @sp 1
7736 @cartouche
7737 @noindent
7738 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7739 @end cartouche
7740 @noindent
7741 @code{Fine_Delta} is 2**(@minus{}63)
7742
7743 @sp 1
7744 @cartouche
7745 @noindent
7746 @strong{19}.  What combinations of small, range, and digits are
7747 supported for fixed point types.  See 3.5.9(10).
7748 @end cartouche
7749 @noindent
7750 Any combinations are permitted that do not result in a small less than
7751 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7752 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7753 is 64 bits (true of all architectures except ia32), then the output from
7754 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7755 is because floating-point conversions are used to convert fixed point.
7756
7757 @sp 1
7758 @cartouche
7759 @noindent
7760 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7761 within an unnamed @code{block_statement}.  See 3.9(10).
7762 @end cartouche
7763 @noindent
7764 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7765 decimal integer are allocated.
7766
7767 @sp 1
7768 @cartouche
7769 @noindent
7770 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7771 @end cartouche
7772 @noindent
7773 @xref{Implementation Defined Attributes}.
7774
7775 @sp 1
7776 @cartouche
7777 @noindent
7778 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7779 @end cartouche
7780 @noindent
7781 There are no implementation-defined time types.
7782
7783 @sp 1
7784 @cartouche
7785 @noindent
7786 @strong{23}.  The time base associated with relative delays.
7787 @end cartouche
7788 @noindent
7789 See 9.6(20).  The time base used is that provided by the C library
7790 function @code{gettimeofday}.
7791
7792 @sp 1
7793 @cartouche
7794 @noindent
7795 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7796 9.6(23).
7797 @end cartouche
7798 @noindent
7799 The time base used is that provided by the C library function
7800 @code{gettimeofday}.
7801
7802 @sp 1
7803 @cartouche
7804 @noindent
7805 @strong{25}.  The time zone used for package @code{Calendar}
7806 operations.  See 9.6(24).
7807 @end cartouche
7808 @noindent
7809 The time zone used by package @code{Calendar} is the current system time zone
7810 setting for local time, as accessed by the C library function
7811 @code{localtime}.
7812
7813 @sp 1
7814 @cartouche
7815 @noindent
7816 @strong{26}.  Any limit on @code{delay_until_statements} of
7817 @code{select_statements}.  See 9.6(29).
7818 @end cartouche
7819 @noindent
7820 There are no such limits.
7821
7822 @sp 1
7823 @cartouche
7824 @noindent
7825 @strong{27}.  Whether or not two non-overlapping parts of a composite
7826 object are independently addressable, in the case where packing, record
7827 layout, or @code{Component_Size} is specified for the object.  See
7828 9.10(1).
7829 @end cartouche
7830 @noindent
7831 Separate components are independently addressable if they do not share
7832 overlapping storage units.
7833
7834 @sp 1
7835 @cartouche
7836 @noindent
7837 @strong{28}.  The representation for a compilation.  See 10.1(2).
7838 @end cartouche
7839 @noindent
7840 A compilation is represented by a sequence of files presented to the
7841 compiler in a single invocation of the @command{gcc} command.
7842
7843 @sp 1
7844 @cartouche
7845 @noindent
7846 @strong{29}.  Any restrictions on compilations that contain multiple
7847 compilation_units.  See 10.1(4).
7848 @end cartouche
7849 @noindent
7850 No single file can contain more than one compilation unit, but any
7851 sequence of files can be presented to the compiler as a single
7852 compilation.
7853
7854 @sp 1
7855 @cartouche
7856 @noindent
7857 @strong{30}.  The mechanisms for creating an environment and for adding
7858 and replacing compilation units.  See 10.1.4(3).
7859 @end cartouche
7860 @noindent
7861 See separate section on compilation model.
7862
7863 @sp 1
7864 @cartouche
7865 @noindent
7866 @strong{31}.  The manner of explicitly assigning library units to a
7867 partition.  See 10.2(2).
7868 @end cartouche
7869 @noindent
7870 If a unit contains an Ada main program, then the Ada units for the partition
7871 are determined by recursive application of the rules in the Ada Reference
7872 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7873 are needed by the main program, and then this definition of need is applied
7874 recursively to those units, and the partition contains the transitive
7875 closure determined by this relationship.  In short, all the necessary units
7876 are included, with no need to explicitly specify the list.  If additional
7877 units are required, e.g.@: by foreign language units, then all units must be
7878 mentioned in the context clause of one of the needed Ada units.
7879
7880 If the partition contains no main program, or if the main program is in
7881 a language other than Ada, then GNAT
7882 provides the binder options @option{-z} and @option{-n} respectively, and in
7883 this case a list of units can be explicitly supplied to the binder for
7884 inclusion in the partition (all units needed by these units will also
7885 be included automatically).  For full details on the use of these
7886 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
7887 @value{EDITION} User's Guide}.
7888
7889 @sp 1
7890 @cartouche
7891 @noindent
7892 @strong{32}.  The implementation-defined means, if any, of specifying
7893 which compilation units are needed by a given compilation unit.  See
7894 10.2(2).
7895 @end cartouche
7896 @noindent
7897 The units needed by a given compilation unit are as defined in
7898 the Ada Reference Manual section 10.2(2-6).  There are no
7899 implementation-defined pragmas or other implementation-defined
7900 means for specifying needed units.
7901
7902 @sp 1
7903 @cartouche
7904 @noindent
7905 @strong{33}.  The manner of designating the main subprogram of a
7906 partition.  See 10.2(7).
7907 @end cartouche
7908 @noindent
7909 The main program is designated by providing the name of the
7910 corresponding @file{ALI} file as the input parameter to the binder.
7911
7912 @sp 1
7913 @cartouche
7914 @noindent
7915 @strong{34}.  The order of elaboration of @code{library_items}.  See
7916 10.2(18).
7917 @end cartouche
7918 @noindent
7919 The first constraint on ordering is that it meets the requirements of
7920 Chapter 10 of the Ada Reference Manual.  This still leaves some
7921 implementation dependent choices, which are resolved by first
7922 elaborating bodies as early as possible (i.e., in preference to specs
7923 where there is a choice), and second by evaluating the immediate with
7924 clauses of a unit to determine the probably best choice, and
7925 third by elaborating in alphabetical order of unit names
7926 where a choice still remains.
7927
7928 @sp 1
7929 @cartouche
7930 @noindent
7931 @strong{35}.  Parameter passing and function return for the main
7932 subprogram.  See 10.2(21).
7933 @end cartouche
7934 @noindent
7935 The main program has no parameters.  It may be a procedure, or a function
7936 returning an integer type.  In the latter case, the returned integer
7937 value is the return code of the program (overriding any value that
7938 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7939
7940 @sp 1
7941 @cartouche
7942 @noindent
7943 @strong{36}.  The mechanisms for building and running partitions.  See
7944 10.2(24).
7945 @end cartouche
7946 @noindent
7947 GNAT itself supports programs with only a single partition.  The GNATDIST
7948 tool provided with the GLADE package (which also includes an implementation
7949 of the PCS) provides a completely flexible method for building and running
7950 programs consisting of multiple partitions.  See the separate GLADE manual
7951 for details.
7952
7953 @sp 1
7954 @cartouche
7955 @noindent
7956 @strong{37}.  The details of program execution, including program
7957 termination.  See 10.2(25).
7958 @end cartouche
7959 @noindent
7960 See separate section on compilation model.
7961
7962 @sp 1
7963 @cartouche
7964 @noindent
7965 @strong{38}.  The semantics of any non-active partitions supported by the
7966 implementation.  See 10.2(28).
7967 @end cartouche
7968 @noindent
7969 Passive partitions are supported on targets where shared memory is
7970 provided by the operating system.  See the GLADE reference manual for
7971 further details.
7972
7973 @sp 1
7974 @cartouche
7975 @noindent
7976 @strong{39}.  The information returned by @code{Exception_Message}.  See
7977 11.4.1(10).
7978 @end cartouche
7979 @noindent
7980 Exception message returns the null string unless a specific message has
7981 been passed by the program.
7982
7983 @sp 1
7984 @cartouche
7985 @noindent
7986 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7987 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7988 @end cartouche
7989 @noindent
7990 Blocks have implementation defined names of the form @code{B@var{nnn}}
7991 where @var{nnn} is an integer.
7992
7993 @sp 1
7994 @cartouche
7995 @noindent
7996 @strong{41}.  The information returned by
7997 @code{Exception_Information}.  See 11.4.1(13).
7998 @end cartouche
7999 @noindent
8000 @code{Exception_Information} returns a string in the following format:
8001
8002 @smallexample
8003 @emph{Exception_Name:} nnnnn
8004 @emph{Message:} mmmmm
8005 @emph{PID:} ppp
8006 @emph{Call stack traceback locations:}
8007 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8008 @end smallexample
8009
8010 @noindent
8011 where
8012
8013 @itemize @bullet
8014 @item
8015 @code{nnnn} is the fully qualified name of the exception in all upper
8016 case letters. This line is always present.
8017
8018 @item
8019 @code{mmmm} is the message (this line present only if message is non-null)
8020
8021 @item
8022 @code{ppp} is the Process Id value as a decimal integer (this line is
8023 present only if the Process Id is nonzero). Currently we are
8024 not making use of this field.
8025
8026 @item
8027 The Call stack traceback locations line and the following values
8028 are present only if at least one traceback location was recorded.
8029 The values are given in C style format, with lower case letters
8030 for a-f, and only as many digits present as are necessary.
8031 @end itemize
8032
8033 @noindent
8034 The line terminator sequence at the end of each line, including
8035 the last line is a single @code{LF} character (@code{16#0A#}).
8036
8037 @sp 1
8038 @cartouche
8039 @noindent
8040 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8041 @end cartouche
8042 @noindent
8043 The implementation defined check name Alignment_Check controls checking of
8044 address clause values for proper alignment (that is, the address supplied
8045 must be consistent with the alignment of the type).
8046
8047 In addition, a user program can add implementation-defined check names
8048 by means of the pragma Check_Name.
8049
8050 @sp 1
8051 @cartouche
8052 @noindent
8053 @strong{43}.  The interpretation of each aspect of representation.  See
8054 13.1(20).
8055 @end cartouche
8056 @noindent
8057 See separate section on data representations.
8058
8059 @sp 1
8060 @cartouche
8061 @noindent
8062 @strong{44}.  Any restrictions placed upon representation items.  See
8063 13.1(20).
8064 @end cartouche
8065 @noindent
8066 See separate section on data representations.
8067
8068 @sp 1
8069 @cartouche
8070 @noindent
8071 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8072 13.3(48).
8073 @end cartouche
8074 @noindent
8075 Size for an indefinite subtype is the maximum possible size, except that
8076 for the case of a subprogram parameter, the size of the parameter object
8077 is the actual size.
8078
8079 @sp 1
8080 @cartouche
8081 @noindent
8082 @strong{46}.  The default external representation for a type tag.  See
8083 13.3(75).
8084 @end cartouche
8085 @noindent
8086 The default external representation for a type tag is the fully expanded
8087 name of the type in upper case letters.
8088
8089 @sp 1
8090 @cartouche
8091 @noindent
8092 @strong{47}.  What determines whether a compilation unit is the same in
8093 two different partitions.  See 13.3(76).
8094 @end cartouche
8095 @noindent
8096 A compilation unit is the same in two different partitions if and only
8097 if it derives from the same source file.
8098
8099 @sp 1
8100 @cartouche
8101 @noindent
8102 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8103 @end cartouche
8104 @noindent
8105 The only implementation defined component is the tag for a tagged type,
8106 which contains a pointer to the dispatching table.
8107
8108 @sp 1
8109 @cartouche
8110 @noindent
8111 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8112 ordering.  See 13.5.3(5).
8113 @end cartouche
8114 @noindent
8115 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8116 implementation, so no non-default bit ordering is supported.  The default
8117 bit ordering corresponds to the natural endianness of the target architecture.
8118
8119 @sp 1
8120 @cartouche
8121 @noindent
8122 @strong{50}.  The contents of the visible part of package @code{System}
8123 and its language-defined children.  See 13.7(2).
8124 @end cartouche
8125 @noindent
8126 See the definition of these packages in files @file{system.ads} and
8127 @file{s-stoele.ads}.
8128
8129 @sp 1
8130 @cartouche
8131 @noindent
8132 @strong{51}.  The contents of the visible part of package
8133 @code{System.Machine_Code}, and the meaning of
8134 @code{code_statements}.  See 13.8(7).
8135 @end cartouche
8136 @noindent
8137 See the definition and documentation in file @file{s-maccod.ads}.
8138
8139 @sp 1
8140 @cartouche
8141 @noindent
8142 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8143 @end cartouche
8144 @noindent
8145 Unchecked conversion between types of the same size
8146 results in an uninterpreted transmission of the bits from one type
8147 to the other.  If the types are of unequal sizes, then in the case of
8148 discrete types, a shorter source is first zero or sign extended as
8149 necessary, and a shorter target is simply truncated on the left.
8150 For all non-discrete types, the source is first copied if necessary
8151 to ensure that the alignment requirements of the target are met, then
8152 a pointer is constructed to the source value, and the result is obtained
8153 by dereferencing this pointer after converting it to be a pointer to the
8154 target type. Unchecked conversions where the target subtype is an
8155 unconstrained array are not permitted. If the target alignment is
8156 greater than the source alignment, then a copy of the result is
8157 made with appropriate alignment
8158
8159 @sp 1
8160 @cartouche
8161 @noindent
8162 @strong{53}.  The manner of choosing a storage pool for an access type
8163 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8164 @end cartouche
8165 @noindent
8166 There are 3 different standard pools used by the compiler when
8167 @code{Storage_Pool} is not specified depending whether the type is local
8168 to a subprogram or defined at the library level and whether
8169 @code{Storage_Size}is specified or not.  See documentation in the runtime
8170 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8171 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8172 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8173 default pools used.
8174
8175 @sp 1
8176 @cartouche
8177 @noindent
8178 @strong{54}.  Whether or not the implementation provides user-accessible
8179 names for the standard pool type(s).  See 13.11(17).
8180 @end cartouche
8181 @noindent
8182
8183 See documentation in the sources of the run time mentioned in paragraph
8184 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8185 these units.
8186
8187 @sp 1
8188 @cartouche
8189 @noindent
8190 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8191 @end cartouche
8192 @noindent
8193 @code{Storage_Size} is measured in storage units, and refers to the
8194 total space available for an access type collection, or to the primary
8195 stack space for a task.
8196
8197 @sp 1
8198 @cartouche
8199 @noindent
8200 @strong{56}.  Implementation-defined aspects of storage pools.  See
8201 13.11(22).
8202 @end cartouche
8203 @noindent
8204 See documentation in the sources of the run time mentioned in paragraph
8205 @strong{53} for details on GNAT-defined aspects of storage pools.
8206
8207 @sp 1
8208 @cartouche
8209 @noindent
8210 @strong{57}.  The set of restrictions allowed in a pragma
8211 @code{Restrictions}.  See 13.12(7).
8212 @end cartouche
8213 @noindent
8214 All RM defined Restriction identifiers are implemented.  The following
8215 additional restriction identifiers are provided.  There are two separate
8216 lists of implementation dependent restriction identifiers.  The first
8217 set requires consistency throughout a partition (in other words, if the
8218 restriction identifier is used for any compilation unit in the partition,
8219 then all compilation units in the partition must obey the restriction.
8220
8221 @table @code
8222
8223 @item Simple_Barriers
8224 @findex Simple_Barriers
8225 This restriction ensures at compile time that barriers in entry declarations
8226 for protected types are restricted to either static boolean expressions or
8227 references to simple boolean variables defined in the private part of the
8228 protected type.  No other form of entry barriers is permitted.  This is one
8229 of the restrictions of the Ravenscar profile for limited tasking (see also
8230 pragma @code{Profile (Ravenscar)}).
8231
8232 @item Max_Entry_Queue_Length => Expr
8233 @findex Max_Entry_Queue_Length
8234 This restriction is a declaration that any protected entry compiled in
8235 the scope of the restriction has at most the specified number of
8236 tasks waiting on the entry
8237 at any one time, and so no queue is required.  This restriction is not
8238 checked at compile time.  A program execution is erroneous if an attempt
8239 is made to queue more than the specified number of tasks on such an entry.
8240
8241 @item No_Calendar
8242 @findex No_Calendar
8243 This restriction ensures at compile time that there is no implicit or
8244 explicit dependence on the package @code{Ada.Calendar}.
8245
8246 @item No_Default_Initialization
8247 @findex No_Default_Initialization
8248
8249 This restriction prohibits any instance of default initialization of variables.
8250 The binder implements a consistency rule which prevents any unit compiled
8251 without the restriction from with'ing a unit with the restriction (this allows
8252 the generation of initialization procedures to be skipped, since you can be
8253 sure that no call is ever generated to an initialization procedure in a unit
8254 with the restriction active). If used in conjunction with Initialize_Scalars or
8255 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8256 without a specific initializer (including the case of OUT scalar parameters).
8257
8258 @item No_Direct_Boolean_Operators
8259 @findex No_Direct_Boolean_Operators
8260 This restriction ensures that no logical (and/or/xor) or comparison
8261 operators are used on operands of type Boolean (or any type derived
8262 from Boolean). This is intended for use in safety critical programs
8263 where the certification protocol requires the use of short-circuit
8264 (and then, or else) forms for all composite boolean operations.
8265
8266 @item No_Dispatching_Calls
8267 @findex No_Dispatching_Calls
8268 This restriction ensures at compile time that the code generated by the
8269 compiler involves no dispatching calls. The use of this restriction allows the
8270 safe use of record extensions, classwide membership tests and other classwide
8271 features not involving implicit dispatching. This restriction ensures that
8272 the code contains no indirect calls through a dispatching mechanism. Note that
8273 this includes internally-generated calls created by the compiler, for example
8274 in the implementation of class-wide objects assignments. The
8275 membership test is allowed in the presence of this restriction, because its
8276 implementation requires no dispatching.
8277 This restriction is comparable to the official Ada restriction
8278 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8279 all classwide constructs that do not imply dispatching.
8280 The following example indicates constructs that violate this restriction.
8281
8282 @smallexample
8283 package Pkg is
8284   type T is tagged record
8285     Data : Natural;
8286   end record;
8287   procedure P (X : T);
8288
8289   type DT is new T with record
8290     More_Data : Natural;
8291   end record;
8292   procedure Q (X : DT);
8293 end Pkg;
8294
8295 with Pkg; use Pkg;
8296 procedure Example is
8297   procedure Test (O : T'Class) is
8298     N : Natural  := O'Size;--  Error: Dispatching call
8299     C : T'Class := O;      --  Error: implicit Dispatching Call
8300   begin
8301     if O in DT'Class then  --  OK   : Membership test
8302        Q (DT (O));         --  OK   : Type conversion plus direct call
8303     else
8304        P (O);              --  Error: Dispatching call
8305     end if;
8306   end Test;
8307
8308   Obj : DT;
8309 begin
8310   P (Obj);                 --  OK   : Direct call
8311   P (T (Obj));             --  OK   : Type conversion plus direct call
8312   P (T'Class (Obj));       --  Error: Dispatching call
8313
8314   Test (Obj);              --  OK   : Type conversion
8315
8316   if Obj in T'Class then   --  OK   : Membership test
8317      null;
8318   end if;
8319 end Example;
8320 @end smallexample
8321
8322 @item No_Dynamic_Attachment
8323 @findex No_Dynamic_Attachment
8324 This restriction ensures that there is no call to any of the operations
8325 defined in package Ada.Interrupts.
8326
8327 @item No_Enumeration_Maps
8328 @findex No_Enumeration_Maps
8329 This restriction ensures at compile time that no operations requiring
8330 enumeration maps are used (that is Image and Value attributes applied
8331 to enumeration types).
8332
8333 @item No_Entry_Calls_In_Elaboration_Code
8334 @findex No_Entry_Calls_In_Elaboration_Code
8335 This restriction ensures at compile time that no task or protected entry
8336 calls are made during elaboration code.  As a result of the use of this
8337 restriction, the compiler can assume that no code past an accept statement
8338 in a task can be executed at elaboration time.
8339
8340 @item No_Exception_Handlers
8341 @findex No_Exception_Handlers
8342 This restriction ensures at compile time that there are no explicit
8343 exception handlers. It also indicates that no exception propagation will
8344 be provided. In this mode, exceptions may be raised but will result in
8345 an immediate call to the last chance handler, a routine that the user
8346 must define with the following profile:
8347
8348 @smallexample @c ada
8349 procedure Last_Chance_Handler
8350   (Source_Location : System.Address; Line : Integer);
8351 pragma Export (C, Last_Chance_Handler,
8352                "__gnat_last_chance_handler");
8353 @end smallexample
8354
8355 The parameter is a C null-terminated string representing a message to be
8356 associated with the exception (typically the source location of the raise
8357 statement generated by the compiler). The Line parameter when nonzero
8358 represents the line number in the source program where the raise occurs.
8359
8360 @item No_Exception_Propagation
8361 @findex No_Exception_Propagation
8362 This restriction guarantees that exceptions are never propagated to an outer
8363 subprogram scope). The only case in which an exception may be raised is when
8364 the handler is statically in the same subprogram, so that the effect of a raise
8365 is essentially like a goto statement. Any other raise statement (implicit or
8366 explicit) will be considered unhandled. Exception handlers are allowed, but may
8367 not contain an exception occurrence identifier (exception choice). In addition
8368 use of the package GNAT.Current_Exception is not permitted, and reraise
8369 statements (raise with no operand) are not permitted.
8370
8371 @item No_Exception_Registration
8372 @findex No_Exception_Registration
8373 This restriction ensures at compile time that no stream operations for
8374 types Exception_Id or Exception_Occurrence are used. This also makes it
8375 impossible to pass exceptions to or from a partition with this restriction
8376 in a distributed environment. If this exception is active, then the generated
8377 code is simplified by omitting the otherwise-required global registration
8378 of exceptions when they are declared.
8379
8380 @item No_Implicit_Conditionals
8381 @findex No_Implicit_Conditionals
8382 This restriction ensures that the generated code does not contain any
8383 implicit conditionals, either by modifying the generated code where possible,
8384 or by rejecting any construct that would otherwise generate an implicit
8385 conditional. Note that this check does not include run time constraint
8386 checks, which on some targets may generate implicit conditionals as
8387 well. To control the latter, constraint checks can be suppressed in the
8388 normal manner. Constructs generating implicit conditionals include comparisons
8389 of composite objects and the Max/Min attributes.
8390
8391 @item No_Implicit_Dynamic_Code
8392 @findex No_Implicit_Dynamic_Code
8393 @cindex trampoline
8394 This restriction prevents the compiler from building ``trampolines''.
8395 This is a structure that is built on the stack and contains dynamic
8396 code to be executed at run time. On some targets, a trampoline is
8397 built for the following features: @code{Access},
8398 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8399 nested task bodies; primitive operations of nested tagged types.
8400 Trampolines do not work on machines that prevent execution of stack
8401 data. For example, on windows systems, enabling DEP (data execution
8402 protection) will cause trampolines to raise an exception.
8403 Trampolines are also quite slow at run time.
8404
8405 On many targets, trampolines have been largely eliminated. Look at the
8406 version of system.ads for your target --- if it has
8407 Always_Compatible_Rep equal to False, then trampolines are largely
8408 eliminated. In particular, a trampoline is built for the following
8409 features: @code{Address} of a nested subprogram;
8410 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8411 but only if pragma Favor_Top_Level applies, or the access type has a
8412 foreign-language convention; primitive operations of nested tagged
8413 types.
8414
8415 @item No_Implicit_Loops
8416 @findex No_Implicit_Loops
8417 This restriction ensures that the generated code does not contain any
8418 implicit @code{for} loops, either by modifying
8419 the generated code where possible,
8420 or by rejecting any construct that would otherwise generate an implicit
8421 @code{for} loop. If this restriction is active, it is possible to build
8422 large array aggregates with all static components without generating an
8423 intermediate temporary, and without generating a loop to initialize individual
8424 components. Otherwise, a loop is created for arrays larger than about 5000
8425 scalar components.
8426
8427 @item No_Initialize_Scalars
8428 @findex No_Initialize_Scalars
8429 This restriction ensures that no unit in the partition is compiled with
8430 pragma Initialize_Scalars. This allows the generation of more efficient
8431 code, and in particular eliminates dummy null initialization routines that
8432 are otherwise generated for some record and array types.
8433
8434 @item No_Local_Protected_Objects
8435 @findex No_Local_Protected_Objects
8436 This restriction ensures at compile time that protected objects are
8437 only declared at the library level.
8438
8439 @item No_Protected_Type_Allocators
8440 @findex No_Protected_Type_Allocators
8441 This restriction ensures at compile time that there are no allocator
8442 expressions that attempt to allocate protected objects.
8443
8444 @item No_Secondary_Stack
8445 @findex No_Secondary_Stack
8446 This restriction ensures at compile time that the generated code does not
8447 contain any reference to the secondary stack.  The secondary stack is used
8448 to implement functions returning unconstrained objects (arrays or records)
8449 on some targets.
8450
8451 @item No_Select_Statements
8452 @findex No_Select_Statements
8453 This restriction ensures at compile time no select statements of any kind
8454 are permitted, that is the keyword @code{select} may not appear.
8455 This is one of the restrictions of the Ravenscar
8456 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8457
8458 @item No_Standard_Storage_Pools
8459 @findex No_Standard_Storage_Pools
8460 This restriction ensures at compile time that no access types
8461 use the standard default storage pool.  Any access type declared must
8462 have an explicit Storage_Pool attribute defined specifying a
8463 user-defined storage pool.
8464
8465 @item No_Streams
8466 @findex No_Streams
8467 This restriction ensures at compile/bind time that there are no
8468 stream objects created (and therefore no actual stream operations).
8469 This restriction does not forbid dependences on the package
8470 @code{Ada.Streams}. So it is permissible to with
8471 @code{Ada.Streams} (or another package that does so itself)
8472 as long as no actual stream objects are created.
8473
8474 @item No_Task_Attributes_Package
8475 @findex No_Task_Attributes_Package
8476 This restriction ensures at compile time that there are no implicit or
8477 explicit dependencies on the package @code{Ada.Task_Attributes}.
8478
8479 @item No_Task_Termination
8480 @findex No_Task_Termination
8481 This restriction ensures at compile time that no terminate alternatives
8482 appear in any task body.
8483
8484 @item No_Tasking
8485 @findex No_Tasking
8486 This restriction prevents the declaration of tasks or task types throughout
8487 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8488 except that violations are caught at compile time and cause an error message
8489 to be output either by the compiler or binder.
8490
8491 @item Static_Priorities
8492 @findex Static_Priorities
8493 This restriction ensures at compile time that all priority expressions
8494 are static, and that there are no dependencies on the package
8495 @code{Ada.Dynamic_Priorities}.
8496
8497 @item Static_Storage_Size
8498 @findex Static_Storage_Size
8499 This restriction ensures at compile time that any expression appearing
8500 in a Storage_Size pragma or attribute definition clause is static.
8501
8502 @end table
8503
8504 @noindent
8505 The second set of implementation dependent restriction identifiers
8506 does not require partition-wide consistency.
8507 The restriction may be enforced for a single
8508 compilation unit without any effect on any of the
8509 other compilation units in the partition.
8510
8511 @table @code
8512
8513 @item No_Elaboration_Code
8514 @findex No_Elaboration_Code
8515 This restriction ensures at compile time that no elaboration code is
8516 generated.  Note that this is not the same condition as is enforced
8517 by pragma @code{Preelaborate}.  There are cases in which pragma
8518 @code{Preelaborate} still permits code to be generated (e.g.@: code
8519 to initialize a large array to all zeroes), and there are cases of units
8520 which do not meet the requirements for pragma @code{Preelaborate},
8521 but for which no elaboration code is generated.  Generally, it is
8522 the case that preelaborable units will meet the restrictions, with
8523 the exception of large aggregates initialized with an others_clause,
8524 and exception declarations (which generate calls to a run-time
8525 registry procedure).  This restriction is enforced on
8526 a unit by unit basis, it need not be obeyed consistently
8527 throughout a partition.
8528
8529 In the case of aggregates with others, if the aggregate has a dynamic
8530 size, there is no way to eliminate the elaboration code (such dynamic
8531 bounds would be incompatible with @code{Preelaborate} in any case). If
8532 the bounds are static, then use of this restriction actually modifies
8533 the code choice of the compiler to avoid generating a loop, and instead
8534 generate the aggregate statically if possible, no matter how many times
8535 the data for the others clause must be repeatedly generated.
8536
8537 It is not possible to precisely document
8538 the constructs which are compatible with this restriction, since,
8539 unlike most other restrictions, this is not a restriction on the
8540 source code, but a restriction on the generated object code. For
8541 example, if the source contains a declaration:
8542
8543 @smallexample
8544    Val : constant Integer := X;
8545 @end smallexample
8546
8547 @noindent
8548 where X is not a static constant, it may be possible, depending
8549 on complex optimization circuitry, for the compiler to figure
8550 out the value of X at compile time, in which case this initialization
8551 can be done by the loader, and requires no initialization code. It
8552 is not possible to document the precise conditions under which the
8553 optimizer can figure this out.
8554
8555 Note that this the implementation of this restriction requires full
8556 code generation. If it is used in conjunction with "semantics only"
8557 checking, then some cases of violations may be missed.
8558
8559 @item No_Entry_Queue
8560 @findex No_Entry_Queue
8561 This restriction is a declaration that any protected entry compiled in
8562 the scope of the restriction has at most one task waiting on the entry
8563 at any one time, and so no queue is required.  This restriction is not
8564 checked at compile time.  A program execution is erroneous if an attempt
8565 is made to queue a second task on such an entry.
8566
8567 @item No_Implementation_Attributes
8568 @findex No_Implementation_Attributes
8569 This restriction checks at compile time that no GNAT-defined attributes
8570 are present.  With this restriction, the only attributes that can be used
8571 are those defined in the Ada Reference Manual.
8572
8573 @item No_Implementation_Pragmas
8574 @findex No_Implementation_Pragmas
8575 This restriction checks at compile time that no GNAT-defined pragmas
8576 are present.  With this restriction, the only pragmas that can be used
8577 are those defined in the Ada Reference Manual.
8578
8579 @item No_Implementation_Restrictions
8580 @findex No_Implementation_Restrictions
8581 This restriction checks at compile time that no GNAT-defined restriction
8582 identifiers (other than @code{No_Implementation_Restrictions} itself)
8583 are present.  With this restriction, the only other restriction identifiers
8584 that can be used are those defined in the Ada Reference Manual.
8585
8586 @item No_Wide_Characters
8587 @findex No_Wide_Characters
8588 This restriction ensures at compile time that no uses of the types
8589 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8590 wide types
8591 appear, and that no wide or wide wide string or character literals
8592 appear in the program (that is literals representing characters not in
8593 type @code{Character}.
8594
8595 @end table
8596
8597 @sp 1
8598 @cartouche
8599 @noindent
8600 @strong{58}.  The consequences of violating limitations on
8601 @code{Restrictions} pragmas.  See 13.12(9).
8602 @end cartouche
8603 @noindent
8604 Restrictions that can be checked at compile time result in illegalities
8605 if violated.  Currently there are no other consequences of violating
8606 restrictions.
8607
8608 @sp 1
8609 @cartouche
8610 @noindent
8611 @strong{59}.  The representation used by the @code{Read} and
8612 @code{Write} attributes of elementary types in terms of stream
8613 elements.  See 13.13.2(9).
8614 @end cartouche
8615 @noindent
8616 The representation is the in-memory representation of the base type of
8617 the type, using the number of bits corresponding to the
8618 @code{@var{type}'Size} value, and the natural ordering of the machine.
8619
8620 @sp 1
8621 @cartouche
8622 @noindent
8623 @strong{60}.  The names and characteristics of the numeric subtypes
8624 declared in the visible part of package @code{Standard}.  See A.1(3).
8625 @end cartouche
8626 @noindent
8627 See items describing the integer and floating-point types supported.
8628
8629 @sp 1
8630 @cartouche
8631 @noindent
8632 @strong{61}.  The accuracy actually achieved by the elementary
8633 functions.  See A.5.1(1).
8634 @end cartouche
8635 @noindent
8636 The elementary functions correspond to the functions available in the C
8637 library.  Only fast math mode is implemented.
8638
8639 @sp 1
8640 @cartouche
8641 @noindent
8642 @strong{62}.  The sign of a zero result from some of the operators or
8643 functions in @code{Numerics.Generic_Elementary_Functions}, when
8644 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8645 @end cartouche
8646 @noindent
8647 The sign of zeroes follows the requirements of the IEEE 754 standard on
8648 floating-point.
8649
8650 @sp 1
8651 @cartouche
8652 @noindent
8653 @strong{63}.  The value of
8654 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8655 @end cartouche
8656 @noindent
8657 Maximum image width is 649, see library file @file{a-numran.ads}.
8658
8659 @sp 1
8660 @cartouche
8661 @noindent
8662 @strong{64}.  The value of
8663 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8664 @end cartouche
8665 @noindent
8666 Maximum image width is 80, see library file @file{a-nudira.ads}.
8667
8668 @sp 1
8669 @cartouche
8670 @noindent
8671 @strong{65}.  The algorithms for random number generation.  See
8672 A.5.2(32).
8673 @end cartouche
8674 @noindent
8675 The algorithm is documented in the source files @file{a-numran.ads} and
8676 @file{a-numran.adb}.
8677
8678 @sp 1
8679 @cartouche
8680 @noindent
8681 @strong{66}.  The string representation of a random number generator's
8682 state.  See A.5.2(38).
8683 @end cartouche
8684 @noindent
8685 See the documentation contained in the file @file{a-numran.adb}.
8686
8687 @sp 1
8688 @cartouche
8689 @noindent
8690 @strong{67}.  The minimum time interval between calls to the
8691 time-dependent Reset procedure that are guaranteed to initiate different
8692 random number sequences.  See A.5.2(45).
8693 @end cartouche
8694 @noindent
8695 The minimum period between reset calls to guarantee distinct series of
8696 random numbers is one microsecond.
8697
8698 @sp 1
8699 @cartouche
8700 @noindent
8701 @strong{68}.  The values of the @code{Model_Mantissa},
8702 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8703 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8704 Annex is not supported.  See A.5.3(72).
8705 @end cartouche
8706 @noindent
8707 See the source file @file{ttypef.ads} for the values of all numeric
8708 attributes.
8709
8710 @sp 1
8711 @cartouche
8712 @noindent
8713 @strong{69}.  Any implementation-defined characteristics of the
8714 input-output packages.  See A.7(14).
8715 @end cartouche
8716 @noindent
8717 There are no special implementation defined characteristics for these
8718 packages.
8719
8720 @sp 1
8721 @cartouche
8722 @noindent
8723 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8724 A.9(10).
8725 @end cartouche
8726 @noindent
8727 All type representations are contiguous, and the @code{Buffer_Size} is
8728 the value of @code{@var{type}'Size} rounded up to the next storage unit
8729 boundary.
8730
8731 @sp 1
8732 @cartouche
8733 @noindent
8734 @strong{71}.  External files for standard input, standard output, and
8735 standard error See A.10(5).
8736 @end cartouche
8737 @noindent
8738 These files are mapped onto the files provided by the C streams
8739 libraries.  See source file @file{i-cstrea.ads} for further details.
8740
8741 @sp 1
8742 @cartouche
8743 @noindent
8744 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8745 A.10.9(36).
8746 @end cartouche
8747 @noindent
8748 If more digits are requested in the output than are represented by the
8749 precision of the value, zeroes are output in the corresponding least
8750 significant digit positions.
8751
8752 @sp 1
8753 @cartouche
8754 @noindent
8755 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8756 @code{Command_Name}.  See A.15(1).
8757 @end cartouche
8758 @noindent
8759 These are mapped onto the @code{argv} and @code{argc} parameters of the
8760 main program in the natural manner.
8761
8762 @sp 1
8763 @cartouche
8764 @noindent
8765 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8766 @end cartouche
8767 @noindent
8768 The following convention names are supported
8769
8770 @table @code
8771 @item  Ada
8772 Ada
8773 @item Assembler
8774 Assembly language
8775 @item Asm
8776 Synonym for Assembler
8777 @item Assembly
8778 Synonym for Assembler
8779 @item C
8780 C
8781 @item C_Pass_By_Copy
8782 Allowed only for record types, like C, but also notes that record
8783 is to be passed by copy rather than reference.
8784 @item COBOL
8785 COBOL
8786 @item C_Plus_Plus (or CPP)
8787 C++
8788 @item Default
8789 Treated the same as C
8790 @item External
8791 Treated the same as C
8792 @item Fortran
8793 Fortran
8794 @item Intrinsic
8795 For support of pragma @code{Import} with convention Intrinsic, see
8796 separate section on Intrinsic Subprograms.
8797 @item Stdcall
8798 Stdcall (used for Windows implementations only).  This convention correspond
8799 to the WINAPI (previously called Pascal convention) C/C++ convention under
8800 Windows.  A function with this convention cleans the stack before exit.
8801 @item DLL
8802 Synonym for Stdcall
8803 @item Win32
8804 Synonym for Stdcall
8805 @item Stubbed
8806 Stubbed is a special convention used to indicate that the body of the
8807 subprogram will be entirely ignored.  Any call to the subprogram
8808 is converted into a raise of the @code{Program_Error} exception.  If a
8809 pragma @code{Import} specifies convention @code{stubbed} then no body need
8810 be present at all.  This convention is useful during development for the
8811 inclusion of subprograms whose body has not yet been written.
8812
8813 @end table
8814 @noindent
8815 In addition, all otherwise unrecognized convention names are also
8816 treated as being synonymous with convention C@.  In all implementations
8817 except for VMS, use of such other names results in a warning.  In VMS
8818 implementations, these names are accepted silently.
8819
8820 @sp 1
8821 @cartouche
8822 @noindent
8823 @strong{75}.  The meaning of link names.  See B.1(36).
8824 @end cartouche
8825 @noindent
8826 Link names are the actual names used by the linker.
8827
8828 @sp 1
8829 @cartouche
8830 @noindent
8831 @strong{76}.  The manner of choosing link names when neither the link
8832 name nor the address of an imported or exported entity is specified.  See
8833 B.1(36).
8834 @end cartouche
8835 @noindent
8836 The default linker name is that which would be assigned by the relevant
8837 external language, interpreting the Ada name as being in all lower case
8838 letters.
8839
8840 @sp 1
8841 @cartouche
8842 @noindent
8843 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8844 @end cartouche
8845 @noindent
8846 The string passed to @code{Linker_Options} is presented uninterpreted as
8847 an argument to the link command, unless it contains ASCII.NUL characters.
8848 NUL characters if they appear act as argument separators, so for example
8849
8850 @smallexample @c ada
8851 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8852 @end smallexample
8853
8854 @noindent
8855 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8856 linker. The order of linker options is preserved for a given unit. The final
8857 list of options passed to the linker is in reverse order of the elaboration
8858 order. For example, linker options for a body always appear before the options
8859 from the corresponding package spec.
8860
8861 @sp 1
8862 @cartouche
8863 @noindent
8864 @strong{78}.  The contents of the visible part of package
8865 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8866 @end cartouche
8867 @noindent
8868 See files with prefix @file{i-} in the distributed library.
8869
8870 @sp 1
8871 @cartouche
8872 @noindent
8873 @strong{79}.  Implementation-defined children of package
8874 @code{Interfaces}.  The contents of the visible part of package
8875 @code{Interfaces}.  See B.2(11).
8876 @end cartouche
8877 @noindent
8878 See files with prefix @file{i-} in the distributed library.
8879
8880 @sp 1
8881 @cartouche
8882 @noindent
8883 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8884 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8885 @code{COBOL_Character}; and the initialization of the variables
8886 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8887 @code{Interfaces.COBOL}.  See B.4(50).
8888 @end cartouche
8889 @noindent
8890 @table @code
8891 @item Floating
8892 Float
8893 @item Long_Floating
8894 (Floating) Long_Float
8895 @item Binary
8896 Integer
8897 @item Long_Binary
8898 Long_Long_Integer
8899 @item Decimal_Element
8900 Character
8901 @item COBOL_Character
8902 Character
8903 @end table
8904
8905 @noindent
8906 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8907
8908 @sp 1
8909 @cartouche
8910 @noindent
8911 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8912 @end cartouche
8913 @noindent
8914 See documentation in file @file{s-maccod.ads} in the distributed library.
8915
8916 @sp 1
8917 @cartouche
8918 @noindent
8919 @strong{82}.  Implementation-defined aspects of access to machine
8920 operations.  See C.1(9).
8921 @end cartouche
8922 @noindent
8923 See documentation in file @file{s-maccod.ads} in the distributed library.
8924
8925 @sp 1
8926 @cartouche
8927 @noindent
8928 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8929 @end cartouche
8930 @noindent
8931 Interrupts are mapped to signals or conditions as appropriate.  See
8932 definition of unit
8933 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8934 on the interrupts supported on a particular target.
8935
8936 @sp 1
8937 @cartouche
8938 @noindent
8939 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8940 C.4(13).
8941 @end cartouche
8942 @noindent
8943 GNAT does not permit a partition to be restarted without reloading,
8944 except under control of the debugger.
8945
8946 @sp 1
8947 @cartouche
8948 @noindent
8949 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8950 @end cartouche
8951 @noindent
8952 Pragma @code{Discard_Names} causes names of enumeration literals to
8953 be suppressed.  In the presence of this pragma, the Image attribute
8954 provides the image of the Pos of the literal, and Value accepts
8955 Pos values.
8956
8957 @sp 1
8958 @cartouche
8959 @noindent
8960 @strong{86}.  The result of the @code{Task_Identification.Image}
8961 attribute.  See C.7.1(7).
8962 @end cartouche
8963 @noindent
8964 The result of this attribute is a string that identifies
8965 the object or component that denotes a given task. If a variable @code{Var}
8966 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
8967 where the suffix
8968 is the hexadecimal representation of the virtual address of the corresponding
8969 task control block. If the variable is an array of tasks, the image of each
8970 task will have the form of an indexed component indicating the position of a
8971 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
8972 component of a record, the image of the task will have the form of a selected
8973 component. These rules are fully recursive, so that the image of a task that
8974 is a subcomponent of a composite object corresponds to the expression that
8975 designates this task.
8976 @noindent
8977 If a task is created by an allocator, its image depends on the context. If the
8978 allocator is part of an object declaration, the rules described above are used
8979 to construct its image, and this image is not affected by subsequent
8980 assignments. If the allocator appears within an expression, the image
8981 includes only the name of the task type.
8982 @noindent
8983 If the configuration pragma Discard_Names is present, or if the restriction
8984 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8985 the numeric suffix, that is to say the hexadecimal representation of the
8986 virtual address of the control block of the task.
8987 @sp 1
8988 @cartouche
8989 @noindent
8990 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8991 or interrupt handler.  See C.7.1(17).
8992 @end cartouche
8993 @noindent
8994 Protected entries or interrupt handlers can be executed by any
8995 convenient thread, so the value of @code{Current_Task} is undefined.
8996
8997 @sp 1
8998 @cartouche
8999 @noindent
9000 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9001 body or interrupt handler.  See C.7.1(19).
9002 @end cartouche
9003 @noindent
9004 The effect of calling @code{Current_Task} from an entry body or
9005 interrupt handler is to return the identification of the task currently
9006 executing the code.
9007
9008 @sp 1
9009 @cartouche
9010 @noindent
9011 @strong{89}.  Implementation-defined aspects of
9012 @code{Task_Attributes}.  See C.7.2(19).
9013 @end cartouche
9014 @noindent
9015 There are no implementation-defined aspects of @code{Task_Attributes}.
9016
9017 @sp 1
9018 @cartouche
9019 @noindent
9020 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9021 @end cartouche
9022 @noindent
9023 The metrics information for GNAT depends on the performance of the
9024 underlying operating system.  The sources of the run-time for tasking
9025 implementation, together with the output from @option{-gnatG} can be
9026 used to determine the exact sequence of operating systems calls made
9027 to implement various tasking constructs.  Together with appropriate
9028 information on the performance of the underlying operating system,
9029 on the exact target in use, this information can be used to determine
9030 the required metrics.
9031
9032 @sp 1
9033 @cartouche
9034 @noindent
9035 @strong{91}.  The declarations of @code{Any_Priority} and
9036 @code{Priority}.  See D.1(11).
9037 @end cartouche
9038 @noindent
9039 See declarations in file @file{system.ads}.
9040
9041 @sp 1
9042 @cartouche
9043 @noindent
9044 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9045 @end cartouche
9046 @noindent
9047 There are no implementation-defined execution resources.
9048
9049 @sp 1
9050 @cartouche
9051 @noindent
9052 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9053 access to a protected object keeps its processor busy.  See D.2.1(3).
9054 @end cartouche
9055 @noindent
9056 On a multi-processor, a task that is waiting for access to a protected
9057 object does not keep its processor busy.
9058
9059 @sp 1
9060 @cartouche
9061 @noindent
9062 @strong{94}.  The affect of implementation defined execution resources
9063 on task dispatching.  See D.2.1(9).
9064 @end cartouche
9065 @noindent
9066 @c SGI info
9067 @ignore
9068 Tasks map to IRIX threads, and the dispatching policy is as defined by
9069 the IRIX implementation of threads.
9070 @end ignore
9071 Tasks map to threads in the threads package used by GNAT@.  Where possible
9072 and appropriate, these threads correspond to native threads of the
9073 underlying operating system.
9074
9075 @sp 1
9076 @cartouche
9077 @noindent
9078 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9079 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9080 @end cartouche
9081 @noindent
9082 There are no implementation-defined policy-identifiers allowed in this
9083 pragma.
9084
9085 @sp 1
9086 @cartouche
9087 @noindent
9088 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9089 D.2.2(16).
9090 @end cartouche
9091 @noindent
9092 Execution of a task cannot be preempted by the implementation processing
9093 of delay expirations for lower priority tasks.
9094
9095 @sp 1
9096 @cartouche
9097 @noindent
9098 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9099 @end cartouche
9100 @noindent
9101 @c SGI info:
9102 @ignore
9103 Tasks map to IRIX threads, and the dispatching policy is as defined by
9104 the IRIX implementation of threads.
9105 @end ignore
9106 The policy is the same as that of the underlying threads implementation.
9107
9108 @sp 1
9109 @cartouche
9110 @noindent
9111 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9112 in a pragma @code{Locking_Policy}.  See D.3(4).
9113 @end cartouche
9114 @noindent
9115 The only implementation defined policy permitted in GNAT is
9116 @code{Inheritance_Locking}.  On targets that support this policy, locking
9117 is implemented by inheritance, i.e.@: the task owning the lock operates
9118 at a priority equal to the highest priority of any task currently
9119 requesting the lock.
9120
9121 @sp 1
9122 @cartouche
9123 @noindent
9124 @strong{99}.  Default ceiling priorities.  See D.3(10).
9125 @end cartouche
9126 @noindent
9127 The ceiling priority of protected objects of the type
9128 @code{System.Interrupt_Priority'Last} as described in the Ada
9129 Reference Manual D.3(10),
9130
9131 @sp 1
9132 @cartouche
9133 @noindent
9134 @strong{100}.  The ceiling of any protected object used internally by
9135 the implementation.  See D.3(16).
9136 @end cartouche
9137 @noindent
9138 The ceiling priority of internal protected objects is
9139 @code{System.Priority'Last}.
9140
9141 @sp 1
9142 @cartouche
9143 @noindent
9144 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9145 @end cartouche
9146 @noindent
9147 There are no implementation-defined queuing policies.
9148
9149 @sp 1
9150 @cartouche
9151 @noindent
9152 @strong{102}.  On a multiprocessor, any conditions that cause the
9153 completion of an aborted construct to be delayed later than what is
9154 specified for a single processor.  See D.6(3).
9155 @end cartouche
9156 @noindent
9157 The semantics for abort on a multi-processor is the same as on a single
9158 processor, there are no further delays.
9159
9160 @sp 1
9161 @cartouche
9162 @noindent
9163 @strong{103}.  Any operations that implicitly require heap storage
9164 allocation.  See D.7(8).
9165 @end cartouche
9166 @noindent
9167 The only operation that implicitly requires heap storage allocation is
9168 task creation.
9169
9170 @sp 1
9171 @cartouche
9172 @noindent
9173 @strong{104}.  Implementation-defined aspects of pragma
9174 @code{Restrictions}.  See D.7(20).
9175 @end cartouche
9176 @noindent
9177 There are no such implementation-defined aspects.
9178
9179 @sp 1
9180 @cartouche
9181 @noindent
9182 @strong{105}.  Implementation-defined aspects of package
9183 @code{Real_Time}.  See D.8(17).
9184 @end cartouche
9185 @noindent
9186 There are no implementation defined aspects of package @code{Real_Time}.
9187
9188 @sp 1
9189 @cartouche
9190 @noindent
9191 @strong{106}.  Implementation-defined aspects of
9192 @code{delay_statements}.  See D.9(8).
9193 @end cartouche
9194 @noindent
9195 Any difference greater than one microsecond will cause the task to be
9196 delayed (see D.9(7)).
9197
9198 @sp 1
9199 @cartouche
9200 @noindent
9201 @strong{107}.  The upper bound on the duration of interrupt blocking
9202 caused by the implementation.  See D.12(5).
9203 @end cartouche
9204 @noindent
9205 The upper bound is determined by the underlying operating system.  In
9206 no cases is it more than 10 milliseconds.
9207
9208 @sp 1
9209 @cartouche
9210 @noindent
9211 @strong{108}.  The means for creating and executing distributed
9212 programs.  See E(5).
9213 @end cartouche
9214 @noindent
9215 The GLADE package provides a utility GNATDIST for creating and executing
9216 distributed programs.  See the GLADE reference manual for further details.
9217
9218 @sp 1
9219 @cartouche
9220 @noindent
9221 @strong{109}.  Any events that can result in a partition becoming
9222 inaccessible.  See E.1(7).
9223 @end cartouche
9224 @noindent
9225 See the GLADE reference manual for full details on such events.
9226
9227 @sp 1
9228 @cartouche
9229 @noindent
9230 @strong{110}.  The scheduling policies, treatment of priorities, and
9231 management of shared resources between partitions in certain cases.  See
9232 E.1(11).
9233 @end cartouche
9234 @noindent
9235 See the GLADE reference manual for full details on these aspects of
9236 multi-partition execution.
9237
9238 @sp 1
9239 @cartouche
9240 @noindent
9241 @strong{111}.  Events that cause the version of a compilation unit to
9242 change.  See E.3(5).
9243 @end cartouche
9244 @noindent
9245 Editing the source file of a compilation unit, or the source files of
9246 any units on which it is dependent in a significant way cause the version
9247 to change.  No other actions cause the version number to change.  All changes
9248 are significant except those which affect only layout, capitalization or
9249 comments.
9250
9251 @sp 1
9252 @cartouche
9253 @noindent
9254 @strong{112}.  Whether the execution of the remote subprogram is
9255 immediately aborted as a result of cancellation.  See E.4(13).
9256 @end cartouche
9257 @noindent
9258 See the GLADE reference manual for details on the effect of abort in
9259 a distributed application.
9260
9261 @sp 1
9262 @cartouche
9263 @noindent
9264 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9265 @end cartouche
9266 @noindent
9267 See the GLADE reference manual for a full description of all implementation
9268 defined aspects of the PCS@.
9269
9270 @sp 1
9271 @cartouche
9272 @noindent
9273 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9274 E.5(26).
9275 @end cartouche
9276 @noindent
9277 See the GLADE reference manual for a full description of all
9278 implementation defined interfaces.
9279
9280 @sp 1
9281 @cartouche
9282 @noindent
9283 @strong{115}.  The values of named numbers in the package
9284 @code{Decimal}.  See F.2(7).
9285 @end cartouche
9286 @noindent
9287 @table @code
9288 @item Max_Scale
9289 +18
9290 @item Min_Scale
9291 -18
9292 @item Min_Delta
9293 1.0E-18
9294 @item Max_Delta
9295 1.0E+18
9296 @item Max_Decimal_Digits
9297 18
9298 @end table
9299
9300 @sp 1
9301 @cartouche
9302 @noindent
9303 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9304 @code{Text_IO.Editing}.  See F.3.3(16).
9305 @end cartouche
9306 @noindent
9307 64
9308
9309 @sp 1
9310 @cartouche
9311 @noindent
9312 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9313 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9314 @end cartouche
9315 @noindent
9316 64
9317
9318 @sp 1
9319 @cartouche
9320 @noindent
9321 @strong{118}.  The accuracy actually achieved by the complex elementary
9322 functions and by other complex arithmetic operations.  See G.1(1).
9323 @end cartouche
9324 @noindent
9325 Standard library functions are used for the complex arithmetic
9326 operations.  Only fast math mode is currently supported.
9327
9328 @sp 1
9329 @cartouche
9330 @noindent
9331 @strong{119}.  The sign of a zero result (or a component thereof) from
9332 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9333 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9334 @end cartouche
9335 @noindent
9336 The signs of zero values are as recommended by the relevant
9337 implementation advice.
9338
9339 @sp 1
9340 @cartouche
9341 @noindent
9342 @strong{120}.  The sign of a zero result (or a component thereof) from
9343 any operator or function in
9344 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9345 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9346 @end cartouche
9347 @noindent
9348 The signs of zero values are as recommended by the relevant
9349 implementation advice.
9350
9351 @sp 1
9352 @cartouche
9353 @noindent
9354 @strong{121}.  Whether the strict mode or the relaxed mode is the
9355 default.  See G.2(2).
9356 @end cartouche
9357 @noindent
9358 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9359 provides a highly efficient implementation of strict mode.
9360
9361 @sp 1
9362 @cartouche
9363 @noindent
9364 @strong{122}.  The result interval in certain cases of fixed-to-float
9365 conversion.  See G.2.1(10).
9366 @end cartouche
9367 @noindent
9368 For cases where the result interval is implementation dependent, the
9369 accuracy is that provided by performing all operations in 64-bit IEEE
9370 floating-point format.
9371
9372 @sp 1
9373 @cartouche
9374 @noindent
9375 @strong{123}.  The result of a floating point arithmetic operation in
9376 overflow situations, when the @code{Machine_Overflows} attribute of the
9377 result type is @code{False}.  See G.2.1(13).
9378 @end cartouche
9379 @noindent
9380 Infinite and NaN values are produced as dictated by the IEEE
9381 floating-point standard.
9382
9383 Note that on machines that are not fully compliant with the IEEE
9384 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9385 must be used for achieving IEEE confirming behavior (although at the cost
9386 of a significant performance penalty), so infinite and NaN values are
9387 properly generated.
9388
9389 @sp 1
9390 @cartouche
9391 @noindent
9392 @strong{124}.  The result interval for division (or exponentiation by a
9393 negative exponent), when the floating point hardware implements division
9394 as multiplication by a reciprocal.  See G.2.1(16).
9395 @end cartouche
9396 @noindent
9397 Not relevant, division is IEEE exact.
9398
9399 @sp 1
9400 @cartouche
9401 @noindent
9402 @strong{125}.  The definition of close result set, which determines the
9403 accuracy of certain fixed point multiplications and divisions.  See
9404 G.2.3(5).
9405 @end cartouche
9406 @noindent
9407 Operations in the close result set are performed using IEEE long format
9408 floating-point arithmetic.  The input operands are converted to
9409 floating-point, the operation is done in floating-point, and the result
9410 is converted to the target type.
9411
9412 @sp 1
9413 @cartouche
9414 @noindent
9415 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9416 point multiplication or division for which the result shall be in the
9417 perfect result set.  See G.2.3(22).
9418 @end cartouche
9419 @noindent
9420 The result is only defined to be in the perfect result set if the result
9421 can be computed by a single scaling operation involving a scale factor
9422 representable in 64-bits.
9423
9424 @sp 1
9425 @cartouche
9426 @noindent
9427 @strong{127}.  The result of a fixed point arithmetic operation in
9428 overflow situations, when the @code{Machine_Overflows} attribute of the
9429 result type is @code{False}.  See G.2.3(27).
9430 @end cartouche
9431 @noindent
9432 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9433 types.
9434
9435 @sp 1
9436 @cartouche
9437 @noindent
9438 @strong{128}.  The result of an elementary function reference in
9439 overflow situations, when the @code{Machine_Overflows} attribute of the
9440 result type is @code{False}.  See G.2.4(4).
9441 @end cartouche
9442 @noindent
9443 IEEE infinite and Nan values are produced as appropriate.
9444
9445 @sp 1
9446 @cartouche
9447 @noindent
9448 @strong{129}.  The value of the angle threshold, within which certain
9449 elementary functions, complex arithmetic operations, and complex
9450 elementary functions yield results conforming to a maximum relative
9451 error bound.  See G.2.4(10).
9452 @end cartouche
9453 @noindent
9454 Information on this subject is not yet available.
9455
9456 @sp 1
9457 @cartouche
9458 @noindent
9459 @strong{130}.  The accuracy of certain elementary functions for
9460 parameters beyond the angle threshold.  See G.2.4(10).
9461 @end cartouche
9462 @noindent
9463 Information on this subject is not yet available.
9464
9465 @sp 1
9466 @cartouche
9467 @noindent
9468 @strong{131}.  The result of a complex arithmetic operation or complex
9469 elementary function reference in overflow situations, when the
9470 @code{Machine_Overflows} attribute of the corresponding real type is
9471 @code{False}.  See G.2.6(5).
9472 @end cartouche
9473 @noindent
9474 IEEE infinite and Nan values are produced as appropriate.
9475
9476 @sp 1
9477 @cartouche
9478 @noindent
9479 @strong{132}.  The accuracy of certain complex arithmetic operations and
9480 certain complex elementary functions for parameters (or components
9481 thereof) beyond the angle threshold.  See G.2.6(8).
9482 @end cartouche
9483 @noindent
9484 Information on those subjects is not yet available.
9485
9486 @sp 1
9487 @cartouche
9488 @noindent
9489 @strong{133}.  Information regarding bounded errors and erroneous
9490 execution.  See H.2(1).
9491 @end cartouche
9492 @noindent
9493 Information on this subject is not yet available.
9494
9495 @sp 1
9496 @cartouche
9497 @noindent
9498 @strong{134}.  Implementation-defined aspects of pragma
9499 @code{Inspection_Point}.  See H.3.2(8).
9500 @end cartouche
9501 @noindent
9502 Pragma @code{Inspection_Point} ensures that the variable is live and can
9503 be examined by the debugger at the inspection point.
9504
9505 @sp 1
9506 @cartouche
9507 @noindent
9508 @strong{135}.  Implementation-defined aspects of pragma
9509 @code{Restrictions}.  See H.4(25).
9510 @end cartouche
9511 @noindent
9512 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9513 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9514 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9515
9516 @sp 1
9517 @cartouche
9518 @noindent
9519 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9520 H.4(27).
9521 @end cartouche
9522 @noindent
9523 There are no restrictions on pragma @code{Restrictions}.
9524
9525 @node Intrinsic Subprograms
9526 @chapter Intrinsic Subprograms
9527 @cindex Intrinsic Subprograms
9528
9529 @menu
9530 * Intrinsic Operators::
9531 * Enclosing_Entity::
9532 * Exception_Information::
9533 * Exception_Message::
9534 * Exception_Name::
9535 * File::
9536 * Line::
9537 * Rotate_Left::
9538 * Rotate_Right::
9539 * Shift_Left::
9540 * Shift_Right::
9541 * Shift_Right_Arithmetic::
9542 * Source_Location::
9543 @end menu
9544
9545 @noindent
9546 GNAT allows a user application program to write the declaration:
9547
9548 @smallexample @c ada
9549    pragma Import (Intrinsic, name);
9550 @end smallexample
9551
9552 @noindent
9553 providing that the name corresponds to one of the implemented intrinsic
9554 subprograms in GNAT, and that the parameter profile of the referenced
9555 subprogram meets the requirements.  This chapter describes the set of
9556 implemented intrinsic subprograms, and the requirements on parameter profiles.
9557 Note that no body is supplied; as with other uses of pragma Import, the
9558 body is supplied elsewhere (in this case by the compiler itself).  Note
9559 that any use of this feature is potentially non-portable, since the
9560 Ada standard does not require Ada compilers to implement this feature.
9561
9562 @node Intrinsic Operators
9563 @section Intrinsic Operators
9564 @cindex Intrinsic operator
9565
9566 @noindent
9567 All the predefined numeric operators in package Standard
9568 in @code{pragma Import (Intrinsic,..)}
9569 declarations.  In the binary operator case, the operands must have the same
9570 size.  The operand or operands must also be appropriate for
9571 the operator.  For example, for addition, the operands must
9572 both be floating-point or both be fixed-point, and the
9573 right operand for @code{"**"} must have a root type of
9574 @code{Standard.Integer'Base}.
9575 You can use an intrinsic operator declaration as in the following example:
9576
9577 @smallexample @c ada
9578    type Int1 is new Integer;
9579    type Int2 is new Integer;
9580
9581    function "+" (X1 : Int1; X2 : Int2) return Int1;
9582    function "+" (X1 : Int1; X2 : Int2) return Int2;
9583    pragma Import (Intrinsic, "+");
9584 @end smallexample
9585
9586 @noindent
9587 This declaration would permit ``mixed mode'' arithmetic on items
9588 of the differing types @code{Int1} and @code{Int2}.
9589 It is also possible to specify such operators for private types, if the
9590 full views are appropriate arithmetic types.
9591
9592 @node Enclosing_Entity
9593 @section Enclosing_Entity
9594 @cindex Enclosing_Entity
9595 @noindent
9596 This intrinsic subprogram is used in the implementation of the
9597 library routine @code{GNAT.Source_Info}.  The only useful use of the
9598 intrinsic import in this case is the one in this unit, so an
9599 application program should simply call the function
9600 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9601 the current subprogram, package, task, entry, or protected subprogram.
9602
9603 @node Exception_Information
9604 @section Exception_Information
9605 @cindex Exception_Information'
9606 @noindent
9607 This intrinsic subprogram is used in the implementation of the
9608 library routine @code{GNAT.Current_Exception}.  The only useful
9609 use of the intrinsic import in this case is the one in this unit,
9610 so an application program should simply call the function
9611 @code{GNAT.Current_Exception.Exception_Information} to obtain
9612 the exception information associated with the current exception.
9613
9614 @node Exception_Message
9615 @section Exception_Message
9616 @cindex Exception_Message
9617 @noindent
9618 This intrinsic subprogram is used in the implementation of the
9619 library routine @code{GNAT.Current_Exception}.  The only useful
9620 use of the intrinsic import in this case is the one in this unit,
9621 so an application program should simply call the function
9622 @code{GNAT.Current_Exception.Exception_Message} to obtain
9623 the message associated with the current exception.
9624
9625 @node Exception_Name
9626 @section Exception_Name
9627 @cindex Exception_Name
9628 @noindent
9629 This intrinsic subprogram is used in the implementation of the
9630 library routine @code{GNAT.Current_Exception}.  The only useful
9631 use of the intrinsic import in this case is the one in this unit,
9632 so an application program should simply call the function
9633 @code{GNAT.Current_Exception.Exception_Name} to obtain
9634 the name of the current exception.
9635
9636 @node File
9637 @section File
9638 @cindex File
9639 @noindent
9640 This intrinsic subprogram is used in the implementation of the
9641 library routine @code{GNAT.Source_Info}.  The only useful use of the
9642 intrinsic import in this case is the one in this unit, so an
9643 application program should simply call the function
9644 @code{GNAT.Source_Info.File} to obtain the name of the current
9645 file.
9646
9647 @node Line
9648 @section Line
9649 @cindex Line
9650 @noindent
9651 This intrinsic subprogram is used in the implementation of the
9652 library routine @code{GNAT.Source_Info}.  The only useful use of the
9653 intrinsic import in this case is the one in this unit, so an
9654 application program should simply call the function
9655 @code{GNAT.Source_Info.Line} to obtain the number of the current
9656 source line.
9657
9658 @node Rotate_Left
9659 @section Rotate_Left
9660 @cindex Rotate_Left
9661 @noindent
9662 In standard Ada, the @code{Rotate_Left} function is available only
9663 for the predefined modular types in package @code{Interfaces}.  However, in
9664 GNAT it is possible to define a Rotate_Left function for a user
9665 defined modular type or any signed integer type as in this example:
9666
9667 @smallexample @c ada
9668    function Shift_Left
9669      (Value  : My_Modular_Type;
9670       Amount : Natural)
9671       return   My_Modular_Type;
9672 @end smallexample
9673
9674 @noindent
9675 The requirements are that the profile be exactly as in the example
9676 above.  The only modifications allowed are in the formal parameter
9677 names, and in the type of @code{Value} and the return type, which
9678 must be the same, and must be either a signed integer type, or
9679 a modular integer type with a binary modulus, and the size must
9680 be 8.  16, 32 or 64 bits.
9681
9682 @node Rotate_Right
9683 @section Rotate_Right
9684 @cindex Rotate_Right
9685 @noindent
9686 A @code{Rotate_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_Left
9691 @section Shift_Left
9692 @cindex Shift_Left
9693 @noindent
9694 A @code{Shift_Left} function can be defined for any user defined
9695 binary modular integer type, or signed integer type, as described
9696 above for @code{Rotate_Left}.
9697
9698 @node Shift_Right
9699 @section Shift_Right
9700 @cindex Shift_Right
9701 @noindent
9702 A @code{Shift_Right} function can be defined for any user defined
9703 binary modular integer type, or signed integer type, as described
9704 above for @code{Rotate_Left}.
9705
9706 @node Shift_Right_Arithmetic
9707 @section Shift_Right_Arithmetic
9708 @cindex Shift_Right_Arithmetic
9709 @noindent
9710 A @code{Shift_Right_Arithmetic} function can be defined for any user
9711 defined binary modular integer type, or signed integer type, as described
9712 above for @code{Rotate_Left}.
9713
9714 @node Source_Location
9715 @section Source_Location
9716 @cindex Source_Location
9717 @noindent
9718 This intrinsic subprogram is used in the implementation of the
9719 library routine @code{GNAT.Source_Info}.  The only useful use of the
9720 intrinsic import in this case is the one in this unit, so an
9721 application program should simply call the function
9722 @code{GNAT.Source_Info.Source_Location} to obtain the current
9723 source file location.
9724
9725 @node Representation Clauses and Pragmas
9726 @chapter Representation Clauses and Pragmas
9727 @cindex Representation Clauses
9728
9729 @menu
9730 * Alignment Clauses::
9731 * Size Clauses::
9732 * Storage_Size Clauses::
9733 * Size of Variant Record Objects::
9734 * Biased Representation ::
9735 * Value_Size and Object_Size Clauses::
9736 * Component_Size Clauses::
9737 * Bit_Order Clauses::
9738 * Effect of Bit_Order on Byte Ordering::
9739 * Pragma Pack for Arrays::
9740 * Pragma Pack for Records::
9741 * Record Representation Clauses::
9742 * Enumeration Clauses::
9743 * Address Clauses::
9744 * Effect of Convention on Representation::
9745 * Determining the Representations chosen by GNAT::
9746 @end menu
9747
9748 @noindent
9749 @cindex Representation Clause
9750 @cindex Representation Pragma
9751 @cindex Pragma, representation
9752 This section describes the representation clauses accepted by GNAT, and
9753 their effect on the representation of corresponding data objects.
9754
9755 GNAT fully implements Annex C (Systems Programming).  This means that all
9756 the implementation advice sections in chapter 13 are fully implemented.
9757 However, these sections only require a minimal level of support for
9758 representation clauses.  GNAT provides much more extensive capabilities,
9759 and this section describes the additional capabilities provided.
9760
9761 @node Alignment Clauses
9762 @section Alignment Clauses
9763 @cindex Alignment Clause
9764
9765 @noindent
9766 GNAT requires that all alignment clauses specify a power of 2, and all
9767 default alignments are always a power of 2.  The default alignment
9768 values are as follows:
9769
9770 @itemize @bullet
9771 @item @emph{Primitive Types}.
9772 For primitive types, the alignment is the minimum of the actual size of
9773 objects of the type divided by @code{Storage_Unit},
9774 and the maximum alignment supported by the target.
9775 (This maximum alignment is given by the GNAT-specific attribute
9776 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9777 @cindex @code{Maximum_Alignment} attribute
9778 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9779 default alignment will be 8 on any target that supports alignments
9780 this large, but on some targets, the maximum alignment may be smaller
9781 than 8, in which case objects of type @code{Long_Float} will be maximally
9782 aligned.
9783
9784 @item @emph{Arrays}.
9785 For arrays, the alignment is equal to the alignment of the component type
9786 for the normal case where no packing or component size is given.  If the
9787 array is packed, and the packing is effective (see separate section on
9788 packed arrays), then the alignment will be one for long packed arrays,
9789 or arrays whose length is not known at compile time.  For short packed
9790 arrays, which are handled internally as modular types, the alignment
9791 will be as described for primitive types, e.g.@: a packed array of length
9792 31 bits will have an object size of four bytes, and an alignment of 4.
9793
9794 @item @emph{Records}.
9795 For the normal non-packed case, the alignment of a record is equal to
9796 the maximum alignment of any of its components.  For tagged records, this
9797 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9798 is used and all components are packable (see separate section on pragma
9799 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9800 record makes it profitable to increase it.
9801
9802 A special case is when:
9803 @itemize @bullet
9804 @item
9805 the size of the record is given explicitly, or a
9806 full record representation clause is given, and
9807 @item
9808 the size of the record is 2, 4, or 8 bytes.
9809 @end itemize
9810 @noindent
9811 In this case, an alignment is chosen to match the
9812 size of the record. For example, if we have:
9813
9814 @smallexample @c ada
9815    type Small is record
9816       A, B : Character;
9817    end record;
9818    for Small'Size use 16;
9819 @end smallexample
9820
9821 @noindent
9822 then the default alignment of the record type @code{Small} is 2, not 1. This
9823 leads to more efficient code when the record is treated as a unit, and also
9824 allows the type to specified as @code{Atomic} on architectures requiring
9825 strict alignment.
9826
9827 @end itemize
9828
9829 @noindent
9830 An alignment clause may specify a larger alignment than the default value
9831 up to some maximum value dependent on the target (obtainable by using the
9832 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9833 a smaller alignment than the default value for enumeration, integer and
9834 fixed point types, as well as for record types, for example
9835
9836 @smallexample @c ada
9837   type V is record
9838      A : Integer;
9839   end record;
9840
9841   for V'alignment use 1;
9842 @end smallexample
9843
9844 @noindent
9845 @cindex Alignment, default
9846 The default alignment for the type @code{V} is 4, as a result of the
9847 Integer field in the record, but it is permissible, as shown, to
9848 override the default alignment of the record with a smaller value.
9849
9850 @node Size Clauses
9851 @section Size Clauses
9852 @cindex Size Clause
9853
9854 @noindent
9855 The default size for a type @code{T} is obtainable through the
9856 language-defined attribute @code{T'Size} and also through the
9857 equivalent GNAT-defined attribute @code{T'Value_Size}.
9858 For objects of type @code{T}, GNAT will generally increase the type size
9859 so that the object size (obtainable through the GNAT-defined attribute
9860 @code{T'Object_Size})
9861 is a multiple of @code{T'Alignment * Storage_Unit}.
9862 For example
9863
9864 @smallexample @c ada
9865    type Smallint is range 1 .. 6;
9866
9867    type Rec is record
9868       Y1 : integer;
9869       Y2 : boolean;
9870    end record;
9871 @end smallexample
9872
9873 @noindent
9874 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9875 as specified by the RM rules,
9876 but objects of this type will have a size of 8
9877 (@code{Smallint'Object_Size} = 8),
9878 since objects by default occupy an integral number
9879 of storage units.  On some targets, notably older
9880 versions of the Digital Alpha, the size of stand
9881 alone objects of this type may be 32, reflecting
9882 the inability of the hardware to do byte load/stores.
9883
9884 Similarly, the size of type @code{Rec} is 40 bits
9885 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9886 the alignment is 4, so objects of this type will have
9887 their size increased to 64 bits so that it is a multiple
9888 of the alignment (in bits).  This decision is
9889 in accordance with the specific Implementation Advice in RM 13.3(43):
9890
9891 @quotation
9892 A @code{Size} clause should be supported for an object if the specified
9893 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9894 to a size in storage elements that is a multiple of the object's
9895 @code{Alignment} (if the @code{Alignment} is nonzero).
9896 @end quotation
9897
9898 @noindent
9899 An explicit size clause may be used to override the default size by
9900 increasing it.  For example, if we have:
9901
9902 @smallexample @c ada
9903    type My_Boolean is new Boolean;
9904    for My_Boolean'Size use 32;
9905 @end smallexample
9906
9907 @noindent
9908 then values of this type will always be 32 bits long.  In the case of
9909 discrete types, the size can be increased up to 64 bits, with the effect
9910 that the entire specified field is used to hold the value, sign- or
9911 zero-extended as appropriate.  If more than 64 bits is specified, then
9912 padding space is allocated after the value, and a warning is issued that
9913 there are unused bits.
9914
9915 Similarly the size of records and arrays may be increased, and the effect
9916 is to add padding bits after the value.  This also causes a warning message
9917 to be generated.
9918
9919 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9920 Size in bits, this corresponds to an object of size 256 megabytes (minus
9921 one).  This limitation is true on all targets.  The reason for this
9922 limitation is that it improves the quality of the code in many cases
9923 if it is known that a Size value can be accommodated in an object of
9924 type Integer.
9925
9926 @node Storage_Size Clauses
9927 @section Storage_Size Clauses
9928 @cindex Storage_Size Clause
9929
9930 @noindent
9931 For tasks, the @code{Storage_Size} clause specifies the amount of space
9932 to be allocated for the task stack.  This cannot be extended, and if the
9933 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9934 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9935 or a @code{Storage_Size} pragma in the task definition to set the
9936 appropriate required size.  A useful technique is to include in every
9937 task definition a pragma of the form:
9938
9939 @smallexample @c ada
9940    pragma Storage_Size (Default_Stack_Size);
9941 @end smallexample
9942
9943 @noindent
9944 Then @code{Default_Stack_Size} can be defined in a global package, and
9945 modified as required. Any tasks requiring stack sizes different from the
9946 default can have an appropriate alternative reference in the pragma.
9947
9948 You can also use the @option{-d} binder switch to modify the default stack
9949 size.
9950
9951 For access types, the @code{Storage_Size} clause specifies the maximum
9952 space available for allocation of objects of the type.  If this space is
9953 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9954 In the case where the access type is declared local to a subprogram, the
9955 use of a @code{Storage_Size} clause triggers automatic use of a special
9956 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9957 space for the pool is automatically reclaimed on exit from the scope in
9958 which the type is declared.
9959
9960 A special case recognized by the compiler is the specification of a
9961 @code{Storage_Size} of zero for an access type.  This means that no
9962 items can be allocated from the pool, and this is recognized at compile
9963 time, and all the overhead normally associated with maintaining a fixed
9964 size storage pool is eliminated.  Consider the following example:
9965
9966 @smallexample @c ada
9967    procedure p is
9968       type R is array (Natural) of Character;
9969       type P is access all R;
9970       for P'Storage_Size use 0;
9971       --  Above access type intended only for interfacing purposes
9972
9973       y : P;
9974
9975       procedure g (m : P);
9976       pragma Import (C, g);
9977
9978       --  @dots{}
9979
9980    begin
9981       --  @dots{}
9982       y := new R;
9983    end;
9984 @end smallexample
9985
9986 @noindent
9987 As indicated in this example, these dummy storage pools are often useful in
9988 connection with interfacing where no object will ever be allocated.  If you
9989 compile the above example, you get the warning:
9990
9991 @smallexample
9992    p.adb:16:09: warning: allocation from empty storage pool
9993    p.adb:16:09: warning: Storage_Error will be raised at run time
9994 @end smallexample
9995
9996 @noindent
9997 Of course in practice, there will not be any explicit allocators in the
9998 case of such an access declaration.
9999
10000 @node Size of Variant Record Objects
10001 @section Size of Variant Record Objects
10002 @cindex Size, variant record objects
10003 @cindex Variant record objects, size
10004
10005 @noindent
10006 In the case of variant record objects, there is a question whether Size gives
10007 information about a particular variant, or the maximum size required
10008 for any variant.  Consider the following program
10009
10010 @smallexample @c ada
10011 with Text_IO; use Text_IO;
10012 procedure q is
10013    type R1 (A : Boolean := False) is record
10014      case A is
10015        when True  => X : Character;
10016        when False => null;
10017      end case;
10018    end record;
10019
10020    V1 : R1 (False);
10021    V2 : R1;
10022
10023 begin
10024    Put_Line (Integer'Image (V1'Size));
10025    Put_Line (Integer'Image (V2'Size));
10026 end q;
10027 @end smallexample
10028
10029 @noindent
10030 Here we are dealing with a variant record, where the True variant
10031 requires 16 bits, and the False variant requires 8 bits.
10032 In the above example, both V1 and V2 contain the False variant,
10033 which is only 8 bits long.  However, the result of running the
10034 program is:
10035
10036 @smallexample
10037 8
10038 16
10039 @end smallexample
10040
10041 @noindent
10042 The reason for the difference here is that the discriminant value of
10043 V1 is fixed, and will always be False.  It is not possible to assign
10044 a True variant value to V1, therefore 8 bits is sufficient.  On the
10045 other hand, in the case of V2, the initial discriminant value is
10046 False (from the default), but it is possible to assign a True
10047 variant value to V2, therefore 16 bits must be allocated for V2
10048 in the general case, even fewer bits may be needed at any particular
10049 point during the program execution.
10050
10051 As can be seen from the output of this program, the @code{'Size}
10052 attribute applied to such an object in GNAT gives the actual allocated
10053 size of the variable, which is the largest size of any of the variants.
10054 The Ada Reference Manual is not completely clear on what choice should
10055 be made here, but the GNAT behavior seems most consistent with the
10056 language in the RM@.
10057
10058 In some cases, it may be desirable to obtain the size of the current
10059 variant, rather than the size of the largest variant.  This can be
10060 achieved in GNAT by making use of the fact that in the case of a
10061 subprogram parameter, GNAT does indeed return the size of the current
10062 variant (because a subprogram has no way of knowing how much space
10063 is actually allocated for the actual).
10064
10065 Consider the following modified version of the above program:
10066
10067 @smallexample @c ada
10068 with Text_IO; use Text_IO;
10069 procedure q is
10070    type R1 (A : Boolean := False) is record
10071      case A is
10072        when True  => X : Character;
10073        when False => null;
10074      end case;
10075    end record;
10076
10077    V2 : R1;
10078
10079    function Size (V : R1) return Integer is
10080    begin
10081       return V'Size;
10082    end Size;
10083
10084 begin
10085    Put_Line (Integer'Image (V2'Size));
10086    Put_Line (Integer'IMage (Size (V2)));
10087    V2 := (True, 'x');
10088    Put_Line (Integer'Image (V2'Size));
10089    Put_Line (Integer'IMage (Size (V2)));
10090 end q;
10091 @end smallexample
10092
10093 @noindent
10094 The output from this program is
10095
10096 @smallexample
10097 16
10098 8
10099 16
10100 16
10101 @end smallexample
10102
10103 @noindent
10104 Here we see that while the @code{'Size} attribute always returns
10105 the maximum size, regardless of the current variant value, the
10106 @code{Size} function does indeed return the size of the current
10107 variant value.
10108
10109 @node Biased Representation
10110 @section Biased Representation
10111 @cindex Size for biased representation
10112 @cindex Biased representation
10113
10114 @noindent
10115 In the case of scalars with a range starting at other than zero, it is
10116 possible in some cases to specify a size smaller than the default minimum
10117 value, and in such cases, GNAT uses an unsigned biased representation,
10118 in which zero is used to represent the lower bound, and successive values
10119 represent successive values of the type.
10120
10121 For example, suppose we have the declaration:
10122
10123 @smallexample @c ada
10124    type Small is range -7 .. -4;
10125    for Small'Size use 2;
10126 @end smallexample
10127
10128 @noindent
10129 Although the default size of type @code{Small} is 4, the @code{Size}
10130 clause is accepted by GNAT and results in the following representation
10131 scheme:
10132
10133 @smallexample
10134   -7 is represented as 2#00#
10135   -6 is represented as 2#01#
10136   -5 is represented as 2#10#
10137   -4 is represented as 2#11#
10138 @end smallexample
10139
10140 @noindent
10141 Biased representation is only used if the specified @code{Size} clause
10142 cannot be accepted in any other manner.  These reduced sizes that force
10143 biased representation can be used for all discrete types except for
10144 enumeration types for which a representation clause is given.
10145
10146 @node Value_Size and Object_Size Clauses
10147 @section Value_Size and Object_Size Clauses
10148 @findex Value_Size
10149 @findex Object_Size
10150 @cindex Size, of objects
10151
10152 @noindent
10153 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10154 number of bits required to hold values of type @code{T}.
10155 Although this interpretation was allowed in Ada 83, it was not required,
10156 and this requirement in practice can cause some significant difficulties.
10157 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10158 However, in Ada 95 and Ada 2005,
10159 @code{Natural'Size} is
10160 typically 31.  This means that code may change in behavior when moving
10161 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10162
10163 @smallexample @c ada
10164    type Rec is record;
10165       A : Natural;
10166       B : Natural;
10167    end record;
10168
10169    for Rec use record
10170       at 0  range 0 .. Natural'Size - 1;
10171       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10172    end record;
10173 @end smallexample
10174
10175 @noindent
10176 In the above code, since the typical size of @code{Natural} objects
10177 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10178 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10179 there are cases where the fact that the object size can exceed the
10180 size of the type causes surprises.
10181
10182 To help get around this problem GNAT provides two implementation
10183 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10184 applied to a type, these attributes yield the size of the type
10185 (corresponding to the RM defined size attribute), and the size of
10186 objects of the type respectively.
10187
10188 The @code{Object_Size} is used for determining the default size of
10189 objects and components.  This size value can be referred to using the
10190 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10191 the basis of the determination of the size.  The backend is free to
10192 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10193 character might be stored in 32 bits on a machine with no efficient
10194 byte access instructions such as the Alpha.
10195
10196 The default rules for the value of @code{Object_Size} for
10197 discrete types are as follows:
10198
10199 @itemize @bullet
10200 @item
10201 The @code{Object_Size} for base subtypes reflect the natural hardware
10202 size in bits (run the compiler with @option{-gnatS} to find those values
10203 for numeric types). Enumeration types and fixed-point base subtypes have
10204 8, 16, 32 or 64 bits for this size, depending on the range of values
10205 to be stored.
10206
10207 @item
10208 The @code{Object_Size} of a subtype is the same as the
10209 @code{Object_Size} of
10210 the type from which it is obtained.
10211
10212 @item
10213 The @code{Object_Size} of a derived base type is copied from the parent
10214 base type, and the @code{Object_Size} of a derived first subtype is copied
10215 from the parent first subtype.
10216 @end itemize
10217
10218 @noindent
10219 The @code{Value_Size} attribute
10220 is the (minimum) number of bits required to store a value
10221 of the type.
10222 This value is used to determine how tightly to pack
10223 records or arrays with components of this type, and also affects
10224 the semantics of unchecked conversion (unchecked conversions where
10225 the @code{Value_Size} values differ generate a warning, and are potentially
10226 target dependent).
10227
10228 The default rules for the value of @code{Value_Size} are as follows:
10229
10230 @itemize @bullet
10231 @item
10232 The @code{Value_Size} for a base subtype is the minimum number of bits
10233 required to store all values of the type (including the sign bit
10234 only if negative values are possible).
10235
10236 @item
10237 If a subtype statically matches the first subtype of a given type, then it has
10238 by default the same @code{Value_Size} as the first subtype.  This is a
10239 consequence of RM 13.1(14) (``if two subtypes statically match,
10240 then their subtype-specific aspects are the same''.)
10241
10242 @item
10243 All other subtypes have a @code{Value_Size} corresponding to the minimum
10244 number of bits required to store all values of the subtype.  For
10245 dynamic bounds, it is assumed that the value can range down or up
10246 to the corresponding bound of the ancestor
10247 @end itemize
10248
10249 @noindent
10250 The RM defined attribute @code{Size} corresponds to the
10251 @code{Value_Size} attribute.
10252
10253 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10254 the @code{Value_Size} of
10255 the first-named subtype to the given value, and the
10256 @code{Object_Size} of this first-named subtype to the given value padded up
10257 to an appropriate boundary.  It is a consequence of the default rules
10258 above that this @code{Object_Size} will apply to all further subtypes.  On the
10259 other hand, @code{Value_Size} is affected only for the first subtype, any
10260 dynamic subtypes obtained from it directly, and any statically matching
10261 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10262
10263 @code{Value_Size} and
10264 @code{Object_Size} may be explicitly set for any subtype using
10265 an attribute definition clause.  Note that the use of these attributes
10266 can cause the RM 13.1(14) rule to be violated.  If two access types
10267 reference aliased objects whose subtypes have differing @code{Object_Size}
10268 values as a result of explicit attribute definition clauses, then it
10269 is erroneous to convert from one access subtype to the other.
10270
10271 At the implementation level, Esize stores the Object_Size and the
10272 RM_Size field stores the @code{Value_Size} (and hence the value of the
10273 @code{Size} attribute,
10274 which, as noted above, is equivalent to @code{Value_Size}).
10275
10276 To get a feel for the difference, consider the following examples (note
10277 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10278
10279 @smallexample
10280                                        Object_Size     Value_Size
10281
10282 type x1 is range 0 .. 5;                    8               3
10283
10284 type x2 is range 0 .. 5;
10285 for x2'size use 12;                        16              12
10286
10287 subtype x3 is x2 range 0 .. 3;             16               2
10288
10289 subtype x4 is x2'base range 0 .. 10;        8               4
10290
10291 subtype x5 is x2 range 0 .. dynamic;       16               3*
10292
10293 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10294
10295 @end smallexample
10296
10297 @noindent
10298 Note: the entries marked ``3*'' are not actually specified by the Ada
10299 Reference Manual, but it seems in the spirit of the RM rules to allocate
10300 the minimum number of bits (here 3, given the range for @code{x2})
10301 known to be large enough to hold the given range of values.
10302
10303 So far, so good, but GNAT has to obey the RM rules, so the question is
10304 under what conditions must the RM @code{Size} be used.
10305 The following is a list
10306 of the occasions on which the RM @code{Size} must be used:
10307
10308 @itemize @bullet
10309 @item
10310 Component size for packed arrays or records
10311
10312 @item
10313 Value of the attribute @code{Size} for a type
10314
10315 @item
10316 Warning about sizes not matching for unchecked conversion
10317 @end itemize
10318
10319 @noindent
10320 For record types, the @code{Object_Size} is always a multiple of the
10321 alignment of the type (this is true for all types). In some cases the
10322 @code{Value_Size} can be smaller. Consider:
10323
10324 @smallexample
10325    type R is record
10326      X : Integer;
10327      Y : Character;
10328    end record;
10329 @end smallexample
10330
10331 @noindent
10332 On a typical 32-bit architecture, the X component will be four bytes, and
10333 require four-byte alignment, and the Y component will be one byte. In this
10334 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10335 required to store a value of this type, and for example, it is permissible
10336 to have a component of type R in an outer record whose component size is
10337 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10338 since it must be rounded up so that this value is a multiple of the
10339 alignment (4 bytes = 32 bits).
10340
10341 @noindent
10342 For all other types, the @code{Object_Size}
10343 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10344 Only @code{Size} may be specified for such types.
10345
10346 @node Component_Size Clauses
10347 @section Component_Size Clauses
10348 @cindex Component_Size Clause
10349
10350 @noindent
10351 Normally, the value specified in a component size clause must be consistent
10352 with the subtype of the array component with regard to size and alignment.
10353 In other words, the value specified must be at least equal to the size
10354 of this subtype, and must be a multiple of the alignment value.
10355
10356 In addition, component size clauses are allowed which cause the array
10357 to be packed, by specifying a smaller value.  A first case is for
10358 component size values in the range 1 through 63.  The value specified
10359 must not be smaller than the Size of the subtype.  GNAT will accurately
10360 honor all packing requests in this range.  For example, if we have:
10361
10362 @smallexample @c ada
10363 type r is array (1 .. 8) of Natural;
10364 for r'Component_Size use 31;
10365 @end smallexample
10366
10367 @noindent
10368 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10369 Of course access to the components of such an array is considerably
10370 less efficient than if the natural component size of 32 is used.
10371 A second case is when the subtype of the component is a record type
10372 padded because of its default alignment.  For example, if we have:
10373
10374 @smallexample @c ada
10375 type r is record
10376   i : Integer;
10377   j : Integer;
10378   b : Boolean;
10379 end record;
10380
10381 type a is array (1 .. 8) of r;
10382 for a'Component_Size use 72;
10383 @end smallexample
10384
10385 @noindent
10386 then the resulting array has a length of 72 bytes, instead of 96 bytes
10387 if the alignment of the record (4) was obeyed.
10388
10389 Note that there is no point in giving both a component size clause
10390 and a pragma Pack for the same array type. if such duplicate
10391 clauses are given, the pragma Pack will be ignored.
10392
10393 @node Bit_Order Clauses
10394 @section Bit_Order Clauses
10395 @cindex Bit_Order Clause
10396 @cindex bit ordering
10397 @cindex ordering, of bits
10398
10399 @noindent
10400 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10401 attribute.  The specification may either correspond to the default bit
10402 order for the target, in which case the specification has no effect and
10403 places no additional restrictions, or it may be for the non-standard
10404 setting (that is the opposite of the default).
10405
10406 In the case where the non-standard value is specified, the effect is
10407 to renumber bits within each byte, but the ordering of bytes is not
10408 affected.  There are certain
10409 restrictions placed on component clauses as follows:
10410
10411 @itemize @bullet
10412
10413 @item Components fitting within a single storage unit.
10414 @noindent
10415 These are unrestricted, and the effect is merely to renumber bits.  For
10416 example if we are on a little-endian machine with @code{Low_Order_First}
10417 being the default, then the following two declarations have exactly
10418 the same effect:
10419
10420 @smallexample @c ada
10421    type R1 is record
10422       A : Boolean;
10423       B : Integer range 1 .. 120;
10424    end record;
10425
10426    for R1 use record
10427       A at 0 range 0 .. 0;
10428       B at 0 range 1 .. 7;
10429    end record;
10430
10431    type R2 is record
10432       A : Boolean;
10433       B : Integer range 1 .. 120;
10434    end record;
10435
10436    for R2'Bit_Order use High_Order_First;
10437
10438    for R2 use record
10439       A at 0 range 7 .. 7;
10440       B at 0 range 0 .. 6;
10441    end record;
10442 @end smallexample
10443
10444 @noindent
10445 The useful application here is to write the second declaration with the
10446 @code{Bit_Order} attribute definition clause, and know that it will be treated
10447 the same, regardless of whether the target is little-endian or big-endian.
10448
10449 @item Components occupying an integral number of bytes.
10450 @noindent
10451 These are components that exactly fit in two or more bytes.  Such component
10452 declarations are allowed, but have no effect, since it is important to realize
10453 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10454 In particular, the following attempt at getting an endian-independent integer
10455 does not work:
10456
10457 @smallexample @c ada
10458    type R2 is record
10459       A : Integer;
10460    end record;
10461
10462    for R2'Bit_Order use High_Order_First;
10463
10464    for R2 use record
10465       A at 0 range 0 .. 31;
10466    end record;
10467 @end smallexample
10468
10469 @noindent
10470 This declaration will result in a little-endian integer on a
10471 little-endian machine, and a big-endian integer on a big-endian machine.
10472 If byte flipping is required for interoperability between big- and
10473 little-endian machines, this must be explicitly programmed.  This capability
10474 is not provided by @code{Bit_Order}.
10475
10476 @item Components that are positioned across byte boundaries
10477 @noindent
10478 but do not occupy an integral number of bytes.  Given that bytes are not
10479 reordered, such fields would occupy a non-contiguous sequence of bits
10480 in memory, requiring non-trivial code to reassemble.  They are for this
10481 reason not permitted, and any component clause specifying such a layout
10482 will be flagged as illegal by GNAT@.
10483
10484 @end itemize
10485
10486 @noindent
10487 Since the misconception that Bit_Order automatically deals with all
10488 endian-related incompatibilities is a common one, the specification of
10489 a component field that is an integral number of bytes will always
10490 generate a warning.  This warning may be suppressed using @code{pragma
10491 Warnings (Off)} if desired.  The following section contains additional
10492 details regarding the issue of byte ordering.
10493
10494 @node Effect of Bit_Order on Byte Ordering
10495 @section Effect of Bit_Order on Byte Ordering
10496 @cindex byte ordering
10497 @cindex ordering, of bytes
10498
10499 @noindent
10500 In this section we will review the effect of the @code{Bit_Order} attribute
10501 definition clause on byte ordering.  Briefly, it has no effect at all, but
10502 a detailed example will be helpful.  Before giving this
10503 example, let us review the precise
10504 definition of the effect of defining @code{Bit_Order}.  The effect of a
10505 non-standard bit order is described in section 15.5.3 of the Ada
10506 Reference Manual:
10507
10508 @quotation
10509 2   A bit ordering is a method of interpreting the meaning of
10510 the storage place attributes.
10511 @end quotation
10512
10513 @noindent
10514 To understand the precise definition of storage place attributes in
10515 this context, we visit section 13.5.1 of the manual:
10516
10517 @quotation
10518 13   A record_representation_clause (without the mod_clause)
10519 specifies the layout.  The storage place attributes (see 13.5.2)
10520 are taken from the values of the position, first_bit, and last_bit
10521 expressions after normalizing those values so that first_bit is
10522 less than Storage_Unit.
10523 @end quotation
10524
10525 @noindent
10526 The critical point here is that storage places are taken from
10527 the values after normalization, not before.  So the @code{Bit_Order}
10528 interpretation applies to normalized values.  The interpretation
10529 is described in the later part of the 15.5.3 paragraph:
10530
10531 @quotation
10532 2   A bit ordering is a method of interpreting the meaning of
10533 the storage place attributes.  High_Order_First (known in the
10534 vernacular as ``big endian'') means that the first bit of a
10535 storage element (bit 0) is the most significant bit (interpreting
10536 the sequence of bits that represent a component as an unsigned
10537 integer value).  Low_Order_First (known in the vernacular as
10538 ``little endian'') means the opposite: the first bit is the
10539 least significant.
10540 @end quotation
10541
10542 @noindent
10543 Note that the numbering is with respect to the bits of a storage
10544 unit.  In other words, the specification affects only the numbering
10545 of bits within a single storage unit.
10546
10547 We can make the effect clearer by giving an example.
10548
10549 Suppose that we have an external device which presents two bytes, the first
10550 byte presented, which is the first (low addressed byte) of the two byte
10551 record is called Master, and the second byte is called Slave.
10552
10553 The left most (most significant bit is called Control for each byte, and
10554 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10555 (least significant) bit.
10556
10557 On a big-endian machine, we can write the following representation clause
10558
10559 @smallexample @c ada
10560    type Data is record
10561       Master_Control : Bit;
10562       Master_V1      : Bit;
10563       Master_V2      : Bit;
10564       Master_V3      : Bit;
10565       Master_V4      : Bit;
10566       Master_V5      : Bit;
10567       Master_V6      : Bit;
10568       Master_V7      : Bit;
10569       Slave_Control  : Bit;
10570       Slave_V1       : Bit;
10571       Slave_V2       : Bit;
10572       Slave_V3       : Bit;
10573       Slave_V4       : Bit;
10574       Slave_V5       : Bit;
10575       Slave_V6       : Bit;
10576       Slave_V7       : Bit;
10577    end record;
10578
10579    for Data use record
10580       Master_Control at 0 range 0 .. 0;
10581       Master_V1      at 0 range 1 .. 1;
10582       Master_V2      at 0 range 2 .. 2;
10583       Master_V3      at 0 range 3 .. 3;
10584       Master_V4      at 0 range 4 .. 4;
10585       Master_V5      at 0 range 5 .. 5;
10586       Master_V6      at 0 range 6 .. 6;
10587       Master_V7      at 0 range 7 .. 7;
10588       Slave_Control  at 1 range 0 .. 0;
10589       Slave_V1       at 1 range 1 .. 1;
10590       Slave_V2       at 1 range 2 .. 2;
10591       Slave_V3       at 1 range 3 .. 3;
10592       Slave_V4       at 1 range 4 .. 4;
10593       Slave_V5       at 1 range 5 .. 5;
10594       Slave_V6       at 1 range 6 .. 6;
10595       Slave_V7       at 1 range 7 .. 7;
10596    end record;
10597 @end smallexample
10598
10599 @noindent
10600 Now if we move this to a little endian machine, then the bit ordering within
10601 the byte is backwards, so we have to rewrite the record rep clause as:
10602
10603 @smallexample @c ada
10604    for Data use record
10605       Master_Control at 0 range 7 .. 7;
10606       Master_V1      at 0 range 6 .. 6;
10607       Master_V2      at 0 range 5 .. 5;
10608       Master_V3      at 0 range 4 .. 4;
10609       Master_V4      at 0 range 3 .. 3;
10610       Master_V5      at 0 range 2 .. 2;
10611       Master_V6      at 0 range 1 .. 1;
10612       Master_V7      at 0 range 0 .. 0;
10613       Slave_Control  at 1 range 7 .. 7;
10614       Slave_V1       at 1 range 6 .. 6;
10615       Slave_V2       at 1 range 5 .. 5;
10616       Slave_V3       at 1 range 4 .. 4;
10617       Slave_V4       at 1 range 3 .. 3;
10618       Slave_V5       at 1 range 2 .. 2;
10619       Slave_V6       at 1 range 1 .. 1;
10620       Slave_V7       at 1 range 0 .. 0;
10621    end record;
10622 @end smallexample
10623
10624 @noindent
10625 It is a nuisance to have to rewrite the clause, especially if
10626 the code has to be maintained on both machines.  However,
10627 this is a case that we can handle with the
10628 @code{Bit_Order} attribute if it is implemented.
10629 Note that the implementation is not required on byte addressed
10630 machines, but it is indeed implemented in GNAT.
10631 This means that we can simply use the
10632 first record clause, together with the declaration
10633
10634 @smallexample @c ada
10635    for Data'Bit_Order use High_Order_First;
10636 @end smallexample
10637
10638 @noindent
10639 and the effect is what is desired, namely the layout is exactly the same,
10640 independent of whether the code is compiled on a big-endian or little-endian
10641 machine.
10642
10643 The important point to understand is that byte ordering is not affected.
10644 A @code{Bit_Order} attribute definition never affects which byte a field
10645 ends up in, only where it ends up in that byte.
10646 To make this clear, let us rewrite the record rep clause of the previous
10647 example as:
10648
10649 @smallexample @c ada
10650    for Data'Bit_Order use High_Order_First;
10651    for Data use record
10652       Master_Control at 0 range  0 .. 0;
10653       Master_V1      at 0 range  1 .. 1;
10654       Master_V2      at 0 range  2 .. 2;
10655       Master_V3      at 0 range  3 .. 3;
10656       Master_V4      at 0 range  4 .. 4;
10657       Master_V5      at 0 range  5 .. 5;
10658       Master_V6      at 0 range  6 .. 6;
10659       Master_V7      at 0 range  7 .. 7;
10660       Slave_Control  at 0 range  8 .. 8;
10661       Slave_V1       at 0 range  9 .. 9;
10662       Slave_V2       at 0 range 10 .. 10;
10663       Slave_V3       at 0 range 11 .. 11;
10664       Slave_V4       at 0 range 12 .. 12;
10665       Slave_V5       at 0 range 13 .. 13;
10666       Slave_V6       at 0 range 14 .. 14;
10667       Slave_V7       at 0 range 15 .. 15;
10668    end record;
10669 @end smallexample
10670
10671 @noindent
10672 This is exactly equivalent to saying (a repeat of the first example):
10673
10674 @smallexample @c ada
10675    for Data'Bit_Order use High_Order_First;
10676    for Data use record
10677       Master_Control at 0 range 0 .. 0;
10678       Master_V1      at 0 range 1 .. 1;
10679       Master_V2      at 0 range 2 .. 2;
10680       Master_V3      at 0 range 3 .. 3;
10681       Master_V4      at 0 range 4 .. 4;
10682       Master_V5      at 0 range 5 .. 5;
10683       Master_V6      at 0 range 6 .. 6;
10684       Master_V7      at 0 range 7 .. 7;
10685       Slave_Control  at 1 range 0 .. 0;
10686       Slave_V1       at 1 range 1 .. 1;
10687       Slave_V2       at 1 range 2 .. 2;
10688       Slave_V3       at 1 range 3 .. 3;
10689       Slave_V4       at 1 range 4 .. 4;
10690       Slave_V5       at 1 range 5 .. 5;
10691       Slave_V6       at 1 range 6 .. 6;
10692       Slave_V7       at 1 range 7 .. 7;
10693    end record;
10694 @end smallexample
10695
10696 @noindent
10697 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10698 field.  The storage place attributes are obtained by normalizing the
10699 values given so that the @code{First_Bit} value is less than 8.  After
10700 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10701 we specified in the other case.
10702
10703 Now one might expect that the @code{Bit_Order} attribute might affect
10704 bit numbering within the entire record component (two bytes in this
10705 case, thus affecting which byte fields end up in), but that is not
10706 the way this feature is defined, it only affects numbering of bits,
10707 not which byte they end up in.
10708
10709 Consequently it never makes sense to specify a starting bit number
10710 greater than 7 (for a byte addressable field) if an attribute
10711 definition for @code{Bit_Order} has been given, and indeed it
10712 may be actively confusing to specify such a value, so the compiler
10713 generates a warning for such usage.
10714
10715 If you do need to control byte ordering then appropriate conditional
10716 values must be used.  If in our example, the slave byte came first on
10717 some machines we might write:
10718
10719 @smallexample @c ada
10720    Master_Byte_First constant Boolean := @dots{};
10721
10722    Master_Byte : constant Natural :=
10723                    1 - Boolean'Pos (Master_Byte_First);
10724    Slave_Byte  : constant Natural :=
10725                    Boolean'Pos (Master_Byte_First);
10726
10727    for Data'Bit_Order use High_Order_First;
10728    for Data use record
10729       Master_Control at Master_Byte range 0 .. 0;
10730       Master_V1      at Master_Byte range 1 .. 1;
10731       Master_V2      at Master_Byte range 2 .. 2;
10732       Master_V3      at Master_Byte range 3 .. 3;
10733       Master_V4      at Master_Byte range 4 .. 4;
10734       Master_V5      at Master_Byte range 5 .. 5;
10735       Master_V6      at Master_Byte range 6 .. 6;
10736       Master_V7      at Master_Byte range 7 .. 7;
10737       Slave_Control  at Slave_Byte  range 0 .. 0;
10738       Slave_V1       at Slave_Byte  range 1 .. 1;
10739       Slave_V2       at Slave_Byte  range 2 .. 2;
10740       Slave_V3       at Slave_Byte  range 3 .. 3;
10741       Slave_V4       at Slave_Byte  range 4 .. 4;
10742       Slave_V5       at Slave_Byte  range 5 .. 5;
10743       Slave_V6       at Slave_Byte  range 6 .. 6;
10744       Slave_V7       at Slave_Byte  range 7 .. 7;
10745    end record;
10746 @end smallexample
10747
10748 @noindent
10749 Now to switch between machines, all that is necessary is
10750 to set the boolean constant @code{Master_Byte_First} in
10751 an appropriate manner.
10752
10753 @node Pragma Pack for Arrays
10754 @section Pragma Pack for Arrays
10755 @cindex Pragma Pack (for arrays)
10756
10757 @noindent
10758 Pragma @code{Pack} applied to an array has no effect unless the component type
10759 is packable.  For a component type to be packable, it must be one of the
10760 following cases:
10761
10762 @itemize @bullet
10763 @item
10764 Any scalar type
10765 @item
10766 Any type whose size is specified with a size clause
10767 @item
10768 Any packed array type with a static size
10769 @item
10770 Any record type padded because of its default alignment
10771 @end itemize
10772
10773 @noindent
10774 For all these cases, if the component subtype size is in the range
10775 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10776 component size were specified giving the component subtype size.
10777 For example if we have:
10778
10779 @smallexample @c ada
10780    type r is range 0 .. 17;
10781
10782    type ar is array (1 .. 8) of r;
10783    pragma Pack (ar);
10784 @end smallexample
10785
10786 @noindent
10787 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10788 and the size of the array @code{ar} will be exactly 40 bits.
10789
10790 Note that in some cases this rather fierce approach to packing can produce
10791 unexpected effects.  For example, in Ada 95 and Ada 2005,
10792 subtype @code{Natural} typically has a size of 31, meaning that if you
10793 pack an array of @code{Natural}, you get 31-bit
10794 close packing, which saves a few bits, but results in far less efficient
10795 access.  Since many other Ada compilers will ignore such a packing request,
10796 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10797 might not be what is intended.  You can easily remove this warning by
10798 using an explicit @code{Component_Size} setting instead, which never generates
10799 a warning, since the intention of the programmer is clear in this case.
10800
10801 GNAT treats packed arrays in one of two ways.  If the size of the array is
10802 known at compile time and is less than 64 bits, then internally the array
10803 is represented as a single modular type, of exactly the appropriate number
10804 of bits.  If the length is greater than 63 bits, or is not known at compile
10805 time, then the packed array is represented as an array of bytes, and the
10806 length is always a multiple of 8 bits.
10807
10808 Note that to represent a packed array as a modular type, the alignment must
10809 be suitable for the modular type involved. For example, on typical machines
10810 a 32-bit packed array will be represented by a 32-bit modular integer with
10811 an alignment of four bytes. If you explicitly override the default alignment
10812 with an alignment clause that is too small, the modular representation
10813 cannot be used. For example, consider the following set of declarations:
10814
10815 @smallexample @c ada
10816    type R is range 1 .. 3;
10817    type S is array (1 .. 31) of R;
10818    for S'Component_Size use 2;
10819    for S'Size use 62;
10820    for S'Alignment use 1;
10821 @end smallexample
10822
10823 @noindent
10824 If the alignment clause were not present, then a 62-bit modular
10825 representation would be chosen (typically with an alignment of 4 or 8
10826 bytes depending on the target). But the default alignment is overridden
10827 with the explicit alignment clause. This means that the modular
10828 representation cannot be used, and instead the array of bytes
10829 representation must be used, meaning that the length must be a multiple
10830 of 8. Thus the above set of declarations will result in a diagnostic
10831 rejecting the size clause and noting that the minimum size allowed is 64.
10832
10833 @cindex Pragma Pack (for type Natural)
10834 @cindex Pragma Pack warning
10835
10836 One special case that is worth noting occurs when the base type of the
10837 component size is 8/16/32 and the subtype is one bit less. Notably this
10838 occurs with subtype @code{Natural}. Consider:
10839
10840 @smallexample @c ada
10841    type Arr is array (1 .. 32) of Natural;
10842    pragma Pack (Arr);
10843 @end smallexample
10844
10845 @noindent
10846 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10847 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10848 Ada 83 compilers did not attempt 31 bit packing.
10849
10850 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10851 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10852 substantial unintended performance penalty when porting legacy Ada 83 code.
10853 To help prevent this, GNAT generates a warning in such cases. If you really
10854 want 31 bit packing in a case like this, you can set the component size
10855 explicitly:
10856
10857 @smallexample @c ada
10858    type Arr is array (1 .. 32) of Natural;
10859    for Arr'Component_Size use 31;
10860 @end smallexample
10861
10862 @noindent
10863 Here 31-bit packing is achieved as required, and no warning is generated,
10864 since in this case the programmer intention is clear.
10865
10866 @node Pragma Pack for Records
10867 @section Pragma Pack for Records
10868 @cindex Pragma Pack (for records)
10869
10870 @noindent
10871 Pragma @code{Pack} applied to a record will pack the components to reduce
10872 wasted space from alignment gaps and by reducing the amount of space
10873 taken by components.  We distinguish between @emph{packable} components and
10874 @emph{non-packable} components.
10875 Components of the following types are considered packable:
10876 @itemize @bullet
10877 @item
10878 All primitive types are packable.
10879
10880 @item
10881 Small packed arrays, whose size does not exceed 64 bits, and where the
10882 size is statically known at compile time, are represented internally
10883 as modular integers, and so they are also packable.
10884
10885 @end itemize
10886
10887 @noindent
10888 All packable components occupy the exact number of bits corresponding to
10889 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10890 can start on an arbitrary bit boundary.
10891
10892 All other types are non-packable, they occupy an integral number of
10893 storage units, and
10894 are placed at a boundary corresponding to their alignment requirements.
10895
10896 For example, consider the record
10897
10898 @smallexample @c ada
10899    type Rb1 is array (1 .. 13) of Boolean;
10900    pragma Pack (rb1);
10901
10902    type Rb2 is array (1 .. 65) of Boolean;
10903    pragma Pack (rb2);
10904
10905    type x2 is record
10906       l1 : Boolean;
10907       l2 : Duration;
10908       l3 : Float;
10909       l4 : Boolean;
10910       l5 : Rb1;
10911       l6 : Rb2;
10912    end record;
10913    pragma Pack (x2);
10914 @end smallexample
10915
10916 @noindent
10917 The representation for the record x2 is as follows:
10918
10919 @smallexample @c ada
10920 for x2'Size use 224;
10921 for x2 use record
10922    l1 at  0 range  0 .. 0;
10923    l2 at  0 range  1 .. 64;
10924    l3 at 12 range  0 .. 31;
10925    l4 at 16 range  0 .. 0;
10926    l5 at 16 range  1 .. 13;
10927    l6 at 18 range  0 .. 71;
10928 end record;
10929 @end smallexample
10930
10931 @noindent
10932 Studying this example, we see that the packable fields @code{l1}
10933 and @code{l2} are
10934 of length equal to their sizes, and placed at specific bit boundaries (and
10935 not byte boundaries) to
10936 eliminate padding.  But @code{l3} is of a non-packable float type, so
10937 it is on the next appropriate alignment boundary.
10938
10939 The next two fields are fully packable, so @code{l4} and @code{l5} are
10940 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10941 array that is longer than 64 bits, so it is itself non-packable.  Thus
10942 the @code{l6} field is aligned to the next byte boundary, and takes an
10943 integral number of bytes, i.e.@: 72 bits.
10944
10945 @node Record Representation Clauses
10946 @section Record Representation Clauses
10947 @cindex Record Representation Clause
10948
10949 @noindent
10950 Record representation clauses may be given for all record types, including
10951 types obtained by record extension.  Component clauses are allowed for any
10952 static component.  The restrictions on component clauses depend on the type
10953 of the component.
10954
10955 @cindex Component Clause
10956 For all components of an elementary type, the only restriction on component
10957 clauses is that the size must be at least the 'Size value of the type
10958 (actually the Value_Size).  There are no restrictions due to alignment,
10959 and such components may freely cross storage boundaries.
10960
10961 Packed arrays with a size up to and including 64 bits are represented
10962 internally using a modular type with the appropriate number of bits, and
10963 thus the same lack of restriction applies.  For example, if you declare:
10964
10965 @smallexample @c ada
10966    type R is array (1 .. 49) of Boolean;
10967    pragma Pack (R);
10968    for R'Size use 49;
10969 @end smallexample
10970
10971 @noindent
10972 then a component clause for a component of type R may start on any
10973 specified bit boundary, and may specify a value of 49 bits or greater.
10974
10975 For packed bit arrays that are longer than 64 bits, there are two
10976 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10977 including the important case of single bits or boolean values, then
10978 there are no limitations on placement of such components, and they
10979 may start and end at arbitrary bit boundaries.
10980
10981 If the component size is not a power of 2 (e.g.@: 3 or 5), then
10982 an array of this type longer than 64 bits must always be placed on
10983 on a storage unit (byte) boundary and occupy an integral number
10984 of storage units (bytes). Any component clause that does not
10985 meet this requirement will be rejected.
10986
10987 Any aliased component, or component of an aliased type, must
10988 have its normal alignment and size. A component clause that
10989 does not meet this requirement will be rejected.
10990
10991 The tag field of a tagged type always occupies an address sized field at
10992 the start of the record.  No component clause may attempt to overlay this
10993 tag. When a tagged type appears as a component, the tag field must have
10994 proper alignment
10995
10996 In the case of a record extension T1, of a type T, no component clause applied
10997 to the type T1 can specify a storage location that would overlap the first
10998 T'Size bytes of the record.
10999
11000 For all other component types, including non-bit-packed arrays,
11001 the component can be placed at an arbitrary bit boundary,
11002 so for example, the following is permitted:
11003
11004 @smallexample @c ada
11005    type R is array (1 .. 10) of Boolean;
11006    for R'Size use 80;
11007
11008    type Q is record
11009       G, H : Boolean;
11010       L, M : R;
11011    end record;
11012
11013    for Q use record
11014       G at 0 range  0 ..   0;
11015       H at 0 range  1 ..   1;
11016       L at 0 range  2 ..  81;
11017       R at 0 range 82 .. 161;
11018    end record;
11019 @end smallexample
11020
11021 @noindent
11022 Note: the above rules apply to recent releases of GNAT 5.
11023 In GNAT 3, there are more severe restrictions on larger components.
11024 For non-primitive types, including packed arrays with a size greater than
11025 64 bits, component clauses must respect the alignment requirement of the
11026 type, in particular, always starting on a byte boundary, and the length
11027 must be a multiple of the storage unit.
11028
11029 @node Enumeration Clauses
11030 @section Enumeration Clauses
11031
11032 The only restriction on enumeration clauses is that the range of values
11033 must be representable.  For the signed case, if one or more of the
11034 representation values are negative, all values must be in the range:
11035
11036 @smallexample @c ada
11037    System.Min_Int .. System.Max_Int
11038 @end smallexample
11039
11040 @noindent
11041 For the unsigned case, where all values are nonnegative, the values must
11042 be in the range:
11043
11044 @smallexample @c ada
11045    0 .. System.Max_Binary_Modulus;
11046 @end smallexample
11047
11048 @noindent
11049 A @emph{confirming} representation clause is one in which the values range
11050 from 0 in sequence, i.e.@: a clause that confirms the default representation
11051 for an enumeration type.
11052 Such a confirming representation
11053 is permitted by these rules, and is specially recognized by the compiler so
11054 that no extra overhead results from the use of such a clause.
11055
11056 If an array has an index type which is an enumeration type to which an
11057 enumeration clause has been applied, then the array is stored in a compact
11058 manner.  Consider the declarations:
11059
11060 @smallexample @c ada
11061    type r is (A, B, C);
11062    for r use (A => 1, B => 5, C => 10);
11063    type t is array (r) of Character;
11064 @end smallexample
11065
11066 @noindent
11067 The array type t corresponds to a vector with exactly three elements and
11068 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11069 use of space, but means that accesses to elements of the array will incur
11070 the overhead of converting representation values to the corresponding
11071 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11072
11073 @node Address Clauses
11074 @section Address Clauses
11075 @cindex Address Clause
11076
11077 The reference manual allows a general restriction on representation clauses,
11078 as found in RM 13.1(22):
11079
11080 @quotation
11081 An implementation need not support representation
11082 items containing nonstatic expressions, except that
11083 an implementation should support a representation item
11084 for a given entity if each nonstatic expression in the
11085 representation item is a name that statically denotes
11086 a constant declared before the entity.
11087 @end quotation
11088
11089 @noindent
11090 In practice this is applicable only to address clauses, since this is the
11091 only case in which a non-static expression is permitted by the syntax.  As
11092 the AARM notes in sections 13.1 (22.a-22.h):
11093
11094 @display
11095   22.a   Reason: This is to avoid the following sort of thing:
11096
11097   22.b        X : Integer := F(@dots{});
11098               Y : Address := G(@dots{});
11099               for X'Address use Y;
11100
11101   22.c   In the above, we have to evaluate the
11102          initialization expression for X before we
11103          know where to put the result.  This seems
11104          like an unreasonable implementation burden.
11105
11106   22.d   The above code should instead be written
11107          like this:
11108
11109   22.e        Y : constant Address := G(@dots{});
11110               X : Integer := F(@dots{});
11111               for X'Address use Y;
11112
11113   22.f   This allows the expression ``Y'' to be safely
11114          evaluated before X is created.
11115
11116   22.g   The constant could be a formal parameter of mode in.
11117
11118   22.h   An implementation can support other nonstatic
11119          expressions if it wants to.  Expressions of type
11120          Address are hardly ever static, but their value
11121          might be known at compile time anyway in many
11122          cases.
11123 @end display
11124
11125 @noindent
11126 GNAT does indeed permit many additional cases of non-static expressions.  In
11127 particular, if the type involved is elementary there are no restrictions
11128 (since in this case, holding a temporary copy of the initialization value,
11129 if one is present, is inexpensive).  In addition, if there is no implicit or
11130 explicit initialization, then there are no restrictions.  GNAT will reject
11131 only the case where all three of these conditions hold:
11132
11133 @itemize @bullet
11134
11135 @item
11136 The type of the item is non-elementary (e.g.@: a record or array).
11137
11138 @item
11139 There is explicit or implicit initialization required for the object.
11140 Note that access values are always implicitly initialized, and also
11141 in GNAT, certain bit-packed arrays (those having a dynamic length or
11142 a length greater than 64) will also be implicitly initialized to zero.
11143
11144 @item
11145 The address value is non-static.  Here GNAT is more permissive than the
11146 RM, and allows the address value to be the address of a previously declared
11147 stand-alone variable, as long as it does not itself have an address clause.
11148
11149 @smallexample @c ada
11150            Anchor  : Some_Initialized_Type;
11151            Overlay : Some_Initialized_Type;
11152            for Overlay'Address use Anchor'Address;
11153 @end smallexample
11154
11155 @noindent
11156 However, the prefix of the address clause cannot be an array component, or
11157 a component of a discriminated record.
11158
11159 @end itemize
11160
11161 @noindent
11162 As noted above in section 22.h, address values are typically non-static.  In
11163 particular the To_Address function, even if applied to a literal value, is
11164 a non-static function call.  To avoid this minor annoyance, GNAT provides
11165 the implementation defined attribute 'To_Address.  The following two
11166 expressions have identical values:
11167
11168 @findex Attribute
11169 @findex To_Address
11170 @smallexample @c ada
11171    To_Address (16#1234_0000#)
11172    System'To_Address (16#1234_0000#);
11173 @end smallexample
11174
11175 @noindent
11176 except that the second form is considered to be a static expression, and
11177 thus when used as an address clause value is always permitted.
11178
11179 @noindent
11180 Additionally, GNAT treats as static an address clause that is an
11181 unchecked_conversion of a static integer value.  This simplifies the porting
11182 of legacy code, and provides a portable equivalent to the GNAT attribute
11183 @code{To_Address}.
11184
11185 Another issue with address clauses is the interaction with alignment
11186 requirements.  When an address clause is given for an object, the address
11187 value must be consistent with the alignment of the object (which is usually
11188 the same as the alignment of the type of the object).  If an address clause
11189 is given that specifies an inappropriately aligned address value, then the
11190 program execution is erroneous.
11191
11192 Since this source of erroneous behavior can have unfortunate effects, GNAT
11193 checks (at compile time if possible, generating a warning, or at execution
11194 time with a run-time check) that the alignment is appropriate.  If the
11195 run-time check fails, then @code{Program_Error} is raised.  This run-time
11196 check is suppressed if range checks are suppressed, or if the special GNAT
11197 check Alignment_Check is suppressed, or if
11198 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11199
11200 Finally, GNAT does not permit overlaying of objects of controlled types or
11201 composite types containing a controlled component. In most cases, the compiler
11202 can detect an attempt at such overlays and will generate a warning at compile
11203 time and a Program_Error exception at run time.
11204
11205 @findex Export
11206 An address clause cannot be given for an exported object.  More
11207 understandably the real restriction is that objects with an address
11208 clause cannot be exported.  This is because such variables are not
11209 defined by the Ada program, so there is no external object to export.
11210
11211 @findex Import
11212 It is permissible to give an address clause and a pragma Import for the
11213 same object.  In this case, the variable is not really defined by the
11214 Ada program, so there is no external symbol to be linked.  The link name
11215 and the external name are ignored in this case.  The reason that we allow this
11216 combination is that it provides a useful idiom to avoid unwanted
11217 initializations on objects with address clauses.
11218
11219 When an address clause is given for an object that has implicit or
11220 explicit initialization, then by default initialization takes place.  This
11221 means that the effect of the object declaration is to overwrite the
11222 memory at the specified address.  This is almost always not what the
11223 programmer wants, so GNAT will output a warning:
11224
11225 @smallexample
11226   with System;
11227   package G is
11228      type R is record
11229         M : Integer := 0;
11230      end record;
11231
11232      Ext : R;
11233      for Ext'Address use System'To_Address (16#1234_1234#);
11234          |
11235   >>> warning: implicit initialization of "Ext" may
11236       modify overlaid storage
11237   >>> warning: use pragma Import for "Ext" to suppress
11238       initialization (RM B(24))
11239
11240   end G;
11241 @end smallexample
11242
11243 @noindent
11244 As indicated by the warning message, the solution is to use a (dummy) pragma
11245 Import to suppress this initialization.  The pragma tell the compiler that the
11246 object is declared and initialized elsewhere.  The following package compiles
11247 without warnings (and the initialization is suppressed):
11248
11249 @smallexample @c ada
11250    with System;
11251    package G is
11252       type R is record
11253          M : Integer := 0;
11254       end record;
11255
11256       Ext : R;
11257       for Ext'Address use System'To_Address (16#1234_1234#);
11258       pragma Import (Ada, Ext);
11259    end G;
11260 @end smallexample
11261
11262 @noindent
11263 A final issue with address clauses involves their use for overlaying
11264 variables, as in the following example:
11265 @cindex Overlaying of objects
11266
11267 @smallexample @c ada
11268   A : Integer;
11269   B : Integer;
11270   for B'Address use A'Address;
11271 @end smallexample
11272
11273 @noindent
11274 or alternatively, using the form recommended by the RM:
11275
11276 @smallexample @c ada
11277   A    : Integer;
11278   Addr : constant Address := A'Address;
11279   B    : Integer;
11280   for B'Address use Addr;
11281 @end smallexample
11282
11283 @noindent
11284 In both of these cases, @code{A}
11285 and @code{B} become aliased to one another via the
11286 address clause. This use of address clauses to overlay
11287 variables, achieving an effect similar to unchecked
11288 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11289 the effect is implementation defined. Furthermore, the
11290 Ada RM specifically recommends that in a situation
11291 like this, @code{B} should be subject to the following
11292 implementation advice (RM 13.3(19)):
11293
11294 @quotation
11295 19  If the Address of an object is specified, or it is imported
11296     or exported, then the implementation should not perform
11297     optimizations based on assumptions of no aliases.
11298 @end quotation
11299
11300 @noindent
11301 GNAT follows this recommendation, and goes further by also applying
11302 this recommendation to the overlaid variable (@code{A}
11303 in the above example) in this case. This means that the overlay
11304 works "as expected", in that a modification to one of the variables
11305 will affect the value of the other.
11306
11307 @node Effect of Convention on Representation
11308 @section Effect of Convention on Representation
11309 @cindex Convention, effect on representation
11310
11311 @noindent
11312 Normally the specification of a foreign language convention for a type or
11313 an object has no effect on the chosen representation.  In particular, the
11314 representation chosen for data in GNAT generally meets the standard system
11315 conventions, and for example records are laid out in a manner that is
11316 consistent with C@.  This means that specifying convention C (for example)
11317 has no effect.
11318
11319 There are four exceptions to this general rule:
11320
11321 @itemize @bullet
11322
11323 @item Convention Fortran and array subtypes
11324 If pragma Convention Fortran is specified for an array subtype, then in
11325 accordance with the implementation advice in section 3.6.2(11) of the
11326 Ada Reference Manual, the array will be stored in a Fortran-compatible
11327 column-major manner, instead of the normal default row-major order.
11328
11329 @item Convention C and enumeration types
11330 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11331 to accommodate all values of the type.  For example, for the enumeration
11332 type declared by:
11333
11334 @smallexample @c ada
11335    type Color is (Red, Green, Blue);
11336 @end smallexample
11337
11338 @noindent
11339 8 bits is sufficient to store all values of the type, so by default, objects
11340 of type @code{Color} will be represented using 8 bits.  However, normal C
11341 convention is to use 32 bits for all enum values in C, since enum values
11342 are essentially of type int.  If pragma @code{Convention C} is specified for an
11343 Ada enumeration type, then the size is modified as necessary (usually to
11344 32 bits) to be consistent with the C convention for enum values.
11345
11346 Note that this treatment applies only to types. If Convention C is given for
11347 an enumeration object, where the enumeration type is not Convention C, then
11348 Object_Size bits are allocated. For example, for a normal enumeration type,
11349 with less than 256 elements, only 8 bits will be allocated for the object.
11350 Since this may be a surprise in terms of what C expects, GNAT will issue a
11351 warning in this situation. The warning can be suppressed by giving an explicit
11352 size clause specifying the desired size.
11353
11354 @item Convention C/Fortran and Boolean types
11355 In C, the usual convention for boolean values, that is values used for
11356 conditions, is that zero represents false, and nonzero values represent
11357 true.  In Ada, the normal convention is that two specific values, typically
11358 0/1, are used to represent false/true respectively.
11359
11360 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11361 value represents true).
11362
11363 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11364 C or Fortran convention for a derived Boolean, as in the following example:
11365
11366 @smallexample @c ada
11367    type C_Switch is new Boolean;
11368    pragma Convention (C, C_Switch);
11369 @end smallexample
11370
11371 @noindent
11372 then the GNAT generated code will treat any nonzero value as true.  For truth
11373 values generated by GNAT, the conventional value 1 will be used for True, but
11374 when one of these values is read, any nonzero value is treated as True.
11375
11376 @item Access types on OpenVMS
11377 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11378 arrays) are 64-bits long. An exception to this rule is for the case of
11379 C-convention access types where there is no explicit size clause present (or
11380 inherited for derived types). In this case, GNAT chooses to make these
11381 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11382 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11383
11384 @end itemize
11385
11386 @node Determining the Representations chosen by GNAT
11387 @section Determining the Representations chosen by GNAT
11388 @cindex Representation, determination of
11389 @cindex @option{-gnatR} switch
11390
11391 @noindent
11392 Although the descriptions in this section are intended to be complete, it is
11393 often easier to simply experiment to see what GNAT accepts and what the
11394 effect is on the layout of types and objects.
11395
11396 As required by the Ada RM, if a representation clause is not accepted, then
11397 it must be rejected as illegal by the compiler.  However, when a
11398 representation clause or pragma is accepted, there can still be questions
11399 of what the compiler actually does.  For example, if a partial record
11400 representation clause specifies the location of some components and not
11401 others, then where are the non-specified components placed? Or if pragma
11402 @code{Pack} is used on a record, then exactly where are the resulting
11403 fields placed? The section on pragma @code{Pack} in this chapter can be
11404 used to answer the second question, but it is often easier to just see
11405 what the compiler does.
11406
11407 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11408 with this option, then the compiler will output information on the actual
11409 representations chosen, in a format similar to source representation
11410 clauses.  For example, if we compile the package:
11411
11412 @smallexample @c ada
11413 package q is
11414    type r (x : boolean) is tagged record
11415       case x is
11416          when True => S : String (1 .. 100);
11417          when False => null;
11418       end case;
11419    end record;
11420
11421    type r2 is new r (false) with record
11422       y2 : integer;
11423    end record;
11424
11425    for r2 use record
11426       y2 at 16 range 0 .. 31;
11427    end record;
11428
11429    type x is record
11430       y : character;
11431    end record;
11432
11433    type x1 is array (1 .. 10) of x;
11434    for x1'component_size use 11;
11435
11436    type ia is access integer;
11437
11438    type Rb1 is array (1 .. 13) of Boolean;
11439    pragma Pack (rb1);
11440
11441    type Rb2 is array (1 .. 65) of Boolean;
11442    pragma Pack (rb2);
11443
11444    type x2 is record
11445       l1 : Boolean;
11446       l2 : Duration;
11447       l3 : Float;
11448       l4 : Boolean;
11449       l5 : Rb1;
11450       l6 : Rb2;
11451    end record;
11452    pragma Pack (x2);
11453 end q;
11454 @end smallexample
11455
11456 @noindent
11457 using the switch @option{-gnatR} we obtain the following output:
11458
11459 @smallexample
11460 Representation information for unit q
11461 -------------------------------------
11462
11463 for r'Size use ??;
11464 for r'Alignment use 4;
11465 for r use record
11466    x    at 4 range  0 .. 7;
11467    _tag at 0 range  0 .. 31;
11468    s    at 5 range  0 .. 799;
11469 end record;
11470
11471 for r2'Size use 160;
11472 for r2'Alignment use 4;
11473 for r2 use record
11474    x       at  4 range  0 .. 7;
11475    _tag    at  0 range  0 .. 31;
11476    _parent at  0 range  0 .. 63;
11477    y2      at 16 range  0 .. 31;
11478 end record;
11479
11480 for x'Size use 8;
11481 for x'Alignment use 1;
11482 for x use record
11483    y at 0 range  0 .. 7;
11484 end record;
11485
11486 for x1'Size use 112;
11487 for x1'Alignment use 1;
11488 for x1'Component_Size use 11;
11489
11490 for rb1'Size use 13;
11491 for rb1'Alignment use 2;
11492 for rb1'Component_Size use 1;
11493
11494 for rb2'Size use 72;
11495 for rb2'Alignment use 1;
11496 for rb2'Component_Size use 1;
11497
11498 for x2'Size use 224;
11499 for x2'Alignment use 4;
11500 for x2 use record
11501    l1 at  0 range  0 .. 0;
11502    l2 at  0 range  1 .. 64;
11503    l3 at 12 range  0 .. 31;
11504    l4 at 16 range  0 .. 0;
11505    l5 at 16 range  1 .. 13;
11506    l6 at 18 range  0 .. 71;
11507 end record;
11508 @end smallexample
11509
11510 @noindent
11511 The Size values are actually the Object_Size, i.e.@: the default size that
11512 will be allocated for objects of the type.
11513 The ?? size for type r indicates that we have a variant record, and the
11514 actual size of objects will depend on the discriminant value.
11515
11516 The Alignment values show the actual alignment chosen by the compiler
11517 for each record or array type.
11518
11519 The record representation clause for type r shows where all fields
11520 are placed, including the compiler generated tag field (whose location
11521 cannot be controlled by the programmer).
11522
11523 The record representation clause for the type extension r2 shows all the
11524 fields present, including the parent field, which is a copy of the fields
11525 of the parent type of r2, i.e.@: r1.
11526
11527 The component size and size clauses for types rb1 and rb2 show
11528 the exact effect of pragma @code{Pack} on these arrays, and the record
11529 representation clause for type x2 shows how pragma @code{Pack} affects
11530 this record type.
11531
11532 In some cases, it may be useful to cut and paste the representation clauses
11533 generated by the compiler into the original source to fix and guarantee
11534 the actual representation to be used.
11535
11536 @node Standard Library Routines
11537 @chapter Standard Library Routines
11538
11539 @noindent
11540 The Ada Reference Manual contains in Annex A a full description of an
11541 extensive set of standard library routines that can be used in any Ada
11542 program, and which must be provided by all Ada compilers.  They are
11543 analogous to the standard C library used by C programs.
11544
11545 GNAT implements all of the facilities described in annex A, and for most
11546 purposes the description in the Ada Reference Manual, or appropriate Ada
11547 text book, will be sufficient for making use of these facilities.
11548
11549 In the case of the input-output facilities,
11550 @xref{The Implementation of Standard I/O},
11551 gives details on exactly how GNAT interfaces to the
11552 file system.  For the remaining packages, the Ada Reference Manual
11553 should be sufficient.  The following is a list of the packages included,
11554 together with a brief description of the functionality that is provided.
11555
11556 For completeness, references are included to other predefined library
11557 routines defined in other sections of the Ada Reference Manual (these are
11558 cross-indexed from Annex A).
11559
11560 @table @code
11561 @item Ada (A.2)
11562 This is a parent package for all the standard library packages.  It is
11563 usually included implicitly in your program, and itself contains no
11564 useful data or routines.
11565
11566 @item Ada.Calendar (9.6)
11567 @code{Calendar} provides time of day access, and routines for
11568 manipulating times and durations.
11569
11570 @item Ada.Characters (A.3.1)
11571 This is a dummy parent package that contains no useful entities
11572
11573 @item Ada.Characters.Handling (A.3.2)
11574 This package provides some basic character handling capabilities,
11575 including classification functions for classes of characters (e.g.@: test
11576 for letters, or digits).
11577
11578 @item Ada.Characters.Latin_1 (A.3.3)
11579 This package includes a complete set of definitions of the characters
11580 that appear in type CHARACTER@.  It is useful for writing programs that
11581 will run in international environments.  For example, if you want an
11582 upper case E with an acute accent in a string, it is often better to use
11583 the definition of @code{UC_E_Acute} in this package.  Then your program
11584 will print in an understandable manner even if your environment does not
11585 support these extended characters.
11586
11587 @item Ada.Command_Line (A.15)
11588 This package provides access to the command line parameters and the name
11589 of the current program (analogous to the use of @code{argc} and @code{argv}
11590 in C), and also allows the exit status for the program to be set in a
11591 system-independent manner.
11592
11593 @item Ada.Decimal (F.2)
11594 This package provides constants describing the range of decimal numbers
11595 implemented, and also a decimal divide routine (analogous to the COBOL
11596 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11597
11598 @item Ada.Direct_IO (A.8.4)
11599 This package provides input-output using a model of a set of records of
11600 fixed-length, containing an arbitrary definite Ada type, indexed by an
11601 integer record number.
11602
11603 @item Ada.Dynamic_Priorities (D.5)
11604 This package allows the priorities of a task to be adjusted dynamically
11605 as the task is running.
11606
11607 @item Ada.Exceptions (11.4.1)
11608 This package provides additional information on exceptions, and also
11609 contains facilities for treating exceptions as data objects, and raising
11610 exceptions with associated messages.
11611
11612 @item Ada.Finalization (7.6)
11613 This package contains the declarations and subprograms to support the
11614 use of controlled types, providing for automatic initialization and
11615 finalization (analogous to the constructors and destructors of C++)
11616
11617 @item Ada.Interrupts (C.3.2)
11618 This package provides facilities for interfacing to interrupts, which
11619 includes the set of signals or conditions that can be raised and
11620 recognized as interrupts.
11621
11622 @item Ada.Interrupts.Names (C.3.2)
11623 This package provides the set of interrupt names (actually signal
11624 or condition names) that can be handled by GNAT@.
11625
11626 @item Ada.IO_Exceptions (A.13)
11627 This package defines the set of exceptions that can be raised by use of
11628 the standard IO packages.
11629
11630 @item Ada.Numerics
11631 This package contains some standard constants and exceptions used
11632 throughout the numerics packages.  Note that the constants pi and e are
11633 defined here, and it is better to use these definitions than rolling
11634 your own.
11635
11636 @item Ada.Numerics.Complex_Elementary_Functions
11637 Provides the implementation of standard elementary functions (such as
11638 log and trigonometric functions) operating on complex numbers using the
11639 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11640 created by the package @code{Numerics.Complex_Types}.
11641
11642 @item Ada.Numerics.Complex_Types
11643 This is a predefined instantiation of
11644 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11645 build the type @code{Complex} and @code{Imaginary}.
11646
11647 @item Ada.Numerics.Discrete_Random
11648 This package provides a random number generator suitable for generating
11649 random integer values from a specified range.
11650
11651 @item Ada.Numerics.Float_Random
11652 This package provides a random number generator suitable for generating
11653 uniformly distributed floating point values.
11654
11655 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11656 This is a generic version of the package that provides the
11657 implementation of standard elementary functions (such as log and
11658 trigonometric functions) for an arbitrary complex type.
11659
11660 The following predefined instantiations of this package are provided:
11661
11662 @table @code
11663 @item Short_Float
11664 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11665 @item Float
11666 @code{Ada.Numerics.Complex_Elementary_Functions}
11667 @item Long_Float
11668 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11669 @end table
11670
11671 @item Ada.Numerics.Generic_Complex_Types
11672 This is a generic package that allows the creation of complex types,
11673 with associated complex arithmetic operations.
11674
11675 The following predefined instantiations of this package exist
11676 @table @code
11677 @item Short_Float
11678 @code{Ada.Numerics.Short_Complex_Complex_Types}
11679 @item Float
11680 @code{Ada.Numerics.Complex_Complex_Types}
11681 @item Long_Float
11682 @code{Ada.Numerics.Long_Complex_Complex_Types}
11683 @end table
11684
11685 @item Ada.Numerics.Generic_Elementary_Functions
11686 This is a generic package that provides the implementation of standard
11687 elementary functions (such as log an trigonometric functions) for an
11688 arbitrary float type.
11689
11690 The following predefined instantiations of this package exist
11691
11692 @table @code
11693 @item Short_Float
11694 @code{Ada.Numerics.Short_Elementary_Functions}
11695 @item Float
11696 @code{Ada.Numerics.Elementary_Functions}
11697 @item Long_Float
11698 @code{Ada.Numerics.Long_Elementary_Functions}
11699 @end table
11700
11701 @item Ada.Real_Time (D.8)
11702 This package provides facilities similar to those of @code{Calendar}, but
11703 operating with a finer clock suitable for real time control. Note that
11704 annex D requires that there be no backward clock jumps, and GNAT generally
11705 guarantees this behavior, but of course if the external clock on which
11706 the GNAT runtime depends is deliberately reset by some external event,
11707 then such a backward jump may occur.
11708
11709 @item Ada.Sequential_IO (A.8.1)
11710 This package provides input-output facilities for sequential files,
11711 which can contain a sequence of values of a single type, which can be
11712 any Ada type, including indefinite (unconstrained) types.
11713
11714 @item Ada.Storage_IO (A.9)
11715 This package provides a facility for mapping arbitrary Ada types to and
11716 from a storage buffer.  It is primarily intended for the creation of new
11717 IO packages.
11718
11719 @item Ada.Streams (13.13.1)
11720 This is a generic package that provides the basic support for the
11721 concept of streams as used by the stream attributes (@code{Input},
11722 @code{Output}, @code{Read} and @code{Write}).
11723
11724 @item Ada.Streams.Stream_IO (A.12.1)
11725 This package is a specialization of the type @code{Streams} defined in
11726 package @code{Streams} together with a set of operations providing
11727 Stream_IO capability.  The Stream_IO model permits both random and
11728 sequential access to a file which can contain an arbitrary set of values
11729 of one or more Ada types.
11730
11731 @item Ada.Strings (A.4.1)
11732 This package provides some basic constants used by the string handling
11733 packages.
11734
11735 @item Ada.Strings.Bounded (A.4.4)
11736 This package provides facilities for handling variable length
11737 strings.  The bounded model requires a maximum length.  It is thus
11738 somewhat more limited than the unbounded model, but avoids the use of
11739 dynamic allocation or finalization.
11740
11741 @item Ada.Strings.Fixed (A.4.3)
11742 This package provides facilities for handling fixed length strings.
11743
11744 @item Ada.Strings.Maps (A.4.2)
11745 This package provides facilities for handling character mappings and
11746 arbitrarily defined subsets of characters.  For instance it is useful in
11747 defining specialized translation tables.
11748
11749 @item Ada.Strings.Maps.Constants (A.4.6)
11750 This package provides a standard set of predefined mappings and
11751 predefined character sets.  For example, the standard upper to lower case
11752 conversion table is found in this package.  Note that upper to lower case
11753 conversion is non-trivial if you want to take the entire set of
11754 characters, including extended characters like E with an acute accent,
11755 into account.  You should use the mappings in this package (rather than
11756 adding 32 yourself) to do case mappings.
11757
11758 @item Ada.Strings.Unbounded (A.4.5)
11759 This package provides facilities for handling variable length
11760 strings.  The unbounded model allows arbitrary length strings, but
11761 requires the use of dynamic allocation and finalization.
11762
11763 @item Ada.Strings.Wide_Bounded (A.4.7)
11764 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11765 @itemx Ada.Strings.Wide_Maps (A.4.7)
11766 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11767 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11768 These packages provide analogous capabilities to the corresponding
11769 packages without @samp{Wide_} in the name, but operate with the types
11770 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11771 and @code{Character}.
11772
11773 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11774 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11775 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11776 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11777 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11778 These packages provide analogous capabilities to the corresponding
11779 packages without @samp{Wide_} in the name, but operate with the types
11780 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11781 of @code{String} and @code{Character}.
11782
11783 @item Ada.Synchronous_Task_Control (D.10)
11784 This package provides some standard facilities for controlling task
11785 communication in a synchronous manner.
11786
11787 @item Ada.Tags
11788 This package contains definitions for manipulation of the tags of tagged
11789 values.
11790
11791 @item Ada.Task_Attributes
11792 This package provides the capability of associating arbitrary
11793 task-specific data with separate tasks.
11794
11795 @item Ada.Text_IO
11796 This package provides basic text input-output capabilities for
11797 character, string and numeric data.  The subpackages of this
11798 package are listed next.
11799
11800 @item Ada.Text_IO.Decimal_IO
11801 Provides input-output facilities for decimal fixed-point types
11802
11803 @item Ada.Text_IO.Enumeration_IO
11804 Provides input-output facilities for enumeration types.
11805
11806 @item Ada.Text_IO.Fixed_IO
11807 Provides input-output facilities for ordinary fixed-point types.
11808
11809 @item Ada.Text_IO.Float_IO
11810 Provides input-output facilities for float types.  The following
11811 predefined instantiations of this generic package are available:
11812
11813 @table @code
11814 @item Short_Float
11815 @code{Short_Float_Text_IO}
11816 @item Float
11817 @code{Float_Text_IO}
11818 @item Long_Float
11819 @code{Long_Float_Text_IO}
11820 @end table
11821
11822 @item Ada.Text_IO.Integer_IO
11823 Provides input-output facilities for integer types.  The following
11824 predefined instantiations of this generic package are available:
11825
11826 @table @code
11827 @item Short_Short_Integer
11828 @code{Ada.Short_Short_Integer_Text_IO}
11829 @item Short_Integer
11830 @code{Ada.Short_Integer_Text_IO}
11831 @item Integer
11832 @code{Ada.Integer_Text_IO}
11833 @item Long_Integer
11834 @code{Ada.Long_Integer_Text_IO}
11835 @item Long_Long_Integer
11836 @code{Ada.Long_Long_Integer_Text_IO}
11837 @end table
11838
11839 @item Ada.Text_IO.Modular_IO
11840 Provides input-output facilities for modular (unsigned) types
11841
11842 @item Ada.Text_IO.Complex_IO (G.1.3)
11843 This package provides basic text input-output capabilities for complex
11844 data.
11845
11846 @item Ada.Text_IO.Editing (F.3.3)
11847 This package contains routines for edited output, analogous to the use
11848 of pictures in COBOL@.  The picture formats used by this package are a
11849 close copy of the facility in COBOL@.
11850
11851 @item Ada.Text_IO.Text_Streams (A.12.2)
11852 This package provides a facility that allows Text_IO files to be treated
11853 as streams, so that the stream attributes can be used for writing
11854 arbitrary data, including binary data, to Text_IO files.
11855
11856 @item Ada.Unchecked_Conversion (13.9)
11857 This generic package allows arbitrary conversion from one type to
11858 another of the same size, providing for breaking the type safety in
11859 special circumstances.
11860
11861 If the types have the same Size (more accurately the same Value_Size),
11862 then the effect is simply to transfer the bits from the source to the
11863 target type without any modification.  This usage is well defined, and
11864 for simple types whose representation is typically the same across
11865 all implementations, gives a portable method of performing such
11866 conversions.
11867
11868 If the types do not have the same size, then the result is implementation
11869 defined, and thus may be non-portable.  The following describes how GNAT
11870 handles such unchecked conversion cases.
11871
11872 If the types are of different sizes, and are both discrete types, then
11873 the effect is of a normal type conversion without any constraint checking.
11874 In particular if the result type has a larger size, the result will be
11875 zero or sign extended.  If the result type has a smaller size, the result
11876 will be truncated by ignoring high order bits.
11877
11878 If the types are of different sizes, and are not both discrete types,
11879 then the conversion works as though pointers were created to the source
11880 and target, and the pointer value is converted.  The effect is that bits
11881 are copied from successive low order storage units and bits of the source
11882 up to the length of the target type.
11883
11884 A warning is issued if the lengths differ, since the effect in this
11885 case is implementation dependent, and the above behavior may not match
11886 that of some other compiler.
11887
11888 A pointer to one type may be converted to a pointer to another type using
11889 unchecked conversion.  The only case in which the effect is undefined is
11890 when one or both pointers are pointers to unconstrained array types.  In
11891 this case, the bounds information may get incorrectly transferred, and in
11892 particular, GNAT uses double size pointers for such types, and it is
11893 meaningless to convert between such pointer types.  GNAT will issue a
11894 warning if the alignment of the target designated type is more strict
11895 than the alignment of the source designated type (since the result may
11896 be unaligned in this case).
11897
11898 A pointer other than a pointer to an unconstrained array type may be
11899 converted to and from System.Address.  Such usage is common in Ada 83
11900 programs, but note that Ada.Address_To_Access_Conversions is the
11901 preferred method of performing such conversions in Ada 95 and Ada 2005.
11902 Neither
11903 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11904 used in conjunction with pointers to unconstrained objects, since
11905 the bounds information cannot be handled correctly in this case.
11906
11907 @item Ada.Unchecked_Deallocation (13.11.2)
11908 This generic package allows explicit freeing of storage previously
11909 allocated by use of an allocator.
11910
11911 @item Ada.Wide_Text_IO (A.11)
11912 This package is similar to @code{Ada.Text_IO}, except that the external
11913 file supports wide character representations, and the internal types are
11914 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11915 and @code{String}.  It contains generic subpackages listed next.
11916
11917 @item Ada.Wide_Text_IO.Decimal_IO
11918 Provides input-output facilities for decimal fixed-point types
11919
11920 @item Ada.Wide_Text_IO.Enumeration_IO
11921 Provides input-output facilities for enumeration types.
11922
11923 @item Ada.Wide_Text_IO.Fixed_IO
11924 Provides input-output facilities for ordinary fixed-point types.
11925
11926 @item Ada.Wide_Text_IO.Float_IO
11927 Provides input-output facilities for float types.  The following
11928 predefined instantiations of this generic package are available:
11929
11930 @table @code
11931 @item Short_Float
11932 @code{Short_Float_Wide_Text_IO}
11933 @item Float
11934 @code{Float_Wide_Text_IO}
11935 @item Long_Float
11936 @code{Long_Float_Wide_Text_IO}
11937 @end table
11938
11939 @item Ada.Wide_Text_IO.Integer_IO
11940 Provides input-output facilities for integer types.  The following
11941 predefined instantiations of this generic package are available:
11942
11943 @table @code
11944 @item Short_Short_Integer
11945 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11946 @item Short_Integer
11947 @code{Ada.Short_Integer_Wide_Text_IO}
11948 @item Integer
11949 @code{Ada.Integer_Wide_Text_IO}
11950 @item Long_Integer
11951 @code{Ada.Long_Integer_Wide_Text_IO}
11952 @item Long_Long_Integer
11953 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11954 @end table
11955
11956 @item Ada.Wide_Text_IO.Modular_IO
11957 Provides input-output facilities for modular (unsigned) types
11958
11959 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11960 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11961 external file supports wide character representations.
11962
11963 @item Ada.Wide_Text_IO.Editing (F.3.4)
11964 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11965 types are @code{Wide_Character} and @code{Wide_String} instead of
11966 @code{Character} and @code{String}.
11967
11968 @item Ada.Wide_Text_IO.Streams (A.12.3)
11969 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11970 types are @code{Wide_Character} and @code{Wide_String} instead of
11971 @code{Character} and @code{String}.
11972
11973 @item Ada.Wide_Wide_Text_IO (A.11)
11974 This package is similar to @code{Ada.Text_IO}, except that the external
11975 file supports wide character representations, and the internal types are
11976 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11977 and @code{String}.  It contains generic subpackages listed next.
11978
11979 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11980 Provides input-output facilities for decimal fixed-point types
11981
11982 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11983 Provides input-output facilities for enumeration types.
11984
11985 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11986 Provides input-output facilities for ordinary fixed-point types.
11987
11988 @item Ada.Wide_Wide_Text_IO.Float_IO
11989 Provides input-output facilities for float types.  The following
11990 predefined instantiations of this generic package are available:
11991
11992 @table @code
11993 @item Short_Float
11994 @code{Short_Float_Wide_Wide_Text_IO}
11995 @item Float
11996 @code{Float_Wide_Wide_Text_IO}
11997 @item Long_Float
11998 @code{Long_Float_Wide_Wide_Text_IO}
11999 @end table
12000
12001 @item Ada.Wide_Wide_Text_IO.Integer_IO
12002 Provides input-output facilities for integer types.  The following
12003 predefined instantiations of this generic package are available:
12004
12005 @table @code
12006 @item Short_Short_Integer
12007 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12008 @item Short_Integer
12009 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12010 @item Integer
12011 @code{Ada.Integer_Wide_Wide_Text_IO}
12012 @item Long_Integer
12013 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12014 @item Long_Long_Integer
12015 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12016 @end table
12017
12018 @item Ada.Wide_Wide_Text_IO.Modular_IO
12019 Provides input-output facilities for modular (unsigned) types
12020
12021 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12022 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12023 external file supports wide character representations.
12024
12025 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12026 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12027 types are @code{Wide_Character} and @code{Wide_String} instead of
12028 @code{Character} and @code{String}.
12029
12030 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12031 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12032 types are @code{Wide_Character} and @code{Wide_String} instead of
12033 @code{Character} and @code{String}.
12034 @end table
12035
12036
12037
12038 @node The Implementation of Standard I/O
12039 @chapter The Implementation of Standard I/O
12040
12041 @noindent
12042 GNAT implements all the required input-output facilities described in
12043 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12044 required behavior of these packages from the Ada point of view, and if
12045 you are writing a portable Ada program that does not need to know the
12046 exact manner in which Ada maps to the outside world when it comes to
12047 reading or writing external files, then you do not need to read this
12048 chapter.  As long as your files are all regular files (not pipes or
12049 devices), and as long as you write and read the files only from Ada, the
12050 description in the Ada Reference Manual is sufficient.
12051
12052 However, if you want to do input-output to pipes or other devices, such
12053 as the keyboard or screen, or if the files you are dealing with are
12054 either generated by some other language, or to be read by some other
12055 language, then you need to know more about the details of how the GNAT
12056 implementation of these input-output facilities behaves.
12057
12058 In this chapter we give a detailed description of exactly how GNAT
12059 interfaces to the file system.  As always, the sources of the system are
12060 available to you for answering questions at an even more detailed level,
12061 but for most purposes the information in this chapter will suffice.
12062
12063 Another reason that you may need to know more about how input-output is
12064 implemented arises when you have a program written in mixed languages
12065 where, for example, files are shared between the C and Ada sections of
12066 the same program.  GNAT provides some additional facilities, in the form
12067 of additional child library packages, that facilitate this sharing, and
12068 these additional facilities are also described in this chapter.
12069
12070 @menu
12071 * Standard I/O Packages::
12072 * FORM Strings::
12073 * Direct_IO::
12074 * Sequential_IO::
12075 * Text_IO::
12076 * Wide_Text_IO::
12077 * Wide_Wide_Text_IO::
12078 * Stream_IO::
12079 * Shared Files::
12080 * Filenames encoding::
12081 * Open Modes::
12082 * Operations on C Streams::
12083 * Interfacing to C Streams::
12084 @end menu
12085
12086 @node Standard I/O Packages
12087 @section Standard I/O Packages
12088
12089 @noindent
12090 The Standard I/O packages described in Annex A for
12091
12092 @itemize @bullet
12093 @item
12094 Ada.Text_IO
12095 @item
12096 Ada.Text_IO.Complex_IO
12097 @item
12098 Ada.Text_IO.Text_Streams
12099 @item
12100 Ada.Wide_Text_IO
12101 @item
12102 Ada.Wide_Text_IO.Complex_IO
12103 @item
12104 Ada.Wide_Text_IO.Text_Streams
12105 @item
12106 Ada.Wide_Wide_Text_IO
12107 @item
12108 Ada.Wide_Wide_Text_IO.Complex_IO
12109 @item
12110 Ada.Wide_Wide_Text_IO.Text_Streams
12111 @item
12112 Ada.Stream_IO
12113 @item
12114 Ada.Sequential_IO
12115 @item
12116 Ada.Direct_IO
12117 @end itemize
12118
12119 @noindent
12120 are implemented using the C
12121 library streams facility; where
12122
12123 @itemize @bullet
12124 @item
12125 All files are opened using @code{fopen}.
12126 @item
12127 All input/output operations use @code{fread}/@code{fwrite}.
12128 @end itemize
12129
12130 @noindent
12131 There is no internal buffering of any kind at the Ada library level. The only
12132 buffering is that provided at the system level in the implementation of the
12133 library routines that support streams. This facilitates shared use of these
12134 streams by mixed language programs. Note though that system level buffering is
12135 explicitly enabled at elaboration of the standard I/O packages and that can
12136 have an impact on mixed language programs, in particular those using I/O before
12137 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12138 the Ada elaboration routine before performing any I/O or when impractical,
12139 flush the common I/O streams and in particular Standard_Output before
12140 elaborating the Ada code.
12141
12142 @node FORM Strings
12143 @section FORM Strings
12144
12145 @noindent
12146 The format of a FORM string in GNAT is:
12147
12148 @smallexample
12149 "keyword=value,keyword=value,@dots{},keyword=value"
12150 @end smallexample
12151
12152 @noindent
12153 where letters may be in upper or lower case, and there are no spaces
12154 between values.  The order of the entries is not important.  Currently
12155 there are two keywords defined.
12156
12157 @smallexample
12158 SHARED=[YES|NO]
12159 WCEM=[n|h|u|s|e|8|b]
12160 @end smallexample
12161
12162 @noindent
12163 The use of these parameters is described later in this section.
12164
12165 @node Direct_IO
12166 @section Direct_IO
12167
12168 @noindent
12169 Direct_IO can only be instantiated for definite types.  This is a
12170 restriction of the Ada language, which means that the records are fixed
12171 length (the length being determined by @code{@var{type}'Size}, rounded
12172 up to the next storage unit boundary if necessary).
12173
12174 The records of a Direct_IO file are simply written to the file in index
12175 sequence, with the first record starting at offset zero, and subsequent
12176 records following.  There is no control information of any kind.  For
12177 example, if 32-bit integers are being written, each record takes
12178 4-bytes, so the record at index @var{K} starts at offset
12179 (@var{K}@minus{}1)*4.
12180
12181 There is no limit on the size of Direct_IO files, they are expanded as
12182 necessary to accommodate whatever records are written to the file.
12183
12184 @node Sequential_IO
12185 @section Sequential_IO
12186
12187 @noindent
12188 Sequential_IO may be instantiated with either a definite (constrained)
12189 or indefinite (unconstrained) type.
12190
12191 For the definite type case, the elements written to the file are simply
12192 the memory images of the data values with no control information of any
12193 kind.  The resulting file should be read using the same type, no validity
12194 checking is performed on input.
12195
12196 For the indefinite type case, the elements written consist of two
12197 parts.  First is the size of the data item, written as the memory image
12198 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12199 the data value.  The resulting file can only be read using the same
12200 (unconstrained) type.  Normal assignment checks are performed on these
12201 read operations, and if these checks fail, @code{Data_Error} is
12202 raised.  In particular, in the array case, the lengths must match, and in
12203 the variant record case, if the variable for a particular read operation
12204 is constrained, the discriminants must match.
12205
12206 Note that it is not possible to use Sequential_IO to write variable
12207 length array items, and then read the data back into different length
12208 arrays.  For example, the following will raise @code{Data_Error}:
12209
12210 @smallexample @c ada
12211  package IO is new Sequential_IO (String);
12212  F : IO.File_Type;
12213  S : String (1..4);
12214  @dots{}
12215  IO.Create (F)
12216  IO.Write (F, "hello!")
12217  IO.Reset (F, Mode=>In_File);
12218  IO.Read (F, S);
12219  Put_Line (S);
12220
12221 @end smallexample
12222
12223 @noindent
12224 On some Ada implementations, this will print @code{hell}, but the program is
12225 clearly incorrect, since there is only one element in the file, and that
12226 element is the string @code{hello!}.
12227
12228 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12229 using Stream_IO, and this is the preferred mechanism.  In particular, the
12230 above program fragment rewritten to use Stream_IO will work correctly.
12231
12232 @node Text_IO
12233 @section Text_IO
12234
12235 @noindent
12236 Text_IO files consist of a stream of characters containing the following
12237 special control characters:
12238
12239 @smallexample
12240 LF (line feed, 16#0A#) Line Mark
12241 FF (form feed, 16#0C#) Page Mark
12242 @end smallexample
12243
12244 @noindent
12245 A canonical Text_IO file is defined as one in which the following
12246 conditions are met:
12247
12248 @itemize @bullet
12249 @item
12250 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12251 of the line.
12252
12253 @item
12254 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12255 end of a page and consequently can appear only immediately following a
12256 @code{LF} (line mark) character.
12257
12258 @item
12259 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12260 (line mark, page mark).  In the former case, the page mark is implicitly
12261 assumed to be present.
12262 @end itemize
12263
12264 @noindent
12265 A file written using Text_IO will be in canonical form provided that no
12266 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12267 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12268 the file unless an explicit @code{New_Page} operation was performed
12269 before closing the file.
12270
12271 A canonical Text_IO file that is a regular file (i.e., not a device or a
12272 pipe) can be read using any of the routines in Text_IO@.  The
12273 semantics in this case will be exactly as defined in the Ada Reference
12274 Manual, and all the routines in Text_IO are fully implemented.
12275
12276 A text file that does not meet the requirements for a canonical Text_IO
12277 file has one of the following:
12278
12279 @itemize @bullet
12280 @item
12281 The file contains @code{FF} characters not immediately following a
12282 @code{LF} character.
12283
12284 @item
12285 The file contains @code{LF} or @code{FF} characters written by
12286 @code{Put} or @code{Put_Line}, which are not logically considered to be
12287 line marks or page marks.
12288
12289 @item
12290 The file ends in a character other than @code{LF} or @code{FF},
12291 i.e.@: there is no explicit line mark or page mark at the end of the file.
12292 @end itemize
12293
12294 @noindent
12295 Text_IO can be used to read such non-standard text files but subprograms
12296 to do with line or page numbers do not have defined meanings.  In
12297 particular, a @code{FF} character that does not follow a @code{LF}
12298 character may or may not be treated as a page mark from the point of
12299 view of page and line numbering.  Every @code{LF} character is considered
12300 to end a line, and there is an implied @code{LF} character at the end of
12301 the file.
12302
12303 @menu
12304 * Text_IO Stream Pointer Positioning::
12305 * Text_IO Reading and Writing Non-Regular Files::
12306 * Get_Immediate::
12307 * Treating Text_IO Files as Streams::
12308 * Text_IO Extensions::
12309 * Text_IO Facilities for Unbounded Strings::
12310 @end menu
12311
12312 @node Text_IO Stream Pointer Positioning
12313 @subsection Stream Pointer Positioning
12314
12315 @noindent
12316 @code{Ada.Text_IO} has a definition of current position for a file that
12317 is being read.  No internal buffering occurs in Text_IO, and usually the
12318 physical position in the stream used to implement the file corresponds
12319 to this logical position defined by Text_IO@.  There are two exceptions:
12320
12321 @itemize @bullet
12322 @item
12323 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12324 is positioned past the @code{LF} (line mark) that precedes the page
12325 mark.  Text_IO maintains an internal flag so that subsequent read
12326 operations properly handle the logical position which is unchanged by
12327 the @code{End_Of_Page} call.
12328
12329 @item
12330 After a call to @code{End_Of_File} that returns @code{True}, if the
12331 Text_IO file was positioned before the line mark at the end of file
12332 before the call, then the logical position is unchanged, but the stream
12333 is physically positioned right at the end of file (past the line mark,
12334 and past a possible page mark following the line mark.  Again Text_IO
12335 maintains internal flags so that subsequent read operations properly
12336 handle the logical position.
12337 @end itemize
12338
12339 @noindent
12340 These discrepancies have no effect on the observable behavior of
12341 Text_IO, but if a single Ada stream is shared between a C program and
12342 Ada program, or shared (using @samp{shared=yes} in the form string)
12343 between two Ada files, then the difference may be observable in some
12344 situations.
12345
12346 @node Text_IO Reading and Writing Non-Regular Files
12347 @subsection Reading and Writing Non-Regular Files
12348
12349 @noindent
12350 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12351 can be used for reading and writing.  Writing is not affected and the
12352 sequence of characters output is identical to the normal file case, but
12353 for reading, the behavior of Text_IO is modified to avoid undesirable
12354 look-ahead as follows:
12355
12356 An input file that is not a regular file is considered to have no page
12357 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12358 page mark) appearing in the file are considered to be data
12359 characters.  In particular:
12360
12361 @itemize @bullet
12362 @item
12363 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12364 following a line mark.  If a page mark appears, it will be treated as a
12365 data character.
12366
12367 @item
12368 This avoids the need to wait for an extra character to be typed or
12369 entered from the pipe to complete one of these operations.
12370
12371 @item
12372 @code{End_Of_Page} always returns @code{False}
12373
12374 @item
12375 @code{End_Of_File} will return @code{False} if there is a page mark at
12376 the end of the file.
12377 @end itemize
12378
12379 @noindent
12380 Output to non-regular files is the same as for regular files.  Page marks
12381 may be written to non-regular files using @code{New_Page}, but as noted
12382 above they will not be treated as page marks on input if the output is
12383 piped to another Ada program.
12384
12385 Another important discrepancy when reading non-regular files is that the end
12386 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12387 pressing the @key{EOT} key,
12388 then end of file
12389 is signaled once (i.e.@: the test @code{End_Of_File}
12390 will yield @code{True}, or a read will
12391 raise @code{End_Error}), but then reading can resume
12392 to read data past that end of
12393 file indication, until another end of file indication is entered.
12394
12395 @node Get_Immediate
12396 @subsection Get_Immediate
12397 @cindex Get_Immediate
12398
12399 @noindent
12400 Get_Immediate returns the next character (including control characters)
12401 from the input file.  In particular, Get_Immediate will return LF or FF
12402 characters used as line marks or page marks.  Such operations leave the
12403 file positioned past the control character, and it is thus not treated
12404 as having its normal function.  This means that page, line and column
12405 counts after this kind of Get_Immediate call are set as though the mark
12406 did not occur.  In the case where a Get_Immediate leaves the file
12407 positioned between the line mark and page mark (which is not normally
12408 possible), it is undefined whether the FF character will be treated as a
12409 page mark.
12410
12411 @node Treating Text_IO Files as Streams
12412 @subsection Treating Text_IO Files as Streams
12413 @cindex Stream files
12414
12415 @noindent
12416 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12417 as a stream.  Data written to a Text_IO file in this stream mode is
12418 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12419 16#0C# (@code{FF}), the resulting file may have non-standard
12420 format.  Similarly if read operations are used to read from a Text_IO
12421 file treated as a stream, then @code{LF} and @code{FF} characters may be
12422 skipped and the effect is similar to that described above for
12423 @code{Get_Immediate}.
12424
12425 @node Text_IO Extensions
12426 @subsection Text_IO Extensions
12427 @cindex Text_IO extensions
12428
12429 @noindent
12430 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12431 to the standard @code{Text_IO} package:
12432
12433 @itemize @bullet
12434 @item function File_Exists (Name : String) return Boolean;
12435 Determines if a file of the given name exists.
12436
12437 @item function Get_Line return String;
12438 Reads a string from the standard input file.  The value returned is exactly
12439 the length of the line that was read.
12440
12441 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12442 Similar, except that the parameter File specifies the file from which
12443 the string is to be read.
12444
12445 @end itemize
12446
12447 @node Text_IO Facilities for Unbounded Strings
12448 @subsection Text_IO Facilities for Unbounded Strings
12449 @cindex Text_IO for unbounded strings
12450 @cindex Unbounded_String, Text_IO operations
12451
12452 @noindent
12453 The package @code{Ada.Strings.Unbounded.Text_IO}
12454 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12455 subprograms useful for Text_IO operations on unbounded strings:
12456
12457 @itemize @bullet
12458
12459 @item function Get_Line (File : File_Type) return Unbounded_String;
12460 Reads a line from the specified file
12461 and returns the result as an unbounded string.
12462
12463 @item procedure Put (File : File_Type; U : Unbounded_String);
12464 Writes the value of the given unbounded string to the specified file
12465 Similar to the effect of
12466 @code{Put (To_String (U))} except that an extra copy is avoided.
12467
12468 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12469 Writes the value of the given unbounded string to the specified file,
12470 followed by a @code{New_Line}.
12471 Similar to the effect of @code{Put_Line (To_String (U))} except
12472 that an extra copy is avoided.
12473 @end itemize
12474
12475 @noindent
12476 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12477 and is optional.  If the parameter is omitted, then the standard input or
12478 output file is referenced as appropriate.
12479
12480 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12481 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12482 @code{Wide_Text_IO} functionality for unbounded wide strings.
12483
12484 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12485 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12486 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12487
12488 @node Wide_Text_IO
12489 @section Wide_Text_IO
12490
12491 @noindent
12492 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12493 both input and output files may contain special sequences that represent
12494 wide character values.  The encoding scheme for a given file may be
12495 specified using a FORM parameter:
12496
12497 @smallexample
12498 WCEM=@var{x}
12499 @end smallexample
12500
12501 @noindent
12502 as part of the FORM string (WCEM = wide character encoding method),
12503 where @var{x} is one of the following characters
12504
12505 @table @samp
12506 @item h
12507 Hex ESC encoding
12508 @item u
12509 Upper half encoding
12510 @item s
12511 Shift-JIS encoding
12512 @item e
12513 EUC Encoding
12514 @item 8
12515 UTF-8 encoding
12516 @item b
12517 Brackets encoding
12518 @end table
12519
12520 @noindent
12521 The encoding methods match those that
12522 can be used in a source
12523 program, but there is no requirement that the encoding method used for
12524 the source program be the same as the encoding method used for files,
12525 and different files may use different encoding methods.
12526
12527 The default encoding method for the standard files, and for opened files
12528 for which no WCEM parameter is given in the FORM string matches the
12529 wide character encoding specified for the main program (the default
12530 being brackets encoding if no coding method was specified with -gnatW).
12531
12532 @table @asis
12533 @item Hex Coding
12534 In this encoding, a wide character is represented by a five character
12535 sequence:
12536
12537 @smallexample
12538 ESC a b c d
12539 @end smallexample
12540
12541 @noindent
12542 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12543 characters (using upper case letters) of the wide character code.  For
12544 example, ESC A345 is used to represent the wide character with code
12545 16#A345#.  This scheme is compatible with use of the full
12546 @code{Wide_Character} set.
12547
12548 @item Upper Half Coding
12549 The wide character with encoding 16#abcd#, where the upper bit is on
12550 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12551 16#cd#.  The second byte may never be a format control character, but is
12552 not required to be in the upper half.  This method can be also used for
12553 shift-JIS or EUC where the internal coding matches the external coding.
12554
12555 @item Shift JIS Coding
12556 A wide character is represented by a two character sequence 16#ab# and
12557 16#cd#, with the restrictions described for upper half encoding as
12558 described above.  The internal character code is the corresponding JIS
12559 character according to the standard algorithm for Shift-JIS
12560 conversion.  Only characters defined in the JIS code set table can be
12561 used with this encoding method.
12562
12563 @item EUC Coding
12564 A wide character is represented by a two character sequence 16#ab# and
12565 16#cd#, with both characters being in the upper half.  The internal
12566 character code is the corresponding JIS character according to the EUC
12567 encoding algorithm.  Only characters defined in the JIS code set table
12568 can be used with this encoding method.
12569
12570 @item UTF-8 Coding
12571 A wide character is represented using
12572 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12573 10646-1/Am.2.  Depending on the character value, the representation
12574 is a one, two, or three byte sequence:
12575
12576 @smallexample
12577 16#0000#-16#007f#: 2#0xxxxxxx#
12578 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12579 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12580 @end smallexample
12581
12582 @noindent
12583 where the @var{xxx} bits correspond to the left-padded bits of the
12584 16-bit character value.  Note that all lower half ASCII characters
12585 are represented as ASCII bytes and all upper half characters and
12586 other wide characters are represented as sequences of upper-half
12587 (The full UTF-8 scheme allows for encoding 31-bit characters as
12588 6-byte sequences, but in this implementation, all UTF-8 sequences
12589 of four or more bytes length will raise a Constraint_Error, as
12590 will all invalid UTF-8 sequences.)
12591
12592 @item Brackets Coding
12593 In this encoding, a wide character is represented by the following eight
12594 character sequence:
12595
12596 @smallexample
12597 [ " a b c d " ]
12598 @end smallexample
12599
12600 @noindent
12601 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12602 characters (using uppercase letters) of the wide character code.  For
12603 example, @code{["A345"]} is used to represent the wide character with code
12604 @code{16#A345#}.
12605 This scheme is compatible with use of the full Wide_Character set.
12606 On input, brackets coding can also be used for upper half characters,
12607 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12608 is only used for wide characters with a code greater than @code{16#FF#}.
12609
12610 Note that brackets coding is not normally used in the context of
12611 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12612 a portable way of encoding source files. In the context of Wide_Text_IO
12613 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12614 any instance of the left bracket character other than to encode wide
12615 character values using the brackets encoding method. In practice it is
12616 expected that some standard wide character encoding method such
12617 as UTF-8 will be used for text input output.
12618
12619 If brackets notation is used, then any occurrence of a left bracket
12620 in the input file which is not the start of a valid wide character
12621 sequence will cause Constraint_Error to be raised. It is possible to
12622 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12623 input will interpret this as a left bracket.
12624
12625 However, when a left bracket is output, it will be output as a left bracket
12626 and not as ["5B"]. We make this decision because for normal use of
12627 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12628 brackets. For example, if we write:
12629
12630 @smallexample
12631    Put_Line ("Start of output [first run]");
12632 @end smallexample
12633
12634 @noindent
12635 we really do not want to have the left bracket in this message clobbered so
12636 that the output reads:
12637
12638 @smallexample
12639    Start of output ["5B"]first run]
12640 @end smallexample
12641
12642 @noindent
12643 In practice brackets encoding is reasonably useful for normal Put_Line use
12644 since we won't get confused between left brackets and wide character
12645 sequences in the output. But for input, or when files are written out
12646 and read back in, it really makes better sense to use one of the standard
12647 encoding methods such as UTF-8.
12648
12649 @end table
12650
12651 @noindent
12652 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12653 not all wide character
12654 values can be represented.  An attempt to output a character that cannot
12655 be represented using the encoding scheme for the file causes
12656 Constraint_Error to be raised.  An invalid wide character sequence on
12657 input also causes Constraint_Error to be raised.
12658
12659 @menu
12660 * Wide_Text_IO Stream Pointer Positioning::
12661 * Wide_Text_IO Reading and Writing Non-Regular Files::
12662 @end menu
12663
12664 @node Wide_Text_IO Stream Pointer Positioning
12665 @subsection Stream Pointer Positioning
12666
12667 @noindent
12668 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12669 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12670 case:
12671
12672 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12673 normal lower ASCII set (i.e.@: a character in the range:
12674
12675 @smallexample @c ada
12676 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12677 @end smallexample
12678
12679 @noindent
12680 then although the logical position of the file pointer is unchanged by
12681 the @code{Look_Ahead} call, the stream is physically positioned past the
12682 wide character sequence.  Again this is to avoid the need for buffering
12683 or backup, and all @code{Wide_Text_IO} routines check the internal
12684 indication that this situation has occurred so that this is not visible
12685 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12686 can be observed if the wide text file shares a stream with another file.
12687
12688 @node Wide_Text_IO Reading and Writing Non-Regular Files
12689 @subsection Reading and Writing Non-Regular Files
12690
12691 @noindent
12692 As in the case of Text_IO, when a non-regular file is read, it is
12693 assumed that the file contains no page marks (any form characters are
12694 treated as data characters), and @code{End_Of_Page} always returns
12695 @code{False}.  Similarly, the end of file indication is not sticky, so
12696 it is possible to read beyond an end of file.
12697
12698 @node Wide_Wide_Text_IO
12699 @section Wide_Wide_Text_IO
12700
12701 @noindent
12702 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12703 both input and output files may contain special sequences that represent
12704 wide wide character values.  The encoding scheme for a given file may be
12705 specified using a FORM parameter:
12706
12707 @smallexample
12708 WCEM=@var{x}
12709 @end smallexample
12710
12711 @noindent
12712 as part of the FORM string (WCEM = wide character encoding method),
12713 where @var{x} is one of the following characters
12714
12715 @table @samp
12716 @item h
12717 Hex ESC encoding
12718 @item u
12719 Upper half encoding
12720 @item s
12721 Shift-JIS encoding
12722 @item e
12723 EUC Encoding
12724 @item 8
12725 UTF-8 encoding
12726 @item b
12727 Brackets encoding
12728 @end table
12729
12730 @noindent
12731 The encoding methods match those that
12732 can be used in a source
12733 program, but there is no requirement that the encoding method used for
12734 the source program be the same as the encoding method used for files,
12735 and different files may use different encoding methods.
12736
12737 The default encoding method for the standard files, and for opened files
12738 for which no WCEM parameter is given in the FORM string matches the
12739 wide character encoding specified for the main program (the default
12740 being brackets encoding if no coding method was specified with -gnatW).
12741
12742 @table @asis
12743
12744 @item UTF-8 Coding
12745 A wide character is represented using
12746 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12747 10646-1/Am.2.  Depending on the character value, the representation
12748 is a one, two, three, or four byte sequence:
12749
12750 @smallexample
12751 16#000000#-16#00007f#: 2#0xxxxxxx#
12752 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12753 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12754 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12755 @end smallexample
12756
12757 @noindent
12758 where the @var{xxx} bits correspond to the left-padded bits of the
12759 21-bit character value.  Note that all lower half ASCII characters
12760 are represented as ASCII bytes and all upper half characters and
12761 other wide characters are represented as sequences of upper-half
12762 characters.
12763
12764 @item Brackets Coding
12765 In this encoding, a wide wide character is represented by the following eight
12766 character sequence if is in wide character range
12767
12768 @smallexample
12769 [ " a b c d " ]
12770 @end smallexample
12771
12772 and by the following ten character sequence if not
12773
12774 @smallexample
12775 [ " a b c d e f " ]
12776 @end smallexample
12777
12778 @noindent
12779 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12780 are the four or six hexadecimal
12781 characters (using uppercase letters) of the wide wide character code.  For
12782 example, @code{["01A345"]} is used to represent the wide wide character
12783 with code @code{16#01A345#}.
12784
12785 This scheme is compatible with use of the full Wide_Wide_Character set.
12786 On input, brackets coding can also be used for upper half characters,
12787 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12788 is only used for wide characters with a code greater than @code{16#FF#}.
12789
12790 @end table
12791
12792 @noindent
12793 If is also possible to use the other Wide_Character encoding methods,
12794 such as Shift-JIS, but the other schemes cannot support the full range
12795 of wide wide characters.
12796 An attempt to output a character that cannot
12797 be represented using the encoding scheme for the file causes
12798 Constraint_Error to be raised.  An invalid wide character sequence on
12799 input also causes Constraint_Error to be raised.
12800
12801 @menu
12802 * Wide_Wide_Text_IO Stream Pointer Positioning::
12803 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12804 @end menu
12805
12806 @node Wide_Wide_Text_IO Stream Pointer Positioning
12807 @subsection Stream Pointer Positioning
12808
12809 @noindent
12810 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12811 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12812 case:
12813
12814 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12815 normal lower ASCII set (i.e.@: a character in the range:
12816
12817 @smallexample @c ada
12818 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12819 @end smallexample
12820
12821 @noindent
12822 then although the logical position of the file pointer is unchanged by
12823 the @code{Look_Ahead} call, the stream is physically positioned past the
12824 wide character sequence.  Again this is to avoid the need for buffering
12825 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12826 indication that this situation has occurred so that this is not visible
12827 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12828 can be observed if the wide text file shares a stream with another file.
12829
12830 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12831 @subsection Reading and Writing Non-Regular Files
12832
12833 @noindent
12834 As in the case of Text_IO, when a non-regular file is read, it is
12835 assumed that the file contains no page marks (any form characters are
12836 treated as data characters), and @code{End_Of_Page} always returns
12837 @code{False}.  Similarly, the end of file indication is not sticky, so
12838 it is possible to read beyond an end of file.
12839
12840 @node Stream_IO
12841 @section Stream_IO
12842
12843 @noindent
12844 A stream file is a sequence of bytes, where individual elements are
12845 written to the file as described in the Ada Reference Manual.  The type
12846 @code{Stream_Element} is simply a byte.  There are two ways to read or
12847 write a stream file.
12848
12849 @itemize @bullet
12850 @item
12851 The operations @code{Read} and @code{Write} directly read or write a
12852 sequence of stream elements with no control information.
12853
12854 @item
12855 The stream attributes applied to a stream file transfer data in the
12856 manner described for stream attributes.
12857 @end itemize
12858
12859 @node Shared Files
12860 @section Shared Files
12861
12862 @noindent
12863 Section A.14 of the Ada Reference Manual allows implementations to
12864 provide a wide variety of behavior if an attempt is made to access the
12865 same external file with two or more internal files.
12866
12867 To provide a full range of functionality, while at the same time
12868 minimizing the problems of portability caused by this implementation
12869 dependence, GNAT handles file sharing as follows:
12870
12871 @itemize @bullet
12872 @item
12873 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12874 to open two or more files with the same full name is considered an error
12875 and is not supported.  The exception @code{Use_Error} will be
12876 raised.  Note that a file that is not explicitly closed by the program
12877 remains open until the program terminates.
12878
12879 @item
12880 If the form parameter @samp{shared=no} appears in the form string, the
12881 file can be opened or created with its own separate stream identifier,
12882 regardless of whether other files sharing the same external file are
12883 opened.  The exact effect depends on how the C stream routines handle
12884 multiple accesses to the same external files using separate streams.
12885
12886 @item
12887 If the form parameter @samp{shared=yes} appears in the form string for
12888 each of two or more files opened using the same full name, the same
12889 stream is shared between these files, and the semantics are as described
12890 in Ada Reference Manual, Section A.14.
12891 @end itemize
12892
12893 @noindent
12894 When a program that opens multiple files with the same name is ported
12895 from another Ada compiler to GNAT, the effect will be that
12896 @code{Use_Error} is raised.
12897
12898 The documentation of the original compiler and the documentation of the
12899 program should then be examined to determine if file sharing was
12900 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12901 and @code{Create} calls as required.
12902
12903 When a program is ported from GNAT to some other Ada compiler, no
12904 special attention is required unless the @samp{shared=@var{xxx}} form
12905 parameter is used in the program.  In this case, you must examine the
12906 documentation of the new compiler to see if it supports the required
12907 file sharing semantics, and form strings modified appropriately.  Of
12908 course it may be the case that the program cannot be ported if the
12909 target compiler does not support the required functionality.  The best
12910 approach in writing portable code is to avoid file sharing (and hence
12911 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12912 completely.
12913
12914 One common use of file sharing in Ada 83 is the use of instantiations of
12915 Sequential_IO on the same file with different types, to achieve
12916 heterogeneous input-output.  Although this approach will work in GNAT if
12917 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12918 for this purpose (using the stream attributes)
12919
12920 @node Filenames encoding
12921 @section Filenames encoding
12922
12923 @noindent
12924 An encoding form parameter can be used to specify the filename
12925 encoding @samp{encoding=@var{xxx}}.
12926
12927 @itemize @bullet
12928 @item
12929 If the form parameter @samp{encoding=utf8} appears in the form string, the
12930 filename must be encoded in UTF-8.
12931
12932 @item
12933 If the form parameter @samp{encoding=8bits} appears in the form
12934 string, the filename must be a standard 8bits string.
12935 @end itemize
12936
12937 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12938 value UTF-8 is used. This encoding form parameter is only supported on
12939 the Windows platform. On the other Operating Systems the runtime is
12940 supporting UTF-8 natively.
12941
12942 @node Open Modes
12943 @section Open Modes
12944
12945 @noindent
12946 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12947 using the mode shown in the following table:
12948
12949 @sp 2
12950 @center @code{Open} and @code{Create} Call Modes
12951 @smallexample
12952                                @b{OPEN }           @b{CREATE}
12953 Append_File                    "r+"             "w+"
12954 In_File                        "r"              "w+"
12955 Out_File (Direct_IO)           "r+"             "w"
12956 Out_File (all other cases)     "w"              "w"
12957 Inout_File                     "r+"             "w+"
12958 @end smallexample
12959
12960 @noindent
12961 If text file translation is required, then either @samp{b} or @samp{t}
12962 is added to the mode, depending on the setting of Text.  Text file
12963 translation refers to the mapping of CR/LF sequences in an external file
12964 to LF characters internally.  This mapping only occurs in DOS and
12965 DOS-like systems, and is not relevant to other systems.
12966
12967 A special case occurs with Stream_IO@.  As shown in the above table, the
12968 file is initially opened in @samp{r} or @samp{w} mode for the
12969 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12970 subsequently requires switching from reading to writing or vice-versa,
12971 then the file is reopened in @samp{r+} mode to permit the required operation.
12972
12973 @node Operations on C Streams
12974 @section Operations on C Streams
12975 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12976 access to the C library functions for operations on C streams:
12977
12978 @smallexample @c adanocomment
12979 package Interfaces.C_Streams is
12980   -- Note: the reason we do not use the types that are in
12981   -- Interfaces.C is that we want to avoid dragging in the
12982   -- code in this unit if possible.
12983   subtype chars is System.Address;
12984   -- Pointer to null-terminated array of characters
12985   subtype FILEs is System.Address;
12986   -- Corresponds to the C type FILE*
12987   subtype voids is System.Address;
12988   -- Corresponds to the C type void*
12989   subtype int is Integer;
12990   subtype long is Long_Integer;
12991   -- Note: the above types are subtypes deliberately, and it
12992   -- is part of this spec that the above correspondences are
12993   -- guaranteed.  This means that it is legitimate to, for
12994   -- example, use Integer instead of int.  We provide these
12995   -- synonyms for clarity, but in some cases it may be
12996   -- convenient to use the underlying types (for example to
12997   -- avoid an unnecessary dependency of a spec on the spec
12998   -- of this unit).
12999   type size_t is mod 2 ** Standard'Address_Size;
13000   NULL_Stream : constant FILEs;
13001   -- Value returned (NULL in C) to indicate an
13002   -- fdopen/fopen/tmpfile error
13003   ----------------------------------
13004   -- Constants Defined in stdio.h --
13005   ----------------------------------
13006   EOF : constant int;
13007   -- Used by a number of routines to indicate error or
13008   -- end of file
13009   IOFBF : constant int;
13010   IOLBF : constant int;
13011   IONBF : constant int;
13012   -- Used to indicate buffering mode for setvbuf call
13013   SEEK_CUR : constant int;
13014   SEEK_END : constant int;
13015   SEEK_SET : constant int;
13016   -- Used to indicate origin for fseek call
13017   function stdin return FILEs;
13018   function stdout return FILEs;
13019   function stderr return FILEs;
13020   -- Streams associated with standard files
13021   --------------------------
13022   -- Standard C functions --
13023   --------------------------
13024   -- The functions selected below are ones that are
13025   -- available in DOS, OS/2, UNIX and Xenix (but not
13026   -- necessarily in ANSI C).  These are very thin interfaces
13027   -- which copy exactly the C headers.  For more
13028   -- documentation on these functions, see the Microsoft C
13029   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13030   -- ISBN 1-55615-225-6), which includes useful information
13031   -- on system compatibility.
13032   procedure clearerr (stream : FILEs);
13033   function fclose (stream : FILEs) return int;
13034   function fdopen (handle : int; mode : chars) return FILEs;
13035   function feof (stream : FILEs) return int;
13036   function ferror (stream : FILEs) return int;
13037   function fflush (stream : FILEs) return int;
13038   function fgetc (stream : FILEs) return int;
13039   function fgets (strng : chars; n : int; stream : FILEs)
13040       return chars;
13041   function fileno (stream : FILEs) return int;
13042   function fopen (filename : chars; Mode : chars)
13043       return FILEs;
13044   -- Note: to maintain target independence, use
13045   -- text_translation_required, a boolean variable defined in
13046   -- a-sysdep.c to deal with the target dependent text
13047   -- translation requirement.  If this variable is set,
13048   -- then  b/t should be appended to the standard mode
13049   -- argument to set the text translation mode off or on
13050   -- as required.
13051   function fputc (C : int; stream : FILEs) return int;
13052   function fputs (Strng : chars; Stream : FILEs) return int;
13053   function fread
13054      (buffer : voids;
13055       size : size_t;
13056       count : size_t;
13057       stream : FILEs)
13058       return size_t;
13059   function freopen
13060      (filename : chars;
13061       mode : chars;
13062       stream : FILEs)
13063       return FILEs;
13064   function fseek
13065      (stream : FILEs;
13066       offset : long;
13067       origin : int)
13068       return int;
13069   function ftell (stream : FILEs) return long;
13070   function fwrite
13071      (buffer : voids;
13072       size : size_t;
13073       count : size_t;
13074       stream : FILEs)
13075       return size_t;
13076   function isatty (handle : int) return int;
13077   procedure mktemp (template : chars);
13078   -- The return value (which is just a pointer to template)
13079   -- is discarded
13080   procedure rewind (stream : FILEs);
13081   function rmtmp return int;
13082   function setvbuf
13083      (stream : FILEs;
13084       buffer : chars;
13085       mode : int;
13086       size : size_t)
13087       return int;
13088
13089   function tmpfile return FILEs;
13090   function ungetc (c : int; stream : FILEs) return int;
13091   function unlink (filename : chars) return int;
13092   ---------------------
13093   -- Extra functions --
13094   ---------------------
13095   -- These functions supply slightly thicker bindings than
13096   -- those above.  They are derived from functions in the
13097   -- C Run-Time Library, but may do a bit more work than
13098   -- just directly calling one of the Library functions.
13099   function is_regular_file (handle : int) return int;
13100   -- Tests if given handle is for a regular file (result 1)
13101   -- or for a non-regular file (pipe or device, result 0).
13102   ---------------------------------
13103   -- Control of Text/Binary Mode --
13104   ---------------------------------
13105   -- If text_translation_required is true, then the following
13106   -- functions may be used to dynamically switch a file from
13107   -- binary to text mode or vice versa.  These functions have
13108   -- no effect if text_translation_required is false (i.e.@: in
13109   -- normal UNIX mode).  Use fileno to get a stream handle.
13110   procedure set_binary_mode (handle : int);
13111   procedure set_text_mode (handle : int);
13112   ----------------------------
13113   -- Full Path Name support --
13114   ----------------------------
13115   procedure full_name (nam : chars; buffer : chars);
13116   -- Given a NUL terminated string representing a file
13117   -- name, returns in buffer a NUL terminated string
13118   -- representing the full path name for the file name.
13119   -- On systems where it is relevant the   drive is also
13120   -- part of the full path name.  It is the responsibility
13121   -- of the caller to pass an actual parameter for buffer
13122   -- that is big enough for any full path name.  Use
13123   -- max_path_len given below as the size of buffer.
13124   max_path_len : integer;
13125   -- Maximum length of an allowable full path name on the
13126   -- system, including a terminating NUL character.
13127 end Interfaces.C_Streams;
13128 @end smallexample
13129
13130 @node Interfacing to C Streams
13131 @section Interfacing to C Streams
13132
13133 @noindent
13134 The packages in this section permit interfacing Ada files to C Stream
13135 operations.
13136
13137 @smallexample @c ada
13138  with Interfaces.C_Streams;
13139  package Ada.Sequential_IO.C_Streams is
13140     function C_Stream (F : File_Type)
13141        return Interfaces.C_Streams.FILEs;
13142     procedure Open
13143       (File : in out File_Type;
13144        Mode : in File_Mode;
13145        C_Stream : in Interfaces.C_Streams.FILEs;
13146        Form : in String := "");
13147  end Ada.Sequential_IO.C_Streams;
13148
13149   with Interfaces.C_Streams;
13150   package Ada.Direct_IO.C_Streams is
13151      function C_Stream (F : File_Type)
13152         return Interfaces.C_Streams.FILEs;
13153      procedure Open
13154        (File : in out File_Type;
13155         Mode : in File_Mode;
13156         C_Stream : in Interfaces.C_Streams.FILEs;
13157         Form : in String := "");
13158   end Ada.Direct_IO.C_Streams;
13159
13160   with Interfaces.C_Streams;
13161   package Ada.Text_IO.C_Streams is
13162      function C_Stream (F : File_Type)
13163         return Interfaces.C_Streams.FILEs;
13164      procedure Open
13165        (File : in out File_Type;
13166         Mode : in File_Mode;
13167         C_Stream : in Interfaces.C_Streams.FILEs;
13168         Form : in String := "");
13169   end Ada.Text_IO.C_Streams;
13170
13171   with Interfaces.C_Streams;
13172   package Ada.Wide_Text_IO.C_Streams is
13173      function C_Stream (F : File_Type)
13174         return Interfaces.C_Streams.FILEs;
13175      procedure Open
13176        (File : in out File_Type;
13177         Mode : in File_Mode;
13178         C_Stream : in Interfaces.C_Streams.FILEs;
13179         Form : in String := "");
13180  end Ada.Wide_Text_IO.C_Streams;
13181
13182   with Interfaces.C_Streams;
13183   package Ada.Wide_Wide_Text_IO.C_Streams is
13184      function C_Stream (F : File_Type)
13185         return Interfaces.C_Streams.FILEs;
13186      procedure Open
13187        (File : in out File_Type;
13188         Mode : in File_Mode;
13189         C_Stream : in Interfaces.C_Streams.FILEs;
13190         Form : in String := "");
13191  end Ada.Wide_Wide_Text_IO.C_Streams;
13192
13193  with Interfaces.C_Streams;
13194  package Ada.Stream_IO.C_Streams is
13195     function C_Stream (F : File_Type)
13196        return Interfaces.C_Streams.FILEs;
13197     procedure Open
13198       (File : in out File_Type;
13199        Mode : in File_Mode;
13200        C_Stream : in Interfaces.C_Streams.FILEs;
13201        Form : in String := "");
13202  end Ada.Stream_IO.C_Streams;
13203 @end smallexample
13204
13205 @noindent
13206 In each of these six packages, the @code{C_Stream} function obtains the
13207 @code{FILE} pointer from a currently opened Ada file.  It is then
13208 possible to use the @code{Interfaces.C_Streams} package to operate on
13209 this stream, or the stream can be passed to a C program which can
13210 operate on it directly.  Of course the program is responsible for
13211 ensuring that only appropriate sequences of operations are executed.
13212
13213 One particular use of relevance to an Ada program is that the
13214 @code{setvbuf} function can be used to control the buffering of the
13215 stream used by an Ada file.  In the absence of such a call the standard
13216 default buffering is used.
13217
13218 The @code{Open} procedures in these packages open a file giving an
13219 existing C Stream instead of a file name.  Typically this stream is
13220 imported from a C program, allowing an Ada file to operate on an
13221 existing C file.
13222
13223 @node The GNAT Library
13224 @chapter The GNAT Library
13225
13226 @noindent
13227 The GNAT library contains a number of general and special purpose packages.
13228 It represents functionality that the GNAT developers have found useful, and
13229 which is made available to GNAT users.  The packages described here are fully
13230 supported, and upwards compatibility will be maintained in future releases,
13231 so you can use these facilities with the confidence that the same functionality
13232 will be available in future releases.
13233
13234 The chapter here simply gives a brief summary of the facilities available.
13235 The full documentation is found in the spec file for the package.  The full
13236 sources of these library packages, including both spec and body, are provided
13237 with all GNAT releases.  For example, to find out the full specifications of
13238 the SPITBOL pattern matching capability, including a full tutorial and
13239 extensive examples, look in the @file{g-spipat.ads} file in the library.
13240
13241 For each entry here, the package name (as it would appear in a @code{with}
13242 clause) is given, followed by the name of the corresponding spec file in
13243 parentheses.  The packages are children in four hierarchies, @code{Ada},
13244 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13245 GNAT-specific hierarchy.
13246
13247 Note that an application program should only use packages in one of these
13248 four hierarchies if the package is defined in the Ada Reference Manual,
13249 or is listed in this section of the GNAT Programmers Reference Manual.
13250 All other units should be considered internal implementation units and
13251 should not be directly @code{with}'ed by application code.  The use of
13252 a @code{with} statement that references one of these internal implementation
13253 units makes an application potentially dependent on changes in versions
13254 of GNAT, and will generate a warning message.
13255
13256 @menu
13257 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13258 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13259 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13260 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13261 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13262 * Ada.Command_Line.Environment (a-colien.ads)::
13263 * Ada.Command_Line.Remove (a-colire.ads)::
13264 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13265 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13266 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13267 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13268 * Ada.Exceptions.Traceback (a-exctra.ads)::
13269 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13270 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13271 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13272 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13273 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13274 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13275 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13276 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13277 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13278 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13279 * GNAT.Altivec (g-altive.ads)::
13280 * GNAT.Altivec.Conversions (g-altcon.ads)::
13281 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13282 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13283 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13284 * GNAT.Array_Split (g-arrspl.ads)::
13285 * GNAT.AWK (g-awk.ads)::
13286 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13287 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13288 * GNAT.Bubble_Sort (g-bubsor.ads)::
13289 * GNAT.Bubble_Sort_A (g-busora.ads)::
13290 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13291 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13292 * GNAT.Byte_Swapping (g-bytswa.ads)::
13293 * GNAT.Calendar (g-calend.ads)::
13294 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13295 * GNAT.Case_Util (g-casuti.ads)::
13296 * GNAT.CGI (g-cgi.ads)::
13297 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13298 * GNAT.CGI.Debug (g-cgideb.ads)::
13299 * GNAT.Command_Line (g-comlin.ads)::
13300 * GNAT.Compiler_Version (g-comver.ads)::
13301 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13302 * GNAT.CRC32 (g-crc32.ads)::
13303 * GNAT.Current_Exception (g-curexc.ads)::
13304 * GNAT.Debug_Pools (g-debpoo.ads)::
13305 * GNAT.Debug_Utilities (g-debuti.ads)::
13306 * GNAT.Decode_String (g-decstr.ads)::
13307 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13308 * GNAT.Directory_Operations (g-dirope.ads)::
13309 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13310 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13311 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13312 * GNAT.Encode_String (g-encstr.ads)::
13313 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13314 * GNAT.Exception_Actions (g-excact.ads)::
13315 * GNAT.Exception_Traces (g-exctra.ads)::
13316 * GNAT.Exceptions (g-except.ads)::
13317 * GNAT.Expect (g-expect.ads)::
13318 * GNAT.Float_Control (g-flocon.ads)::
13319 * GNAT.Heap_Sort (g-heasor.ads)::
13320 * GNAT.Heap_Sort_A (g-hesora.ads)::
13321 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13322 * GNAT.HTable (g-htable.ads)::
13323 * GNAT.IO (g-io.ads)::
13324 * GNAT.IO_Aux (g-io_aux.ads)::
13325 * GNAT.Lock_Files (g-locfil.ads)::
13326 * GNAT.MD5 (g-md5.ads)::
13327 * GNAT.Memory_Dump (g-memdum.ads)::
13328 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13329 * GNAT.OS_Lib (g-os_lib.ads)::
13330 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13331 * GNAT.Random_Numbers (g-rannum.ads)::
13332 * GNAT.Regexp (g-regexp.ads)::
13333 * GNAT.Registry (g-regist.ads)::
13334 * GNAT.Regpat (g-regpat.ads)::
13335 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13336 * GNAT.Semaphores (g-semaph.ads)::
13337 * GNAT.Serial_Communications (g-sercom.ads)::
13338 * GNAT.SHA1 (g-sha1.ads)::
13339 * GNAT.Signals (g-signal.ads)::
13340 * GNAT.Sockets (g-socket.ads)::
13341 * GNAT.Source_Info (g-souinf.ads)::
13342 * GNAT.Spelling_Checker (g-speche.ads)::
13343 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13344 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13345 * GNAT.Spitbol (g-spitbo.ads)::
13346 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13347 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13348 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13349 * GNAT.Strings (g-string.ads)::
13350 * GNAT.String_Split (g-strspl.ads)::
13351 * GNAT.Table (g-table.ads)::
13352 * GNAT.Task_Lock (g-tasloc.ads)::
13353 * GNAT.Threads (g-thread.ads)::
13354 * GNAT.Time_Stamp (g-timsta.ads)::
13355 * GNAT.Traceback (g-traceb.ads)::
13356 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13357 * GNAT.UTF_32 (g-utf_32.ads)::
13358 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13359 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13360 * GNAT.Wide_String_Split (g-wistsp.ads)::
13361 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13362 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13363 * Interfaces.C.Extensions (i-cexten.ads)::
13364 * Interfaces.C.Streams (i-cstrea.ads)::
13365 * Interfaces.CPP (i-cpp.ads)::
13366 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13367 * Interfaces.VxWorks (i-vxwork.ads)::
13368 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13369 * System.Address_Image (s-addima.ads)::
13370 * System.Assertions (s-assert.ads)::
13371 * System.Memory (s-memory.ads)::
13372 * System.Partition_Interface (s-parint.ads)::
13373 * System.Pool_Global (s-pooglo.ads)::
13374 * System.Pool_Local (s-pooloc.ads)::
13375 * System.Restrictions (s-restri.ads)::
13376 * System.Rident (s-rident.ads)::
13377 * System.Task_Info (s-tasinf.ads)::
13378 * System.Wch_Cnv (s-wchcnv.ads)::
13379 * System.Wch_Con (s-wchcon.ads)::
13380 @end menu
13381
13382 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13383 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13384 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13385 @cindex Latin_9 constants for Character
13386
13387 @noindent
13388 This child of @code{Ada.Characters}
13389 provides a set of definitions corresponding to those in the
13390 RM-defined package @code{Ada.Characters.Latin_1} but with the
13391 few modifications required for @code{Latin-9}
13392 The provision of such a package
13393 is specifically authorized by the Ada Reference Manual
13394 (RM A.3.3(27)).
13395
13396 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13397 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13398 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13399 @cindex Latin_1 constants for Wide_Character
13400
13401 @noindent
13402 This child of @code{Ada.Characters}
13403 provides a set of definitions corresponding to those in the
13404 RM-defined package @code{Ada.Characters.Latin_1} but with the
13405 types of the constants being @code{Wide_Character}
13406 instead of @code{Character}.  The provision of such a package
13407 is specifically authorized by the Ada Reference Manual
13408 (RM A.3.3(27)).
13409
13410 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13411 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13412 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13413 @cindex Latin_9 constants for Wide_Character
13414
13415 @noindent
13416 This child of @code{Ada.Characters}
13417 provides a set of definitions corresponding to those in the
13418 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13419 types of the constants being @code{Wide_Character}
13420 instead of @code{Character}.  The provision of such a package
13421 is specifically authorized by the Ada Reference Manual
13422 (RM A.3.3(27)).
13423
13424 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13425 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13426 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13427 @cindex Latin_1 constants for Wide_Wide_Character
13428
13429 @noindent
13430 This child of @code{Ada.Characters}
13431 provides a set of definitions corresponding to those in the
13432 RM-defined package @code{Ada.Characters.Latin_1} but with the
13433 types of the constants being @code{Wide_Wide_Character}
13434 instead of @code{Character}.  The provision of such a package
13435 is specifically authorized by the Ada Reference Manual
13436 (RM A.3.3(27)).
13437
13438 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13439 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13440 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13441 @cindex Latin_9 constants for Wide_Wide_Character
13442
13443 @noindent
13444 This child of @code{Ada.Characters}
13445 provides a set of definitions corresponding to those in the
13446 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13447 types of the constants being @code{Wide_Wide_Character}
13448 instead of @code{Character}.  The provision of such a package
13449 is specifically authorized by the Ada Reference Manual
13450 (RM A.3.3(27)).
13451
13452 @node Ada.Command_Line.Environment (a-colien.ads)
13453 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13454 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13455 @cindex Environment entries
13456
13457 @noindent
13458 This child of @code{Ada.Command_Line}
13459 provides a mechanism for obtaining environment values on systems
13460 where this concept makes sense.
13461
13462 @node Ada.Command_Line.Remove (a-colire.ads)
13463 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13464 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13465 @cindex Removing command line arguments
13466 @cindex Command line, argument removal
13467
13468 @noindent
13469 This child of @code{Ada.Command_Line}
13470 provides a mechanism for logically removing
13471 arguments from the argument list.  Once removed, an argument is not visible
13472 to further calls on the subprograms in @code{Ada.Command_Line} will not
13473 see the removed argument.
13474
13475 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13476 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13477 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13478 @cindex Response file for command line
13479 @cindex Command line, response file
13480 @cindex Command line, handling long command lines
13481
13482 @noindent
13483 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13484 getting command line arguments from a text file, called a "response file".
13485 Using a response file allow passing a set of arguments to an executable longer
13486 than the maximum allowed by the system on the command line.
13487
13488 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13489 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13490 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13491 @cindex C Streams, Interfacing with Direct_IO
13492
13493 @noindent
13494 This package provides subprograms that allow interfacing between
13495 C streams and @code{Direct_IO}.  The stream identifier can be
13496 extracted from a file opened on the Ada side, and an Ada file
13497 can be constructed from a stream opened on the C side.
13498
13499 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13500 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13501 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13502 @cindex Null_Occurrence, testing for
13503
13504 @noindent
13505 This child subprogram provides a way of testing for the null
13506 exception occurrence (@code{Null_Occurrence}) without raising
13507 an exception.
13508
13509 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13510 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13511 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13512 @cindex Null_Occurrence, testing for
13513
13514 @noindent
13515 This child subprogram is used for handling otherwise unhandled
13516 exceptions (hence the name last chance), and perform clean ups before
13517 terminating the program. Note that this subprogram never returns.
13518
13519 @node Ada.Exceptions.Traceback (a-exctra.ads)
13520 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13521 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13522 @cindex Traceback for Exception Occurrence
13523
13524 @noindent
13525 This child package provides the subprogram (@code{Tracebacks}) to
13526 give a traceback array of addresses based on an exception
13527 occurrence.
13528
13529 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13530 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13531 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13532 @cindex C Streams, Interfacing with Sequential_IO
13533
13534 @noindent
13535 This package provides subprograms that allow interfacing between
13536 C streams and @code{Sequential_IO}.  The stream identifier can be
13537 extracted from a file opened on the Ada side, and an Ada file
13538 can be constructed from a stream opened on the C side.
13539
13540 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13541 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13542 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13543 @cindex C Streams, Interfacing with Stream_IO
13544
13545 @noindent
13546 This package provides subprograms that allow interfacing between
13547 C streams and @code{Stream_IO}.  The stream identifier can be
13548 extracted from a file opened on the Ada side, and an Ada file
13549 can be constructed from a stream opened on the C side.
13550
13551 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13552 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13553 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13554 @cindex @code{Unbounded_String}, IO support
13555 @cindex @code{Text_IO}, extensions for unbounded strings
13556
13557 @noindent
13558 This package provides subprograms for Text_IO for unbounded
13559 strings, avoiding the necessity for an intermediate operation
13560 with ordinary strings.
13561
13562 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13563 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13564 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13565 @cindex @code{Unbounded_Wide_String}, IO support
13566 @cindex @code{Text_IO}, extensions for unbounded wide strings
13567
13568 @noindent
13569 This package provides subprograms for Text_IO for unbounded
13570 wide strings, avoiding the necessity for an intermediate operation
13571 with ordinary wide strings.
13572
13573 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13574 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13575 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13576 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13577 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13578
13579 @noindent
13580 This package provides subprograms for Text_IO for unbounded
13581 wide wide strings, avoiding the necessity for an intermediate operation
13582 with ordinary wide wide strings.
13583
13584 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13585 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13586 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13587 @cindex C Streams, Interfacing with @code{Text_IO}
13588
13589 @noindent
13590 This package provides subprograms that allow interfacing between
13591 C streams and @code{Text_IO}.  The stream identifier can be
13592 extracted from a file opened on the Ada side, and an Ada file
13593 can be constructed from a stream opened on the C side.
13594
13595 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13596 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13597 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13598 @cindex Unicode categorization, Wide_Character
13599
13600 @noindent
13601 This package provides subprograms that allow categorization of
13602 Wide_Character values according to Unicode categories.
13603
13604 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13605 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13606 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13607 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13608
13609 @noindent
13610 This package provides subprograms that allow interfacing between
13611 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13612 extracted from a file opened on the Ada side, and an Ada file
13613 can be constructed from a stream opened on the C side.
13614
13615 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13616 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13617 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13618 @cindex Unicode categorization, Wide_Wide_Character
13619
13620 @noindent
13621 This package provides subprograms that allow categorization of
13622 Wide_Wide_Character values according to Unicode categories.
13623
13624 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13625 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13626 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13627 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13628
13629 @noindent
13630 This package provides subprograms that allow interfacing between
13631 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13632 extracted from a file opened on the Ada side, and an Ada file
13633 can be constructed from a stream opened on the C side.
13634
13635 @node GNAT.Altivec (g-altive.ads)
13636 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13637 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13638 @cindex AltiVec
13639
13640 @noindent
13641 This is the root package of the GNAT AltiVec binding. It provides
13642 definitions of constants and types common to all the versions of the
13643 binding.
13644
13645 @node GNAT.Altivec.Conversions (g-altcon.ads)
13646 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13647 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13648 @cindex AltiVec
13649
13650 @noindent
13651 This package provides the Vector/View conversion routines.
13652
13653 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13654 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13655 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13656 @cindex AltiVec
13657
13658 @noindent
13659 This package exposes the Ada interface to the AltiVec operations on
13660 vector objects. A soft emulation is included by default in the GNAT
13661 library. The hard binding is provided as a separate package. This unit
13662 is common to both bindings.
13663
13664 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13665 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13666 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13667 @cindex AltiVec
13668
13669 @noindent
13670 This package exposes the various vector types part of the Ada binding
13671 to AltiVec facilities.
13672
13673 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13674 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13675 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13676 @cindex AltiVec
13677
13678 @noindent
13679 This package provides public 'View' data types from/to which private
13680 vector representations can be converted via
13681 GNAT.Altivec.Conversions. This allows convenient access to individual
13682 vector elements and provides a simple way to initialize vector
13683 objects.
13684
13685 @node GNAT.Array_Split (g-arrspl.ads)
13686 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13687 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13688 @cindex Array splitter
13689
13690 @noindent
13691 Useful array-manipulation routines: given a set of separators, split
13692 an array wherever the separators appear, and provide direct access
13693 to the resulting slices.
13694
13695 @node GNAT.AWK (g-awk.ads)
13696 @section @code{GNAT.AWK} (@file{g-awk.ads})
13697 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13698 @cindex Parsing
13699 @cindex AWK
13700
13701 @noindent
13702 Provides AWK-like parsing functions, with an easy interface for parsing one
13703 or more files containing formatted data.  The file is viewed as a database
13704 where each record is a line and a field is a data element in this line.
13705
13706 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13707 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13708 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13709 @cindex Parsing
13710 @cindex Bounded Buffers
13711
13712 @noindent
13713 Provides a concurrent generic bounded buffer abstraction.  Instances are
13714 useful directly or as parts of the implementations of other abstractions,
13715 such as mailboxes.
13716
13717 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13718 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13719 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13720 @cindex Parsing
13721 @cindex Mailboxes
13722
13723 @noindent
13724 Provides a thread-safe asynchronous intertask mailbox communication facility.
13725
13726 @node GNAT.Bubble_Sort (g-bubsor.ads)
13727 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13728 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13729 @cindex Sorting
13730 @cindex Bubble sort
13731
13732 @noindent
13733 Provides a general implementation of bubble sort usable for sorting arbitrary
13734 data items.  Exchange and comparison procedures are provided by passing
13735 access-to-procedure values.
13736
13737 @node GNAT.Bubble_Sort_A (g-busora.ads)
13738 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13739 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13740 @cindex Sorting
13741 @cindex Bubble sort
13742
13743 @noindent
13744 Provides a general implementation of bubble sort usable for sorting arbitrary
13745 data items.  Move and comparison procedures are provided by passing
13746 access-to-procedure values. This is an older version, retained for
13747 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13748
13749 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13750 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13751 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13752 @cindex Sorting
13753 @cindex Bubble sort
13754
13755 @noindent
13756 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13757 are provided as generic parameters, this improves efficiency, especially
13758 if the procedures can be inlined, at the expense of duplicating code for
13759 multiple instantiations.
13760
13761 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13762 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13763 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13764 @cindex UTF-8 representation
13765 @cindex Wide characte representations
13766
13767 @noindent
13768 Provides a routine which given a string, reads the start of the string to
13769 see whether it is one of the standard byte order marks (BOM's) which signal
13770 the encoding of the string. The routine includes detection of special XML
13771 sequences for various UCS input formats.
13772
13773 @node GNAT.Byte_Swapping (g-bytswa.ads)
13774 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13775 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13776 @cindex Byte swapping
13777 @cindex Endian
13778
13779 @noindent
13780 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13781 Machine-specific implementations are available in some cases.
13782
13783 @node GNAT.Calendar (g-calend.ads)
13784 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13785 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13786 @cindex @code{Calendar}
13787
13788 @noindent
13789 Extends the facilities provided by @code{Ada.Calendar} to include handling
13790 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13791 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13792 C @code{timeval} format.
13793
13794 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13795 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13796 @cindex @code{Calendar}
13797 @cindex Time
13798 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13799
13800 @node GNAT.CRC32 (g-crc32.ads)
13801 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13802 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13803 @cindex CRC32
13804 @cindex Cyclic Redundancy Check
13805
13806 @noindent
13807 This package implements the CRC-32 algorithm.  For a full description
13808 of this algorithm see
13809 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13810 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13811 Aug.@: 1988.  Sarwate, D.V@.
13812
13813 @node GNAT.Case_Util (g-casuti.ads)
13814 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13815 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13816 @cindex Casing utilities
13817 @cindex Character handling (@code{GNAT.Case_Util})
13818
13819 @noindent
13820 A set of simple routines for handling upper and lower casing of strings
13821 without the overhead of the full casing tables
13822 in @code{Ada.Characters.Handling}.
13823
13824 @node GNAT.CGI (g-cgi.ads)
13825 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13826 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13827 @cindex CGI (Common Gateway Interface)
13828
13829 @noindent
13830 This is a package for interfacing a GNAT program with a Web server via the
13831 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13832 parameters, which are a set of key/value pairs sent by the Web server.  It
13833 builds a table whose index is the key and provides some services to deal
13834 with this table.
13835
13836 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13837 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13838 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13839 @cindex CGI (Common Gateway Interface) cookie support
13840 @cindex Cookie support in CGI
13841
13842 @noindent
13843 This is a package to interface a GNAT program with a Web server via the
13844 Common Gateway Interface (CGI).  It exports services to deal with Web
13845 cookies (piece of information kept in the Web client software).
13846
13847 @node GNAT.CGI.Debug (g-cgideb.ads)
13848 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13849 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13850 @cindex CGI (Common Gateway Interface) debugging
13851
13852 @noindent
13853 This is a package to help debugging CGI (Common Gateway Interface)
13854 programs written in Ada.
13855
13856 @node GNAT.Command_Line (g-comlin.ads)
13857 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13858 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13859 @cindex Command line
13860
13861 @noindent
13862 Provides a high level interface to @code{Ada.Command_Line} facilities,
13863 including the ability to scan for named switches with optional parameters
13864 and expand file names using wild card notations.
13865
13866 @node GNAT.Compiler_Version (g-comver.ads)
13867 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13868 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13869 @cindex Compiler Version
13870 @cindex Version, of compiler
13871
13872 @noindent
13873 Provides a routine for obtaining the version of the compiler used to
13874 compile the program. More accurately this is the version of the binder
13875 used to bind the program (this will normally be the same as the version
13876 of the compiler if a consistent tool set is used to compile all units
13877 of a partition).
13878
13879 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13880 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13881 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13882 @cindex Interrupt
13883
13884 @noindent
13885 Provides a simple interface to handle Ctrl-C keyboard events.
13886
13887 @node GNAT.Current_Exception (g-curexc.ads)
13888 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13889 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13890 @cindex Current exception
13891 @cindex Exception retrieval
13892
13893 @noindent
13894 Provides access to information on the current exception that has been raised
13895 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13896 specification syntax.
13897 This is particularly useful in simulating typical facilities for
13898 obtaining information about exceptions provided by Ada 83 compilers.
13899
13900 @node GNAT.Debug_Pools (g-debpoo.ads)
13901 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13902 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13903 @cindex Debugging
13904 @cindex Debug pools
13905 @cindex Memory corruption debugging
13906
13907 @noindent
13908 Provide a debugging storage pools that helps tracking memory corruption
13909 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13910 @value{EDITION} User's Guide}.
13911
13912 @node GNAT.Debug_Utilities (g-debuti.ads)
13913 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13914 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13915 @cindex Debugging
13916
13917 @noindent
13918 Provides a few useful utilities for debugging purposes, including conversion
13919 to and from string images of address values. Supports both C and Ada formats
13920 for hexadecimal literals.
13921
13922 @node GNAT.Decode_String (g-decstr.ads)
13923 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13924 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13925 @cindex Decoding strings
13926 @cindex String decoding
13927 @cindex Wide character encoding
13928 @cindex UTF-8
13929 @cindex Unicode
13930
13931 @noindent
13932 A generic package providing routines for decoding wide character and wide wide
13933 character strings encoded as sequences of 8-bit characters using a specified
13934 encoding method. Includes validation routines, and also routines for stepping
13935 to next or previous encoded character in an encoded string.
13936 Useful in conjunction with Unicode character coding. Note there is a
13937 preinstantiation for UTF-8. See next entry.
13938
13939 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13940 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13941 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13942 @cindex Decoding strings
13943 @cindex Decoding UTF-8 strings
13944 @cindex UTF-8 string decoding
13945 @cindex Wide character decoding
13946 @cindex UTF-8
13947 @cindex Unicode
13948
13949 @noindent
13950 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13951
13952 @node GNAT.Directory_Operations (g-dirope.ads)
13953 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13954 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13955 @cindex Directory operations
13956
13957 @noindent
13958 Provides a set of routines for manipulating directories, including changing
13959 the current directory, making new directories, and scanning the files in a
13960 directory.
13961
13962 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13963 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13964 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13965 @cindex Directory operations iteration
13966
13967 @noindent
13968 A child unit of GNAT.Directory_Operations providing additional operations
13969 for iterating through directories.
13970
13971 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13972 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13973 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13974 @cindex Hash tables
13975
13976 @noindent
13977 A generic implementation of hash tables that can be used to hash arbitrary
13978 data.  Provided in two forms, a simple form with built in hash functions,
13979 and a more complex form in which the hash function is supplied.
13980
13981 @noindent
13982 This package provides a facility similar to that of @code{GNAT.HTable},
13983 except that this package declares a type that can be used to define
13984 dynamic instances of the hash table, while an instantiation of
13985 @code{GNAT.HTable} creates a single instance of the hash table.
13986
13987 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13988 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13989 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13990 @cindex Table implementation
13991 @cindex Arrays, extendable
13992
13993 @noindent
13994 A generic package providing a single dimension array abstraction where the
13995 length of the array can be dynamically modified.
13996
13997 @noindent
13998 This package provides a facility similar to that of @code{GNAT.Table},
13999 except that this package declares a type that can be used to define
14000 dynamic instances of the table, while an instantiation of
14001 @code{GNAT.Table} creates a single instance of the table type.
14002
14003 @node GNAT.Encode_String (g-encstr.ads)
14004 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14005 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14006 @cindex Encoding strings
14007 @cindex String encoding
14008 @cindex Wide character encoding
14009 @cindex UTF-8
14010 @cindex Unicode
14011
14012 @noindent
14013 A generic package providing routines for encoding wide character and wide
14014 wide character strings as sequences of 8-bit characters using a specified
14015 encoding method. Useful in conjunction with Unicode character coding.
14016 Note there is a preinstantiation for UTF-8. See next entry.
14017
14018 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14019 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14020 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14021 @cindex Encoding strings
14022 @cindex Encoding UTF-8 strings
14023 @cindex UTF-8 string encoding
14024 @cindex Wide character encoding
14025 @cindex UTF-8
14026 @cindex Unicode
14027
14028 @noindent
14029 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14030
14031 @node GNAT.Exception_Actions (g-excact.ads)
14032 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14033 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14034 @cindex Exception actions
14035
14036 @noindent
14037 Provides callbacks when an exception is raised. Callbacks can be registered
14038 for specific exceptions, or when any exception is raised. This
14039 can be used for instance to force a core dump to ease debugging.
14040
14041 @node GNAT.Exception_Traces (g-exctra.ads)
14042 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14043 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14044 @cindex Exception traces
14045 @cindex Debugging
14046
14047 @noindent
14048 Provides an interface allowing to control automatic output upon exception
14049 occurrences.
14050
14051 @node GNAT.Exceptions (g-except.ads)
14052 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14053 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14054 @cindex Exceptions, Pure
14055 @cindex Pure packages, exceptions
14056
14057 @noindent
14058 Normally it is not possible to raise an exception with
14059 a message from a subprogram in a pure package, since the
14060 necessary types and subprograms are in @code{Ada.Exceptions}
14061 which is not a pure unit. @code{GNAT.Exceptions} provides a
14062 facility for getting around this limitation for a few
14063 predefined exceptions, and for example allow raising
14064 @code{Constraint_Error} with a message from a pure subprogram.
14065
14066 @node GNAT.Expect (g-expect.ads)
14067 @section @code{GNAT.Expect} (@file{g-expect.ads})
14068 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14069
14070 @noindent
14071 Provides a set of subprograms similar to what is available
14072 with the standard Tcl Expect tool.
14073 It allows you to easily spawn and communicate with an external process.
14074 You can send commands or inputs to the process, and compare the output
14075 with some expected regular expression. Currently @code{GNAT.Expect}
14076 is implemented on all native GNAT ports except for OpenVMS@.
14077 It is not implemented for cross ports, and in particular is not
14078 implemented for VxWorks or LynxOS@.
14079
14080 @node GNAT.Float_Control (g-flocon.ads)
14081 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14082 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14083 @cindex Floating-Point Processor
14084
14085 @noindent
14086 Provides an interface for resetting the floating-point processor into the
14087 mode required for correct semantic operation in Ada.  Some third party
14088 library calls may cause this mode to be modified, and the Reset procedure
14089 in this package can be used to reestablish the required mode.
14090
14091 @node GNAT.Heap_Sort (g-heasor.ads)
14092 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14093 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14094 @cindex Sorting
14095
14096 @noindent
14097 Provides a general implementation of heap sort usable for sorting arbitrary
14098 data items. Exchange and comparison procedures are provided by passing
14099 access-to-procedure values.  The algorithm used is a modified heap sort
14100 that performs approximately N*log(N) comparisons in the worst case.
14101
14102 @node GNAT.Heap_Sort_A (g-hesora.ads)
14103 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14104 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14105 @cindex Sorting
14106
14107 @noindent
14108 Provides a general implementation of heap sort usable for sorting arbitrary
14109 data items. Move and comparison procedures are provided by passing
14110 access-to-procedure values.  The algorithm used is a modified heap sort
14111 that performs approximately N*log(N) comparisons in the worst case.
14112 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14113 interface, but may be slightly more efficient.
14114
14115 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14116 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14117 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14118 @cindex Sorting
14119
14120 @noindent
14121 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14122 are provided as generic parameters, this improves efficiency, especially
14123 if the procedures can be inlined, at the expense of duplicating code for
14124 multiple instantiations.
14125
14126 @node GNAT.HTable (g-htable.ads)
14127 @section @code{GNAT.HTable} (@file{g-htable.ads})
14128 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14129 @cindex Hash tables
14130
14131 @noindent
14132 A generic implementation of hash tables that can be used to hash arbitrary
14133 data.  Provides two approaches, one a simple static approach, and the other
14134 allowing arbitrary dynamic hash tables.
14135
14136 @node GNAT.IO (g-io.ads)
14137 @section @code{GNAT.IO} (@file{g-io.ads})
14138 @cindex @code{GNAT.IO} (@file{g-io.ads})
14139 @cindex Simple I/O
14140 @cindex Input/Output facilities
14141
14142 @noindent
14143 A simple preelaborable input-output package that provides a subset of
14144 simple Text_IO functions for reading characters and strings from
14145 Standard_Input, and writing characters, strings and integers to either
14146 Standard_Output or Standard_Error.
14147
14148 @node GNAT.IO_Aux (g-io_aux.ads)
14149 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14150 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14151 @cindex Text_IO
14152 @cindex Input/Output facilities
14153
14154 Provides some auxiliary functions for use with Text_IO, including a test
14155 for whether a file exists, and functions for reading a line of text.
14156
14157 @node GNAT.Lock_Files (g-locfil.ads)
14158 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14159 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14160 @cindex File locking
14161 @cindex Locking using files
14162
14163 @noindent
14164 Provides a general interface for using files as locks.  Can be used for
14165 providing program level synchronization.
14166
14167 @node GNAT.MD5 (g-md5.ads)
14168 @section @code{GNAT.MD5} (@file{g-md5.ads})
14169 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14170 @cindex Message Digest MD5
14171
14172 @noindent
14173 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14174
14175 @node GNAT.Memory_Dump (g-memdum.ads)
14176 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14177 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14178 @cindex Dump Memory
14179
14180 @noindent
14181 Provides a convenient routine for dumping raw memory to either the
14182 standard output or standard error files. Uses GNAT.IO for actual
14183 output.
14184
14185 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14186 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14187 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14188 @cindex Exception, obtaining most recent
14189
14190 @noindent
14191 Provides access to the most recently raised exception.  Can be used for
14192 various logging purposes, including duplicating functionality of some
14193 Ada 83 implementation dependent extensions.
14194
14195 @node GNAT.OS_Lib (g-os_lib.ads)
14196 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14197 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14198 @cindex Operating System interface
14199 @cindex Spawn capability
14200
14201 @noindent
14202 Provides a range of target independent operating system interface functions,
14203 including time/date management, file operations, subprocess management,
14204 including a portable spawn procedure, and access to environment variables
14205 and error return codes.
14206
14207 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14208 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14209 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14210 @cindex Hash functions
14211
14212 @noindent
14213 Provides a generator of static minimal perfect hash functions. No
14214 collisions occur and each item can be retrieved from the table in one
14215 probe (perfect property). The hash table size corresponds to the exact
14216 size of the key set and no larger (minimal property). The key set has to
14217 be know in advance (static property). The hash functions are also order
14218 preserving. If w2 is inserted after w1 in the generator, their
14219 hashcode are in the same order. These hashing functions are very
14220 convenient for use with realtime applications.
14221
14222 @node GNAT.Random_Numbers (g-rannum.ads)
14223 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14224 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14225 @cindex Random number generation
14226
14227 @noindent
14228 Provides random number capabilities which extend those available in the
14229 standard Ada library and are more convenient to use.
14230
14231 @node GNAT.Regexp (g-regexp.ads)
14232 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14233 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14234 @cindex Regular expressions
14235 @cindex Pattern matching
14236
14237 @noindent
14238 A simple implementation of regular expressions, using a subset of regular
14239 expression syntax copied from familiar Unix style utilities.  This is the
14240 simples of the three pattern matching packages provided, and is particularly
14241 suitable for ``file globbing'' applications.
14242
14243 @node GNAT.Registry (g-regist.ads)
14244 @section @code{GNAT.Registry} (@file{g-regist.ads})
14245 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14246 @cindex Windows Registry
14247
14248 @noindent
14249 This is a high level binding to the Windows registry.  It is possible to
14250 do simple things like reading a key value, creating a new key.  For full
14251 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14252 package provided with the Win32Ada binding
14253
14254 @node GNAT.Regpat (g-regpat.ads)
14255 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14256 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14257 @cindex Regular expressions
14258 @cindex Pattern matching
14259
14260 @noindent
14261 A complete implementation of Unix-style regular expression matching, copied
14262 from the original V7 style regular expression library written in C by
14263 Henry Spencer (and binary compatible with this C library).
14264
14265 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14266 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14267 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14268 @cindex Secondary Stack Info
14269
14270 @noindent
14271 Provide the capability to query the high water mark of the current task's
14272 secondary stack.
14273
14274 @node GNAT.Semaphores (g-semaph.ads)
14275 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14276 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14277 @cindex Semaphores
14278
14279 @noindent
14280 Provides classic counting and binary semaphores using protected types.
14281
14282 @node GNAT.Serial_Communications (g-sercom.ads)
14283 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14284 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14285 @cindex Serial_Communications
14286
14287 @noindent
14288 Provides a simple interface to send and receive data over a serial
14289 port. This is only supported on GNU/Linux and Windows.
14290
14291 @node GNAT.SHA1 (g-sha1.ads)
14292 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14293 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14294 @cindex Secure Hash Algorithm SHA-1
14295
14296 @noindent
14297 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14298
14299 @node GNAT.Signals (g-signal.ads)
14300 @section @code{GNAT.Signals} (@file{g-signal.ads})
14301 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14302 @cindex Signals
14303
14304 @noindent
14305 Provides the ability to manipulate the blocked status of signals on supported
14306 targets.
14307
14308 @node GNAT.Sockets (g-socket.ads)
14309 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14310 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14311 @cindex Sockets
14312
14313 @noindent
14314 A high level and portable interface to develop sockets based applications.
14315 This package is based on the sockets thin binding found in
14316 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14317 on all native GNAT ports except for OpenVMS@.  It is not implemented
14318 for the LynxOS@ cross port.
14319
14320 @node GNAT.Source_Info (g-souinf.ads)
14321 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14322 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14323 @cindex Source Information
14324
14325 @noindent
14326 Provides subprograms that give access to source code information known at
14327 compile time, such as the current file name and line number.
14328
14329 @node GNAT.Spelling_Checker (g-speche.ads)
14330 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14331 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14332 @cindex Spell checking
14333
14334 @noindent
14335 Provides a function for determining whether one string is a plausible
14336 near misspelling of another string.
14337
14338 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14339 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14340 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14341 @cindex Spell checking
14342
14343 @noindent
14344 Provides a generic function that can be instantiated with a string type for
14345 determining whether one string is a plausible near misspelling of another
14346 string.
14347
14348 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14349 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14350 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14351 @cindex SPITBOL pattern matching
14352 @cindex Pattern matching
14353
14354 @noindent
14355 A complete implementation of SNOBOL4 style pattern matching.  This is the
14356 most elaborate of the pattern matching packages provided.  It fully duplicates
14357 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14358 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14359
14360 @node GNAT.Spitbol (g-spitbo.ads)
14361 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14362 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14363 @cindex SPITBOL interface
14364
14365 @noindent
14366 The top level package of the collection of SPITBOL-style functionality, this
14367 package provides basic SNOBOL4 string manipulation functions, such as
14368 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14369 useful for constructing arbitrary mappings from strings in the style of
14370 the SNOBOL4 TABLE function.
14371
14372 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14373 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14374 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14375 @cindex Sets of strings
14376 @cindex SPITBOL Tables
14377
14378 @noindent
14379 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14380 for type @code{Standard.Boolean}, giving an implementation of sets of
14381 string values.
14382
14383 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14384 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14385 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14386 @cindex Integer maps
14387 @cindex Maps
14388 @cindex SPITBOL Tables
14389
14390 @noindent
14391 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14392 for type @code{Standard.Integer}, giving an implementation of maps
14393 from string to integer values.
14394
14395 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14396 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14397 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14398 @cindex String maps
14399 @cindex Maps
14400 @cindex SPITBOL Tables
14401
14402 @noindent
14403 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14404 a variable length string type, giving an implementation of general
14405 maps from strings to strings.
14406
14407 @node GNAT.Strings (g-string.ads)
14408 @section @code{GNAT.Strings} (@file{g-string.ads})
14409 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14410
14411 @noindent
14412 Common String access types and related subprograms. Basically it
14413 defines a string access and an array of string access types.
14414
14415 @node GNAT.String_Split (g-strspl.ads)
14416 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14417 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14418 @cindex String splitter
14419
14420 @noindent
14421 Useful string manipulation routines: given a set of separators, split
14422 a string wherever the separators appear, and provide direct access
14423 to the resulting slices. This package is instantiated from
14424 @code{GNAT.Array_Split}.
14425
14426 @node GNAT.Table (g-table.ads)
14427 @section @code{GNAT.Table} (@file{g-table.ads})
14428 @cindex @code{GNAT.Table} (@file{g-table.ads})
14429 @cindex Table implementation
14430 @cindex Arrays, extendable
14431
14432 @noindent
14433 A generic package providing a single dimension array abstraction where the
14434 length of the array can be dynamically modified.
14435
14436 @noindent
14437 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14438 except that this package declares a single instance of the table type,
14439 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14440 used to define dynamic instances of the table.
14441
14442 @node GNAT.Task_Lock (g-tasloc.ads)
14443 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14444 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14445 @cindex Task synchronization
14446 @cindex Task locking
14447 @cindex Locking
14448
14449 @noindent
14450 A very simple facility for locking and unlocking sections of code using a
14451 single global task lock.  Appropriate for use in situations where contention
14452 between tasks is very rarely expected.
14453
14454 @node GNAT.Time_Stamp (g-timsta.ads)
14455 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14456 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14457 @cindex Time stamp
14458 @cindex Current time
14459
14460 @noindent
14461 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14462 represents the current date and time in ISO 8601 format. This is a very simple
14463 routine with minimal code and there are no dependencies on any other unit.
14464
14465 @node GNAT.Threads (g-thread.ads)
14466 @section @code{GNAT.Threads} (@file{g-thread.ads})
14467 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14468 @cindex Foreign threads
14469 @cindex Threads, foreign
14470
14471 @noindent
14472 Provides facilities for dealing with foreign threads which need to be known
14473 by the GNAT run-time system. Consult the documentation of this package for
14474 further details if your program has threads that are created by a non-Ada
14475 environment which then accesses Ada code.
14476
14477 @node GNAT.Traceback (g-traceb.ads)
14478 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14479 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14480 @cindex Trace back facilities
14481
14482 @noindent
14483 Provides a facility for obtaining non-symbolic traceback information, useful
14484 in various debugging situations.
14485
14486 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14487 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14488 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14489 @cindex Trace back facilities
14490
14491 @node GNAT.UTF_32 (g-utf_32.ads)
14492 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14493 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14494 @cindex Wide character codes
14495
14496 @noindent
14497 This is a package intended to be used in conjunction with the
14498 @code{Wide_Character} type in Ada 95 and the
14499 @code{Wide_Wide_Character} type in Ada 2005 (available
14500 in @code{GNAT} in Ada 2005 mode). This package contains
14501 Unicode categorization routines, as well as lexical
14502 categorization routines corresponding to the Ada 2005
14503 lexical rules for identifiers and strings, and also a
14504 lower case to upper case fold routine corresponding to
14505 the Ada 2005 rules for identifier equivalence.
14506
14507 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14508 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14509 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14510 @cindex Spell checking
14511
14512 @noindent
14513 Provides a function for determining whether one wide wide string is a plausible
14514 near misspelling of another wide wide string, where the strings are represented
14515 using the UTF_32_String type defined in System.Wch_Cnv.
14516
14517 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14518 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14519 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14520 @cindex Spell checking
14521
14522 @noindent
14523 Provides a function for determining whether one wide string is a plausible
14524 near misspelling of another wide string.
14525
14526 @node GNAT.Wide_String_Split (g-wistsp.ads)
14527 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14528 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14529 @cindex Wide_String splitter
14530
14531 @noindent
14532 Useful wide string manipulation routines: given a set of separators, split
14533 a wide string wherever the separators appear, and provide direct access
14534 to the resulting slices. This package is instantiated from
14535 @code{GNAT.Array_Split}.
14536
14537 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14538 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14539 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14540 @cindex Spell checking
14541
14542 @noindent
14543 Provides a function for determining whether one wide wide string is a plausible
14544 near misspelling of another wide wide string.
14545
14546 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14547 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14548 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14549 @cindex Wide_Wide_String splitter
14550
14551 @noindent
14552 Useful wide wide string manipulation routines: given a set of separators, split
14553 a wide wide string wherever the separators appear, and provide direct access
14554 to the resulting slices. This package is instantiated from
14555 @code{GNAT.Array_Split}.
14556
14557 @node Interfaces.C.Extensions (i-cexten.ads)
14558 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14559 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14560
14561 @noindent
14562 This package contains additional C-related definitions, intended
14563 for use with either manually or automatically generated bindings
14564 to C libraries.
14565
14566 @node Interfaces.C.Streams (i-cstrea.ads)
14567 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14568 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14569 @cindex  C streams, interfacing
14570
14571 @noindent
14572 This package is a binding for the most commonly used operations
14573 on C streams.
14574
14575 @node Interfaces.CPP (i-cpp.ads)
14576 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14577 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14578 @cindex  C++ interfacing
14579 @cindex  Interfacing, to C++
14580
14581 @noindent
14582 This package provides facilities for use in interfacing to C++.  It
14583 is primarily intended to be used in connection with automated tools
14584 for the generation of C++ interfaces.
14585
14586 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14587 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14588 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14589 @cindex  IBM Packed Format
14590 @cindex  Packed Decimal
14591
14592 @noindent
14593 This package provides a set of routines for conversions to and
14594 from a packed decimal format compatible with that used on IBM
14595 mainframes.
14596
14597 @node Interfaces.VxWorks (i-vxwork.ads)
14598 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14599 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14600 @cindex Interfacing to VxWorks
14601 @cindex VxWorks, interfacing
14602
14603 @noindent
14604 This package provides a limited binding to the VxWorks API.
14605 In particular, it interfaces with the
14606 VxWorks hardware interrupt facilities.
14607
14608 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14609 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14610 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14611 @cindex Interfacing to VxWorks' I/O
14612 @cindex VxWorks, I/O interfacing
14613 @cindex VxWorks, Get_Immediate
14614 @cindex Get_Immediate, VxWorks
14615
14616 @noindent
14617 This package provides a binding to the ioctl (IO/Control)
14618 function of VxWorks, defining a set of option values and
14619 function codes. A particular use of this package is
14620 to enable the use of Get_Immediate under VxWorks.
14621
14622 @node System.Address_Image (s-addima.ads)
14623 @section @code{System.Address_Image} (@file{s-addima.ads})
14624 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14625 @cindex Address image
14626 @cindex Image, of an address
14627
14628 @noindent
14629 This function provides a useful debugging
14630 function that gives an (implementation dependent)
14631 string which identifies an address.
14632
14633 @node System.Assertions (s-assert.ads)
14634 @section @code{System.Assertions} (@file{s-assert.ads})
14635 @cindex @code{System.Assertions} (@file{s-assert.ads})
14636 @cindex Assertions
14637 @cindex Assert_Failure, exception
14638
14639 @noindent
14640 This package provides the declaration of the exception raised
14641 by an run-time assertion failure, as well as the routine that
14642 is used internally to raise this assertion.
14643
14644 @node System.Memory (s-memory.ads)
14645 @section @code{System.Memory} (@file{s-memory.ads})
14646 @cindex @code{System.Memory} (@file{s-memory.ads})
14647 @cindex Memory allocation
14648
14649 @noindent
14650 This package provides the interface to the low level routines used
14651 by the generated code for allocation and freeing storage for the
14652 default storage pool (analogous to the C routines malloc and free.
14653 It also provides a reallocation interface analogous to the C routine
14654 realloc. The body of this unit may be modified to provide alternative
14655 allocation mechanisms for the default pool, and in addition, direct
14656 calls to this unit may be made for low level allocation uses (for
14657 example see the body of @code{GNAT.Tables}).
14658
14659 @node System.Partition_Interface (s-parint.ads)
14660 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14661 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14662 @cindex Partition interfacing functions
14663
14664 @noindent
14665 This package provides facilities for partition interfacing.  It
14666 is used primarily in a distribution context when using Annex E
14667 with @code{GLADE}.
14668
14669 @node System.Pool_Global (s-pooglo.ads)
14670 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14671 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14672 @cindex Storage pool, global
14673 @cindex Global storage pool
14674
14675 @noindent
14676 This package provides a storage pool that is equivalent to the default
14677 storage pool used for access types for which no pool is specifically
14678 declared. It uses malloc/free to allocate/free and does not attempt to
14679 do any automatic reclamation.
14680
14681 @node System.Pool_Local (s-pooloc.ads)
14682 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14683 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14684 @cindex Storage pool, local
14685 @cindex Local storage pool
14686
14687 @noindent
14688 This package provides a storage pool that is intended for use with locally
14689 defined access types. It uses malloc/free for allocate/free, and maintains
14690 a list of allocated blocks, so that all storage allocated for the pool can
14691 be freed automatically when the pool is finalized.
14692
14693 @node System.Restrictions (s-restri.ads)
14694 @section @code{System.Restrictions} (@file{s-restri.ads})
14695 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14696 @cindex Run-time restrictions access
14697
14698 @noindent
14699 This package provides facilities for accessing at run time
14700 the status of restrictions specified at compile time for
14701 the partition. Information is available both with regard
14702 to actual restrictions specified, and with regard to
14703 compiler determined information on which restrictions
14704 are violated by one or more packages in the partition.
14705
14706 @node System.Rident (s-rident.ads)
14707 @section @code{System.Rident} (@file{s-rident.ads})
14708 @cindex @code{System.Rident} (@file{s-rident.ads})
14709 @cindex Restrictions definitions
14710
14711 @noindent
14712 This package provides definitions of the restrictions
14713 identifiers supported by GNAT, and also the format of
14714 the restrictions provided in package System.Restrictions.
14715 It is not normally necessary to @code{with} this generic package
14716 since the necessary instantiation is included in
14717 package System.Restrictions.
14718
14719 @node System.Task_Info (s-tasinf.ads)
14720 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14721 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14722 @cindex Task_Info pragma
14723
14724 @noindent
14725 This package provides target dependent functionality that is used
14726 to support the @code{Task_Info} pragma
14727
14728 @node System.Wch_Cnv (s-wchcnv.ads)
14729 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14730 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14731 @cindex Wide Character, Representation
14732 @cindex Wide String, Conversion
14733 @cindex Representation of wide characters
14734
14735 @noindent
14736 This package provides routines for converting between
14737 wide and wide wide characters and a representation as a value of type
14738 @code{Standard.String}, using a specified wide character
14739 encoding method.  It uses definitions in
14740 package @code{System.Wch_Con}.
14741
14742 @node System.Wch_Con (s-wchcon.ads)
14743 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14744 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14745
14746 @noindent
14747 This package provides definitions and descriptions of
14748 the various methods used for encoding wide characters
14749 in ordinary strings.  These definitions are used by
14750 the package @code{System.Wch_Cnv}.
14751
14752 @node Interfacing to Other Languages
14753 @chapter Interfacing to Other Languages
14754 @noindent
14755 The facilities in annex B of the Ada Reference Manual are fully
14756 implemented in GNAT, and in addition, a full interface to C++ is
14757 provided.
14758
14759 @menu
14760 * Interfacing to C::
14761 * Interfacing to C++::
14762 * Interfacing to COBOL::
14763 * Interfacing to Fortran::
14764 * Interfacing to non-GNAT Ada code::
14765 @end menu
14766
14767 @node Interfacing to C
14768 @section Interfacing to C
14769
14770 @noindent
14771 Interfacing to C with GNAT can use one of two approaches:
14772
14773 @itemize @bullet
14774 @item
14775 The types in the package @code{Interfaces.C} may be used.
14776 @item
14777 Standard Ada types may be used directly.  This may be less portable to
14778 other compilers, but will work on all GNAT compilers, which guarantee
14779 correspondence between the C and Ada types.
14780 @end itemize
14781
14782 @noindent
14783 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14784 effect, since this is the default.  The following table shows the
14785 correspondence between Ada scalar types and the corresponding C types.
14786
14787 @table @code
14788 @item Integer
14789 @code{int}
14790 @item Short_Integer
14791 @code{short}
14792 @item Short_Short_Integer
14793 @code{signed char}
14794 @item Long_Integer
14795 @code{long}
14796 @item Long_Long_Integer
14797 @code{long long}
14798 @item Short_Float
14799 @code{float}
14800 @item Float
14801 @code{float}
14802 @item Long_Float
14803 @code{double}
14804 @item Long_Long_Float
14805 This is the longest floating-point type supported by the hardware.
14806 @end table
14807
14808 @noindent
14809 Additionally, there are the following general correspondences between Ada
14810 and C types:
14811 @itemize @bullet
14812 @item
14813 Ada enumeration types map to C enumeration types directly if pragma
14814 @code{Convention C} is specified, which causes them to have int
14815 length.  Without pragma @code{Convention C}, Ada enumeration types map to
14816 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14817 @code{int}, respectively) depending on the number of values passed.
14818 This is the only case in which pragma @code{Convention C} affects the
14819 representation of an Ada type.
14820
14821 @item
14822 Ada access types map to C pointers, except for the case of pointers to
14823 unconstrained types in Ada, which have no direct C equivalent.
14824
14825 @item
14826 Ada arrays map directly to C arrays.
14827
14828 @item
14829 Ada records map directly to C structures.
14830
14831 @item
14832 Packed Ada records map to C structures where all members are bit fields
14833 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14834 @end itemize
14835
14836 @node Interfacing to C++
14837 @section Interfacing to C++
14838
14839 @noindent
14840 The interface to C++ makes use of the following pragmas, which are
14841 primarily intended to be constructed automatically using a binding generator
14842 tool, although it is possible to construct them by hand.  No suitable binding
14843 generator tool is supplied with GNAT though.
14844
14845 Using these pragmas it is possible to achieve complete
14846 inter-operability between Ada tagged types and C++ class definitions.
14847 See @ref{Implementation Defined Pragmas}, for more details.
14848
14849 @table @code
14850 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14851 The argument denotes an entity in the current declarative region that is
14852 declared as a tagged or untagged record type. It indicates that the type
14853 corresponds to an externally declared C++ class type, and is to be laid
14854 out the same way that C++ would lay out the type.
14855
14856 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14857 for backward compatibility but its functionality is available
14858 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14859
14860 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14861 This pragma identifies an imported function (imported in the usual way
14862 with pragma @code{Import}) as corresponding to a C++ constructor.
14863 @end table
14864
14865 @node Interfacing to COBOL
14866 @section Interfacing to COBOL
14867
14868 @noindent
14869 Interfacing to COBOL is achieved as described in section B.4 of
14870 the Ada Reference Manual.
14871
14872 @node Interfacing to Fortran
14873 @section Interfacing to Fortran
14874
14875 @noindent
14876 Interfacing to Fortran is achieved as described in section B.5 of the
14877 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14878 multi-dimensional array causes the array to be stored in column-major
14879 order as required for convenient interface to Fortran.
14880
14881 @node Interfacing to non-GNAT Ada code
14882 @section Interfacing to non-GNAT Ada code
14883
14884 It is possible to specify the convention @code{Ada} in a pragma
14885 @code{Import} or pragma @code{Export}.  However this refers to
14886 the calling conventions used by GNAT, which may or may not be
14887 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14888 compiler to allow interoperation.
14889
14890 If arguments types are kept simple, and if the foreign compiler generally
14891 follows system calling conventions, then it may be possible to integrate
14892 files compiled by other Ada compilers, provided that the elaboration
14893 issues are adequately addressed (for example by eliminating the
14894 need for any load time elaboration).
14895
14896 In particular, GNAT running on VMS is designed to
14897 be highly compatible with the DEC Ada 83 compiler, so this is one
14898 case in which it is possible to import foreign units of this type,
14899 provided that the data items passed are restricted to simple scalar
14900 values or simple record types without variants, or simple array
14901 types with fixed bounds.
14902
14903 @node Specialized Needs Annexes
14904 @chapter Specialized Needs Annexes
14905
14906 @noindent
14907 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14908 required in all implementations.  However, as described in this chapter,
14909 GNAT implements all of these annexes:
14910
14911 @table @asis
14912 @item Systems Programming (Annex C)
14913 The Systems Programming Annex is fully implemented.
14914
14915 @item Real-Time Systems (Annex D)
14916 The Real-Time Systems Annex is fully implemented.
14917
14918 @item Distributed Systems (Annex E)
14919 Stub generation is fully implemented in the GNAT compiler.  In addition,
14920 a complete compatible PCS is available as part of the GLADE system,
14921 a separate product.  When the two
14922 products are used in conjunction, this annex is fully implemented.
14923
14924 @item Information Systems (Annex F)
14925 The Information Systems annex is fully implemented.
14926
14927 @item Numerics (Annex G)
14928 The Numerics Annex is fully implemented.
14929
14930 @item Safety and Security / High-Integrity Systems (Annex H)
14931 The Safety and Security Annex (termed the High-Integrity Systems Annex
14932 in Ada 2005) is fully implemented.
14933 @end table
14934
14935 @node Implementation of Specific Ada Features
14936 @chapter Implementation of Specific Ada Features
14937
14938 @noindent
14939 This chapter describes the GNAT implementation of several Ada language
14940 facilities.
14941
14942 @menu
14943 * Machine Code Insertions::
14944 * GNAT Implementation of Tasking::
14945 * GNAT Implementation of Shared Passive Packages::
14946 * Code Generation for Array Aggregates::
14947 * The Size of Discriminated Records with Default Discriminants::
14948 * Strict Conformance to the Ada Reference Manual::
14949 @end menu
14950
14951 @node Machine Code Insertions
14952 @section Machine Code Insertions
14953 @cindex Machine Code insertions
14954
14955 @noindent
14956 Package @code{Machine_Code} provides machine code support as described
14957 in the Ada Reference Manual in two separate forms:
14958 @itemize @bullet
14959 @item
14960 Machine code statements, consisting of qualified expressions that
14961 fit the requirements of RM section 13.8.
14962 @item
14963 An intrinsic callable procedure, providing an alternative mechanism of
14964 including machine instructions in a subprogram.
14965 @end itemize
14966
14967 @noindent
14968 The two features are similar, and both are closely related to the mechanism
14969 provided by the asm instruction in the GNU C compiler.  Full understanding
14970 and use of the facilities in this package requires understanding the asm
14971 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
14972 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
14973
14974 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14975 semantic restrictions and effects as described below.  Both are provided so
14976 that the procedure call can be used as a statement, and the function call
14977 can be used to form a code_statement.
14978
14979 The first example given in the GCC documentation is the C @code{asm}
14980 instruction:
14981 @smallexample
14982    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14983 @end smallexample
14984
14985 @noindent
14986 The equivalent can be written for GNAT as:
14987
14988 @smallexample @c ada
14989 Asm ("fsinx %1 %0",
14990      My_Float'Asm_Output ("=f", result),
14991      My_Float'Asm_Input  ("f",  angle));
14992 @end smallexample
14993
14994 @noindent
14995 The first argument to @code{Asm} is the assembler template, and is
14996 identical to what is used in GNU C@.  This string must be a static
14997 expression.  The second argument is the output operand list.  It is
14998 either a single @code{Asm_Output} attribute reference, or a list of such
14999 references enclosed in parentheses (technically an array aggregate of
15000 such references).
15001
15002 The @code{Asm_Output} attribute denotes a function that takes two
15003 parameters.  The first is a string, the second is the name of a variable
15004 of the type designated by the attribute prefix.  The first (string)
15005 argument is required to be a static expression and designates the
15006 constraint for the parameter (e.g.@: what kind of register is
15007 required).  The second argument is the variable to be updated with the
15008 result.  The possible values for constraint are the same as those used in
15009 the RTL, and are dependent on the configuration file used to build the
15010 GCC back end.  If there are no output operands, then this argument may
15011 either be omitted, or explicitly given as @code{No_Output_Operands}.
15012
15013 The second argument of @code{@var{my_float}'Asm_Output} functions as
15014 though it were an @code{out} parameter, which is a little curious, but
15015 all names have the form of expressions, so there is no syntactic
15016 irregularity, even though normally functions would not be permitted
15017 @code{out} parameters.  The third argument is the list of input
15018 operands.  It is either a single @code{Asm_Input} attribute reference, or
15019 a list of such references enclosed in parentheses (technically an array
15020 aggregate of such references).
15021
15022 The @code{Asm_Input} attribute denotes a function that takes two
15023 parameters.  The first is a string, the second is an expression of the
15024 type designated by the prefix.  The first (string) argument is required
15025 to be a static expression, and is the constraint for the parameter,
15026 (e.g.@: what kind of register is required).  The second argument is the
15027 value to be used as the input argument.  The possible values for the
15028 constant are the same as those used in the RTL, and are dependent on
15029 the configuration file used to built the GCC back end.
15030
15031 If there are no input operands, this argument may either be omitted, or
15032 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15033 present in the above example, is a list of register names, called the
15034 @dfn{clobber} argument.  This argument, if given, must be a static string
15035 expression, and is a space or comma separated list of names of registers
15036 that must be considered destroyed as a result of the @code{Asm} call.  If
15037 this argument is the null string (the default value), then the code
15038 generator assumes that no additional registers are destroyed.
15039
15040 The fifth argument, not present in the above example, called the
15041 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15042 the literal value @code{True} to indicate to the code generator that all
15043 optimizations with respect to the instruction specified should be
15044 suppressed, and that in particular, for an instruction that has outputs,
15045 the instruction will still be generated, even if none of the outputs are
15046 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15047 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15048 Generally it is strongly advisable to use Volatile for any ASM statement
15049 that is missing either input or output operands, or when two or more ASM
15050 statements appear in sequence, to avoid unwanted optimizations. A warning
15051 is generated if this advice is not followed.
15052
15053 The @code{Asm} subprograms may be used in two ways.  First the procedure
15054 forms can be used anywhere a procedure call would be valid, and
15055 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15056 be used to intersperse machine instructions with other Ada statements.
15057 Second, the function forms, which return a dummy value of the limited
15058 private type @code{Asm_Insn}, can be used in code statements, and indeed
15059 this is the only context where such calls are allowed.  Code statements
15060 appear as aggregates of the form:
15061
15062 @smallexample @c ada
15063 Asm_Insn'(Asm (@dots{}));
15064 Asm_Insn'(Asm_Volatile (@dots{}));
15065 @end smallexample
15066
15067 @noindent
15068 In accordance with RM rules, such code statements are allowed only
15069 within subprograms whose entire body consists of such statements.  It is
15070 not permissible to intermix such statements with other Ada statements.
15071
15072 Typically the form using intrinsic procedure calls is more convenient
15073 and more flexible.  The code statement form is provided to meet the RM
15074 suggestion that such a facility should be made available.  The following
15075 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15076 is used, the arguments may be given in arbitrary order, following the
15077 normal rules for use of positional and named arguments)
15078
15079 @smallexample
15080 ASM_CALL ::= Asm (
15081                  [Template =>] static_string_EXPRESSION
15082                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15083                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15084                [,[Clobber  =>] static_string_EXPRESSION ]
15085                [,[Volatile =>] static_boolean_EXPRESSION] )
15086
15087 OUTPUT_OPERAND_LIST ::=
15088   [PREFIX.]No_Output_Operands
15089 | OUTPUT_OPERAND_ATTRIBUTE
15090 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15091
15092 OUTPUT_OPERAND_ATTRIBUTE ::=
15093   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15094
15095 INPUT_OPERAND_LIST ::=
15096   [PREFIX.]No_Input_Operands
15097 | INPUT_OPERAND_ATTRIBUTE
15098 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15099
15100 INPUT_OPERAND_ATTRIBUTE ::=
15101   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15102 @end smallexample
15103
15104 @noindent
15105 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15106 are declared in the package @code{Machine_Code} and must be referenced
15107 according to normal visibility rules. In particular if there is no
15108 @code{use} clause for this package, then appropriate package name
15109 qualification is required.
15110
15111 @node GNAT Implementation of Tasking
15112 @section GNAT Implementation of Tasking
15113
15114 @noindent
15115 This chapter outlines the basic GNAT approach to tasking (in particular,
15116 a multi-layered library for portability) and discusses issues related
15117 to compliance with the Real-Time Systems Annex.
15118
15119 @menu
15120 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15121 * Ensuring Compliance with the Real-Time Annex::
15122 @end menu
15123
15124 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15125 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15126
15127 @noindent
15128 GNAT's run-time support comprises two layers:
15129
15130 @itemize @bullet
15131 @item GNARL (GNAT Run-time Layer)
15132 @item GNULL (GNAT Low-level Library)
15133 @end itemize
15134
15135 @noindent
15136 In GNAT, Ada's tasking services rely on a platform and OS independent
15137 layer known as GNARL@.  This code is responsible for implementing the
15138 correct semantics of Ada's task creation, rendezvous, protected
15139 operations etc.
15140
15141 GNARL decomposes Ada's tasking semantics into simpler lower level
15142 operations such as create a thread, set the priority of a thread,
15143 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15144 operations constitutes GNULLI, the GNULL Interface.  This interface is
15145 directly inspired from the POSIX real-time API@.
15146
15147 If the underlying executive or OS implements the POSIX standard
15148 faithfully, the GNULL Interface maps as is to the services offered by
15149 the underlying kernel.  Otherwise, some target dependent glue code maps
15150 the services offered by the underlying kernel to the semantics expected
15151 by GNARL@.
15152
15153 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15154 key point is that each Ada task is mapped on a thread in the underlying
15155 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15156
15157 In addition Ada task priorities map onto the underlying thread priorities.
15158 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15159
15160 @itemize @bullet
15161 @item
15162 The underlying scheduler is used to schedule the Ada tasks.  This
15163 makes Ada tasks as efficient as kernel threads from a scheduling
15164 standpoint.
15165
15166 @item
15167 Interaction with code written in C containing threads is eased
15168 since at the lowest level Ada tasks and C threads map onto the same
15169 underlying kernel concept.
15170
15171 @item
15172 When an Ada task is blocked during I/O the remaining Ada tasks are
15173 able to proceed.
15174
15175 @item
15176 On multiprocessor systems Ada tasks can execute in parallel.
15177 @end itemize
15178
15179 @noindent
15180 Some threads libraries offer a mechanism to fork a new process, with the
15181 child process duplicating the threads from the parent.
15182 GNAT does not
15183 support this functionality when the parent contains more than one task.
15184 @cindex Forking a new process
15185
15186 @node Ensuring Compliance with the Real-Time Annex
15187 @subsection Ensuring Compliance with the Real-Time Annex
15188 @cindex Real-Time Systems Annex compliance
15189
15190 @noindent
15191 Although mapping Ada tasks onto
15192 the underlying threads has significant advantages, it does create some
15193 complications when it comes to respecting the scheduling semantics
15194 specified in the real-time annex (Annex D).
15195
15196 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15197 scheduling policy states:
15198
15199 @quotation
15200 @emph{When the active priority of a ready task that is not running
15201 changes, or the setting of its base priority takes effect, the
15202 task is removed from the ready queue for its old active priority
15203 and is added at the tail of the ready queue for its new active
15204 priority, except in the case where the active priority is lowered
15205 due to the loss of inherited priority, in which case the task is
15206 added at the head of the ready queue for its new active priority.}
15207 @end quotation
15208
15209 @noindent
15210 While most kernels do put tasks at the end of the priority queue when
15211 a task changes its priority, (which respects the main
15212 FIFO_Within_Priorities requirement), almost none keep a thread at the
15213 beginning of its priority queue when its priority drops from the loss
15214 of inherited priority.
15215
15216 As a result most vendors have provided incomplete Annex D implementations.
15217
15218 The GNAT run-time, has a nice cooperative solution to this problem
15219 which ensures that accurate FIFO_Within_Priorities semantics are
15220 respected.
15221
15222 The principle is as follows.  When an Ada task T is about to start
15223 running, it checks whether some other Ada task R with the same
15224 priority as T has been suspended due to the loss of priority
15225 inheritance.  If this is the case, T yields and is placed at the end of
15226 its priority queue.  When R arrives at the front of the queue it
15227 executes.
15228
15229 Note that this simple scheme preserves the relative order of the tasks
15230 that were ready to execute in the priority queue where R has been
15231 placed at the end.
15232
15233 @node GNAT Implementation of Shared Passive Packages
15234 @section GNAT Implementation of Shared Passive Packages
15235 @cindex Shared passive packages
15236
15237 @noindent
15238 GNAT fully implements the pragma @code{Shared_Passive} for
15239 @cindex pragma @code{Shared_Passive}
15240 the purpose of designating shared passive packages.
15241 This allows the use of passive partitions in the
15242 context described in the Ada Reference Manual; i.e., for communication
15243 between separate partitions of a distributed application using the
15244 features in Annex E.
15245 @cindex Annex E
15246 @cindex Distribution Systems Annex
15247
15248 However, the implementation approach used by GNAT provides for more
15249 extensive usage as follows:
15250
15251 @table @emph
15252 @item Communication between separate programs
15253
15254 This allows separate programs to access the data in passive
15255 partitions, using protected objects for synchronization where
15256 needed. The only requirement is that the two programs have a
15257 common shared file system. It is even possible for programs
15258 running on different machines with different architectures
15259 (e.g.@: different endianness) to communicate via the data in
15260 a passive partition.
15261
15262 @item Persistence between program runs
15263
15264 The data in a passive package can persist from one run of a
15265 program to another, so that a later program sees the final
15266 values stored by a previous run of the same program.
15267
15268 @end table
15269
15270 @noindent
15271 The implementation approach used is to store the data in files. A
15272 separate stream file is created for each object in the package, and
15273 an access to an object causes the corresponding file to be read or
15274 written.
15275
15276 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15277 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15278 set to the directory to be used for these files.
15279 The files in this directory
15280 have names that correspond to their fully qualified names. For
15281 example, if we have the package
15282
15283 @smallexample @c ada
15284 package X is
15285   pragma Shared_Passive (X);
15286   Y : Integer;
15287   Z : Float;
15288 end X;
15289 @end smallexample
15290
15291 @noindent
15292 and the environment variable is set to @code{/stemp/}, then the files created
15293 will have the names:
15294
15295 @smallexample
15296 /stemp/x.y
15297 /stemp/x.z
15298 @end smallexample
15299
15300 @noindent
15301 These files are created when a value is initially written to the object, and
15302 the files are retained until manually deleted. This provides the persistence
15303 semantics. If no file exists, it means that no partition has assigned a value
15304 to the variable; in this case the initial value declared in the package
15305 will be used. This model ensures that there are no issues in synchronizing
15306 the elaboration process, since elaboration of passive packages elaborates the
15307 initial values, but does not create the files.
15308
15309 The files are written using normal @code{Stream_IO} access.
15310 If you want to be able
15311 to communicate between programs or partitions running on different
15312 architectures, then you should use the XDR versions of the stream attribute
15313 routines, since these are architecture independent.
15314
15315 If active synchronization is required for access to the variables in the
15316 shared passive package, then as described in the Ada Reference Manual, the
15317 package may contain protected objects used for this purpose. In this case
15318 a lock file (whose name is @file{___lock} (three underscores)
15319 is created in the shared memory directory.
15320 @cindex @file{___lock} file (for shared passive packages)
15321 This is used to provide the required locking
15322 semantics for proper protected object synchronization.
15323
15324 As of January 2003, GNAT supports shared passive packages on all platforms
15325 except for OpenVMS.
15326
15327 @node Code Generation for Array Aggregates
15328 @section Code Generation for Array Aggregates
15329
15330 @menu
15331 * Static constant aggregates with static bounds::
15332 * Constant aggregates with unconstrained nominal types::
15333 * Aggregates with static bounds::
15334 * Aggregates with non-static bounds::
15335 * Aggregates in assignment statements::
15336 @end menu
15337
15338 @noindent
15339 Aggregates have a rich syntax and allow the user to specify the values of
15340 complex data structures by means of a single construct.  As a result, the
15341 code generated for aggregates can be quite complex and involve loops, case
15342 statements and multiple assignments.  In the simplest cases, however, the
15343 compiler will recognize aggregates whose components and constraints are
15344 fully static, and in those cases the compiler will generate little or no
15345 executable code.  The following is an outline of the code that GNAT generates
15346 for various aggregate constructs.  For further details, you will find it
15347 useful to examine the output produced by the -gnatG flag to see the expanded
15348 source that is input to the code generator.  You may also want to examine
15349 the assembly code generated at various levels of optimization.
15350
15351 The code generated for aggregates depends on the context, the component values,
15352 and the type.  In the context of an object declaration the code generated is
15353 generally simpler than in the case of an assignment.  As a general rule, static
15354 component values and static subtypes also lead to simpler code.
15355
15356 @node Static constant aggregates with static bounds
15357 @subsection Static constant aggregates with static bounds
15358
15359 @noindent
15360 For the declarations:
15361 @smallexample @c ada
15362     type One_Dim is array (1..10) of integer;
15363     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15364 @end smallexample
15365
15366 @noindent
15367 GNAT generates no executable code: the constant ar0 is placed in static memory.
15368 The same is true for constant aggregates with named associations:
15369
15370 @smallexample @c ada
15371     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15372     Cr3 : constant One_Dim := (others => 7777);
15373 @end smallexample
15374
15375 @noindent
15376 The same is true for multidimensional constant arrays such as:
15377
15378 @smallexample @c ada
15379     type two_dim is array (1..3, 1..3) of integer;
15380     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15381 @end smallexample
15382
15383 @noindent
15384 The same is true for arrays of one-dimensional arrays: the following are
15385 static:
15386
15387 @smallexample @c ada
15388 type ar1b  is array (1..3) of boolean;
15389 type ar_ar is array (1..3) of ar1b;
15390 None  : constant ar1b := (others => false);     --  fully static
15391 None2 : constant ar_ar := (1..3 => None);       --  fully static
15392 @end smallexample
15393
15394 @noindent
15395 However, for multidimensional aggregates with named associations, GNAT will
15396 generate assignments and loops, even if all associations are static.  The
15397 following two declarations generate a loop for the first dimension, and
15398 individual component assignments for the second dimension:
15399
15400 @smallexample @c ada
15401 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15402 Zero2: constant two_dim := (others => (others => 0));
15403 @end smallexample
15404
15405 @node Constant aggregates with unconstrained nominal types
15406 @subsection Constant aggregates with unconstrained nominal types
15407
15408 @noindent
15409 In such cases the aggregate itself establishes the subtype, so that
15410 associations with @code{others} cannot be used.  GNAT determines the
15411 bounds for the actual subtype of the aggregate, and allocates the
15412 aggregate statically as well.  No code is generated for the following:
15413
15414 @smallexample @c ada
15415     type One_Unc is array (natural range <>) of integer;
15416     Cr_Unc : constant One_Unc := (12,24,36);
15417 @end smallexample
15418
15419 @node Aggregates with static bounds
15420 @subsection Aggregates with static bounds
15421
15422 @noindent
15423 In all previous examples the aggregate was the initial (and immutable) value
15424 of a constant.  If the aggregate initializes a variable, then code is generated
15425 for it as a combination of individual assignments and loops over the target
15426 object.  The declarations
15427
15428 @smallexample @c ada
15429        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15430        Cr_Var2 : One_Dim := (others > -1);
15431 @end smallexample
15432
15433 @noindent
15434 generate the equivalent of
15435
15436 @smallexample @c ada
15437        Cr_Var1 (1) := 2;
15438        Cr_Var1 (2) := 3;
15439        Cr_Var1 (3) := 5;
15440        Cr_Var1 (4) := 11;
15441
15442        for I in Cr_Var2'range loop
15443           Cr_Var2 (I) := -1;
15444        end loop;
15445 @end smallexample
15446
15447 @node Aggregates with non-static bounds
15448 @subsection Aggregates with non-static bounds
15449
15450 @noindent
15451 If the bounds of the aggregate are not statically compatible with the bounds
15452 of the nominal subtype  of the target, then constraint checks have to be
15453 generated on the bounds.  For a multidimensional array, constraint checks may
15454 have to be applied to sub-arrays individually, if they do not have statically
15455 compatible subtypes.
15456
15457 @node Aggregates in assignment statements
15458 @subsection Aggregates in assignment statements
15459
15460 @noindent
15461 In general, aggregate assignment requires the construction of a temporary,
15462 and a copy from the temporary to the target of the assignment.  This is because
15463 it is not always possible to convert the assignment into a series of individual
15464 component assignments.  For example, consider the simple case:
15465
15466 @smallexample @c ada
15467         A := (A(2), A(1));
15468 @end smallexample
15469
15470 @noindent
15471 This cannot be converted into:
15472
15473 @smallexample @c ada
15474         A(1) := A(2);
15475         A(2) := A(1);
15476 @end smallexample
15477
15478 @noindent
15479 So the aggregate has to be built first in a separate location, and then
15480 copied into the target.  GNAT recognizes simple cases where this intermediate
15481 step is not required, and the assignments can be performed in place, directly
15482 into the target.  The following sufficient criteria are applied:
15483
15484 @itemize @bullet
15485 @item
15486 The bounds of the aggregate are static, and the associations are static.
15487 @item
15488 The components of the aggregate are static constants, names of
15489 simple variables that are not renamings, or expressions not involving
15490 indexed components whose operands obey these rules.
15491 @end itemize
15492
15493 @noindent
15494 If any of these conditions are violated, the aggregate will be built in
15495 a temporary (created either by the front-end or the code generator) and then
15496 that temporary will be copied onto the target.
15497
15498
15499 @node The Size of Discriminated Records with Default Discriminants
15500 @section The Size of Discriminated Records with Default Discriminants
15501
15502 @noindent
15503 If a discriminated type @code{T} has discriminants with default values, it is
15504 possible to declare an object of this type without providing an explicit
15505 constraint:
15506
15507 @smallexample @c ada
15508 @group
15509 type Size is range 1..100;
15510
15511 type Rec (D : Size := 15) is record
15512    Name : String (1..D);
15513 end T;
15514
15515 Word : Rec;
15516 @end group
15517 @end smallexample
15518
15519 @noindent
15520 Such an object is said to be @emph{unconstrained}.
15521 The discriminant of the object
15522 can be modified by a full assignment to the object, as long as it preserves the
15523 relation between the value of the discriminant, and the value of the components
15524 that depend on it:
15525
15526 @smallexample @c ada
15527 @group
15528 Word := (3, "yes");
15529
15530 Word := (5, "maybe");
15531
15532 Word := (5, "no"); -- raises Constraint_Error
15533 @end group
15534 @end smallexample
15535
15536 @noindent
15537 In order to support this behavior efficiently, an unconstrained object is
15538 given the maximum size that any value of the type requires. In the case
15539 above, @code{Word} has storage for the discriminant and for
15540 a @code{String} of length 100.
15541 It is important to note that unconstrained objects do not require dynamic
15542 allocation. It would be an improper implementation to place on the heap those
15543 components whose size depends on discriminants. (This improper implementation
15544 was used by some Ada83 compilers, where the @code{Name} component above
15545 would have
15546 been stored as a pointer to a dynamic string). Following the principle that
15547 dynamic storage management should never be introduced implicitly,
15548 an Ada compiler should reserve the full size for an unconstrained declared
15549 object, and place it on the stack.
15550
15551 This maximum size approach
15552 has been a source of surprise to some users, who expect the default
15553 values of the discriminants to determine the size reserved for an
15554 unconstrained object: ``If the default is 15, why should the object occupy
15555 a larger size?''
15556 The answer, of course, is that the discriminant may be later modified,
15557 and its full range of values must be taken into account. This is why the
15558 declaration:
15559
15560 @smallexample
15561 @group
15562 type Rec (D : Positive := 15) is record
15563    Name : String (1..D);
15564 end record;
15565
15566 Too_Large : Rec;
15567 @end group
15568 @end smallexample
15569
15570 @noindent
15571 is flagged by the compiler with a warning:
15572 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15573 because the required size includes @code{Positive'Last}
15574 bytes. As the first example indicates, the proper approach is to declare an
15575 index type of ``reasonable'' range so that unconstrained objects are not too
15576 large.
15577
15578 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15579 created in the heap by means of an allocator, then it is @emph{not}
15580 unconstrained:
15581 it is constrained by the default values of the discriminants, and those values
15582 cannot be modified by full assignment. This is because in the presence of
15583 aliasing all views of the object (which may be manipulated by different tasks,
15584 say) must be consistent, so it is imperative that the object, once created,
15585 remain invariant.
15586
15587 @node Strict Conformance to the Ada Reference Manual
15588 @section Strict Conformance to the Ada Reference Manual
15589
15590 @noindent
15591 The dynamic semantics defined by the Ada Reference Manual impose a set of
15592 run-time checks to be generated. By default, the GNAT compiler will insert many
15593 run-time checks into the compiled code, including most of those required by the
15594 Ada Reference Manual. However, there are three checks that are not enabled
15595 in the default mode for efficiency reasons: arithmetic overflow checking for
15596 integer operations (including division by zero), checks for access before
15597 elaboration on subprogram calls, and stack overflow checking (most operating
15598 systems do not perform this check by default).
15599
15600 Strict conformance to the Ada Reference Manual can be achieved by adding
15601 three compiler options for overflow checking for integer operations
15602 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15603 calls and generic instantiations (@option{-gnatE}), and stack overflow
15604 checking (@option{-fstack-check}).
15605
15606 Note that the result of a floating point arithmetic operation in overflow and
15607 invalid situations, when the @code{Machine_Overflows} attribute of the result
15608 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15609 case for machines compliant with the IEEE floating-point standard, but on
15610 machines that are not fully compliant with this standard, such as Alpha, the
15611 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15612 behavior (although at the cost of a significant performance penalty), so
15613 infinite and and NaN values are properly generated.
15614
15615
15616 @node Project File Reference
15617 @chapter Project File Reference
15618
15619 @noindent
15620 This chapter describes the syntax and semantics of project files.
15621 Project files specify the options to be used when building a system.
15622 Project files can specify global settings for all tools,
15623 as well as tool-specific settings.
15624 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15625 for examples of use.
15626
15627 @menu
15628 * Reserved Words::
15629 * Lexical Elements::
15630 * Declarations::
15631 * Empty declarations::
15632 * Typed string declarations::
15633 * Variables::
15634 * Expressions::
15635 * Attributes::
15636 * Project Attributes::
15637 * Attribute References::
15638 * External Values::
15639 * Case Construction::
15640 * Packages::
15641 * Package Renamings::
15642 * Projects::
15643 * Project Extensions::
15644 * Project File Elaboration::
15645 @end menu
15646
15647 @node Reserved Words
15648 @section Reserved Words
15649
15650 @noindent
15651 All Ada reserved words are reserved in project files, and cannot be used
15652 as variable names or project names. In addition, the following are
15653 also reserved in project files:
15654
15655 @itemize
15656 @item @code{extends}
15657
15658 @item @code{external}
15659
15660 @item @code{project}
15661
15662 @end itemize
15663
15664 @node Lexical Elements
15665 @section Lexical Elements
15666
15667 @noindent
15668 Rules for identifiers are the same as in Ada. Identifiers
15669 are case-insensitive.  Strings are case sensitive, except where noted.
15670 Comments have the same form as in Ada.
15671
15672 @noindent
15673 Syntax:
15674
15675 @smallexample
15676 simple_name ::=
15677   identifier
15678
15679 name ::=
15680   simple_name @{. simple_name@}
15681 @end smallexample
15682
15683 @node Declarations
15684 @section Declarations
15685
15686 @noindent
15687 Declarations introduce new entities that denote types, variables, attributes,
15688 and packages. Some declarations can only appear immediately within a project
15689 declaration. Others can appear within a project or within a package.
15690
15691 Syntax:
15692 @smallexample
15693 declarative_item ::=
15694   simple_declarative_item |
15695   typed_string_declaration |
15696   package_declaration
15697
15698 simple_declarative_item ::=
15699   variable_declaration |
15700   typed_variable_declaration |
15701   attribute_declaration |
15702   case_construction |
15703   empty_declaration
15704 @end smallexample
15705
15706 @node Empty declarations
15707 @section Empty declarations
15708
15709 @smallexample
15710 empty_declaration ::=
15711   @b{null} ;
15712 @end smallexample
15713
15714 An empty declaration is allowed anywhere a declaration is allowed.
15715 It has no effect.
15716
15717 @node Typed string declarations
15718 @section Typed string declarations
15719
15720 @noindent
15721 Typed strings are sequences of string literals. Typed strings are the only
15722 named types in project files. They are used in case constructions, where they
15723 provide support for conditional attribute definitions.
15724
15725 Syntax:
15726 @smallexample
15727 typed_string_declaration ::=
15728   @b{type} <typed_string_>_simple_name @b{is}
15729    ( string_literal @{, string_literal@} );
15730 @end smallexample
15731
15732 @noindent
15733 A typed string declaration can only appear immediately within a project
15734 declaration.
15735
15736 All the string literals in a typed string declaration must be distinct.
15737
15738 @node Variables
15739 @section Variables
15740
15741 @noindent
15742 Variables denote values, and appear as constituents of expressions.
15743
15744 @smallexample
15745 typed_variable_declaration ::=
15746   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15747
15748 variable_declaration ::=
15749   <variable_>simple_name := expression;
15750 @end smallexample
15751
15752 @noindent
15753 The elaboration of a variable declaration introduces the variable and
15754 assigns to it the value of the expression. The name of the variable is
15755 available after the assignment symbol.
15756
15757 @noindent
15758 A typed_variable can only be declare once.
15759
15760 @noindent
15761 a non-typed variable can be declared multiple times.
15762
15763 @noindent
15764 Before the completion of its first declaration, the value of variable
15765 is the null string.
15766
15767 @node Expressions
15768 @section Expressions
15769
15770 @noindent
15771 An expression is a formula that defines a computation or retrieval of a value.
15772 In a project file the value of an expression is either a string or a list
15773 of strings. A string value in an expression is either a literal, the current
15774 value of a variable, an external value, an attribute reference, or a
15775 concatenation operation.
15776
15777 Syntax:
15778
15779 @smallexample
15780 expression ::=
15781   term @{& term@}
15782
15783 term ::=
15784   string_literal |
15785   string_list |
15786   <variable_>name |
15787   external_value |
15788   attribute_reference
15789
15790 string_literal ::=
15791   (same as Ada)
15792
15793 string_list ::=
15794   ( <string_>expression @{ , <string_>expression @} )
15795 @end smallexample
15796
15797 @subsection Concatenation
15798 @noindent
15799 The following concatenation functions are defined:
15800
15801 @smallexample @c ada
15802   function "&" (X : String;      Y : String)      return String;
15803   function "&" (X : String_List; Y : String)      return String_List;
15804   function "&" (X : String_List; Y : String_List) return String_List;
15805 @end smallexample
15806
15807 @node Attributes
15808 @section Attributes
15809
15810 @noindent
15811 An attribute declaration defines a property of a project or package. This
15812 property can later be queried by means of an attribute reference.
15813 Attribute values are strings or string lists.
15814
15815 Some attributes are associative arrays. These attributes are mappings whose
15816 domain is a set of strings. These attributes are declared one association
15817 at a time, by specifying a point in the domain and the corresponding image
15818 of the attribute. They may also be declared as a full associative array,
15819 getting the same associations as the corresponding attribute in an imported
15820 or extended project.
15821
15822 Attributes that are not associative arrays are called simple attributes.
15823
15824 Syntax:
15825 @smallexample
15826 attribute_declaration ::=
15827   full_associative_array_declaration |
15828   @b{for} attribute_designator @b{use} expression ;
15829
15830 full_associative_array_declaration ::=
15831   @b{for} <associative_array_attribute_>simple_name @b{use}
15832   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15833
15834 attribute_designator ::=
15835   <simple_attribute_>simple_name |
15836   <associative_array_attribute_>simple_name ( string_literal )
15837 @end smallexample
15838
15839 @noindent
15840 Some attributes are project-specific, and can only appear immediately within
15841 a project declaration. Others are package-specific, and can only appear within
15842 the proper package.
15843
15844 The expression in an attribute definition must be a string or a string_list.
15845 The string literal appearing in the attribute_designator of an associative
15846 array attribute is case-insensitive.
15847
15848 @node Project Attributes
15849 @section Project Attributes
15850
15851 @noindent
15852 The following attributes apply to a project. All of them are simple
15853 attributes.
15854
15855 @table @code
15856 @item   Object_Dir
15857 Expression must be a path name. The attribute defines the
15858 directory in which the object files created by the build are to be placed. If
15859 not specified, object files are placed in the project directory.
15860
15861 @item   Exec_Dir
15862 Expression must be a path name. The attribute defines the
15863 directory in which the executables created by the build are to be placed.
15864 If not specified, executables are placed in the object directory.
15865
15866 @item  Source_Dirs
15867 Expression must be a list of path names. The attribute
15868 defines the directories in which the source files for the project are to be
15869 found. If not specified, source files are found in the project directory.
15870 If a string in the list ends with "/**", then the directory that precedes
15871 "/**" and all of its subdirectories (recursively) are included in the list
15872 of source directories.
15873
15874 @item  Excluded_Source_Dirs
15875 Expression must be a list of strings. Each entry designates a directory that
15876 is not to be included in the list of source directories of the project.
15877 This is normally used when there are strings ending with "/**" in the value
15878 of attribute Source_Dirs.
15879
15880 @item  Source_Files
15881 Expression must be a list of file names. The attribute
15882 defines the individual files, in the project directory, which are to be used
15883 as sources for the project. File names are path_names that contain no directory
15884 information. If the project has no sources the attribute must be declared
15885 explicitly with an empty list.
15886
15887 @item  Excluded_Source_Files (Locally_Removed_Files)
15888 Expression must be a list of strings that are legal file names.
15889 Each file name must designate a source that would normally be a source file
15890 in the source directories of the project or, if the project file is an
15891 extending project file, inherited by the current project file. It cannot
15892 designate an immediate source that is not inherited. Each of the source files
15893 in the list are not considered to be sources of the project file: they are not
15894 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15895 Excluded_Source_Files is preferred.
15896
15897 @item  Source_List_File
15898 Expression must a single path name. The attribute
15899 defines a text file that contains a list of source file names to be used
15900 as sources for the project
15901
15902 @item  Library_Dir
15903 Expression must be a path name. The attribute defines the
15904 directory in which a  library is to be built.  The directory must exist, must
15905 be distinct from the project's object directory, and must be writable.
15906
15907 @item  Library_Name
15908 Expression must be a string that is a legal file name,
15909 without extension. The attribute defines a string that is used to generate
15910 the name of the library to be built by the project.
15911
15912 @item  Library_Kind
15913 Argument must be a string value that must be one of the
15914 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15915 string is case-insensitive. If this attribute is not specified, the library is
15916 a static library. Otherwise, the library may be dynamic or relocatable. This
15917 distinction is operating-system dependent.
15918
15919 @item  Library_Version
15920 Expression must be a string value whose interpretation
15921 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15922 libraries as the internal name of the library (the @code{"soname"}). If the
15923 library file name (built from the @code{Library_Name}) is different from the
15924 @code{Library_Version}, then the library file will be a symbolic link to the
15925 actual file whose name will be @code{Library_Version}.
15926
15927 @item Library_Interface
15928 Expression must be a string list. Each element of the string list
15929 must designate a unit of the project.
15930 If this attribute is present in a Library Project File, then the project
15931 file is a Stand-alone Library_Project_File.
15932
15933 @item Library_Auto_Init
15934 Expression must be a single string "true" or "false", case-insensitive.
15935 If this attribute is present in a Stand-alone Library Project File,
15936 it indicates if initialization is automatic when the dynamic library
15937 is loaded.
15938
15939 @item Library_Options
15940 Expression must be a string list. Indicates additional switches that
15941 are to be used when building a shared library.
15942
15943 @item Library_GCC
15944 Expression must be a single string. Designates an alternative to "gcc"
15945 for building shared libraries.
15946
15947 @item  Library_Src_Dir
15948 Expression must be a path name. The attribute defines the
15949 directory in which the sources of the interfaces of a Stand-alone Library will
15950 be copied.  The directory must exist, must be distinct from the project's
15951 object directory and source directories of all projects in the project tree,
15952 and must be writable.
15953
15954 @item  Library_Src_Dir
15955 Expression must be a path name. The attribute defines the
15956 directory in which the ALI files of a Library will
15957 be copied.  The directory must exist, must be distinct from the project's
15958 object directory and source directories of all projects in the project tree,
15959 and must be writable.
15960
15961 @item  Library_Symbol_File
15962 Expression must be a single string. Its value is the single file name of a
15963 symbol file to be created when building a stand-alone library when the
15964 symbol policy is either "compliant", "controlled" or "restricted",
15965 on platforms that support symbol control, such as VMS. When symbol policy
15966 is "direct", then a file with this name must exist in the object directory.
15967
15968 @item   Library_Reference_Symbol_File
15969 Expression must be a single string. Its value is the path name of a
15970 reference symbol file that is read when the symbol policy is either
15971 "compliant" or "controlled", on platforms that support symbol control,
15972 such as VMS, when building a stand-alone library. The path may be an absolute
15973 path or a path relative to the project directory.
15974
15975 @item  Library_Symbol_Policy
15976 Expression must be a single string. Its case-insensitive value can only be
15977 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15978
15979 This attribute is not taken into account on all platforms. It controls the
15980 policy for exported symbols and, on some platforms (like VMS) that have the
15981 notions of major and minor IDs built in the library files, it controls
15982 the setting of these IDs.
15983
15984 "autonomous" or "default": exported symbols are not controlled.
15985
15986 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15987 it is equivalent to policy "autonomous". If there are exported symbols in
15988 the reference symbol file that are not in the object files of the interfaces,
15989 the major ID of the library is increased. If there are symbols in the
15990 object files of the interfaces that are not in the reference symbol file,
15991 these symbols are put at the end of the list in the newly created symbol file
15992 and the minor ID is increased.
15993
15994 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15995 The library will fail to build if the exported symbols in the object files of
15996 the interfaces do not match exactly the symbol in the symbol file.
15997
15998 "restricted": The attribute Library_Symbol_File must be defined. The library
15999 will fail to build if there are symbols in the symbol file that are not in
16000 the exported symbols of the object files of the interfaces. Additional symbols
16001 in the object files are not added to the symbol file.
16002
16003 "direct": The attribute Library_Symbol_File must be defined and must designate
16004 an existing file in the object directory. This symbol file is passed directly
16005 to the underlying linker without any symbol processing.
16006
16007 @item  Main
16008 Expression must be a list of strings that are legal file names.
16009 These file names designate existing compilation units in the source directory
16010 that are legal main subprograms.
16011
16012 When a project file is elaborated, as part of the execution of a gnatmake
16013 command, one or several executables are built and placed in the Exec_Dir.
16014 If the gnatmake command does not include explicit file names, the executables
16015 that are built correspond to the files specified by this attribute.
16016
16017 @item  Externally_Built
16018 Expression must be a single string. Its value must be either "true" of "false",
16019 case-insensitive. The default is "false". When the value of this attribute is
16020 "true", no attempt is made to compile the sources or to build the library,
16021 when the project is a library project.
16022
16023 @item Main_Language
16024 This is a simple attribute. Its value is a string that specifies the
16025 language of the main program.
16026
16027 @item  Languages
16028 Expression must be a string list. Each string designates
16029 a programming language that is known to GNAT. The strings are case-insensitive.
16030
16031 @end table
16032
16033 @node Attribute References
16034 @section Attribute References
16035
16036 @noindent
16037 Attribute references are used to retrieve the value of previously defined
16038 attribute for a package or project.
16039 Syntax:
16040 @smallexample
16041 attribute_reference ::=
16042   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16043
16044 attribute_prefix ::=
16045   @b{project} |
16046   <project_simple_name | package_identifier |
16047   <project_>simple_name . package_identifier
16048 @end smallexample
16049
16050 @noindent
16051 If an attribute has not been specified for a given package or project, its
16052 value is the null string or the empty list.
16053
16054 @node External Values
16055 @section External Values
16056
16057 @noindent
16058 An external value is an expression whose value is obtained from the command
16059 that invoked the processing of the current project file (typically a
16060 gnatmake command).
16061
16062 Syntax:
16063 @smallexample
16064 external_value ::=
16065   @b{external} ( string_literal [, string_literal] )
16066 @end smallexample
16067
16068 @noindent
16069 The first string_literal is the string to be used on the command line or
16070 in the environment to specify the external value. The second string_literal,
16071 if present, is the default to use if there is no specification for this
16072 external value either on the command line or in the environment.
16073
16074 @node Case Construction
16075 @section Case Construction
16076
16077 @noindent
16078 A case construction supports attribute and variable declarations that depend
16079 on the value of a previously declared variable.
16080
16081 Syntax:
16082 @smallexample
16083 case_construction ::=
16084   @b{case} <typed_variable_>name @b{is}
16085     @{case_item@}
16086   @b{end case} ;
16087
16088 case_item ::=
16089   @b{when} discrete_choice_list =>
16090     @{case_construction |
16091       attribute_declaration |
16092       variable_declaration |
16093       empty_declaration@}
16094
16095 discrete_choice_list ::=
16096   string_literal @{| string_literal@} |
16097     @b{others}
16098 @end smallexample
16099
16100 @noindent
16101 Inside a case construction, variable declarations must be for variables that
16102 have already been declared before the case construction.
16103
16104 All choices in a choice list must be distinct. The choice lists of two
16105 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16106 alternatives do not need to include all values of the type. An @code{others}
16107 choice must appear last in the list of alternatives.
16108
16109 @node Packages
16110 @section Packages
16111
16112 @noindent
16113 A package provides a grouping of variable declarations and attribute
16114 declarations to be used when invoking various GNAT tools. The name of
16115 the package indicates the tool(s) to which it applies.
16116 Syntax:
16117
16118 @smallexample
16119 package_declaration ::=
16120   package_spec | package_renaming
16121
16122 package_spec ::=
16123   @b{package} package_identifier @b{is}
16124     @{simple_declarative_item@}
16125   @b{end} package_identifier ;
16126
16127 package_identifier ::=
16128   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16129   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16130   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16131 @end smallexample
16132
16133 @subsection Package Naming
16134
16135 @noindent
16136 The attributes of a @code{Naming} package specifies the naming conventions
16137 that apply to the source files in a project. When invoking other GNAT tools,
16138 they will use the sources in the source directories that satisfy these
16139 naming conventions.
16140
16141 The following attributes apply to a @code{Naming} package:
16142
16143 @table @code
16144 @item Casing
16145 This is a simple attribute whose value is a string. Legal values of this
16146 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16147 These strings are themselves case insensitive.
16148
16149 @noindent
16150 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16151
16152 @item Dot_Replacement
16153 This is a simple attribute whose string value satisfies the following
16154 requirements:
16155
16156 @itemize @bullet
16157 @item It must not be empty
16158 @item It cannot start or end with an alphanumeric character
16159 @item It cannot be a single underscore
16160 @item It cannot start with an underscore followed by an alphanumeric
16161 @item It cannot contain a dot @code{'.'} if longer than one character
16162 @end itemize
16163
16164 @noindent
16165 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16166
16167 @item Spec_Suffix
16168 This is an associative array attribute, defined on language names,
16169 whose image is a string that must satisfy the following
16170 conditions:
16171
16172 @itemize @bullet
16173 @item It must not be empty
16174 @item It cannot start with an alphanumeric character
16175 @item It cannot start with an underscore followed by an alphanumeric character
16176 @end itemize
16177
16178 @noindent
16179 For Ada, the attribute denotes the suffix used in file names that contain
16180 library unit declarations, that is to say units that are package and
16181 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16182 specified, then the default is @code{".ads"}.
16183
16184 For C and C++, the attribute denotes the suffix used in file names that
16185 contain prototypes.
16186
16187 @item Body_Suffix
16188 This is an associative array attribute defined on language names,
16189 whose image is a string that must satisfy the following
16190 conditions:
16191
16192 @itemize @bullet
16193 @item It must not be empty
16194 @item It cannot start with an alphanumeric character
16195 @item It cannot start with an underscore followed by an alphanumeric character
16196 @item It cannot be a suffix of @code{Spec_Suffix}
16197 @end itemize
16198
16199 @noindent
16200 For Ada, the attribute denotes the suffix used in file names that contain
16201 library bodies, that is to say units that are package and subprogram bodies.
16202 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16203 @code{".adb"}.
16204
16205 For C and C++, the attribute denotes the suffix used in file names that contain
16206 source code.
16207
16208 @item Separate_Suffix
16209 This is a simple attribute whose value satisfies the same conditions as
16210 @code{Body_Suffix}.
16211
16212 This attribute is specific to Ada. It denotes the suffix used in file names
16213 that contain separate bodies. If it is not specified, then it defaults to same
16214 value as @code{Body_Suffix ("Ada")}.
16215
16216 @item Spec
16217 This is an associative array attribute, specific to Ada, defined over
16218 compilation unit names. The image is a string that is the name of the file
16219 that contains that library unit. The file name is case sensitive if the
16220 conventions of the host operating system require it.
16221
16222 @item Body
16223 This is an associative array attribute, specific to Ada, defined over
16224 compilation unit names. The image is a string that is the name of the file
16225 that contains the library unit body for the named unit. The file name is case
16226 sensitive if the conventions of the host operating system require it.
16227
16228 @item Specification_Exceptions
16229 This is an associative array attribute defined on language names,
16230 whose value is a list of strings.
16231
16232 This attribute is not significant for Ada.
16233
16234 For C and C++, each string in the list denotes the name of a file that
16235 contains prototypes, but whose suffix is not necessarily the
16236 @code{Spec_Suffix} for the language.
16237
16238 @item Implementation_Exceptions
16239 This is an associative array attribute defined on language names,
16240 whose value is a list of strings.
16241
16242 This attribute is not significant for Ada.
16243
16244 For C and C++, each string in the list denotes the name of a file that
16245 contains source code, but whose suffix is not necessarily the
16246 @code{Body_Suffix} for the language.
16247 @end table
16248
16249 The following attributes of package @code{Naming} are obsolescent. They are
16250 kept as synonyms of other attributes for compatibility with previous versions
16251 of the Project Manager.
16252
16253 @table @code
16254 @item Specification_Suffix
16255 This is a synonym of @code{Spec_Suffix}.
16256
16257 @item Implementation_Suffix
16258 This is a synonym of @code{Body_Suffix}.
16259
16260 @item Specification
16261 This is a synonym of @code{Spec}.
16262
16263 @item Implementation
16264 This is a synonym of @code{Body}.
16265 @end table
16266
16267 @subsection package Compiler
16268
16269 @noindent
16270 The attributes of the @code{Compiler} package specify the compilation options
16271 to be used by the underlying compiler.
16272
16273 @table @code
16274 @item  Default_Switches
16275 This is an associative array attribute. Its
16276 domain is a set of language names. Its range is a string list that
16277 specifies the compilation options to be used when compiling a component
16278 written in that language, for which no file-specific switches have been
16279 specified.
16280
16281 @item  Switches
16282 This is an associative array attribute. Its domain is
16283 a set of file names. Its range is a string list that specifies the
16284 compilation options to be used when compiling the named file. If a file
16285 is not specified in the Switches attribute, it is compiled with the
16286 options specified by Default_Switches of its language, if defined.
16287
16288 @item  Local_Configuration_Pragmas.
16289 This is a simple attribute, whose
16290 value is a path name that designates a file containing configuration pragmas
16291 to be used for all invocations of the compiler for immediate sources of the
16292 project.
16293 @end table
16294
16295 @subsection package Builder
16296
16297 @noindent
16298 The attributes of package @code{Builder} specify the compilation, binding, and
16299 linking options to be used when building an executable for a project. The
16300 following attributes apply to package @code{Builder}:
16301
16302 @table @code
16303 @item Default_Switches
16304 This is an associative array attribute. Its
16305 domain is a set of language names. Its range is a string list that
16306 specifies options to be used when building a main
16307 written in that language, for which no file-specific switches have been
16308 specified.
16309
16310 @item Switches
16311 This is an associative array attribute. Its domain is
16312 a set of file names. Its range is a string list that specifies
16313 options to be used when building the named main file. If a main file
16314 is not specified in the Switches attribute, it is built with the
16315 options specified by Default_Switches of its language, if defined.
16316
16317 @item Global_Configuration_Pragmas
16318 This is a simple attribute, whose
16319 value is a path name that designates a file that contains configuration pragmas
16320 to be used in every build of an executable. If both local and global
16321 configuration pragmas are specified, a compilation makes use of both sets.
16322
16323
16324 @item Executable
16325 This is an associative array attribute. Its domain is
16326 a set of main source file names. Its range is a simple string that specifies
16327 the executable file name to be used when linking the specified main source.
16328 If a main source is not specified in the Executable attribute, the executable
16329 file name is deducted from the main source file name.
16330 This attribute has no effect if its value is the empty string.
16331
16332 @item Executable_Suffix
16333 This is a simple attribute whose value is the suffix to be added to
16334 the executables that don't have an attribute Executable specified.
16335 @end table
16336
16337 @subsection package Gnatls
16338
16339 @noindent
16340 The attributes of package @code{Gnatls} specify the tool options to be used
16341 when invoking the library browser @command{gnatls}.
16342 The following attributes apply to package @code{Gnatls}:
16343
16344 @table @code
16345 @item Switches
16346 This is a single attribute with a string list value. Each nonempty string
16347 in the list is an option when invoking @code{gnatls}.
16348 @end table
16349
16350 @subsection package Binder
16351
16352 @noindent
16353 The attributes of package @code{Binder} specify the options to be used
16354 when invoking the binder in the construction of an executable.
16355 The following attributes apply to package @code{Binder}:
16356
16357 @table @code
16358 @item     Default_Switches
16359 This is an associative array attribute. Its
16360 domain is a set of language names. Its range is a string list that
16361 specifies options to be used when binding a main
16362 written in that language, for which no file-specific switches have been
16363 specified.
16364
16365 @item Switches
16366 This is an associative array attribute. Its domain is
16367 a set of file names. Its range is a string list that specifies
16368 options to be used when binding the named main file. If a main file
16369 is not specified in the Switches attribute, it is bound with the
16370 options specified by Default_Switches of its language, if defined.
16371 @end table
16372
16373 @subsection package Linker
16374
16375 @noindent
16376 The attributes of package @code{Linker} specify the options to be used when
16377 invoking the linker in the construction of an executable.
16378 The following attributes apply to package @code{Linker}:
16379
16380 @table @code
16381 @item     Default_Switches
16382 This is an associative array attribute. Its
16383 domain is a set of language names. Its range is a string list that
16384 specifies options to be used when linking a main
16385 written in that language, for which no file-specific switches have been
16386 specified.
16387
16388 @item Switches
16389 This is an associative array attribute. Its domain is
16390 a set of file names. Its range is a string list that specifies
16391 options to be used when linking the named main file. If a main file
16392 is not specified in the Switches attribute, it is linked with the
16393 options specified by Default_Switches of its language, if defined.
16394
16395 @item  Linker_Options
16396 This is a string list attribute. Its value specifies additional options that
16397 be given to the linker when linking an executable. This attribute is not
16398 used in the main project, only in projects imported directly or indirectly.
16399
16400 @end table
16401
16402 @subsection package Cross_Reference
16403
16404 @noindent
16405 The attributes of package @code{Cross_Reference} specify the tool options
16406 to be used
16407 when invoking the library tool @command{gnatxref}.
16408 The following attributes apply to package @code{Cross_Reference}:
16409
16410 @table @code
16411 @item     Default_Switches
16412 This is an associative array attribute. Its
16413 domain is a set of language names. Its range is a string list that
16414 specifies options to be used when calling @command{gnatxref} on a source
16415 written in that language, for which no file-specific switches have been
16416 specified.
16417
16418 @item Switches
16419 This is an associative array attribute. Its domain is
16420 a set of file names. Its range is a string list that specifies
16421 options to be used when calling @command{gnatxref} on the named main source.
16422 If a source is not specified in the Switches attribute, @command{gnatxref} will
16423 be called with the options specified by Default_Switches of its language,
16424 if defined.
16425 @end table
16426
16427 @subsection package   Finder
16428
16429 @noindent
16430 The attributes of package @code{Finder} specify the tool options to be used
16431 when invoking the search tool @command{gnatfind}.
16432 The following attributes apply to package @code{Finder}:
16433
16434 @table @code
16435 @item     Default_Switches
16436 This is an associative array attribute. Its
16437 domain is a set of language names. Its range is a string list that
16438 specifies options to be used when calling @command{gnatfind} on a source
16439 written in that language, for which no file-specific switches have been
16440 specified.
16441
16442 @item Switches
16443 This is an associative array attribute. Its domain is
16444 a set of file names. Its range is a string list that specifies
16445 options to be used when calling @command{gnatfind} on the named main source.
16446 If a source is not specified in the Switches attribute, @command{gnatfind} will
16447 be called with the options specified by Default_Switches of its language,
16448 if defined.
16449 @end table
16450
16451 @subsection package Pretty_Printer
16452
16453 @noindent
16454 The attributes of package @code{Pretty_Printer}
16455 specify the tool options to be used
16456 when invoking the formatting tool @command{gnatpp}.
16457 The following attributes apply to package @code{Pretty_Printer}:
16458
16459 @table @code
16460 @item     Default_switches
16461 This is an associative array attribute. Its
16462 domain is a set of language names. Its range is a string list that
16463 specifies options to be used when calling @command{gnatpp} on a source
16464 written in that language, for which no file-specific switches have been
16465 specified.
16466
16467 @item Switches
16468 This is an associative array attribute. Its domain is
16469 a set of file names. Its range is a string list that specifies
16470 options to be used when calling @command{gnatpp} on the named main source.
16471 If a source is not specified in the Switches attribute, @command{gnatpp} will
16472 be called with the options specified by Default_Switches of its language,
16473 if defined.
16474 @end table
16475
16476 @subsection package gnatstub
16477
16478 @noindent
16479 The attributes of package @code{gnatstub}
16480 specify the tool options to be used
16481 when invoking the tool @command{gnatstub}.
16482 The following attributes apply to package @code{gnatstub}:
16483
16484 @table @code
16485 @item     Default_switches
16486 This is an associative array attribute. Its
16487 domain is a set of language names. Its range is a string list that
16488 specifies options to be used when calling @command{gnatstub} on a source
16489 written in that language, for which no file-specific switches have been
16490 specified.
16491
16492 @item Switches
16493 This is an associative array attribute. Its domain is
16494 a set of file names. Its range is a string list that specifies
16495 options to be used when calling @command{gnatstub} on the named main source.
16496 If a source is not specified in the Switches attribute, @command{gnatpp} will
16497 be called with the options specified by Default_Switches of its language,
16498 if defined.
16499 @end table
16500
16501 @subsection package Eliminate
16502
16503 @noindent
16504 The attributes of package @code{Eliminate}
16505 specify the tool options to be used
16506 when invoking the tool @command{gnatelim}.
16507 The following attributes apply to package @code{Eliminate}:
16508
16509 @table @code
16510 @item     Default_switches
16511 This is an associative array attribute. Its
16512 domain is a set of language names. Its range is a string list that
16513 specifies options to be used when calling @command{gnatelim} on a source
16514 written in that language, for which no file-specific switches have been
16515 specified.
16516
16517 @item Switches
16518 This is an associative array attribute. Its domain is
16519 a set of file names. Its range is a string list that specifies
16520 options to be used when calling @command{gnatelim} on the named main source.
16521 If a source is not specified in the Switches attribute, @command{gnatelim} will
16522 be called with the options specified by Default_Switches of its language,
16523 if defined.
16524 @end table
16525
16526 @subsection package Metrics
16527
16528 @noindent
16529 The attributes of package @code{Metrics}
16530 specify the tool options to be used
16531 when invoking the tool @command{gnatmetric}.
16532 The following attributes apply to package @code{Metrics}:
16533
16534 @table @code
16535 @item     Default_switches
16536 This is an associative array attribute. Its
16537 domain is a set of language names. Its range is a string list that
16538 specifies options to be used when calling @command{gnatmetric} on a source
16539 written in that language, for which no file-specific switches have been
16540 specified.
16541
16542 @item Switches
16543 This is an associative array attribute. Its domain is
16544 a set of file names. Its range is a string list that specifies
16545 options to be used when calling @command{gnatmetric} on the named main source.
16546 If a source is not specified in the Switches attribute, @command{gnatmetric}
16547 will be called with the options specified by Default_Switches of its language,
16548 if defined.
16549 @end table
16550
16551 @subsection  package IDE
16552
16553 @noindent
16554 The attributes of package @code{IDE} specify the options to be used when using
16555 an Integrated Development Environment such as @command{GPS}.
16556
16557 @table @code
16558 @item Remote_Host
16559 This is a simple attribute. Its value is a string that designates the remote
16560 host in a cross-compilation environment, to be used for remote compilation and
16561 debugging. This field should not be specified when running on the local
16562 machine.
16563
16564 @item Program_Host
16565 This is a simple attribute. Its value is a string that specifies the
16566 name of IP address of the embedded target in a cross-compilation environment,
16567 on which the program should execute.
16568
16569 @item Communication_Protocol
16570 This is a simple string attribute. Its value is the name of the protocol
16571 to use to communicate with the target in a cross-compilation environment,
16572 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16573
16574 @item Compiler_Command
16575 This is an associative array attribute, whose domain is a language name. Its
16576 value is  string that denotes the command to be used to invoke the compiler.
16577 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16578 gnatmake, in particular in the handling of switches.
16579
16580 @item Debugger_Command
16581 This is simple attribute, Its value is a string that specifies the name of
16582 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16583
16584 @item Default_Switches
16585 This is an associative array attribute. Its indexes are the name of the
16586 external tools that the GNAT Programming System (GPS) is supporting. Its
16587 value is a list of switches to use when invoking that tool.
16588
16589 @item  Gnatlist
16590 This is a simple attribute.  Its value is a string that specifies the name
16591 of the @command{gnatls} utility to be used to retrieve information about the
16592 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16593
16594 @item VCS_Kind
16595 This is a simple attribute. Its value is a string used to specify the
16596 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16597 ClearCase or Perforce.
16598
16599 @item VCS_File_Check
16600 This is a simple attribute. Its value is a string that specifies the
16601 command used by the VCS to check the validity of a file, either
16602 when the user explicitly asks for a check, or as a sanity check before
16603 doing the check-in.
16604
16605 @item VCS_Log_Check
16606 This is a simple attribute. Its value is a string that specifies
16607 the command used by the VCS to check the validity of a log file.
16608
16609 @item VCS_Repository_Root
16610 The VCS repository root path. This is used to create tags or branches
16611 of the repository. For subversion the value should be the @code{URL}
16612 as specified to check-out the working copy of the repository.
16613
16614 @item VCS_Patch_Root
16615 The local root directory to use for building patch file. All patch chunks
16616 will be relative to this path. The root project directory is used if
16617 this value is not defined.
16618
16619 @end table
16620
16621 @node Package Renamings
16622 @section Package Renamings
16623
16624 @noindent
16625 A package can be defined by a renaming declaration. The new package renames
16626 a package declared in a different project file, and has the same attributes
16627 as the package it renames.
16628 Syntax:
16629 @smallexample
16630 package_renaming ::==
16631   @b{package} package_identifier @b{renames}
16632        <project_>simple_name.package_identifier ;
16633 @end smallexample
16634
16635 @noindent
16636 The package_identifier of the renamed package must be the same as the
16637 package_identifier. The project whose name is the prefix of the renamed
16638 package must contain a package declaration with this name. This project
16639 must appear in the context_clause of the enclosing project declaration,
16640 or be the parent project of the enclosing child project.
16641
16642 @node Projects
16643 @section Projects
16644
16645 @noindent
16646 A project file specifies a set of rules for constructing a software system.
16647 A project file can be self-contained, or depend on other project files.
16648 Dependencies are expressed through a context clause that names other projects.
16649
16650 Syntax:
16651
16652 @smallexample
16653 project ::=
16654   context_clause project_declaration
16655
16656 project_declaration ::=
16657   simple_project_declaration | project_extension
16658
16659 simple_project_declaration ::=
16660   @b{project} <project_>simple_name @b{is}
16661     @{declarative_item@}
16662   @b{end} <project_>simple_name;
16663
16664 context_clause ::=
16665   @{with_clause@}
16666
16667 with_clause ::=
16668   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16669
16670 path_name ::=
16671    string_literal
16672 @end smallexample
16673
16674 @noindent
16675 A path name denotes a project file. A path name can be absolute or relative.
16676 An absolute path name includes a sequence of directories, in the syntax of
16677 the host operating system, that identifies uniquely the project file in the
16678 file system. A relative path name identifies the project file, relative
16679 to the directory that contains the current project, or relative to a
16680 directory listed in the environment variable ADA_PROJECT_PATH.
16681 Path names are case sensitive if file names in the host operating system
16682 are case sensitive.
16683
16684 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16685 directory names separated by colons (semicolons on Windows).
16686
16687 A given project name can appear only once in a context_clause.
16688
16689 It is illegal for a project imported by a context clause to refer, directly
16690 or indirectly, to the project in which this context clause appears (the
16691 dependency graph cannot contain cycles), except when one of the with_clause
16692 in the cycle is a @code{limited with}.
16693
16694 @node Project Extensions
16695 @section Project Extensions
16696
16697 @noindent
16698 A project extension introduces a new project, which inherits the declarations
16699 of another project.
16700 Syntax:
16701 @smallexample
16702
16703 project_extension ::=
16704   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16705     @{declarative_item@}
16706   @b{end} <project_>simple_name;
16707 @end smallexample
16708
16709 @noindent
16710 The project extension declares a child project. The child project inherits
16711 all the declarations and all the files of the parent project, These inherited
16712 declaration can be overridden in the child project, by means of suitable
16713 declarations.
16714
16715 @node Project File Elaboration
16716 @section Project File Elaboration
16717
16718 @noindent
16719 A project file is processed as part of the invocation of a gnat tool that
16720 uses the project option. Elaboration of the process file consists in the
16721 sequential elaboration of all its declarations. The computed values of
16722 attributes and variables in the project are then used to establish the
16723 environment in which the gnat tool will execute.
16724
16725 @node Obsolescent Features
16726 @chapter Obsolescent Features
16727
16728 @noindent
16729 This chapter describes features that are provided by GNAT, but are
16730 considered obsolescent since there are preferred ways of achieving
16731 the same effect. These features are provided solely for historical
16732 compatibility purposes.
16733
16734 @menu
16735 * pragma No_Run_Time::
16736 * pragma Ravenscar::
16737 * pragma Restricted_Run_Time::
16738 @end menu
16739
16740 @node pragma No_Run_Time
16741 @section pragma No_Run_Time
16742
16743 The pragma @code{No_Run_Time} is used to achieve an affect similar
16744 to the use of the "Zero Foot Print" configurable run time, but without
16745 requiring a specially configured run time. The result of using this
16746 pragma, which must be used for all units in a partition, is to restrict
16747 the use of any language features requiring run-time support code. The
16748 preferred usage is to use an appropriately configured run-time that
16749 includes just those features that are to be made accessible.
16750
16751 @node pragma Ravenscar
16752 @section pragma Ravenscar
16753
16754 The pragma @code{Ravenscar} has exactly the same effect as pragma
16755 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16756 is part of the new Ada 2005 standard.
16757
16758 @node pragma Restricted_Run_Time
16759 @section pragma Restricted_Run_Time
16760
16761 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16762 pragma @code{Profile (Restricted)}. The latter usage is
16763 preferred since the Ada 2005 pragma @code{Profile} is intended for
16764 this kind of implementation dependent addition.
16765
16766 @include fdl.texi
16767 @c GNU Free Documentation License
16768
16769 @node Index,,GNU Free Documentation License, Top
16770 @unnumbered Index
16771
16772 @printindex cp
16773
16774 @contents
16775
16776 @bye