2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob5046cc56c731a014b4cbd1bacb0a44858c9bff09
1 \input texinfo   @c -*-texinfo-*-
3 @c %**start of header
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
18 @setfilename gnat_rm.info
20 @set EDITION GNAT
21 @set DEFAULTLANGUAGEVERSION Ada 2005
22 @set NONDEFAULTLANGUAGEVERSION Ada 95
24 @settitle GNAT Reference Manual
26 @setchapternewpage odd
27 @syncodeindex fn cp
29 @include gcc-common.texi
31 @dircategory GNU Ada tools
32 @direntry
33 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
34 @end direntry
36 @copying
37 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
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
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
56 @insertcopying
58 @end titlepage
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
64 @noindent
65 GNAT Reference Manual
67 @noindent
68 GNAT, The GNU Ada Compiler@*
69 GCC version @value{version-GCC}@*
71 @noindent
72 AdaCore
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::
93  --- The Detailed Node Listing ---
95 About This Guide
97 * What This Reference Manual Contains::
98 * Related Information::
100 Implementation Defined Pragmas
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::
218 Implementation Defined Attributes
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::
274 The Implementation of Standard I/O
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::
290 The GNAT Library
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)::
416 Text_IO
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::
425 Wide_Text_IO
427 * Wide_Text_IO Stream Pointer Positioning::
428 * Wide_Text_IO Reading and Writing Non-Regular Files::
430 Wide_Wide_Text_IO
432 * Wide_Wide_Text_IO Stream Pointer Positioning::
433 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
435 Interfacing to Other Languages
437 * Interfacing to C::
438 * Interfacing to C++::
439 * Interfacing to COBOL::
440 * Interfacing to Fortran::
441 * Interfacing to non-GNAT Ada code::
443 Specialized Needs Annexes
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::
453 Project File Reference
455 Obsolescent Features
457 GNU Free Documentation License
459 Index
460 @end menu
462 @end ifnottex
464 @node About This Guide
465 @unnumbered About This Guide
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.
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.
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
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.
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
502 @menu
503 * What This Reference Manual Contains::
504 * Conventions::
505 * Related Information::
506 @end menu
508 @node What This Reference Manual Contains
509 @unnumberedsec What This Reference Manual Contains
511 @noindent
512 This reference manual contains the following chapters:
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.
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.
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.
531 @item
532 @ref{Implementation Defined Characteristics}, provides a guide to
533 minimizing implementation dependent features.
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.
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.
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@.
550 @item
551 @ref{The Implementation of Standard I/O}, details how the GNAT
552 implementation of the input-output facilities.
554 @item
555 @ref{The GNAT Library}, is a catalog of packages that complement
556 the Ada predefined library.
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.
563 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
564 of the specialized needs annexes.
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.
571 @item
572 @ref{Project File Reference}, presents the syntax and semantics
573 of project files.
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.
581 @end itemize
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.
595 @node Conventions
596 @unnumberedsec Conventions
597 @cindex Conventions, typographical
598 @cindex Typographical conventions
600 @noindent
601 Following are examples of the typographical and graphic conventions used
602 in this guide:
604 @itemize @bullet
605 @item
606 @code{Functions}, @code{utility program names}, @code{standard names},
607 and @code{classes}.
609 @item
610 @code{Option flags}
612 @item
613 @file{File names}, @samp{button names}, and @samp{field names}.
615 @item
616 @code{Variables}, @env{environment variables}, and @var{metasyntactic
617 variables}.
619 @item
620 @emph{Emphasis}.
622 @item
623 [optional information or parameters]
625 @item
626 Examples are described by text
627 @smallexample
628 and then shown this way.
629 @end smallexample
630 @end itemize
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.
639 @node Related Information
640 @unnumberedsec Related Information
641 @noindent
642 See the following documents for further information on GNAT:
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.
650 @item
651 @cite{Ada 95 Reference Manual}, which contains all reference
652 material for the Ada 95 programming language.
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.
660 @item
661 @cite{Ada 2005 Reference Manual}, which contains all reference
662 material for the Ada 2005 programming language.
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.
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.
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.
680 @end itemize
682 @node Implementation Defined Pragmas
683 @chapter Implementation Defined Pragmas
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.
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.
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.
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
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
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).
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
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.
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.
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
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.
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
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.
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
910 @noindent
911 This configuration pragma is a synonym for pragma Ada_05 and has the
912 same syntax and effect.
914 @node Pragma Annotate
915 @unnumberedsec Pragma Annotate
916 @findex Annotate
917 @noindent
918 Syntax:
919 @smallexample @c ada
920 pragma Annotate (IDENTIFIER @{, ARG@});
922 ARG ::= NAME | EXPRESSION
923 @end smallexample
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.
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@.
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
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:
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
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:
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
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.
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).
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.
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.
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
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.
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
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:
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
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).
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.
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
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}.
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}.
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
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.
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).
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);
1133 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1134 @end smallexample
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)}.
1144 The identifier given as the first argument corresponds to a name used in
1145 associated @code{Check} pragmas. For example, if the pragma:
1147 @smallexample @c ada
1148 pragma Check_Policy (Critical_Error, Off);
1149 @end smallexample
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).
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.
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.
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.
1175 @node Pragma Comment
1176 @unnumberedsec Pragma Comment
1177 @findex Comment
1178 @noindent
1179 Syntax:
1181 @smallexample @c ada
1182 pragma Comment (static_string_EXPRESSION);
1183 @end smallexample
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.
1194 @node Pragma Common_Object
1195 @unnumberedsec Pragma Common_Object
1196 @findex Common_Object
1197 @noindent
1198 Syntax:
1200 @smallexample @c ada
1201 pragma Common_Object (
1202      [Internal =>] LOCAL_NAME
1203   [, [External =>] EXTERNAL_SYMBOL]
1204   [, [Size     =>] EXTERNAL_SYMBOL] );
1206 EXTERNAL_SYMBOL ::=
1207   IDENTIFIER
1208 | static_string_EXPRESSION
1209 @end smallexample
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.
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.
1226 @node Pragma Compile_Time_Error
1227 @unnumberedsec Pragma Compile_Time_Error
1228 @findex Compile_Time_Error
1229 @noindent
1230 Syntax:
1232 @smallexample @c ada
1233 pragma Compile_Time_Error
1234          (boolean_EXPRESSION, static_string_EXPRESSION);
1235 @end smallexample
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.
1253 @node Pragma Compile_Time_Warning
1254 @unnumberedsec Pragma Compile_Time_Warning
1255 @findex Compile_Time_Warning
1256 @noindent
1257 Syntax:
1259 @smallexample @c ada
1260 pragma Compile_Time_Warning
1261          (boolean_EXPRESSION, static_string_EXPRESSION);
1262 @end smallexample
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).
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.
1276 @node Pragma Complete_Representation
1277 @unnumberedsec Pragma Complete_Representation
1278 @findex Complete_Representation
1279 @noindent
1280 Syntax:
1282 @smallexample @c ada
1283 pragma Complete_Representation;
1284 @end smallexample
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.
1295 @node Pragma Complex_Representation
1296 @unnumberedsec Pragma Complex_Representation
1297 @findex Complex_Representation
1298 @noindent
1299 Syntax:
1301 @smallexample @c ada
1302 pragma Complex_Representation
1303         ([Entity =>] LOCAL_NAME);
1304 @end smallexample
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.
1317 @node Pragma Component_Alignment
1318 @unnumberedsec Pragma Component_Alignment
1319 @cindex Alignments of components
1320 @findex Component_Alignment
1321 @noindent
1322 Syntax:
1324 @smallexample @c ada
1325 pragma Component_Alignment (
1326      [Form =>] ALIGNMENT_CHOICE
1327   [, [Name =>] type_LOCAL_NAME]);
1329 ALIGNMENT_CHOICE ::=
1330   Component_Size
1331 | Component_Size_4
1332 | Storage_Unit
1333 | Default
1334 @end smallexample
1336 @noindent
1337 Specifies the alignment of components in array or record types.
1338 The meaning of the @var{Form} argument is as follows:
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@.
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.
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}.
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
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.
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.
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.
1395 @node Pragma Convention_Identifier
1396 @unnumberedsec Pragma Convention_Identifier
1397 @findex Convention_Identifier
1398 @cindex Conventions, synonyms
1399 @noindent
1400 Syntax:
1402 @smallexample @c ada
1403 pragma Convention_Identifier (
1404          [Name =>]       IDENTIFIER,
1405          [Convention =>] convention_IDENTIFIER);
1406 @end smallexample
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:
1416 @smallexample @c ada
1417 pragma Convention_Identifier (Fortran77, Fortran);
1418 @end smallexample
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.
1430 @node Pragma CPP_Class
1431 @unnumberedsec Pragma CPP_Class
1432 @findex CPP_Class
1433 @cindex Interfacing with C++
1434 @noindent
1435 Syntax:
1437 @smallexample @c ada
1438 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1439 @end smallexample
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.
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.
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.
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}.
1462 @node Pragma CPP_Constructor
1463 @unnumberedsec Pragma CPP_Constructor
1464 @cindex Interfacing with C++
1465 @findex CPP_Constructor
1466 @noindent
1467 Syntax:
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
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:
1483 @itemize @bullet
1484 @item
1485 @code{function @var{Fname} return @var{T}'Class}
1487 @item
1488 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1489 @end itemize
1491 @noindent
1492 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
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:
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
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.
1514 In the case of derived objects, you may use one of two possible forms
1515 for declaring and creating an object:
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
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.
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.
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.
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.
1546 See @ref{Interfacing to C++} for related information.
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.
1556 See @ref{Interfacing to C++} for related information.
1558 @node Pragma Debug
1559 @unnumberedsec Pragma Debug
1560 @findex Debug
1561 @noindent
1562 Syntax:
1564 @smallexample @c ada
1565 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1567 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1568   PROCEDURE_NAME
1569 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1570 @end smallexample
1572 @noindent
1573 The procedure call argument has the syntactic form of an expression, meeting
1574 the syntactic requirements for pragmas.
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}.
1585 @node Pragma Debug_Policy
1586 @unnumberedsec Pragma Debug_Policy
1587 @findex Debug_Policy
1588 @noindent
1589 Syntax:
1591 @smallexample @c ada
1592 pragma Debug_Policy (CHECK | IGNORE);
1593 @end smallexample
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.
1601 @node Pragma Detect_Blocking
1602 @unnumberedsec Pragma Detect_Blocking
1603 @findex Detect_Blocking
1604 @noindent
1605 Syntax:
1607 @smallexample @c ada
1608 pragma Detect_Blocking;
1609 @end smallexample
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.
1616 @node Pragma Elaboration_Checks
1617 @unnumberedsec Pragma Elaboration_Checks
1618 @cindex Elaboration control
1619 @findex Elaboration_Checks
1620 @noindent
1621 Syntax:
1623 @smallexample @c ada
1624 pragma Elaboration_Checks (Dynamic | Static);
1625 @end smallexample
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}.
1640 @node Pragma Eliminate
1641 @unnumberedsec Pragma Eliminate
1642 @cindex Elimination of unused subprograms
1643 @findex Eliminate
1644 @noindent
1645 Syntax:
1647 @smallexample @c ada
1648 pragma Eliminate (
1649     [Unit_Name =>] IDENTIFIER |
1650                    SELECTED_COMPONENT);
1652 pragma Eliminate (
1653     [Unit_Name       =>]  IDENTIFIER |
1654                           SELECTED_COMPONENT,
1655     [Entity          =>]  IDENTIFIER |
1656                           SELECTED_COMPONENT |
1657                           STRING_LITERAL
1658     [,OVERLOADING_RESOLUTION]);
1660 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1661                            SOURCE_LOCATION
1663 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1664                                       FUNCTION_PROFILE
1666 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1668 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1669                       Result_Type => result_SUBTYPE_NAME]
1671 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1672 SUBTYPE_NAME    ::= STRING_VALUE
1674 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1675 SOURCE_TRACE    ::= STRING_VALUE
1677 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1678 @end smallexample
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.
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.
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).
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.
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.
1710 Note that in case of a parameterless procedure its profile is represented
1711 as @code{Parameter_Types => ("")}
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:
1719 @smallexample @c ada
1720 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1722 LBRACKET ::= [
1723 RBRACKET ::= ]
1725 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1726 FILE_NAME       ::= STRING_LITERAL
1727 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1728 @end smallexample
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.
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.
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.
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}.
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.
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.
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.
1767 @node Pragma Export_Exception
1768 @unnumberedsec Pragma Export_Exception
1769 @cindex OpenVMS
1770 @findex Export_Exception
1771 @noindent
1772 Syntax:
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]);
1781 EXTERNAL_SYMBOL ::=
1782   IDENTIFIER
1783 | static_string_EXPRESSION
1784 @end smallexample
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.
1795 @node Pragma Export_Function
1796 @unnumberedsec Pragma Export_Function
1797 @cindex Argument passing mechanisms
1798 @findex Export_Function
1800 @noindent
1801 Syntax:
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]);
1812 EXTERNAL_SYMBOL ::=
1813   IDENTIFIER
1814 | static_string_EXPRESSION
1815 | ""
1817 PARAMETER_TYPES ::=
1818   null
1819 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1821 TYPE_DESIGNATOR ::=
1822   subtype_NAME
1823 | subtype_Name ' Access
1825 MECHANISM ::=
1826   MECHANISM_NAME
1827 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1829 MECHANISM_ASSOCIATION ::=
1830   [formal_parameter_NAME =>] MECHANISM_NAME
1832 MECHANISM_NAME ::=
1833   Value
1834 | Reference
1835 | Descriptor [([Class =>] CLASS_NAME)]
1837 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1838 @end smallexample
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.
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.
1865 @cindex OpenVMS
1866 @cindex Passing by descriptor
1867 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
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.
1875 @node Pragma Export_Object
1876 @unnumberedsec Pragma Export_Object
1877 @findex Export_Object
1878 @noindent
1879 Syntax:
1881 @smallexample @c ada
1882 pragma Export_Object
1883       [Internal =>] LOCAL_NAME
1884    [, [External =>] EXTERNAL_SYMBOL]
1885    [, [Size     =>] EXTERNAL_SYMBOL]
1887 EXTERNAL_SYMBOL ::=
1888   IDENTIFIER
1889 | static_string_EXPRESSION
1890 @end smallexample
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@.
1900 @node Pragma Export_Procedure
1901 @unnumberedsec Pragma Export_Procedure
1902 @findex Export_Procedure
1903 @noindent
1904 Syntax:
1906 @smallexample @c ada
1907 pragma Export_Procedure (
1908      [Internal        =>] LOCAL_NAME
1909   [, [External        =>] EXTERNAL_SYMBOL]
1910   [, [Parameter_Types =>] PARAMETER_TYPES]
1911   [, [Mechanism       =>] MECHANISM]);
1913 EXTERNAL_SYMBOL ::=
1914   IDENTIFIER
1915 | static_string_EXPRESSION
1916 | ""
1918 PARAMETER_TYPES ::=
1919   null
1920 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1922 TYPE_DESIGNATOR ::=
1923   subtype_NAME
1924 | subtype_Name ' Access
1926 MECHANISM ::=
1927   MECHANISM_NAME
1928 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1930 MECHANISM_ASSOCIATION ::=
1931   [formal_parameter_NAME =>] MECHANISM_NAME
1933 MECHANISM_NAME ::=
1934   Value
1935 | Reference
1936 | Descriptor [([Class =>] CLASS_NAME)]
1938 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1939 @end smallexample
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.
1951 @cindex OpenVMS
1952 @cindex Passing by descriptor
1953 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
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.
1961 @node Pragma Export_Value
1962 @unnumberedsec Pragma Export_Value
1963 @findex Export_Value
1964 @noindent
1965 Syntax:
1967 @smallexample @c ada
1968 pragma Export_Value (
1969   [Value     =>] static_integer_EXPRESSION,
1970   [Link_Name =>] static_string_EXPRESSION);
1971 @end smallexample
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.
1982 @node Pragma Export_Valued_Procedure
1983 @unnumberedsec Pragma Export_Valued_Procedure
1984 @findex Export_Valued_Procedure
1985 @noindent
1986 Syntax:
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]);
1995 EXTERNAL_SYMBOL ::=
1996   IDENTIFIER
1997 | static_string_EXPRESSION
1998 | ""
2000 PARAMETER_TYPES ::=
2001   null
2002 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2004 TYPE_DESIGNATOR ::=
2005   subtype_NAME
2006 | subtype_Name ' Access
2008 MECHANISM ::=
2009   MECHANISM_NAME
2010 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2012 MECHANISM_ASSOCIATION ::=
2013   [formal_parameter_NAME =>] MECHANISM_NAME
2015 MECHANISM_NAME ::=
2016   Value
2017 | Reference
2018 | Descriptor [([Class =>] CLASS_NAME)]
2020 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2021 @end smallexample
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.
2038 @cindex OpenVMS
2039 @cindex Passing by descriptor
2040 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
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.
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:
2056 @smallexample @c ada
2057 pragma Extend_System ([Name =>] IDENTIFIER);
2058 @end smallexample
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}.
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.
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}.
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.
2096 @node Pragma External
2097 @unnumberedsec Pragma External
2098 @findex External
2099 @noindent
2100 Syntax:
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
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.
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:
2126 @smallexample @c ada
2127 pragma External_Name_Casing (
2128   Uppercase | Lowercase
2129   [, Uppercase | Lowercase | As_Is]);
2130 @end smallexample
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:
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:
2142 @smallexample @c ada
2143    pragma Import (C, C_Routine);
2144 @end smallexample
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.
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.
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:
2166 @smallexample @c ada
2167 pragma Import (C, C_Routine, "C_routine");
2168 @end smallexample
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
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.
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:
2193 @smallexample @c ada
2194 pragma External_Name_Casing (Uppercase, Uppercase);
2195 @end smallexample
2197 @noindent
2198 to enforce the upper casing of all external symbols.
2200 @node Pragma Fast_Math
2201 @unnumberedsec Pragma Fast_Math
2202 @findex Fast_Math
2203 @noindent
2204 Syntax:
2206 @smallexample @c ada
2207 pragma Fast_Math;
2208 @end smallexample
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:
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
2226 @node Pragma Favor_Top_Level
2227 @unnumberedsec Pragma Favor_Top_Level
2228 @findex Favor_Top_Level
2229 @noindent
2230 Syntax:
2232 @smallexample @c ada
2233 pragma Favor_Top_Level (type_NAME);
2234 @end smallexample
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.
2246 @node Pragma Finalize_Storage_Only
2247 @unnumberedsec Pragma Finalize_Storage_Only
2248 @findex Finalize_Storage_Only
2249 @noindent
2250 Syntax:
2252 @smallexample @c ada
2253 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2254 @end smallexample
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.
2263 @node Pragma Float_Representation
2264 @unnumberedsec Pragma Float_Representation
2265 @cindex OpenVMS
2266 @findex Float_Representation
2267 @noindent
2268 Syntax:
2270 @smallexample @c ada
2271 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2273 FLOAT_REP ::= VAX_Float | IEEE_Float
2274 @end smallexample
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.
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:
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
2306 @node Pragma Ident
2307 @unnumberedsec Pragma Ident
2308 @findex Ident
2309 @noindent
2310 Syntax:
2312 @smallexample @c ada
2313 pragma Ident (static_string_EXPRESSION);
2314 @end smallexample
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.
2329 @node Pragma Implemented_By_Entry
2330 @unnumberedsec Pragma Implemented_By_Entry
2331 @findex Implemented_By_Entry
2332 @noindent
2333 Syntax:
2335 @smallexample @c ada
2336 pragma Implemented_By_Entry (LOCAL_NAME);
2337 @end smallexample
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.
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);
2350 protected type P is new Iface with
2351    procedure Do_Something;  --  Illegal
2352 end P;
2354 task type T is new Iface with
2355    entry Do_Something;      --  Legal
2356 end T;
2357 @end smallexample
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.
2365 @node Pragma Implicit_Packing
2366 @unnumberedsec Pragma Implicit_Packing
2367 @findex Implicit_Packing
2368 @noindent
2369 Syntax:
2371 @smallexample @c ada
2372 pragma Implicit_Packing;
2373 @end smallexample
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:
2380 @smallexample @c ada
2381 type R is array (0 .. 7) of Boolean;
2382 for R'Size use 8;
2383 @end smallexample
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.
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
2400 @node Pragma Import_Exception
2401 @unnumberedsec Pragma Import_Exception
2402 @cindex OpenVMS
2403 @findex Import_Exception
2404 @noindent
2405 Syntax:
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]);
2414 EXTERNAL_SYMBOL ::=
2415   IDENTIFIER
2416 | static_string_EXPRESSION
2417 @end smallexample
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.
2428 @node Pragma Import_Function
2429 @unnumberedsec Pragma Import_Function
2430 @findex Import_Function
2431 @noindent
2432 Syntax:
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]);
2444 EXTERNAL_SYMBOL ::=
2445   IDENTIFIER
2446 | static_string_EXPRESSION
2448 PARAMETER_TYPES ::=
2449   null
2450 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2452 TYPE_DESIGNATOR ::=
2453   subtype_NAME
2454 | subtype_Name ' Access
2456 MECHANISM ::=
2457   MECHANISM_NAME
2458 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2460 MECHANISM_ASSOCIATION ::=
2461   [formal_parameter_NAME =>] MECHANISM_NAME
2463 MECHANISM_NAME ::=
2464   Value
2465 | Reference
2466 | Descriptor [([Class =>] CLASS_NAME)]
2468 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2469 @end smallexample
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.
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.
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.
2497 @cindex OpenVMS
2498 @cindex Passing by descriptor
2499 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
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.
2510 @node Pragma Import_Object
2511 @unnumberedsec Pragma Import_Object
2512 @findex Import_Object
2513 @noindent
2514 Syntax:
2516 @smallexample @c ada
2517 pragma Import_Object
2518      [Internal =>] LOCAL_NAME
2519   [, [External =>] EXTERNAL_SYMBOL]
2520   [, [Size     =>] EXTERNAL_SYMBOL]);
2522 EXTERNAL_SYMBOL ::=
2523   IDENTIFIER
2524 | static_string_EXPRESSION
2525 @end smallexample
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@.
2536 @node Pragma Import_Procedure
2537 @unnumberedsec Pragma Import_Procedure
2538 @findex Import_Procedure
2539 @noindent
2540 Syntax:
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]);
2550 EXTERNAL_SYMBOL ::=
2551   IDENTIFIER
2552 | static_string_EXPRESSION
2554 PARAMETER_TYPES ::=
2555   null
2556 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2558 TYPE_DESIGNATOR ::=
2559   subtype_NAME
2560 | subtype_Name ' Access
2562 MECHANISM ::=
2563   MECHANISM_NAME
2564 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2566 MECHANISM_ASSOCIATION ::=
2567   [formal_parameter_NAME =>] MECHANISM_NAME
2569 MECHANISM_NAME ::=
2570   Value
2571 | Reference
2572 | Descriptor [([Class =>] CLASS_NAME)]
2574 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2575 @end smallexample
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.
2582 @node Pragma Import_Valued_Procedure
2583 @unnumberedsec Pragma Import_Valued_Procedure
2584 @findex Import_Valued_Procedure
2585 @noindent
2586 Syntax:
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]);
2596 EXTERNAL_SYMBOL ::=
2597   IDENTIFIER
2598 | static_string_EXPRESSION
2600 PARAMETER_TYPES ::=
2601   null
2602 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2604 TYPE_DESIGNATOR ::=
2605   subtype_NAME
2606 | subtype_Name ' Access
2608 MECHANISM ::=
2609   MECHANISM_NAME
2610 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2612 MECHANISM_ASSOCIATION ::=
2613   [formal_parameter_NAME =>] MECHANISM_NAME
2615 MECHANISM_NAME ::=
2616   Value
2617 | Reference
2618 | Descriptor [([Class =>] CLASS_NAME)]
2620 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2621 @end smallexample
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.
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.
2641 @node Pragma Initialize_Scalars
2642 @unnumberedsec Pragma Initialize_Scalars
2643 @findex Initialize_Scalars
2644 @cindex debugging with Initialize_Scalars
2645 @noindent
2646 Syntax:
2648 @smallexample @c ada
2649 pragma Initialize_Scalars;
2650 @end smallexample
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.
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.
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.
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.
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.
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.
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.
2702 @node Pragma Inline_Always
2703 @unnumberedsec Pragma Inline_Always
2704 @findex Inline_Always
2705 @noindent
2706 Syntax:
2708 @smallexample @c ada
2709 pragma Inline_Always (NAME [, NAME]);
2710 @end smallexample
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.
2717 @node Pragma Inline_Generic
2718 @unnumberedsec Pragma Inline_Generic
2719 @findex Inline_Generic
2720 @noindent
2721 Syntax:
2723 @smallexample @c ada
2724 pragma Inline_Generic (generic_package_NAME);
2725 @end smallexample
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@.
2732 @node Pragma Interface
2733 @unnumberedsec Pragma Interface
2734 @findex Interface
2735 @noindent
2736 Syntax:
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
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.
2754 @node Pragma Interface_Name
2755 @unnumberedsec Pragma Interface_Name
2756 @findex Interface_Name
2757 @noindent
2758 Syntax:
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
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}.
2773 @node Pragma Interrupt_Handler
2774 @unnumberedsec Pragma Interrupt_Handler
2775 @findex Interrupt_Handler
2776 @noindent
2777 Syntax:
2779 @smallexample @c ada
2780 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2781 @end smallexample
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.
2793 @node Pragma Interrupt_State
2794 @unnumberedsec Pragma Interrupt_State
2795 @findex Interrupt_State
2796 @noindent
2797 Syntax:
2799 @smallexample @c ada
2800 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2801 @end smallexample
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.
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.
2822 Interrupts can be in one of three states:
2823 @itemize @bullet
2824 @item System
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.
2830 @item Runtime
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.
2836 @item User
2838 The interrupt is unreserved.  The user may install a handler to provide
2839 some other action.
2840 @end itemize
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}.
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.
2852 The effect is to move the interrupt to the specified state.
2854 By declaring interrupts to be SYSTEM, you guarantee the standard system
2855 action, such as a core dump.
2857 By declaring interrupts to be USER, you guarantee that you can install
2858 a handler.
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}.
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.
2869 @node Pragma Keep_Names
2870 @unnumberedsec Pragma Keep_Names
2871 @findex Keep_Names
2872 @noindent
2873 Syntax:
2875 @smallexample @c ada
2876 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2877 @end smallexample
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.
2889 @node Pragma License
2890 @unnumberedsec Pragma License
2891 @findex License
2892 @cindex License checking
2893 @noindent
2894 Syntax:
2896 @smallexample @c ada
2897 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2898 @end smallexample
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:
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.
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.
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@.
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).
2931 @end itemize
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.
2938 @itemize @bullet
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.
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@.
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
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:
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
2966 @noindent
2967 if compiled with pragma @code{License} (@code{Restricted}) in a
2968 @file{gnat.adc} file will generate the warning:
2970 @smallexample
2971 1.  with Sem_Ch3;
2972         |
2973    >>> license of withed unit "Sem_Ch3" is incompatible
2975 2.  with GNAT.Sockets;
2976 3.  procedure Secret_Stuff is
2977 @end smallexample
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@.
2985 @node Pragma Link_With
2986 @unnumberedsec Pragma Link_With
2987 @findex Link_With
2988 @noindent
2989 Syntax:
2991 @smallexample @c ada
2992 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2993 @end smallexample
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:
3001 @smallexample @c ada
3002 pragma Link_With ("-labc -ldef");
3003 @end smallexample
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.
3010 @node Pragma Linker_Alias
3011 @unnumberedsec Pragma Linker_Alias
3012 @findex Linker_Alias
3013 @noindent
3014 Syntax:
3016 @smallexample @c ada
3017 pragma Linker_Alias (
3018   [Entity =>] LOCAL_NAME,
3019   [Target =>] static_string_EXPRESSION);
3020 @end smallexample
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.
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}.
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}.
3039 @smallexample @c ada
3040 --  Example of the use of pragma Linker_Alias
3042 package p is
3043   i : Integer := 1;
3044   pragma Export (C, i);
3046   new_name_for_i : Integer;
3047   pragma Linker_Alias (new_name_for_i, "i");
3048 end p;
3049 @end smallexample
3051 @node Pragma Linker_Constructor
3052 @unnumberedsec Pragma Linker_Constructor
3053 @findex Linker_Constructor
3054 @noindent
3055 Syntax:
3057 @smallexample @c ada
3058 pragma Linker_Constructor (procedure_LOCAL_NAME);
3059 @end smallexample
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.
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.
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.
3081 @node Pragma Linker_Destructor
3082 @unnumberedsec Pragma Linker_Destructor
3083 @findex Linker_Destructor
3084 @noindent
3085 Syntax:
3087 @smallexample @c ada
3088 pragma Linker_Destructor (procedure_LOCAL_NAME);
3089 @end smallexample
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.
3101 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3102 because of these specific contexts.
3104 @node Pragma Linker_Section
3105 @unnumberedsec Pragma Linker_Section
3106 @findex Linker_Section
3107 @noindent
3108 Syntax:
3110 @smallexample @c ada
3111 pragma Linker_Section (
3112   [Entity  =>] LOCAL_NAME,
3113   [Section =>] static_string_EXPRESSION);
3114 @end smallexample
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).
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.
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.
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}.
3139 @smallexample @c ada
3140 --  Example of the use of pragma Linker_Section
3142 package IO_Card is
3143   Port_A : Integer;
3144   pragma Volatile (Port_A);
3145   pragma Linker_Section (Port_A, ".bss.port_a");
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
3153 @node Pragma Long_Float
3154 @unnumberedsec Pragma Long_Float
3155 @cindex OpenVMS
3156 @findex Long_Float
3157 @noindent
3158 Syntax:
3160 @smallexample @c ada
3161 pragma Long_Float (FLOAT_FORMAT);
3163 FLOAT_FORMAT ::= D_Float | G_Float
3164 @end smallexample
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.
3178 @node Pragma Machine_Attribute
3179 @unnumberedsec Pragma Machine_Attribute
3180 @findex Machine_Attribute
3181 @noindent
3182 Syntax:
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
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.
3207 @node Pragma Main
3208 @unnumberedsec Pragma Main
3209 @cindex OpenVMS
3210 @findex Main
3211 @noindent
3212 Syntax:
3214 @smallexample @c ada
3215 pragma Main
3216  (MAIN_OPTION [, MAIN_OPTION]);
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
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.
3228 @node Pragma Main_Storage
3229 @unnumberedsec Pragma Main_Storage
3230 @cindex OpenVMS
3231 @findex Main_Storage
3232 @noindent
3233 Syntax:
3235 @smallexample @c ada
3236 pragma Main_Storage
3237   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3239 MAIN_STORAGE_OPTION ::=
3240   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3241 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3242 @end smallexample
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.
3249 @node Pragma No_Body
3250 @unnumberedsec Pragma No_Body
3251 @findex No_Body
3252 @noindent
3253 Syntax:
3255 @smallexample @c ada
3256 pragma No_Body;
3257 @end smallexample
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.
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.
3272 @node Pragma No_Return
3273 @unnumberedsec Pragma No_Return
3274 @findex No_Return
3275 @noindent
3276 Syntax:
3278 @smallexample @c ada
3279 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3280 @end smallexample
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.
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.
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.
3298 @node Pragma No_Strict_Aliasing
3299 @unnumberedsec Pragma No_Strict_Aliasing
3300 @findex No_Strict_Aliasing
3301 @noindent
3302 Syntax:
3304 @smallexample @c ada
3305 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3306 @end smallexample
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}.
3318 @node Pragma Normalize_Scalars
3319 @unnumberedsec Pragma Normalize_Scalars
3320 @findex Normalize_Scalars
3321 @noindent
3322 Syntax:
3324 @smallexample @c ada
3325 pragma Normalize_Scalars;
3326 @end smallexample
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:
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.
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.
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.
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.
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.
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.
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.
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.
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.
3393 @end table
3395 @node Pragma Obsolescent
3396 @unnumberedsec Pragma Obsolescent
3397 @findex Obsolescent
3398 @noindent
3399 Syntax:
3401 @smallexample @c ada
3402 pragma Obsolescent
3403   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3404 @end smallexample
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.
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.
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).
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.
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.
3444 The following examples show typical uses of this pragma:
3446 @smallexample @c ada
3447 package p is
3448    pragma Obsolescent
3449      (Entity => p, "use pp instead of p");
3450 end p;
3452 package q is
3453    procedure q2;
3454    pragma Obsolescent
3455      (Entity => q2, "use q2new instead");
3457    type R is new integer;
3458    pragma Obsolescent
3459      (Entity => R, "use RR in Ada 2005", Ada_05);
3461    type M is record
3462       F1 : Integer;
3463       F2 : Integer;
3464       pragma Obsolescent (Entity => F2);
3465       F3 : Integer;
3466    end record;
3468    type E is (a, bc, 'd', quack);
3469    pragma Obsolescent (Entity => bc)
3470    pragma Obsolescent (Entity => 'd')
3472    function "+"
3473      (a, b : character) return character;
3474    pragma Obsolescent (Entity => "+");
3475 end;
3476 @end smallexample
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).
3485 @node Pragma Optimize_Alignment
3486 @unnumberedsec Pragma Optimize_Alignment
3487 @findex Optimize_Alignment
3488 @cindex Alignment, default settings
3489 @noindent
3490 Syntax:
3492 @smallexample @c ada
3493 pragma Optimize_Alignment (TIME | SPACE | OFF);
3494 @end smallexample
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.
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:
3511 @smallexample @c ada
3512    type R is record
3513       X : Integer;
3514       Y : Character;
3515    end record;
3517    for R'Size use 5*8;
3518 @end smallexample
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.
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:
3531 @smallexample @c ada
3532    type R is record
3533       A : Character;
3534       B : Character;
3535       C : Boolean;
3536    end record;
3538    pragma Pack (R);
3539    for R'Size use 17;
3540 @end smallexample
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.
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.
3557 @node Pragma Passive
3558 @unnumberedsec Pragma Passive
3559 @findex Passive
3560 @noindent
3561 Syntax:
3563 @smallexample @c ada
3564 pragma Passive [(Semaphore | No)];
3565 @end smallexample
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).
3578 @node Pragma Persistent_BSS
3579 @unnumberedsec Pragma Persistent_BSS
3580 @findex Persistent_BSS
3581 @noindent
3582 Syntax:
3584 @smallexample @c ada
3585 pragma Persistent_BSS [(LOCAL_NAME)]
3586 @end smallexample
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).
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.
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.
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}.
3609 @node Pragma Polling
3610 @unnumberedsec Pragma Polling
3611 @findex Polling
3612 @noindent
3613 Syntax:
3615 @smallexample @c ada
3616 pragma Polling (ON | OFF);
3617 @end smallexample
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}.
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.
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.
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}.
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.
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.
3652 @node Pragma Postcondition
3653 @unnumberedsec Pragma Postcondition
3654 @cindex Postconditions
3655 @cindex Checks, postconditions
3656 @findex Postconditions
3657 @noindent
3658 Syntax:
3660 @smallexample @c ada
3661 pragma Postcondition (
3662    [Check   =>] Boolean_Expression
3663  [,[Message =>] String_Expression]);
3664 @end smallexample
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.
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.
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.
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:
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
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.
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:
3717 @smallexample @c ada
3718    Sqrt_Calls : Natural := 0;
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
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.
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.
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.
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.
3754 The following example shows that this even allows
3755 mutually recursive postconditions as in:
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))));
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))));
3773 end Parity_Functions;
3774 @end smallexample
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.
3782 @smallexample @c ada
3783 package Sort is
3785    Performance : constant Float;
3786    --  Performance constant set by implementation
3787    --  to match target architecture behavior.
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
3799 @node Pragma Precondition
3800 @unnumberedsec Pragma Precondition
3801 @cindex Preconditions
3802 @cindex Checks, preconditions
3803 @findex Preconditions
3804 @noindent
3805 Syntax:
3807 @smallexample @c ada
3808 pragma Precondition (
3809    [Check   =>] Boolean_Expression
3810  [,[Message =>] String_Expression]);
3811 @end smallexample
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.
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:
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
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).
3840 @node Pragma Profile (Ravenscar)
3841 @unnumberedsec Pragma Profile (Ravenscar)
3842 @findex Ravenscar
3843 @noindent
3844 Syntax:
3846 @smallexample @c ada
3847 pragma Profile (Ravenscar);
3848 @end smallexample
3850 @noindent
3851 A configuration pragma that establishes the following set of configuration
3852 pragmas:
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.
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.
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
3869 plus the following set of restrictions:
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.
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.
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).
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.
3899 @item No_Asynchronous_Control
3900 There are no semantic dependences on the package
3901 Asynchronous_Task_Control.
3903 @item No_Calendar
3904 There are no semantic dependencies on the package Ada.Calendar.
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).
3911 @item No_Dynamic_Priorities
3912 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3914 @item No_Implicit_Heap_Allocations
3915 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3917 @item No_Local_Protected_Objects
3918 Protected objects and access types that designate
3919 such objects shall be declared only at library level.
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.
3925 @item No_Protected_Type_Allocators
3926 There are no allocators for protected types or
3927 types containing protected subcomponents.
3929 @item No_Relative_Delay
3930 There are no delay_relative statements.
3932 @item No_Requeue_Statements
3933 Requeue statements are not allowed.
3935 @item No_Select_Statements
3936 There are no select_statements.
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.
3942 @item No_Task_Allocators
3943 [RM D.7] There are no allocators for task types
3944 or types containing task subcomponents.
3946 @item No_Task_Attributes_Package
3947 There are no semantic dependencies on the Ada.Task_Attributes package.
3949 @item No_Task_Hierarchy
3950 [RM D.7] All (non-environment) tasks depend
3951 directly on the environment task of the partition.
3953 @item No_Task_Termination
3954 Tasks which terminate are erroneous.
3956 @item No_Unchecked_Conversion
3957 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
3959 @item No_Unchecked_Deallocation
3960 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
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
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}.
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.
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.
3996 @node Pragma Profile (Restricted)
3997 @unnumberedsec Pragma Profile (Restricted)
3998 @findex Restricted Run Time
3999 @noindent
4000 Syntax:
4002 @smallexample @c ada
4003 pragma Profile (Restricted);
4004 @end smallexample
4006 @noindent
4007 A configuration pragma that establishes the following set of restrictions:
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
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.
4032 @node Pragma Psect_Object
4033 @unnumberedsec Pragma Psect_Object
4034 @findex Psect_Object
4035 @noindent
4036 Syntax:
4038 @smallexample @c ada
4039 pragma Psect_Object (
4040      [Internal =>] LOCAL_NAME,
4041   [, [External =>] EXTERNAL_SYMBOL]
4042   [, [Size     =>] EXTERNAL_SYMBOL]);
4044 EXTERNAL_SYMBOL ::=
4045   IDENTIFIER
4046 | static_string_EXPRESSION
4047 @end smallexample
4049 @noindent
4050 This pragma is identical in effect to pragma @code{Common_Object}.
4052 @node Pragma Pure_Function
4053 @unnumberedsec Pragma Pure_Function
4054 @findex Pure_Function
4055 @noindent
4056 Syntax:
4058 @smallexample @c ada
4059 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4060 @end smallexample
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.
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).
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.
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.
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.
4107 @node Pragma Restriction_Warnings
4108 @unnumberedsec Pragma Restriction_Warnings
4109 @findex Restriction_Warnings
4110 @noindent
4111 Syntax:
4113 @smallexample @c ada
4114 pragma Restriction_Warnings
4115   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4116 @end smallexample
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.
4126 @node Pragma Shared
4127 @unnumberedsec Pragma Shared
4128 @findex Shared
4130 @noindent
4131 This pragma is provided for compatibility with Ada 83. The syntax and
4132 semantics are identical to pragma Atomic.
4134 @node Pragma Source_File_Name
4135 @unnumberedsec Pragma Source_File_Name
4136 @findex Source_File_Name
4137 @noindent
4138 Syntax:
4140 @smallexample @c ada
4141 pragma Source_File_Name (
4142   [Unit_Name   =>] unit_NAME,
4143   Spec_File_Name =>  STRING_LITERAL);
4145 pragma Source_File_Name (
4146   [Unit_Name   =>] unit_NAME,
4147   Body_File_Name =>  STRING_LITERAL);
4148 @end smallexample
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.
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.
4163 @smallexample @c ada
4164 pragma Source_File_Name
4165   (Spec_File_Name => STRING_LITERAL
4166    [,Casing => CASING_SPEC]
4167    [,Dot_Replacement => STRING_LITERAL]);
4169 pragma Source_File_Name
4170   (Body_File_Name => STRING_LITERAL
4171    [,Casing => CASING_SPEC]
4172    [,Dot_Replacement => STRING_LITERAL]);
4174 pragma Source_File_Name
4175   (Subunit_File_Name => STRING_LITERAL
4176    [,Casing => CASING_SPEC]
4177    [,Dot_Replacement => STRING_LITERAL]);
4179 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4180 @end smallexample
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.
4190 A pragma Source_File_Name cannot appear after a
4191 @ref{Pragma Source_File_Name_Project}.
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}.
4198 @node Pragma Source_File_Name_Project
4199 @unnumberedsec Pragma Source_File_Name_Project
4200 @findex Source_File_Name_Project
4201 @noindent
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.
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).
4215 @node Pragma Source_Reference
4216 @unnumberedsec Pragma Source_Reference
4217 @findex Source_Reference
4218 @noindent
4219 Syntax:
4221 @smallexample @c ada
4222 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4223 @end smallexample
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.
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.
4239 @node Pragma Stream_Convert
4240 @unnumberedsec Pragma Stream_Convert
4241 @findex Stream_Convert
4242 @noindent
4243 Syntax:
4245 @smallexample @c ada
4246 pragma Stream_Convert (
4247   [Entity =>] type_LOCAL_NAME,
4248   [Read   =>] function_NAME,
4249   [Write  =>] function_NAME);
4250 @end smallexample
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.
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.
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.
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.
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:
4286 @smallexample @c ada
4287 function To_Unbounded (S : String)
4288            return Unbounded_String
4289   renames To_Unbounded_String;
4291 pragma Stream_Convert
4292   (Unbounded_String, To_Unbounded, To_String);
4293 @end smallexample
4295 @noindent
4296 The specifications of the referenced functions, as given in the Ada
4297 Reference Manual are:
4299 @smallexample @c ada
4300 function To_Unbounded_String (Source : String)
4301   return Unbounded_String;
4303 function To_String (Source : Unbounded_String)
4304   return String;
4305 @end smallexample
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.
4313 @node Pragma Style_Checks
4314 @unnumberedsec Pragma Style_Checks
4315 @findex Style_Checks
4316 @noindent
4317 Syntax:
4319 @smallexample @c ada
4320 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4321                      On | Off [, LOCAL_NAME]);
4322 @end smallexample
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).
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:
4340 @itemize @bullet
4341 @item
4342 @smallexample @c ada
4343 pragma Style_Checks ("l");
4344 @end smallexample
4346 @item
4347 @smallexample
4348 gcc -c -gnatyl @dots{}
4349 @end smallexample
4350 @end itemize
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.
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:
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
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:
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
4389 @node Pragma Subtitle
4390 @unnumberedsec Pragma Subtitle
4391 @findex Subtitle
4392 @noindent
4393 Syntax:
4395 @smallexample @c ada
4396 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4397 @end smallexample
4399 @noindent
4400 This pragma is recognized for compatibility with other Ada compilers
4401 but is ignored by GNAT@.
4403 @node Pragma Suppress
4404 @unnumberedsec Pragma Suppress
4405 @findex Suppress
4406 @noindent
4407 Syntax:
4409 @smallexample @c ada
4410 pragma Suppress (Identifier [, [On =>] Name]);
4411 @end smallexample
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.
4421 @node Pragma Suppress_All
4422 @unnumberedsec Pragma Suppress_All
4423 @findex Suppress_All
4424 @noindent
4425 Syntax:
4427 @smallexample @c ada
4428 pragma Suppress_All;
4429 @end smallexample
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@.
4438 @node Pragma Suppress_Exception_Locations
4439 @unnumberedsec Pragma Suppress_Exception_Locations
4440 @findex Suppress_Exception_Locations
4441 @noindent
4442 Syntax:
4444 @smallexample @c ada
4445 pragma Suppress_Exception_Locations;
4446 @end smallexample
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.
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:
4469 @smallexample @c ada
4470 pragma Suppress_Initialization ([Entity =>] type_Name);
4471 @end smallexample
4473 @noindent
4474 This pragma suppresses any implicit or explicit initialization
4475 associated with the given type name for all variables of this type.
4477 @node Pragma Task_Info
4478 @unnumberedsec Pragma Task_Info
4479 @findex Task_Info
4480 @noindent
4481 Syntax
4483 @smallexample @c ada
4484 pragma Task_Info (EXPRESSION);
4485 @end smallexample
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.
4498 @node Pragma Task_Name
4499 @unnumberedsec Pragma Task_Name
4500 @findex Task_Name
4501 @noindent
4502 Syntax
4504 @smallexample @c ada
4505 pragma Task_Name (string_EXPRESSION);
4506 @end smallexample
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.
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.
4523 @smallexample @c ada
4524 --  Example of the use of pragma Task_Name
4526 with Ada.Task_Identification;
4527 use Ada.Task_Identification;
4528 with Text_IO; use Text_IO;
4529 procedure t3 is
4531    type Astring is access String;
4533    task type Task_Typ (Name : access String) is
4534       pragma Task_Name (Name.all);
4535    end Task_Typ;
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;
4543    type Ptr_Task is access Task_Typ;
4544    Task_Var : Ptr_Task;
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
4554 @node Pragma Task_Storage
4555 @unnumberedsec Pragma Task_Storage
4556 @findex Task_Storage
4557 Syntax:
4559 @smallexample @c ada
4560 pragma Task_Storage (
4561   [Task_Type =>] LOCAL_NAME,
4562   [Top_Guard =>] static_integer_EXPRESSION);
4563 @end smallexample
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.
4573 @node Pragma Time_Slice
4574 @unnumberedsec Pragma Time_Slice
4575 @findex Time_Slice
4576 @noindent
4577 Syntax:
4579 @smallexample @c ada
4580 pragma Time_Slice (static_duration_EXPRESSION);
4581 @end smallexample
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.
4592 @node Pragma Title
4593 @unnumberedsec Pragma Title
4594 @findex Title
4595 @noindent
4596 Syntax:
4598 @smallexample @c ada
4599 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4601 TITLING_OPTION ::=
4602   [Title    =>] STRING_LITERAL,
4603 | [Subtitle =>] STRING_LITERAL
4604 @end smallexample
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.
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.
4617 @node Pragma Unchecked_Union
4618 @unnumberedsec Pragma Unchecked_Union
4619 @cindex Unions in C
4620 @findex Unchecked_Union
4621 @noindent
4622 Syntax:
4624 @smallexample @c ada
4625 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4626 @end smallexample
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.
4636 @node Pragma Unimplemented_Unit
4637 @unnumberedsec Pragma Unimplemented_Unit
4638 @findex Unimplemented_Unit
4639 @noindent
4640 Syntax:
4642 @smallexample @c ada
4643 pragma Unimplemented_Unit;
4644 @end smallexample
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.
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.
4656 @node Pragma Universal_Aliasing
4657 @unnumberedsec Pragma Universal_Aliasing
4658 @findex Universal_Aliasing
4659 @noindent
4660 Syntax:
4662 @smallexample @c ada
4663 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4664 @end smallexample
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}.
4675 @node Pragma Universal_Data
4676 @unnumberedsec Pragma Universal_Data
4677 @findex Universal_Data
4678 @noindent
4679 Syntax:
4681 @smallexample @c ada
4682 pragma Universal_Data [(library_unit_Name)];
4683 @end smallexample
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.
4699 @node Pragma Unmodified
4700 @unnumberedsec Pragma Unmodified
4701 @findex Unmodified
4702 @cindex Warnings, unmodified
4703 @noindent
4704 Syntax:
4706 @smallexample @c ada
4707 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4708 @end smallexample
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).
4720 This is particularly useful for clearly signaling that a particular
4721 parameter is not modified, even though the spec suggests that it might
4724 @node Pragma Unreferenced
4725 @unnumberedsec Pragma Unreferenced
4726 @findex Unreferenced
4727 @cindex Warnings, unreferenced
4728 @noindent
4729 Syntax:
4731 @smallexample @c ada
4732 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4733 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4734 @end smallexample
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).
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.
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.
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.
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}.
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.
4774 @node Pragma Unreferenced_Objects
4775 @unnumberedsec Pragma Unreferenced_Objects
4776 @findex Unreferenced_Objects
4777 @cindex Warnings, unreferenced
4778 @noindent
4779 Syntax:
4781 @smallexample @c ada
4782 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4783 @end smallexample
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.
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.
4797 @node Pragma Unreserve_All_Interrupts
4798 @unnumberedsec Pragma Unreserve_All_Interrupts
4799 @findex Unreserve_All_Interrupts
4800 @noindent
4801 Syntax:
4803 @smallexample @c ada
4804 pragma Unreserve_All_Interrupts;
4805 @end smallexample
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.
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.
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.
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.
4833 @node Pragma Unsuppress
4834 @unnumberedsec Pragma Unsuppress
4835 @findex Unsuppress
4836 @noindent
4837 Syntax:
4839 @smallexample @c ada
4840 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4841 @end smallexample
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}.
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.
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:
4862 @smallexample @c ada
4863 pragma Use_VADS_Size;
4864 @end smallexample
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.
4875 @node Pragma Validity_Checks
4876 @unnumberedsec Pragma Validity_Checks
4877 @findex Validity_Checks
4878 @noindent
4879 Syntax:
4881 @smallexample @c ada
4882 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4883 @end smallexample
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).
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:
4903 @itemize @bullet
4904 @item
4905 @smallexample @c ada
4906 pragma Validity_Checks ("im");
4907 @end smallexample
4909 @item
4910 @smallexample
4911 gcc -c -gnatVim @dots{}
4912 @end smallexample
4913 @end itemize
4915 @noindent
4916 The form ALL_CHECKS activates all standard checks (its use is equivalent
4917 to the use of the @code{gnatva} switch.
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:
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
4934 @node Pragma Volatile
4935 @unnumberedsec Pragma Volatile
4936 @findex Volatile
4937 @noindent
4938 Syntax:
4940 @smallexample @c ada
4941 pragma Volatile (LOCAL_NAME);
4942 @end smallexample
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.
4952 @node Pragma Warnings
4953 @unnumberedsec Pragma Warnings
4954 @findex Warnings
4955 @noindent
4956 Syntax:
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
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.
4973 The form with a single argument may be used as a configuration pragma.
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}).
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}.
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
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.
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).
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.
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.
5075 The second usage is to suppress a warning locally, and in this case, two
5076 pragmas must appear in sequence:
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
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.
5088 @node Pragma Weak_External
5089 @unnumberedsec Pragma Weak_External
5090 @findex Weak_External
5091 @noindent
5092 Syntax:
5094 @smallexample @c ada
5095 pragma Weak_External ([Entity =>] LOCAL_NAME);
5096 @end smallexample
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.
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.
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.
5117 Some file formats do not support weak symbols so not all target machines
5118 support this pragma.
5120 @smallexample @c ada
5121 --  Example of the use of pragma Weak_External
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;
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
5139 @node Pragma Wide_Character_Encoding
5140 @unnumberedsec Pragma Wide_Character_Encoding
5141 @findex Wide_Character_Encoding
5142 @noindent
5143 Syntax:
5145 @smallexample @c ada
5146 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5147 @end smallexample
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.
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}.
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.
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.
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.
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.
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
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).
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.
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}
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}
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.
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}.
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).
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.
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.
5330 This attribute is designed to be compatible with the DEC Ada 83 definition
5331 and implementation of the @code{Bit} attribute.
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}.
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:
5357 @smallexample @c ada
5358 procedure K is @dots{}
5360 procedure L;
5361 for L'Address use K'Address;
5362 pragma Import (Ada, L);
5363 @end smallexample
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.
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.
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.
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}.
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.
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.
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.
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.
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).
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.
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:
5472 @smallexample @c ada
5473 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5474   return @i{Universal_Integer};
5475 @end smallexample
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.
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).
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}.
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:
5507 @smallexample @c ada
5508 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5509   return @var{S}'Base};
5510 @end smallexample
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).
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.
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:
5536 @smallexample @c ada
5537 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5538   return @var{S};
5539 @end smallexample
5541 @noindent
5542 The value returned is the fixed-point value @var{V} such that
5544 @smallexample @c ada
5545 @var{V} = Arg * @var{S}'Small
5546 @end smallexample
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.
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.
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.
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:
5589 @smallexample @c ada
5590 Put_Line ("X = " & X'Img);
5591 @end smallexample
5593 @noindent
5594 has the same meaning as the more verbose:
5596 @smallexample @c ada
5597 Put_Line ("X = " & @var{T}'Image (X));
5598 @end smallexample
5600 @noindent
5601 where @var{T} is the (sub)type of the object @code{X}.
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:
5610 @smallexample @c ada
5611 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5612   return @var{S};
5613 @end smallexample
5615 @noindent
5616 The value returned is the integer value @var{V}, such that
5618 @smallexample @c ada
5619 Arg = @var{V} * @var{T}'Small
5620 @end smallexample
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.
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.
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.
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.
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.
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}.
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}.
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.
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:
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
5730 @noindent
5731 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5732 @cindex OpenVMS
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.
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).
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.
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:
5766 @smallexample @c ada
5767 type Rec is record
5768    I : Integer;
5769    C : Character;
5770 end record;
5771 @end smallexample
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).
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).
5794 The following example shows the use of 'Old to implement
5795 a test of a postcondition:
5797 @smallexample @c ada
5798 with Old_Pkg;
5799 procedure Old is
5800 begin
5801    Old_Pkg.Incr;
5802 end Old;
5804 package Old_Pkg is
5805    procedure Incr;
5806 end Old_Pkg;
5808 package body Old_Pkg is
5809    Count : Natural := 0;
5811    procedure Incr is
5812    begin
5813       ... code manipulating the value of Count
5815       pragma Assert (Count = Count'Old + 1);
5816    end Incr;
5817 end Old_Pkg;
5818 @end smallexample
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.
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.
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.
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}.
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.
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.
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.
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.
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}.
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.
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.
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.
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").
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},
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).
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:
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
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.
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.
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.
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.
6019 For example, the following program prints the first 50 digits of pi:
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
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).
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.
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.
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.
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}.
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}.
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.
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.
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.
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.
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.
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.
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:
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
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.
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.
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.
6229 @cindex Integer types
6230 @unnumberedsec 3.5.4(28): Integer Types
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
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.
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.
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.
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.
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)).
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.
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.
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}.
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.
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:
6387 @smallexample @c ada
6388   X : Integer;
6389   Y : Float;
6390   for Y'Address use X'Address;>>
6391 @end smallexample
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.
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.
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:
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.
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
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.
6455 @sp 1
6456 @cartouche
6457 The recommended level of support for the @code{Address} attribute is:
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.
6467 @sp 1
6468 @cartouche
6469 An implementation should support @code{Address} clauses for imported
6470 subprograms.
6471 @end cartouche
6472 Followed.
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.
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.
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:
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.
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.
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.
6518 @sp 1
6519 @cartouche
6520 The recommended level of support for the @code{Alignment} attribute for
6521 objects is:
6523 Same as above, for subtypes, but in addition:
6524 @end cartouche
6525 Followed.
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.
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:
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.
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:
6558 Aliased objects (including components).
6559 @end cartouche
6560 Followed.
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.
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.
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.
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.
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.
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
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.
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:
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.
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.
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.
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.
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.
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@.
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.
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.
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.
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.
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.
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.
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:
6782 @itemize @bullet
6783 @item
6784 At initial elaboration time, to allocate dynamically sized global
6785 objects.
6787 @item
6788 To allocate space for a task when a task is created.
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
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.
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.
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.
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
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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++.
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.
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.
7005 @sp 1
7006 @cartouche
7007 An Ada procedure corresponds to a void-returning C function.
7008 @end cartouche
7009 Followed.
7011 @sp 1
7012 @cartouche
7013 An Ada function corresponds to a non-void C function.
7014 @end cartouche
7015 Followed.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
7109 @sp 1
7110 @cartouche
7111 An Ada procedure corresponds to a Fortran subroutine.
7112 @end cartouche
7113 Followed.
7115 @sp 1
7116 @cartouche
7117 An Ada function corresponds to a Fortran function.
7118 @end cartouche
7119 Followed.
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.
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.
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.
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.
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.
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.
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.
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.
7194 @sp 1
7195 @cartouche
7196 Standard numeric functions---e.g.@:, sin, log.
7197 @end cartouche
7198 Followed on any target supporting such operations.
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.
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.
7212 @sp 1
7213 @cartouche
7214 Direct operations on I/O ports.
7215 @end cartouche
7216 Followed on any target supporting such operations.
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.
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.
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.
7251 @cindex Package @code{Interrupts}
7252 @findex Interrupts
7253 @unnumberedsec C.3.2(25): Package @code{Interrupts}
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.
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.
7277 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
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.
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.
7303 @cindex Locking Policies
7304 @unnumberedsec D.3(17): Locking Policies
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.
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.
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.
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.
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.
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.
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.
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.
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.
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@.
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.
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.
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.
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.
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.
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.
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.
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.
7524 @cindex Complex arithmetic accuracy
7525 @cindex Accuracy, complex arithmetic
7526 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
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.
7538 @c -----------------------------------------
7539 @node Implementation Defined Characteristics
7540 @chapter Implementation Defined Characteristics
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@.
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.
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.
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}.
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.
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.
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.
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.
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.
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.
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.
7637 @sp 1
7638 @cartouche
7639 @noindent
7640 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7641 @end cartouche
7642 @noindent
7644 @xref{Implementation Defined Pragmas}.
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.
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.
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
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.
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.
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.
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
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)
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.
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.
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}.
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.
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}.
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}.
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}.
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.
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.
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.
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.
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.
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.
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}.
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.
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.
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.
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}).
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.
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.
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.
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.
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.
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:
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
8010 @noindent
8011 where
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.
8018 @item
8019 @code{mmmm} is the message (this line present only if message is non-null)
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.
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
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#}).
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).
8047 In addition, a user program can add implementation-defined check names
8048 by means of the pragma Check_Name.
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.
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.
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.
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.
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.
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.
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.
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}.
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}.
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
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.
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
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.
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.
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.
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.
8221 @table @code
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)}).
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.
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}.
8246 @item No_Default_Initialization
8247 @findex No_Default_Initialization
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).
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.
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.
8282 @smallexample
8283 package Pkg is
8284   type T is tagged record
8285     Data : Natural;
8286   end record;
8287   procedure P (X : T);
8289   type DT is new T with record
8290     More_Data : Natural;
8291   end record;
8292   procedure Q (X : DT);
8293 end Pkg;
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;
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
8314   Test (Obj);              --  OK   : Type conversion
8316   if Obj in T'Class then   --  OK   : Membership test
8317      null;
8318   end if;
8319 end Example;
8320 @end smallexample
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.
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).
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.
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:
8348    procedure Last_Chance_Handler
8349      (Source_Location : System.Address; Line : Integer);
8350    pragma Export (C, Last_Chance_Handler,
8351                   "__gnat_last_chance_handler");
8353    The parameter is a C null-terminated string representing a message to be
8354    associated with the exception (typically the source location of the raise
8355    statement generated by the compiler). The Line parameter when nonzero
8356    represents the line number in the source program where the raise occurs.
8358 @item No_Exception_Propagation
8359 @findex No_Exception_Propagation
8360 This restriction guarantees that exceptions are never propagated to an outer
8361 subprogram scope). The only case in which an exception may be raised is when
8362 the handler is statically in the same subprogram, so that the effect of a raise
8363 is essentially like a goto statement. Any other raise statement (implicit or
8364 explicit) will be considered unhandled. Exception handlers are allowed, but may
8365 not contain an exception occurrence identifier (exception choice). In addition
8366 use of the package GNAT.Current_Exception is not permitted, and reraise
8367 statements (raise with no operand) are not permitted.
8369 @item No_Exception_Registration
8370 @findex No_Exception_Registration
8371 This restriction ensures at compile time that no stream operations for
8372 types Exception_Id or Exception_Occurrence are used. This also makes it
8373 impossible to pass exceptions to or from a partition with this restriction
8374 in a distributed environment. If this exception is active, then the generated
8375 code is simplified by omitting the otherwise-required global registration
8376 of exceptions when they are declared.
8378 @item No_Implicit_Conditionals
8379 @findex No_Implicit_Conditionals
8380 This restriction ensures that the generated code does not contain any
8381 implicit conditionals, either by modifying the generated code where possible,
8382 or by rejecting any construct that would otherwise generate an implicit
8383 conditional. Note that this check does not include run time constraint
8384 checks, which on some targets may generate implicit conditionals as
8385 well. To control the latter, constraint checks can be suppressed in the
8386 normal manner. Constructs generating implicit conditionals include comparisons
8387 of composite objects and the Max/Min attributes.
8389 @item No_Implicit_Dynamic_Code
8390 @findex No_Implicit_Dynamic_Code
8391 @cindex trampoline
8392 This restriction prevents the compiler from building ``trampolines''.
8393 This is a structure that is built on the stack and contains dynamic
8394 code to be executed at run time. On some targets, a trampoline is
8395 built for the following features: @code{Access},
8396 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8397 nested task bodies; primitive operations of nested tagged types.
8398 Trampolines do not work on machines that prevent execution of stack
8399 data. For example, on windows systems, enabling DEP (data execution
8400 protection) will cause trampolines to raise an exception.
8401 Trampolines are also quite slow at run time.
8403 On many targets, trampolines have been largely eliminated. Look at the
8404 version of system.ads for your target --- if it has
8405 Always_Compatible_Rep equal to False, then trampolines are largely
8406 eliminated. In particular, a trampoline is built for the following
8407 features: @code{Address} of a nested subprogram;
8408 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8409 but only if pragma Favor_Top_Level applies, or the access type has a
8410 foreign-language convention; primitive operations of nested tagged
8411 types.
8413 @item No_Implicit_Loops
8414 @findex No_Implicit_Loops
8415 This restriction ensures that the generated code does not contain any
8416 implicit @code{for} loops, either by modifying
8417 the generated code where possible,
8418 or by rejecting any construct that would otherwise generate an implicit
8419 @code{for} loop. If this restriction is active, it is possible to build
8420 large array aggregates with all static components without generating an
8421 intermediate temporary, and without generating a loop to initialize individual
8422 components. Otherwise, a loop is created for arrays larger than about 5000
8423 scalar components.
8425 @item No_Initialize_Scalars
8426 @findex No_Initialize_Scalars
8427 This restriction ensures that no unit in the partition is compiled with
8428 pragma Initialize_Scalars. This allows the generation of more efficient
8429 code, and in particular eliminates dummy null initialization routines that
8430 are otherwise generated for some record and array types.
8432 @item No_Local_Protected_Objects
8433 @findex No_Local_Protected_Objects
8434 This restriction ensures at compile time that protected objects are
8435 only declared at the library level.
8437 @item No_Protected_Type_Allocators
8438 @findex No_Protected_Type_Allocators
8439 This restriction ensures at compile time that there are no allocator
8440 expressions that attempt to allocate protected objects.
8442 @item No_Secondary_Stack
8443 @findex No_Secondary_Stack
8444 This restriction ensures at compile time that the generated code does not
8445 contain any reference to the secondary stack.  The secondary stack is used
8446 to implement functions returning unconstrained objects (arrays or records)
8447 on some targets.
8449 @item No_Select_Statements
8450 @findex No_Select_Statements
8451 This restriction ensures at compile time no select statements of any kind
8452 are permitted, that is the keyword @code{select} may not appear.
8453 This is one of the restrictions of the Ravenscar
8454 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8456 @item No_Standard_Storage_Pools
8457 @findex No_Standard_Storage_Pools
8458 This restriction ensures at compile time that no access types
8459 use the standard default storage pool.  Any access type declared must
8460 have an explicit Storage_Pool attribute defined specifying a
8461 user-defined storage pool.
8463 @item No_Streams
8464 @findex No_Streams
8465 This restriction ensures at compile/bind time that there are no
8466 stream objects created (and therefore no actual stream operations).
8467 This restriction does not forbid dependences on the package
8468 @code{Ada.Streams}. So it is permissible to with
8469 @code{Ada.Streams} (or another package that does so itself)
8470 as long as no actual stream objects are created.
8472 @item No_Task_Attributes_Package
8473 @findex No_Task_Attributes_Package
8474 This restriction ensures at compile time that there are no implicit or
8475 explicit dependencies on the package @code{Ada.Task_Attributes}.
8477 @item No_Task_Termination
8478 @findex No_Task_Termination
8479 This restriction ensures at compile time that no terminate alternatives
8480 appear in any task body.
8482 @item No_Tasking
8483 @findex No_Tasking
8484 This restriction prevents the declaration of tasks or task types throughout
8485 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8486 except that violations are caught at compile time and cause an error message
8487 to be output either by the compiler or binder.
8489 @item Static_Priorities
8490 @findex Static_Priorities
8491 This restriction ensures at compile time that all priority expressions
8492 are static, and that there are no dependencies on the package
8493 @code{Ada.Dynamic_Priorities}.
8495 @item Static_Storage_Size
8496 @findex Static_Storage_Size
8497 This restriction ensures at compile time that any expression appearing
8498 in a Storage_Size pragma or attribute definition clause is static.
8500 @end table
8502 @noindent
8503 The second set of implementation dependent restriction identifiers
8504 does not require partition-wide consistency.
8505 The restriction may be enforced for a single
8506 compilation unit without any effect on any of the
8507 other compilation units in the partition.
8509 @table @code
8511 @item No_Elaboration_Code
8512 @findex No_Elaboration_Code
8513 This restriction ensures at compile time that no elaboration code is
8514 generated.  Note that this is not the same condition as is enforced
8515 by pragma @code{Preelaborate}.  There are cases in which pragma
8516 @code{Preelaborate} still permits code to be generated (e.g.@: code
8517 to initialize a large array to all zeroes), and there are cases of units
8518 which do not meet the requirements for pragma @code{Preelaborate},
8519 but for which no elaboration code is generated.  Generally, it is
8520 the case that preelaborable units will meet the restrictions, with
8521 the exception of large aggregates initialized with an others_clause,
8522 and exception declarations (which generate calls to a run-time
8523 registry procedure).  This restriction is enforced on
8524 a unit by unit basis, it need not be obeyed consistently
8525 throughout a partition.
8527 In the case of aggregates with others, if the aggregate has a dynamic
8528 size, there is no way to eliminate the elaboration code (such dynamic
8529 bounds would be incompatible with @code{Preelaborate} in any case). If
8530 the bounds are static, then use of this restriction actually modifies
8531 the code choice of the compiler to avoid generating a loop, and instead
8532 generate the aggregate statically if possible, no matter how many times
8533 the data for the others clause must be repeatedly generated.
8535 It is not possible to precisely document
8536 the constructs which are compatible with this restriction, since,
8537 unlike most other restrictions, this is not a restriction on the
8538 source code, but a restriction on the generated object code. For
8539 example, if the source contains a declaration:
8541 @smallexample
8542    Val : constant Integer := X;
8543 @end smallexample
8545 @noindent
8546 where X is not a static constant, it may be possible, depending
8547 on complex optimization circuitry, for the compiler to figure
8548 out the value of X at compile time, in which case this initialization
8549 can be done by the loader, and requires no initialization code. It
8550 is not possible to document the precise conditions under which the
8551 optimizer can figure this out.
8553 Note that this the implementation of this restriction requires full
8554 code generation. If it is used in conjunction with "semantics only"
8555 checking, then some cases of violations may be missed.
8557 @item No_Entry_Queue
8558 @findex No_Entry_Queue
8559 This restriction is a declaration that any protected entry compiled in
8560 the scope of the restriction has at most one task waiting on the entry
8561 at any one time, and so no queue is required.  This restriction is not
8562 checked at compile time.  A program execution is erroneous if an attempt
8563 is made to queue a second task on such an entry.
8565 @item No_Implementation_Attributes
8566 @findex No_Implementation_Attributes
8567 This restriction checks at compile time that no GNAT-defined attributes
8568 are present.  With this restriction, the only attributes that can be used
8569 are those defined in the Ada Reference Manual.
8571 @item No_Implementation_Pragmas
8572 @findex No_Implementation_Pragmas
8573 This restriction checks at compile time that no GNAT-defined pragmas
8574 are present.  With this restriction, the only pragmas that can be used
8575 are those defined in the Ada Reference Manual.
8577 @item No_Implementation_Restrictions
8578 @findex No_Implementation_Restrictions
8579 This restriction checks at compile time that no GNAT-defined restriction
8580 identifiers (other than @code{No_Implementation_Restrictions} itself)
8581 are present.  With this restriction, the only other restriction identifiers
8582 that can be used are those defined in the Ada Reference Manual.
8584 @item No_Wide_Characters
8585 @findex No_Wide_Characters
8586 This restriction ensures at compile time that no uses of the types
8587 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8588 wide types
8589 appear, and that no wide or wide wide string or character literals
8590 appear in the program (that is literals representing characters not in
8591 type @code{Character}.
8593 @end table
8595 @sp 1
8596 @cartouche
8597 @noindent
8598 @strong{58}.  The consequences of violating limitations on
8599 @code{Restrictions} pragmas.  See 13.12(9).
8600 @end cartouche
8601 @noindent
8602 Restrictions that can be checked at compile time result in illegalities
8603 if violated.  Currently there are no other consequences of violating
8604 restrictions.
8606 @sp 1
8607 @cartouche
8608 @noindent
8609 @strong{59}.  The representation used by the @code{Read} and
8610 @code{Write} attributes of elementary types in terms of stream
8611 elements.  See 13.13.2(9).
8612 @end cartouche
8613 @noindent
8614 The representation is the in-memory representation of the base type of
8615 the type, using the number of bits corresponding to the
8616 @code{@var{type}'Size} value, and the natural ordering of the machine.
8618 @sp 1
8619 @cartouche
8620 @noindent
8621 @strong{60}.  The names and characteristics of the numeric subtypes
8622 declared in the visible part of package @code{Standard}.  See A.1(3).
8623 @end cartouche
8624 @noindent
8625 See items describing the integer and floating-point types supported.
8627 @sp 1
8628 @cartouche
8629 @noindent
8630 @strong{61}.  The accuracy actually achieved by the elementary
8631 functions.  See A.5.1(1).
8632 @end cartouche
8633 @noindent
8634 The elementary functions correspond to the functions available in the C
8635 library.  Only fast math mode is implemented.
8637 @sp 1
8638 @cartouche
8639 @noindent
8640 @strong{62}.  The sign of a zero result from some of the operators or
8641 functions in @code{Numerics.Generic_Elementary_Functions}, when
8642 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8643 @end cartouche
8644 @noindent
8645 The sign of zeroes follows the requirements of the IEEE 754 standard on
8646 floating-point.
8648 @sp 1
8649 @cartouche
8650 @noindent
8651 @strong{63}.  The value of
8652 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8653 @end cartouche
8654 @noindent
8655 Maximum image width is 649, see library file @file{a-numran.ads}.
8657 @sp 1
8658 @cartouche
8659 @noindent
8660 @strong{64}.  The value of
8661 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8662 @end cartouche
8663 @noindent
8664 Maximum image width is 80, see library file @file{a-nudira.ads}.
8666 @sp 1
8667 @cartouche
8668 @noindent
8669 @strong{65}.  The algorithms for random number generation.  See
8670 A.5.2(32).
8671 @end cartouche
8672 @noindent
8673 The algorithm is documented in the source files @file{a-numran.ads} and
8674 @file{a-numran.adb}.
8676 @sp 1
8677 @cartouche
8678 @noindent
8679 @strong{66}.  The string representation of a random number generator's
8680 state.  See A.5.2(38).
8681 @end cartouche
8682 @noindent
8683 See the documentation contained in the file @file{a-numran.adb}.
8685 @sp 1
8686 @cartouche
8687 @noindent
8688 @strong{67}.  The minimum time interval between calls to the
8689 time-dependent Reset procedure that are guaranteed to initiate different
8690 random number sequences.  See A.5.2(45).
8691 @end cartouche
8692 @noindent
8693 The minimum period between reset calls to guarantee distinct series of
8694 random numbers is one microsecond.
8696 @sp 1
8697 @cartouche
8698 @noindent
8699 @strong{68}.  The values of the @code{Model_Mantissa},
8700 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8701 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8702 Annex is not supported.  See A.5.3(72).
8703 @end cartouche
8704 @noindent
8705 See the source file @file{ttypef.ads} for the values of all numeric
8706 attributes.
8708 @sp 1
8709 @cartouche
8710 @noindent
8711 @strong{69}.  Any implementation-defined characteristics of the
8712 input-output packages.  See A.7(14).
8713 @end cartouche
8714 @noindent
8715 There are no special implementation defined characteristics for these
8716 packages.
8718 @sp 1
8719 @cartouche
8720 @noindent
8721 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8722 A.9(10).
8723 @end cartouche
8724 @noindent
8725 All type representations are contiguous, and the @code{Buffer_Size} is
8726 the value of @code{@var{type}'Size} rounded up to the next storage unit
8727 boundary.
8729 @sp 1
8730 @cartouche
8731 @noindent
8732 @strong{71}.  External files for standard input, standard output, and
8733 standard error See A.10(5).
8734 @end cartouche
8735 @noindent
8736 These files are mapped onto the files provided by the C streams
8737 libraries.  See source file @file{i-cstrea.ads} for further details.
8739 @sp 1
8740 @cartouche
8741 @noindent
8742 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8743 A.10.9(36).
8744 @end cartouche
8745 @noindent
8746 If more digits are requested in the output than are represented by the
8747 precision of the value, zeroes are output in the corresponding least
8748 significant digit positions.
8750 @sp 1
8751 @cartouche
8752 @noindent
8753 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8754 @code{Command_Name}.  See A.15(1).
8755 @end cartouche
8756 @noindent
8757 These are mapped onto the @code{argv} and @code{argc} parameters of the
8758 main program in the natural manner.
8760 @sp 1
8761 @cartouche
8762 @noindent
8763 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8764 @end cartouche
8765 @noindent
8766 The following convention names are supported
8768 @table @code
8769 @item  Ada
8771 @item Assembler
8772 Assembly language
8773 @item Asm
8774 Synonym for Assembler
8775 @item Assembly
8776 Synonym for Assembler
8777 @item C
8779 @item C_Pass_By_Copy
8780 Allowed only for record types, like C, but also notes that record
8781 is to be passed by copy rather than reference.
8782 @item COBOL
8783 COBOL
8784 @item C_Plus_Plus (or CPP)
8786 @item Default
8787 Treated the same as C
8788 @item External
8789 Treated the same as C
8790 @item Fortran
8791 Fortran
8792 @item Intrinsic
8793 For support of pragma @code{Import} with convention Intrinsic, see
8794 separate section on Intrinsic Subprograms.
8795 @item Stdcall
8796 Stdcall (used for Windows implementations only).  This convention correspond
8797 to the WINAPI (previously called Pascal convention) C/C++ convention under
8798 Windows.  A function with this convention cleans the stack before exit.
8799 @item DLL
8800 Synonym for Stdcall
8801 @item Win32
8802 Synonym for Stdcall
8803 @item Stubbed
8804 Stubbed is a special convention used to indicate that the body of the
8805 subprogram will be entirely ignored.  Any call to the subprogram
8806 is converted into a raise of the @code{Program_Error} exception.  If a
8807 pragma @code{Import} specifies convention @code{stubbed} then no body need
8808 be present at all.  This convention is useful during development for the
8809 inclusion of subprograms whose body has not yet been written.
8811 @end table
8812 @noindent
8813 In addition, all otherwise unrecognized convention names are also
8814 treated as being synonymous with convention C@.  In all implementations
8815 except for VMS, use of such other names results in a warning.  In VMS
8816 implementations, these names are accepted silently.
8818 @sp 1
8819 @cartouche
8820 @noindent
8821 @strong{75}.  The meaning of link names.  See B.1(36).
8822 @end cartouche
8823 @noindent
8824 Link names are the actual names used by the linker.
8826 @sp 1
8827 @cartouche
8828 @noindent
8829 @strong{76}.  The manner of choosing link names when neither the link
8830 name nor the address of an imported or exported entity is specified.  See
8831 B.1(36).
8832 @end cartouche
8833 @noindent
8834 The default linker name is that which would be assigned by the relevant
8835 external language, interpreting the Ada name as being in all lower case
8836 letters.
8838 @sp 1
8839 @cartouche
8840 @noindent
8841 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8842 @end cartouche
8843 @noindent
8844 The string passed to @code{Linker_Options} is presented uninterpreted as
8845 an argument to the link command, unless it contains ASCII.NUL characters.
8846 NUL characters if they appear act as argument separators, so for example
8848 @smallexample @c ada
8849 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8850 @end smallexample
8852 @noindent
8853 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8854 linker. The order of linker options is preserved for a given unit. The final
8855 list of options passed to the linker is in reverse order of the elaboration
8856 order. For example, linker options for a body always appear before the options
8857 from the corresponding package spec.
8859 @sp 1
8860 @cartouche
8861 @noindent
8862 @strong{78}.  The contents of the visible part of package
8863 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8864 @end cartouche
8865 @noindent
8866 See files with prefix @file{i-} in the distributed library.
8868 @sp 1
8869 @cartouche
8870 @noindent
8871 @strong{79}.  Implementation-defined children of package
8872 @code{Interfaces}.  The contents of the visible part of package
8873 @code{Interfaces}.  See B.2(11).
8874 @end cartouche
8875 @noindent
8876 See files with prefix @file{i-} in the distributed library.
8878 @sp 1
8879 @cartouche
8880 @noindent
8881 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8882 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8883 @code{COBOL_Character}; and the initialization of the variables
8884 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8885 @code{Interfaces.COBOL}.  See B.4(50).
8886 @end cartouche
8887 @noindent
8888 @table @code
8889 @item Floating
8890 Float
8891 @item Long_Floating
8892 (Floating) Long_Float
8893 @item Binary
8894 Integer
8895 @item Long_Binary
8896 Long_Long_Integer
8897 @item Decimal_Element
8898 Character
8899 @item COBOL_Character
8900 Character
8901 @end table
8903 @noindent
8904 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8906 @sp 1
8907 @cartouche
8908 @noindent
8909 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8910 @end cartouche
8911 @noindent
8912 See documentation in file @file{s-maccod.ads} in the distributed library.
8914 @sp 1
8915 @cartouche
8916 @noindent
8917 @strong{82}.  Implementation-defined aspects of access to machine
8918 operations.  See C.1(9).
8919 @end cartouche
8920 @noindent
8921 See documentation in file @file{s-maccod.ads} in the distributed library.
8923 @sp 1
8924 @cartouche
8925 @noindent
8926 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8927 @end cartouche
8928 @noindent
8929 Interrupts are mapped to signals or conditions as appropriate.  See
8930 definition of unit
8931 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8932 on the interrupts supported on a particular target.
8934 @sp 1
8935 @cartouche
8936 @noindent
8937 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8938 C.4(13).
8939 @end cartouche
8940 @noindent
8941 GNAT does not permit a partition to be restarted without reloading,
8942 except under control of the debugger.
8944 @sp 1
8945 @cartouche
8946 @noindent
8947 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8948 @end cartouche
8949 @noindent
8950 Pragma @code{Discard_Names} causes names of enumeration literals to
8951 be suppressed.  In the presence of this pragma, the Image attribute
8952 provides the image of the Pos of the literal, and Value accepts
8953 Pos values.
8955 @sp 1
8956 @cartouche
8957 @noindent
8958 @strong{86}.  The result of the @code{Task_Identification.Image}
8959 attribute.  See C.7.1(7).
8960 @end cartouche
8961 @noindent
8962 The result of this attribute is a string that identifies
8963 the object or component that denotes a given task. If a variable @code{Var}
8964 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
8965 where the suffix
8966 is the hexadecimal representation of the virtual address of the corresponding
8967 task control block. If the variable is an array of tasks, the image of each
8968 task will have the form of an indexed component indicating the position of a
8969 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
8970 component of a record, the image of the task will have the form of a selected
8971 component. These rules are fully recursive, so that the image of a task that
8972 is a subcomponent of a composite object corresponds to the expression that
8973 designates this task.
8974 @noindent
8975 If a task is created by an allocator, its image depends on the context. If the
8976 allocator is part of an object declaration, the rules described above are used
8977 to construct its image, and this image is not affected by subsequent
8978 assignments. If the allocator appears within an expression, the image
8979 includes only the name of the task type.
8980 @noindent
8981 If the configuration pragma Discard_Names is present, or if the restriction
8982 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8983 the numeric suffix, that is to say the hexadecimal representation of the
8984 virtual address of the control block of the task.
8985 @sp 1
8986 @cartouche
8987 @noindent
8988 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8989 or interrupt handler.  See C.7.1(17).
8990 @end cartouche
8991 @noindent
8992 Protected entries or interrupt handlers can be executed by any
8993 convenient thread, so the value of @code{Current_Task} is undefined.
8995 @sp 1
8996 @cartouche
8997 @noindent
8998 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8999 body or interrupt handler.  See C.7.1(19).
9000 @end cartouche
9001 @noindent
9002 The effect of calling @code{Current_Task} from an entry body or
9003 interrupt handler is to return the identification of the task currently
9004 executing the code.
9006 @sp 1
9007 @cartouche
9008 @noindent
9009 @strong{89}.  Implementation-defined aspects of
9010 @code{Task_Attributes}.  See C.7.2(19).
9011 @end cartouche
9012 @noindent
9013 There are no implementation-defined aspects of @code{Task_Attributes}.
9015 @sp 1
9016 @cartouche
9017 @noindent
9018 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9019 @end cartouche
9020 @noindent
9021 The metrics information for GNAT depends on the performance of the
9022 underlying operating system.  The sources of the run-time for tasking
9023 implementation, together with the output from @option{-gnatG} can be
9024 used to determine the exact sequence of operating systems calls made
9025 to implement various tasking constructs.  Together with appropriate
9026 information on the performance of the underlying operating system,
9027 on the exact target in use, this information can be used to determine
9028 the required metrics.
9030 @sp 1
9031 @cartouche
9032 @noindent
9033 @strong{91}.  The declarations of @code{Any_Priority} and
9034 @code{Priority}.  See D.1(11).
9035 @end cartouche
9036 @noindent
9037 See declarations in file @file{system.ads}.
9039 @sp 1
9040 @cartouche
9041 @noindent
9042 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9043 @end cartouche
9044 @noindent
9045 There are no implementation-defined execution resources.
9047 @sp 1
9048 @cartouche
9049 @noindent
9050 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9051 access to a protected object keeps its processor busy.  See D.2.1(3).
9052 @end cartouche
9053 @noindent
9054 On a multi-processor, a task that is waiting for access to a protected
9055 object does not keep its processor busy.
9057 @sp 1
9058 @cartouche
9059 @noindent
9060 @strong{94}.  The affect of implementation defined execution resources
9061 on task dispatching.  See D.2.1(9).
9062 @end cartouche
9063 @noindent
9064 @c SGI info
9065 @ignore
9066 Tasks map to IRIX threads, and the dispatching policy is as defined by
9067 the IRIX implementation of threads.
9068 @end ignore
9069 Tasks map to threads in the threads package used by GNAT@.  Where possible
9070 and appropriate, these threads correspond to native threads of the
9071 underlying operating system.
9073 @sp 1
9074 @cartouche
9075 @noindent
9076 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9077 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9078 @end cartouche
9079 @noindent
9080 There are no implementation-defined policy-identifiers allowed in this
9081 pragma.
9083 @sp 1
9084 @cartouche
9085 @noindent
9086 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9087 D.2.2(16).
9088 @end cartouche
9089 @noindent
9090 Execution of a task cannot be preempted by the implementation processing
9091 of delay expirations for lower priority tasks.
9093 @sp 1
9094 @cartouche
9095 @noindent
9096 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9097 @end cartouche
9098 @noindent
9099 @c SGI info:
9100 @ignore
9101 Tasks map to IRIX threads, and the dispatching policy is as defined by
9102 the IRIX implementation of threads.
9103 @end ignore
9104 The policy is the same as that of the underlying threads implementation.
9106 @sp 1
9107 @cartouche
9108 @noindent
9109 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9110 in a pragma @code{Locking_Policy}.  See D.3(4).
9111 @end cartouche
9112 @noindent
9113 The only implementation defined policy permitted in GNAT is
9114 @code{Inheritance_Locking}.  On targets that support this policy, locking
9115 is implemented by inheritance, i.e.@: the task owning the lock operates
9116 at a priority equal to the highest priority of any task currently
9117 requesting the lock.
9119 @sp 1
9120 @cartouche
9121 @noindent
9122 @strong{99}.  Default ceiling priorities.  See D.3(10).
9123 @end cartouche
9124 @noindent
9125 The ceiling priority of protected objects of the type
9126 @code{System.Interrupt_Priority'Last} as described in the Ada
9127 Reference Manual D.3(10),
9129 @sp 1
9130 @cartouche
9131 @noindent
9132 @strong{100}.  The ceiling of any protected object used internally by
9133 the implementation.  See D.3(16).
9134 @end cartouche
9135 @noindent
9136 The ceiling priority of internal protected objects is
9137 @code{System.Priority'Last}.
9139 @sp 1
9140 @cartouche
9141 @noindent
9142 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9143 @end cartouche
9144 @noindent
9145 There are no implementation-defined queuing policies.
9147 @sp 1
9148 @cartouche
9149 @noindent
9150 @strong{102}.  On a multiprocessor, any conditions that cause the
9151 completion of an aborted construct to be delayed later than what is
9152 specified for a single processor.  See D.6(3).
9153 @end cartouche
9154 @noindent
9155 The semantics for abort on a multi-processor is the same as on a single
9156 processor, there are no further delays.
9158 @sp 1
9159 @cartouche
9160 @noindent
9161 @strong{103}.  Any operations that implicitly require heap storage
9162 allocation.  See D.7(8).
9163 @end cartouche
9164 @noindent
9165 The only operation that implicitly requires heap storage allocation is
9166 task creation.
9168 @sp 1
9169 @cartouche
9170 @noindent
9171 @strong{104}.  Implementation-defined aspects of pragma
9172 @code{Restrictions}.  See D.7(20).
9173 @end cartouche
9174 @noindent
9175 There are no such implementation-defined aspects.
9177 @sp 1
9178 @cartouche
9179 @noindent
9180 @strong{105}.  Implementation-defined aspects of package
9181 @code{Real_Time}.  See D.8(17).
9182 @end cartouche
9183 @noindent
9184 There are no implementation defined aspects of package @code{Real_Time}.
9186 @sp 1
9187 @cartouche
9188 @noindent
9189 @strong{106}.  Implementation-defined aspects of
9190 @code{delay_statements}.  See D.9(8).
9191 @end cartouche
9192 @noindent
9193 Any difference greater than one microsecond will cause the task to be
9194 delayed (see D.9(7)).
9196 @sp 1
9197 @cartouche
9198 @noindent
9199 @strong{107}.  The upper bound on the duration of interrupt blocking
9200 caused by the implementation.  See D.12(5).
9201 @end cartouche
9202 @noindent
9203 The upper bound is determined by the underlying operating system.  In
9204 no cases is it more than 10 milliseconds.
9206 @sp 1
9207 @cartouche
9208 @noindent
9209 @strong{108}.  The means for creating and executing distributed
9210 programs.  See E(5).
9211 @end cartouche
9212 @noindent
9213 The GLADE package provides a utility GNATDIST for creating and executing
9214 distributed programs.  See the GLADE reference manual for further details.
9216 @sp 1
9217 @cartouche
9218 @noindent
9219 @strong{109}.  Any events that can result in a partition becoming
9220 inaccessible.  See E.1(7).
9221 @end cartouche
9222 @noindent
9223 See the GLADE reference manual for full details on such events.
9225 @sp 1
9226 @cartouche
9227 @noindent
9228 @strong{110}.  The scheduling policies, treatment of priorities, and
9229 management of shared resources between partitions in certain cases.  See
9230 E.1(11).
9231 @end cartouche
9232 @noindent
9233 See the GLADE reference manual for full details on these aspects of
9234 multi-partition execution.
9236 @sp 1
9237 @cartouche
9238 @noindent
9239 @strong{111}.  Events that cause the version of a compilation unit to
9240 change.  See E.3(5).
9241 @end cartouche
9242 @noindent
9243 Editing the source file of a compilation unit, or the source files of
9244 any units on which it is dependent in a significant way cause the version
9245 to change.  No other actions cause the version number to change.  All changes
9246 are significant except those which affect only layout, capitalization or
9247 comments.
9249 @sp 1
9250 @cartouche
9251 @noindent
9252 @strong{112}.  Whether the execution of the remote subprogram is
9253 immediately aborted as a result of cancellation.  See E.4(13).
9254 @end cartouche
9255 @noindent
9256 See the GLADE reference manual for details on the effect of abort in
9257 a distributed application.
9259 @sp 1
9260 @cartouche
9261 @noindent
9262 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9263 @end cartouche
9264 @noindent
9265 See the GLADE reference manual for a full description of all implementation
9266 defined aspects of the PCS@.
9268 @sp 1
9269 @cartouche
9270 @noindent
9271 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9272 E.5(26).
9273 @end cartouche
9274 @noindent
9275 See the GLADE reference manual for a full description of all
9276 implementation defined interfaces.
9278 @sp 1
9279 @cartouche
9280 @noindent
9281 @strong{115}.  The values of named numbers in the package
9282 @code{Decimal}.  See F.2(7).
9283 @end cartouche
9284 @noindent
9285 @table @code
9286 @item Max_Scale
9288 @item Min_Scale
9290 @item Min_Delta
9291 1.0E-18
9292 @item Max_Delta
9293 1.0E+18
9294 @item Max_Decimal_Digits
9296 @end table
9298 @sp 1
9299 @cartouche
9300 @noindent
9301 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9302 @code{Text_IO.Editing}.  See F.3.3(16).
9303 @end cartouche
9304 @noindent
9307 @sp 1
9308 @cartouche
9309 @noindent
9310 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9311 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9312 @end cartouche
9313 @noindent
9316 @sp 1
9317 @cartouche
9318 @noindent
9319 @strong{118}.  The accuracy actually achieved by the complex elementary
9320 functions and by other complex arithmetic operations.  See G.1(1).
9321 @end cartouche
9322 @noindent
9323 Standard library functions are used for the complex arithmetic
9324 operations.  Only fast math mode is currently supported.
9326 @sp 1
9327 @cartouche
9328 @noindent
9329 @strong{119}.  The sign of a zero result (or a component thereof) from
9330 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9331 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9332 @end cartouche
9333 @noindent
9334 The signs of zero values are as recommended by the relevant
9335 implementation advice.
9337 @sp 1
9338 @cartouche
9339 @noindent
9340 @strong{120}.  The sign of a zero result (or a component thereof) from
9341 any operator or function in
9342 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9343 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9344 @end cartouche
9345 @noindent
9346 The signs of zero values are as recommended by the relevant
9347 implementation advice.
9349 @sp 1
9350 @cartouche
9351 @noindent
9352 @strong{121}.  Whether the strict mode or the relaxed mode is the
9353 default.  See G.2(2).
9354 @end cartouche
9355 @noindent
9356 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9357 provides a highly efficient implementation of strict mode.
9359 @sp 1
9360 @cartouche
9361 @noindent
9362 @strong{122}.  The result interval in certain cases of fixed-to-float
9363 conversion.  See G.2.1(10).
9364 @end cartouche
9365 @noindent
9366 For cases where the result interval is implementation dependent, the
9367 accuracy is that provided by performing all operations in 64-bit IEEE
9368 floating-point format.
9370 @sp 1
9371 @cartouche
9372 @noindent
9373 @strong{123}.  The result of a floating point arithmetic operation in
9374 overflow situations, when the @code{Machine_Overflows} attribute of the
9375 result type is @code{False}.  See G.2.1(13).
9376 @end cartouche
9377 @noindent
9378 Infinite and NaN values are produced as dictated by the IEEE
9379 floating-point standard.
9381 Note that on machines that are not fully compliant with the IEEE
9382 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9383 must be used for achieving IEEE confirming behavior (although at the cost
9384 of a significant performance penalty), so infinite and NaN values are
9385 properly generated.
9387 @sp 1
9388 @cartouche
9389 @noindent
9390 @strong{124}.  The result interval for division (or exponentiation by a
9391 negative exponent), when the floating point hardware implements division
9392 as multiplication by a reciprocal.  See G.2.1(16).
9393 @end cartouche
9394 @noindent
9395 Not relevant, division is IEEE exact.
9397 @sp 1
9398 @cartouche
9399 @noindent
9400 @strong{125}.  The definition of close result set, which determines the
9401 accuracy of certain fixed point multiplications and divisions.  See
9402 G.2.3(5).
9403 @end cartouche
9404 @noindent
9405 Operations in the close result set are performed using IEEE long format
9406 floating-point arithmetic.  The input operands are converted to
9407 floating-point, the operation is done in floating-point, and the result
9408 is converted to the target type.
9410 @sp 1
9411 @cartouche
9412 @noindent
9413 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9414 point multiplication or division for which the result shall be in the
9415 perfect result set.  See G.2.3(22).
9416 @end cartouche
9417 @noindent
9418 The result is only defined to be in the perfect result set if the result
9419 can be computed by a single scaling operation involving a scale factor
9420 representable in 64-bits.
9422 @sp 1
9423 @cartouche
9424 @noindent
9425 @strong{127}.  The result of a fixed point arithmetic operation in
9426 overflow situations, when the @code{Machine_Overflows} attribute of the
9427 result type is @code{False}.  See G.2.3(27).
9428 @end cartouche
9429 @noindent
9430 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9431 types.
9433 @sp 1
9434 @cartouche
9435 @noindent
9436 @strong{128}.  The result of an elementary function reference in
9437 overflow situations, when the @code{Machine_Overflows} attribute of the
9438 result type is @code{False}.  See G.2.4(4).
9439 @end cartouche
9440 @noindent
9441 IEEE infinite and Nan values are produced as appropriate.
9443 @sp 1
9444 @cartouche
9445 @noindent
9446 @strong{129}.  The value of the angle threshold, within which certain
9447 elementary functions, complex arithmetic operations, and complex
9448 elementary functions yield results conforming to a maximum relative
9449 error bound.  See G.2.4(10).
9450 @end cartouche
9451 @noindent
9452 Information on this subject is not yet available.
9454 @sp 1
9455 @cartouche
9456 @noindent
9457 @strong{130}.  The accuracy of certain elementary functions for
9458 parameters beyond the angle threshold.  See G.2.4(10).
9459 @end cartouche
9460 @noindent
9461 Information on this subject is not yet available.
9463 @sp 1
9464 @cartouche
9465 @noindent
9466 @strong{131}.  The result of a complex arithmetic operation or complex
9467 elementary function reference in overflow situations, when the
9468 @code{Machine_Overflows} attribute of the corresponding real type is
9469 @code{False}.  See G.2.6(5).
9470 @end cartouche
9471 @noindent
9472 IEEE infinite and Nan values are produced as appropriate.
9474 @sp 1
9475 @cartouche
9476 @noindent
9477 @strong{132}.  The accuracy of certain complex arithmetic operations and
9478 certain complex elementary functions for parameters (or components
9479 thereof) beyond the angle threshold.  See G.2.6(8).
9480 @end cartouche
9481 @noindent
9482 Information on those subjects is not yet available.
9484 @sp 1
9485 @cartouche
9486 @noindent
9487 @strong{133}.  Information regarding bounded errors and erroneous
9488 execution.  See H.2(1).
9489 @end cartouche
9490 @noindent
9491 Information on this subject is not yet available.
9493 @sp 1
9494 @cartouche
9495 @noindent
9496 @strong{134}.  Implementation-defined aspects of pragma
9497 @code{Inspection_Point}.  See H.3.2(8).
9498 @end cartouche
9499 @noindent
9500 Pragma @code{Inspection_Point} ensures that the variable is live and can
9501 be examined by the debugger at the inspection point.
9503 @sp 1
9504 @cartouche
9505 @noindent
9506 @strong{135}.  Implementation-defined aspects of pragma
9507 @code{Restrictions}.  See H.4(25).
9508 @end cartouche
9509 @noindent
9510 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9511 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9512 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9514 @sp 1
9515 @cartouche
9516 @noindent
9517 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9518 H.4(27).
9519 @end cartouche
9520 @noindent
9521 There are no restrictions on pragma @code{Restrictions}.
9523 @node Intrinsic Subprograms
9524 @chapter Intrinsic Subprograms
9525 @cindex Intrinsic Subprograms
9527 @menu
9528 * Intrinsic Operators::
9529 * Enclosing_Entity::
9530 * Exception_Information::
9531 * Exception_Message::
9532 * Exception_Name::
9533 * File::
9534 * Line::
9535 * Rotate_Left::
9536 * Rotate_Right::
9537 * Shift_Left::
9538 * Shift_Right::
9539 * Shift_Right_Arithmetic::
9540 * Source_Location::
9541 @end menu
9543 @noindent
9544 GNAT allows a user application program to write the declaration:
9546 @smallexample @c ada
9547    pragma Import (Intrinsic, name);
9548 @end smallexample
9550 @noindent
9551 providing that the name corresponds to one of the implemented intrinsic
9552 subprograms in GNAT, and that the parameter profile of the referenced
9553 subprogram meets the requirements.  This chapter describes the set of
9554 implemented intrinsic subprograms, and the requirements on parameter profiles.
9555 Note that no body is supplied; as with other uses of pragma Import, the
9556 body is supplied elsewhere (in this case by the compiler itself).  Note
9557 that any use of this feature is potentially non-portable, since the
9558 Ada standard does not require Ada compilers to implement this feature.
9560 @node Intrinsic Operators
9561 @section Intrinsic Operators
9562 @cindex Intrinsic operator
9564 @noindent
9565 All the predefined numeric operators in package Standard
9566 in @code{pragma Import (Intrinsic,..)}
9567 declarations.  In the binary operator case, the operands must have the same
9568 size.  The operand or operands must also be appropriate for
9569 the operator.  For example, for addition, the operands must
9570 both be floating-point or both be fixed-point, and the
9571 right operand for @code{"**"} must have a root type of
9572 @code{Standard.Integer'Base}.
9573 You can use an intrinsic operator declaration as in the following example:
9575 @smallexample @c ada
9576    type Int1 is new Integer;
9577    type Int2 is new Integer;
9579    function "+" (X1 : Int1; X2 : Int2) return Int1;
9580    function "+" (X1 : Int1; X2 : Int2) return Int2;
9581    pragma Import (Intrinsic, "+");
9582 @end smallexample
9584 @noindent
9585 This declaration would permit ``mixed mode'' arithmetic on items
9586 of the differing types @code{Int1} and @code{Int2}.
9587 It is also possible to specify such operators for private types, if the
9588 full views are appropriate arithmetic types.
9590 @node Enclosing_Entity
9591 @section Enclosing_Entity
9592 @cindex Enclosing_Entity
9593 @noindent
9594 This intrinsic subprogram is used in the implementation of the
9595 library routine @code{GNAT.Source_Info}.  The only useful use of the
9596 intrinsic import in this case is the one in this unit, so an
9597 application program should simply call the function
9598 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9599 the current subprogram, package, task, entry, or protected subprogram.
9601 @node Exception_Information
9602 @section Exception_Information
9603 @cindex Exception_Information'
9604 @noindent
9605 This intrinsic subprogram is used in the implementation of the
9606 library routine @code{GNAT.Current_Exception}.  The only useful
9607 use of the intrinsic import in this case is the one in this unit,
9608 so an application program should simply call the function
9609 @code{GNAT.Current_Exception.Exception_Information} to obtain
9610 the exception information associated with the current exception.
9612 @node Exception_Message
9613 @section Exception_Message
9614 @cindex Exception_Message
9615 @noindent
9616 This intrinsic subprogram is used in the implementation of the
9617 library routine @code{GNAT.Current_Exception}.  The only useful
9618 use of the intrinsic import in this case is the one in this unit,
9619 so an application program should simply call the function
9620 @code{GNAT.Current_Exception.Exception_Message} to obtain
9621 the message associated with the current exception.
9623 @node Exception_Name
9624 @section Exception_Name
9625 @cindex Exception_Name
9626 @noindent
9627 This intrinsic subprogram is used in the implementation of the
9628 library routine @code{GNAT.Current_Exception}.  The only useful
9629 use of the intrinsic import in this case is the one in this unit,
9630 so an application program should simply call the function
9631 @code{GNAT.Current_Exception.Exception_Name} to obtain
9632 the name of the current exception.
9634 @node File
9635 @section File
9636 @cindex File
9637 @noindent
9638 This intrinsic subprogram is used in the implementation of the
9639 library routine @code{GNAT.Source_Info}.  The only useful use of the
9640 intrinsic import in this case is the one in this unit, so an
9641 application program should simply call the function
9642 @code{GNAT.Source_Info.File} to obtain the name of the current
9643 file.
9645 @node Line
9646 @section Line
9647 @cindex Line
9648 @noindent
9649 This intrinsic subprogram is used in the implementation of the
9650 library routine @code{GNAT.Source_Info}.  The only useful use of the
9651 intrinsic import in this case is the one in this unit, so an
9652 application program should simply call the function
9653 @code{GNAT.Source_Info.Line} to obtain the number of the current
9654 source line.
9656 @node Rotate_Left
9657 @section Rotate_Left
9658 @cindex Rotate_Left
9659 @noindent
9660 In standard Ada, the @code{Rotate_Left} function is available only
9661 for the predefined modular types in package @code{Interfaces}.  However, in
9662 GNAT it is possible to define a Rotate_Left function for a user
9663 defined modular type or any signed integer type as in this example:
9665 @smallexample @c ada
9666    function Shift_Left
9667      (Value  : My_Modular_Type;
9668       Amount : Natural)
9669       return   My_Modular_Type;
9670 @end smallexample
9672 @noindent
9673 The requirements are that the profile be exactly as in the example
9674 above.  The only modifications allowed are in the formal parameter
9675 names, and in the type of @code{Value} and the return type, which
9676 must be the same, and must be either a signed integer type, or
9677 a modular integer type with a binary modulus, and the size must
9678 be 8.  16, 32 or 64 bits.
9680 @node Rotate_Right
9681 @section Rotate_Right
9682 @cindex Rotate_Right
9683 @noindent
9684 A @code{Rotate_Right} function can be defined for any user defined
9685 binary modular integer type, or signed integer type, as described
9686 above for @code{Rotate_Left}.
9688 @node Shift_Left
9689 @section Shift_Left
9690 @cindex Shift_Left
9691 @noindent
9692 A @code{Shift_Left} function can be defined for any user defined
9693 binary modular integer type, or signed integer type, as described
9694 above for @code{Rotate_Left}.
9696 @node Shift_Right
9697 @section Shift_Right
9698 @cindex Shift_Right
9699 @noindent
9700 A @code{Shift_Right} function can be defined for any user defined
9701 binary modular integer type, or signed integer type, as described
9702 above for @code{Rotate_Left}.
9704 @node Shift_Right_Arithmetic
9705 @section Shift_Right_Arithmetic
9706 @cindex Shift_Right_Arithmetic
9707 @noindent
9708 A @code{Shift_Right_Arithmetic} function can be defined for any user
9709 defined binary modular integer type, or signed integer type, as described
9710 above for @code{Rotate_Left}.
9712 @node Source_Location
9713 @section Source_Location
9714 @cindex Source_Location
9715 @noindent
9716 This intrinsic subprogram is used in the implementation of the
9717 library routine @code{GNAT.Source_Info}.  The only useful use of the
9718 intrinsic import in this case is the one in this unit, so an
9719 application program should simply call the function
9720 @code{GNAT.Source_Info.Source_Location} to obtain the current
9721 source file location.
9723 @node Representation Clauses and Pragmas
9724 @chapter Representation Clauses and Pragmas
9725 @cindex Representation Clauses
9727 @menu
9728 * Alignment Clauses::
9729 * Size Clauses::
9730 * Storage_Size Clauses::
9731 * Size of Variant Record Objects::
9732 * Biased Representation ::
9733 * Value_Size and Object_Size Clauses::
9734 * Component_Size Clauses::
9735 * Bit_Order Clauses::
9736 * Effect of Bit_Order on Byte Ordering::
9737 * Pragma Pack for Arrays::
9738 * Pragma Pack for Records::
9739 * Record Representation Clauses::
9740 * Enumeration Clauses::
9741 * Address Clauses::
9742 * Effect of Convention on Representation::
9743 * Determining the Representations chosen by GNAT::
9744 @end menu
9746 @noindent
9747 @cindex Representation Clause
9748 @cindex Representation Pragma
9749 @cindex Pragma, representation
9750 This section describes the representation clauses accepted by GNAT, and
9751 their effect on the representation of corresponding data objects.
9753 GNAT fully implements Annex C (Systems Programming).  This means that all
9754 the implementation advice sections in chapter 13 are fully implemented.
9755 However, these sections only require a minimal level of support for
9756 representation clauses.  GNAT provides much more extensive capabilities,
9757 and this section describes the additional capabilities provided.
9759 @node Alignment Clauses
9760 @section Alignment Clauses
9761 @cindex Alignment Clause
9763 @noindent
9764 GNAT requires that all alignment clauses specify a power of 2, and all
9765 default alignments are always a power of 2.  The default alignment
9766 values are as follows:
9768 @itemize @bullet
9769 @item @emph{Primitive Types}.
9770 For primitive types, the alignment is the minimum of the actual size of
9771 objects of the type divided by @code{Storage_Unit},
9772 and the maximum alignment supported by the target.
9773 (This maximum alignment is given by the GNAT-specific attribute
9774 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9775 @cindex @code{Maximum_Alignment} attribute
9776 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9777 default alignment will be 8 on any target that supports alignments
9778 this large, but on some targets, the maximum alignment may be smaller
9779 than 8, in which case objects of type @code{Long_Float} will be maximally
9780 aligned.
9782 @item @emph{Arrays}.
9783 For arrays, the alignment is equal to the alignment of the component type
9784 for the normal case where no packing or component size is given.  If the
9785 array is packed, and the packing is effective (see separate section on
9786 packed arrays), then the alignment will be one for long packed arrays,
9787 or arrays whose length is not known at compile time.  For short packed
9788 arrays, which are handled internally as modular types, the alignment
9789 will be as described for primitive types, e.g.@: a packed array of length
9790 31 bits will have an object size of four bytes, and an alignment of 4.
9792 @item @emph{Records}.
9793 For the normal non-packed case, the alignment of a record is equal to
9794 the maximum alignment of any of its components.  For tagged records, this
9795 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9796 is used and all components are packable (see separate section on pragma
9797 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9798 record makes it profitable to increase it.
9800 A special case is when:
9801 @itemize @bullet
9802 @item
9803 the size of the record is given explicitly, or a
9804 full record representation clause is given, and
9805 @item
9806 the size of the record is 2, 4, or 8 bytes.
9807 @end itemize
9808 @noindent
9809 In this case, an alignment is chosen to match the
9810 size of the record. For example, if we have:
9812 @smallexample @c ada
9813    type Small is record
9814       A, B : Character;
9815    end record;
9816    for Small'Size use 16;
9817 @end smallexample
9819 @noindent
9820 then the default alignment of the record type @code{Small} is 2, not 1. This
9821 leads to more efficient code when the record is treated as a unit, and also
9822 allows the type to specified as @code{Atomic} on architectures requiring
9823 strict alignment.
9825 @end itemize
9827 @noindent
9828 An alignment clause may specify a larger alignment than the default value
9829 up to some maximum value dependent on the target (obtainable by using the
9830 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9831 a smaller alignment than the default value for enumeration, integer and
9832 fixed point types, as well as for record types, for example
9834 @smallexample @c ada
9835   type V is record
9836      A : Integer;
9837   end record;
9839   for V'alignment use 1;
9840 @end smallexample
9842 @noindent
9843 @cindex Alignment, default
9844 The default alignment for the type @code{V} is 4, as a result of the
9845 Integer field in the record, but it is permissible, as shown, to
9846 override the default alignment of the record with a smaller value.
9848 @node Size Clauses
9849 @section Size Clauses
9850 @cindex Size Clause
9852 @noindent
9853 The default size for a type @code{T} is obtainable through the
9854 language-defined attribute @code{T'Size} and also through the
9855 equivalent GNAT-defined attribute @code{T'Value_Size}.
9856 For objects of type @code{T}, GNAT will generally increase the type size
9857 so that the object size (obtainable through the GNAT-defined attribute
9858 @code{T'Object_Size})
9859 is a multiple of @code{T'Alignment * Storage_Unit}.
9860 For example
9862 @smallexample @c ada
9863    type Smallint is range 1 .. 6;
9865    type Rec is record
9866       Y1 : integer;
9867       Y2 : boolean;
9868    end record;
9869 @end smallexample
9871 @noindent
9872 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9873 as specified by the RM rules,
9874 but objects of this type will have a size of 8
9875 (@code{Smallint'Object_Size} = 8),
9876 since objects by default occupy an integral number
9877 of storage units.  On some targets, notably older
9878 versions of the Digital Alpha, the size of stand
9879 alone objects of this type may be 32, reflecting
9880 the inability of the hardware to do byte load/stores.
9882 Similarly, the size of type @code{Rec} is 40 bits
9883 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9884 the alignment is 4, so objects of this type will have
9885 their size increased to 64 bits so that it is a multiple
9886 of the alignment (in bits).  This decision is
9887 in accordance with the specific Implementation Advice in RM 13.3(43):
9889 @quotation
9890 A @code{Size} clause should be supported for an object if the specified
9891 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9892 to a size in storage elements that is a multiple of the object's
9893 @code{Alignment} (if the @code{Alignment} is nonzero).
9894 @end quotation
9896 @noindent
9897 An explicit size clause may be used to override the default size by
9898 increasing it.  For example, if we have:
9900 @smallexample @c ada
9901    type My_Boolean is new Boolean;
9902    for My_Boolean'Size use 32;
9903 @end smallexample
9905 @noindent
9906 then values of this type will always be 32 bits long.  In the case of
9907 discrete types, the size can be increased up to 64 bits, with the effect
9908 that the entire specified field is used to hold the value, sign- or
9909 zero-extended as appropriate.  If more than 64 bits is specified, then
9910 padding space is allocated after the value, and a warning is issued that
9911 there are unused bits.
9913 Similarly the size of records and arrays may be increased, and the effect
9914 is to add padding bits after the value.  This also causes a warning message
9915 to be generated.
9917 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9918 Size in bits, this corresponds to an object of size 256 megabytes (minus
9919 one).  This limitation is true on all targets.  The reason for this
9920 limitation is that it improves the quality of the code in many cases
9921 if it is known that a Size value can be accommodated in an object of
9922 type Integer.
9924 @node Storage_Size Clauses
9925 @section Storage_Size Clauses
9926 @cindex Storage_Size Clause
9928 @noindent
9929 For tasks, the @code{Storage_Size} clause specifies the amount of space
9930 to be allocated for the task stack.  This cannot be extended, and if the
9931 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9932 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9933 or a @code{Storage_Size} pragma in the task definition to set the
9934 appropriate required size.  A useful technique is to include in every
9935 task definition a pragma of the form:
9937 @smallexample @c ada
9938    pragma Storage_Size (Default_Stack_Size);
9939 @end smallexample
9941 @noindent
9942 Then @code{Default_Stack_Size} can be defined in a global package, and
9943 modified as required. Any tasks requiring stack sizes different from the
9944 default can have an appropriate alternative reference in the pragma.
9946 You can also use the @option{-d} binder switch to modify the default stack
9947 size.
9949 For access types, the @code{Storage_Size} clause specifies the maximum
9950 space available for allocation of objects of the type.  If this space is
9951 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9952 In the case where the access type is declared local to a subprogram, the
9953 use of a @code{Storage_Size} clause triggers automatic use of a special
9954 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9955 space for the pool is automatically reclaimed on exit from the scope in
9956 which the type is declared.
9958 A special case recognized by the compiler is the specification of a
9959 @code{Storage_Size} of zero for an access type.  This means that no
9960 items can be allocated from the pool, and this is recognized at compile
9961 time, and all the overhead normally associated with maintaining a fixed
9962 size storage pool is eliminated.  Consider the following example:
9964 @smallexample @c ada
9965    procedure p is
9966       type R is array (Natural) of Character;
9967       type P is access all R;
9968       for P'Storage_Size use 0;
9969       --  Above access type intended only for interfacing purposes
9971       y : P;
9973       procedure g (m : P);
9974       pragma Import (C, g);
9976       --  @dots{}
9978    begin
9979       --  @dots{}
9980       y := new R;
9981    end;
9982 @end smallexample
9984 @noindent
9985 As indicated in this example, these dummy storage pools are often useful in
9986 connection with interfacing where no object will ever be allocated.  If you
9987 compile the above example, you get the warning:
9989 @smallexample
9990    p.adb:16:09: warning: allocation from empty storage pool
9991    p.adb:16:09: warning: Storage_Error will be raised at run time
9992 @end smallexample
9994 @noindent
9995 Of course in practice, there will not be any explicit allocators in the
9996 case of such an access declaration.
9998 @node Size of Variant Record Objects
9999 @section Size of Variant Record Objects
10000 @cindex Size, variant record objects
10001 @cindex Variant record objects, size
10003 @noindent
10004 In the case of variant record objects, there is a question whether Size gives
10005 information about a particular variant, or the maximum size required
10006 for any variant.  Consider the following program
10008 @smallexample @c ada
10009 with Text_IO; use Text_IO;
10010 procedure q is
10011    type R1 (A : Boolean := False) is record
10012      case A is
10013        when True  => X : Character;
10014        when False => null;
10015      end case;
10016    end record;
10018    V1 : R1 (False);
10019    V2 : R1;
10021 begin
10022    Put_Line (Integer'Image (V1'Size));
10023    Put_Line (Integer'Image (V2'Size));
10024 end q;
10025 @end smallexample
10027 @noindent
10028 Here we are dealing with a variant record, where the True variant
10029 requires 16 bits, and the False variant requires 8 bits.
10030 In the above example, both V1 and V2 contain the False variant,
10031 which is only 8 bits long.  However, the result of running the
10032 program is:
10034 @smallexample
10037 @end smallexample
10039 @noindent
10040 The reason for the difference here is that the discriminant value of
10041 V1 is fixed, and will always be False.  It is not possible to assign
10042 a True variant value to V1, therefore 8 bits is sufficient.  On the
10043 other hand, in the case of V2, the initial discriminant value is
10044 False (from the default), but it is possible to assign a True
10045 variant value to V2, therefore 16 bits must be allocated for V2
10046 in the general case, even fewer bits may be needed at any particular
10047 point during the program execution.
10049 As can be seen from the output of this program, the @code{'Size}
10050 attribute applied to such an object in GNAT gives the actual allocated
10051 size of the variable, which is the largest size of any of the variants.
10052 The Ada Reference Manual is not completely clear on what choice should
10053 be made here, but the GNAT behavior seems most consistent with the
10054 language in the RM@.
10056 In some cases, it may be desirable to obtain the size of the current
10057 variant, rather than the size of the largest variant.  This can be
10058 achieved in GNAT by making use of the fact that in the case of a
10059 subprogram parameter, GNAT does indeed return the size of the current
10060 variant (because a subprogram has no way of knowing how much space
10061 is actually allocated for the actual).
10063 Consider the following modified version of the above program:
10065 @smallexample @c ada
10066 with Text_IO; use Text_IO;
10067 procedure q is
10068    type R1 (A : Boolean := False) is record
10069      case A is
10070        when True  => X : Character;
10071        when False => null;
10072      end case;
10073    end record;
10075    V2 : R1;
10077    function Size (V : R1) return Integer is
10078    begin
10079       return V'Size;
10080    end Size;
10082 begin
10083    Put_Line (Integer'Image (V2'Size));
10084    Put_Line (Integer'IMage (Size (V2)));
10085    V2 := (True, 'x');
10086    Put_Line (Integer'Image (V2'Size));
10087    Put_Line (Integer'IMage (Size (V2)));
10088 end q;
10089 @end smallexample
10091 @noindent
10092 The output from this program is
10094 @smallexample
10099 @end smallexample
10101 @noindent
10102 Here we see that while the @code{'Size} attribute always returns
10103 the maximum size, regardless of the current variant value, the
10104 @code{Size} function does indeed return the size of the current
10105 variant value.
10107 @node Biased Representation
10108 @section Biased Representation
10109 @cindex Size for biased representation
10110 @cindex Biased representation
10112 @noindent
10113 In the case of scalars with a range starting at other than zero, it is
10114 possible in some cases to specify a size smaller than the default minimum
10115 value, and in such cases, GNAT uses an unsigned biased representation,
10116 in which zero is used to represent the lower bound, and successive values
10117 represent successive values of the type.
10119 For example, suppose we have the declaration:
10121 @smallexample @c ada
10122    type Small is range -7 .. -4;
10123    for Small'Size use 2;
10124 @end smallexample
10126 @noindent
10127 Although the default size of type @code{Small} is 4, the @code{Size}
10128 clause is accepted by GNAT and results in the following representation
10129 scheme:
10131 @smallexample
10132   -7 is represented as 2#00#
10133   -6 is represented as 2#01#
10134   -5 is represented as 2#10#
10135   -4 is represented as 2#11#
10136 @end smallexample
10138 @noindent
10139 Biased representation is only used if the specified @code{Size} clause
10140 cannot be accepted in any other manner.  These reduced sizes that force
10141 biased representation can be used for all discrete types except for
10142 enumeration types for which a representation clause is given.
10144 @node Value_Size and Object_Size Clauses
10145 @section Value_Size and Object_Size Clauses
10146 @findex Value_Size
10147 @findex Object_Size
10148 @cindex Size, of objects
10150 @noindent
10151 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10152 number of bits required to hold values of type @code{T}.
10153 Although this interpretation was allowed in Ada 83, it was not required,
10154 and this requirement in practice can cause some significant difficulties.
10155 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10156 However, in Ada 95 and Ada 2005,
10157 @code{Natural'Size} is
10158 typically 31.  This means that code may change in behavior when moving
10159 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10161 @smallexample @c ada
10162    type Rec is record;
10163       A : Natural;
10164       B : Natural;
10165    end record;
10167    for Rec use record
10168       at 0  range 0 .. Natural'Size - 1;
10169       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10170    end record;
10171 @end smallexample
10173 @noindent
10174 In the above code, since the typical size of @code{Natural} objects
10175 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10176 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10177 there are cases where the fact that the object size can exceed the
10178 size of the type causes surprises.
10180 To help get around this problem GNAT provides two implementation
10181 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10182 applied to a type, these attributes yield the size of the type
10183 (corresponding to the RM defined size attribute), and the size of
10184 objects of the type respectively.
10186 The @code{Object_Size} is used for determining the default size of
10187 objects and components.  This size value can be referred to using the
10188 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10189 the basis of the determination of the size.  The backend is free to
10190 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10191 character might be stored in 32 bits on a machine with no efficient
10192 byte access instructions such as the Alpha.
10194 The default rules for the value of @code{Object_Size} for
10195 discrete types are as follows:
10197 @itemize @bullet
10198 @item
10199 The @code{Object_Size} for base subtypes reflect the natural hardware
10200 size in bits (run the compiler with @option{-gnatS} to find those values
10201 for numeric types). Enumeration types and fixed-point base subtypes have
10202 8, 16, 32 or 64 bits for this size, depending on the range of values
10203 to be stored.
10205 @item
10206 The @code{Object_Size} of a subtype is the same as the
10207 @code{Object_Size} of
10208 the type from which it is obtained.
10210 @item
10211 The @code{Object_Size} of a derived base type is copied from the parent
10212 base type, and the @code{Object_Size} of a derived first subtype is copied
10213 from the parent first subtype.
10214 @end itemize
10216 @noindent
10217 The @code{Value_Size} attribute
10218 is the (minimum) number of bits required to store a value
10219 of the type.
10220 This value is used to determine how tightly to pack
10221 records or arrays with components of this type, and also affects
10222 the semantics of unchecked conversion (unchecked conversions where
10223 the @code{Value_Size} values differ generate a warning, and are potentially
10224 target dependent).
10226 The default rules for the value of @code{Value_Size} are as follows:
10228 @itemize @bullet
10229 @item
10230 The @code{Value_Size} for a base subtype is the minimum number of bits
10231 required to store all values of the type (including the sign bit
10232 only if negative values are possible).
10234 @item
10235 If a subtype statically matches the first subtype of a given type, then it has
10236 by default the same @code{Value_Size} as the first subtype.  This is a
10237 consequence of RM 13.1(14) (``if two subtypes statically match,
10238 then their subtype-specific aspects are the same''.)
10240 @item
10241 All other subtypes have a @code{Value_Size} corresponding to the minimum
10242 number of bits required to store all values of the subtype.  For
10243 dynamic bounds, it is assumed that the value can range down or up
10244 to the corresponding bound of the ancestor
10245 @end itemize
10247 @noindent
10248 The RM defined attribute @code{Size} corresponds to the
10249 @code{Value_Size} attribute.
10251 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10252 the @code{Value_Size} of
10253 the first-named subtype to the given value, and the
10254 @code{Object_Size} of this first-named subtype to the given value padded up
10255 to an appropriate boundary.  It is a consequence of the default rules
10256 above that this @code{Object_Size} will apply to all further subtypes.  On the
10257 other hand, @code{Value_Size} is affected only for the first subtype, any
10258 dynamic subtypes obtained from it directly, and any statically matching
10259 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10261 @code{Value_Size} and
10262 @code{Object_Size} may be explicitly set for any subtype using
10263 an attribute definition clause.  Note that the use of these attributes
10264 can cause the RM 13.1(14) rule to be violated.  If two access types
10265 reference aliased objects whose subtypes have differing @code{Object_Size}
10266 values as a result of explicit attribute definition clauses, then it
10267 is erroneous to convert from one access subtype to the other.
10269 At the implementation level, Esize stores the Object_Size and the
10270 RM_Size field stores the @code{Value_Size} (and hence the value of the
10271 @code{Size} attribute,
10272 which, as noted above, is equivalent to @code{Value_Size}).
10274 To get a feel for the difference, consider the following examples (note
10275 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10277 @smallexample
10278                                        Object_Size     Value_Size
10280 type x1 is range 0 .. 5;                    8               3
10282 type x2 is range 0 .. 5;
10283 for x2'size use 12;                        16              12
10285 subtype x3 is x2 range 0 .. 3;             16               2
10287 subtype x4 is x2'base range 0 .. 10;        8               4
10289 subtype x5 is x2 range 0 .. dynamic;       16               3*
10291 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10293 @end smallexample
10295 @noindent
10296 Note: the entries marked ``3*'' are not actually specified by the Ada
10297 Reference Manual, but it seems in the spirit of the RM rules to allocate
10298 the minimum number of bits (here 3, given the range for @code{x2})
10299 known to be large enough to hold the given range of values.
10301 So far, so good, but GNAT has to obey the RM rules, so the question is
10302 under what conditions must the RM @code{Size} be used.
10303 The following is a list
10304 of the occasions on which the RM @code{Size} must be used:
10306 @itemize @bullet
10307 @item
10308 Component size for packed arrays or records
10310 @item
10311 Value of the attribute @code{Size} for a type
10313 @item
10314 Warning about sizes not matching for unchecked conversion
10315 @end itemize
10317 @noindent
10318 For record types, the @code{Object_Size} is always a multiple of the
10319 alignment of the type (this is true for all types). In some cases the
10320 @code{Value_Size} can be smaller. Consider:
10322 @smallexample
10323    type R is record
10324      X : Integer;
10325      Y : Character;
10326    end record;
10327 @end smallexample
10329 @noindent
10330 On a typical 32-bit architecture, the X component will be four bytes, and
10331 require four-byte alignment, and the Y component will be one byte. In this
10332 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10333 required to store a value of this type, and for example, it is permissible
10334 to have a component of type R in an outer record whose component size is
10335 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10336 since it must be rounded up so that this value is a multiple of the
10337 alignment (4 bytes = 32 bits).
10339 @noindent
10340 For all other types, the @code{Object_Size}
10341 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10342 Only @code{Size} may be specified for such types.
10344 @node Component_Size Clauses
10345 @section Component_Size Clauses
10346 @cindex Component_Size Clause
10348 @noindent
10349 Normally, the value specified in a component size clause must be consistent
10350 with the subtype of the array component with regard to size and alignment.
10351 In other words, the value specified must be at least equal to the size
10352 of this subtype, and must be a multiple of the alignment value.
10354 In addition, component size clauses are allowed which cause the array
10355 to be packed, by specifying a smaller value.  A first case is for
10356 component size values in the range 1 through 63.  The value specified
10357 must not be smaller than the Size of the subtype.  GNAT will accurately
10358 honor all packing requests in this range.  For example, if we have:
10360 @smallexample @c ada
10361 type r is array (1 .. 8) of Natural;
10362 for r'Component_Size use 31;
10363 @end smallexample
10365 @noindent
10366 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10367 Of course access to the components of such an array is considerably
10368 less efficient than if the natural component size of 32 is used.
10369 A second case is when the subtype of the component is a record type
10370 padded because of its default alignment.  For example, if we have:
10372 @smallexample @c ada
10373 type r is record
10374   i : Integer;
10375   j : Integer;
10376   b : Boolean;
10377 end record;
10379 type a is array (1 .. 8) of r;
10380 for a'Component_Size use 72;
10381 @end smallexample
10383 @noindent
10384 then the resulting array has a length of 72 bytes, instead of 96 bytes
10385 if the alignment of the record (4) was obeyed.
10387 Note that there is no point in giving both a component size clause
10388 and a pragma Pack for the same array type. if such duplicate
10389 clauses are given, the pragma Pack will be ignored.
10391 @node Bit_Order Clauses
10392 @section Bit_Order Clauses
10393 @cindex Bit_Order Clause
10394 @cindex bit ordering
10395 @cindex ordering, of bits
10397 @noindent
10398 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10399 attribute.  The specification may either correspond to the default bit
10400 order for the target, in which case the specification has no effect and
10401 places no additional restrictions, or it may be for the non-standard
10402 setting (that is the opposite of the default).
10404 In the case where the non-standard value is specified, the effect is
10405 to renumber bits within each byte, but the ordering of bytes is not
10406 affected.  There are certain
10407 restrictions placed on component clauses as follows:
10409 @itemize @bullet
10411 @item Components fitting within a single storage unit.
10412 @noindent
10413 These are unrestricted, and the effect is merely to renumber bits.  For
10414 example if we are on a little-endian machine with @code{Low_Order_First}
10415 being the default, then the following two declarations have exactly
10416 the same effect:
10418 @smallexample @c ada
10419    type R1 is record
10420       A : Boolean;
10421       B : Integer range 1 .. 120;
10422    end record;
10424    for R1 use record
10425       A at 0 range 0 .. 0;
10426       B at 0 range 1 .. 7;
10427    end record;
10429    type R2 is record
10430       A : Boolean;
10431       B : Integer range 1 .. 120;
10432    end record;
10434    for R2'Bit_Order use High_Order_First;
10436    for R2 use record
10437       A at 0 range 7 .. 7;
10438       B at 0 range 0 .. 6;
10439    end record;
10440 @end smallexample
10442 @noindent
10443 The useful application here is to write the second declaration with the
10444 @code{Bit_Order} attribute definition clause, and know that it will be treated
10445 the same, regardless of whether the target is little-endian or big-endian.
10447 @item Components occupying an integral number of bytes.
10448 @noindent
10449 These are components that exactly fit in two or more bytes.  Such component
10450 declarations are allowed, but have no effect, since it is important to realize
10451 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10452 In particular, the following attempt at getting an endian-independent integer
10453 does not work:
10455 @smallexample @c ada
10456    type R2 is record
10457       A : Integer;
10458    end record;
10460    for R2'Bit_Order use High_Order_First;
10462    for R2 use record
10463       A at 0 range 0 .. 31;
10464    end record;
10465 @end smallexample
10467 @noindent
10468 This declaration will result in a little-endian integer on a
10469 little-endian machine, and a big-endian integer on a big-endian machine.
10470 If byte flipping is required for interoperability between big- and
10471 little-endian machines, this must be explicitly programmed.  This capability
10472 is not provided by @code{Bit_Order}.
10474 @item Components that are positioned across byte boundaries
10475 @noindent
10476 but do not occupy an integral number of bytes.  Given that bytes are not
10477 reordered, such fields would occupy a non-contiguous sequence of bits
10478 in memory, requiring non-trivial code to reassemble.  They are for this
10479 reason not permitted, and any component clause specifying such a layout
10480 will be flagged as illegal by GNAT@.
10482 @end itemize
10484 @noindent
10485 Since the misconception that Bit_Order automatically deals with all
10486 endian-related incompatibilities is a common one, the specification of
10487 a component field that is an integral number of bytes will always
10488 generate a warning.  This warning may be suppressed using @code{pragma
10489 Warnings (Off)} if desired.  The following section contains additional
10490 details regarding the issue of byte ordering.
10492 @node Effect of Bit_Order on Byte Ordering
10493 @section Effect of Bit_Order on Byte Ordering
10494 @cindex byte ordering
10495 @cindex ordering, of bytes
10497 @noindent
10498 In this section we will review the effect of the @code{Bit_Order} attribute
10499 definition clause on byte ordering.  Briefly, it has no effect at all, but
10500 a detailed example will be helpful.  Before giving this
10501 example, let us review the precise
10502 definition of the effect of defining @code{Bit_Order}.  The effect of a
10503 non-standard bit order is described in section 15.5.3 of the Ada
10504 Reference Manual:
10506 @quotation
10507 2   A bit ordering is a method of interpreting the meaning of
10508 the storage place attributes.
10509 @end quotation
10511 @noindent
10512 To understand the precise definition of storage place attributes in
10513 this context, we visit section 13.5.1 of the manual:
10515 @quotation
10516 13   A record_representation_clause (without the mod_clause)
10517 specifies the layout.  The storage place attributes (see 13.5.2)
10518 are taken from the values of the position, first_bit, and last_bit
10519 expressions after normalizing those values so that first_bit is
10520 less than Storage_Unit.
10521 @end quotation
10523 @noindent
10524 The critical point here is that storage places are taken from
10525 the values after normalization, not before.  So the @code{Bit_Order}
10526 interpretation applies to normalized values.  The interpretation
10527 is described in the later part of the 15.5.3 paragraph:
10529 @quotation
10530 2   A bit ordering is a method of interpreting the meaning of
10531 the storage place attributes.  High_Order_First (known in the
10532 vernacular as ``big endian'') means that the first bit of a
10533 storage element (bit 0) is the most significant bit (interpreting
10534 the sequence of bits that represent a component as an unsigned
10535 integer value).  Low_Order_First (known in the vernacular as
10536 ``little endian'') means the opposite: the first bit is the
10537 least significant.
10538 @end quotation
10540 @noindent
10541 Note that the numbering is with respect to the bits of a storage
10542 unit.  In other words, the specification affects only the numbering
10543 of bits within a single storage unit.
10545 We can make the effect clearer by giving an example.
10547 Suppose that we have an external device which presents two bytes, the first
10548 byte presented, which is the first (low addressed byte) of the two byte
10549 record is called Master, and the second byte is called Slave.
10551 The left most (most significant bit is called Control for each byte, and
10552 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10553 (least significant) bit.
10555 On a big-endian machine, we can write the following representation clause
10557 @smallexample @c ada
10558    type Data is record
10559       Master_Control : Bit;
10560       Master_V1      : Bit;
10561       Master_V2      : Bit;
10562       Master_V3      : Bit;
10563       Master_V4      : Bit;
10564       Master_V5      : Bit;
10565       Master_V6      : Bit;
10566       Master_V7      : Bit;
10567       Slave_Control  : Bit;
10568       Slave_V1       : Bit;
10569       Slave_V2       : Bit;
10570       Slave_V3       : Bit;
10571       Slave_V4       : Bit;
10572       Slave_V5       : Bit;
10573       Slave_V6       : Bit;
10574       Slave_V7       : Bit;
10575    end record;
10577    for Data use record
10578       Master_Control at 0 range 0 .. 0;
10579       Master_V1      at 0 range 1 .. 1;
10580       Master_V2      at 0 range 2 .. 2;
10581       Master_V3      at 0 range 3 .. 3;
10582       Master_V4      at 0 range 4 .. 4;
10583       Master_V5      at 0 range 5 .. 5;
10584       Master_V6      at 0 range 6 .. 6;
10585       Master_V7      at 0 range 7 .. 7;
10586       Slave_Control  at 1 range 0 .. 0;
10587       Slave_V1       at 1 range 1 .. 1;
10588       Slave_V2       at 1 range 2 .. 2;
10589       Slave_V3       at 1 range 3 .. 3;
10590       Slave_V4       at 1 range 4 .. 4;
10591       Slave_V5       at 1 range 5 .. 5;
10592       Slave_V6       at 1 range 6 .. 6;
10593       Slave_V7       at 1 range 7 .. 7;
10594    end record;
10595 @end smallexample
10597 @noindent
10598 Now if we move this to a little endian machine, then the bit ordering within
10599 the byte is backwards, so we have to rewrite the record rep clause as:
10601 @smallexample @c ada
10602    for Data use record
10603       Master_Control at 0 range 7 .. 7;
10604       Master_V1      at 0 range 6 .. 6;
10605       Master_V2      at 0 range 5 .. 5;
10606       Master_V3      at 0 range 4 .. 4;
10607       Master_V4      at 0 range 3 .. 3;
10608       Master_V5      at 0 range 2 .. 2;
10609       Master_V6      at 0 range 1 .. 1;
10610       Master_V7      at 0 range 0 .. 0;
10611       Slave_Control  at 1 range 7 .. 7;
10612       Slave_V1       at 1 range 6 .. 6;
10613       Slave_V2       at 1 range 5 .. 5;
10614       Slave_V3       at 1 range 4 .. 4;
10615       Slave_V4       at 1 range 3 .. 3;
10616       Slave_V5       at 1 range 2 .. 2;
10617       Slave_V6       at 1 range 1 .. 1;
10618       Slave_V7       at 1 range 0 .. 0;
10619    end record;
10620 @end smallexample
10622 @noindent
10623 It is a nuisance to have to rewrite the clause, especially if
10624 the code has to be maintained on both machines.  However,
10625 this is a case that we can handle with the
10626 @code{Bit_Order} attribute if it is implemented.
10627 Note that the implementation is not required on byte addressed
10628 machines, but it is indeed implemented in GNAT.
10629 This means that we can simply use the
10630 first record clause, together with the declaration
10632 @smallexample @c ada
10633    for Data'Bit_Order use High_Order_First;
10634 @end smallexample
10636 @noindent
10637 and the effect is what is desired, namely the layout is exactly the same,
10638 independent of whether the code is compiled on a big-endian or little-endian
10639 machine.
10641 The important point to understand is that byte ordering is not affected.
10642 A @code{Bit_Order} attribute definition never affects which byte a field
10643 ends up in, only where it ends up in that byte.
10644 To make this clear, let us rewrite the record rep clause of the previous
10645 example as:
10647 @smallexample @c ada
10648    for Data'Bit_Order use High_Order_First;
10649    for Data use record
10650       Master_Control at 0 range  0 .. 0;
10651       Master_V1      at 0 range  1 .. 1;
10652       Master_V2      at 0 range  2 .. 2;
10653       Master_V3      at 0 range  3 .. 3;
10654       Master_V4      at 0 range  4 .. 4;
10655       Master_V5      at 0 range  5 .. 5;
10656       Master_V6      at 0 range  6 .. 6;
10657       Master_V7      at 0 range  7 .. 7;
10658       Slave_Control  at 0 range  8 .. 8;
10659       Slave_V1       at 0 range  9 .. 9;
10660       Slave_V2       at 0 range 10 .. 10;
10661       Slave_V3       at 0 range 11 .. 11;
10662       Slave_V4       at 0 range 12 .. 12;
10663       Slave_V5       at 0 range 13 .. 13;
10664       Slave_V6       at 0 range 14 .. 14;
10665       Slave_V7       at 0 range 15 .. 15;
10666    end record;
10667 @end smallexample
10669 @noindent
10670 This is exactly equivalent to saying (a repeat of the first example):
10672 @smallexample @c ada
10673    for Data'Bit_Order use High_Order_First;
10674    for Data use record
10675       Master_Control at 0 range 0 .. 0;
10676       Master_V1      at 0 range 1 .. 1;
10677       Master_V2      at 0 range 2 .. 2;
10678       Master_V3      at 0 range 3 .. 3;
10679       Master_V4      at 0 range 4 .. 4;
10680       Master_V5      at 0 range 5 .. 5;
10681       Master_V6      at 0 range 6 .. 6;
10682       Master_V7      at 0 range 7 .. 7;
10683       Slave_Control  at 1 range 0 .. 0;
10684       Slave_V1       at 1 range 1 .. 1;
10685       Slave_V2       at 1 range 2 .. 2;
10686       Slave_V3       at 1 range 3 .. 3;
10687       Slave_V4       at 1 range 4 .. 4;
10688       Slave_V5       at 1 range 5 .. 5;
10689       Slave_V6       at 1 range 6 .. 6;
10690       Slave_V7       at 1 range 7 .. 7;
10691    end record;
10692 @end smallexample
10694 @noindent
10695 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10696 field.  The storage place attributes are obtained by normalizing the
10697 values given so that the @code{First_Bit} value is less than 8.  After
10698 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10699 we specified in the other case.
10701 Now one might expect that the @code{Bit_Order} attribute might affect
10702 bit numbering within the entire record component (two bytes in this
10703 case, thus affecting which byte fields end up in), but that is not
10704 the way this feature is defined, it only affects numbering of bits,
10705 not which byte they end up in.
10707 Consequently it never makes sense to specify a starting bit number
10708 greater than 7 (for a byte addressable field) if an attribute
10709 definition for @code{Bit_Order} has been given, and indeed it
10710 may be actively confusing to specify such a value, so the compiler
10711 generates a warning for such usage.
10713 If you do need to control byte ordering then appropriate conditional
10714 values must be used.  If in our example, the slave byte came first on
10715 some machines we might write:
10717 @smallexample @c ada
10718    Master_Byte_First constant Boolean := @dots{};
10720    Master_Byte : constant Natural :=
10721                    1 - Boolean'Pos (Master_Byte_First);
10722    Slave_Byte  : constant Natural :=
10723                    Boolean'Pos (Master_Byte_First);
10725    for Data'Bit_Order use High_Order_First;
10726    for Data use record
10727       Master_Control at Master_Byte range 0 .. 0;
10728       Master_V1      at Master_Byte range 1 .. 1;
10729       Master_V2      at Master_Byte range 2 .. 2;
10730       Master_V3      at Master_Byte range 3 .. 3;
10731       Master_V4      at Master_Byte range 4 .. 4;
10732       Master_V5      at Master_Byte range 5 .. 5;
10733       Master_V6      at Master_Byte range 6 .. 6;
10734       Master_V7      at Master_Byte range 7 .. 7;
10735       Slave_Control  at Slave_Byte  range 0 .. 0;
10736       Slave_V1       at Slave_Byte  range 1 .. 1;
10737       Slave_V2       at Slave_Byte  range 2 .. 2;
10738       Slave_V3       at Slave_Byte  range 3 .. 3;
10739       Slave_V4       at Slave_Byte  range 4 .. 4;
10740       Slave_V5       at Slave_Byte  range 5 .. 5;
10741       Slave_V6       at Slave_Byte  range 6 .. 6;
10742       Slave_V7       at Slave_Byte  range 7 .. 7;
10743    end record;
10744 @end smallexample
10746 @noindent
10747 Now to switch between machines, all that is necessary is
10748 to set the boolean constant @code{Master_Byte_First} in
10749 an appropriate manner.
10751 @node Pragma Pack for Arrays
10752 @section Pragma Pack for Arrays
10753 @cindex Pragma Pack (for arrays)
10755 @noindent
10756 Pragma @code{Pack} applied to an array has no effect unless the component type
10757 is packable.  For a component type to be packable, it must be one of the
10758 following cases:
10760 @itemize @bullet
10761 @item
10762 Any scalar type
10763 @item
10764 Any type whose size is specified with a size clause
10765 @item
10766 Any packed array type with a static size
10767 @item
10768 Any record type padded because of its default alignment
10769 @end itemize
10771 @noindent
10772 For all these cases, if the component subtype size is in the range
10773 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10774 component size were specified giving the component subtype size.
10775 For example if we have:
10777 @smallexample @c ada
10778    type r is range 0 .. 17;
10780    type ar is array (1 .. 8) of r;
10781    pragma Pack (ar);
10782 @end smallexample
10784 @noindent
10785 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10786 and the size of the array @code{ar} will be exactly 40 bits.
10788 Note that in some cases this rather fierce approach to packing can produce
10789 unexpected effects.  For example, in Ada 95 and Ada 2005,
10790 subtype @code{Natural} typically has a size of 31, meaning that if you
10791 pack an array of @code{Natural}, you get 31-bit
10792 close packing, which saves a few bits, but results in far less efficient
10793 access.  Since many other Ada compilers will ignore such a packing request,
10794 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10795 might not be what is intended.  You can easily remove this warning by
10796 using an explicit @code{Component_Size} setting instead, which never generates
10797 a warning, since the intention of the programmer is clear in this case.
10799 GNAT treats packed arrays in one of two ways.  If the size of the array is
10800 known at compile time and is less than 64 bits, then internally the array
10801 is represented as a single modular type, of exactly the appropriate number
10802 of bits.  If the length is greater than 63 bits, or is not known at compile
10803 time, then the packed array is represented as an array of bytes, and the
10804 length is always a multiple of 8 bits.
10806 Note that to represent a packed array as a modular type, the alignment must
10807 be suitable for the modular type involved. For example, on typical machines
10808 a 32-bit packed array will be represented by a 32-bit modular integer with
10809 an alignment of four bytes. If you explicitly override the default alignment
10810 with an alignment clause that is too small, the modular representation
10811 cannot be used. For example, consider the following set of declarations:
10813 @smallexample @c ada
10814    type R is range 1 .. 3;
10815    type S is array (1 .. 31) of R;
10816    for S'Component_Size use 2;
10817    for S'Size use 62;
10818    for S'Alignment use 1;
10819 @end smallexample
10821 @noindent
10822 If the alignment clause were not present, then a 62-bit modular
10823 representation would be chosen (typically with an alignment of 4 or 8
10824 bytes depending on the target). But the default alignment is overridden
10825 with the explicit alignment clause. This means that the modular
10826 representation cannot be used, and instead the array of bytes
10827 representation must be used, meaning that the length must be a multiple
10828 of 8. Thus the above set of declarations will result in a diagnostic
10829 rejecting the size clause and noting that the minimum size allowed is 64.
10831 @cindex Pragma Pack (for type Natural)
10832 @cindex Pragma Pack warning
10834 One special case that is worth noting occurs when the base type of the
10835 component size is 8/16/32 and the subtype is one bit less. Notably this
10836 occurs with subtype @code{Natural}. Consider:
10838 @smallexample @c ada
10839    type Arr is array (1 .. 32) of Natural;
10840    pragma Pack (Arr);
10841 @end smallexample
10843 @noindent
10844 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10845 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10846 Ada 83 compilers did not attempt 31 bit packing.
10848 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10849 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10850 substantial unintended performance penalty when porting legacy Ada 83 code.
10851 To help prevent this, GNAT generates a warning in such cases. If you really
10852 want 31 bit packing in a case like this, you can set the component size
10853 explicitly:
10855 @smallexample @c ada
10856    type Arr is array (1 .. 32) of Natural;
10857    for Arr'Component_Size use 31;
10858 @end smallexample
10860 @noindent
10861 Here 31-bit packing is achieved as required, and no warning is generated,
10862 since in this case the programmer intention is clear.
10864 @node Pragma Pack for Records
10865 @section Pragma Pack for Records
10866 @cindex Pragma Pack (for records)
10868 @noindent
10869 Pragma @code{Pack} applied to a record will pack the components to reduce
10870 wasted space from alignment gaps and by reducing the amount of space
10871 taken by components.  We distinguish between @emph{packable} components and
10872 @emph{non-packable} components.
10873 Components of the following types are considered packable:
10874 @itemize @bullet
10875 @item
10876 All primitive types are packable.
10878 @item
10879 Small packed arrays, whose size does not exceed 64 bits, and where the
10880 size is statically known at compile time, are represented internally
10881 as modular integers, and so they are also packable.
10883 @end itemize
10885 @noindent
10886 All packable components occupy the exact number of bits corresponding to
10887 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10888 can start on an arbitrary bit boundary.
10890 All other types are non-packable, they occupy an integral number of
10891 storage units, and
10892 are placed at a boundary corresponding to their alignment requirements.
10894 For example, consider the record
10896 @smallexample @c ada
10897    type Rb1 is array (1 .. 13) of Boolean;
10898    pragma Pack (rb1);
10900    type Rb2 is array (1 .. 65) of Boolean;
10901    pragma Pack (rb2);
10903    type x2 is record
10904       l1 : Boolean;
10905       l2 : Duration;
10906       l3 : Float;
10907       l4 : Boolean;
10908       l5 : Rb1;
10909       l6 : Rb2;
10910    end record;
10911    pragma Pack (x2);
10912 @end smallexample
10914 @noindent
10915 The representation for the record x2 is as follows:
10917 @smallexample @c ada
10918 for x2'Size use 224;
10919 for x2 use record
10920    l1 at  0 range  0 .. 0;
10921    l2 at  0 range  1 .. 64;
10922    l3 at 12 range  0 .. 31;
10923    l4 at 16 range  0 .. 0;
10924    l5 at 16 range  1 .. 13;
10925    l6 at 18 range  0 .. 71;
10926 end record;
10927 @end smallexample
10929 @noindent
10930 Studying this example, we see that the packable fields @code{l1}
10931 and @code{l2} are
10932 of length equal to their sizes, and placed at specific bit boundaries (and
10933 not byte boundaries) to
10934 eliminate padding.  But @code{l3} is of a non-packable float type, so
10935 it is on the next appropriate alignment boundary.
10937 The next two fields are fully packable, so @code{l4} and @code{l5} are
10938 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10939 array that is longer than 64 bits, so it is itself non-packable.  Thus
10940 the @code{l6} field is aligned to the next byte boundary, and takes an
10941 integral number of bytes, i.e.@: 72 bits.
10943 @node Record Representation Clauses
10944 @section Record Representation Clauses
10945 @cindex Record Representation Clause
10947 @noindent
10948 Record representation clauses may be given for all record types, including
10949 types obtained by record extension.  Component clauses are allowed for any
10950 static component.  The restrictions on component clauses depend on the type
10951 of the component.
10953 @cindex Component Clause
10954 For all components of an elementary type, the only restriction on component
10955 clauses is that the size must be at least the 'Size value of the type
10956 (actually the Value_Size).  There are no restrictions due to alignment,
10957 and such components may freely cross storage boundaries.
10959 Packed arrays with a size up to and including 64 bits are represented
10960 internally using a modular type with the appropriate number of bits, and
10961 thus the same lack of restriction applies.  For example, if you declare:
10963 @smallexample @c ada
10964    type R is array (1 .. 49) of Boolean;
10965    pragma Pack (R);
10966    for R'Size use 49;
10967 @end smallexample
10969 @noindent
10970 then a component clause for a component of type R may start on any
10971 specified bit boundary, and may specify a value of 49 bits or greater.
10973 For packed bit arrays that are longer than 64 bits, there are two
10974 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10975 including the important case of single bits or boolean values, then
10976 there are no limitations on placement of such components, and they
10977 may start and end at arbitrary bit boundaries.
10979 If the component size is not a power of 2 (e.g.@: 3 or 5), then
10980 an array of this type longer than 64 bits must always be placed on
10981 on a storage unit (byte) boundary and occupy an integral number
10982 of storage units (bytes). Any component clause that does not
10983 meet this requirement will be rejected.
10985 Any aliased component, or component of an aliased type, must
10986 have its normal alignment and size. A component clause that
10987 does not meet this requirement will be rejected.
10989 The tag field of a tagged type always occupies an address sized field at
10990 the start of the record.  No component clause may attempt to overlay this
10991 tag. When a tagged type appears as a component, the tag field must have
10992 proper alignment
10994 In the case of a record extension T1, of a type T, no component clause applied
10995 to the type T1 can specify a storage location that would overlap the first
10996 T'Size bytes of the record.
10998 For all other component types, including non-bit-packed arrays,
10999 the component can be placed at an arbitrary bit boundary,
11000 so for example, the following is permitted:
11002 @smallexample @c ada
11003    type R is array (1 .. 10) of Boolean;
11004    for R'Size use 80;
11006    type Q is record
11007       G, H : Boolean;
11008       L, M : R;
11009    end record;
11011    for Q use record
11012       G at 0 range  0 ..   0;
11013       H at 0 range  1 ..   1;
11014       L at 0 range  2 ..  81;
11015       R at 0 range 82 .. 161;
11016    end record;
11017 @end smallexample
11019 @noindent
11020 Note: the above rules apply to recent releases of GNAT 5.
11021 In GNAT 3, there are more severe restrictions on larger components.
11022 For non-primitive types, including packed arrays with a size greater than
11023 64 bits, component clauses must respect the alignment requirement of the
11024 type, in particular, always starting on a byte boundary, and the length
11025 must be a multiple of the storage unit.
11027 @node Enumeration Clauses
11028 @section Enumeration Clauses
11030 The only restriction on enumeration clauses is that the range of values
11031 must be representable.  For the signed case, if one or more of the
11032 representation values are negative, all values must be in the range:
11034 @smallexample @c ada
11035    System.Min_Int .. System.Max_Int
11036 @end smallexample
11038 @noindent
11039 For the unsigned case, where all values are nonnegative, the values must
11040 be in the range:
11042 @smallexample @c ada
11043    0 .. System.Max_Binary_Modulus;
11044 @end smallexample
11046 @noindent
11047 A @emph{confirming} representation clause is one in which the values range
11048 from 0 in sequence, i.e.@: a clause that confirms the default representation
11049 for an enumeration type.
11050 Such a confirming representation
11051 is permitted by these rules, and is specially recognized by the compiler so
11052 that no extra overhead results from the use of such a clause.
11054 If an array has an index type which is an enumeration type to which an
11055 enumeration clause has been applied, then the array is stored in a compact
11056 manner.  Consider the declarations:
11058 @smallexample @c ada
11059    type r is (A, B, C);
11060    for r use (A => 1, B => 5, C => 10);
11061    type t is array (r) of Character;
11062 @end smallexample
11064 @noindent
11065 The array type t corresponds to a vector with exactly three elements and
11066 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11067 use of space, but means that accesses to elements of the array will incur
11068 the overhead of converting representation values to the corresponding
11069 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11071 @node Address Clauses
11072 @section Address Clauses
11073 @cindex Address Clause
11075 The reference manual allows a general restriction on representation clauses,
11076 as found in RM 13.1(22):
11078 @quotation
11079 An implementation need not support representation
11080 items containing nonstatic expressions, except that
11081 an implementation should support a representation item
11082 for a given entity if each nonstatic expression in the
11083 representation item is a name that statically denotes
11084 a constant declared before the entity.
11085 @end quotation
11087 @noindent
11088 In practice this is applicable only to address clauses, since this is the
11089 only case in which a non-static expression is permitted by the syntax.  As
11090 the AARM notes in sections 13.1 (22.a-22.h):
11092 @display
11093   22.a   Reason: This is to avoid the following sort of thing:
11095   22.b        X : Integer := F(@dots{});
11096               Y : Address := G(@dots{});
11097               for X'Address use Y;
11099   22.c   In the above, we have to evaluate the
11100          initialization expression for X before we
11101          know where to put the result.  This seems
11102          like an unreasonable implementation burden.
11104   22.d   The above code should instead be written
11105          like this:
11107   22.e        Y : constant Address := G(@dots{});
11108               X : Integer := F(@dots{});
11109               for X'Address use Y;
11111   22.f   This allows the expression ``Y'' to be safely
11112          evaluated before X is created.
11114   22.g   The constant could be a formal parameter of mode in.
11116   22.h   An implementation can support other nonstatic
11117          expressions if it wants to.  Expressions of type
11118          Address are hardly ever static, but their value
11119          might be known at compile time anyway in many
11120          cases.
11121 @end display
11123 @noindent
11124 GNAT does indeed permit many additional cases of non-static expressions.  In
11125 particular, if the type involved is elementary there are no restrictions
11126 (since in this case, holding a temporary copy of the initialization value,
11127 if one is present, is inexpensive).  In addition, if there is no implicit or
11128 explicit initialization, then there are no restrictions.  GNAT will reject
11129 only the case where all three of these conditions hold:
11131 @itemize @bullet
11133 @item
11134 The type of the item is non-elementary (e.g.@: a record or array).
11136 @item
11137 There is explicit or implicit initialization required for the object.
11138 Note that access values are always implicitly initialized, and also
11139 in GNAT, certain bit-packed arrays (those having a dynamic length or
11140 a length greater than 64) will also be implicitly initialized to zero.
11142 @item
11143 The address value is non-static.  Here GNAT is more permissive than the
11144 RM, and allows the address value to be the address of a previously declared
11145 stand-alone variable, as long as it does not itself have an address clause.
11147 @smallexample @c ada
11148            Anchor  : Some_Initialized_Type;
11149            Overlay : Some_Initialized_Type;
11150            for Overlay'Address use Anchor'Address;
11151 @end smallexample
11153 @noindent
11154 However, the prefix of the address clause cannot be an array component, or
11155 a component of a discriminated record.
11157 @end itemize
11159 @noindent
11160 As noted above in section 22.h, address values are typically non-static.  In
11161 particular the To_Address function, even if applied to a literal value, is
11162 a non-static function call.  To avoid this minor annoyance, GNAT provides
11163 the implementation defined attribute 'To_Address.  The following two
11164 expressions have identical values:
11166 @findex Attribute
11167 @findex To_Address
11168 @smallexample @c ada
11169    To_Address (16#1234_0000#)
11170    System'To_Address (16#1234_0000#);
11171 @end smallexample
11173 @noindent
11174 except that the second form is considered to be a static expression, and
11175 thus when used as an address clause value is always permitted.
11177 @noindent
11178 Additionally, GNAT treats as static an address clause that is an
11179 unchecked_conversion of a static integer value.  This simplifies the porting
11180 of legacy code, and provides a portable equivalent to the GNAT attribute
11181 @code{To_Address}.
11183 Another issue with address clauses is the interaction with alignment
11184 requirements.  When an address clause is given for an object, the address
11185 value must be consistent with the alignment of the object (which is usually
11186 the same as the alignment of the type of the object).  If an address clause
11187 is given that specifies an inappropriately aligned address value, then the
11188 program execution is erroneous.
11190 Since this source of erroneous behavior can have unfortunate effects, GNAT
11191 checks (at compile time if possible, generating a warning, or at execution
11192 time with a run-time check) that the alignment is appropriate.  If the
11193 run-time check fails, then @code{Program_Error} is raised.  This run-time
11194 check is suppressed if range checks are suppressed, or if the special GNAT
11195 check Alignment_Check is suppressed, or if
11196 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11198 Finally, GNAT does not permit overlaying of objects of controlled types or
11199 composite types containing a controlled component. In most cases, the compiler
11200 can detect an attempt at such overlays and will generate a warning at compile
11201 time and a Program_Error exception at run time.
11203 @findex Export
11204 An address clause cannot be given for an exported object.  More
11205 understandably the real restriction is that objects with an address
11206 clause cannot be exported.  This is because such variables are not
11207 defined by the Ada program, so there is no external object to export.
11209 @findex Import
11210 It is permissible to give an address clause and a pragma Import for the
11211 same object.  In this case, the variable is not really defined by the
11212 Ada program, so there is no external symbol to be linked.  The link name
11213 and the external name are ignored in this case.  The reason that we allow this
11214 combination is that it provides a useful idiom to avoid unwanted
11215 initializations on objects with address clauses.
11217 When an address clause is given for an object that has implicit or
11218 explicit initialization, then by default initialization takes place.  This
11219 means that the effect of the object declaration is to overwrite the
11220 memory at the specified address.  This is almost always not what the
11221 programmer wants, so GNAT will output a warning:
11223 @smallexample
11224   with System;
11225   package G is
11226      type R is record
11227         M : Integer := 0;
11228      end record;
11230      Ext : R;
11231      for Ext'Address use System'To_Address (16#1234_1234#);
11232          |
11233   >>> warning: implicit initialization of "Ext" may
11234       modify overlaid storage
11235   >>> warning: use pragma Import for "Ext" to suppress
11236       initialization (RM B(24))
11238   end G;
11239 @end smallexample
11241 @noindent
11242 As indicated by the warning message, the solution is to use a (dummy) pragma
11243 Import to suppress this initialization.  The pragma tell the compiler that the
11244 object is declared and initialized elsewhere.  The following package compiles
11245 without warnings (and the initialization is suppressed):
11247 @smallexample @c ada
11248    with System;
11249    package G is
11250       type R is record
11251          M : Integer := 0;
11252       end record;
11254       Ext : R;
11255       for Ext'Address use System'To_Address (16#1234_1234#);
11256       pragma Import (Ada, Ext);
11257    end G;
11258 @end smallexample
11260 @noindent
11261 A final issue with address clauses involves their use for overlaying
11262 variables, as in the following example:
11263 @cindex Overlaying of objects
11265 @smallexample @c ada
11266   A : Integer;
11267   B : Integer;
11268   for B'Address use A'Address;
11269 @end smallexample
11271 @noindent
11272 or alternatively, using the form recommended by the RM:
11274 @smallexample @c ada
11275   A    : Integer;
11276   Addr : constant Address := A'Address;
11277   B    : Integer;
11278   for B'Address use Addr;
11279 @end smallexample
11281 @noindent
11282 In both of these cases, @code{A}
11283 and @code{B} become aliased to one another via the
11284 address clause. This use of address clauses to overlay
11285 variables, achieving an effect similar to unchecked
11286 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11287 the effect is implementation defined. Furthermore, the
11288 Ada RM specifically recommends that in a situation
11289 like this, @code{B} should be subject to the following
11290 implementation advice (RM 13.3(19)):
11292 @quotation
11293 19  If the Address of an object is specified, or it is imported
11294     or exported, then the implementation should not perform
11295     optimizations based on assumptions of no aliases.
11296 @end quotation
11298 @noindent
11299 GNAT follows this recommendation, and goes further by also applying
11300 this recommendation to the overlaid variable (@code{A}
11301 in the above example) in this case. This means that the overlay
11302 works "as expected", in that a modification to one of the variables
11303 will affect the value of the other.
11305 @node Effect of Convention on Representation
11306 @section Effect of Convention on Representation
11307 @cindex Convention, effect on representation
11309 @noindent
11310 Normally the specification of a foreign language convention for a type or
11311 an object has no effect on the chosen representation.  In particular, the
11312 representation chosen for data in GNAT generally meets the standard system
11313 conventions, and for example records are laid out in a manner that is
11314 consistent with C@.  This means that specifying convention C (for example)
11315 has no effect.
11317 There are four exceptions to this general rule:
11319 @itemize @bullet
11321 @item Convention Fortran and array subtypes
11322 If pragma Convention Fortran is specified for an array subtype, then in
11323 accordance with the implementation advice in section 3.6.2(11) of the
11324 Ada Reference Manual, the array will be stored in a Fortran-compatible
11325 column-major manner, instead of the normal default row-major order.
11327 @item Convention C and enumeration types
11328 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11329 to accommodate all values of the type.  For example, for the enumeration
11330 type declared by:
11332 @smallexample @c ada
11333    type Color is (Red, Green, Blue);
11334 @end smallexample
11336 @noindent
11337 8 bits is sufficient to store all values of the type, so by default, objects
11338 of type @code{Color} will be represented using 8 bits.  However, normal C
11339 convention is to use 32 bits for all enum values in C, since enum values
11340 are essentially of type int.  If pragma @code{Convention C} is specified for an
11341 Ada enumeration type, then the size is modified as necessary (usually to
11342 32 bits) to be consistent with the C convention for enum values.
11344 Note that this treatment applies only to types. If Convention C is given for
11345 an enumeration object, where the enumeration type is not Convention C, then
11346 Object_Size bits are allocated. For example, for a normal enumeration type,
11347 with less than 256 elements, only 8 bits will be allocated for the object.
11348 Since this may be a surprise in terms of what C expects, GNAT will issue a
11349 warning in this situation. The warning can be suppressed by giving an explicit
11350 size clause specifying the desired size.
11352 @item Convention C/Fortran and Boolean types
11353 In C, the usual convention for boolean values, that is values used for
11354 conditions, is that zero represents false, and nonzero values represent
11355 true.  In Ada, the normal convention is that two specific values, typically
11356 0/1, are used to represent false/true respectively.
11358 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11359 value represents true).
11361 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11362 C or Fortran convention for a derived Boolean, as in the following example:
11364 @smallexample @c ada
11365    type C_Switch is new Boolean;
11366    pragma Convention (C, C_Switch);
11367 @end smallexample
11369 @noindent
11370 then the GNAT generated code will treat any nonzero value as true.  For truth
11371 values generated by GNAT, the conventional value 1 will be used for True, but
11372 when one of these values is read, any nonzero value is treated as True.
11374 @item Access types on OpenVMS
11375 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11376 arrays) are 64-bits long. An exception to this rule is for the case of
11377 C-convention access types where there is no explicit size clause present (or
11378 inherited for derived types). In this case, GNAT chooses to make these
11379 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11380 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11382 @end itemize
11384 @node Determining the Representations chosen by GNAT
11385 @section Determining the Representations chosen by GNAT
11386 @cindex Representation, determination of
11387 @cindex @option{-gnatR} switch
11389 @noindent
11390 Although the descriptions in this section are intended to be complete, it is
11391 often easier to simply experiment to see what GNAT accepts and what the
11392 effect is on the layout of types and objects.
11394 As required by the Ada RM, if a representation clause is not accepted, then
11395 it must be rejected as illegal by the compiler.  However, when a
11396 representation clause or pragma is accepted, there can still be questions
11397 of what the compiler actually does.  For example, if a partial record
11398 representation clause specifies the location of some components and not
11399 others, then where are the non-specified components placed? Or if pragma
11400 @code{Pack} is used on a record, then exactly where are the resulting
11401 fields placed? The section on pragma @code{Pack} in this chapter can be
11402 used to answer the second question, but it is often easier to just see
11403 what the compiler does.
11405 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11406 with this option, then the compiler will output information on the actual
11407 representations chosen, in a format similar to source representation
11408 clauses.  For example, if we compile the package:
11410 @smallexample @c ada
11411 package q is
11412    type r (x : boolean) is tagged record
11413       case x is
11414          when True => S : String (1 .. 100);
11415          when False => null;
11416       end case;
11417    end record;
11419    type r2 is new r (false) with record
11420       y2 : integer;
11421    end record;
11423    for r2 use record
11424       y2 at 16 range 0 .. 31;
11425    end record;
11427    type x is record
11428       y : character;
11429    end record;
11431    type x1 is array (1 .. 10) of x;
11432    for x1'component_size use 11;
11434    type ia is access integer;
11436    type Rb1 is array (1 .. 13) of Boolean;
11437    pragma Pack (rb1);
11439    type Rb2 is array (1 .. 65) of Boolean;
11440    pragma Pack (rb2);
11442    type x2 is record
11443       l1 : Boolean;
11444       l2 : Duration;
11445       l3 : Float;
11446       l4 : Boolean;
11447       l5 : Rb1;
11448       l6 : Rb2;
11449    end record;
11450    pragma Pack (x2);
11451 end q;
11452 @end smallexample
11454 @noindent
11455 using the switch @option{-gnatR} we obtain the following output:
11457 @smallexample
11458 Representation information for unit q
11459 -------------------------------------
11461 for r'Size use ??;
11462 for r'Alignment use 4;
11463 for r use record
11464    x    at 4 range  0 .. 7;
11465    _tag at 0 range  0 .. 31;
11466    s    at 5 range  0 .. 799;
11467 end record;
11469 for r2'Size use 160;
11470 for r2'Alignment use 4;
11471 for r2 use record
11472    x       at  4 range  0 .. 7;
11473    _tag    at  0 range  0 .. 31;
11474    _parent at  0 range  0 .. 63;
11475    y2      at 16 range  0 .. 31;
11476 end record;
11478 for x'Size use 8;
11479 for x'Alignment use 1;
11480 for x use record
11481    y at 0 range  0 .. 7;
11482 end record;
11484 for x1'Size use 112;
11485 for x1'Alignment use 1;
11486 for x1'Component_Size use 11;
11488 for rb1'Size use 13;
11489 for rb1'Alignment use 2;
11490 for rb1'Component_Size use 1;
11492 for rb2'Size use 72;
11493 for rb2'Alignment use 1;
11494 for rb2'Component_Size use 1;
11496 for x2'Size use 224;
11497 for x2'Alignment use 4;
11498 for x2 use record
11499    l1 at  0 range  0 .. 0;
11500    l2 at  0 range  1 .. 64;
11501    l3 at 12 range  0 .. 31;
11502    l4 at 16 range  0 .. 0;
11503    l5 at 16 range  1 .. 13;
11504    l6 at 18 range  0 .. 71;
11505 end record;
11506 @end smallexample
11508 @noindent
11509 The Size values are actually the Object_Size, i.e.@: the default size that
11510 will be allocated for objects of the type.
11511 The ?? size for type r indicates that we have a variant record, and the
11512 actual size of objects will depend on the discriminant value.
11514 The Alignment values show the actual alignment chosen by the compiler
11515 for each record or array type.
11517 The record representation clause for type r shows where all fields
11518 are placed, including the compiler generated tag field (whose location
11519 cannot be controlled by the programmer).
11521 The record representation clause for the type extension r2 shows all the
11522 fields present, including the parent field, which is a copy of the fields
11523 of the parent type of r2, i.e.@: r1.
11525 The component size and size clauses for types rb1 and rb2 show
11526 the exact effect of pragma @code{Pack} on these arrays, and the record
11527 representation clause for type x2 shows how pragma @code{Pack} affects
11528 this record type.
11530 In some cases, it may be useful to cut and paste the representation clauses
11531 generated by the compiler into the original source to fix and guarantee
11532 the actual representation to be used.
11534 @node Standard Library Routines
11535 @chapter Standard Library Routines
11537 @noindent
11538 The Ada Reference Manual contains in Annex A a full description of an
11539 extensive set of standard library routines that can be used in any Ada
11540 program, and which must be provided by all Ada compilers.  They are
11541 analogous to the standard C library used by C programs.
11543 GNAT implements all of the facilities described in annex A, and for most
11544 purposes the description in the Ada Reference Manual, or appropriate Ada
11545 text book, will be sufficient for making use of these facilities.
11547 In the case of the input-output facilities,
11548 @xref{The Implementation of Standard I/O},
11549 gives details on exactly how GNAT interfaces to the
11550 file system.  For the remaining packages, the Ada Reference Manual
11551 should be sufficient.  The following is a list of the packages included,
11552 together with a brief description of the functionality that is provided.
11554 For completeness, references are included to other predefined library
11555 routines defined in other sections of the Ada Reference Manual (these are
11556 cross-indexed from Annex A).
11558 @table @code
11559 @item Ada (A.2)
11560 This is a parent package for all the standard library packages.  It is
11561 usually included implicitly in your program, and itself contains no
11562 useful data or routines.
11564 @item Ada.Calendar (9.6)
11565 @code{Calendar} provides time of day access, and routines for
11566 manipulating times and durations.
11568 @item Ada.Characters (A.3.1)
11569 This is a dummy parent package that contains no useful entities
11571 @item Ada.Characters.Handling (A.3.2)
11572 This package provides some basic character handling capabilities,
11573 including classification functions for classes of characters (e.g.@: test
11574 for letters, or digits).
11576 @item Ada.Characters.Latin_1 (A.3.3)
11577 This package includes a complete set of definitions of the characters
11578 that appear in type CHARACTER@.  It is useful for writing programs that
11579 will run in international environments.  For example, if you want an
11580 upper case E with an acute accent in a string, it is often better to use
11581 the definition of @code{UC_E_Acute} in this package.  Then your program
11582 will print in an understandable manner even if your environment does not
11583 support these extended characters.
11585 @item Ada.Command_Line (A.15)
11586 This package provides access to the command line parameters and the name
11587 of the current program (analogous to the use of @code{argc} and @code{argv}
11588 in C), and also allows the exit status for the program to be set in a
11589 system-independent manner.
11591 @item Ada.Decimal (F.2)
11592 This package provides constants describing the range of decimal numbers
11593 implemented, and also a decimal divide routine (analogous to the COBOL
11594 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11596 @item Ada.Direct_IO (A.8.4)
11597 This package provides input-output using a model of a set of records of
11598 fixed-length, containing an arbitrary definite Ada type, indexed by an
11599 integer record number.
11601 @item Ada.Dynamic_Priorities (D.5)
11602 This package allows the priorities of a task to be adjusted dynamically
11603 as the task is running.
11605 @item Ada.Exceptions (11.4.1)
11606 This package provides additional information on exceptions, and also
11607 contains facilities for treating exceptions as data objects, and raising
11608 exceptions with associated messages.
11610 @item Ada.Finalization (7.6)
11611 This package contains the declarations and subprograms to support the
11612 use of controlled types, providing for automatic initialization and
11613 finalization (analogous to the constructors and destructors of C++)
11615 @item Ada.Interrupts (C.3.2)
11616 This package provides facilities for interfacing to interrupts, which
11617 includes the set of signals or conditions that can be raised and
11618 recognized as interrupts.
11620 @item Ada.Interrupts.Names (C.3.2)
11621 This package provides the set of interrupt names (actually signal
11622 or condition names) that can be handled by GNAT@.
11624 @item Ada.IO_Exceptions (A.13)
11625 This package defines the set of exceptions that can be raised by use of
11626 the standard IO packages.
11628 @item Ada.Numerics
11629 This package contains some standard constants and exceptions used
11630 throughout the numerics packages.  Note that the constants pi and e are
11631 defined here, and it is better to use these definitions than rolling
11632 your own.
11634 @item Ada.Numerics.Complex_Elementary_Functions
11635 Provides the implementation of standard elementary functions (such as
11636 log and trigonometric functions) operating on complex numbers using the
11637 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11638 created by the package @code{Numerics.Complex_Types}.
11640 @item Ada.Numerics.Complex_Types
11641 This is a predefined instantiation of
11642 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11643 build the type @code{Complex} and @code{Imaginary}.
11645 @item Ada.Numerics.Discrete_Random
11646 This package provides a random number generator suitable for generating
11647 random integer values from a specified range.
11649 @item Ada.Numerics.Float_Random
11650 This package provides a random number generator suitable for generating
11651 uniformly distributed floating point values.
11653 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11654 This is a generic version of the package that provides the
11655 implementation of standard elementary functions (such as log and
11656 trigonometric functions) for an arbitrary complex type.
11658 The following predefined instantiations of this package are provided:
11660 @table @code
11661 @item Short_Float
11662 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11663 @item Float
11664 @code{Ada.Numerics.Complex_Elementary_Functions}
11665 @item Long_Float
11666 @code{Ada.Numerics.
11667  Long_Complex_Elementary_Functions}
11668 @end table
11670 @item Ada.Numerics.Generic_Complex_Types
11671 This is a generic package that allows the creation of complex types,
11672 with associated complex arithmetic operations.
11674 The following predefined instantiations of this package exist
11675 @table @code
11676 @item Short_Float
11677 @code{Ada.Numerics.Short_Complex_Complex_Types}
11678 @item Float
11679 @code{Ada.Numerics.Complex_Complex_Types}
11680 @item Long_Float
11681 @code{Ada.Numerics.Long_Complex_Complex_Types}
11682 @end table
11684 @item Ada.Numerics.Generic_Elementary_Functions
11685 This is a generic package that provides the implementation of standard
11686 elementary functions (such as log an trigonometric functions) for an
11687 arbitrary float type.
11689 The following predefined instantiations of this package exist
11691 @table @code
11692 @item Short_Float
11693 @code{Ada.Numerics.Short_Elementary_Functions}
11694 @item Float
11695 @code{Ada.Numerics.Elementary_Functions}
11696 @item Long_Float
11697 @code{Ada.Numerics.Long_Elementary_Functions}
11698 @end table
11700 @item Ada.Real_Time (D.8)
11701 This package provides facilities similar to those of @code{Calendar}, but
11702 operating with a finer clock suitable for real time control. Note that
11703 annex D requires that there be no backward clock jumps, and GNAT generally
11704 guarantees this behavior, but of course if the external clock on which
11705 the GNAT runtime depends is deliberately reset by some external event,
11706 then such a backward jump may occur.
11708 @item Ada.Sequential_IO (A.8.1)
11709 This package provides input-output facilities for sequential files,
11710 which can contain a sequence of values of a single type, which can be
11711 any Ada type, including indefinite (unconstrained) types.
11713 @item Ada.Storage_IO (A.9)
11714 This package provides a facility for mapping arbitrary Ada types to and
11715 from a storage buffer.  It is primarily intended for the creation of new
11716 IO packages.
11718 @item Ada.Streams (13.13.1)
11719 This is a generic package that provides the basic support for the
11720 concept of streams as used by the stream attributes (@code{Input},
11721 @code{Output}, @code{Read} and @code{Write}).
11723 @item Ada.Streams.Stream_IO (A.12.1)
11724 This package is a specialization of the type @code{Streams} defined in
11725 package @code{Streams} together with a set of operations providing
11726 Stream_IO capability.  The Stream_IO model permits both random and
11727 sequential access to a file which can contain an arbitrary set of values
11728 of one or more Ada types.
11730 @item Ada.Strings (A.4.1)
11731 This package provides some basic constants used by the string handling
11732 packages.
11734 @item Ada.Strings.Bounded (A.4.4)
11735 This package provides facilities for handling variable length
11736 strings.  The bounded model requires a maximum length.  It is thus
11737 somewhat more limited than the unbounded model, but avoids the use of
11738 dynamic allocation or finalization.
11740 @item Ada.Strings.Fixed (A.4.3)
11741 This package provides facilities for handling fixed length strings.
11743 @item Ada.Strings.Maps (A.4.2)
11744 This package provides facilities for handling character mappings and
11745 arbitrarily defined subsets of characters.  For instance it is useful in
11746 defining specialized translation tables.
11748 @item Ada.Strings.Maps.Constants (A.4.6)
11749 This package provides a standard set of predefined mappings and
11750 predefined character sets.  For example, the standard upper to lower case
11751 conversion table is found in this package.  Note that upper to lower case
11752 conversion is non-trivial if you want to take the entire set of
11753 characters, including extended characters like E with an acute accent,
11754 into account.  You should use the mappings in this package (rather than
11755 adding 32 yourself) to do case mappings.
11757 @item Ada.Strings.Unbounded (A.4.5)
11758 This package provides facilities for handling variable length
11759 strings.  The unbounded model allows arbitrary length strings, but
11760 requires the use of dynamic allocation and finalization.
11762 @item Ada.Strings.Wide_Bounded (A.4.7)
11763 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11764 @itemx Ada.Strings.Wide_Maps (A.4.7)
11765 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11766 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11767 These packages provide analogous capabilities to the corresponding
11768 packages without @samp{Wide_} in the name, but operate with the types
11769 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11770 and @code{Character}.
11772 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11773 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11774 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11775 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11776 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11777 These packages provide analogous capabilities to the corresponding
11778 packages without @samp{Wide_} in the name, but operate with the types
11779 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11780 of @code{String} and @code{Character}.
11782 @item Ada.Synchronous_Task_Control (D.10)
11783 This package provides some standard facilities for controlling task
11784 communication in a synchronous manner.
11786 @item Ada.Tags
11787 This package contains definitions for manipulation of the tags of tagged
11788 values.
11790 @item Ada.Task_Attributes
11791 This package provides the capability of associating arbitrary
11792 task-specific data with separate tasks.
11794 @item Ada.Text_IO
11795 This package provides basic text input-output capabilities for
11796 character, string and numeric data.  The subpackages of this
11797 package are listed next.
11799 @item Ada.Text_IO.Decimal_IO
11800 Provides input-output facilities for decimal fixed-point types
11802 @item Ada.Text_IO.Enumeration_IO
11803 Provides input-output facilities for enumeration types.
11805 @item Ada.Text_IO.Fixed_IO
11806 Provides input-output facilities for ordinary fixed-point types.
11808 @item Ada.Text_IO.Float_IO
11809 Provides input-output facilities for float types.  The following
11810 predefined instantiations of this generic package are available:
11812 @table @code
11813 @item Short_Float
11814 @code{Short_Float_Text_IO}
11815 @item Float
11816 @code{Float_Text_IO}
11817 @item Long_Float
11818 @code{Long_Float_Text_IO}
11819 @end table
11821 @item Ada.Text_IO.Integer_IO
11822 Provides input-output facilities for integer types.  The following
11823 predefined instantiations of this generic package are available:
11825 @table @code
11826 @item Short_Short_Integer
11827 @code{Ada.Short_Short_Integer_Text_IO}
11828 @item Short_Integer
11829 @code{Ada.Short_Integer_Text_IO}
11830 @item Integer
11831 @code{Ada.Integer_Text_IO}
11832 @item Long_Integer
11833 @code{Ada.Long_Integer_Text_IO}
11834 @item Long_Long_Integer
11835 @code{Ada.Long_Long_Integer_Text_IO}
11836 @end table
11838 @item Ada.Text_IO.Modular_IO
11839 Provides input-output facilities for modular (unsigned) types
11841 @item Ada.Text_IO.Complex_IO (G.1.3)
11842 This package provides basic text input-output capabilities for complex
11843 data.
11845 @item Ada.Text_IO.Editing (F.3.3)
11846 This package contains routines for edited output, analogous to the use
11847 of pictures in COBOL@.  The picture formats used by this package are a
11848 close copy of the facility in COBOL@.
11850 @item Ada.Text_IO.Text_Streams (A.12.2)
11851 This package provides a facility that allows Text_IO files to be treated
11852 as streams, so that the stream attributes can be used for writing
11853 arbitrary data, including binary data, to Text_IO files.
11855 @item Ada.Unchecked_Conversion (13.9)
11856 This generic package allows arbitrary conversion from one type to
11857 another of the same size, providing for breaking the type safety in
11858 special circumstances.
11860 If the types have the same Size (more accurately the same Value_Size),
11861 then the effect is simply to transfer the bits from the source to the
11862 target type without any modification.  This usage is well defined, and
11863 for simple types whose representation is typically the same across
11864 all implementations, gives a portable method of performing such
11865 conversions.
11867 If the types do not have the same size, then the result is implementation
11868 defined, and thus may be non-portable.  The following describes how GNAT
11869 handles such unchecked conversion cases.
11871 If the types are of different sizes, and are both discrete types, then
11872 the effect is of a normal type conversion without any constraint checking.
11873 In particular if the result type has a larger size, the result will be
11874 zero or sign extended.  If the result type has a smaller size, the result
11875 will be truncated by ignoring high order bits.
11877 If the types are of different sizes, and are not both discrete types,
11878 then the conversion works as though pointers were created to the source
11879 and target, and the pointer value is converted.  The effect is that bits
11880 are copied from successive low order storage units and bits of the source
11881 up to the length of the target type.
11883 A warning is issued if the lengths differ, since the effect in this
11884 case is implementation dependent, and the above behavior may not match
11885 that of some other compiler.
11887 A pointer to one type may be converted to a pointer to another type using
11888 unchecked conversion.  The only case in which the effect is undefined is
11889 when one or both pointers are pointers to unconstrained array types.  In
11890 this case, the bounds information may get incorrectly transferred, and in
11891 particular, GNAT uses double size pointers for such types, and it is
11892 meaningless to convert between such pointer types.  GNAT will issue a
11893 warning if the alignment of the target designated type is more strict
11894 than the alignment of the source designated type (since the result may
11895 be unaligned in this case).
11897 A pointer other than a pointer to an unconstrained array type may be
11898 converted to and from System.Address.  Such usage is common in Ada 83
11899 programs, but note that Ada.Address_To_Access_Conversions is the
11900 preferred method of performing such conversions in Ada 95 and Ada 2005.
11901 Neither
11902 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11903 used in conjunction with pointers to unconstrained objects, since
11904 the bounds information cannot be handled correctly in this case.
11906 @item Ada.Unchecked_Deallocation (13.11.2)
11907 This generic package allows explicit freeing of storage previously
11908 allocated by use of an allocator.
11910 @item Ada.Wide_Text_IO (A.11)
11911 This package is similar to @code{Ada.Text_IO}, except that the external
11912 file supports wide character representations, and the internal types are
11913 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11914 and @code{String}.  It contains generic subpackages listed next.
11916 @item Ada.Wide_Text_IO.Decimal_IO
11917 Provides input-output facilities for decimal fixed-point types
11919 @item Ada.Wide_Text_IO.Enumeration_IO
11920 Provides input-output facilities for enumeration types.
11922 @item Ada.Wide_Text_IO.Fixed_IO
11923 Provides input-output facilities for ordinary fixed-point types.
11925 @item Ada.Wide_Text_IO.Float_IO
11926 Provides input-output facilities for float types.  The following
11927 predefined instantiations of this generic package are available:
11929 @table @code
11930 @item Short_Float
11931 @code{Short_Float_Wide_Text_IO}
11932 @item Float
11933 @code{Float_Wide_Text_IO}
11934 @item Long_Float
11935 @code{Long_Float_Wide_Text_IO}
11936 @end table
11938 @item Ada.Wide_Text_IO.Integer_IO
11939 Provides input-output facilities for integer types.  The following
11940 predefined instantiations of this generic package are available:
11942 @table @code
11943 @item Short_Short_Integer
11944 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11945 @item Short_Integer
11946 @code{Ada.Short_Integer_Wide_Text_IO}
11947 @item Integer
11948 @code{Ada.Integer_Wide_Text_IO}
11949 @item Long_Integer
11950 @code{Ada.Long_Integer_Wide_Text_IO}
11951 @item Long_Long_Integer
11952 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11953 @end table
11955 @item Ada.Wide_Text_IO.Modular_IO
11956 Provides input-output facilities for modular (unsigned) types
11958 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11959 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11960 external file supports wide character representations.
11962 @item Ada.Wide_Text_IO.Editing (F.3.4)
11963 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11964 types are @code{Wide_Character} and @code{Wide_String} instead of
11965 @code{Character} and @code{String}.
11967 @item Ada.Wide_Text_IO.Streams (A.12.3)
11968 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11969 types are @code{Wide_Character} and @code{Wide_String} instead of
11970 @code{Character} and @code{String}.
11972 @item Ada.Wide_Wide_Text_IO (A.11)
11973 This package is similar to @code{Ada.Text_IO}, except that the external
11974 file supports wide character representations, and the internal types are
11975 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11976 and @code{String}.  It contains generic subpackages listed next.
11978 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11979 Provides input-output facilities for decimal fixed-point types
11981 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11982 Provides input-output facilities for enumeration types.
11984 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11985 Provides input-output facilities for ordinary fixed-point types.
11987 @item Ada.Wide_Wide_Text_IO.Float_IO
11988 Provides input-output facilities for float types.  The following
11989 predefined instantiations of this generic package are available:
11991 @table @code
11992 @item Short_Float
11993 @code{Short_Float_Wide_Wide_Text_IO}
11994 @item Float
11995 @code{Float_Wide_Wide_Text_IO}
11996 @item Long_Float
11997 @code{Long_Float_Wide_Wide_Text_IO}
11998 @end table
12000 @item Ada.Wide_Wide_Text_IO.Integer_IO
12001 Provides input-output facilities for integer types.  The following
12002 predefined instantiations of this generic package are available:
12004 @table @code
12005 @item Short_Short_Integer
12006 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12007 @item Short_Integer
12008 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12009 @item Integer
12010 @code{Ada.Integer_Wide_Wide_Text_IO}
12011 @item Long_Integer
12012 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12013 @item Long_Long_Integer
12014 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12015 @end table
12017 @item Ada.Wide_Wide_Text_IO.Modular_IO
12018 Provides input-output facilities for modular (unsigned) types
12020 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12021 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12022 external file supports wide character representations.
12024 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12025 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12026 types are @code{Wide_Character} and @code{Wide_String} instead of
12027 @code{Character} and @code{String}.
12029 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12030 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12031 types are @code{Wide_Character} and @code{Wide_String} instead of
12032 @code{Character} and @code{String}.
12033 @end table
12037 @node The Implementation of Standard I/O
12038 @chapter The Implementation of Standard I/O
12040 @noindent
12041 GNAT implements all the required input-output facilities described in
12042 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12043 required behavior of these packages from the Ada point of view, and if
12044 you are writing a portable Ada program that does not need to know the
12045 exact manner in which Ada maps to the outside world when it comes to
12046 reading or writing external files, then you do not need to read this
12047 chapter.  As long as your files are all regular files (not pipes or
12048 devices), and as long as you write and read the files only from Ada, the
12049 description in the Ada Reference Manual is sufficient.
12051 However, if you want to do input-output to pipes or other devices, such
12052 as the keyboard or screen, or if the files you are dealing with are
12053 either generated by some other language, or to be read by some other
12054 language, then you need to know more about the details of how the GNAT
12055 implementation of these input-output facilities behaves.
12057 In this chapter we give a detailed description of exactly how GNAT
12058 interfaces to the file system.  As always, the sources of the system are
12059 available to you for answering questions at an even more detailed level,
12060 but for most purposes the information in this chapter will suffice.
12062 Another reason that you may need to know more about how input-output is
12063 implemented arises when you have a program written in mixed languages
12064 where, for example, files are shared between the C and Ada sections of
12065 the same program.  GNAT provides some additional facilities, in the form
12066 of additional child library packages, that facilitate this sharing, and
12067 these additional facilities are also described in this chapter.
12069 @menu
12070 * Standard I/O Packages::
12071 * FORM Strings::
12072 * Direct_IO::
12073 * Sequential_IO::
12074 * Text_IO::
12075 * Wide_Text_IO::
12076 * Wide_Wide_Text_IO::
12077 * Stream_IO::
12078 * Shared Files::
12079 * Filenames encoding::
12080 * Open Modes::
12081 * Operations on C Streams::
12082 * Interfacing to C Streams::
12083 @end menu
12085 @node Standard I/O Packages
12086 @section Standard I/O Packages
12088 @noindent
12089 The Standard I/O packages described in Annex A for
12091 @itemize @bullet
12092 @item
12093 Ada.Text_IO
12094 @item
12095 Ada.Text_IO.Complex_IO
12096 @item
12097 Ada.Text_IO.Text_Streams
12098 @item
12099 Ada.Wide_Text_IO
12100 @item
12101 Ada.Wide_Text_IO.Complex_IO
12102 @item
12103 Ada.Wide_Text_IO.Text_Streams
12104 @item
12105 Ada.Wide_Wide_Text_IO
12106 @item
12107 Ada.Wide_Wide_Text_IO.Complex_IO
12108 @item
12109 Ada.Wide_Wide_Text_IO.Text_Streams
12110 @item
12111 Ada.Stream_IO
12112 @item
12113 Ada.Sequential_IO
12114 @item
12115 Ada.Direct_IO
12116 @end itemize
12118 @noindent
12119 are implemented using the C
12120 library streams facility; where
12122 @itemize @bullet
12123 @item
12124 All files are opened using @code{fopen}.
12125 @item
12126 All input/output operations use @code{fread}/@code{fwrite}.
12127 @end itemize
12129 @noindent
12130 There is no internal buffering of any kind at the Ada library level. The only
12131 buffering is that provided at the system level in the implementation of the
12132 library routines that support streams. This facilitates shared use of these
12133 streams by mixed language programs. Note though that system level buffering is
12134 explicitly enabled at elaboration of the standard I/O packages and that can
12135 have an impact on mixed language programs, in particular those using I/O before
12136 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12137 the Ada elaboration routine before performing any I/O or when impractical,
12138 flush the common I/O streams and in particular Standard_Output before
12139 elaborating the Ada code.
12141 @node FORM Strings
12142 @section FORM Strings
12144 @noindent
12145 The format of a FORM string in GNAT is:
12147 @smallexample
12148 "keyword=value,keyword=value,@dots{},keyword=value"
12149 @end smallexample
12151 @noindent
12152 where letters may be in upper or lower case, and there are no spaces
12153 between values.  The order of the entries is not important.  Currently
12154 there are two keywords defined.
12156 @smallexample
12157 SHARED=[YES|NO]
12158 WCEM=[n|h|u|s|e|8|b]
12159 @end smallexample
12161 @noindent
12162 The use of these parameters is described later in this section.
12164 @node Direct_IO
12165 @section Direct_IO
12167 @noindent
12168 Direct_IO can only be instantiated for definite types.  This is a
12169 restriction of the Ada language, which means that the records are fixed
12170 length (the length being determined by @code{@var{type}'Size}, rounded
12171 up to the next storage unit boundary if necessary).
12173 The records of a Direct_IO file are simply written to the file in index
12174 sequence, with the first record starting at offset zero, and subsequent
12175 records following.  There is no control information of any kind.  For
12176 example, if 32-bit integers are being written, each record takes
12177 4-bytes, so the record at index @var{K} starts at offset
12178 (@var{K}@minus{}1)*4.
12180 There is no limit on the size of Direct_IO files, they are expanded as
12181 necessary to accommodate whatever records are written to the file.
12183 @node Sequential_IO
12184 @section Sequential_IO
12186 @noindent
12187 Sequential_IO may be instantiated with either a definite (constrained)
12188 or indefinite (unconstrained) type.
12190 For the definite type case, the elements written to the file are simply
12191 the memory images of the data values with no control information of any
12192 kind.  The resulting file should be read using the same type, no validity
12193 checking is performed on input.
12195 For the indefinite type case, the elements written consist of two
12196 parts.  First is the size of the data item, written as the memory image
12197 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12198 the data value.  The resulting file can only be read using the same
12199 (unconstrained) type.  Normal assignment checks are performed on these
12200 read operations, and if these checks fail, @code{Data_Error} is
12201 raised.  In particular, in the array case, the lengths must match, and in
12202 the variant record case, if the variable for a particular read operation
12203 is constrained, the discriminants must match.
12205 Note that it is not possible to use Sequential_IO to write variable
12206 length array items, and then read the data back into different length
12207 arrays.  For example, the following will raise @code{Data_Error}:
12209 @smallexample @c ada
12210  package IO is new Sequential_IO (String);
12211  F : IO.File_Type;
12212  S : String (1..4);
12213  @dots{}
12214  IO.Create (F)
12215  IO.Write (F, "hello!")
12216  IO.Reset (F, Mode=>In_File);
12217  IO.Read (F, S);
12218  Put_Line (S);
12220 @end smallexample
12222 @noindent
12223 On some Ada implementations, this will print @code{hell}, but the program is
12224 clearly incorrect, since there is only one element in the file, and that
12225 element is the string @code{hello!}.
12227 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12228 using Stream_IO, and this is the preferred mechanism.  In particular, the
12229 above program fragment rewritten to use Stream_IO will work correctly.
12231 @node Text_IO
12232 @section Text_IO
12234 @noindent
12235 Text_IO files consist of a stream of characters containing the following
12236 special control characters:
12238 @smallexample
12239 LF (line feed, 16#0A#) Line Mark
12240 FF (form feed, 16#0C#) Page Mark
12241 @end smallexample
12243 @noindent
12244 A canonical Text_IO file is defined as one in which the following
12245 conditions are met:
12247 @itemize @bullet
12248 @item
12249 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12250 of the line.
12252 @item
12253 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12254 end of a page and consequently can appear only immediately following a
12255 @code{LF} (line mark) character.
12257 @item
12258 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12259 (line mark, page mark).  In the former case, the page mark is implicitly
12260 assumed to be present.
12261 @end itemize
12263 @noindent
12264 A file written using Text_IO will be in canonical form provided that no
12265 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12266 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12267 the file unless an explicit @code{New_Page} operation was performed
12268 before closing the file.
12270 A canonical Text_IO file that is a regular file (i.e., not a device or a
12271 pipe) can be read using any of the routines in Text_IO@.  The
12272 semantics in this case will be exactly as defined in the Ada Reference
12273 Manual, and all the routines in Text_IO are fully implemented.
12275 A text file that does not meet the requirements for a canonical Text_IO
12276 file has one of the following:
12278 @itemize @bullet
12279 @item
12280 The file contains @code{FF} characters not immediately following a
12281 @code{LF} character.
12283 @item
12284 The file contains @code{LF} or @code{FF} characters written by
12285 @code{Put} or @code{Put_Line}, which are not logically considered to be
12286 line marks or page marks.
12288 @item
12289 The file ends in a character other than @code{LF} or @code{FF},
12290 i.e.@: there is no explicit line mark or page mark at the end of the file.
12291 @end itemize
12293 @noindent
12294 Text_IO can be used to read such non-standard text files but subprograms
12295 to do with line or page numbers do not have defined meanings.  In
12296 particular, a @code{FF} character that does not follow a @code{LF}
12297 character may or may not be treated as a page mark from the point of
12298 view of page and line numbering.  Every @code{LF} character is considered
12299 to end a line, and there is an implied @code{LF} character at the end of
12300 the file.
12302 @menu
12303 * Text_IO Stream Pointer Positioning::
12304 * Text_IO Reading and Writing Non-Regular Files::
12305 * Get_Immediate::
12306 * Treating Text_IO Files as Streams::
12307 * Text_IO Extensions::
12308 * Text_IO Facilities for Unbounded Strings::
12309 @end menu
12311 @node Text_IO Stream Pointer Positioning
12312 @subsection Stream Pointer Positioning
12314 @noindent
12315 @code{Ada.Text_IO} has a definition of current position for a file that
12316 is being read.  No internal buffering occurs in Text_IO, and usually the
12317 physical position in the stream used to implement the file corresponds
12318 to this logical position defined by Text_IO@.  There are two exceptions:
12320 @itemize @bullet
12321 @item
12322 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12323 is positioned past the @code{LF} (line mark) that precedes the page
12324 mark.  Text_IO maintains an internal flag so that subsequent read
12325 operations properly handle the logical position which is unchanged by
12326 the @code{End_Of_Page} call.
12328 @item
12329 After a call to @code{End_Of_File} that returns @code{True}, if the
12330 Text_IO file was positioned before the line mark at the end of file
12331 before the call, then the logical position is unchanged, but the stream
12332 is physically positioned right at the end of file (past the line mark,
12333 and past a possible page mark following the line mark.  Again Text_IO
12334 maintains internal flags so that subsequent read operations properly
12335 handle the logical position.
12336 @end itemize
12338 @noindent
12339 These discrepancies have no effect on the observable behavior of
12340 Text_IO, but if a single Ada stream is shared between a C program and
12341 Ada program, or shared (using @samp{shared=yes} in the form string)
12342 between two Ada files, then the difference may be observable in some
12343 situations.
12345 @node Text_IO Reading and Writing Non-Regular Files
12346 @subsection Reading and Writing Non-Regular Files
12348 @noindent
12349 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12350 can be used for reading and writing.  Writing is not affected and the
12351 sequence of characters output is identical to the normal file case, but
12352 for reading, the behavior of Text_IO is modified to avoid undesirable
12353 look-ahead as follows:
12355 An input file that is not a regular file is considered to have no page
12356 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12357 page mark) appearing in the file are considered to be data
12358 characters.  In particular:
12360 @itemize @bullet
12361 @item
12362 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12363 following a line mark.  If a page mark appears, it will be treated as a
12364 data character.
12366 @item
12367 This avoids the need to wait for an extra character to be typed or
12368 entered from the pipe to complete one of these operations.
12370 @item
12371 @code{End_Of_Page} always returns @code{False}
12373 @item
12374 @code{End_Of_File} will return @code{False} if there is a page mark at
12375 the end of the file.
12376 @end itemize
12378 @noindent
12379 Output to non-regular files is the same as for regular files.  Page marks
12380 may be written to non-regular files using @code{New_Page}, but as noted
12381 above they will not be treated as page marks on input if the output is
12382 piped to another Ada program.
12384 Another important discrepancy when reading non-regular files is that the end
12385 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12386 pressing the @key{EOT} key,
12387 then end of file
12388 is signaled once (i.e.@: the test @code{End_Of_File}
12389 will yield @code{True}, or a read will
12390 raise @code{End_Error}), but then reading can resume
12391 to read data past that end of
12392 file indication, until another end of file indication is entered.
12394 @node Get_Immediate
12395 @subsection Get_Immediate
12396 @cindex Get_Immediate
12398 @noindent
12399 Get_Immediate returns the next character (including control characters)
12400 from the input file.  In particular, Get_Immediate will return LF or FF
12401 characters used as line marks or page marks.  Such operations leave the
12402 file positioned past the control character, and it is thus not treated
12403 as having its normal function.  This means that page, line and column
12404 counts after this kind of Get_Immediate call are set as though the mark
12405 did not occur.  In the case where a Get_Immediate leaves the file
12406 positioned between the line mark and page mark (which is not normally
12407 possible), it is undefined whether the FF character will be treated as a
12408 page mark.
12410 @node Treating Text_IO Files as Streams
12411 @subsection Treating Text_IO Files as Streams
12412 @cindex Stream files
12414 @noindent
12415 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12416 as a stream.  Data written to a Text_IO file in this stream mode is
12417 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12418 16#0C# (@code{FF}), the resulting file may have non-standard
12419 format.  Similarly if read operations are used to read from a Text_IO
12420 file treated as a stream, then @code{LF} and @code{FF} characters may be
12421 skipped and the effect is similar to that described above for
12422 @code{Get_Immediate}.
12424 @node Text_IO Extensions
12425 @subsection Text_IO Extensions
12426 @cindex Text_IO extensions
12428 @noindent
12429 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12430 to the standard @code{Text_IO} package:
12432 @itemize @bullet
12433 @item function File_Exists (Name : String) return Boolean;
12434 Determines if a file of the given name exists.
12436 @item function Get_Line return String;
12437 Reads a string from the standard input file.  The value returned is exactly
12438 the length of the line that was read.
12440 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12441 Similar, except that the parameter File specifies the file from which
12442 the string is to be read.
12444 @end itemize
12446 @node Text_IO Facilities for Unbounded Strings
12447 @subsection Text_IO Facilities for Unbounded Strings
12448 @cindex Text_IO for unbounded strings
12449 @cindex Unbounded_String, Text_IO operations
12451 @noindent
12452 The package @code{Ada.Strings.Unbounded.Text_IO}
12453 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12454 subprograms useful for Text_IO operations on unbounded strings:
12456 @itemize @bullet
12458 @item function Get_Line (File : File_Type) return Unbounded_String;
12459 Reads a line from the specified file
12460 and returns the result as an unbounded string.
12462 @item procedure Put (File : File_Type; U : Unbounded_String);
12463 Writes the value of the given unbounded string to the specified file
12464 Similar to the effect of
12465 @code{Put (To_String (U))} except that an extra copy is avoided.
12467 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12468 Writes the value of the given unbounded string to the specified file,
12469 followed by a @code{New_Line}.
12470 Similar to the effect of @code{Put_Line (To_String (U))} except
12471 that an extra copy is avoided.
12472 @end itemize
12474 @noindent
12475 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12476 and is optional.  If the parameter is omitted, then the standard input or
12477 output file is referenced as appropriate.
12479 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12480 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12481 @code{Wide_Text_IO} functionality for unbounded wide strings.
12483 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12484 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12485 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12487 @node Wide_Text_IO
12488 @section Wide_Text_IO
12490 @noindent
12491 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12492 both input and output files may contain special sequences that represent
12493 wide character values.  The encoding scheme for a given file may be
12494 specified using a FORM parameter:
12496 @smallexample
12497 WCEM=@var{x}
12498 @end smallexample
12500 @noindent
12501 as part of the FORM string (WCEM = wide character encoding method),
12502 where @var{x} is one of the following characters
12504 @table @samp
12505 @item h
12506 Hex ESC encoding
12507 @item u
12508 Upper half encoding
12509 @item s
12510 Shift-JIS encoding
12511 @item e
12512 EUC Encoding
12513 @item 8
12514 UTF-8 encoding
12515 @item b
12516 Brackets encoding
12517 @end table
12519 @noindent
12520 The encoding methods match those that
12521 can be used in a source
12522 program, but there is no requirement that the encoding method used for
12523 the source program be the same as the encoding method used for files,
12524 and different files may use different encoding methods.
12526 The default encoding method for the standard files, and for opened files
12527 for which no WCEM parameter is given in the FORM string matches the
12528 wide character encoding specified for the main program (the default
12529 being brackets encoding if no coding method was specified with -gnatW).
12531 @table @asis
12532 @item Hex Coding
12533 In this encoding, a wide character is represented by a five character
12534 sequence:
12536 @smallexample
12537 ESC a b c d
12538 @end smallexample
12540 @noindent
12541 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12542 characters (using upper case letters) of the wide character code.  For
12543 example, ESC A345 is used to represent the wide character with code
12544 16#A345#.  This scheme is compatible with use of the full
12545 @code{Wide_Character} set.
12547 @item Upper Half Coding
12548 The wide character with encoding 16#abcd#, where the upper bit is on
12549 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12550 16#cd#.  The second byte may never be a format control character, but is
12551 not required to be in the upper half.  This method can be also used for
12552 shift-JIS or EUC where the internal coding matches the external coding.
12554 @item Shift JIS Coding
12555 A wide character is represented by a two character sequence 16#ab# and
12556 16#cd#, with the restrictions described for upper half encoding as
12557 described above.  The internal character code is the corresponding JIS
12558 character according to the standard algorithm for Shift-JIS
12559 conversion.  Only characters defined in the JIS code set table can be
12560 used with this encoding method.
12562 @item EUC Coding
12563 A wide character is represented by a two character sequence 16#ab# and
12564 16#cd#, with both characters being in the upper half.  The internal
12565 character code is the corresponding JIS character according to the EUC
12566 encoding algorithm.  Only characters defined in the JIS code set table
12567 can be used with this encoding method.
12569 @item UTF-8 Coding
12570 A wide character is represented using
12571 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12572 10646-1/Am.2.  Depending on the character value, the representation
12573 is a one, two, or three byte sequence:
12575 @smallexample
12576 16#0000#-16#007f#: 2#0xxxxxxx#
12577 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12578 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12579 @end smallexample
12581 @noindent
12582 where the @var{xxx} bits correspond to the left-padded bits of the
12583 16-bit character value.  Note that all lower half ASCII characters
12584 are represented as ASCII bytes and all upper half characters and
12585 other wide characters are represented as sequences of upper-half
12586 (The full UTF-8 scheme allows for encoding 31-bit characters as
12587 6-byte sequences, but in this implementation, all UTF-8 sequences
12588 of four or more bytes length will raise a Constraint_Error, as
12589 will all invalid UTF-8 sequences.)
12591 @item Brackets Coding
12592 In this encoding, a wide character is represented by the following eight
12593 character sequence:
12595 @smallexample
12596 [ " a b c d " ]
12597 @end smallexample
12599 @noindent
12600 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12601 characters (using uppercase letters) of the wide character code.  For
12602 example, @code{["A345"]} is used to represent the wide character with code
12603 @code{16#A345#}.
12604 This scheme is compatible with use of the full Wide_Character set.
12605 On input, brackets coding can also be used for upper half characters,
12606 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12607 is only used for wide characters with a code greater than @code{16#FF#}.
12609 Note that brackets coding is not normally used in the context of
12610 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12611 a portable way of encoding source files. In the context of Wide_Text_IO
12612 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12613 any instance of the left bracket character other than to encode wide
12614 character values using the brackets encoding method. In practice it is
12615 expected that some standard wide character encoding method such
12616 as UTF-8 will be used for text input output.
12618 If brackets notation is used, then any occurrence of a left bracket
12619 in the input file which is not the start of a valid wide character
12620 sequence will cause Constraint_Error to be raised. It is possible to
12621 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12622 input will interpret this as a left bracket.
12624 However, when a left bracket is output, it will be output as a left bracket
12625 and not as ["5B"]. We make this decision because for normal use of
12626 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12627 brackets. For example, if we write:
12629 @smallexample
12630    Put_Line ("Start of output [first run]");
12631 @end smallexample
12633 @noindent
12634 we really do not want to have the left bracket in this message clobbered so
12635 that the output reads:
12637 @smallexample
12638    Start of output ["5B"]first run]
12639 @end smallexample
12641 @noindent
12642 In practice brackets encoding is reasonably useful for normal Put_Line use
12643 since we won't get confused between left brackets and wide character
12644 sequences in the output. But for input, or when files are written out
12645 and read back in, it really makes better sense to use one of the standard
12646 encoding methods such as UTF-8.
12648 @end table
12650 @noindent
12651 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12652 not all wide character
12653 values can be represented.  An attempt to output a character that cannot
12654 be represented using the encoding scheme for the file causes
12655 Constraint_Error to be raised.  An invalid wide character sequence on
12656 input also causes Constraint_Error to be raised.
12658 @menu
12659 * Wide_Text_IO Stream Pointer Positioning::
12660 * Wide_Text_IO Reading and Writing Non-Regular Files::
12661 @end menu
12663 @node Wide_Text_IO Stream Pointer Positioning
12664 @subsection Stream Pointer Positioning
12666 @noindent
12667 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12668 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12669 case:
12671 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12672 normal lower ASCII set (i.e.@: a character in the range:
12674 @smallexample @c ada
12675 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12676 @end smallexample
12678 @noindent
12679 then although the logical position of the file pointer is unchanged by
12680 the @code{Look_Ahead} call, the stream is physically positioned past the
12681 wide character sequence.  Again this is to avoid the need for buffering
12682 or backup, and all @code{Wide_Text_IO} routines check the internal
12683 indication that this situation has occurred so that this is not visible
12684 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12685 can be observed if the wide text file shares a stream with another file.
12687 @node Wide_Text_IO Reading and Writing Non-Regular Files
12688 @subsection Reading and Writing Non-Regular Files
12690 @noindent
12691 As in the case of Text_IO, when a non-regular file is read, it is
12692 assumed that the file contains no page marks (any form characters are
12693 treated as data characters), and @code{End_Of_Page} always returns
12694 @code{False}.  Similarly, the end of file indication is not sticky, so
12695 it is possible to read beyond an end of file.
12697 @node Wide_Wide_Text_IO
12698 @section Wide_Wide_Text_IO
12700 @noindent
12701 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12702 both input and output files may contain special sequences that represent
12703 wide wide character values.  The encoding scheme for a given file may be
12704 specified using a FORM parameter:
12706 @smallexample
12707 WCEM=@var{x}
12708 @end smallexample
12710 @noindent
12711 as part of the FORM string (WCEM = wide character encoding method),
12712 where @var{x} is one of the following characters
12714 @table @samp
12715 @item h
12716 Hex ESC encoding
12717 @item u
12718 Upper half encoding
12719 @item s
12720 Shift-JIS encoding
12721 @item e
12722 EUC Encoding
12723 @item 8
12724 UTF-8 encoding
12725 @item b
12726 Brackets encoding
12727 @end table
12729 @noindent
12730 The encoding methods match those that
12731 can be used in a source
12732 program, but there is no requirement that the encoding method used for
12733 the source program be the same as the encoding method used for files,
12734 and different files may use different encoding methods.
12736 The default encoding method for the standard files, and for opened files
12737 for which no WCEM parameter is given in the FORM string matches the
12738 wide character encoding specified for the main program (the default
12739 being brackets encoding if no coding method was specified with -gnatW).
12741 @table @asis
12743 @item UTF-8 Coding
12744 A wide character is represented using
12745 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12746 10646-1/Am.2.  Depending on the character value, the representation
12747 is a one, two, three, or four byte sequence:
12749 @smallexample
12750 16#000000#-16#00007f#: 2#0xxxxxxx#
12751 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12752 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12753 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12754 @end smallexample
12756 @noindent
12757 where the @var{xxx} bits correspond to the left-padded bits of the
12758 21-bit character value.  Note that all lower half ASCII characters
12759 are represented as ASCII bytes and all upper half characters and
12760 other wide characters are represented as sequences of upper-half
12761 characters.
12763 @item Brackets Coding
12764 In this encoding, a wide wide character is represented by the following eight
12765 character sequence if is in wide character range
12767 @smallexample
12768 [ " a b c d " ]
12769 @end smallexample
12771 and by the following ten character sequence if not
12773 @smallexample
12774 [ " a b c d e f " ]
12775 @end smallexample
12777 @noindent
12778 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12779 are the four or six hexadecimal
12780 characters (using uppercase letters) of the wide wide character code.  For
12781 example, @code{["01A345"]} is used to represent the wide wide character
12782 with code @code{16#01A345#}.
12784 This scheme is compatible with use of the full Wide_Wide_Character set.
12785 On input, brackets coding can also be used for upper half characters,
12786 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12787 is only used for wide characters with a code greater than @code{16#FF#}.
12789 @end table
12791 @noindent
12792 If is also possible to use the other Wide_Character encoding methods,
12793 such as Shift-JIS, but the other schemes cannot support the full range
12794 of wide wide characters.
12795 An attempt to output a character that cannot
12796 be represented using the encoding scheme for the file causes
12797 Constraint_Error to be raised.  An invalid wide character sequence on
12798 input also causes Constraint_Error to be raised.
12800 @menu
12801 * Wide_Wide_Text_IO Stream Pointer Positioning::
12802 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12803 @end menu
12805 @node Wide_Wide_Text_IO Stream Pointer Positioning
12806 @subsection Stream Pointer Positioning
12808 @noindent
12809 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12810 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12811 case:
12813 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12814 normal lower ASCII set (i.e.@: a character in the range:
12816 @smallexample @c ada
12817 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12818 @end smallexample
12820 @noindent
12821 then although the logical position of the file pointer is unchanged by
12822 the @code{Look_Ahead} call, the stream is physically positioned past the
12823 wide character sequence.  Again this is to avoid the need for buffering
12824 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12825 indication that this situation has occurred so that this is not visible
12826 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12827 can be observed if the wide text file shares a stream with another file.
12829 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12830 @subsection Reading and Writing Non-Regular Files
12832 @noindent
12833 As in the case of Text_IO, when a non-regular file is read, it is
12834 assumed that the file contains no page marks (any form characters are
12835 treated as data characters), and @code{End_Of_Page} always returns
12836 @code{False}.  Similarly, the end of file indication is not sticky, so
12837 it is possible to read beyond an end of file.
12839 @node Stream_IO
12840 @section Stream_IO
12842 @noindent
12843 A stream file is a sequence of bytes, where individual elements are
12844 written to the file as described in the Ada Reference Manual.  The type
12845 @code{Stream_Element} is simply a byte.  There are two ways to read or
12846 write a stream file.
12848 @itemize @bullet
12849 @item
12850 The operations @code{Read} and @code{Write} directly read or write a
12851 sequence of stream elements with no control information.
12853 @item
12854 The stream attributes applied to a stream file transfer data in the
12855 manner described for stream attributes.
12856 @end itemize
12858 @node Shared Files
12859 @section Shared Files
12861 @noindent
12862 Section A.14 of the Ada Reference Manual allows implementations to
12863 provide a wide variety of behavior if an attempt is made to access the
12864 same external file with two or more internal files.
12866 To provide a full range of functionality, while at the same time
12867 minimizing the problems of portability caused by this implementation
12868 dependence, GNAT handles file sharing as follows:
12870 @itemize @bullet
12871 @item
12872 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12873 to open two or more files with the same full name is considered an error
12874 and is not supported.  The exception @code{Use_Error} will be
12875 raised.  Note that a file that is not explicitly closed by the program
12876 remains open until the program terminates.
12878 @item
12879 If the form parameter @samp{shared=no} appears in the form string, the
12880 file can be opened or created with its own separate stream identifier,
12881 regardless of whether other files sharing the same external file are
12882 opened.  The exact effect depends on how the C stream routines handle
12883 multiple accesses to the same external files using separate streams.
12885 @item
12886 If the form parameter @samp{shared=yes} appears in the form string for
12887 each of two or more files opened using the same full name, the same
12888 stream is shared between these files, and the semantics are as described
12889 in Ada Reference Manual, Section A.14.
12890 @end itemize
12892 @noindent
12893 When a program that opens multiple files with the same name is ported
12894 from another Ada compiler to GNAT, the effect will be that
12895 @code{Use_Error} is raised.
12897 The documentation of the original compiler and the documentation of the
12898 program should then be examined to determine if file sharing was
12899 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12900 and @code{Create} calls as required.
12902 When a program is ported from GNAT to some other Ada compiler, no
12903 special attention is required unless the @samp{shared=@var{xxx}} form
12904 parameter is used in the program.  In this case, you must examine the
12905 documentation of the new compiler to see if it supports the required
12906 file sharing semantics, and form strings modified appropriately.  Of
12907 course it may be the case that the program cannot be ported if the
12908 target compiler does not support the required functionality.  The best
12909 approach in writing portable code is to avoid file sharing (and hence
12910 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12911 completely.
12913 One common use of file sharing in Ada 83 is the use of instantiations of
12914 Sequential_IO on the same file with different types, to achieve
12915 heterogeneous input-output.  Although this approach will work in GNAT if
12916 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12917 for this purpose (using the stream attributes)
12919 @node Filenames encoding
12920 @section Filenames encoding
12922 @noindent
12923 An encoding form parameter can be used to specify the filename
12924 encoding @samp{encoding=@var{xxx}}.
12926 @itemize @bullet
12927 @item
12928 If the form parameter @samp{encoding=utf8} appears in the form string, the
12929 filename must be encoded in UTF-8.
12931 @item
12932 If the form parameter @samp{encoding=8bits} appears in the form
12933 string, the filename must be a standard 8bits string.
12934 @end itemize
12936 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12937 value UTF-8 is used. This encoding form parameter is only supported on
12938 the Windows platform. On the other Operating Systems the runtime is
12939 supporting UTF-8 natively.
12941 @node Open Modes
12942 @section Open Modes
12944 @noindent
12945 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12946 using the mode shown in the following table:
12948 @sp 2
12949 @center @code{Open} and @code{Create} Call Modes
12950 @smallexample
12951                                @b{OPEN }           @b{CREATE}
12952 Append_File                    "r+"             "w+"
12953 In_File                        "r"              "w+"
12954 Out_File (Direct_IO)           "r+"             "w"
12955 Out_File (all other cases)     "w"              "w"
12956 Inout_File                     "r+"             "w+"
12957 @end smallexample
12959 @noindent
12960 If text file translation is required, then either @samp{b} or @samp{t}
12961 is added to the mode, depending on the setting of Text.  Text file
12962 translation refers to the mapping of CR/LF sequences in an external file
12963 to LF characters internally.  This mapping only occurs in DOS and
12964 DOS-like systems, and is not relevant to other systems.
12966 A special case occurs with Stream_IO@.  As shown in the above table, the
12967 file is initially opened in @samp{r} or @samp{w} mode for the
12968 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12969 subsequently requires switching from reading to writing or vice-versa,
12970 then the file is reopened in @samp{r+} mode to permit the required operation.
12972 @node Operations on C Streams
12973 @section Operations on C Streams
12974 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12975 access to the C library functions for operations on C streams:
12977 @smallexample @c adanocomment
12978 package Interfaces.C_Streams is
12979   -- Note: the reason we do not use the types that are in
12980   -- Interfaces.C is that we want to avoid dragging in the
12981   -- code in this unit if possible.
12982   subtype chars is System.Address;
12983   -- Pointer to null-terminated array of characters
12984   subtype FILEs is System.Address;
12985   -- Corresponds to the C type FILE*
12986   subtype voids is System.Address;
12987   -- Corresponds to the C type void*
12988   subtype int is Integer;
12989   subtype long is Long_Integer;
12990   -- Note: the above types are subtypes deliberately, and it
12991   -- is part of this spec that the above correspondences are
12992   -- guaranteed.  This means that it is legitimate to, for
12993   -- example, use Integer instead of int.  We provide these
12994   -- synonyms for clarity, but in some cases it may be
12995   -- convenient to use the underlying types (for example to
12996   -- avoid an unnecessary dependency of a spec on the spec
12997   -- of this unit).
12998   type size_t is mod 2 ** Standard'Address_Size;
12999   NULL_Stream : constant FILEs;
13000   -- Value returned (NULL in C) to indicate an
13001   -- fdopen/fopen/tmpfile error
13002   ----------------------------------
13003   -- Constants Defined in stdio.h --
13004   ----------------------------------
13005   EOF : constant int;
13006   -- Used by a number of routines to indicate error or
13007   -- end of file
13008   IOFBF : constant int;
13009   IOLBF : constant int;
13010   IONBF : constant int;
13011   -- Used to indicate buffering mode for setvbuf call
13012   SEEK_CUR : constant int;
13013   SEEK_END : constant int;
13014   SEEK_SET : constant int;
13015   -- Used to indicate origin for fseek call
13016   function stdin return FILEs;
13017   function stdout return FILEs;
13018   function stderr return FILEs;
13019   -- Streams associated with standard files
13020   --------------------------
13021   -- Standard C functions --
13022   --------------------------
13023   -- The functions selected below are ones that are
13024   -- available in DOS, OS/2, UNIX and Xenix (but not
13025   -- necessarily in ANSI C).  These are very thin interfaces
13026   -- which copy exactly the C headers.  For more
13027   -- documentation on these functions, see the Microsoft C
13028   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13029   -- ISBN 1-55615-225-6), which includes useful information
13030   -- on system compatibility.
13031   procedure clearerr (stream : FILEs);
13032   function fclose (stream : FILEs) return int;
13033   function fdopen (handle : int; mode : chars) return FILEs;
13034   function feof (stream : FILEs) return int;
13035   function ferror (stream : FILEs) return int;
13036   function fflush (stream : FILEs) return int;
13037   function fgetc (stream : FILEs) return int;
13038   function fgets (strng : chars; n : int; stream : FILEs)
13039       return chars;
13040   function fileno (stream : FILEs) return int;
13041   function fopen (filename : chars; Mode : chars)
13042       return FILEs;
13043   -- Note: to maintain target independence, use
13044   -- text_translation_required, a boolean variable defined in
13045   -- a-sysdep.c to deal with the target dependent text
13046   -- translation requirement.  If this variable is set,
13047   -- then  b/t should be appended to the standard mode
13048   -- argument to set the text translation mode off or on
13049   -- as required.
13050   function fputc (C : int; stream : FILEs) return int;
13051   function fputs (Strng : chars; Stream : FILEs) return int;
13052   function fread
13053      (buffer : voids;
13054       size : size_t;
13055       count : size_t;
13056       stream : FILEs)
13057       return size_t;
13058   function freopen
13059      (filename : chars;
13060       mode : chars;
13061       stream : FILEs)
13062       return FILEs;
13063   function fseek
13064      (stream : FILEs;
13065       offset : long;
13066       origin : int)
13067       return int;
13068   function ftell (stream : FILEs) return long;
13069   function fwrite
13070      (buffer : voids;
13071       size : size_t;
13072       count : size_t;
13073       stream : FILEs)
13074       return size_t;
13075   function isatty (handle : int) return int;
13076   procedure mktemp (template : chars);
13077   -- The return value (which is just a pointer to template)
13078   -- is discarded
13079   procedure rewind (stream : FILEs);
13080   function rmtmp return int;
13081   function setvbuf
13082      (stream : FILEs;
13083       buffer : chars;
13084       mode : int;
13085       size : size_t)
13086       return int;
13088   function tmpfile return FILEs;
13089   function ungetc (c : int; stream : FILEs) return int;
13090   function unlink (filename : chars) return int;
13091   ---------------------
13092   -- Extra functions --
13093   ---------------------
13094   -- These functions supply slightly thicker bindings than
13095   -- those above.  They are derived from functions in the
13096   -- C Run-Time Library, but may do a bit more work than
13097   -- just directly calling one of the Library functions.
13098   function is_regular_file (handle : int) return int;
13099   -- Tests if given handle is for a regular file (result 1)
13100   -- or for a non-regular file (pipe or device, result 0).
13101   ---------------------------------
13102   -- Control of Text/Binary Mode --
13103   ---------------------------------
13104   -- If text_translation_required is true, then the following
13105   -- functions may be used to dynamically switch a file from
13106   -- binary to text mode or vice versa.  These functions have
13107   -- no effect if text_translation_required is false (i.e.@: in
13108   -- normal UNIX mode).  Use fileno to get a stream handle.
13109   procedure set_binary_mode (handle : int);
13110   procedure set_text_mode (handle : int);
13111   ----------------------------
13112   -- Full Path Name support --
13113   ----------------------------
13114   procedure full_name (nam : chars; buffer : chars);
13115   -- Given a NUL terminated string representing a file
13116   -- name, returns in buffer a NUL terminated string
13117   -- representing the full path name for the file name.
13118   -- On systems where it is relevant the   drive is also
13119   -- part of the full path name.  It is the responsibility
13120   -- of the caller to pass an actual parameter for buffer
13121   -- that is big enough for any full path name.  Use
13122   -- max_path_len given below as the size of buffer.
13123   max_path_len : integer;
13124   -- Maximum length of an allowable full path name on the
13125   -- system, including a terminating NUL character.
13126 end Interfaces.C_Streams;
13127 @end smallexample
13129 @node Interfacing to C Streams
13130 @section Interfacing to C Streams
13132 @noindent
13133 The packages in this section permit interfacing Ada files to C Stream
13134 operations.
13136 @smallexample @c ada
13137  with Interfaces.C_Streams;
13138  package Ada.Sequential_IO.C_Streams is
13139     function C_Stream (F : File_Type)
13140        return Interfaces.C_Streams.FILEs;
13141     procedure Open
13142       (File : in out File_Type;
13143        Mode : in File_Mode;
13144        C_Stream : in Interfaces.C_Streams.FILEs;
13145        Form : in String := "");
13146  end Ada.Sequential_IO.C_Streams;
13148   with Interfaces.C_Streams;
13149   package Ada.Direct_IO.C_Streams is
13150      function C_Stream (F : File_Type)
13151         return Interfaces.C_Streams.FILEs;
13152      procedure Open
13153        (File : in out File_Type;
13154         Mode : in File_Mode;
13155         C_Stream : in Interfaces.C_Streams.FILEs;
13156         Form : in String := "");
13157   end Ada.Direct_IO.C_Streams;
13159   with Interfaces.C_Streams;
13160   package Ada.Text_IO.C_Streams is
13161      function C_Stream (F : File_Type)
13162         return Interfaces.C_Streams.FILEs;
13163      procedure Open
13164        (File : in out File_Type;
13165         Mode : in File_Mode;
13166         C_Stream : in Interfaces.C_Streams.FILEs;
13167         Form : in String := "");
13168   end Ada.Text_IO.C_Streams;
13170   with Interfaces.C_Streams;
13171   package Ada.Wide_Text_IO.C_Streams is
13172      function C_Stream (F : File_Type)
13173         return Interfaces.C_Streams.FILEs;
13174      procedure Open
13175        (File : in out File_Type;
13176         Mode : in File_Mode;
13177         C_Stream : in Interfaces.C_Streams.FILEs;
13178         Form : in String := "");
13179  end Ada.Wide_Text_IO.C_Streams;
13181   with Interfaces.C_Streams;
13182   package Ada.Wide_Wide_Text_IO.C_Streams is
13183      function C_Stream (F : File_Type)
13184         return Interfaces.C_Streams.FILEs;
13185      procedure Open
13186        (File : in out File_Type;
13187         Mode : in File_Mode;
13188         C_Stream : in Interfaces.C_Streams.FILEs;
13189         Form : in String := "");
13190  end Ada.Wide_Wide_Text_IO.C_Streams;
13192  with Interfaces.C_Streams;
13193  package Ada.Stream_IO.C_Streams is
13194     function C_Stream (F : File_Type)
13195        return Interfaces.C_Streams.FILEs;
13196     procedure Open
13197       (File : in out File_Type;
13198        Mode : in File_Mode;
13199        C_Stream : in Interfaces.C_Streams.FILEs;
13200        Form : in String := "");
13201  end Ada.Stream_IO.C_Streams;
13202 @end smallexample
13204 @noindent
13205 In each of these six packages, the @code{C_Stream} function obtains the
13206 @code{FILE} pointer from a currently opened Ada file.  It is then
13207 possible to use the @code{Interfaces.C_Streams} package to operate on
13208 this stream, or the stream can be passed to a C program which can
13209 operate on it directly.  Of course the program is responsible for
13210 ensuring that only appropriate sequences of operations are executed.
13212 One particular use of relevance to an Ada program is that the
13213 @code{setvbuf} function can be used to control the buffering of the
13214 stream used by an Ada file.  In the absence of such a call the standard
13215 default buffering is used.
13217 The @code{Open} procedures in these packages open a file giving an
13218 existing C Stream instead of a file name.  Typically this stream is
13219 imported from a C program, allowing an Ada file to operate on an
13220 existing C file.
13222 @node The GNAT Library
13223 @chapter The GNAT Library
13225 @noindent
13226 The GNAT library contains a number of general and special purpose packages.
13227 It represents functionality that the GNAT developers have found useful, and
13228 which is made available to GNAT users.  The packages described here are fully
13229 supported, and upwards compatibility will be maintained in future releases,
13230 so you can use these facilities with the confidence that the same functionality
13231 will be available in future releases.
13233 The chapter here simply gives a brief summary of the facilities available.
13234 The full documentation is found in the spec file for the package.  The full
13235 sources of these library packages, including both spec and body, are provided
13236 with all GNAT releases.  For example, to find out the full specifications of
13237 the SPITBOL pattern matching capability, including a full tutorial and
13238 extensive examples, look in the @file{g-spipat.ads} file in the library.
13240 For each entry here, the package name (as it would appear in a @code{with}
13241 clause) is given, followed by the name of the corresponding spec file in
13242 parentheses.  The packages are children in four hierarchies, @code{Ada},
13243 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13244 GNAT-specific hierarchy.
13246 Note that an application program should only use packages in one of these
13247 four hierarchies if the package is defined in the Ada Reference Manual,
13248 or is listed in this section of the GNAT Programmers Reference Manual.
13249 All other units should be considered internal implementation units and
13250 should not be directly @code{with}'ed by application code.  The use of
13251 a @code{with} statement that references one of these internal implementation
13252 units makes an application potentially dependent on changes in versions
13253 of GNAT, and will generate a warning message.
13255 @menu
13256 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13257 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13258 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13259 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13260 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13261 * Ada.Command_Line.Environment (a-colien.ads)::
13262 * Ada.Command_Line.Remove (a-colire.ads)::
13263 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13264 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13265 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13266 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13267 * Ada.Exceptions.Traceback (a-exctra.ads)::
13268 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13269 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13270 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13271 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13272 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13273 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13274 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13275 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13276 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13277 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13278 * GNAT.Altivec (g-altive.ads)::
13279 * GNAT.Altivec.Conversions (g-altcon.ads)::
13280 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13281 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13282 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13283 * GNAT.Array_Split (g-arrspl.ads)::
13284 * GNAT.AWK (g-awk.ads)::
13285 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13286 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13287 * GNAT.Bubble_Sort (g-bubsor.ads)::
13288 * GNAT.Bubble_Sort_A (g-busora.ads)::
13289 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13290 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13291 * GNAT.Byte_Swapping (g-bytswa.ads)::
13292 * GNAT.Calendar (g-calend.ads)::
13293 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13294 * GNAT.Case_Util (g-casuti.ads)::
13295 * GNAT.CGI (g-cgi.ads)::
13296 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13297 * GNAT.CGI.Debug (g-cgideb.ads)::
13298 * GNAT.Command_Line (g-comlin.ads)::
13299 * GNAT.Compiler_Version (g-comver.ads)::
13300 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13301 * GNAT.CRC32 (g-crc32.ads)::
13302 * GNAT.Current_Exception (g-curexc.ads)::
13303 * GNAT.Debug_Pools (g-debpoo.ads)::
13304 * GNAT.Debug_Utilities (g-debuti.ads)::
13305 * GNAT.Decode_String (g-decstr.ads)::
13306 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13307 * GNAT.Directory_Operations (g-dirope.ads)::
13308 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13309 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13310 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13311 * GNAT.Encode_String (g-encstr.ads)::
13312 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13313 * GNAT.Exception_Actions (g-excact.ads)::
13314 * GNAT.Exception_Traces (g-exctra.ads)::
13315 * GNAT.Exceptions (g-except.ads)::
13316 * GNAT.Expect (g-expect.ads)::
13317 * GNAT.Float_Control (g-flocon.ads)::
13318 * GNAT.Heap_Sort (g-heasor.ads)::
13319 * GNAT.Heap_Sort_A (g-hesora.ads)::
13320 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13321 * GNAT.HTable (g-htable.ads)::
13322 * GNAT.IO (g-io.ads)::
13323 * GNAT.IO_Aux (g-io_aux.ads)::
13324 * GNAT.Lock_Files (g-locfil.ads)::
13325 * GNAT.MD5 (g-md5.ads)::
13326 * GNAT.Memory_Dump (g-memdum.ads)::
13327 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13328 * GNAT.OS_Lib (g-os_lib.ads)::
13329 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13330 * GNAT.Random_Numbers (g-rannum.ads)::
13331 * GNAT.Regexp (g-regexp.ads)::
13332 * GNAT.Registry (g-regist.ads)::
13333 * GNAT.Regpat (g-regpat.ads)::
13334 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13335 * GNAT.Semaphores (g-semaph.ads)::
13336 * GNAT.Serial_Communications (g-sercom.ads)::
13337 * GNAT.SHA1 (g-sha1.ads)::
13338 * GNAT.Signals (g-signal.ads)::
13339 * GNAT.Sockets (g-socket.ads)::
13340 * GNAT.Source_Info (g-souinf.ads)::
13341 * GNAT.Spelling_Checker (g-speche.ads)::
13342 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13343 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13344 * GNAT.Spitbol (g-spitbo.ads)::
13345 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13346 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13347 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13348 * GNAT.Strings (g-string.ads)::
13349 * GNAT.String_Split (g-strspl.ads)::
13350 * GNAT.Table (g-table.ads)::
13351 * GNAT.Task_Lock (g-tasloc.ads)::
13352 * GNAT.Threads (g-thread.ads)::
13353 * GNAT.Time_Stamp (g-timsta.ads)::
13354 * GNAT.Traceback (g-traceb.ads)::
13355 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13356 * GNAT.UTF_32 (g-utf_32.ads)::
13357 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13358 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13359 * GNAT.Wide_String_Split (g-wistsp.ads)::
13360 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13361 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13362 * Interfaces.C.Extensions (i-cexten.ads)::
13363 * Interfaces.C.Streams (i-cstrea.ads)::
13364 * Interfaces.CPP (i-cpp.ads)::
13365 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13366 * Interfaces.VxWorks (i-vxwork.ads)::
13367 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13368 * System.Address_Image (s-addima.ads)::
13369 * System.Assertions (s-assert.ads)::
13370 * System.Memory (s-memory.ads)::
13371 * System.Partition_Interface (s-parint.ads)::
13372 * System.Pool_Global (s-pooglo.ads)::
13373 * System.Pool_Local (s-pooloc.ads)::
13374 * System.Restrictions (s-restri.ads)::
13375 * System.Rident (s-rident.ads)::
13376 * System.Task_Info (s-tasinf.ads)::
13377 * System.Wch_Cnv (s-wchcnv.ads)::
13378 * System.Wch_Con (s-wchcon.ads)::
13379 @end menu
13381 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13382 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13383 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13384 @cindex Latin_9 constants for Character
13386 @noindent
13387 This child of @code{Ada.Characters}
13388 provides a set of definitions corresponding to those in the
13389 RM-defined package @code{Ada.Characters.Latin_1} but with the
13390 few modifications required for @code{Latin-9}
13391 The provision of such a package
13392 is specifically authorized by the Ada Reference Manual
13393 (RM A.3.3(27)).
13395 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13396 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13397 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13398 @cindex Latin_1 constants for Wide_Character
13400 @noindent
13401 This child of @code{Ada.Characters}
13402 provides a set of definitions corresponding to those in the
13403 RM-defined package @code{Ada.Characters.Latin_1} but with the
13404 types of the constants being @code{Wide_Character}
13405 instead of @code{Character}.  The provision of such a package
13406 is specifically authorized by the Ada Reference Manual
13407 (RM A.3.3(27)).
13409 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13410 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13411 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13412 @cindex Latin_9 constants for Wide_Character
13414 @noindent
13415 This child of @code{Ada.Characters}
13416 provides a set of definitions corresponding to those in the
13417 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13418 types of the constants being @code{Wide_Character}
13419 instead of @code{Character}.  The provision of such a package
13420 is specifically authorized by the Ada Reference Manual
13421 (RM A.3.3(27)).
13423 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13424 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13425 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13426 @cindex Latin_1 constants for Wide_Wide_Character
13428 @noindent
13429 This child of @code{Ada.Characters}
13430 provides a set of definitions corresponding to those in the
13431 RM-defined package @code{Ada.Characters.Latin_1} but with the
13432 types of the constants being @code{Wide_Wide_Character}
13433 instead of @code{Character}.  The provision of such a package
13434 is specifically authorized by the Ada Reference Manual
13435 (RM A.3.3(27)).
13437 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13438 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13439 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13440 @cindex Latin_9 constants for Wide_Wide_Character
13442 @noindent
13443 This child of @code{Ada.Characters}
13444 provides a set of definitions corresponding to those in the
13445 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13446 types of the constants being @code{Wide_Wide_Character}
13447 instead of @code{Character}.  The provision of such a package
13448 is specifically authorized by the Ada Reference Manual
13449 (RM A.3.3(27)).
13451 @node Ada.Command_Line.Environment (a-colien.ads)
13452 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13453 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13454 @cindex Environment entries
13456 @noindent
13457 This child of @code{Ada.Command_Line}
13458 provides a mechanism for obtaining environment values on systems
13459 where this concept makes sense.
13461 @node Ada.Command_Line.Remove (a-colire.ads)
13462 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13463 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13464 @cindex Removing command line arguments
13465 @cindex Command line, argument removal
13467 @noindent
13468 This child of @code{Ada.Command_Line}
13469 provides a mechanism for logically removing
13470 arguments from the argument list.  Once removed, an argument is not visible
13471 to further calls on the subprograms in @code{Ada.Command_Line} will not
13472 see the removed argument.
13474 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13475 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13476 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13477 @cindex Response file for command line
13478 @cindex Command line, response file
13479 @cindex Command line, handling long command lines
13481 @noindent
13482 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13483 getting command line arguments from a text file, called a "response file".
13484 Using a response file allow passing a set of arguments to an executable longer
13485 than the maximum allowed by the system on the command line.
13487 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13488 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13489 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13490 @cindex C Streams, Interfacing with Direct_IO
13492 @noindent
13493 This package provides subprograms that allow interfacing between
13494 C streams and @code{Direct_IO}.  The stream identifier can be
13495 extracted from a file opened on the Ada side, and an Ada file
13496 can be constructed from a stream opened on the C side.
13498 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13499 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13500 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13501 @cindex Null_Occurrence, testing for
13503 @noindent
13504 This child subprogram provides a way of testing for the null
13505 exception occurrence (@code{Null_Occurrence}) without raising
13506 an exception.
13508 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13509 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13510 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13511 @cindex Null_Occurrence, testing for
13513 @noindent
13514 This child subprogram is used for handling otherwise unhandled
13515 exceptions (hence the name last chance), and perform clean ups before
13516 terminating the program. Note that this subprogram never returns.
13518 @node Ada.Exceptions.Traceback (a-exctra.ads)
13519 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13520 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13521 @cindex Traceback for Exception Occurrence
13523 @noindent
13524 This child package provides the subprogram (@code{Tracebacks}) to
13525 give a traceback array of addresses based on an exception
13526 occurrence.
13528 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13529 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13530 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13531 @cindex C Streams, Interfacing with Sequential_IO
13533 @noindent
13534 This package provides subprograms that allow interfacing between
13535 C streams and @code{Sequential_IO}.  The stream identifier can be
13536 extracted from a file opened on the Ada side, and an Ada file
13537 can be constructed from a stream opened on the C side.
13539 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13540 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13541 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13542 @cindex C Streams, Interfacing with Stream_IO
13544 @noindent
13545 This package provides subprograms that allow interfacing between
13546 C streams and @code{Stream_IO}.  The stream identifier can be
13547 extracted from a file opened on the Ada side, and an Ada file
13548 can be constructed from a stream opened on the C side.
13550 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13551 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13552 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13553 @cindex @code{Unbounded_String}, IO support
13554 @cindex @code{Text_IO}, extensions for unbounded strings
13556 @noindent
13557 This package provides subprograms for Text_IO for unbounded
13558 strings, avoiding the necessity for an intermediate operation
13559 with ordinary strings.
13561 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13562 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13563 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13564 @cindex @code{Unbounded_Wide_String}, IO support
13565 @cindex @code{Text_IO}, extensions for unbounded wide strings
13567 @noindent
13568 This package provides subprograms for Text_IO for unbounded
13569 wide strings, avoiding the necessity for an intermediate operation
13570 with ordinary wide strings.
13572 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13573 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13574 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13575 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13576 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13578 @noindent
13579 This package provides subprograms for Text_IO for unbounded
13580 wide wide strings, avoiding the necessity for an intermediate operation
13581 with ordinary wide wide strings.
13583 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13584 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13585 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13586 @cindex C Streams, Interfacing with @code{Text_IO}
13588 @noindent
13589 This package provides subprograms that allow interfacing between
13590 C streams and @code{Text_IO}.  The stream identifier can be
13591 extracted from a file opened on the Ada side, and an Ada file
13592 can be constructed from a stream opened on the C side.
13594 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13595 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13596 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13597 @cindex Unicode categorization, Wide_Character
13599 @noindent
13600 This package provides subprograms that allow categorization of
13601 Wide_Character values according to Unicode categories.
13603 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13604 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13605 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13606 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13608 @noindent
13609 This package provides subprograms that allow interfacing between
13610 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13611 extracted from a file opened on the Ada side, and an Ada file
13612 can be constructed from a stream opened on the C side.
13614 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13615 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13616 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13617 @cindex Unicode categorization, Wide_Wide_Character
13619 @noindent
13620 This package provides subprograms that allow categorization of
13621 Wide_Wide_Character values according to Unicode categories.
13623 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13624 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13625 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13626 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13628 @noindent
13629 This package provides subprograms that allow interfacing between
13630 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13631 extracted from a file opened on the Ada side, and an Ada file
13632 can be constructed from a stream opened on the C side.
13634 @node GNAT.Altivec (g-altive.ads)
13635 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13636 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13637 @cindex AltiVec
13639 @noindent
13640 This is the root package of the GNAT AltiVec binding. It provides
13641 definitions of constants and types common to all the versions of the
13642 binding.
13644 @node GNAT.Altivec.Conversions (g-altcon.ads)
13645 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13646 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13647 @cindex AltiVec
13649 @noindent
13650 This package provides the Vector/View conversion routines.
13652 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13653 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13654 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13655 @cindex AltiVec
13657 @noindent
13658 This package exposes the Ada interface to the AltiVec operations on
13659 vector objects. A soft emulation is included by default in the GNAT
13660 library. The hard binding is provided as a separate package. This unit
13661 is common to both bindings.
13663 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13664 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13665 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13666 @cindex AltiVec
13668 @noindent
13669 This package exposes the various vector types part of the Ada binding
13670 to AltiVec facilities.
13672 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13673 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13674 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13675 @cindex AltiVec
13677 @noindent
13678 This package provides public 'View' data types from/to which private
13679 vector representations can be converted via
13680 GNAT.Altivec.Conversions. This allows convenient access to individual
13681 vector elements and provides a simple way to initialize vector
13682 objects.
13684 @node GNAT.Array_Split (g-arrspl.ads)
13685 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13686 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13687 @cindex Array splitter
13689 @noindent
13690 Useful array-manipulation routines: given a set of separators, split
13691 an array wherever the separators appear, and provide direct access
13692 to the resulting slices.
13694 @node GNAT.AWK (g-awk.ads)
13695 @section @code{GNAT.AWK} (@file{g-awk.ads})
13696 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13697 @cindex Parsing
13698 @cindex AWK
13700 @noindent
13701 Provides AWK-like parsing functions, with an easy interface for parsing one
13702 or more files containing formatted data.  The file is viewed as a database
13703 where each record is a line and a field is a data element in this line.
13705 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13706 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13707 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13708 @cindex Parsing
13709 @cindex Bounded Buffers
13711 @noindent
13712 Provides a concurrent generic bounded buffer abstraction.  Instances are
13713 useful directly or as parts of the implementations of other abstractions,
13714 such as mailboxes.
13716 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13717 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13718 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13719 @cindex Parsing
13720 @cindex Mailboxes
13722 @noindent
13723 Provides a thread-safe asynchronous intertask mailbox communication facility.
13725 @node GNAT.Bubble_Sort (g-bubsor.ads)
13726 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13727 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13728 @cindex Sorting
13729 @cindex Bubble sort
13731 @noindent
13732 Provides a general implementation of bubble sort usable for sorting arbitrary
13733 data items.  Exchange and comparison procedures are provided by passing
13734 access-to-procedure values.
13736 @node GNAT.Bubble_Sort_A (g-busora.ads)
13737 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13738 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13739 @cindex Sorting
13740 @cindex Bubble sort
13742 @noindent
13743 Provides a general implementation of bubble sort usable for sorting arbitrary
13744 data items.  Move and comparison procedures are provided by passing
13745 access-to-procedure values. This is an older version, retained for
13746 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13748 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13749 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13750 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13751 @cindex Sorting
13752 @cindex Bubble sort
13754 @noindent
13755 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13756 are provided as generic parameters, this improves efficiency, especially
13757 if the procedures can be inlined, at the expense of duplicating code for
13758 multiple instantiations.
13760 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13761 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13762 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13763 @cindex UTF-8 representation
13764 @cindex Wide characte representations
13766 @noindent
13767 Provides a routine which given a string, reads the start of the string to
13768 see whether it is one of the standard byte order marks (BOM's) which signal
13769 the encoding of the string. The routine includes detection of special XML
13770 sequences for various UCS input formats.
13772 @node GNAT.Byte_Swapping (g-bytswa.ads)
13773 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13774 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13775 @cindex Byte swapping
13776 @cindex Endian
13778 @noindent
13779 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13780 Machine-specific implementations are available in some cases.
13782 @node GNAT.Calendar (g-calend.ads)
13783 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13784 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13785 @cindex @code{Calendar}
13787 @noindent
13788 Extends the facilities provided by @code{Ada.Calendar} to include handling
13789 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13790 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13791 C @code{timeval} format.
13793 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13794 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13795 @cindex @code{Calendar}
13796 @cindex Time
13797 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13799 @node GNAT.CRC32 (g-crc32.ads)
13800 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13801 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13802 @cindex CRC32
13803 @cindex Cyclic Redundancy Check
13805 @noindent
13806 This package implements the CRC-32 algorithm.  For a full description
13807 of this algorithm see
13808 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13809 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13810 Aug.@: 1988.  Sarwate, D.V@.
13812 @node GNAT.Case_Util (g-casuti.ads)
13813 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13814 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13815 @cindex Casing utilities
13816 @cindex Character handling (@code{GNAT.Case_Util})
13818 @noindent
13819 A set of simple routines for handling upper and lower casing of strings
13820 without the overhead of the full casing tables
13821 in @code{Ada.Characters.Handling}.
13823 @node GNAT.CGI (g-cgi.ads)
13824 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13825 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13826 @cindex CGI (Common Gateway Interface)
13828 @noindent
13829 This is a package for interfacing a GNAT program with a Web server via the
13830 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13831 parameters, which are a set of key/value pairs sent by the Web server.  It
13832 builds a table whose index is the key and provides some services to deal
13833 with this table.
13835 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13836 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13837 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13838 @cindex CGI (Common Gateway Interface) cookie support
13839 @cindex Cookie support in CGI
13841 @noindent
13842 This is a package to interface a GNAT program with a Web server via the
13843 Common Gateway Interface (CGI).  It exports services to deal with Web
13844 cookies (piece of information kept in the Web client software).
13846 @node GNAT.CGI.Debug (g-cgideb.ads)
13847 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13848 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13849 @cindex CGI (Common Gateway Interface) debugging
13851 @noindent
13852 This is a package to help debugging CGI (Common Gateway Interface)
13853 programs written in Ada.
13855 @node GNAT.Command_Line (g-comlin.ads)
13856 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13857 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13858 @cindex Command line
13860 @noindent
13861 Provides a high level interface to @code{Ada.Command_Line} facilities,
13862 including the ability to scan for named switches with optional parameters
13863 and expand file names using wild card notations.
13865 @node GNAT.Compiler_Version (g-comver.ads)
13866 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13867 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13868 @cindex Compiler Version
13869 @cindex Version, of compiler
13871 @noindent
13872 Provides a routine for obtaining the version of the compiler used to
13873 compile the program. More accurately this is the version of the binder
13874 used to bind the program (this will normally be the same as the version
13875 of the compiler if a consistent tool set is used to compile all units
13876 of a partition).
13878 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13879 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13880 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13881 @cindex Interrupt
13883 @noindent
13884 Provides a simple interface to handle Ctrl-C keyboard events.
13886 @node GNAT.Current_Exception (g-curexc.ads)
13887 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13888 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13889 @cindex Current exception
13890 @cindex Exception retrieval
13892 @noindent
13893 Provides access to information on the current exception that has been raised
13894 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13895 specification syntax.
13896 This is particularly useful in simulating typical facilities for
13897 obtaining information about exceptions provided by Ada 83 compilers.
13899 @node GNAT.Debug_Pools (g-debpoo.ads)
13900 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13901 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13902 @cindex Debugging
13903 @cindex Debug pools
13904 @cindex Memory corruption debugging
13906 @noindent
13907 Provide a debugging storage pools that helps tracking memory corruption
13908 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13909 @value{EDITION} User's Guide}.
13911 @node GNAT.Debug_Utilities (g-debuti.ads)
13912 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13913 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13914 @cindex Debugging
13916 @noindent
13917 Provides a few useful utilities for debugging purposes, including conversion
13918 to and from string images of address values. Supports both C and Ada formats
13919 for hexadecimal literals.
13921 @node GNAT.Decode_String (g-decstr.ads)
13922 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13923 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13924 @cindex Decoding strings
13925 @cindex String decoding
13926 @cindex Wide character encoding
13927 @cindex UTF-8
13928 @cindex Unicode
13930 @noindent
13931 A generic package providing routines for decoding wide character and wide wide
13932 character strings encoded as sequences of 8-bit characters using a specified
13933 encoding method. Includes validation routines, and also routines for stepping
13934 to next or previous encoded character in an encoded string.
13935 Useful in conjunction with Unicode character coding. Note there is a
13936 preinstantiation for UTF-8. See next entry.
13938 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13939 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13940 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13941 @cindex Decoding strings
13942 @cindex Decoding UTF-8 strings
13943 @cindex UTF-8 string decoding
13944 @cindex Wide character decoding
13945 @cindex UTF-8
13946 @cindex Unicode
13948 @noindent
13949 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13951 @node GNAT.Directory_Operations (g-dirope.ads)
13952 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13953 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13954 @cindex Directory operations
13956 @noindent
13957 Provides a set of routines for manipulating directories, including changing
13958 the current directory, making new directories, and scanning the files in a
13959 directory.
13961 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13962 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13963 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13964 @cindex Directory operations iteration
13966 @noindent
13967 A child unit of GNAT.Directory_Operations providing additional operations
13968 for iterating through directories.
13970 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13971 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13972 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13973 @cindex Hash tables
13975 @noindent
13976 A generic implementation of hash tables that can be used to hash arbitrary
13977 data.  Provided in two forms, a simple form with built in hash functions,
13978 and a more complex form in which the hash function is supplied.
13980 @noindent
13981 This package provides a facility similar to that of @code{GNAT.HTable},
13982 except that this package declares a type that can be used to define
13983 dynamic instances of the hash table, while an instantiation of
13984 @code{GNAT.HTable} creates a single instance of the hash table.
13986 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13987 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13988 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13989 @cindex Table implementation
13990 @cindex Arrays, extendable
13992 @noindent
13993 A generic package providing a single dimension array abstraction where the
13994 length of the array can be dynamically modified.
13996 @noindent
13997 This package provides a facility similar to that of @code{GNAT.Table},
13998 except that this package declares a type that can be used to define
13999 dynamic instances of the table, while an instantiation of
14000 @code{GNAT.Table} creates a single instance of the table type.
14002 @node GNAT.Encode_String (g-encstr.ads)
14003 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14004 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14005 @cindex Encoding strings
14006 @cindex String encoding
14007 @cindex Wide character encoding
14008 @cindex UTF-8
14009 @cindex Unicode
14011 @noindent
14012 A generic package providing routines for encoding wide character and wide
14013 wide character strings as sequences of 8-bit characters using a specified
14014 encoding method. Useful in conjunction with Unicode character coding.
14015 Note there is a preinstantiation for UTF-8. See next entry.
14017 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14018 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14019 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14020 @cindex Encoding strings
14021 @cindex Encoding UTF-8 strings
14022 @cindex UTF-8 string encoding
14023 @cindex Wide character encoding
14024 @cindex UTF-8
14025 @cindex Unicode
14027 @noindent
14028 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14030 @node GNAT.Exception_Actions (g-excact.ads)
14031 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14032 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14033 @cindex Exception actions
14035 @noindent
14036 Provides callbacks when an exception is raised. Callbacks can be registered
14037 for specific exceptions, or when any exception is raised. This
14038 can be used for instance to force a core dump to ease debugging.
14040 @node GNAT.Exception_Traces (g-exctra.ads)
14041 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14042 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14043 @cindex Exception traces
14044 @cindex Debugging
14046 @noindent
14047 Provides an interface allowing to control automatic output upon exception
14048 occurrences.
14050 @node GNAT.Exceptions (g-except.ads)
14051 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14052 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14053 @cindex Exceptions, Pure
14054 @cindex Pure packages, exceptions
14056 @noindent
14057 Normally it is not possible to raise an exception with
14058 a message from a subprogram in a pure package, since the
14059 necessary types and subprograms are in @code{Ada.Exceptions}
14060 which is not a pure unit. @code{GNAT.Exceptions} provides a
14061 facility for getting around this limitation for a few
14062 predefined exceptions, and for example allow raising
14063 @code{Constraint_Error} with a message from a pure subprogram.
14065 @node GNAT.Expect (g-expect.ads)
14066 @section @code{GNAT.Expect} (@file{g-expect.ads})
14067 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14069 @noindent
14070 Provides a set of subprograms similar to what is available
14071 with the standard Tcl Expect tool.
14072 It allows you to easily spawn and communicate with an external process.
14073 You can send commands or inputs to the process, and compare the output
14074 with some expected regular expression. Currently @code{GNAT.Expect}
14075 is implemented on all native GNAT ports except for OpenVMS@.
14076 It is not implemented for cross ports, and in particular is not
14077 implemented for VxWorks or LynxOS@.
14079 @node GNAT.Float_Control (g-flocon.ads)
14080 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14081 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14082 @cindex Floating-Point Processor
14084 @noindent
14085 Provides an interface for resetting the floating-point processor into the
14086 mode required for correct semantic operation in Ada.  Some third party
14087 library calls may cause this mode to be modified, and the Reset procedure
14088 in this package can be used to reestablish the required mode.
14090 @node GNAT.Heap_Sort (g-heasor.ads)
14091 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14092 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14093 @cindex Sorting
14095 @noindent
14096 Provides a general implementation of heap sort usable for sorting arbitrary
14097 data items. Exchange and comparison procedures are provided by passing
14098 access-to-procedure values.  The algorithm used is a modified heap sort
14099 that performs approximately N*log(N) comparisons in the worst case.
14101 @node GNAT.Heap_Sort_A (g-hesora.ads)
14102 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14103 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14104 @cindex Sorting
14106 @noindent
14107 Provides a general implementation of heap sort usable for sorting arbitrary
14108 data items. Move and comparison procedures are provided by passing
14109 access-to-procedure values.  The algorithm used is a modified heap sort
14110 that performs approximately N*log(N) comparisons in the worst case.
14111 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14112 interface, but may be slightly more efficient.
14114 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14115 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14116 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14117 @cindex Sorting
14119 @noindent
14120 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14121 are provided as generic parameters, this improves efficiency, especially
14122 if the procedures can be inlined, at the expense of duplicating code for
14123 multiple instantiations.
14125 @node GNAT.HTable (g-htable.ads)
14126 @section @code{GNAT.HTable} (@file{g-htable.ads})
14127 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14128 @cindex Hash tables
14130 @noindent
14131 A generic implementation of hash tables that can be used to hash arbitrary
14132 data.  Provides two approaches, one a simple static approach, and the other
14133 allowing arbitrary dynamic hash tables.
14135 @node GNAT.IO (g-io.ads)
14136 @section @code{GNAT.IO} (@file{g-io.ads})
14137 @cindex @code{GNAT.IO} (@file{g-io.ads})
14138 @cindex Simple I/O
14139 @cindex Input/Output facilities
14141 @noindent
14142 A simple preelaborable input-output package that provides a subset of
14143 simple Text_IO functions for reading characters and strings from
14144 Standard_Input, and writing characters, strings and integers to either
14145 Standard_Output or Standard_Error.
14147 @node GNAT.IO_Aux (g-io_aux.ads)
14148 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14149 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14150 @cindex Text_IO
14151 @cindex Input/Output facilities
14153 Provides some auxiliary functions for use with Text_IO, including a test
14154 for whether a file exists, and functions for reading a line of text.
14156 @node GNAT.Lock_Files (g-locfil.ads)
14157 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14158 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14159 @cindex File locking
14160 @cindex Locking using files
14162 @noindent
14163 Provides a general interface for using files as locks.  Can be used for
14164 providing program level synchronization.
14166 @node GNAT.MD5 (g-md5.ads)
14167 @section @code{GNAT.MD5} (@file{g-md5.ads})
14168 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14169 @cindex Message Digest MD5
14171 @noindent
14172 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14174 @node GNAT.Memory_Dump (g-memdum.ads)
14175 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14176 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14177 @cindex Dump Memory
14179 @noindent
14180 Provides a convenient routine for dumping raw memory to either the
14181 standard output or standard error files. Uses GNAT.IO for actual
14182 output.
14184 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14185 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14186 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14187 @cindex Exception, obtaining most recent
14189 @noindent
14190 Provides access to the most recently raised exception.  Can be used for
14191 various logging purposes, including duplicating functionality of some
14192 Ada 83 implementation dependent extensions.
14194 @node GNAT.OS_Lib (g-os_lib.ads)
14195 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14196 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14197 @cindex Operating System interface
14198 @cindex Spawn capability
14200 @noindent
14201 Provides a range of target independent operating system interface functions,
14202 including time/date management, file operations, subprocess management,
14203 including a portable spawn procedure, and access to environment variables
14204 and error return codes.
14206 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14207 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14208 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14209 @cindex Hash functions
14211 @noindent
14212 Provides a generator of static minimal perfect hash functions. No
14213 collisions occur and each item can be retrieved from the table in one
14214 probe (perfect property). The hash table size corresponds to the exact
14215 size of the key set and no larger (minimal property). The key set has to
14216 be know in advance (static property). The hash functions are also order
14217 preserving. If w2 is inserted after w1 in the generator, their
14218 hashcode are in the same order. These hashing functions are very
14219 convenient for use with realtime applications.
14221 @node GNAT.Random_Numbers (g-rannum.ads)
14222 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14223 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14224 @cindex Random number generation
14226 @noindent
14227 Provides random number capabilities which extend those available in the
14228 standard Ada library and are more convenient to use.
14230 @node GNAT.Regexp (g-regexp.ads)
14231 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14232 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14233 @cindex Regular expressions
14234 @cindex Pattern matching
14236 @noindent
14237 A simple implementation of regular expressions, using a subset of regular
14238 expression syntax copied from familiar Unix style utilities.  This is the
14239 simples of the three pattern matching packages provided, and is particularly
14240 suitable for ``file globbing'' applications.
14242 @node GNAT.Registry (g-regist.ads)
14243 @section @code{GNAT.Registry} (@file{g-regist.ads})
14244 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14245 @cindex Windows Registry
14247 @noindent
14248 This is a high level binding to the Windows registry.  It is possible to
14249 do simple things like reading a key value, creating a new key.  For full
14250 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14251 package provided with the Win32Ada binding
14253 @node GNAT.Regpat (g-regpat.ads)
14254 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14255 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14256 @cindex Regular expressions
14257 @cindex Pattern matching
14259 @noindent
14260 A complete implementation of Unix-style regular expression matching, copied
14261 from the original V7 style regular expression library written in C by
14262 Henry Spencer (and binary compatible with this C library).
14264 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14265 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14266 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14267 @cindex Secondary Stack Info
14269 @noindent
14270 Provide the capability to query the high water mark of the current task's
14271 secondary stack.
14273 @node GNAT.Semaphores (g-semaph.ads)
14274 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14275 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14276 @cindex Semaphores
14278 @noindent
14279 Provides classic counting and binary semaphores using protected types.
14281 @node GNAT.Serial_Communications (g-sercom.ads)
14282 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14283 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14284 @cindex Serial_Communications
14286 @noindent
14287 Provides a simple interface to send and receive data over a serial
14288 port. This is only supported on GNU/Linux and Windows.
14290 @node GNAT.SHA1 (g-sha1.ads)
14291 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14292 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14293 @cindex Secure Hash Algorithm SHA-1
14295 @noindent
14296 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14298 @node GNAT.Signals (g-signal.ads)
14299 @section @code{GNAT.Signals} (@file{g-signal.ads})
14300 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14301 @cindex Signals
14303 @noindent
14304 Provides the ability to manipulate the blocked status of signals on supported
14305 targets.
14307 @node GNAT.Sockets (g-socket.ads)
14308 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14309 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14310 @cindex Sockets
14312 @noindent
14313 A high level and portable interface to develop sockets based applications.
14314 This package is based on the sockets thin binding found in
14315 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14316 on all native GNAT ports except for OpenVMS@.  It is not implemented
14317 for the LynxOS@ cross port.
14319 @node GNAT.Source_Info (g-souinf.ads)
14320 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14321 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14322 @cindex Source Information
14324 @noindent
14325 Provides subprograms that give access to source code information known at
14326 compile time, such as the current file name and line number.
14328 @node GNAT.Spelling_Checker (g-speche.ads)
14329 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14330 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14331 @cindex Spell checking
14333 @noindent
14334 Provides a function for determining whether one string is a plausible
14335 near misspelling of another string.
14337 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14338 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14339 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14340 @cindex Spell checking
14342 @noindent
14343 Provides a generic function that can be instantiated with a string type for
14344 determining whether one string is a plausible near misspelling of another
14345 string.
14347 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14348 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14349 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14350 @cindex SPITBOL pattern matching
14351 @cindex Pattern matching
14353 @noindent
14354 A complete implementation of SNOBOL4 style pattern matching.  This is the
14355 most elaborate of the pattern matching packages provided.  It fully duplicates
14356 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14357 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14359 @node GNAT.Spitbol (g-spitbo.ads)
14360 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14361 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14362 @cindex SPITBOL interface
14364 @noindent
14365 The top level package of the collection of SPITBOL-style functionality, this
14366 package provides basic SNOBOL4 string manipulation functions, such as
14367 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14368 useful for constructing arbitrary mappings from strings in the style of
14369 the SNOBOL4 TABLE function.
14371 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14372 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14373 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14374 @cindex Sets of strings
14375 @cindex SPITBOL Tables
14377 @noindent
14378 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14379 for type @code{Standard.Boolean}, giving an implementation of sets of
14380 string values.
14382 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14383 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14384 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14385 @cindex Integer maps
14386 @cindex Maps
14387 @cindex SPITBOL Tables
14389 @noindent
14390 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14391 for type @code{Standard.Integer}, giving an implementation of maps
14392 from string to integer values.
14394 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14395 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14396 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14397 @cindex String maps
14398 @cindex Maps
14399 @cindex SPITBOL Tables
14401 @noindent
14402 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14403 a variable length string type, giving an implementation of general
14404 maps from strings to strings.
14406 @node GNAT.Strings (g-string.ads)
14407 @section @code{GNAT.Strings} (@file{g-string.ads})
14408 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14410 @noindent
14411 Common String access types and related subprograms. Basically it
14412 defines a string access and an array of string access types.
14414 @node GNAT.String_Split (g-strspl.ads)
14415 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14416 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14417 @cindex String splitter
14419 @noindent
14420 Useful string manipulation routines: given a set of separators, split
14421 a string wherever the separators appear, and provide direct access
14422 to the resulting slices. This package is instantiated from
14423 @code{GNAT.Array_Split}.
14425 @node GNAT.Table (g-table.ads)
14426 @section @code{GNAT.Table} (@file{g-table.ads})
14427 @cindex @code{GNAT.Table} (@file{g-table.ads})
14428 @cindex Table implementation
14429 @cindex Arrays, extendable
14431 @noindent
14432 A generic package providing a single dimension array abstraction where the
14433 length of the array can be dynamically modified.
14435 @noindent
14436 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14437 except that this package declares a single instance of the table type,
14438 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14439 used to define dynamic instances of the table.
14441 @node GNAT.Task_Lock (g-tasloc.ads)
14442 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14443 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14444 @cindex Task synchronization
14445 @cindex Task locking
14446 @cindex Locking
14448 @noindent
14449 A very simple facility for locking and unlocking sections of code using a
14450 single global task lock.  Appropriate for use in situations where contention
14451 between tasks is very rarely expected.
14453 @node GNAT.Time_Stamp (g-timsta.ads)
14454 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14455 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14456 @cindex Time stamp
14457 @cindex Current time
14459 @noindent
14460 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14461 represents the current date and time in ISO 8601 format. This is a very simple
14462 routine with minimal code and there are no dependencies on any other unit.
14464 @node GNAT.Threads (g-thread.ads)
14465 @section @code{GNAT.Threads} (@file{g-thread.ads})
14466 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14467 @cindex Foreign threads
14468 @cindex Threads, foreign
14470 @noindent
14471 Provides facilities for dealing with foreign threads which need to be known
14472 by the GNAT run-time system. Consult the documentation of this package for
14473 further details if your program has threads that are created by a non-Ada
14474 environment which then accesses Ada code.
14476 @node GNAT.Traceback (g-traceb.ads)
14477 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14478 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14479 @cindex Trace back facilities
14481 @noindent
14482 Provides a facility for obtaining non-symbolic traceback information, useful
14483 in various debugging situations.
14485 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14486 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14487 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14488 @cindex Trace back facilities
14490 @node GNAT.UTF_32 (g-utf_32.ads)
14491 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14492 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14493 @cindex Wide character codes
14495 @noindent
14496 This is a package intended to be used in conjunction with the
14497 @code{Wide_Character} type in Ada 95 and the
14498 @code{Wide_Wide_Character} type in Ada 2005 (available
14499 in @code{GNAT} in Ada 2005 mode). This package contains
14500 Unicode categorization routines, as well as lexical
14501 categorization routines corresponding to the Ada 2005
14502 lexical rules for identifiers and strings, and also a
14503 lower case to upper case fold routine corresponding to
14504 the Ada 2005 rules for identifier equivalence.
14506 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14507 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14508 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14509 @cindex Spell checking
14511 @noindent
14512 Provides a function for determining whether one wide wide string is a plausible
14513 near misspelling of another wide wide string, where the strings are represented
14514 using the UTF_32_String type defined in System.Wch_Cnv.
14516 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14517 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14518 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14519 @cindex Spell checking
14521 @noindent
14522 Provides a function for determining whether one wide string is a plausible
14523 near misspelling of another wide string.
14525 @node GNAT.Wide_String_Split (g-wistsp.ads)
14526 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14527 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14528 @cindex Wide_String splitter
14530 @noindent
14531 Useful wide string manipulation routines: given a set of separators, split
14532 a wide string wherever the separators appear, and provide direct access
14533 to the resulting slices. This package is instantiated from
14534 @code{GNAT.Array_Split}.
14536 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14537 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14538 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14539 @cindex Spell checking
14541 @noindent
14542 Provides a function for determining whether one wide wide string is a plausible
14543 near misspelling of another wide wide string.
14545 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14546 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14547 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14548 @cindex Wide_Wide_String splitter
14550 @noindent
14551 Useful wide wide string manipulation routines: given a set of separators, split
14552 a wide wide string wherever the separators appear, and provide direct access
14553 to the resulting slices. This package is instantiated from
14554 @code{GNAT.Array_Split}.
14556 @node Interfaces.C.Extensions (i-cexten.ads)
14557 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14558 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14560 @noindent
14561 This package contains additional C-related definitions, intended
14562 for use with either manually or automatically generated bindings
14563 to C libraries.
14565 @node Interfaces.C.Streams (i-cstrea.ads)
14566 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14567 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14568 @cindex  C streams, interfacing
14570 @noindent
14571 This package is a binding for the most commonly used operations
14572 on C streams.
14574 @node Interfaces.CPP (i-cpp.ads)
14575 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14576 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14577 @cindex  C++ interfacing
14578 @cindex  Interfacing, to C++
14580 @noindent
14581 This package provides facilities for use in interfacing to C++.  It
14582 is primarily intended to be used in connection with automated tools
14583 for the generation of C++ interfaces.
14585 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14586 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14587 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14588 @cindex  IBM Packed Format
14589 @cindex  Packed Decimal
14591 @noindent
14592 This package provides a set of routines for conversions to and
14593 from a packed decimal format compatible with that used on IBM
14594 mainframes.
14596 @node Interfaces.VxWorks (i-vxwork.ads)
14597 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14598 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14599 @cindex Interfacing to VxWorks
14600 @cindex VxWorks, interfacing
14602 @noindent
14603 This package provides a limited binding to the VxWorks API.
14604 In particular, it interfaces with the
14605 VxWorks hardware interrupt facilities.
14607 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14608 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14609 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14610 @cindex Interfacing to VxWorks' I/O
14611 @cindex VxWorks, I/O interfacing
14612 @cindex VxWorks, Get_Immediate
14613 @cindex Get_Immediate, VxWorks
14615 @noindent
14616 This package provides a binding to the ioctl (IO/Control)
14617 function of VxWorks, defining a set of option values and
14618 function codes. A particular use of this package is
14619 to enable the use of Get_Immediate under VxWorks.
14621 @node System.Address_Image (s-addima.ads)
14622 @section @code{System.Address_Image} (@file{s-addima.ads})
14623 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14624 @cindex Address image
14625 @cindex Image, of an address
14627 @noindent
14628 This function provides a useful debugging
14629 function that gives an (implementation dependent)
14630 string which identifies an address.
14632 @node System.Assertions (s-assert.ads)
14633 @section @code{System.Assertions} (@file{s-assert.ads})
14634 @cindex @code{System.Assertions} (@file{s-assert.ads})
14635 @cindex Assertions
14636 @cindex Assert_Failure, exception
14638 @noindent
14639 This package provides the declaration of the exception raised
14640 by an run-time assertion failure, as well as the routine that
14641 is used internally to raise this assertion.
14643 @node System.Memory (s-memory.ads)
14644 @section @code{System.Memory} (@file{s-memory.ads})
14645 @cindex @code{System.Memory} (@file{s-memory.ads})
14646 @cindex Memory allocation
14648 @noindent
14649 This package provides the interface to the low level routines used
14650 by the generated code for allocation and freeing storage for the
14651 default storage pool (analogous to the C routines malloc and free.
14652 It also provides a reallocation interface analogous to the C routine
14653 realloc. The body of this unit may be modified to provide alternative
14654 allocation mechanisms for the default pool, and in addition, direct
14655 calls to this unit may be made for low level allocation uses (for
14656 example see the body of @code{GNAT.Tables}).
14658 @node System.Partition_Interface (s-parint.ads)
14659 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14660 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14661 @cindex Partition interfacing functions
14663 @noindent
14664 This package provides facilities for partition interfacing.  It
14665 is used primarily in a distribution context when using Annex E
14666 with @code{GLADE}.
14668 @node System.Pool_Global (s-pooglo.ads)
14669 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14670 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14671 @cindex Storage pool, global
14672 @cindex Global storage pool
14674 @noindent
14675 This package provides a storage pool that is equivalent to the default
14676 storage pool used for access types for which no pool is specifically
14677 declared. It uses malloc/free to allocate/free and does not attempt to
14678 do any automatic reclamation.
14680 @node System.Pool_Local (s-pooloc.ads)
14681 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14682 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14683 @cindex Storage pool, local
14684 @cindex Local storage pool
14686 @noindent
14687 This package provides a storage pool that is intended for use with locally
14688 defined access types. It uses malloc/free for allocate/free, and maintains
14689 a list of allocated blocks, so that all storage allocated for the pool can
14690 be freed automatically when the pool is finalized.
14692 @node System.Restrictions (s-restri.ads)
14693 @section @code{System.Restrictions} (@file{s-restri.ads})
14694 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14695 @cindex Run-time restrictions access
14697 @noindent
14698 This package provides facilities for accessing at run time
14699 the status of restrictions specified at compile time for
14700 the partition. Information is available both with regard
14701 to actual restrictions specified, and with regard to
14702 compiler determined information on which restrictions
14703 are violated by one or more packages in the partition.
14705 @node System.Rident (s-rident.ads)
14706 @section @code{System.Rident} (@file{s-rident.ads})
14707 @cindex @code{System.Rident} (@file{s-rident.ads})
14708 @cindex Restrictions definitions
14710 @noindent
14711 This package provides definitions of the restrictions
14712 identifiers supported by GNAT, and also the format of
14713 the restrictions provided in package System.Restrictions.
14714 It is not normally necessary to @code{with} this generic package
14715 since the necessary instantiation is included in
14716 package System.Restrictions.
14718 @node System.Task_Info (s-tasinf.ads)
14719 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14720 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14721 @cindex Task_Info pragma
14723 @noindent
14724 This package provides target dependent functionality that is used
14725 to support the @code{Task_Info} pragma
14727 @node System.Wch_Cnv (s-wchcnv.ads)
14728 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14729 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14730 @cindex Wide Character, Representation
14731 @cindex Wide String, Conversion
14732 @cindex Representation of wide characters
14734 @noindent
14735 This package provides routines for converting between
14736 wide and wide wide characters and a representation as a value of type
14737 @code{Standard.String}, using a specified wide character
14738 encoding method.  It uses definitions in
14739 package @code{System.Wch_Con}.
14741 @node System.Wch_Con (s-wchcon.ads)
14742 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14743 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14745 @noindent
14746 This package provides definitions and descriptions of
14747 the various methods used for encoding wide characters
14748 in ordinary strings.  These definitions are used by
14749 the package @code{System.Wch_Cnv}.
14751 @node Interfacing to Other Languages
14752 @chapter Interfacing to Other Languages
14753 @noindent
14754 The facilities in annex B of the Ada Reference Manual are fully
14755 implemented in GNAT, and in addition, a full interface to C++ is
14756 provided.
14758 @menu
14759 * Interfacing to C::
14760 * Interfacing to C++::
14761 * Interfacing to COBOL::
14762 * Interfacing to Fortran::
14763 * Interfacing to non-GNAT Ada code::
14764 @end menu
14766 @node Interfacing to C
14767 @section Interfacing to C
14769 @noindent
14770 Interfacing to C with GNAT can use one of two approaches:
14772 @itemize @bullet
14773 @item
14774 The types in the package @code{Interfaces.C} may be used.
14775 @item
14776 Standard Ada types may be used directly.  This may be less portable to
14777 other compilers, but will work on all GNAT compilers, which guarantee
14778 correspondence between the C and Ada types.
14779 @end itemize
14781 @noindent
14782 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14783 effect, since this is the default.  The following table shows the
14784 correspondence between Ada scalar types and the corresponding C types.
14786 @table @code
14787 @item Integer
14788 @code{int}
14789 @item Short_Integer
14790 @code{short}
14791 @item Short_Short_Integer
14792 @code{signed char}
14793 @item Long_Integer
14794 @code{long}
14795 @item Long_Long_Integer
14796 @code{long long}
14797 @item Short_Float
14798 @code{float}
14799 @item Float
14800 @code{float}
14801 @item Long_Float
14802 @code{double}
14803 @item Long_Long_Float
14804 This is the longest floating-point type supported by the hardware.
14805 @end table
14807 @noindent
14808 Additionally, there are the following general correspondences between Ada
14809 and C types:
14810 @itemize @bullet
14811 @item
14812 Ada enumeration types map to C enumeration types directly if pragma
14813 @code{Convention C} is specified, which causes them to have int
14814 length.  Without pragma @code{Convention C}, Ada enumeration types map to
14815 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14816 @code{int}, respectively) depending on the number of values passed.
14817 This is the only case in which pragma @code{Convention C} affects the
14818 representation of an Ada type.
14820 @item
14821 Ada access types map to C pointers, except for the case of pointers to
14822 unconstrained types in Ada, which have no direct C equivalent.
14824 @item
14825 Ada arrays map directly to C arrays.
14827 @item
14828 Ada records map directly to C structures.
14830 @item
14831 Packed Ada records map to C structures where all members are bit fields
14832 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14833 @end itemize
14835 @node Interfacing to C++
14836 @section Interfacing to C++
14838 @noindent
14839 The interface to C++ makes use of the following pragmas, which are
14840 primarily intended to be constructed automatically using a binding generator
14841 tool, although it is possible to construct them by hand.  No suitable binding
14842 generator tool is supplied with GNAT though.
14844 Using these pragmas it is possible to achieve complete
14845 inter-operability between Ada tagged types and C++ class definitions.
14846 See @ref{Implementation Defined Pragmas}, for more details.
14848 @table @code
14849 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14850 The argument denotes an entity in the current declarative region that is
14851 declared as a tagged or untagged record type. It indicates that the type
14852 corresponds to an externally declared C++ class type, and is to be laid
14853 out the same way that C++ would lay out the type.
14855 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14856 for backward compatibility but its functionality is available
14857 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14859 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14860 This pragma identifies an imported function (imported in the usual way
14861 with pragma @code{Import}) as corresponding to a C++ constructor.
14862 @end table
14864 @node Interfacing to COBOL
14865 @section Interfacing to COBOL
14867 @noindent
14868 Interfacing to COBOL is achieved as described in section B.4 of
14869 the Ada Reference Manual.
14871 @node Interfacing to Fortran
14872 @section Interfacing to Fortran
14874 @noindent
14875 Interfacing to Fortran is achieved as described in section B.5 of the
14876 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14877 multi-dimensional array causes the array to be stored in column-major
14878 order as required for convenient interface to Fortran.
14880 @node Interfacing to non-GNAT Ada code
14881 @section Interfacing to non-GNAT Ada code
14883 It is possible to specify the convention @code{Ada} in a pragma
14884 @code{Import} or pragma @code{Export}.  However this refers to
14885 the calling conventions used by GNAT, which may or may not be
14886 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14887 compiler to allow interoperation.
14889 If arguments types are kept simple, and if the foreign compiler generally
14890 follows system calling conventions, then it may be possible to integrate
14891 files compiled by other Ada compilers, provided that the elaboration
14892 issues are adequately addressed (for example by eliminating the
14893 need for any load time elaboration).
14895 In particular, GNAT running on VMS is designed to
14896 be highly compatible with the DEC Ada 83 compiler, so this is one
14897 case in which it is possible to import foreign units of this type,
14898 provided that the data items passed are restricted to simple scalar
14899 values or simple record types without variants, or simple array
14900 types with fixed bounds.
14902 @node Specialized Needs Annexes
14903 @chapter Specialized Needs Annexes
14905 @noindent
14906 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14907 required in all implementations.  However, as described in this chapter,
14908 GNAT implements all of these annexes:
14910 @table @asis
14911 @item Systems Programming (Annex C)
14912 The Systems Programming Annex is fully implemented.
14914 @item Real-Time Systems (Annex D)
14915 The Real-Time Systems Annex is fully implemented.
14917 @item Distributed Systems (Annex E)
14918 Stub generation is fully implemented in the GNAT compiler.  In addition,
14919 a complete compatible PCS is available as part of the GLADE system,
14920 a separate product.  When the two
14921 products are used in conjunction, this annex is fully implemented.
14923 @item Information Systems (Annex F)
14924 The Information Systems annex is fully implemented.
14926 @item Numerics (Annex G)
14927 The Numerics Annex is fully implemented.
14929 @item Safety and Security / High-Integrity Systems (Annex H)
14930 The Safety and Security Annex (termed the High-Integrity Systems Annex
14931 in Ada 2005) is fully implemented.
14932 @end table
14934 @node Implementation of Specific Ada Features
14935 @chapter Implementation of Specific Ada Features
14937 @noindent
14938 This chapter describes the GNAT implementation of several Ada language
14939 facilities.
14941 @menu
14942 * Machine Code Insertions::
14943 * GNAT Implementation of Tasking::
14944 * GNAT Implementation of Shared Passive Packages::
14945 * Code Generation for Array Aggregates::
14946 * The Size of Discriminated Records with Default Discriminants::
14947 * Strict Conformance to the Ada Reference Manual::
14948 @end menu
14950 @node Machine Code Insertions
14951 @section Machine Code Insertions
14952 @cindex Machine Code insertions
14954 @noindent
14955 Package @code{Machine_Code} provides machine code support as described
14956 in the Ada Reference Manual in two separate forms:
14957 @itemize @bullet
14958 @item
14959 Machine code statements, consisting of qualified expressions that
14960 fit the requirements of RM section 13.8.
14961 @item
14962 An intrinsic callable procedure, providing an alternative mechanism of
14963 including machine instructions in a subprogram.
14964 @end itemize
14966 @noindent
14967 The two features are similar, and both are closely related to the mechanism
14968 provided by the asm instruction in the GNU C compiler.  Full understanding
14969 and use of the facilities in this package requires understanding the asm
14970 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
14971 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
14973 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14974 semantic restrictions and effects as described below.  Both are provided so
14975 that the procedure call can be used as a statement, and the function call
14976 can be used to form a code_statement.
14978 The first example given in the GCC documentation is the C @code{asm}
14979 instruction:
14980 @smallexample
14981    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14982 @end smallexample
14984 @noindent
14985 The equivalent can be written for GNAT as:
14987 @smallexample @c ada
14988 Asm ("fsinx %1 %0",
14989      My_Float'Asm_Output ("=f", result),
14990      My_Float'Asm_Input  ("f",  angle));
14991 @end smallexample
14993 @noindent
14994 The first argument to @code{Asm} is the assembler template, and is
14995 identical to what is used in GNU C@.  This string must be a static
14996 expression.  The second argument is the output operand list.  It is
14997 either a single @code{Asm_Output} attribute reference, or a list of such
14998 references enclosed in parentheses (technically an array aggregate of
14999 such references).
15001 The @code{Asm_Output} attribute denotes a function that takes two
15002 parameters.  The first is a string, the second is the name of a variable
15003 of the type designated by the attribute prefix.  The first (string)
15004 argument is required to be a static expression and designates the
15005 constraint for the parameter (e.g.@: what kind of register is
15006 required).  The second argument is the variable to be updated with the
15007 result.  The possible values for constraint are the same as those used in
15008 the RTL, and are dependent on the configuration file used to build the
15009 GCC back end.  If there are no output operands, then this argument may
15010 either be omitted, or explicitly given as @code{No_Output_Operands}.
15012 The second argument of @code{@var{my_float}'Asm_Output} functions as
15013 though it were an @code{out} parameter, which is a little curious, but
15014 all names have the form of expressions, so there is no syntactic
15015 irregularity, even though normally functions would not be permitted
15016 @code{out} parameters.  The third argument is the list of input
15017 operands.  It is either a single @code{Asm_Input} attribute reference, or
15018 a list of such references enclosed in parentheses (technically an array
15019 aggregate of such references).
15021 The @code{Asm_Input} attribute denotes a function that takes two
15022 parameters.  The first is a string, the second is an expression of the
15023 type designated by the prefix.  The first (string) argument is required
15024 to be a static expression, and is the constraint for the parameter,
15025 (e.g.@: what kind of register is required).  The second argument is the
15026 value to be used as the input argument.  The possible values for the
15027 constant are the same as those used in the RTL, and are dependent on
15028 the configuration file used to built the GCC back end.
15030 If there are no input operands, this argument may either be omitted, or
15031 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15032 present in the above example, is a list of register names, called the
15033 @dfn{clobber} argument.  This argument, if given, must be a static string
15034 expression, and is a space or comma separated list of names of registers
15035 that must be considered destroyed as a result of the @code{Asm} call.  If
15036 this argument is the null string (the default value), then the code
15037 generator assumes that no additional registers are destroyed.
15039 The fifth argument, not present in the above example, called the
15040 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15041 the literal value @code{True} to indicate to the code generator that all
15042 optimizations with respect to the instruction specified should be
15043 suppressed, and that in particular, for an instruction that has outputs,
15044 the instruction will still be generated, even if none of the outputs are
15045 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15046 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15047 Generally it is strongly advisable to use Volatile for any ASM statement
15048 that is missing either input or output operands, or when two or more ASM
15049 statements appear in sequence, to avoid unwanted optimizations. A warning
15050 is generated if this advice is not followed.
15052 The @code{Asm} subprograms may be used in two ways.  First the procedure
15053 forms can be used anywhere a procedure call would be valid, and
15054 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15055 be used to intersperse machine instructions with other Ada statements.
15056 Second, the function forms, which return a dummy value of the limited
15057 private type @code{Asm_Insn}, can be used in code statements, and indeed
15058 this is the only context where such calls are allowed.  Code statements
15059 appear as aggregates of the form:
15061 @smallexample @c ada
15062 Asm_Insn'(Asm (@dots{}));
15063 Asm_Insn'(Asm_Volatile (@dots{}));
15064 @end smallexample
15066 @noindent
15067 In accordance with RM rules, such code statements are allowed only
15068 within subprograms whose entire body consists of such statements.  It is
15069 not permissible to intermix such statements with other Ada statements.
15071 Typically the form using intrinsic procedure calls is more convenient
15072 and more flexible.  The code statement form is provided to meet the RM
15073 suggestion that such a facility should be made available.  The following
15074 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15075 is used, the arguments may be given in arbitrary order, following the
15076 normal rules for use of positional and named arguments)
15078 @smallexample
15079 ASM_CALL ::= Asm (
15080                  [Template =>] static_string_EXPRESSION
15081                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15082                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15083                [,[Clobber  =>] static_string_EXPRESSION ]
15084                [,[Volatile =>] static_boolean_EXPRESSION] )
15086 OUTPUT_OPERAND_LIST ::=
15087   [PREFIX.]No_Output_Operands
15088 | OUTPUT_OPERAND_ATTRIBUTE
15089 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15091 OUTPUT_OPERAND_ATTRIBUTE ::=
15092   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15094 INPUT_OPERAND_LIST ::=
15095   [PREFIX.]No_Input_Operands
15096 | INPUT_OPERAND_ATTRIBUTE
15097 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15099 INPUT_OPERAND_ATTRIBUTE ::=
15100   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15101 @end smallexample
15103 @noindent
15104 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15105 are declared in the package @code{Machine_Code} and must be referenced
15106 according to normal visibility rules. In particular if there is no
15107 @code{use} clause for this package, then appropriate package name
15108 qualification is required.
15110 @node GNAT Implementation of Tasking
15111 @section GNAT Implementation of Tasking
15113 @noindent
15114 This chapter outlines the basic GNAT approach to tasking (in particular,
15115 a multi-layered library for portability) and discusses issues related
15116 to compliance with the Real-Time Systems Annex.
15118 @menu
15119 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15120 * Ensuring Compliance with the Real-Time Annex::
15121 @end menu
15123 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15124 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15126 @noindent
15127 GNAT's run-time support comprises two layers:
15129 @itemize @bullet
15130 @item GNARL (GNAT Run-time Layer)
15131 @item GNULL (GNAT Low-level Library)
15132 @end itemize
15134 @noindent
15135 In GNAT, Ada's tasking services rely on a platform and OS independent
15136 layer known as GNARL@.  This code is responsible for implementing the
15137 correct semantics of Ada's task creation, rendezvous, protected
15138 operations etc.
15140 GNARL decomposes Ada's tasking semantics into simpler lower level
15141 operations such as create a thread, set the priority of a thread,
15142 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15143 operations constitutes GNULLI, the GNULL Interface.  This interface is
15144 directly inspired from the POSIX real-time API@.
15146 If the underlying executive or OS implements the POSIX standard
15147 faithfully, the GNULL Interface maps as is to the services offered by
15148 the underlying kernel.  Otherwise, some target dependent glue code maps
15149 the services offered by the underlying kernel to the semantics expected
15150 by GNARL@.
15152 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15153 key point is that each Ada task is mapped on a thread in the underlying
15154 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15156 In addition Ada task priorities map onto the underlying thread priorities.
15157 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15159 @itemize @bullet
15160 @item
15161 The underlying scheduler is used to schedule the Ada tasks.  This
15162 makes Ada tasks as efficient as kernel threads from a scheduling
15163 standpoint.
15165 @item
15166 Interaction with code written in C containing threads is eased
15167 since at the lowest level Ada tasks and C threads map onto the same
15168 underlying kernel concept.
15170 @item
15171 When an Ada task is blocked during I/O the remaining Ada tasks are
15172 able to proceed.
15174 @item
15175 On multiprocessor systems Ada tasks can execute in parallel.
15176 @end itemize
15178 @noindent
15179 Some threads libraries offer a mechanism to fork a new process, with the
15180 child process duplicating the threads from the parent.
15181 GNAT does not
15182 support this functionality when the parent contains more than one task.
15183 @cindex Forking a new process
15185 @node Ensuring Compliance with the Real-Time Annex
15186 @subsection Ensuring Compliance with the Real-Time Annex
15187 @cindex Real-Time Systems Annex compliance
15189 @noindent
15190 Although mapping Ada tasks onto
15191 the underlying threads has significant advantages, it does create some
15192 complications when it comes to respecting the scheduling semantics
15193 specified in the real-time annex (Annex D).
15195 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15196 scheduling policy states:
15198 @quotation
15199 @emph{When the active priority of a ready task that is not running
15200 changes, or the setting of its base priority takes effect, the
15201 task is removed from the ready queue for its old active priority
15202 and is added at the tail of the ready queue for its new active
15203 priority, except in the case where the active priority is lowered
15204 due to the loss of inherited priority, in which case the task is
15205 added at the head of the ready queue for its new active priority.}
15206 @end quotation
15208 @noindent
15209 While most kernels do put tasks at the end of the priority queue when
15210 a task changes its priority, (which respects the main
15211 FIFO_Within_Priorities requirement), almost none keep a thread at the
15212 beginning of its priority queue when its priority drops from the loss
15213 of inherited priority.
15215 As a result most vendors have provided incomplete Annex D implementations.
15217 The GNAT run-time, has a nice cooperative solution to this problem
15218 which ensures that accurate FIFO_Within_Priorities semantics are
15219 respected.
15221 The principle is as follows.  When an Ada task T is about to start
15222 running, it checks whether some other Ada task R with the same
15223 priority as T has been suspended due to the loss of priority
15224 inheritance.  If this is the case, T yields and is placed at the end of
15225 its priority queue.  When R arrives at the front of the queue it
15226 executes.
15228 Note that this simple scheme preserves the relative order of the tasks
15229 that were ready to execute in the priority queue where R has been
15230 placed at the end.
15232 @node GNAT Implementation of Shared Passive Packages
15233 @section GNAT Implementation of Shared Passive Packages
15234 @cindex Shared passive packages
15236 @noindent
15237 GNAT fully implements the pragma @code{Shared_Passive} for
15238 @cindex pragma @code{Shared_Passive}
15239 the purpose of designating shared passive packages.
15240 This allows the use of passive partitions in the
15241 context described in the Ada Reference Manual; i.e., for communication
15242 between separate partitions of a distributed application using the
15243 features in Annex E.
15244 @cindex Annex E
15245 @cindex Distribution Systems Annex
15247 However, the implementation approach used by GNAT provides for more
15248 extensive usage as follows:
15250 @table @emph
15251 @item Communication between separate programs
15253 This allows separate programs to access the data in passive
15254 partitions, using protected objects for synchronization where
15255 needed. The only requirement is that the two programs have a
15256 common shared file system. It is even possible for programs
15257 running on different machines with different architectures
15258 (e.g.@: different endianness) to communicate via the data in
15259 a passive partition.
15261 @item Persistence between program runs
15263 The data in a passive package can persist from one run of a
15264 program to another, so that a later program sees the final
15265 values stored by a previous run of the same program.
15267 @end table
15269 @noindent
15270 The implementation approach used is to store the data in files. A
15271 separate stream file is created for each object in the package, and
15272 an access to an object causes the corresponding file to be read or
15273 written.
15275 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15276 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15277 set to the directory to be used for these files.
15278 The files in this directory
15279 have names that correspond to their fully qualified names. For
15280 example, if we have the package
15282 @smallexample @c ada
15283 package X is
15284   pragma Shared_Passive (X);
15285   Y : Integer;
15286   Z : Float;
15287 end X;
15288 @end smallexample
15290 @noindent
15291 and the environment variable is set to @code{/stemp/}, then the files created
15292 will have the names:
15294 @smallexample
15295 /stemp/x.y
15296 /stemp/x.z
15297 @end smallexample
15299 @noindent
15300 These files are created when a value is initially written to the object, and
15301 the files are retained until manually deleted. This provides the persistence
15302 semantics. If no file exists, it means that no partition has assigned a value
15303 to the variable; in this case the initial value declared in the package
15304 will be used. This model ensures that there are no issues in synchronizing
15305 the elaboration process, since elaboration of passive packages elaborates the
15306 initial values, but does not create the files.
15308 The files are written using normal @code{Stream_IO} access.
15309 If you want to be able
15310 to communicate between programs or partitions running on different
15311 architectures, then you should use the XDR versions of the stream attribute
15312 routines, since these are architecture independent.
15314 If active synchronization is required for access to the variables in the
15315 shared passive package, then as described in the Ada Reference Manual, the
15316 package may contain protected objects used for this purpose. In this case
15317 a lock file (whose name is @file{___lock} (three underscores)
15318 is created in the shared memory directory.
15319 @cindex @file{___lock} file (for shared passive packages)
15320 This is used to provide the required locking
15321 semantics for proper protected object synchronization.
15323 As of January 2003, GNAT supports shared passive packages on all platforms
15324 except for OpenVMS.
15326 @node Code Generation for Array Aggregates
15327 @section Code Generation for Array Aggregates
15329 @menu
15330 * Static constant aggregates with static bounds::
15331 * Constant aggregates with unconstrained nominal types::
15332 * Aggregates with static bounds::
15333 * Aggregates with non-static bounds::
15334 * Aggregates in assignment statements::
15335 @end menu
15337 @noindent
15338 Aggregates have a rich syntax and allow the user to specify the values of
15339 complex data structures by means of a single construct.  As a result, the
15340 code generated for aggregates can be quite complex and involve loops, case
15341 statements and multiple assignments.  In the simplest cases, however, the
15342 compiler will recognize aggregates whose components and constraints are
15343 fully static, and in those cases the compiler will generate little or no
15344 executable code.  The following is an outline of the code that GNAT generates
15345 for various aggregate constructs.  For further details, you will find it
15346 useful to examine the output produced by the -gnatG flag to see the expanded
15347 source that is input to the code generator.  You may also want to examine
15348 the assembly code generated at various levels of optimization.
15350 The code generated for aggregates depends on the context, the component values,
15351 and the type.  In the context of an object declaration the code generated is
15352 generally simpler than in the case of an assignment.  As a general rule, static
15353 component values and static subtypes also lead to simpler code.
15355 @node Static constant aggregates with static bounds
15356 @subsection Static constant aggregates with static bounds
15358 @noindent
15359 For the declarations:
15360 @smallexample @c ada
15361     type One_Dim is array (1..10) of integer;
15362     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15363 @end smallexample
15365 @noindent
15366 GNAT generates no executable code: the constant ar0 is placed in static memory.
15367 The same is true for constant aggregates with named associations:
15369 @smallexample @c ada
15370     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15371     Cr3 : constant One_Dim := (others => 7777);
15372 @end smallexample
15374 @noindent
15375 The same is true for multidimensional constant arrays such as:
15377 @smallexample @c ada
15378     type two_dim is array (1..3, 1..3) of integer;
15379     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15380 @end smallexample
15382 @noindent
15383 The same is true for arrays of one-dimensional arrays: the following are
15384 static:
15386 @smallexample @c ada
15387 type ar1b  is array (1..3) of boolean;
15388 type ar_ar is array (1..3) of ar1b;
15389 None  : constant ar1b := (others => false);     --  fully static
15390 None2 : constant ar_ar := (1..3 => None);       --  fully static
15391 @end smallexample
15393 @noindent
15394 However, for multidimensional aggregates with named associations, GNAT will
15395 generate assignments and loops, even if all associations are static.  The
15396 following two declarations generate a loop for the first dimension, and
15397 individual component assignments for the second dimension:
15399 @smallexample @c ada
15400 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15401 Zero2: constant two_dim := (others => (others => 0));
15402 @end smallexample
15404 @node Constant aggregates with unconstrained nominal types
15405 @subsection Constant aggregates with unconstrained nominal types
15407 @noindent
15408 In such cases the aggregate itself establishes the subtype, so that
15409 associations with @code{others} cannot be used.  GNAT determines the
15410 bounds for the actual subtype of the aggregate, and allocates the
15411 aggregate statically as well.  No code is generated for the following:
15413 @smallexample @c ada
15414     type One_Unc is array (natural range <>) of integer;
15415     Cr_Unc : constant One_Unc := (12,24,36);
15416 @end smallexample
15418 @node Aggregates with static bounds
15419 @subsection Aggregates with static bounds
15421 @noindent
15422 In all previous examples the aggregate was the initial (and immutable) value
15423 of a constant.  If the aggregate initializes a variable, then code is generated
15424 for it as a combination of individual assignments and loops over the target
15425 object.  The declarations
15427 @smallexample @c ada
15428        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15429        Cr_Var2 : One_Dim := (others > -1);
15430 @end smallexample
15432 @noindent
15433 generate the equivalent of
15435 @smallexample @c ada
15436        Cr_Var1 (1) := 2;
15437        Cr_Var1 (2) := 3;
15438        Cr_Var1 (3) := 5;
15439        Cr_Var1 (4) := 11;
15441        for I in Cr_Var2'range loop
15442           Cr_Var2 (I) := -1;
15443        end loop;
15444 @end smallexample
15446 @node Aggregates with non-static bounds
15447 @subsection Aggregates with non-static bounds
15449 @noindent
15450 If the bounds of the aggregate are not statically compatible with the bounds
15451 of the nominal subtype  of the target, then constraint checks have to be
15452 generated on the bounds.  For a multidimensional array, constraint checks may
15453 have to be applied to sub-arrays individually, if they do not have statically
15454 compatible subtypes.
15456 @node Aggregates in assignment statements
15457 @subsection Aggregates in assignment statements
15459 @noindent
15460 In general, aggregate assignment requires the construction of a temporary,
15461 and a copy from the temporary to the target of the assignment.  This is because
15462 it is not always possible to convert the assignment into a series of individual
15463 component assignments.  For example, consider the simple case:
15465 @smallexample @c ada
15466         A := (A(2), A(1));
15467 @end smallexample
15469 @noindent
15470 This cannot be converted into:
15472 @smallexample @c ada
15473         A(1) := A(2);
15474         A(2) := A(1);
15475 @end smallexample
15477 @noindent
15478 So the aggregate has to be built first in a separate location, and then
15479 copied into the target.  GNAT recognizes simple cases where this intermediate
15480 step is not required, and the assignments can be performed in place, directly
15481 into the target.  The following sufficient criteria are applied:
15483 @itemize @bullet
15484 @item
15485 The bounds of the aggregate are static, and the associations are static.
15486 @item
15487 The components of the aggregate are static constants, names of
15488 simple variables that are not renamings, or expressions not involving
15489 indexed components whose operands obey these rules.
15490 @end itemize
15492 @noindent
15493 If any of these conditions are violated, the aggregate will be built in
15494 a temporary (created either by the front-end or the code generator) and then
15495 that temporary will be copied onto the target.
15498 @node The Size of Discriminated Records with Default Discriminants
15499 @section The Size of Discriminated Records with Default Discriminants
15501 @noindent
15502 If a discriminated type @code{T} has discriminants with default values, it is
15503 possible to declare an object of this type without providing an explicit
15504 constraint:
15506 @smallexample @c ada
15507 @group
15508 type Size is range 1..100;
15510 type Rec (D : Size := 15) is record
15511    Name : String (1..D);
15512 end T;
15514 Word : Rec;
15515 @end group
15516 @end smallexample
15518 @noindent
15519 Such an object is said to be @emph{unconstrained}.
15520 The discriminant of the object
15521 can be modified by a full assignment to the object, as long as it preserves the
15522 relation between the value of the discriminant, and the value of the components
15523 that depend on it:
15525 @smallexample @c ada
15526 @group
15527 Word := (3, "yes");
15529 Word := (5, "maybe");
15531 Word := (5, "no"); -- raises Constraint_Error
15532 @end group
15533 @end smallexample
15535 @noindent
15536 In order to support this behavior efficiently, an unconstrained object is
15537 given the maximum size that any value of the type requires. In the case
15538 above, @code{Word} has storage for the discriminant and for
15539 a @code{String} of length 100.
15540 It is important to note that unconstrained objects do not require dynamic
15541 allocation. It would be an improper implementation to place on the heap those
15542 components whose size depends on discriminants. (This improper implementation
15543 was used by some Ada83 compilers, where the @code{Name} component above
15544 would have
15545 been stored as a pointer to a dynamic string). Following the principle that
15546 dynamic storage management should never be introduced implicitly,
15547 an Ada compiler should reserve the full size for an unconstrained declared
15548 object, and place it on the stack.
15550 This maximum size approach
15551 has been a source of surprise to some users, who expect the default
15552 values of the discriminants to determine the size reserved for an
15553 unconstrained object: ``If the default is 15, why should the object occupy
15554 a larger size?''
15555 The answer, of course, is that the discriminant may be later modified,
15556 and its full range of values must be taken into account. This is why the
15557 declaration:
15559 @smallexample
15560 @group
15561 type Rec (D : Positive := 15) is record
15562    Name : String (1..D);
15563 end record;
15565 Too_Large : Rec;
15566 @end group
15567 @end smallexample
15569 @noindent
15570 is flagged by the compiler with a warning:
15571 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15572 because the required size includes @code{Positive'Last}
15573 bytes. As the first example indicates, the proper approach is to declare an
15574 index type of ``reasonable'' range so that unconstrained objects are not too
15575 large.
15577 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15578 created in the heap by means of an allocator, then it is @emph{not}
15579 unconstrained:
15580 it is constrained by the default values of the discriminants, and those values
15581 cannot be modified by full assignment. This is because in the presence of
15582 aliasing all views of the object (which may be manipulated by different tasks,
15583 say) must be consistent, so it is imperative that the object, once created,
15584 remain invariant.
15586 @node Strict Conformance to the Ada Reference Manual
15587 @section Strict Conformance to the Ada Reference Manual
15589 @noindent
15590 The dynamic semantics defined by the Ada Reference Manual impose a set of
15591 run-time checks to be generated. By default, the GNAT compiler will insert many
15592 run-time checks into the compiled code, including most of those required by the
15593 Ada Reference Manual. However, there are three checks that are not enabled
15594 in the default mode for efficiency reasons: arithmetic overflow checking for
15595 integer operations (including division by zero), checks for access before
15596 elaboration on subprogram calls, and stack overflow checking (most operating
15597 systems do not perform this check by default).
15599 Strict conformance to the Ada Reference Manual can be achieved by adding
15600 three compiler options for overflow checking for integer operations
15601 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15602 calls and generic instantiations (@option{-gnatE}), and stack overflow
15603 checking (@option{-fstack-check}).
15605 Note that the result of a floating point arithmetic operation in overflow and
15606 invalid situations, when the @code{Machine_Overflows} attribute of the result
15607 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15608 case for machines compliant with the IEEE floating-point standard, but on
15609 machines that are not fully compliant with this standard, such as Alpha, the
15610 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15611 behavior (although at the cost of a significant performance penalty), so
15612 infinite and and NaN values are properly generated.
15615 @node Project File Reference
15616 @chapter Project File Reference
15618 @noindent
15619 This chapter describes the syntax and semantics of project files.
15620 Project files specify the options to be used when building a system.
15621 Project files can specify global settings for all tools,
15622 as well as tool-specific settings.
15623 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15624 for examples of use.
15626 @menu
15627 * Reserved Words::
15628 * Lexical Elements::
15629 * Declarations::
15630 * Empty declarations::
15631 * Typed string declarations::
15632 * Variables::
15633 * Expressions::
15634 * Attributes::
15635 * Project Attributes::
15636 * Attribute References::
15637 * External Values::
15638 * Case Construction::
15639 * Packages::
15640 * Package Renamings::
15641 * Projects::
15642 * Project Extensions::
15643 * Project File Elaboration::
15644 @end menu
15646 @node Reserved Words
15647 @section Reserved Words
15649 @noindent
15650 All Ada reserved words are reserved in project files, and cannot be used
15651 as variable names or project names. In addition, the following are
15652 also reserved in project files:
15654 @itemize
15655 @item @code{extends}
15657 @item @code{external}
15659 @item @code{project}
15661 @end itemize
15663 @node Lexical Elements
15664 @section Lexical Elements
15666 @noindent
15667 Rules for identifiers are the same as in Ada. Identifiers
15668 are case-insensitive.  Strings are case sensitive, except where noted.
15669 Comments have the same form as in Ada.
15671 @noindent
15672 Syntax:
15674 @smallexample
15675 simple_name ::=
15676   identifier
15678 name ::=
15679   simple_name @{. simple_name@}
15680 @end smallexample
15682 @node Declarations
15683 @section Declarations
15685 @noindent
15686 Declarations introduce new entities that denote types, variables, attributes,
15687 and packages. Some declarations can only appear immediately within a project
15688 declaration. Others can appear within a project or within a package.
15690 Syntax:
15691 @smallexample
15692 declarative_item ::=
15693   simple_declarative_item |
15694   typed_string_declaration |
15695   package_declaration
15697 simple_declarative_item ::=
15698   variable_declaration |
15699   typed_variable_declaration |
15700   attribute_declaration |
15701   case_construction |
15702   empty_declaration
15703 @end smallexample
15705 @node Empty declarations
15706 @section Empty declarations
15708 @smallexample
15709 empty_declaration ::=
15710   @b{null} ;
15711 @end smallexample
15713 An empty declaration is allowed anywhere a declaration is allowed.
15714 It has no effect.
15716 @node Typed string declarations
15717 @section Typed string declarations
15719 @noindent
15720 Typed strings are sequences of string literals. Typed strings are the only
15721 named types in project files. They are used in case constructions, where they
15722 provide support for conditional attribute definitions.
15724 Syntax:
15725 @smallexample
15726 typed_string_declaration ::=
15727   @b{type} <typed_string_>_simple_name @b{is}
15728    ( string_literal @{, string_literal@} );
15729 @end smallexample
15731 @noindent
15732 A typed string declaration can only appear immediately within a project
15733 declaration.
15735 All the string literals in a typed string declaration must be distinct.
15737 @node Variables
15738 @section Variables
15740 @noindent
15741 Variables denote values, and appear as constituents of expressions.
15743 @smallexample
15744 typed_variable_declaration ::=
15745   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15747 variable_declaration ::=
15748   <variable_>simple_name := expression;
15749 @end smallexample
15751 @noindent
15752 The elaboration of a variable declaration introduces the variable and
15753 assigns to it the value of the expression. The name of the variable is
15754 available after the assignment symbol.
15756 @noindent
15757 A typed_variable can only be declare once.
15759 @noindent
15760 a non-typed variable can be declared multiple times.
15762 @noindent
15763 Before the completion of its first declaration, the value of variable
15764 is the null string.
15766 @node Expressions
15767 @section Expressions
15769 @noindent
15770 An expression is a formula that defines a computation or retrieval of a value.
15771 In a project file the value of an expression is either a string or a list
15772 of strings. A string value in an expression is either a literal, the current
15773 value of a variable, an external value, an attribute reference, or a
15774 concatenation operation.
15776 Syntax:
15778 @smallexample
15779 expression ::=
15780   term @{& term@}
15782 term ::=
15783   string_literal |
15784   string_list |
15785   <variable_>name |
15786   external_value |
15787   attribute_reference
15789 string_literal ::=
15790   (same as Ada)
15792 string_list ::=
15793   ( <string_>expression @{ , <string_>expression @} )
15794 @end smallexample
15796 @subsection Concatenation
15797 @noindent
15798 The following concatenation functions are defined:
15800 @smallexample @c ada
15801   function "&" (X : String;      Y : String)      return String;
15802   function "&" (X : String_List; Y : String)      return String_List;
15803   function "&" (X : String_List; Y : String_List) return String_List;
15804 @end smallexample
15806 @node Attributes
15807 @section Attributes
15809 @noindent
15810 An attribute declaration defines a property of a project or package. This
15811 property can later be queried by means of an attribute reference.
15812 Attribute values are strings or string lists.
15814 Some attributes are associative arrays. These attributes are mappings whose
15815 domain is a set of strings. These attributes are declared one association
15816 at a time, by specifying a point in the domain and the corresponding image
15817 of the attribute. They may also be declared as a full associative array,
15818 getting the same associations as the corresponding attribute in an imported
15819 or extended project.
15821 Attributes that are not associative arrays are called simple attributes.
15823 Syntax:
15824 @smallexample
15825 attribute_declaration ::=
15826   full_associative_array_declaration |
15827   @b{for} attribute_designator @b{use} expression ;
15829 full_associative_array_declaration ::=
15830   @b{for} <associative_array_attribute_>simple_name @b{use}
15831   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15833 attribute_designator ::=
15834   <simple_attribute_>simple_name |
15835   <associative_array_attribute_>simple_name ( string_literal )
15836 @end smallexample
15838 @noindent
15839 Some attributes are project-specific, and can only appear immediately within
15840 a project declaration. Others are package-specific, and can only appear within
15841 the proper package.
15843 The expression in an attribute definition must be a string or a string_list.
15844 The string literal appearing in the attribute_designator of an associative
15845 array attribute is case-insensitive.
15847 @node Project Attributes
15848 @section Project Attributes
15850 @noindent
15851 The following attributes apply to a project. All of them are simple
15852 attributes.
15854 @table @code
15855 @item   Object_Dir
15856 Expression must be a path name. The attribute defines the
15857 directory in which the object files created by the build are to be placed. If
15858 not specified, object files are placed in the project directory.
15860 @item   Exec_Dir
15861 Expression must be a path name. The attribute defines the
15862 directory in which the executables created by the build are to be placed.
15863 If not specified, executables are placed in the object directory.
15865 @item  Source_Dirs
15866 Expression must be a list of path names. The attribute
15867 defines the directories in which the source files for the project are to be
15868 found. If not specified, source files are found in the project directory.
15869 If a string in the list ends with "/**", then the directory that precedes
15870 "/**" and all of its subdirectories (recursively) are included in the list
15871 of source directories.
15873 @item  Excluded_Source_Dirs
15874 Expression must be a list of strings. Each entry designates a directory that
15875 is not to be included in the list of source directories of the project.
15876 This is normally used when there are strings ending with "/**" in the value
15877 of attribute Source_Dirs.
15879 @item  Source_Files
15880 Expression must be a list of file names. The attribute
15881 defines the individual files, in the project directory, which are to be used
15882 as sources for the project. File names are path_names that contain no directory
15883 information. If the project has no sources the attribute must be declared
15884 explicitly with an empty list.
15886 @item  Excluded_Source_Files (Locally_Removed_Files)
15887 Expression must be a list of strings that are legal file names.
15888 Each file name must designate a source that would normally be a source file
15889 in the source directories of the project or, if the project file is an
15890 extending project file, inherited by the current project file. It cannot
15891 designate an immediate source that is not inherited. Each of the source files
15892 in the list are not considered to be sources of the project file: they are not
15893 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15894 Excluded_Source_Files is preferred.
15896 @item  Source_List_File
15897 Expression must a single path name. The attribute
15898 defines a text file that contains a list of source file names to be used
15899 as sources for the project
15901 @item  Library_Dir
15902 Expression must be a path name. The attribute defines the
15903 directory in which a  library is to be built.  The directory must exist, must
15904 be distinct from the project's object directory, and must be writable.
15906 @item  Library_Name
15907 Expression must be a string that is a legal file name,
15908 without extension. The attribute defines a string that is used to generate
15909 the name of the library to be built by the project.
15911 @item  Library_Kind
15912 Argument must be a string value that must be one of the
15913 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15914 string is case-insensitive. If this attribute is not specified, the library is
15915 a static library. Otherwise, the library may be dynamic or relocatable. This
15916 distinction is operating-system dependent.
15918 @item  Library_Version
15919 Expression must be a string value whose interpretation
15920 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15921 libraries as the internal name of the library (the @code{"soname"}). If the
15922 library file name (built from the @code{Library_Name}) is different from the
15923 @code{Library_Version}, then the library file will be a symbolic link to the
15924 actual file whose name will be @code{Library_Version}.
15926 @item Library_Interface
15927 Expression must be a string list. Each element of the string list
15928 must designate a unit of the project.
15929 If this attribute is present in a Library Project File, then the project
15930 file is a Stand-alone Library_Project_File.
15932 @item Library_Auto_Init
15933 Expression must be a single string "true" or "false", case-insensitive.
15934 If this attribute is present in a Stand-alone Library Project File,
15935 it indicates if initialization is automatic when the dynamic library
15936 is loaded.
15938 @item Library_Options
15939 Expression must be a string list. Indicates additional switches that
15940 are to be used when building a shared library.
15942 @item Library_GCC
15943 Expression must be a single string. Designates an alternative to "gcc"
15944 for building shared libraries.
15946 @item  Library_Src_Dir
15947 Expression must be a path name. The attribute defines the
15948 directory in which the sources of the interfaces of a Stand-alone Library will
15949 be copied.  The directory must exist, must be distinct from the project's
15950 object directory and source directories of all projects in the project tree,
15951 and must be writable.
15953 @item  Library_Src_Dir
15954 Expression must be a path name. The attribute defines the
15955 directory in which the ALI files of a Library will
15956 be copied.  The directory must exist, must be distinct from the project's
15957 object directory and source directories of all projects in the project tree,
15958 and must be writable.
15960 @item  Library_Symbol_File
15961 Expression must be a single string. Its value is the single file name of a
15962 symbol file to be created when building a stand-alone library when the
15963 symbol policy is either "compliant", "controlled" or "restricted",
15964 on platforms that support symbol control, such as VMS. When symbol policy
15965 is "direct", then a file with this name must exist in the object directory.
15967 @item   Library_Reference_Symbol_File
15968 Expression must be a single string. Its value is the path name of a
15969 reference symbol file that is read when the symbol policy is either
15970 "compliant" or "controlled", on platforms that support symbol control,
15971 such as VMS, when building a stand-alone library. The path may be an absolute
15972 path or a path relative to the project directory.
15974 @item  Library_Symbol_Policy
15975 Expression must be a single string. Its case-insensitive value can only be
15976 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15978 This attribute is not taken into account on all platforms. It controls the
15979 policy for exported symbols and, on some platforms (like VMS) that have the
15980 notions of major and minor IDs built in the library files, it controls
15981 the setting of these IDs.
15983 "autonomous" or "default": exported symbols are not controlled.
15985 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15986 it is equivalent to policy "autonomous". If there are exported symbols in
15987 the reference symbol file that are not in the object files of the interfaces,
15988 the major ID of the library is increased. If there are symbols in the
15989 object files of the interfaces that are not in the reference symbol file,
15990 these symbols are put at the end of the list in the newly created symbol file
15991 and the minor ID is increased.
15993 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15994 The library will fail to build if the exported symbols in the object files of
15995 the interfaces do not match exactly the symbol in the symbol file.
15997 "restricted": The attribute Library_Symbol_File must be defined. The library
15998 will fail to build if there are symbols in the symbol file that are not in
15999 the exported symbols of the object files of the interfaces. Additional symbols
16000 in the object files are not added to the symbol file.
16002 "direct": The attribute Library_Symbol_File must be defined and must designate
16003 an existing file in the object directory. This symbol file is passed directly
16004 to the underlying linker without any symbol processing.
16006 @item  Main
16007 Expression must be a list of strings that are legal file names.
16008 These file names designate existing compilation units in the source directory
16009 that are legal main subprograms.
16011 When a project file is elaborated, as part of the execution of a gnatmake
16012 command, one or several executables are built and placed in the Exec_Dir.
16013 If the gnatmake command does not include explicit file names, the executables
16014 that are built correspond to the files specified by this attribute.
16016 @item  Externally_Built
16017 Expression must be a single string. Its value must be either "true" of "false",
16018 case-insensitive. The default is "false". When the value of this attribute is
16019 "true", no attempt is made to compile the sources or to build the library,
16020 when the project is a library project.
16022 @item Main_Language
16023 This is a simple attribute. Its value is a string that specifies the
16024 language of the main program.
16026 @item  Languages
16027 Expression must be a string list. Each string designates
16028 a programming language that is known to GNAT. The strings are case-insensitive.
16030 @end table
16032 @node Attribute References
16033 @section Attribute References
16035 @noindent
16036 Attribute references are used to retrieve the value of previously defined
16037 attribute for a package or project.
16038 Syntax:
16039 @smallexample
16040 attribute_reference ::=
16041   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16043 attribute_prefix ::=
16044   @b{project} |
16045   <project_simple_name | package_identifier |
16046   <project_>simple_name . package_identifier
16047 @end smallexample
16049 @noindent
16050 If an attribute has not been specified for a given package or project, its
16051 value is the null string or the empty list.
16053 @node External Values
16054 @section External Values
16056 @noindent
16057 An external value is an expression whose value is obtained from the command
16058 that invoked the processing of the current project file (typically a
16059 gnatmake command).
16061 Syntax:
16062 @smallexample
16063 external_value ::=
16064   @b{external} ( string_literal [, string_literal] )
16065 @end smallexample
16067 @noindent
16068 The first string_literal is the string to be used on the command line or
16069 in the environment to specify the external value. The second string_literal,
16070 if present, is the default to use if there is no specification for this
16071 external value either on the command line or in the environment.
16073 @node Case Construction
16074 @section Case Construction
16076 @noindent
16077 A case construction supports attribute and variable declarations that depend
16078 on the value of a previously declared variable.
16080 Syntax:
16081 @smallexample
16082 case_construction ::=
16083   @b{case} <typed_variable_>name @b{is}
16084     @{case_item@}
16085   @b{end case} ;
16087 case_item ::=
16088   @b{when} discrete_choice_list =>
16089     @{case_construction |
16090       attribute_declaration |
16091       variable_declaration |
16092       empty_declaration@}
16094 discrete_choice_list ::=
16095   string_literal @{| string_literal@} |
16096     @b{others}
16097 @end smallexample
16099 @noindent
16100 Inside a case construction, variable declarations must be for variables that
16101 have already been declared before the case construction.
16103 All choices in a choice list must be distinct. The choice lists of two
16104 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16105 alternatives do not need to include all values of the type. An @code{others}
16106 choice must appear last in the list of alternatives.
16108 @node Packages
16109 @section Packages
16111 @noindent
16112 A package provides a grouping of variable declarations and attribute
16113 declarations to be used when invoking various GNAT tools. The name of
16114 the package indicates the tool(s) to which it applies.
16115 Syntax:
16117 @smallexample
16118 package_declaration ::=
16119   package_spec | package_renaming
16121 package_spec ::=
16122   @b{package} package_identifier @b{is}
16123     @{simple_declarative_item@}
16124   @b{end} package_identifier ;
16126 package_identifier ::=
16127   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16128   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16129   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16130 @end smallexample
16132 @subsection Package Naming
16134 @noindent
16135 The attributes of a @code{Naming} package specifies the naming conventions
16136 that apply to the source files in a project. When invoking other GNAT tools,
16137 they will use the sources in the source directories that satisfy these
16138 naming conventions.
16140 The following attributes apply to a @code{Naming} package:
16142 @table @code
16143 @item Casing
16144 This is a simple attribute whose value is a string. Legal values of this
16145 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16146 These strings are themselves case insensitive.
16148 @noindent
16149 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16151 @item Dot_Replacement
16152 This is a simple attribute whose string value satisfies the following
16153 requirements:
16155 @itemize @bullet
16156 @item It must not be empty
16157 @item It cannot start or end with an alphanumeric character
16158 @item It cannot be a single underscore
16159 @item It cannot start with an underscore followed by an alphanumeric
16160 @item It cannot contain a dot @code{'.'} if longer than one character
16161 @end itemize
16163 @noindent
16164 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16166 @item Spec_Suffix
16167 This is an associative array attribute, defined on language names,
16168 whose image is a string that must satisfy the following
16169 conditions:
16171 @itemize @bullet
16172 @item It must not be empty
16173 @item It cannot start with an alphanumeric character
16174 @item It cannot start with an underscore followed by an alphanumeric character
16175 @end itemize
16177 @noindent
16178 For Ada, the attribute denotes the suffix used in file names that contain
16179 library unit declarations, that is to say units that are package and
16180 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16181 specified, then the default is @code{".ads"}.
16183 For C and C++, the attribute denotes the suffix used in file names that
16184 contain prototypes.
16186 @item Body_Suffix
16187 This is an associative array attribute defined on language names,
16188 whose image is a string that must satisfy the following
16189 conditions:
16191 @itemize @bullet
16192 @item It must not be empty
16193 @item It cannot start with an alphanumeric character
16194 @item It cannot start with an underscore followed by an alphanumeric character
16195 @item It cannot be a suffix of @code{Spec_Suffix}
16196 @end itemize
16198 @noindent
16199 For Ada, the attribute denotes the suffix used in file names that contain
16200 library bodies, that is to say units that are package and subprogram bodies.
16201 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16202 @code{".adb"}.
16204 For C and C++, the attribute denotes the suffix used in file names that contain
16205 source code.
16207 @item Separate_Suffix
16208 This is a simple attribute whose value satisfies the same conditions as
16209 @code{Body_Suffix}.
16211 This attribute is specific to Ada. It denotes the suffix used in file names
16212 that contain separate bodies. If it is not specified, then it defaults to same
16213 value as @code{Body_Suffix ("Ada")}.
16215 @item Spec
16216 This is an associative array attribute, specific to Ada, defined over
16217 compilation unit names. The image is a string that is the name of the file
16218 that contains that library unit. The file name is case sensitive if the
16219 conventions of the host operating system require it.
16221 @item Body
16222 This is an associative array attribute, specific to Ada, defined over
16223 compilation unit names. The image is a string that is the name of the file
16224 that contains the library unit body for the named unit. The file name is case
16225 sensitive if the conventions of the host operating system require it.
16227 @item Specification_Exceptions
16228 This is an associative array attribute defined on language names,
16229 whose value is a list of strings.
16231 This attribute is not significant for Ada.
16233 For C and C++, each string in the list denotes the name of a file that
16234 contains prototypes, but whose suffix is not necessarily the
16235 @code{Spec_Suffix} for the language.
16237 @item Implementation_Exceptions
16238 This is an associative array attribute defined on language names,
16239 whose value is a list of strings.
16241 This attribute is not significant for Ada.
16243 For C and C++, each string in the list denotes the name of a file that
16244 contains source code, but whose suffix is not necessarily the
16245 @code{Body_Suffix} for the language.
16246 @end table
16248 The following attributes of package @code{Naming} are obsolescent. They are
16249 kept as synonyms of other attributes for compatibility with previous versions
16250 of the Project Manager.
16252 @table @code
16253 @item Specification_Suffix
16254 This is a synonym of @code{Spec_Suffix}.
16256 @item Implementation_Suffix
16257 This is a synonym of @code{Body_Suffix}.
16259 @item Specification
16260 This is a synonym of @code{Spec}.
16262 @item Implementation
16263 This is a synonym of @code{Body}.
16264 @end table
16266 @subsection package Compiler
16268 @noindent
16269 The attributes of the @code{Compiler} package specify the compilation options
16270 to be used by the underlying compiler.
16272 @table @code
16273 @item  Default_Switches
16274 This is an associative array attribute. Its
16275 domain is a set of language names. Its range is a string list that
16276 specifies the compilation options to be used when compiling a component
16277 written in that language, for which no file-specific switches have been
16278 specified.
16280 @item  Switches
16281 This is an associative array attribute. Its domain is
16282 a set of file names. Its range is a string list that specifies the
16283 compilation options to be used when compiling the named file. If a file
16284 is not specified in the Switches attribute, it is compiled with the
16285 options specified by Default_Switches of its language, if defined.
16287 @item  Local_Configuration_Pragmas.
16288 This is a simple attribute, whose
16289 value is a path name that designates a file containing configuration pragmas
16290 to be used for all invocations of the compiler for immediate sources of the
16291 project.
16292 @end table
16294 @subsection package Builder
16296 @noindent
16297 The attributes of package @code{Builder} specify the compilation, binding, and
16298 linking options to be used when building an executable for a project. The
16299 following attributes apply to package @code{Builder}:
16301 @table @code
16302 @item Default_Switches
16303 This is an associative array attribute. Its
16304 domain is a set of language names. Its range is a string list that
16305 specifies options to be used when building a main
16306 written in that language, for which no file-specific switches have been
16307 specified.
16309 @item Switches
16310 This is an associative array attribute. Its domain is
16311 a set of file names. Its range is a string list that specifies
16312 options to be used when building the named main file. If a main file
16313 is not specified in the Switches attribute, it is built with the
16314 options specified by Default_Switches of its language, if defined.
16316 @item Global_Configuration_Pragmas
16317 This is a simple attribute, whose
16318 value is a path name that designates a file that contains configuration pragmas
16319 to be used in every build of an executable. If both local and global
16320 configuration pragmas are specified, a compilation makes use of both sets.
16323 @item Executable
16324 This is an associative array attribute. Its domain is
16325 a set of main source file names. Its range is a simple string that specifies
16326 the executable file name to be used when linking the specified main source.
16327 If a main source is not specified in the Executable attribute, the executable
16328 file name is deducted from the main source file name.
16329 This attribute has no effect if its value is the empty string.
16331 @item Executable_Suffix
16332 This is a simple attribute whose value is the suffix to be added to
16333 the executables that don't have an attribute Executable specified.
16334 @end table
16336 @subsection package Gnatls
16338 @noindent
16339 The attributes of package @code{Gnatls} specify the tool options to be used
16340 when invoking the library browser @command{gnatls}.
16341 The following attributes apply to package @code{Gnatls}:
16343 @table @code
16344 @item Switches
16345 This is a single attribute with a string list value. Each nonempty string
16346 in the list is an option when invoking @code{gnatls}.
16347 @end table
16349 @subsection package Binder
16351 @noindent
16352 The attributes of package @code{Binder} specify the options to be used
16353 when invoking the binder in the construction of an executable.
16354 The following attributes apply to package @code{Binder}:
16356 @table @code
16357 @item     Default_Switches
16358 This is an associative array attribute. Its
16359 domain is a set of language names. Its range is a string list that
16360 specifies options to be used when binding a main
16361 written in that language, for which no file-specific switches have been
16362 specified.
16364 @item Switches
16365 This is an associative array attribute. Its domain is
16366 a set of file names. Its range is a string list that specifies
16367 options to be used when binding the named main file. If a main file
16368 is not specified in the Switches attribute, it is bound with the
16369 options specified by Default_Switches of its language, if defined.
16370 @end table
16372 @subsection package Linker
16374 @noindent
16375 The attributes of package @code{Linker} specify the options to be used when
16376 invoking the linker in the construction of an executable.
16377 The following attributes apply to package @code{Linker}:
16379 @table @code
16380 @item     Default_Switches
16381 This is an associative array attribute. Its
16382 domain is a set of language names. Its range is a string list that
16383 specifies options to be used when linking a main
16384 written in that language, for which no file-specific switches have been
16385 specified.
16387 @item Switches
16388 This is an associative array attribute. Its domain is
16389 a set of file names. Its range is a string list that specifies
16390 options to be used when linking the named main file. If a main file
16391 is not specified in the Switches attribute, it is linked with the
16392 options specified by Default_Switches of its language, if defined.
16394 @item  Linker_Options
16395 This is a string list attribute. Its value specifies additional options that
16396 be given to the linker when linking an executable. This attribute is not
16397 used in the main project, only in projects imported directly or indirectly.
16399 @end table
16401 @subsection package Cross_Reference
16403 @noindent
16404 The attributes of package @code{Cross_Reference} specify the tool options
16405 to be used
16406 when invoking the library tool @command{gnatxref}.
16407 The following attributes apply to package @code{Cross_Reference}:
16409 @table @code
16410 @item     Default_Switches
16411 This is an associative array attribute. Its
16412 domain is a set of language names. Its range is a string list that
16413 specifies options to be used when calling @command{gnatxref} on a source
16414 written in that language, for which no file-specific switches have been
16415 specified.
16417 @item Switches
16418 This is an associative array attribute. Its domain is
16419 a set of file names. Its range is a string list that specifies
16420 options to be used when calling @command{gnatxref} on the named main source.
16421 If a source is not specified in the Switches attribute, @command{gnatxref} will
16422 be called with the options specified by Default_Switches of its language,
16423 if defined.
16424 @end table
16426 @subsection package   Finder
16428 @noindent
16429 The attributes of package @code{Finder} specify the tool options to be used
16430 when invoking the search tool @command{gnatfind}.
16431 The following attributes apply to package @code{Finder}:
16433 @table @code
16434 @item     Default_Switches
16435 This is an associative array attribute. Its
16436 domain is a set of language names. Its range is a string list that
16437 specifies options to be used when calling @command{gnatfind} on a source
16438 written in that language, for which no file-specific switches have been
16439 specified.
16441 @item Switches
16442 This is an associative array attribute. Its domain is
16443 a set of file names. Its range is a string list that specifies
16444 options to be used when calling @command{gnatfind} on the named main source.
16445 If a source is not specified in the Switches attribute, @command{gnatfind} will
16446 be called with the options specified by Default_Switches of its language,
16447 if defined.
16448 @end table
16450 @subsection package Pretty_Printer
16452 @noindent
16453 The attributes of package @code{Pretty_Printer}
16454 specify the tool options to be used
16455 when invoking the formatting tool @command{gnatpp}.
16456 The following attributes apply to package @code{Pretty_Printer}:
16458 @table @code
16459 @item     Default_switches
16460 This is an associative array attribute. Its
16461 domain is a set of language names. Its range is a string list that
16462 specifies options to be used when calling @command{gnatpp} on a source
16463 written in that language, for which no file-specific switches have been
16464 specified.
16466 @item Switches
16467 This is an associative array attribute. Its domain is
16468 a set of file names. Its range is a string list that specifies
16469 options to be used when calling @command{gnatpp} on the named main source.
16470 If a source is not specified in the Switches attribute, @command{gnatpp} will
16471 be called with the options specified by Default_Switches of its language,
16472 if defined.
16473 @end table
16475 @subsection package gnatstub
16477 @noindent
16478 The attributes of package @code{gnatstub}
16479 specify the tool options to be used
16480 when invoking the tool @command{gnatstub}.
16481 The following attributes apply to package @code{gnatstub}:
16483 @table @code
16484 @item     Default_switches
16485 This is an associative array attribute. Its
16486 domain is a set of language names. Its range is a string list that
16487 specifies options to be used when calling @command{gnatstub} on a source
16488 written in that language, for which no file-specific switches have been
16489 specified.
16491 @item Switches
16492 This is an associative array attribute. Its domain is
16493 a set of file names. Its range is a string list that specifies
16494 options to be used when calling @command{gnatstub} on the named main source.
16495 If a source is not specified in the Switches attribute, @command{gnatpp} will
16496 be called with the options specified by Default_Switches of its language,
16497 if defined.
16498 @end table
16500 @subsection package Eliminate
16502 @noindent
16503 The attributes of package @code{Eliminate}
16504 specify the tool options to be used
16505 when invoking the tool @command{gnatelim}.
16506 The following attributes apply to package @code{Eliminate}:
16508 @table @code
16509 @item     Default_switches
16510 This is an associative array attribute. Its
16511 domain is a set of language names. Its range is a string list that
16512 specifies options to be used when calling @command{gnatelim} on a source
16513 written in that language, for which no file-specific switches have been
16514 specified.
16516 @item Switches
16517 This is an associative array attribute. Its domain is
16518 a set of file names. Its range is a string list that specifies
16519 options to be used when calling @command{gnatelim} on the named main source.
16520 If a source is not specified in the Switches attribute, @command{gnatelim} will
16521 be called with the options specified by Default_Switches of its language,
16522 if defined.
16523 @end table
16525 @subsection package Metrics
16527 @noindent
16528 The attributes of package @code{Metrics}
16529 specify the tool options to be used
16530 when invoking the tool @command{gnatmetric}.
16531 The following attributes apply to package @code{Metrics}:
16533 @table @code
16534 @item     Default_switches
16535 This is an associative array attribute. Its
16536 domain is a set of language names. Its range is a string list that
16537 specifies options to be used when calling @command{gnatmetric} on a source
16538 written in that language, for which no file-specific switches have been
16539 specified.
16541 @item Switches
16542 This is an associative array attribute. Its domain is
16543 a set of file names. Its range is a string list that specifies
16544 options to be used when calling @command{gnatmetric} on the named main source.
16545 If a source is not specified in the Switches attribute, @command{gnatmetric}
16546 will be called with the options specified by Default_Switches of its language,
16547 if defined.
16548 @end table
16550 @subsection  package IDE
16552 @noindent
16553 The attributes of package @code{IDE} specify the options to be used when using
16554 an Integrated Development Environment such as @command{GPS}.
16556 @table @code
16557 @item Remote_Host
16558 This is a simple attribute. Its value is a string that designates the remote
16559 host in a cross-compilation environment, to be used for remote compilation and
16560 debugging. This field should not be specified when running on the local
16561 machine.
16563 @item Program_Host
16564 This is a simple attribute. Its value is a string that specifies the
16565 name of IP address of the embedded target in a cross-compilation environment,
16566 on which the program should execute.
16568 @item Communication_Protocol
16569 This is a simple string attribute. Its value is the name of the protocol
16570 to use to communicate with the target in a cross-compilation environment,
16571 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16573 @item Compiler_Command
16574 This is an associative array attribute, whose domain is a language name. Its
16575 value is  string that denotes the command to be used to invoke the compiler.
16576 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16577 gnatmake, in particular in the handling of switches.
16579 @item Debugger_Command
16580 This is simple attribute, Its value is a string that specifies the name of
16581 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16583 @item Default_Switches
16584 This is an associative array attribute. Its indexes are the name of the
16585 external tools that the GNAT Programming System (GPS) is supporting. Its
16586 value is a list of switches to use when invoking that tool.
16588 @item  Gnatlist
16589 This is a simple attribute.  Its value is a string that specifies the name
16590 of the @command{gnatls} utility to be used to retrieve information about the
16591 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16593 @item VCS_Kind
16594 This is a simple attribute. Its value is a string used to specify the
16595 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16596 ClearCase or Perforce.
16598 @item VCS_File_Check
16599 This is a simple attribute. Its value is a string that specifies the
16600 command used by the VCS to check the validity of a file, either
16601 when the user explicitly asks for a check, or as a sanity check before
16602 doing the check-in.
16604 @item VCS_Log_Check
16605 This is a simple attribute. Its value is a string that specifies
16606 the command used by the VCS to check the validity of a log file.
16608 @item VCS_Repository_Root
16609 The VCS repository root path. This is used to create tags or branches
16610 of the repository. For subversion the value should be the @code{URL}
16611 as specified to check-out the working copy of the repository.
16613 @item VCS_Patch_Root
16614 The local root directory to use for building patch file. All patch chunks
16615 will be relative to this path. The root project directory is used if
16616 this value is not defined.
16618 @end table
16620 @node Package Renamings
16621 @section Package Renamings
16623 @noindent
16624 A package can be defined by a renaming declaration. The new package renames
16625 a package declared in a different project file, and has the same attributes
16626 as the package it renames.
16627 Syntax:
16628 @smallexample
16629 package_renaming ::==
16630   @b{package} package_identifier @b{renames}
16631        <project_>simple_name.package_identifier ;
16632 @end smallexample
16634 @noindent
16635 The package_identifier of the renamed package must be the same as the
16636 package_identifier. The project whose name is the prefix of the renamed
16637 package must contain a package declaration with this name. This project
16638 must appear in the context_clause of the enclosing project declaration,
16639 or be the parent project of the enclosing child project.
16641 @node Projects
16642 @section Projects
16644 @noindent
16645 A project file specifies a set of rules for constructing a software system.
16646 A project file can be self-contained, or depend on other project files.
16647 Dependencies are expressed through a context clause that names other projects.
16649 Syntax:
16651 @smallexample
16652 project ::=
16653   context_clause project_declaration
16655 project_declaration ::=
16656   simple_project_declaration | project_extension
16658 simple_project_declaration ::=
16659   @b{project} <project_>simple_name @b{is}
16660     @{declarative_item@}
16661   @b{end} <project_>simple_name;
16663 context_clause ::=
16664   @{with_clause@}
16666 with_clause ::=
16667   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16669 path_name ::=
16670    string_literal
16671 @end smallexample
16673 @noindent
16674 A path name denotes a project file. A path name can be absolute or relative.
16675 An absolute path name includes a sequence of directories, in the syntax of
16676 the host operating system, that identifies uniquely the project file in the
16677 file system. A relative path name identifies the project file, relative
16678 to the directory that contains the current project, or relative to a
16679 directory listed in the environment variable ADA_PROJECT_PATH.
16680 Path names are case sensitive if file names in the host operating system
16681 are case sensitive.
16683 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16684 directory names separated by colons (semicolons on Windows).
16686 A given project name can appear only once in a context_clause.
16688 It is illegal for a project imported by a context clause to refer, directly
16689 or indirectly, to the project in which this context clause appears (the
16690 dependency graph cannot contain cycles), except when one of the with_clause
16691 in the cycle is a @code{limited with}.
16693 @node Project Extensions
16694 @section Project Extensions
16696 @noindent
16697 A project extension introduces a new project, which inherits the declarations
16698 of another project.
16699 Syntax:
16700 @smallexample
16702 project_extension ::=
16703   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16704     @{declarative_item@}
16705   @b{end} <project_>simple_name;
16706 @end smallexample
16708 @noindent
16709 The project extension declares a child project. The child project inherits
16710 all the declarations and all the files of the parent project, These inherited
16711 declaration can be overridden in the child project, by means of suitable
16712 declarations.
16714 @node Project File Elaboration
16715 @section Project File Elaboration
16717 @noindent
16718 A project file is processed as part of the invocation of a gnat tool that
16719 uses the project option. Elaboration of the process file consists in the
16720 sequential elaboration of all its declarations. The computed values of
16721 attributes and variables in the project are then used to establish the
16722 environment in which the gnat tool will execute.
16724 @node Obsolescent Features
16725 @chapter Obsolescent Features
16727 @noindent
16728 This chapter describes features that are provided by GNAT, but are
16729 considered obsolescent since there are preferred ways of achieving
16730 the same effect. These features are provided solely for historical
16731 compatibility purposes.
16733 @menu
16734 * pragma No_Run_Time::
16735 * pragma Ravenscar::
16736 * pragma Restricted_Run_Time::
16737 @end menu
16739 @node pragma No_Run_Time
16740 @section pragma No_Run_Time
16742 The pragma @code{No_Run_Time} is used to achieve an affect similar
16743 to the use of the "Zero Foot Print" configurable run time, but without
16744 requiring a specially configured run time. The result of using this
16745 pragma, which must be used for all units in a partition, is to restrict
16746 the use of any language features requiring run-time support code. The
16747 preferred usage is to use an appropriately configured run-time that
16748 includes just those features that are to be made accessible.
16750 @node pragma Ravenscar
16751 @section pragma Ravenscar
16753 The pragma @code{Ravenscar} has exactly the same effect as pragma
16754 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16755 is part of the new Ada 2005 standard.
16757 @node pragma Restricted_Run_Time
16758 @section pragma Restricted_Run_Time
16760 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16761 pragma @code{Profile (Restricted)}. The latter usage is
16762 preferred since the Ada 2005 pragma @code{Profile} is intended for
16763 this kind of implementation dependent addition.
16765 @include fdl.texi
16766 @c GNU Free Documentation License
16768 @node Index,,GNU Free Documentation License, Top
16769 @unnumbered Index
16771 @printindex cp
16773 @contents
16775 @bye